instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I am designing a contact management system and have come across an interesting issue regarding modeling geographic locations in a consistent way. I would like to be able to record locations associated with a particular person (mailing address(es) for work, school, home, etc.) My thought is to create a table of locales such as the following:</p> <p><strong>Locales (ID, LocationName, ParentID)</strong> where autonomous locations (such as countries, e.g. USA) are parents of themselves. This way I can have an arbitrarily deep nesting of 'political units' (COUNTRY > STATE > CITY or COUNTRY > STATE > CITY > UNIVERSITY). Some queries will necessarily involve recursion.</p> <p>I would appreciate any other recommendations or perhaps advice regarding predictable issues that I am likely to encounter with such a scheme.</p>
<p>You might want to have a look at Freebase.com as a site that's had some open discussion about what a "location" means and what it means when a location is included in another. These sorts of questions can generate a lot of discussion.</p> <p>For example, there is the obvious "geographic nesting", but there are less obvious logical nestings. For example, in a strictly geographic sense, Vatican City is nested within Italy. But it's not nested politically. Similarly, if your user is located in a research center that belongs to a university, but isn't located on the University's property, do you model that relationship or not?</p>
<p>I'm modeling an apps for global users and I have the same problems, but I think that this approach could already be in use in many enterprise. But why this problem don't have an universal solution? Or, has this problem one best solution that can be the start point or anybody in the world need think in a solution for it since beginnig? In IT, we are making the same things any times and in many places, unfortunately. For exemplo, who are not have made more than one user, customer or product's database? And the worst, all enterprise in the world has made it. I think that could have universal solutions for universal problems.</p>
7,298
<p>i have scenario where i have to provide my own control template for a few WPF controls - i.e. GridViewHeader. when you take a look at control template for GridViewHEader in blend, it is agregated from several other controls, which in some cases are styled for that control only - i.e. this splitter between columns. those templates, obviously are resources hidden somewhere in system...dll (or somewhwere in themes dll's). so, my question is - is there a way to reference those predefined templates? so far, i've ended up having my own copies of them in my resources, but i don't like that approach.</p> <p>here is sample scenario: i have a GridViewColumnHeader:</p> <pre><code> &lt;Style TargetType="{x:Type GridViewColumnHeader}" x:Key="gridViewColumnStyle"&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"/&gt; &lt;Setter Property="VerticalContentAlignment" Value="Stretch"/&gt; &lt;Setter Property="Background" Value="{StaticResource GridViewHeaderBackgroundColor}"/&gt; &lt;Setter Property="BorderBrush" Value="{StaticResource GridViewHeaderForegroundColor}"/&gt; &lt;Setter Property="BorderThickness" Value="0"/&gt; &lt;Setter Property="Padding" Value="2,0,2,0"/&gt; &lt;Setter Property="Foreground" Value="{StaticResource GridViewHeaderForegroundColor}"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type GridViewColumnHeader}"&gt; &lt;Grid SnapsToDevicePixels="true" Tag="Header" Name="Header"&gt; &lt;ContentPresenter Name="HeaderContent" Margin="0,0,0,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /&gt; &lt;Canvas&gt; &lt;Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}"/&gt; &lt;/Canvas&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="true"&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsPressed" Value="true"&gt; &lt;Setter TargetName="HeaderContent" Property="Margin" Value="1,1,0,0"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="Height" Value="Auto"&gt; &lt;Setter Property="MinHeight" Value="20"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>so far - nothing interesting, but say, i want to add some extra functionality straight in the template - i'd leave cotnent presenter as is, add my controls next to it and i'd like to leave Thumb with defaults from framework. i've found themes provided by microsoft <a href="http://msdn.microsoft.com/en-us/library/aa358533.aspx" rel="nofollow noreferrer">here</a>:</p> <p>the theme for Thumb looks like that:</p> <pre><code>&lt;Style x:Key="GridViewColumnHeaderGripper" TargetType="{x:Type Thumb}"&gt; &lt;Setter Property="Canvas.Right" Value="-9"/&gt; &lt;Setter Property="Width" Value="18"/&gt; &lt;Setter Property="Height" Value="{Binding Path=ActualHeight,RelativeSource={RelativeSource TemplatedParent}}"/&gt; &lt;Setter Property="Padding" Value="0"/&gt; &lt;Setter Property="Background" Value="{StaticResource GridViewColumnHeaderBorderBackground}"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Thumb}"&gt; &lt;Border Padding="{TemplateBinding Padding}" Background="Transparent"&gt; &lt;Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>so far - i have to copy &amp; paste that style, while i'd prefer to get reference to it from resources.</p>
<p>Referencing internal resources that are 100% subject to change isn't serviceable - better to just copy it. </p>
<p>It is possible to reference them, but as paulbetts said, its not recommended as they could change. Also consider if what you are doing is truely 'correct'. Can you edit your question to explain why you need to do this exactly?</p>
9,478
<p>Let's take the code</p> <pre><code>int a, b, c; ... if ((a + b) &gt; C) </code></pre> <p>If we add the values of a and b and the sum exceeds the maximum value of an int, will the integrity of the comparison be compromised? I was thinking that there might be an implicit up cast or overflow bit check and that will be factored into the evaluation of this expression.</p>
<p>C will do no such thing. It will silently overflow and lead to a possibly incorrect comparison. You can up-cast yourself, but it will not be done automatically.</p>
<p>I believe this might be platform specific. Check the C documentation on how overflows are handled...</p> <p>Ah, yes, and the upcast will not happen automatically...</p>
7,330
<p>I'm getting a <code>NoSuchMethodError</code> error when running my Java program. What's wrong and how do I fix it?</p>
<p>Without any more information it is difficult to pinpoint the problem, but the root cause is that you most likely have compiled a class against a different version of the class that is missing a method, than the one you are using when running it.</p> <p>Look at the stack trace ... If the exception appears when calling a method on an object in a library, you are most likely using separate versions of the library when compiling and running. Make sure you have the right version both places.</p> <p>If the exception appears when calling a method on objects instantiated by classes <em>you</em> made, then your build process seems to be faulty. Make sure the class files that you are actually running are updated when you compile.</p>
<p>If your file name is different than the class name which contain main method then it may be the possibility that this error may cause.</p>
5,562
<p>Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements? </p>
<p>The <a href="https://docs.python.org/3/library/dis.html" rel="noreferrer"><code>dis</code></a> module disassembles the byte code for a function and is useful to see the difference between tuples and lists.</p> <p>In this case, you can see that accessing an element generates identical code, but that assigning a tuple is much faster than assigning a list.</p> <pre><code>&gt;&gt;&gt; def a(): ... x=[1,2,3,4,5] ... y=x[2] ... &gt;&gt;&gt; def b(): ... x=(1,2,3,4,5) ... y=x[2] ... &gt;&gt;&gt; import dis &gt;&gt;&gt; dis.dis(a) 2 0 LOAD_CONST 1 (1) 3 LOAD_CONST 2 (2) 6 LOAD_CONST 3 (3) 9 LOAD_CONST 4 (4) 12 LOAD_CONST 5 (5) 15 BUILD_LIST 5 18 STORE_FAST 0 (x) 3 21 LOAD_FAST 0 (x) 24 LOAD_CONST 2 (2) 27 BINARY_SUBSCR 28 STORE_FAST 1 (y) 31 LOAD_CONST 0 (None) 34 RETURN_VALUE &gt;&gt;&gt; dis.dis(b) 2 0 LOAD_CONST 6 ((1, 2, 3, 4, 5)) 3 STORE_FAST 0 (x) 3 6 LOAD_FAST 0 (x) 9 LOAD_CONST 2 (2) 12 BINARY_SUBSCR 13 STORE_FAST 1 (y) 16 LOAD_CONST 0 (None) 19 RETURN_VALUE </code></pre>
<p>The main reason for Tuple to be very efficient in reading is because it's immutable. </p> <h2>Why immutable objects are easy to read?</h2> <p>The reason is tuples can be stored in the memory cache, unlike lists. The program always read from the lists memory location as it is mutable (can change any time).</p>
9,417
<p>I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring.</p> <p>Example:</p> <pre><code>// Updated to be correct, thanks @Apocalisp ^foo.*(?&lt;!bar)$ </code></pre> <p>Should match anything that starts with "foo" and doesn't end with "bar". I know about the [^...] syntax, but I can't find anything that will do that for a string instead of single characters. </p> <p>I am specifically trying to do this for Java's regex, but I've run into this before so answers for other regex engines would be great too. </p> <p>Thanks to @Kibbee for verifying that this works in C# as well. </p>
<p>I think in this case you want <strong>negative lookbehind</strong>, like so:</p> <pre><code>foo.*(?&lt;!bar) </code></pre>
<p>As other commenters said, you need a negative lookahead. In Java you can use this pattern:</p> <pre><code>"^first_string(?!.?second_string)\\z" </code></pre> <ul> <li>^ - ensures that string starts with first_string</li> <li>\z - ensures that string ends with second_string</li> <li>(?!.?second_string) - means that first_string can't be followed by second_string</li> </ul>
6,462
<p>The following XHTML code is not working:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;link rel="stylesheet" type="text/css" href="/dojotoolkit/dijit/themes/tundra/tundra.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="/dojotoolkit/dojo/resources/dojo.css" /&gt; &lt;script type="text/javascript" src="/dojotoolkit/dojo/dojo.js" djConfig="parseOnLoad: true" /&gt; &lt;script type="text/javascript"&gt; dojo.require("dijit.form.ValidationTextBox"); dojo.require("dojo.parser"); &lt;/script&gt; &lt;/head&gt; &lt;body class="nihilo"&gt; &lt;input type="text" dojoType="dijit.form.ValidationTextBox" size="30" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In Firebug I get the following error message:</p> <blockquote> <p>[Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: <a href="http://localhost:21000/dojotoolkit/dojo/dojo.js" rel="nofollow noreferrer">http://localhost:21000/dojotoolkit/dojo/dojo.js</a> :: anonymous :: line 319" data: no] <a href="http://localhost:21000/dojotoolkit/dojo/dojo.js" rel="nofollow noreferrer">http://localhost:21000/dojotoolkit/dojo/dojo.js</a> Line 319</p> </blockquote> <p>Any idea what is wrong?</p>
<p>The problem seams to be the ending of the file...</p> <ul> <li>If I name the file <a href="http://www.tasix.ch/Greter/test2.html" rel="nofollow noreferrer">test2.html</a> everything works.</li> <li>If I name the file <a href="http://www.tasix.ch/Greter/test2.xhtml" rel="nofollow noreferrer">test2.xhtml</a> I get the error message.</li> </ul> <p>The diverence between the two seams to be the Content-Type in the response header from apache.</p> <ul> <li>For .html it is Content-Type text/html; charset=ISO-8859-1</li> <li>For .xhtml it is Content-Type application/xhtml+xml</li> </ul>
<p>Well, what is dojo.js doing at line 319?</p>
7,097
<p>Code:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;Unusual Array Lengths!&lt;/title&gt; &lt;script type="text/javascript"&gt; var arrayList = new Array(); arrayList = [1, 2, 3, 4, 5, ]; alert(arrayList.length); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Notice the extra comma in the array declaration. The code above gives different outputs for various browsers:</p> <p>Safari: 5</p> <p>Firefox: 5</p> <p>IE: 6</p> <p>The extra comma in the array is being ignored by Safari and FF while IE treats it as another object in the array.</p> <p>On some search, I have found mixed opinions about which answer is correct. Most people say that IE is correct but then Safari is also doing the same thing as Firefox. I haven't tested this on other browsers like Opera but I assume that there are discrepancies.</p> <p>My questions:</p> <p>i. <strong>Which one of these is correct?</strong></p> <p><em>Edit: By general consensus (and ECMAScript guidelines) we assume that IE is again at fault.</em> </p> <p>ii. <strong>Are there any other such Javascript browser quirks that I should be wary of?</strong></p> <p><em>Edit: Yes, there are loads of Javascript quirks. <a href="http://www.quirksmode.org" rel="nofollow noreferrer">www.quirksmode.org</a> is a good resource for the same.</em></p> <p>iii. <strong>How do I avoid errors such as these?</strong></p> <p><em>Edit: Use <a href="http://www.jslint.com/" rel="nofollow noreferrer">JSLint</a> to validate your javascript. Or, use some external <a href="http://openjsan.org/" rel="nofollow noreferrer">libraries</a>. Or, <a href="https://stackoverflow.com/questions/29053/javascript-browser-quirks-arraylength#29062">sanitize</a> your code.</em></p> <p><em>Thanks to <a href="https://stackoverflow.com/users/3069/damien-b">DamienB</a>, <a href="https://stackoverflow.com/users/1790/jasonbunting">JasonBunting</a>, <a href="https://stackoverflow.com/users/2168/john">John</a> and <a href="https://stackoverflow.com/users/1968/konrad-rudolph">Konrad Rudolph</a> for their inputs.</em></p>
<p>It seems to me that the Firefox behavior is correct. What is the value of the 6th value in IE (sorry I don't have it handy to test). Since there is no actual value provided, I imagine it's filling it with something like 'null' which certainly doesn't seem to be what you intended to have happen when you created the array.</p> <p>At the end of the day though, it doesn't really matter which is "correct" since the reality is that either you are targeting only one browser, in which case you can ignore what the others do, or you are targeting multiple browsers in which case your code needs to work on all of them. In this case the obvious solution is to never include the dangling comma in an array initializer.</p> <p>If you have problems avoiding it (e.g. for some reason you have developed a (bad, imho) habit of including it) and other problems like this, then something like <a href="http://www.jslint.com/" rel="noreferrer">JSLint</a> might help. </p>
<p><a href="https://stackoverflow.com/questions/29053/javascript-browser-quirks-arraylength#29073">@John</a>: The value of arrayList[5] comes out to be 'undefined'.</p> <p>Yes, there should never be a dangling comma in declarations. Actually, I was just going through someone else's long long javascript code which somehow was not working correctly in different browers. Turned out that the dangling comma was the culprit that has accidently been typed in! :)</p>
4,872
<p>I had a problem with my nozzle on my homemade printer. The problem was that the nozzle with a 0.4 mm diameter wasn't putting out any plastic. I replaced the nozzle with a 0.2 mm one and now the bottom of my model is looking like this: <a href="https://i.stack.imgur.com/UFSHV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UFSHV.jpg" alt="waves" /></a> I tried to change flow,temperatures and speed. But nothing helped it keeps making this waves. At the old 0.4 mm nozzle there everything was okay.</p>
<p>Without more detail is difficult to say with certainty what the <em>root</em> cause of the problem is, but it looks like <strong>too much material is being deposited on the bed</strong>.</p> <p>A few things to try/check:</p> <ul> <li><strong>Make sure the nozzle is not leaking</strong>. If it is, you should see fused plastic coming out from the seal nozzle/hot-end and/or hot-end/heat break and trickling down. This is often the case when the nozzle hasn't been tightened enough, or it has been changed with the hot-end being cold, or if the internal PTFE tube has been dislodged upwards (does not apply to all-metal hot-ends).</li> <li><strong>Make sure you changed the appropriate setting for the nozzle diameter</strong>. This is <em>not</em> "flow" it is a separate setting. If you haven't, your printer is now extruding ~4 times as much filament as it ought.</li> <li><strong>Recalibrate your nozzle height</strong>. This should be done at each nozzle change, as each nozzle is slightly different from the other, and it is possible your new nozzle now sits too close to the bed.</li> </ul> <p><strong>EDIT</strong>: also, the picture is too low-res to be sure, but looking at the skirt, <strong>it looks like the extruded plastic comes out in blobs</strong>. If it is not due to leakage, then I would suggest to also check that the filament is not slipping through the gears of the extruder. If you have access to a suitable thermometer, you could also check that the hot-end temperature is stable at the level it should.</p> <p>Final thought: have you ever succeeded printing with that filament spool? It is unlikely, but it may be for example a defective one, or a mis-labelled one (so your printing temperature may be wrong).</p>
<p>Without more detail is difficult to say with certainty what the <em>root</em> cause of the problem is, but it looks like <strong>too much material is being deposited on the bed</strong>.</p> <p>A few things to try/check:</p> <ul> <li><strong>Make sure the nozzle is not leaking</strong>. If it is, you should see fused plastic coming out from the seal nozzle/hot-end and/or hot-end/heat break and trickling down. This is often the case when the nozzle hasn't been tightened enough, or it has been changed with the hot-end being cold, or if the internal PTFE tube has been dislodged upwards (does not apply to all-metal hot-ends).</li> <li><strong>Make sure you changed the appropriate setting for the nozzle diameter</strong>. This is <em>not</em> "flow" it is a separate setting. If you haven't, your printer is now extruding ~4 times as much filament as it ought.</li> <li><strong>Recalibrate your nozzle height</strong>. This should be done at each nozzle change, as each nozzle is slightly different from the other, and it is possible your new nozzle now sits too close to the bed.</li> </ul> <p><strong>EDIT</strong>: also, the picture is too low-res to be sure, but looking at the skirt, <strong>it looks like the extruded plastic comes out in blobs</strong>. If it is not due to leakage, then I would suggest to also check that the filament is not slipping through the gears of the extruder. If you have access to a suitable thermometer, you could also check that the hot-end temperature is stable at the level it should.</p> <p>Final thought: have you ever succeeded printing with that filament spool? It is unlikely, but it may be for example a defective one, or a mis-labelled one (so your printing temperature may be wrong).</p>
820
<p>I bought an ASP.NET script about a year ago to retrieve FedEx shipping values. It builds an XML string that passes to the FedEx server using an HttpWebRequest, then parses the raw XML. The average response time for the script is about 900 milliseconds. </p> <p>So the other day I was poking around in the FedEx developer center and discovered that they provide some C# code samples for using their web service. I built a little project using their code and WSDL file, and was surprised to find that the average response time is about 2.5 seconds. </p> <p>Can someone help me understand the difference in speed? And is there a way to make it faster? I have zero experience using web services.</p> <p>Thanks.</p>
<p>You can find a good article and a library to start with here: <a href="http://www.codeproject.com/KB/COM/opcdotnet.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/COM/opcdotnet.aspx</a></p>
<p>If buying a comercial toolkit is an option I've used the Northern Dynamics <a href="http://www.nordyn.com/Main/Products/Main.htm" rel="nofollow noreferrer">server toolkit</a> and it worked fine. A toolkit will take away a lot of the issues mentioned in the other questions (or at least you should get support if there's a problem).</p> <p>They've wrapped the OPC protocol up nicely so it makes it easy to use. See one of my questions here for a <a href="https://stackoverflow.com/questions/1649264/how-to-make-a-type-safe-wrapper-around-variant-values">type-safe Variant wrapper</a> that I wrote to help with this.</p>
9,234
<p>I am a physics graduate student and I want to create some 3D models for my crystal samples. We have an X-ray diffractometer in our lab. It comes with a goniometer inside it, so basically I can take as many photos as needed from any angles. (I have included a gif animation made of 10 photos taken by the machine as an example below) </p> <p><a href="https://i.stack.imgur.com/HHvM8.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HHvM8.gif" alt="a gif animation made of ten photos taken by the machine"></a></p> <p>My problem is, given these 2D photos, am I able to construct 3D models for my crystals in AutoCAD or similar software so that I can determine angles, edge lengths and volume more precisely. </p> <p>I am new to 3D printing section. I just thought maybe someone here has encountered with a similar problem. It would be very helpful if anyone could tell me any Github codes, MATLAB scripts, Mathematica scripts or software that can finish this kind of job. I can try to figure it out myself.</p>
<p>YES, it is possible to make a model from several shots, if you know the angle of rotation between the pictures.</p> <p>most CAD programs allow to insert a picture, for example as backdrop or to trace it. We are interested in the later use:</p> <p>We insert the picture, trace it in the picture's layer, then insert the next picture, rotated around the axis of rotation of the picture, and trace that. This we repeat again and again. The resulting cloud of outlines approximates the photographed body to a good degree.</p> <p>There is a big caveat though: all photos must be in the same scale and distance, the rotation of the object has to be around one axis of the item itself (no wobble) and the rotation between the pictures has to be known quite exact. This principle is pretty much used by raster scanning by the way.</p> <p>With a very hard contrast between the crystal and the backdrop, software might be able to automate the tracing process (for example use a white background and a black crystal and make sure no reflection hits the camera).</p> <h1>Example using Fusion360</h1> <p>Let's assume I have a perfect crystal like this octahedron with two cut tips <a href="https://i.stack.imgur.com/7t0op.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7t0op.png" alt="Octahedron with upper and lower tip cut" /></a></p> <p>To model this, we need at least a photo of the XZ and YZ shape (that is, 90° rotation to each other), which look like this:</p> <p><a href="https://i.stack.imgur.com/pSkDB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pSkDB.png" alt="XZ and YZ plane projection" /></a><a href="https://i.stack.imgur.com/Xogdh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xogdh.png" alt="The outlines traced" /></a></p> <p>But that shape would also match a double-cone! So we'll need some intermediary photos, in this case, the 45° shot that lies on the plane of (XY-diagonal)Z Plane</p> <p><a href="https://i.stack.imgur.com/Bncfa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bncfa.png" alt="Diagonal-Z plane projection" /></a><a href="https://i.stack.imgur.com/w67LL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w67LL.png" alt="The traced outlines" /></a></p> <p>As you see, the more outlines you have, the more detailed the pseudo-body becomes - it is just a gathering of vertices and lines yet though! But, we can take 3 points and create a construction area on these, then draw the face to merge all points on these faces...</p> <p><a href="https://i.stack.imgur.com/6NsGu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6NsGu.png" alt="construction layers" /></a></p> <p>Now, we turn these construction faces into modeling faces, then create a too large object and cut out the whole thing out...</p> <p><a href="https://i.stack.imgur.com/k4XIh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k4XIh.png" alt="Making the modeling faces" /></a> <a href="https://i.stack.imgur.com/wl5Xb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wl5Xb.png" alt="Creating the cutout" /></a> <a href="https://i.stack.imgur.com/3LukB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3LukB.png" alt="Resulting model" /></a></p> <p>The whole workflow looked like this for 4 pictures (0°, 45°, 90°, 135°)</p> <p><a href="https://i.stack.imgur.com/U05Ss.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U05Ss.png" alt="Workflow" /></a></p> <p>The actual f3D design file is <a href="https://www.dropbox.com/s/y70bpjnk6d9oyrw/Model%20v0.f3d?dl=0" rel="nofollow noreferrer">here</a>.</p>
<p>You may want to do a search for "photogrammetry". This is software that uses many photos to build a 3D model. Dr. Falkingham did a good review of free software on his blog:</p> <p><a href="https://peterfalkingham.com/2016/09/14/trying-all-the-free-photogrammetry/" rel="nofollow noreferrer">https://peterfalkingham.com/2016/09/14/trying-all-the-free-photogrammetry/</a> <a href="https://peterfalkingham.com/2017/12/17/free-photogrammetry-software-review-2017/" rel="nofollow noreferrer">https://peterfalkingham.com/2017/12/17/free-photogrammetry-software-review-2017/</a></p> <p>His conclusion that works very well for me uses COLMAP to take the photos and build a point cloud, then OpenMVS to build and texture a mesh from the point cloud.</p> <p><a href="https://colmap.github.io/" rel="nofollow noreferrer">https://colmap.github.io/</a> <a href="https://github.com/cdcseacave/openMVS/wiki/Usage" rel="nofollow noreferrer">https://github.com/cdcseacave/openMVS/wiki/Usage</a></p> <p>I have not used many commercial packages, but Pix4D has worked very well for me.</p> <p><a href="https://www.pix4d.com/" rel="nofollow noreferrer">https://www.pix4d.com/</a></p> <p>I hope that gets you started.</p>
1,152
<p>How do I forcefully unload a <code>ByteArray</code> from memory using ActionScript 3?</p> <p>I have tried the following:</p> <pre><code>// First non-working solution byteArray.length = 0; byteArray = new ByteArray(); // Second non-working solution for ( var i:int=0; i &lt; byteArray.length; i++ ) { byteArray[i] = null; } </code></pre>
<p>(I'm not positive about this, but...)</p> <p>AS3 uses a non-deterministic garbage collection which means that dereferenced memory will be freed up whenever the runtime feels like it (typically not unless there's a reason to run, since it's an expensive operation to execute). This is the same approach used by most modern garbage collecting languages (like C# and Java as well).</p> <p>Assuming there are no other references to the memory pointed to by <code>byteArray</code> or the items within the array itself, the memory will be freed at some point after you exit the scope where <code>byteArray</code> is declared.</p> <p>You can force a garbage collection, though you really shouldn't. If you do, do it only for testing. If you do it in production, you'll hurt performance much more than help it.</p> <p>To force a GC, try (yes, twice):</p> <pre><code>flash.system.System.gc(); flash.system.System.gc(); </code></pre> <p><a href="http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/" rel="nofollow noreferrer">You can read more here</a>.</p>
<p>Use <code>bytearray.clear()</code></p> <p>As per the <a href="https://airsdk.dev/reference/actionscript/3.0/" rel="nofollow noreferrer">Language Reference</a></p> <p>this</p> <blockquote> <p>Clears the contents of the byte array and resets the length and position properties to 0. Calling this method explicitly frees up the memory used by the ByteArray instance.</p> </blockquote>
2,241
<p>My motto for Java is "just because Java has static blocks, it doesn't mean that you should be using them." Jokes aside, there are a lot of tricks in Java that make testing a nightmare. Two of the most I hate are Anonymous Classes and Static Blocks. We have a lot of legacy code that make use of Static Blocks and these are one of the annoying points in our push in writing unit tests. Our goal is to be able to write unit tests for classes that depend on this static initialization with minimal code changes. </p> <p>So far my suggestion to my colleagues is to move the body of the static block into a private static method and call it <code>staticInit</code>. This method can then be called from within the static block. For unit testing another class that depends on this class could easily mock <code>staticInit</code> with <a href="https://jmockit.github.io/" rel="noreferrer">JMockit</a> to not do anything. Let's see this in example.</p> <pre><code>public class ClassWithStaticInit { static { System.out.println("static initializer."); } } </code></pre> <p>Will be changed to</p> <pre><code>public class ClassWithStaticInit { static { staticInit(); } private static void staticInit() { System.out.println("static initialized."); } } </code></pre> <p>So that we can do the following in a <a href="https://junit.org/junit5/" rel="noreferrer">JUnit</a>.</p> <pre><code>public class DependentClassTest { public static class MockClassWithStaticInit { public static void staticInit() { } } @BeforeClass public static void setUpBeforeClass() { Mockit.redefineMethods(ClassWithStaticInit.class, MockClassWithStaticInit.class); } } </code></pre> <p>However this solution also comes with its own problems. You can't run <code>DependentClassTest</code> and <code>ClassWithStaticInitTest</code> on the same JVM since you actually want the static block to run for <code>ClassWithStaticInitTest</code>.</p> <p>What would be your way of accomplishing this task? Or any better, non-JMockit based solutions that you think would work cleaner?</p>
<p><a href="http://powermock.org" rel="noreferrer">PowerMock</a> is another mock framework that extends EasyMock and Mockito. With PowerMock you can easily <a href="http://code.google.com/p/powermock/wiki/SuppressUnwantedBehavior" rel="noreferrer">remove unwanted behavior</a> from a class, for example a static initializer. In your example you simply add the following annotations to your JUnit test case:</p> <pre><code>@RunWith(PowerMockRunner.class) @SuppressStaticInitializationFor("some.package.ClassWithStaticInit") </code></pre> <p>PowerMock does not use a Java agent and therefore does not require modification of the JVM startup parameters. You simple add the jar file and the above annotations. </p>
<p>Not really an answer, but just wondering - isn't there any way to "reverse" the call to <code>Mockit.redefineMethods</code>?<br> If no such explicit method exists, shouldn't executing it again in the following fashion do the trick?</p> <pre><code>Mockit.redefineMethods(ClassWithStaticInit.class, ClassWithStaticInit.class); </code></pre> <p>If such a method exists, you could execute it in the class' <code>@AfterClass</code> method, and test <code>ClassWithStaticInitTest</code> with the "original" static initializer block, as if nothing has changed, from the same JVM.</p> <p>This is just a hunch though, so I may be missing something.</p>
8,626
<p>I have just set up my new 3D printer. However, the build plate keeps slipping while printing. I tried to use binder clips to keep the plate in place, but this makes the build plate unlevel, messing up my prints. What are some other ways to prevent the build plate from slipping. I was considering using duct tape, but am not sure whether this would work.</p>
<p>I use kapton tape to fixate the glass plates to the heated beds on two of my printers, one a Prusa i3 clone, the other a CoreXY. The tape is able to withstand higher temperatures, and is very thin, so it doesn't have the drawbacks of limiting the print area or high chance the nozzle hitting the clips.</p> <p><a href="https://i.stack.imgur.com/4Mjuj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Mjuj.jpg" alt="enter image description here" /></a></p>
<p>I'm not sure what &quot;the build plate keeps slipping while printing. I tried to use binder clips to keep the plate in place&quot; means, but if you have a build surface and a bottom heated bed, you can look for &quot;silicone thermal pad 0.5mm&quot;.</p> <p>You can put it between build surface and lower bed, so that it will increase friction and there won't be any slipping, even without clips.</p> <p><a href="https://i.stack.imgur.com/ppiOT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ppiOT.jpg" alt="enter image description here" /></a></p> <p>You can also look for &quot;thermal conductive rubber silicone cloth 0.3mm&quot; which is fiberglass reinforced and thinner, but with a maybe worse thermal conductivity. It is however more tear resistant, which helps when you remove the build surface.</p> <p><a href="https://i.stack.imgur.com/JTBCY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JTBCY.jpg" alt="enter image description here" /></a></p>
1,899
<p>The following code should find the appropriate project tag and remove it from the XmlDocument, however when I test it, it says:</p> <p><strong>The node to be removed is not a child of this node.</strong></p> <p>Does anyone know the proper way to do this?</p> <pre><code>public void DeleteProject (string projectName) { string ccConfigPath = ConfigurationManager.AppSettings["ConfigPath"]; XmlDocument configDoc = new XmlDocument(); configDoc.Load(ccConfigPath); XmlNodeList projectNodes = configDoc.GetElementsByTagName("project"); for (int i = 0; i &lt; projectNodes.Count; i++) { if (projectNodes[i].Attributes["name"] != null) { if (projectName == projectNodes[i].Attributes["name"].InnerText) { configDoc.RemoveChild(projectNodes[i]); configDoc.Save(ccConfigPath); } } } } </code></pre> <p><strong>UPDATE</strong></p> <p>Fixed. I did two things:</p> <pre><code>XmlNode project = configDoc.SelectSingleNode("//project[@name='" + projectName + "']"); </code></pre> <p>Replaced the For loop with an XPath query, which wasn't for fixing it, just because it was a better approach.</p> <p>The actual fix was:</p> <pre><code>project.ParentNode.RemoveChild(project); </code></pre> <p>Thanks Pat and Chuck for this suggestion.</p>
<p>Instead of </p> <pre><code>configDoc.RemoveChild(projectNodes[i]); </code></pre> <p>try </p> <pre><code>projectNodes[i].parentNode.RemoveChild(projectNodes[i]); </code></pre>
<p>It would be handy to see a sample of the XML file you're processing but my guess would be that you have something like this</p> <pre><code>&lt;Root&gt; &lt;Blah&gt; &lt;project&gt;...&lt;/project&gt; &lt;/Blah&gt; &lt;/Root&gt; </code></pre> <p>The error message seems to be because you're trying to remove <code>&lt;project&gt;</code> from the grandparent rather than the direct parent of the project node</p>
4,095
<p>If you create an ASP.NET web file project you have direct access to the Profile information in the web.config file. If you convert that to a Web App and have been using ProfileCommon etc. then you have to jump through a whole bunch of hoops to get your web app to work.</p> <p>Why wasn't the Profile provider built into the ASP.NET web app projects like it was with the web file projects?</p>
<p>The profile provider uses the ASP.NET Build Provider system, which doesn't work with Web Application Projects.</p> <blockquote> <p>Adding a customized BuildProvider class to the Web.config file works in an ASP.NET Web site but does not work in an ASP.NET Web application project. In a Web application project, the code that is generated by the BuildProvider class cannot be included in the application.</p> </blockquote> <p>source: <a href="http://msdn.microsoft.com/en-us/library/system.web.compilation.buildprovider.aspx" rel="nofollow noreferrer">MSDN Build Provider documentation</a></p>
<p>Actually, Microsoft does have a solution for this known issue. It's the "Web Profiler Builder". I used it for my Web App and it works great. <a href="http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980" rel="nofollow noreferrer">http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980</a></p>
3,366
<p>When running a Java app from eclipse my ImageIcon shows up just fine.</p> <p>But after creating a jar the path to the image obviously gets screwed up.</p> <p>Is there a way to extract an image from the jar at runtime so I can then open it up? Or, is there a better way to do this?</p> <p>I'd like to distribute a single jar file if possible.</p>
<p>To create an <code>ImageIcon</code> from an image file within the same jars your code is loaded:</p> <pre><code>new javax.swing.ImageIcon(getClass().getResource("myimage.jpeg")) </code></pre> <p><code>Class.getResource</code> returns a URL of a resource (or <code>null</code>!). <code>ImageIcon</code> has a constructors that load from a URL.</p> <p>To construct a URL for a resource in a jar not on your "classpath", see the documentation for <code>java.net.JarURLConnection</code>.</p>
<p>Load image in from Jar file during run time is the same as loading image when executed from IDE e.g netbeans the difference is that when loading image from JAR file the path must be correct and its <b>case sensitive</b> (very important). This works for me</p> <pre> image1 = new javax.swing.ImageIcon(getClass().getResource("/Pictures/firstgame/habitat1.jpg")); img = image1.getImage().getScaledInstance(lblhabitat1.getWidth(), lblhabitat1.getHeight(), Image.SCALE_SMOOTH); lblhabitat1.setIcon(new ImageIcon(img)); </pre> <p>if p in "/Pictures/firstgame/habitat1.jpg" is in lower case it wont work. check spaces, cases and spelling</p>
5,101
<p>How do you unit test a <code>HttpModule</code> in asp.net given that <code>HttpApplication</code> and <code>HttpContext</code> do no implement an interface ?</p>
<p>In the past before moving to ASP.NET MVC, I used <a href="http://haacked.com/archive/2007/09/09/ihttpcontext-and-other-interfaces-for-your-duck-typing-benefit.aspx" rel="nofollow noreferrer">this library</a> Phil Haack created for Unit Testing anything that used the HttpApplication and HttpContext. It in turned used a <a href="http://www.deftflux.net/blog/page/Duck-Typing-Project.aspx" rel="nofollow noreferrer">Duck Typing library</a>.</p> <p>Unfortunately, this was the best way to do it. ASP.NET was not made to be easily testable. When they worked on ASP.NET MVC, one of the goals is to get rid of these headaches by making the framework more testable.</p>
<p>You can use an Isolation (mocking) framework. I know of two tools that enable you to fake/mock any .NET objects - <a href="http://www.typemock.com/typemock-isolator-product3" rel="nofollow">Typemock Isolator</a> and <a href="http://www.telerik.com/products/mocking.aspx" rel="nofollow">Telerik JustMock</a> i think that you can also use <a href="http://social.msdn.microsoft.com/Forums/en/pex/thread/d73f730b-37df-40f9-8c62-afb76993fbbe" rel="nofollow">Moles</a>.</p> <p>All of the above will enable you to fake any .NET object event if it does not implement an interface or even have a public c'tor.</p>
4,488
<p>I'm looking to convert a SQL like statement on the fly to the equivalent regex i.e. </p> <pre><code>LIKE '%this%' LIKE 'Sm_th' LIKE '[C-P]arsen' </code></pre> <p>What's the best approach to doing this?</p> <p>P.S. I'm looking to do this on the .Net Framework (C#).</p>
<p>The following Regex converts an SQL like pattern into a Regex pattern with the help of a <a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchevaluator.aspx" rel="nofollow noreferrer"><code>MatchEvaluator</code></a> delegate. It correctly handles square bracket blocks and escapes special Regex characters.</p> <pre><code>string regexPattern = &quot;^&quot; + Regex.Replace( likePattern, @&quot;[%_]|\[[^]]*\]|[^%_[]+&quot;, match =&gt; { if (match.Value == &quot;%&quot;) { return &quot;.*&quot;; } if (match.Value == &quot;_&quot;) { return &quot;.&quot;; } if (match.Value.StartsWith(&quot;[&quot;) &amp;&amp; match.Value.EndsWith(&quot;]&quot;)) { return match.Value; } return Regex.Escape(match.Value); }) + &quot;$&quot;; </code></pre>
<p>I found a Perl module called <a href="http://search.cpan.org/dist/Regexp-Wildcards/lib/Regexp/Wildcards.pm" rel="nofollow noreferrer">Regexp::Wildcards</a>. You can try to port it or try Perl.NET. I have a feeling you can write something up yourself too.</p>
6,924
<p>I'm using Cura as my slicing/printing software and I just started using the BuildTak printing surface.</p> <p>The BuildTak is damaged by pushing a hot nozzle into it and my printer's (Robo3D R1+) autoleveling feature works by pushing the nozzle into the build surface.</p> <p>Is there a way to configure Cura so that it runs the Z probe first, then heat up the nozzle?</p> <p>My first sheet of BuildTak already has 10 small holes in it (at the homing position and at the 9 leveling touch points)</p>
<p>In Cura (and Slic3r), you can 100% customize what the printer does before printing your actual model through custom <strong>start/end g-code</strong>.</p> <p>If you navigate to the <code>Start/End-GCode tab in Cura</code>, then select <code>start.gcode</code>, you can see what operations are run before each print begins. Lines prefixed with <code>;</code> are comments, and does not affect the printing in any way. </p> <p>Basically, we want to manually tell the printer to do the auto leveling <em>before</em> heating up the nozzle by editing the g-code in <code>start.gcode</code>.</p> <h3>G-Code generated with the default start.gcode:</h3> <p>If you try to slice some model with the default code found in <code>start.gcode</code>, you will get something like the following (depending on your printer):</p> <pre><code>; CURA AUTOMATICALLY INSERTS THESE TEMPERATURE CODES M190 S70.000000 ; Set bed temperature to 70 degrees M109 S210.000000 ; Set nozzle temperature to 210 degrees ; THESE ARE THE CODES FROM START.GCODE (for a ROBO 3D R1) G28 ;move printer to endstops (the home position) G92 E0 ;zero the extruded filament length M565 Z-1 ;set z-probe offset G1 Z5 F5000 ;move the printer 5mm above the bed G29 ;run auto-leveling ; THE ACTUAL MODEL BEGINS HERE ;Layer count: 168 ;LAYER:0 . . </code></pre> <h3>Analyzing the g-code output</h3> <p>At the top of this code snippet, we can see that Cura automatically inserts g-code for heating up the bed and nozzle to their respective temperatures with the <a href="http://reprap.org/wiki/G-code#M190:_Wait_for_bed_temperature_to_reach_target_temp" rel="noreferrer">M190</a> and <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a> g-codes. This means the printer always will heat up the nozzle before reading the <code>start.gcode</code>s that we set. However, if we manually override <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a> code in <code>start.gcode</code>, the <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a> at the top will automagically disappear from the generated g-code output! (Thanks, @TomvanderZanden!)</p> <p>We could therefore use the auto-leveling command <a href="http://reprap.org/wiki/G-code#G29:_Detailed_Z-Probe" rel="noreferrer">G29</a> before manually setting the nozzle temperature with <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a>; specifically, we want to add <code>M109 S{print_temperature}</code>, which reads the <code>Basic -&gt; Print Temperature</code>-setting in Cura, and replace <code>{print_temperature}</code> with it automatically.</p> <h3>Manipulating start.gcode:</h3> <p>In order to postpone heating the hotend till after probing, <code>start.gcode</code> could be something like: </p> <pre><code>G28 ;move printer to endstops (the home position) G92 E0 ;zero the extruded filament length M565 Z-1 ;set z-probe offset &lt;----- ( YOU HAVE TO ADJUST THIS, READ BELOW) G1 Z5 F5000 ;move the printer 5mm above the bed G29 ;run auto-leveling M109 S{print_temperature} ;set nozzle temperature, and wait for it heat up </code></pre> <p>And that's about it! You can then use these codes in your <code>start.gcode</code>. However, you probably will have to recalibrate your z-prove offset. </p> <h3>Adjust z-probe offset:</h3> <p>Normally, auto-leveling is done with the nozzle heated for a reason: when the nozzle is warm, it expands slightly, moving closer to the bed. You might therefore have to adjust your Z-probe offset with the <a href="http://reprap.org/wiki/G-code#M565:_Set_Z_probe_offset" rel="noreferrer">M565</a> command (as demonstrated in the snippet) to account for the increase in nozzle length when warm.</p> <h3>Remember:</h3> <p>Remember that when editing g-code in this manner, you will take full control of how the printer operates. You could therefore very well do something unintended, so keep the power switch close! </p>
<p>As pointed out in <a href="https://3dprinting.stackexchange.com/questions/454/how-to-configure-cura-to-run-the-z-probe-before-heating/469#comment6403_469">Markus's comment</a> to <a href="https://3dprinting.stackexchange.com/a/469/4762">Tormod's answer</a>, <code>{print_temperature}</code> needs to be replaced by <code>{material_print_temperature}</code>, so the code now becomes:</p> <pre><code>G28 ;move printer to endstops (the home position) G92 E0 ;zero the extruded filament length M565 Z-1 ;set z-probe offset &lt;----- ( YOU HAVE TO ADJUST THIS, READ BELOW) G1 Z5 F5000 ;move the printer 5mm above the bed G29 ;run auto-leveling M109 S{material_print_temperature} ;set nozzle temperature, and wait for it heat up </code></pre>
179
<p>I am currently using Windows Server 2008 Standard and have several Hyper V machines. These are development VM's and I want to now switch back Vista x64 because I am missing Aero.</p> <p>I know Windows Server 2008 can have aero but the host performance is very very bad when I run VM in Hyper V.</p> <p>I want to export my Hyper V machines so that I can use it in Virtual PC. Anyone know an easy way?</p>
<p>VPC to Hyper-V is one way.</p>
<p>You should review Windows 2008 R2 SP1 upgrade with RemoteFX, it comes with a new video driver for VM's that allow 3D, extended desktops and more. It will help resolve some of the issues you are seeing today.</p> <p>Both the Host server and VM need to be running SP1 of Windows 2008 R2.</p> <p><a href="http://blogs.technet.com/b/virtualization/archive/2010/03/18/explaining-microsoft-remotefx.aspx" rel="nofollow">http://blogs.technet.com/b/virtualization/archive/2010/03/18/explaining-microsoft-remotefx.aspx</a></p>
6,477
<p>Internet Explorer has a file download limit of 4GB (2 GB on IE6). Firefox does not have this problem (haven't tested safari yet) (More info here: <a href="http://support.microsoft.com/kb/298618" rel="nofollow noreferrer">http://support.microsoft.com/kb/298618</a>)</p> <p>I am working on a site that will allow the user to download very large files (up to and exceeding 100GB)</p> <p>What is the best way to do this <strong><em>without using FTP</em></strong>. The end user must be able to download the file from there browser using HTTP. I don't think Flash or Silverlight can save files to the client so as far as I know they won't cut it.</p> <p>I'm guessing we will need an ActiveX or Java applet to pull this off. Something like the download manager that MSDN uses.</p> <p>Does anyone know of a commercial (or free) component that will do that? We do not want the user to have to install a "browser wide" download manager (like GetRight), we want it to only work with downloading on our site. </p> <p><strong>Update:</strong> Here is some additional info to help clarify what I'm trying to do. Most of the files above the 4GB limit would be large HD video files (its for a video editing company). These will be downloaded by users across the internet, this isn't going to be people on a local network. We want the files to be available via HTTP (some users are going to be behind firewalls that aren't going to allow FTP, Bittorrent, etc.). The will be a library of files the end user could download, so we aren't talking about a one time large download. The will be download different large files on a semi-regular basis.</p> <p>So far Vault that @Edmund-Tay suggested is the closest solution. The only problem is that it doesn't work for files larger than 4GB (it instantly fails before starting the download, they are probably using a 32bit integer somewhere which is exceeded/overflown by the content length of the file).</p> <p>The best solution would be a java applet or ActiveX component, since the problem only exist in IE, that would work like the article @spoulson linked to. However, so far I haven't had any luck finding a solution that does anything like that (multipart downloads, resume, etc.).</p> <p>It looks like we might have to write our own. Another option would be to write a .Net application (maybe ClickOnce) that is associated with an extension or mime type. Then the user would actually be downloading a small file from the web server that opens in the exe/ClickOnce app that tells the application what file to download. That is how the MSDN downloader works. The end user would then only have to download/install an EXE once. That would be better than downloading an exe every time they wanted to download a large file.</p>
<p><a href="http://www.bittorrent.com/" rel="nofollow noreferrer">bittorrent</a>?</p> <p>There have been a few web-based versions already (<a href="http://www.bitlet.org/" rel="nofollow noreferrer">bitlet</a>, <a href="http://torrentfreak.com/w3btorrent-a-bittorrent-client-for-your-web-server/" rel="nofollow noreferrer">w3btorrent</a>), and <a href="http://azureus.sourceforge.net/" rel="nofollow noreferrer">Azureus</a> was built using java, so it's definitely possible.</p> <p>Edit: @TonyB is it limited to port 80?</p>
<p>@travis</p> <p>Unfortunately It has to be over HTTP inside the users browser. I'll update the question to be more clear about that.</p>
5,570
<p>I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.</p> <p>I am looking for a way to prompt the user to Open / Save As on a local file stored in the Application Storage Directory. I have tried using the FileReference + URLRequest classes but this throws an exception that it needs a remote url.</p> <p>My last resort is just copying the file to their desktop : \</p>
<p>You can use the new <code>openWithDefaultApplication();</code> function that's available on the File class (I believe it's only available in AIR 2)</p> <p>eg:</p> <pre><code>var file:File = File.desktopDirectory.resolvePath(fileLocation); file.openWithDefaultApplication(); </code></pre>
<p>Currently adobe is not supporting opening files in there default applications. Passing it off to the browser seems to be the only way to make it work.</p> <p>You could however use a FileStream and write a small html file with some javascript that sets the location of an iframe to the file, then after 100ms or so calls window.close(). Then open that file in the browser.</p>
2,699
<p>I forgot my password for Sql Server 2005. Windows Authentication is not enabled so I cannot login. How can I remove the current instance and create a new db instance? Or is there a better solution exists?</p>
<p>Assuming you are a member of the Windows Admininstrator group, you can put the server in Single User mode, you could try this -</p> <p><a href="http://blogs.msdn.com/raulga/archive/2007/07/12/disaster-recovery-what-to-do-when-the-sa-account-password-is-lost-in-sql-server-2005.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/raulga/archive/2007/07/12/disaster-recovery-what-to-do-when-the-sa-account-password-is-lost-in-sql-server-2005.aspx</a></p>
<p>Have you tried connecting when logged on as domain/server-local Administrator?</p>
3,932
<p>I have a job interview tomorrow for a .NET shop. For the past few years I have been developing in languages other than .NET and figure it is probably a good idea to brush up on what is cool and new in the world of .NET. I've been reading about LINQ and WPF but these are more technologies than trends. What else should I look at?</p> <p>Been reading things like:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/bb332048.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb332048.aspx</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms754130.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms754130.aspx</a></li> </ul> <p><strong>Edit</strong></p> <p>As it turns out this interview was high level and we didn't really get into much which was more .NET specific than generics. </p>
<p>This is completely language agnostic so you may want to skip over it, but I've based a lot of my practice and preparation for job interviews around <a href="http://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html" rel="nofollow noreferrer">Steve Yegge's getting a job at google post</a>.</p> <p>I use a lot of the topics there not only as an interview preparedness guide, but also as a list of things that I <strong>SHOULD</strong> know about. Admittedly I am still working my way through some of the books and exercises, but every little bit helps. </p> <p><strong>EDIT:</strong> I'm not sure if it necessarily a good thing to focus specifically on the latest <em>trends</em> in web development for job interviews. When I am interviewing someone I am more impressed if they can write a recursive function to solve some problem or write a really cool algorithm, then if they know all the details about <em>some latest thing that is going to fix everything but it's really just a buzzword</em></p>
<p>If you're doing web development, ASP.NET MVC and Silverlight (née WPF/e) come to mind as relatively recent trends.</p>
3,590
<p>I have an Ender 3 Pro which I use together with Cura 4.2.1 (and Octoprint). I print in PLA at 180°C. The print bed is set to 70°C. The Bed temperature is lower though, since I use a glas bed on top of the heated bed. I use a print cooling fan at 100%. The layer height is set to 0.2 mm, the line width 0.4mm from the 0.4mm nozzle. My retraction is 5mm at 50mm/s.</p> <p>Prints come out with heavy vertical lines and no layer adhesion at these lines. I can easily break the print apart. In other spots the print is fine. Any ideas on what could cause this problem? <a href="https://i.stack.imgur.com/mGGT9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mGGT9.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/F3ZZ5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F3ZZ5.jpg" alt="enter image description here"></a></p>
<p>So the problem was that the TMC2208 were wired for UART mode, yet Marlin was configured for standalone, which apparently makes them work, but with completely wrong step sizes. Changing it in the configuration completely eliminated the problem</p>
<p>I would check the "steps per distance" setting. If the motors were moving more than the firmware thinks, the height would measure as shorter than actual (since the number of steps would be less than the firmware expected). Similarly, the radius would scale up.</p> <p>You replaced the controller and motor drivers, so perhaps the micro-stepping is different.</p> <p>If the result is inconsistently wrong, it could be a dynamics setting, such as acceleration or max velocity.</p>
1,477
<p>i have a list of products that are being displayed in particular order. store admin can reassign the display order, by moving the "hot" items to the top of the list. what's the best way of implementing the admin functionality <b>UI</b> [asp.net C#]? Products table has a [displayOrder(int)] filed which determines the display order.</p> <p>i'm looking for something intuitive and simple.</p> <p>thank you.</p> <p>p.s. i guess i didn't make myself clear, i'm looking for UI advice more than anything.</p> <p>SOLUTION: ReorderList worked out great, this <a href="http://weblogs.asp.net/justinsaraceno/archive/2008/02/22/reorderlist-with-objectdatasource.aspx" rel="nofollow noreferrer">article</a> helped too. Also, make sure OldValuesParameterFormatString="{0}" in your DataSource.</p>
<p>using AJAX you could implement a Reoder list control you can find more information here <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx" rel="nofollow noreferrer">http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ReorderList/ReorderList.aspx</a></p> <p>Mauro</p> <p><a href="http://www.brantas.co.uk/" rel="nofollow noreferrer">http://www.brantas.co.uk</a></p>
<p>i'm implementing that using the 'Order' column/property where people input numbers like 10, 20, 30 (i have ascending ordering). i have a list of items with text boxes to input order, and an 'apply order' button that saves new values to the database and reorders/reloads items on the page with the new ordering applied.</p> <p>i don't forbid inputting the same value for two items, i sort them by name as a second sort parameter, or leave it to the database to sort it at will if it doesn't matter much. i believe it's understandable enough to put it that way, it seems like an ordered list which everybody understand easily.</p>
7,439
<p>I know this isn't strictly speaking a programming question but something I always hear from pseudo-techies is that having a lot of entries in your registry slows down your Windows-based PC. I think this notion comes from people who are trying to troubleshoot their PC and why it's running so slow and they open up the registry at some point and see leftover entries from programs they uninstalled ages ago.</p> <p>But is there any truth to this idea? I would not think so since the registry is essentially just a database and drilling down to an entry wouldn't take significantly longer on a larger registry. But does it?</p> <p><strong>EDIT:</strong> To be clear, I'm not looking for advice on how to make a PC run faster, or asking why my PC in particular is slow (it's not), I'm just curious if people who say "bigger registry means slower PC" are accurate or not.</p>
<p>In short, not really. </p> <p>In the old days when machines were slower the answer was yes; but having a modern processor rip through even a 60MB registry is not a problem.</p> <p>Typically, the real reason a modern machine starts running slow is due to everything from malware to virus scanners: Mcafee, Norton's, etc are prime targets in my mind.</p> <p>Also, the WinSXS folder tends to grow as service packs and applications are installed. This seems to have a negative impact on system performance. There are only two possible solutions in this scenario. First, if possible, reinstall the OS with the latest service pack already slipstreamed into the install. Second, if that isn't possible AND you are running Vista with SP1, you can run the vsp1cln.exe tool (see <a href="http://technet.microsoft.com/en-us/library/cc766219.aspx" rel="nofollow noreferrer">technet</a>) which will clean up a lot of the older versions of components. Note that this tool can only be executed once and it does not allow you to roll back.</p>
<p>any problems occur on the registry could also make your computer much slower.the fix registry problems you need to install a <a href="http://www.windows7-slow.com/computer-running-extremely-slow/" rel="nofollow">registry cleaner</a> as this will fix the errors and make your pc back to its normal state.</p>
7,317
<p>I have a table with a 'filename' column. I recently performed an insert into this column but in my haste forgot to append the file extension to all the filenames entered. Fortunately they are all '.jpg' images.</p> <p>How can I easily update the 'filename' column of these inserted fields (assuming I can select the recent rows based on known id values) to include the '.jpg' extension?</p>
<p>The solution is:</p> <pre><code>UPDATE tablename SET [filename] = RTRIM([filename]) + '.jpg' WHERE id &gt; 50 </code></pre> <p>RTRIM is required because otherwise the [filename] column in its entirety will be selected for the string concatenation i.e. if it is a varchar(20) column and filename is only 10 letters long then it will still select those 10 letters and then 10 spaces. This will in turn result in an error as you try to fit 20 + 3 characters into a 20 character long field.</p>
<p>If the original data came from a char column or variable (before being inserted into this table), then the original data had the spaces appended before becoming a varchar.</p> <pre><code>DECLARE @Name char(10), @Name2 varchar(10) SELECT @Name = 'Bob', @Name2 = 'Bob' SELECT CASE WHEN @Name2 = @Name THEN 1 ELSE 0 END as Equal, CASE WHEN @Name2 like @Name THEN 1 ELSE 0 END as Similiar </code></pre> <p>Life Lesson : never use char.</p>
3,822
<p>I have a form in C# that has a button that, when clicked, I want the background image to cycle through a set of images (which I have as resources to the project). The images are named '_1', '_2', etc. and each time I click the button I want its background image to increment to the next one and go back to "_1" when it gets to the highest. Is there a way to do this?</p> <p>I tried getting <code>button1.BackgroundImage.ToString()</code> but that yields <code>System.Drawing.Bitmap</code> instead of <code>Resources._1</code> like I was thinking it would (in which case I could just get the last character and switch on that to change the background to the appropriate new image).</p> <p>Thanks for your help.</p>
<p>Why don't you just put the images in an array?</p>
<p>You could subclass Button and override the BackgroundImage property so you can better keep track of the current resource that represents the image. You might also override the onclick method to internally handle cycling to the next image, though that might be a little weird if the resources are handled outside of your derived button class.</p>
3,587
<p>I want to know what a "<em>virtual base class</em>" is and what it means.</p> <p>Let me show an example:</p> <pre><code>class Foo { public: void DoSomething() { /* ... */ } }; class Bar : public virtual Foo { public: void DoSpecific() { /* ... */ } }; </code></pre>
<p>Virtual base classes, used in virtual inheritance, is a way of preventing multiple "instances" of a given class appearing in an inheritance hierarchy when using multiple inheritance.</p> <p>Consider the following scenario:</p> <pre><code>class A { public: void Foo() {} }; class B : public A {}; class C : public A {}; class D : public B, public C {}; </code></pre> <p>The above class hierarchy results in the "dreaded diamond" which looks like this:</p> <pre><code> A / \ B C \ / D </code></pre> <p>An instance of D will be made up of B, which includes A, and C which also includes A. So you have two "instances" (for want of a better expression) of A.</p> <p>When you have this scenario, you have the possibility of ambiguity. What happens when you do this:</p> <pre><code>D d; d.Foo(); // is this B's Foo() or C's Foo() ?? </code></pre> <p>Virtual inheritance is there to solve this problem. When you specify virtual when inheriting your classes, you're telling the compiler that you only want a single instance.</p> <pre><code>class A { public: void Foo() {} }; class B : public virtual A {}; class C : public virtual A {}; class D : public B, public C {}; </code></pre> <p>This means that there is only one "instance" of A included in the hierarchy. Hence</p> <pre><code>D d; d.Foo(); // no longer ambiguous </code></pre> <p>This is a mini summary. For more information, have a read of <a href="http://en.wikipedia.org/wiki/Virtual_inheritance" rel="noreferrer">this</a> and <a href="https://isocpp.org/wiki/faq/multiple-inheritance" rel="noreferrer">this</a>. A good example is also available <a href="http://www.learncpp.com/cpp-tutorial/118-virtual-base-classes/" rel="noreferrer">here</a>.</p>
<p>Virtual classes are <strong>not</strong> the same as virtual inheritance. Virtual classes you cannot instantiate, virtual inheritance is something else entirely.</p> <p>Wikipedia describes it better than I can. <a href="http://en.wikipedia.org/wiki/Virtual_inheritance" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Virtual_inheritance</a></p>
4,169
<p>I have a Tevo Flash. Normally, I don't care about perpendicularity with respect to the table. But now I have a 5&quot; disc on a ball bearing, held by a 3D printed tube with a flat bottom. If the tube's axis is not 100 % perpendicular to the bottom, the disc, when spun, wobbles at the edge: ~1/8&quot;.</p> <p><a href="https://i.stack.imgur.com/LgMr5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LgMr5.png" alt="Disc wobble" /></a></p> <p>As a test, I printed a vertical sample tube. I took close-up pics, on the printer's table, next to a carpenter's square. Down the table's Y axis, there's a vert. deviation of ~1 mm over 45 mm of height, between the sample tube and the square. Down the X-axis, the deviation is small.</p> <p><a href="https://i.stack.imgur.com/rhb9c.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rhb9c.jpg" alt="Deviation photos" /></a></p> <p>How do I deal with it? Can a slicer (I have Simplify3D) compensate for it? I could gently &quot;skew&quot; the geo in 3D modeling software, but it seems inelegant.</p> <p>Note: this has nothing to do with bed leveling. The bed is level, the printer has a BLTouch. The first layers look great. The problem is above the bed. The right angles of the aluminum-extrusion frame aren't 100 % exact. Measured with the carpenter's square, the vertical columns of the frame (Z) deviate 1-2 mm over 100 mm from perpendicular, with respect to the bottom frame (X-Y). Trying to fix the whole frame would be hard.</p> <p>EDIT: I used a 0.127 mm shim (from a sacrificial steel gauge blade), it fixed most of it. With the printer laid horizontally (so I could work with the screws underneath) and the shim in, the vertical posts were 100% true (see pic). When I put the printer back into its vertical, working position, the posts tilted back a bit. I'll try a 0.15 mm shim.</p> <p><a href="https://i.stack.imgur.com/2Rt9t.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Rt9t.jpg" alt="Shim added" /></a></p>
<p>In answer to <em>(doesn't have to the issue of the OP, but as a reaction for other readers)</em>:</p> <blockquote> <p>Note: this has nothing to do with bed leveling. The bed is level, the printer has a BLTouch.</p> </blockquote> <p><a href="/a/16605">Having a BLTouch doesn't imply the bed is level!</a> The bed is level when the nozzle moves in the same plane parallel to the bed, the bed shape is compensated for by the BLTouch, it can be very skew and still it will print.</p> <blockquote> <p>The right angles of the aluminum-extrusion frame aren't 100 % exact.</p> </blockquote> <p>That is a problem, the frame needs to be square. I don't think that it is a major operation to modify that, you can use some support struts, I've done that for a 2040 aluminum extrusion i3 clone.</p> <p>Note, this is a portal style printer driven by a single Z lead screw (and a roller mount on the other Z post) as far as can be seen from the manufacturer photographs. <em>(Update, the OP has a dual screw Z portal, so this possibly is not applicable to that specific version)</em> Single Z screw portal printer types are also prone to unlevel over height, be sure the rollers of the nozzle carrier and the opposite Z post rollers are correctly functioning.</p> <p>Although fixing the hardware is the preferred option, there is an alternative, you can solve this in firmware like e.g. Marlin.</p> <p>You need to make some test prints and fill out the correct values to correct for the skewness, but this may be limited to overall Z skewness, not individual skew Z posts.</p> <p>E.g. in Marlin, the configuration file can be used to compensate the skewness problem:</p> <pre><code>/** * Bed Skew Compensation * * This feature corrects for misalignment in the XYZ axes. * * Take the following steps to get the bed skew in the XY plane: * 1. Print a test square (e.g., https://www.thingiverse.com/thing:2563185) * 2. For XY_DIAG_AC measure the diagonal A to C * 3. For XY_DIAG_BD measure the diagonal B to D * 4. For XY_SIDE_AD measure the edge A to D * * Marlin automatically computes skew factors from these measurements. * Skew factors may also be computed and set manually: * * - Compute AB : SQRT(2*AC*AC+2*BD*BD-4*AD*AD)/2 * - XY_SKEW_FACTOR : TAN(PI/2-ACOS((AC*AC-AB*AB-AD*AD)/(2*AB*AD))) * * If desired, follow the same procedure for XZ and YZ. * Use these diagrams for reference: * * Y Z Z * ^ B-------C ^ B-------C ^ B-------C * | / / | / / | / / * | / / | / / | / / * | A-------D | A-------D | A-------D * +--------------&gt;X +--------------&gt;X +--------------&gt;Y * XY_SKEW_FACTOR XZ_SKEW_FACTOR YZ_SKEW_FACTOR */ //#define SKEW_CORRECTION </code></pre> <p>But, this requires a new firmware installation, the reader should investigate whether this is within the capabilities of the reader.</p>
<p>If you've measured the frame and it's not square, that's almost surely your problem and you need to fix it. But having a BLtouch does not mean your bed is level. The effect you're seeing is exactly what you get from using a BLtouch and mesh leveling to compensate for a non-level bed, and it's a very bad thing and why these fake leveling systems are band-aids to make it easier to get started printing something minimally viable, not something that gives you a working, precise printer. The bed needs to be physically square with the Z axis.</p>
1,965
<p>There are three assembly version attributes. What are differences? Is it ok if I use <code>AssemblyVersion</code> and ignore the rest?</p> <hr> <p>MSDN says:</p> <ul> <li><p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assemblyversionattribute" rel="noreferrer">AssemblyVersion</a>:</p> <blockquote> <p>Specifies the version of the assembly being attributed. </p> </blockquote></li> <li><p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assemblyfileversionattribute" rel="noreferrer">AssemblyFileVersion</a>:</p> <blockquote> <p>Instructs a compiler to use a specific version number for the Win32 file version resource. The Win32 file version is not required to be the same as the assembly's version number. </p> </blockquote></li> <li><p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assemblyinformationalversionattribute" rel="noreferrer">AssemblyInformationalVersion</a>:</p> <blockquote> <p>Defines additional version information for an assembly manifest. </p> </blockquote></li> </ul> <hr> <p><em>This is a follow-up to <a href="https://stackoverflow.com/questions/62353/what-are-the-best-practices-for-using-assembly-attributes">What are the best practices for using Assembly Attributes?</a></em></p>
<p><strong>AssemblyVersion</strong></p> <p>Where other assemblies that reference your assembly will look. If this number changes, other assemblies must update their references to your assembly! Only update this version if it breaks backward compatibility. The <code>AssemblyVersion</code> is required.</p> <p>I use the format: <em>major.minor</em> (and <em>major</em> for very stable codebases). This would result in:</p> <pre><code>[assembly: AssemblyVersion(&quot;1.3&quot;)] </code></pre> <p>If you're following <a href="https://semver.org/" rel="noreferrer">SemVer</a> strictly then this means you only update when the <em>major</em> changes, so 1.0, 2.0, 3.0, etc.</p> <p><strong>AssemblyFileVersion</strong></p> <p>Used for deployment (like setup programs). You can increase this number for every deployment. Use it to mark assemblies that have the same <code>AssemblyVersion</code> but are generated from different builds and/or code.</p> <p>In Windows, it can be viewed in the file properties.</p> <p>The AssemblyFileVersion is optional. If not given, the AssemblyVersion is used.</p> <p>I use the format: <em>major.minor.patch.build</em>, where I follow <a href="https://semver.org/" rel="noreferrer">SemVer</a> for the first three parts and use the buildnumber of the buildserver for the last part (0 for local build). This would result in:</p> <pre><code>[assembly: AssemblyFileVersion(&quot;1.3.2.42&quot;)] </code></pre> <p>Be aware that <a href="https://learn.microsoft.com/en-us/dotnet/api/system.version" rel="noreferrer">System.Version</a> names these parts as <code>major.minor.build.revision</code>!</p> <p><strong>AssemblyInformationalVersion</strong></p> <p>The Product version of the assembly. This is the version you would use when talking to customers or for display on your website. This version can be a string, like '<em>1.0 Release Candidate</em>'.</p> <p>The <code>AssemblyInformationalVersion</code> is optional. If not given, the AssemblyFileVersion is used.</p> <p>I use the format: <em>major.minor[.patch] [revision as string]</em>. This would result in:</p> <pre><code>[assembly: AssemblyInformationalVersion(&quot;1.3 RC1&quot;)] </code></pre>
<p>When a assembly' s AssemblyVersion is changed, If it has strong name, the referencing assemblies need to be recompiled, otherwise the assembly does not load! If it does not have strong name, if not explicitly added to project file, it will not be copied to output directory when build so you may miss depending assemblies, especially after cleaning the output directory. </p>
9,018
<p>I have a three-tier application which is installed in corporate environments. With every server version update, all clients have to be updated, too. Currently, I provide an MSI package which is automatically deployed via Active Directory, however my customers (mostly with 20-300 users each) seem to hate the MSI solution because it is</p> <ul> <li>Complicated to get it running (little Active Directory knowledge);</li> <li>The update process can't be triggered by the server, when a new version is detected;</li> <li>Customers can't install multiple versions of the client (e.g. 2.3 and 2.4) at the same time to speak to different servers;</li> <li>The update process itself doesn't always work as expected (sometimes very strange behaviour healing itself after a few hours)</li> </ul> <p>I've now made a few experiments with ClickOnce, but that way to unflexible for me and too hard to integrate in my automated build process. Also, it produces cryptic error messages which would surely confuse my customers.</p> <p>I would have no problems to write the update logic myself, but there the problem is that the users running to self-updating applications have too restricted rights to perform an update. I've found that they are able to write to their Local Application Data directory, but I don't think this would be the typical place to install application files into.</p> <p>Do you know a way to an update that "just works"?</p>
<p>You can somewhat replicate what ClickOnce does, just adjust it for your needs.</p> <ol> <li>Create a lightweight executable that checks a network/web location for updates. </li> <li>If there are updates, it copies them locally and replaces the "real" application files.</li> <li>It runs the "real" application.</li> </ol> <p>The location for the application files should be determined by permissions and operating system. If users only have write permission to a limited set of folders, then you don't have a choice but use one of these folders. Another option is provide an initial installation package that installs the lightweight executable and grants r/w permission on a specific folder such as "C:\Program Files\MyApp". This approach usually requires a buy-in from IT. </p> <p>I hope this helps.</p>
<p>If you don't want to give your users too many rights, it is possible to write a Windows Service, which will run on each computer under an account with the appropriate privileges, and which can update your application, when a new version gets available.</p>
9,167
<p>I have an exe with an <code>App.Config</code> file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities.</p> <p>The question is how can I access the app.config property in the exe from the wrapper dll?</p> <p>Maybe I should be a little bit more in my questions, I have the following app.config content with the exe:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;appSettings&gt; &lt;add key="myKey" value="myValue"/&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <p>The question is how to how to get "myValue" out from the wrapper dll?</p> <hr> <p>thanks for your solution.</p> <p>Actually my initial concept was to avoid XML file reading method or LINQ or whatever. My preferred solution was to use the <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx" rel="noreferrer">configuration manager libraries and the like</a>.</p> <p>I'll appreciate any help that uses the classes that are normally associated with accessing app.config properties. </p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.openmappedexeconfiguration(VS.80).aspx" rel="noreferrer">ConfigurationManager.OpenMappedExeConfiguration Method</a> will allow you to do this.</p> <p>Sample from the MSDN page:</p> <pre><code>static void GetMappedExeConfigurationSections() { // Get the machine.config file. ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); // You may want to map to your own exe.comfig file here. fileMap.ExeConfigFilename = @"C:\test\ConfigurationManager.exe.config"; System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); // Loop to get the sections. Display basic information. Console.WriteLine("Name, Allow Definition"); int i = 0; foreach (ConfigurationSection section in config.Sections) { Console.WriteLine( section.SectionInformation.Name + "\t" + section.SectionInformation.AllowExeDefinition); i += 1; } Console.WriteLine("[Total number of sections: {0}]", i); // Display machine.config path. Console.WriteLine("[File path: {0}]", config.FilePath); } </code></pre> <hr> <p>EDIT: This should output the "myKey" value:</p> <pre><code>ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = @"C:\test\ConfigurationManager.exe.config"; System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); Console.WriteLine(config.AppSettings.Settings["MyKey"].Value); </code></pre>
<p>It's an xml file, you can use Linq-XML or DOM based approaches to parse out the relevant information.<br> (that said I'd question if there isn't a better design for whatever it is.. you're trying to achieve.)</p>
7,706
<p>I'm looking for a testing framework for the Windows kernel environment. So far, I've found <a href="http://cfix.sourceforge.net/" rel="noreferrer">cfix</a>. Has any one tried it? Are there alternatives?</p>
<p>Being the author of cfix, I might be a little biased here -- but as a matter of fact, I am currently not aware of any other unit-testing framework for NT kernel mode.</p> <p>If you should experience any problems with cfix, feel free to contact me.</p>
<p><a href="http://www.microsoft.com/whdc/devtools/tools/SDV.mspx" rel="nofollow noreferrer">Microsoft Static Driver Verifier</a> is described as "a compile-time tool that explores code paths in a device driver by symbolically executing the source code. SDV is a unit-testing tool for Microsoft Windows device drivers based on the Windows Driver Model (WDM)."</p> <p>Is that what you're looking for?</p>
3,885
<p>I have three stepper motors. One Nema 17 - 2.4 ohm, the second smaller noname from color printer - 9.5 ohm and third the smallest noname from cdrom - 10.5 ohm.</p> <p>I have connected them to arduino mega 2560 with ramps 1.4(set to 1/32 micro stepping) and drivers drv8825. <a href="https://3dprinting.stackexchange.com/questions/8480/errorprinter-halted-kill-called">See my previous question.</a></p> <p>After some time (less than one minute) the first is cold. The second motor is hot. And the third is very hot. I can not even touch it.</p> <p>What can I do to fix it.</p>
<blockquote> <p>The second motor is hot. And the third is very hot. I can not even touch it.</p> </blockquote> <p>This is to some degree, completely normal and expected. From the <a href="https://www.oyostepper.com/images/upload/File/17HS19-1684S1.pdf" rel="nofollow noreferrer">datasheet for a typical NEMA 17 stepper</a>, the rated temperature rise is 80 °C above ambient and the maximum operating temperature is 130 °C (implying an ambient temperature of 50 °C). It is normal that stepper motors (in general) get a bit hot.</p> <p>"Too hot to touch" is still relatively cold. 60 °C is already too hot to touch, and that's only a 40 °C rise above a 20 °C ambient temperature.</p> <p>You can reduce the temperature rise of the motors by reducing the current they receive. The stepper driver has a small potentiometer that can be turned to adjust the current, but keep in mind that doing so will also reduce the torque of the motors and thus they might skip steps if you reduce the current too much.</p> <p><em>Technical details:</em> Note that stepper motor drivers used in 3D printers are <em>constant current</em> drivers, and the little potentiometer controls the current. If you had not paid much attention to this potentiometer, the drivers might all have been set for the same constant current of <span class="math-container">$1.0\ \text A$</span>. The stepper driver would (to achieve the same constant current) send a higher voltage to the higher resistance motors. This would imply a power dissipation of <span class="math-container">$2.4\ \text W$</span> in the Nema 17, and a power dissipation of <span class="math-container">$10.5\ \text W$</span> in the small stepper. <span class="math-container">$2.4\ \text W$</span> in the Nema 17 would only heat it up by about <span class="math-container">$20\ °\text C$</span> above ambient. A dissipation of <span class="math-container">$10\ \text W$</span> in the small stepper, which also has much less surface area to dissipate the power, would heat it up by a lot (and probably, given that you didn't fry it, the current was set lower -- or a technical peculiarity limited the current given that the motor likely also has very low inductance).</p>
<h2>Problem statement</h2> <p>Your RAMPs board is supplying your drivers all with similar voltages, with the basic settings calculated for a NEMA 17. </p> <p>So, we got different Resistances R, so why do they heat differently?</p> <h2>Physics background: energy transformation and dissipation</h2> <p>Resistance can be described as "friction of electrons in the conductor" to some degree. When electrons flow through a wire, then a current <span class="math-container">$I$</span> is trying to equalize a potential difference <span class="math-container">$U$</span>. A flowing current transforms the kinetic energy of the electrons (<span class="math-container">$\propto U$</span>) into an electromagnetic field and heat from the resistance. The electromagnetic field then is used to spin a rotor together with the magnets in the motor, which transforms the energy in the field into kinetic energy again. The end result is, that the kinetic energy of the electrons is transformed into the motion of the motor and heat.</p> <h2>Can we get the Current?</h2> <h3>OR: "What if there was no driver?"</h3> <p>How does Resistance figure into all this? Well, Ohms Law is there: <span class="math-container">$U=RI$</span>. With it, one can solve how much current I flows through an aperture of known resistance R and voltage U. The operation of the circuits that contain a <a href="http://robocup.idi.ntnu.no/wiki/images/c/c6/PL15S020.pdf" rel="nofollow noreferrer">CD stepper motor</a> is usually 5 V, while 12 V is used for <a href="http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/stepper-motors/specifications" rel="nofollow noreferrer">NEMA 17</a> and the typical steppers from Printer/scanner combos.</p> <p>Those results wouldn't match the currents they are operated on as the motors are supplied via a motor driver chipset. We can look up the spec sheets to get a short glimpse of how they might dissipate heat in both constant voltage and constant current setups. Most stepper driver adjusts the voltage so we get constant current but there might be some cases one wants constant voltage. To estimate their heat generation, one needs...</p> <h2>Joules Formula of electric Heating</h2> <h3>Constant Voltage case</h3> <p>Joules Formula of electric heating is written as <span class="math-container">$H=I^2Rt$</span>, which gives us Energy in Joules. We can make it easier on us and drop the time to get the derivate power of electric heating. <span class="math-container">$P=\frac{H}{t}= I^2\ R= U \ I=\frac {U^2} {R}$</span></p> <ul> <li><span class="math-container">$P={12\ \text V}\times {0.4\ \text A}=4.8\ \text {W}$</span></li> <li><span class="math-container">$P=\frac{144\ \text V^2}{9.5\ \Omega}=15.14\ \text {W}$</span></li> <li><span class="math-container">$P=\frac{25\ \text V^2}{10\ \Omega}=2.5\ \text {W}$</span></li> </ul> <p>if we throw <strong>12 V</strong> at the poor small stepper though...</p> <ul> <li><span class="math-container">$P=\frac{144\ \text V^2}{10\ \Omega}=14.4\ \text {W}$</span></li> </ul> <p><sup>How did the small one survive this torture? I have no idea!</sup></p> <h3>Constant Current case</h3> <p>Now, that is pretty much "constant voltage" but the stepper drivers used try to give always a set constant current to the motors. For most motors I have found, this is apparently in the area around 0.5 A, which gives us a better estimation</p> <ul> <li><span class="math-container">$P={0.25\ \text A^2}\times {2.4\ \Omega}=0.6\ \text {W}$</span></li> <li><span class="math-container">$P={0.25\ \text A^2}\times {9.5\ \Omega}=2.375\ \text {W}$</span></li> <li><span class="math-container">$P={0.25\ \text A^2}\times {10.5\ \Omega}=2.625\ \text {W}$</span></li> </ul> <p>If they all are operated at the same, set current (with adjusted voltage to match that), we get about a factor 4 for the heat generation on the middle and 4.3 on the CD stepper. Even with a higher current, the factors for heat dissipation are what is really interesting here.</p> <h2>Heating and temperature</h2> <p>Another small part of the answer is the mass of the motor and when it was touched. The thermal energy <span class="math-container">$E_T$</span> in a whole object is <em>not directly</em> equal to the temperature <span class="math-container">$T$</span> of the object, it is just proportional to it but also the specific heat capacity <span class="math-container">$c$</span> of the body... all in all we get for an amount of energy <span class="math-container">$Q$</span> deposited in an object <span class="math-container">$\text Q = \text m\ \text c\ \Delta\text T$</span>. </p> <p>Assuming that c is equal for the motors, one can do a quick estimation with typical weights via <span class="math-container">$\Delta\text T \propto \frac H m$</span></p> <p>A typical NEMA 17 motor weighs about 280 grams while the typical CD-drive stepper (PL15S-020-PNA9) weighs 19 grams.</p> <p>You see, the smaller steppers not only dissipates more heat, it also heats up faster than the chunky NEMA 17. The reason why after a short time the smaller one with not that much more heating than the big one felt considerably hotter is, that there is less mass that needs to be heated up: it might be already at its maximum temperature while the middle one still is heating up.</p> <h2>All in all</h2> <p>This is <em>not</em> a marlin issue but one from your material choice. Getting all similar motors makes motion control all the much easier, but you are not necessarily in danger of burning the motors.</p> <p>To cool the motors...</p> <ul> <li>figure out what current I the smaller motors want to be operated on and adjust your setup to that, so to stay safe. <ul> <li>there are potentiometers for this on most boards.</li> </ul></li> <li>mount a heatsink on the motors, increasing their effective thermal mass and their ability to dissipate the heat to the room around by increasing the surface area.</li> </ul>
1,250
<p>A few months back my team switched our source control over to <a href="http://subversion.apache.org/" rel="noreferrer">Apache Subversion</a> from <a href="http://msdn.microsoft.com/en-us/vs2005/aa718670.aspx" rel="noreferrer">Visual SourceSafe</a>, and we haven't been happier. </p> <p>Recently I've been looking at <a href="http://tfspreview.com/" rel="noreferrer">Team Foundation Server</a>, and at least on the surface, it seems very impressive. There is some great integration with Visual Studio, and lots of great tools for DBAs, testers, project managers, etc.</p> <p>The most obvious difference between these two products is price. It's hard to beat Apache Subversion (free). Team Foundation Server is quite expensive, so the extra features would really have to kick Subversion in the pants.</p> <ul> <li>Does anyone have practical experience with both? </li> <li>How do they compare?</li> <li>Is Team Foundation Server actually worth the expense?</li> </ul>
<p>I joined an Open Source project over at CodePlex, recently. They use TFS for their source control and I have to say that it's absolutely magnificent. I'm incredibly impressed with it, so far. I'm a huge fan of the IDE integration and how easy it is to branch and tag your code. Adding a solution to source control is something like two clicks, if you've already got everything configured properly.</p> <p>Now. Is it worth the hefty price tag? I don't think so. The benefit to working on projects at CodePlex is it lets me get the experience with TFS that I need, in the event that I have to use it somewhere later. If you want good IDE integration for your Source Control, go grab <a href="http://www.visualsvn.com/visualsvn/" rel="noreferrer">VisualSVN</a> integration package. It's a much, much cheaper investment to get a lot of the same features (free on non-domain computers BTW).</p>
<p>TFS by a mile.</p> <p>I inadvertently cause too many problems for myself with SVNs file-based approach. Source control problems ive experienced: TFS – 0 problems over 2 years SVN – lost count...</p> <p>Yes I know the price of TFS factors it out for most companies which is such a shame. MS might have a lot more marketshare (and profit) if they had a reasonable pricing model.</p>
2,620
<p>I'm working on a website built with pure HTML and CSS, and I need a way to restrict access to pages located within particular directories within the site. The solution I came up with was, of course, ASP.NET Forms Authorization. I created the default Visual Studio log in form and set up the users, roles, and access restrictions with Visual Studio's wizard. The problem is, I can't log in to the website with the credentials that I have set.</p> <p>I'm using IIS 7. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>I'd guess (since I don't have IIS7 handy ATM) that you'd need to turn off Anonomyous Auth, and enable Forms Auth in the IIS7 sections.</p>
<p>At what point did you insert your login/password? Did you have a look at the tables that where created? Althought your password must be encrypted, maybe it's worth just checking if your user was actually created.</p>
4,505
<p>What are the steps in the production process that factories that produce filament have to take to get from pellets to a full spool of filament.</p> <p>Which of these steps are critical for quality (thickness, roundness, long shelf life,..) ?</p>
<p>Some general comments about the process used (plastic extrusion):</p> <p>The plastic extrusion process is not simple- many textbooks dense with equations have been written about it. The lowest cost industrial extrusion processes do not use pellets at all- because pellets have already gone through an extrusion process so they are more expensive than powder resin. There is typically a 'compounding' stage where colors etc. are added before extrusion. </p> <p>Significant heat is generated by the screw (which often has a complex geometry) via shear action that is itself temperature and pressure sensitive, and the heat is added to by external heaters in various zones (or subtracted by water cooling and chillers in larger extruders). In some cases we were able to operate an extruder adiabatically- the heat created by the screw motor matched the heat loss as the product left the die and no heating or cooling was needed once the process was stabilized. </p> <p>The end result is that you want to plasticize (melt) the plastic and achieve a certain pressure at the die. The plastic is deteriorating the higher the temperature and the longer the time so you want to limit the residence time at high temperature. There is some trial-and-error and a lot of previous experience in the setup person's task. Once the parameters are determined they are recorded and are used the next time that material is run. </p> <p>The size of an extrusion is typically determined exactly by downstream equipment rather than controlling the conditions at the die. It is essentially stretched as it comes out of the die and the heat is removed in a cooling trough. </p> <p>Here you can see a factory environment with a very typical extrusion setup, used in this case for 3D printing filament (but the setup would look almost the same if they were making slats for Venetian blinds). Notice that there are cooling fans as well as band heaters on the extruder barrel. They control the diameter by adjusting the take-off capstan RPM once the extruder is running well. This extruder looks like it has 4 heat/cool barrel zones and two (heat-only) nozzle zones (6 temperatures total). </p> <p><a href="https://www.youtube.com/watch?v=40HOAsUnSQ8" rel="nofollow">https://www.youtube.com/watch?v=40HOAsUnSQ8</a></p> <p>Extruders are categorized by the barrel bore diameter in inches or mm. A very small extruder might be 25mm. An extruder used for pipe production might be 6" (150mm) or more. Some machines use multiple screws. </p>
<p>Each step is critical for quality. It's refined plastic mass. And in oil-based-products, every step is crucial for quality.</p> <p>In <strong><a href="https://www.youtube.com/watch?time_continue=1&amp;v=OEkksADFjP8" rel="nofollow">this</a></strong> vieo, everything is explained.</p>
241
<p>I have an extrusion problem with my creality CR 10 3D printer while printing. I am using a standard 0.4&nbsp;mm nozzle with a 1.75&nbsp;mm diameter PLA and I use Cura as my slicer.</p> <p>This printer worked perfectly fine and I stopped using it a few months ago right after the problem started.</p> <p>When I try printing a <code>.gcode</code> file, the first layer is very thin but visible (it seems like the glass bed is engraved). However, after the first layer is complete, the extruder stops working properly. It moves forward then jumps backwards so it looks like the filament isn’t moving (I can also see the extruder’s marks on the filament). Also, the axis seem to move fine in all directions as I’m able to see a clear first layer.</p> <p>However, when I go into the “prepare” menu of my printer and move the extruder, it works great as the filament flow is very smooth.</p> <p>Hence, the problem is only visible while printing. I don’t think there’s a problem with the <code>.gcode</code> files as I printed them perfectly fine beforehand.</p>
<p>Without images of the problem it is difficult to diagnose, but, the described symptoms sounds as if the nozzle is too close to the bed. If the nozzle is too close to the bed, and the extruder not strong enough, the filament flow is very limited due to pressure caused by a very small opening between the nozzle and the bed. Skipping of the extruder may wear out (grind) the filament and stop extrusion altogether.</p> <p>Re-level the bed with a (thicker) piece of paper or with a feeler gauge. Alternatively, increase the height of the nozzle by re-defining the height or add an extra Z raise in the slicer (see question: &quot;<a href="https://3dprinting.stackexchange.com/questions/13330/how-can-i-add-an-offset-to-the-first-layer-to-increase-clearance/13334">How can I add an offset to the first layer to increase clearance?</a>&quot;).</p>
<p>Clearly you're having an extrusion problem. Extrusion problems usually come either from a clogged nozzle (as @Adam S. said) or from the extruder it self. To determine where the problem is located I would first do a flow rate test using <a href="https://www.youtube.com/watch?v=lWBkPIXTOlo&amp;feature=emb_logo" rel="nofollow noreferrer">this</a>. When doing this test you can determine if the extruder is grinding the filament or if it's not grabbing it too much. After the calibration of the flowrate you can be certain that the printer is (by .gcode) pushing the correct amount of filament. If the problem persist I would first do an unclogging (since it's cheaper than the following option) using something like <a href="https://www.youtube.com/watch?v=XR7tUVLku14" rel="nofollow noreferrer">this</a>. </p> <p>If both previous options do not solve the problem, I would highly recommend you to by a mk-8 like metal extruder. After a while, the plastic one that comes with the printer loses force and you'll lose steps. Personally, I had a similar problem where the first layer was printed in a droplet pattern and was solved by changing the extruder to a metal one.</p> <p>Try these options and if the problem persist you could upload some pictures of the first layer or a video. Other possibilities I think of are that the filament is having trouble passing through the Bowden tube or maybe you'll have to reasemble the hotend.</p>
1,659
<p>A former coworker insisted that a database with more tables with fewer columns each is better than one with fewer tables with more columns each. For example rather than a customer table with name, address, city, state, zip, etc. columns, you would have a name table, an address table, a city table, etc.</p> <p>He argued this design was more efficient and flexible. Perhaps it is more flexible, but I am not qualified to comment on its efficiency. Even if it is more efficient, I think those gains may be outweighed by the added complexity.</p> <p>So, are there any significant benefits to more tables with fewer columns over fewer tables with more columns?</p>
<p>I have a few fairly simple rules of thumb I follow when designing databases, which I think can be used to help make decisions like this....</p> <ol> <li>Favor normalization. Denormalization is a form of optimization, with all the requisite tradeoffs, and as such it should be approached with a <a href="http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It" rel="noreferrer">YAGNI</a> attitude.</li> <li>Make sure that client code referencing the database is decoupled enough from the schema that reworking it doesn't necessitate a major redesign of the client(s).</li> <li>Don't be afraid to denormalize when it provides a clear benefit to performance or query complexity.</li> <li>Use views or downstream tables to implement denormalization rather than denormalizing the core of the schema, <em>when data volume and usage scenarios allow for it</em>.</li> </ol> <p>The usual result of these rules is that the initial design will favor tables over columns, with a focus on eliminating redundancy. As the project progresses and denormalization points are identified, the overall structure will evolve toward a balance that compromises with limited redundancy and column proliferation in exchange for other valuable benefits.</p>
<p>Good to see so many inspiring and well based answers.</p> <p>My answer would be (unfortunately): it depends.</p> <p>Two cases: * If you create a datamodel that is to be used for many years and thus possibly has to adept many future changes: go for more tables and less rows and pretty strict normalization. * In other cases you can choose between more tables-less rows or less tables-more rows. Especially for people relatively new to the subject this last approach can be more intuitive and easy to comprehend.</p> <p>The same is valid for the choosing between the object oriented approach and other options.</p>
8,411
<p>I have read that if I disconnect OctoPrint when printing, the print will stop. Since I thought the advantage of OctoPrint over, say, printing from Cura, was that it didn't tie up the computer while the print was taking place, what are the advantages of OctoPrint?</p>
<p>The benefit of using OctoPrint as a printserver lies in the fact that it can be used on a stable computer platform. E.g. when you install OctoPrint on a Raspberry Pi, you are ensured that the &quot;computer&quot; stays online. Other platforms, such as Windows are much prone to interrupt the printing process (user actions during printing, sleep mode, Windows updates, etc.). Furthermore, the power consumption of the Raspberry Pi is also much lower than a full computer or laptop running OctoPrint.</p> <p>An advantage of running OctoPrint on a dedicated Raspberry Pi is that you can access it from anywhere within your network through a browser interface (or even from the outside) as it is always online. Other advantages of OctoPrint over e.g. Cura is that there are numerous plugins available to tailor the printing process to your needs.</p>
<p>Printer Supervisory control and data acquisition (SCADA)</p> <p><a href="https://en.wikipedia.org/wiki/SCADA" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/SCADA</a></p> <p>In the context of 3d printing, SCADA is useful because it is important to have a redundant method of monitoring (and control) of a system. The 3d printer's µController is typically busy with doing the important task of controlling the steppers and monitoring the heating elements. It is important to the print job that these functions occur in a way that is uninterruptible. We know all too well of the consequences of letting the hot end go into thermal runaway. As it stands most 3d printers have simple µControllers that are not powerful enough to handle TCP/IP responses AND monitor the 3d printer's machinery. To that end, being able to notify a Supervisor of the status of the machine and any failure conditions that may be occurring becomes important in the management of the machine. This is where a Supervisory system like Octoprint comes in. With its myriad of plugins and other connectivity, it extends the abilities of an inexpensive printer (e.g. like my Anet A8) with advanced capabilities for notification (e.g. the Octoprint Android/IOS apps) and control; such as automatically powering off the printer with a wifi-enabled smart plug. These are safety features that should be considered when operating a 3d printer. The temptation to leave the machine running unattended has resulted in problems in the past. With a supervisory system, the machine's operator can give at least some attention to the print process at all times.</p> <p>Further, sometimes the print fails without actually being a result of some sort of electromechanical fault. Having optical inspection equipment (e.g. a camera) attached to the supervisory system can help determine if there are problems with the process so that fine-tuning can be performed. Without such data, it is usually very difficult to diagnose those problems.</p>
1,900
<p>If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into?</p> <p>Specifically, I would like to avoid code similar to:</p> <pre><code>void Main() { ValidateTable1(); ValidateTable2(); ValidateTable3(); } private void ValidateTable1() { //Table1 validation code goes here } private void ValidateTable2() { //Table2 validation code goes here } private void ValidateTable3() { //Table3 validation code goes here } </code></pre> <p>Also, I've decided to use log4net to log all of the errors and warnings, so that each method can be declared <code>void</code> and doesn't need to return anything. Is this a good idea or would it be better to create some sort of <code>ValidationException</code> that catches all exceptions and stores them in a <code>List&lt;ValidationException&gt;</code> before printing them all out at the end?</p> <p>I did find <a href="http://www.hickorysystems.com/sw_validation.html" rel="noreferrer">this</a>, which looks like it may work, but I'm hoping to actually find some code samples to work off of. Any suggestions? Has anyone done something similar in the past?</p> <p>For some background, the program will be written in either C# or VB.NET and the tables will more than likely be stored in either Access or SQL Server CE.</p>
<p>Just an update on this: I decided to go with the <a href="http://en.wikipedia.org/wiki/Decorator_pattern" rel="noreferrer">Decorator pattern</a>. That is, I have one 'generic' table class that implements an <code>IValidateableTable</code> interface (which contains <code>validate()</code> method). Then, I created several validation decorators (that also <code>implement IValidateableTable</code>) which I can wrap around each table that I'm trying to validate.</p> <p>So, the code ends up looking like this:</p> <pre><code>IValidateableTable table1 = new GenericTable(myDataSet); table1 = new NonNullNonEmptyColumnValidator(table1, "ColumnA"); table1 = new ColumnValueValidator(table1, "ColumnB", "ExpectedValue"); </code></pre> <p>Then, all I need to do is call <code>table1.Validate()</code> which unwinds through the decorators calling all of the needed validations. So far, it seems to work really well, though I am still open to suggestions.</p>
<p>I think you are really talking about a concept called <a href="http://en.wikipedia.org/wiki/Database_constraints" rel="nofollow noreferrer">constraints</a> in the world of databases. Constraints are how a database guarantees the integrity of the data it contains. It makes much more sense to put this sort of logic in the database, rather than the application (even Access offers rudimentary forms of constraints, such as requiring uniqueness of values in a column, or values from a list, etc.).<br> Input validation (of individual fields) is of course a different matter, and any application should still perform that (to provide nice feedback to the user in case of problems), even if the DB has well-defined constraints of the table columns.</p>
6,806
<p>I want to skeletize the surface mesh. For that I need to export .STL from Solidworks and then convert that into .OFF file to be able to use it in CGAL library for skeletonzation. How can I do this?</p>
<p>One aspect of having this level of control with 3d printing of a model is the removal of the need for supports and the attendant post-processing. In the case of the model shown in the video, some effects are created by printing the continents in a conformal manner that would otherwise be impossible with conventional 3d printing. Cosmetically, the results of the "5d" printer are superior in this example.</p> <p>There would also be some structural benefit for models with high organic content, that is curves and bulges, as opposed to orthogonal designs. Even with orthogonal designs, one can achieve stronger parts with cross-layered plastic in all directions, rather than being limited by x and y filament layers.</p> <p>I see on the web site that one can exchange tool heads as well. One could print a 3d model, layering the filament on all the surfaces, then use a tool head change to a milling bit and smooth the surface under CAD control. Alternatively, one could use foam or wood and mill a model shape to be covered with a 3d printed material.</p> <p>Considering the relative novelty of this product, it's likely that many aspects of the creative utility have yet to be discovered!</p>
<p>Slicing prints for printing in 5 Axis is not going to be simple with the current software. If you look at the web site for the 5AxisMaker you can see they are using Algorithmic modeling software (Grasshopper). You would probably need to buy this as well and then spend a decent amount of time learning how to use this software as well if you were going to try and take advantage of the 5th Axis for 3D printing. </p> <p>I have only seen Grasshopper used for 3D printing and 5 Axis used in research papers. </p>
429
<p><strong>Most recent edits in bold</strong> I am using the .net <code>HttpListener</code> class, but I won't be running this application on IIS and am not using ASP.net. This <a href="http://www.leastprivilege.com/CommentView.aspx?guid=0c34094a-bdd4-4041-be6e-919f10fe1d31" rel="noreferrer">web site</a> describes what code to actually use to implement SSL with asp.net and <a href="http://blogs.msdn.com/adarshk/archive/2004/11/10/255467.aspx" rel="noreferrer">this site</a> describes how to set up the certificates (although I'm not sure if it works only for IIS or not). </p> <p>The class documentation describes various types of authentication (basic, digest, Windows, etc.) --- none of them refer to SSL. It does say that if <a href="http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx" rel="noreferrer">HTTPS is used, you will need to set a server certificate</a>. Is this going to be a one line property setting and <code>HttpListener</code> figures out the rest? </p> <p>In short, I need to know how to set up the certificates and how to modify the code to implement SSL.</p> <p>Although it doesn't occur when I'm trying to access HTTPS, I did notice an error in my System Event log - the source is "Schannel" and the content of the message is:</p> <blockquote> <p>A fatal error occurred when attempting to access the SSL server credential private key. The error code returned from the cryptographic module is 0x80090016.</p> </blockquote> <p>Edit:<br> <strong>Steps taken so far</strong></p> <ul> <li>Created a working HTTPListener in C# that works for HTTP connections (e.g. "<a href="http://localhost:8089/foldername/" rel="noreferrer">http://localhost:8089/foldername/</a>"</li> <li>Created a certificate using makecert.exe</li> <li>Added the certificate to be trusted using certmgr.exe</li> <li>Used Httpcfg.exe to listen for SSL connections on a test port (e.g. 8090)</li> <li>Added port 8080 to the HTTPListener via listener.Prefixes.Add(<a href="https://localhost:8090/foldername/" rel="noreferrer">https://localhost:8090/foldername/</a>");</li> <li>tested an HTTP client connection, e.g. (<a href="http://localhost:8089/foldername/" rel="noreferrer">http://localhost:8089/foldername/</a>") in a browser and receive correct return</li> <li>tested an HTTPS client connection, e.g. (<a href="http://localhost:8090/foldername/" rel="noreferrer">http://localhost:8090/foldername/</a>") in a browser and receive "Data Transfer Interrupted" (in Firefox)</li> <li>debugging in visual studio shows that the listener callback that receives the requests never gets hit when the HTTPS connection starts - I don't see any place that I could set a breakpoint to catch anything else earlier.</li> <li>netstat shows that listening ports are open for both HTTPS and HTTP. the HTTPS port does go to TIME_WAIT after a connection is attempted.</li> <li><strong><a href="http://www.fiddlertool.com/fiddler/" rel="noreferrer">Fiddler</a> and <a href="http://www.ieinspector.com/httpanalyzer/" rel="noreferrer">HTTPAnalyzer</a> don't catch any of the traffic, I guess it doesn't get far enough in the process to show up in those HTTP analysis tools</strong></li> </ul> <p><strong>Questions</strong></p> <ul> <li>What could the problem be? </li> <li>Is there a piece of .Net code I am missing (meaning I have to do more in C# other than simply add a prefix to the listener that points to HTTPS, which is what i have done)</li> <li>Have a missed a configuration step somewhere? </li> <li>What else might I do to analyze the problem?</li> <li>Is the error message in the System Event log a sign of the problem? If so how would it be fixed?</li> </ul>
<p>I don't have it entirely implemented yet, but this web site seems to give a <a href="http://developers.de/blogs/damir_dobric/archive/2006/08/01/897.aspx" rel="noreferrer">good walkthrough</a> of setting up the certificates and the code.</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx" rel="nofollow noreferrer">class documentation</a></p> <p>has this note:</p> <blockquote> <p>If you create an HttpListener using https, you must select a Server Certificate for that listener. Otherwise, an HttpWebRequest query of this HttpListener will fail with an unexpected close of the connection.</p> </blockquote> <p>and this:</p> <blockquote> <p>You can configure Server Certificates and other listener options by using HttpCfg.exe. See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/http/http/httpcfg_exe.asp" rel="nofollow noreferrer">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/http/http/httpcfg_exe.asp</a> for more details. The executable is shipped with Windows Server 2003, or can be built from source code available in the Platform SDK.</p> </blockquote> <p>Is the first note explained by the second? As outlined in the question, I used httpcfg.exe to bind the certificate to a specific port. If they intend something other than this, the note is ambiguous.</p>
2,603
<p>I am looking for good methods of manipulating HTML in PHP. For example, the problem I currently have is dealing with malformed HTML.</p> <p>I am getting input that looks something like this:</p> <pre><code>&lt;div&gt;This is some &lt;b&gt;text </code></pre> <p>As you noticed, the HTML is missing closing tags. I could use regex or an XML Parser to solve this problem. However, it is likely that I will have to do other DOM manipulation in the future. I wonder if there are any good PHP libraries that handle DOM manipulation similar to how Javascript deals with DOM manipulation.</p>
<p>PHP has <a href="http://php.net/tidy" rel="noreferrer">a PECL extension that gives you access to the features of HTML Tidy</a>. Tidy is a pretty powerful library that should be able to take code like that and close tags in an intelligent manner.</p> <p>I use it to clean up malformed XML and HTML sent to me by a classified ad system prior to import.</p>
<p>For manipulating the DOM i think that what you're looking for is <a href="http://www.php.net/manual/en/intro.dom.php" rel="nofollow noreferrer">this</a>. I've used to parse HTML documents from the web and it worked fine for me.</p>
4,685
<p>I ended up writing a quick little script for this in Python, but I was wondering if there was a utility you could feed text into which would prepend each line with some text -- in my specific case, a timestamp. Ideally, the use would be something like:</p> <pre><code>cat somefile.txt | prepend-timestamp </code></pre> <p>(Before you answer sed, I tried this:</p> <pre><code>cat somefile.txt | sed "s/^/`date`/" </code></pre> <p>But that only evaluates the date command once when sed is executed, so the same timestamp is incorrectly prepended to each line.)</p>
<p>Could try using <code>awk</code>:</p> <pre><code>&lt;command&gt; | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' </code></pre> <p>You may need to make sure that <code>&lt;command&gt;</code> produces line buffered output, i.e. it flushes its output stream after each line; the timestamp <code>awk</code> adds will be the time that the end of the line appeared on its input pipe.</p> <p>If awk shows errors, then try <code>gawk</code> instead.</p>
<p>If the value you are prepending is the same on every line, fire up emacs with the file, then:</p> <p><kbd>Ctrl</kbd> + <kbd>&lt;space&gt;</kbd></p> <p>at the beginning of the of the file (to mark that spot), then scroll down to the beginning of the last line (Alt + &gt; will go to the end of file... which probably will involve the Shift key too, then Ctrl + a to go to the beginning of that line) and:</p> <p><kbd>Ctrl</kbd> + <kbd>x</kbd> <kbd>r</kbd> <kbd>t</kbd></p> <p>Which is the command to insert at the rectangle you just specified (a rectangle of 0 width).</p> <p>2008-8-21 6:45PM &lt;enter&gt;</p> <p>Or whatever you want to prepend... then you will see that text prepended to every line within the 0 width rectangle.</p> <p>UPDATE: I just realized you don't want the SAME date, so this won't work... though you may be able to do this in emacs with a slightly more complicated custom macro, but still, this kind of rectangle editing is pretty nice to know about...</p>
4,170
<p>I see in the Stack Overflow footer that the SVN Revision number is displayed. Is this automated and if so, how does one implement it in ASP.NET?</p> <p><em>(Solutions in other languages are acceptable)</em></p>
<p>Make sure that the file has s<code>vn:keywords "Rev Id"</code> and then put <code>$Rev$</code> somewhere in there.</p> <p>See <a href="https://stackoverflow.com/q/163/10221765">this question and the answers to it</a>.</p>
<p>in our continuous integration setup we use <code>SVNRevisionLabeller</code> and pass the variables from this to MSBuild to use when creating the compiled website dll. It's then available to .NET using <code>GetCurrentAssembly()</code> in the final build.</p>
2,447
<p>I'm currently in the process of setting up a continuous integration environment at work. We are using VisualSVN Server and CrusieControl.NET. Occasionally a build will fail and a symptom is that there are conflicts in the CruiseControl.NET working copy. I believe this is due to the way I've setup the Visual Studio solutions. Hopefully the more projects we run in this environment the better our understanding of how to set them up will be so I'm not questioning why the conflicts happen at this stage. To fix the builds I delete the working copy and force a new build - this works every time (currently). So my questions are: is deleting the working copy a valid part of a continuous integration build process, and how do I go about it?</p> <p>I've tried solutions including MSTask and calling delete from the command line but I'm not having any luck.</p> <p>Sorry for being so wordy - good job this is a beta :)</p>
<p>Doing a full delete before or after your build is good practice. This means that there is no chance of your build environment picking up an out of date file. Your building exactly against what is in the repository.</p> <p>Deleting the working copy is possible as I have done it with Nant. </p> <p>In Nant I would have a clean script in its own folder outwith the one I want to delete and would then invoke it from CC.net. </p> <p>I assume this should also be possible with a batch file. Take a look at the rmdir command <a href="http://www.computerhope.com/rmdirhlp.htm" rel="noreferrer">http://www.computerhope.com/rmdirhlp.htm</a></p> <p>@pauldoo</p> <p>I prefer my CI server to do a full delete as I don't want any surprise when I go to do a release build, which should always be done from a clean state. But it should be able to handle both, no reason why not</p>
<p>It is very common and generally a good practice for any build process to do a 'clean' before doing any significant build. This prevents any 'artifacts' from previous builds to taint the output.</p> <p>A clean is essentially what you are doing by deleting the working copy.</p>
2,959
<p>I am starting to build a new web application that will require user accounts. Now that I have an OpenID that I am using for this site I thought it would be cool if I could use OpenID for authentication in my application. Are there any good tutorials on how to integrate OpenID with an ASP.NET site?</p>
<p>See <a href="http://www.hanselman.com/blog/TheWeeklySourceCode25OpenIDEdition.aspx" rel="noreferrer">Scott Hanselman's post on using DotNetOpenID</a> in ASP.NET. <a href="http://blog.nerdbank.net/" rel="noreferrer">Andrew Arnott's blog</a> is full of samples on using DotNetOpenID with ASP.NET, including ASP.NET MVC.</p> <p>I recently hooked up DotNetOpenID for the Subtext 2.0 release. It went really smoothly - the code samples included with the DotNetOpenID download are pretty helpful. The one thing I'd recommend is that you just use the library and avoid the ASP.NET control. It uses table based layout (hardcoded) and is pretty difficult to restyle.</p>
<p>You should check out the <a href="http://www.dotnetnuke.com" rel="nofollow noreferrer">DotNetNuke</a> codebase as well, they have been using OpenID for the last several revisions, and you'll find working code for implementing it there.</p>
3,741
<p>I know you could make a helper pretty easily given the data. So, if possible, please only submit answers that also include getting the data.</p>
<p>We are using an action filter for this. </p> <p>...</p> <pre><code> public override void OnActionExecuting(ActionExecutingContext filterContext) { var controller = (Controller) filterContext.Controller; Breadcrumb[] breadcrumbs = _breadcrumbManager.PushBreadcrumb(_breadcrumbLinkText); controller.ViewData.Add(breadcrumbs); } </code></pre> <p>before you mention it, I too have a distaste for service location in the filter attributes - but we are left with few options. IBreadcrumbManager looks like this:</p> <pre><code>public interface IBreadcrumbManager { Breadcrumb[] PushBreadcrumb(string linkText); } </code></pre> <p>The implementation puts Breadcrumb objects into the Session. The Url is <code>HttpContext.Current.Request.RawUrl</code></p>
<p>@Chris: something like this:</p> <pre><code> &lt;% foreach (var item in ViewData.Get&lt;Breadcrumb[]&gt;()) { %&gt; &lt;a href="&lt;%= Server.HtmlEncode(item.Url) %&gt;"&gt;&lt;%= item.LinkText %&gt;&lt;/a&gt; &amp;raquo; &lt;% } %&gt; </code></pre>
9,168
<p>Currently, pure CAD questions are out of scope of our Stack, but we have quite some cases that edge, where the question about the CAD is about how to make a model printable or design principles or such.</p> <p>Where do we draw the line in the sand? <a href="https://3dprinting.meta.stackexchange.com/questions/204/the-fine-line-between-3d-and-cad">This was once discussed in 2016, but no conclusive answer defined.</a></p>
<p>I struggled with the same question since I saw the edit, good that you brought this to Meta! Thanks!</p> <p>As the community of regular and active members is limited, I think it is okay to welcome people in a comment or an answer. It would be a shame to scare people away after their first question, resulting in abandoned questions and unaccepted answers. But, we do need to conform to the Q&amp;A format and sometimes need to remind people this isn't a forum of threaded messages and we do have some rules to participate. We have created some <a href="/q/303/">standard comments</a> that welcome and thank new members but at the same time lead them to the rules of the site.</p> <p>It might be a good idea to approach first time (SE) members friendly. Welcoming comments can and tend to be deleted after a while when users aren't new anymore (everybody can raise a flag on a comment to vote for <em>”It's no longer needed&quot;</em>). So option 4 would be my preferred option.</p> <p>Personally I think this site is more welcoming than larger sites as SO for instance. My first experiences at SO didn't make me feel welcome.</p>
<p>I struggled with the same question since I saw the edit, good that you brought this to Meta! Thanks!</p> <p>As the community of regular and active members is limited, I think it is okay to welcome people in a comment or an answer. It would be a shame to scare people away after their first question, resulting in abandoned questions and unaccepted answers. But, we do need to conform to the Q&amp;A format and sometimes need to remind people this isn't a forum of threaded messages and we do have some rules to participate. We have created some <a href="/q/303/">standard comments</a> that welcome and thank new members but at the same time lead them to the rules of the site.</p> <p>It might be a good idea to approach first time (SE) members friendly. Welcoming comments can and tend to be deleted after a while when users aren't new anymore (everybody can raise a flag on a comment to vote for <em>”It's no longer needed&quot;</em>). So option 4 would be my preferred option.</p> <p>Personally I think this site is more welcoming than larger sites as SO for instance. My first experiences at SO didn't make me feel welcome.</p>
78
<p>How do I make <code>diff</code> ignore temporary files like <code>foo.c~</code>? Is there a configuration file that will make ignoring temporaries the default?</p> <p>More generally: what's the best way to generate a "clean" patch off a tarball? I do this rarely enough (submitting a bug fix to an OSS project by email) that I always struggle with it...</p> <p>EDIT: OK, the short answer is</p> <pre><code>diff -ruN -x *~ ... </code></pre> <p>Is there a better answer? E.g., can this go in a configuration file?</p>
<p>This doesn't strictly answer your question, but you can avoid the problem by configuring Emacs to use a specific directory to keep the backup files in. There are different implementations for Emacs or XEmacs.</p> <p>In GNU Emacs</p> <pre> (defvar user-temporary-file-directory (concat temporary-file-directory user-login-name "/")) (make-directory user-temporary-file-directory t) (setq backup-by-copying t) (setq backup-directory-alist `(("." . ,user-temporary-file-directory) (,tramp-file-name-regexp nil))) (setq auto-save-list-file-prefix (concat user-temporary-file-directory ".auto-saves-")) (setq auto-save-file-name-transforms `((".*" ,user-temporary-file-directory t))) </pre> <p>In XEmacs</p> <pre> (require 'auto-save) (require 'backup-dir) (defvar user-temporary-file-directory (concat (temp-directory) "/" (user-login-name))) (make-directory user-temporary-file-directory t) (setq backup-by-copying t) (setq auto-save-directory user-temporary-file-directory) (setq auto-save-list-file-prefix (concat user-temporary-file-directory ".auto-saves-")) (setq bkup-backup-directory-info `((t ,user-temporary-file-directory full-path))) </pre> <p>You can also remove them all with a simple find command</p> <pre> find . -name “*~” -delete </pre> <p>Note that the asterisk and tilde are in double quotes to stop the shell expanding them.</p> <p>By the way, these aren't strictly <em>temporary</em> files. They are a backup of the previous version of the file, so you can manually "undo" your last edit at any time in the future. </p>
<p>You can create a small sunction/script to it, like:</p> <pre><code>#!/bin/bash olddir="/tmp/old" newdir="/tmp/new" pushd $newdir for files in $(find . -name \*.c) do diff $olddir/$file $newdir/$file done popd </code></pre> <p>This is only one way to script this. The simple way. But I think you got the idea.</p> <p>Other suggestion is configuring in emacs a backup dir, so your backup files go always to the same place, outside your work dir!</p>
5,304
<p>If the hot-end is at ~0 on the Z axis and I go to level it, as it approaches X = 0 it begins scraping along the bed, then when moving back to probe the center of the bed (after homing X to 0) it will scrape the bed again.</p> <p>I want to add a glass plate but am worried this aggressive homing will smash the glass. How can I fix it? The printer auto-levels and runs Marlin.</p>
<p>I realised the simplest fix for this shortly after posting the question. In either your slicer or your printer controller (I use octoprint, so I added this there) add to the starting G-code something to lift the head so that it is above the point it is scraping across.</p> <p>For example, change your starting G-code from something like:</p> <pre><code>G28 ;Home all axis G29 ;probe bed </code></pre> <p>To</p> <pre><code>G91 ;Set to relative positioning G0 Z10 ;move head up by 10mm G28 ;Home all axis G29 ;probe bed </code></pre> <p>(obviously remove G29 if you do not have a probe)</p> <p>10mm should be more than enough to lift by unless you have something seriously wrong, but you can adjust the figure as needed.</p>
<p>Sounds like you need a different sensor? You have a lot of issues from the sounds of it. Also no code so cannot comment on your settings.</p> <p>If it always scrapes the bed (sorry but its really unclear what is going on) then lower your sensor a bit.. Best I can give you with the provided info.</p>
403
<p>How do I set the column which has the header sort glyph, and its direction, in a .NET 2.0 WinForms ListView?</p> <h2>Bump</h2> <p>The listview is .net is not a managed control, it is a very thin wrapper around the Win32 ListView common control. It's not even a very good wrapper - it doesn't expose all the features of the real listview.</p> <p>The Win32 listview common control supports drawing itself with themes. One of the themed elements is the header sort arrow. Windows Explorer's listview common control knows how to draw one of its columns with that theme element.</p> <ul> <li>does the Win32 listview support specifying which column has what sort order? </li> <li>does the Win32 header control that the listview internally uses support specifying which column has what sort order? </li> <li>does the win32 header control support custom drawing, so I can draw the header sort glyph myself?</li> <li>does the win32 listview control support custom header drawing, so I can draw the header sort glyph myself?</li> <li>does the .NET ListView control support custom header drawing, so I can draw the header sort glyph myself?</li> </ul>
<p>In case someone needs a quick solution (it draws up/down arrow at the beginning of column header text):</p> <p><strong>ListViewExtensions.cs:</strong></p> <pre><code>public static class ListViewExtensions { public static void DrawSortArrow(this ListView listView, SortOrder sortOrder, int colIndex) { string upArrow = "▲ "; string downArrow = "▼ "; foreach (ColumnHeader ch in listView.Columns) { if (ch.Text.Contains(upArrow)) ch.Text = ch.Text.Replace(upArrow, string.Empty); else if (ch.Text.Contains(downArrow)) ch.Text = ch.Text.Replace(downArrow, string.Empty); } if (sortOrder == SortOrder.Ascending) listView.Columns[colIndex].Text = listView.Columns[colIndex].Text.Insert(0, downArrow); else listView.Columns[colIndex].Text = listView.Columns[colIndex].Text.Insert(0, upArrow); } } </code></pre> <p><strong>Usage:</strong></p> <pre><code>private void lstOffers_ColumnClick(object sender, ColumnClickEventArgs e) { lstOffers.DrawSortArrow(SortOrder.Descending, e.Column); } </code></pre>
<p>I use unicode arrow characters in the title of the column and make the header a linkbutton.</p>
9,901
<p>I have a <a href="https://flex3drive.com/" rel="nofollow noreferrer">Flex3Drive</a> remote-direct-drive extruder I bought for my Ender 3 (with the original extruder motor), and I'm pretty happy with it except for abysmal retraction performance due to the 40:1 reduction, which requires the motor to turn about 480° to retract just 1 mm. This is minimally workable for PLA and rigid materials where I can get by with just 1 mm of retraction, but it takes just as long to retract 1 mm as the original bowden extruder did to retract 6 mm, defeating a lot of the appeal of a direct drive. For TPU I haven't been able to make it workable at all. By the time I retract 3 mm or so, which seems necessary to avoid stringing, the hotend has already melted and/or deposited a blob on the print. Failure to print TPU also defeats much of the point of a direct drive.</p> <p>I'm running retraction at 8 mm/s, 500 mm/s² acceleration, which is already higher than the manufacturer of the extruder recommends, and about the fastest I've been able to get it to work. Based on <a href="https://www.daycounter.com/Calculators/Stepper-Motor-Calculator.phtml" rel="nofollow noreferrer">this calculator</a> and 8.9 mH motor inductance, that seems roughly expected. I have TMC 2209 steppers and tried playing with current but it doesn't seem to make much difference.</p> <p>Otherwise, I love this extruder, and want to make it work. Is there a way I can salvage it by changing out the motor for something that can do higher RPMs and accelerate just as fast or faster?</p>
<p>In general I would use <a href="https://github.com/rcarlyle/StepperSim" rel="nofollow noreferrer">https://github.com/rcarlyle/StepperSim</a> which takes into account more parameters.</p> <p>You can play with voltage and current to see which combination gives you the best results for your motor.</p> <p>Or you can change to a TMC driver with higher voltage (35-50 V) to keep torque at much higher speeds and push the current motor more.</p> <p>Since the torque you require is likely not so high, you can increase the speed of your stepper motor with 3D printed herringbone gears, for example 4:1. They don't need to be super accurate, backlash is totally fine considering the ridiculous 40:1 reduction.</p>
<p>I was considering buying a Fl3xdrive but had this exact fear, that the speed (rotation) required for retractions was too much.</p> <p>I stumbled upon this post while looking for a project for a step-up gearbox. I found a <a href="https://www.thingiverse.com/thing:3714978" rel="nofollow noreferrer">Nema 17 Gearbox &quot;Pulleybox&quot; Mod for Extruder</a> on Thingiverse, should be enough to do what you did with your design, I guess.</p>
1,894
<p>What are the most common things to test in a new site?</p> <p>For instance to prevent exploits by bots, malicious users, massive load, etc.?</p> <p>And just as importantly, what tools and approaches should you use?</p> <p>(some stress test tools are really expensive/had to use, do you write your own? etc)</p> <p><a href="https://stackoverflow.com/questions/23102/what-are-comon-exploits-web-i-should-know-about">Common exploits that should be checked for</a>. </p> <p>Edit: the reason for this question is partially from being in SO beta, however please refrain from SO beta discussion, SO beta got me thinking about my own site and good thing too. This is meant to be a checklist for things that I, you, or someone else hasn't thought of before. </p>
<p>Try and break your own site before someone else does. Your web site is basically a publicly accessible API that allows access to a database and other backend systems. Test the URLs as if they were any other API. I like to start by cataloging all URLs that have some sort of permenant affect on the state of the system - this is easy if you are doing Ruby on Rails development or trying to follow a RESTful design pattern. For each of those URLs, try running a GET, POST, PUT or DELETE HTTP methods with different parameters so that you can ensure that you're only giving access to what you want to give access to. </p> <p>This of course is in addition to obvious: Functional testing, Load Testing, SQL Injection, XSS etc.</p>
<p>There's seperate stages for this one.</p> <p>Firstly there's the technical testing, where you check all technical functionality:</p> <ul> <li>SQL injections</li> <li>Cross-site Scripting (XSS)</li> <li>load times</li> <li>stress levels</li> </ul> <p>Then there's the phase where you have someone completely computer-illiterate sit down and ask them to find something. Not only does it show you where there's flaws in your navigational logic (I find that developers look upon things way differently than 'other people') but they're also guaranteed to find some way to break your site.</p>
4,301
<p>I have a Person object with two constructors - one takes an int (personId), the other a string (logonName). I would like another constructor that takes a string (badgeNumber). I know this can't be done, but seems it might be a common situation. Is there a graceful way of handling this? I suppose this would apply to any overloaded method. Code:</p> <pre><code>public class Person { public Person() {} public Person(int personId) { this.Load(personId); } public Person(string logonName) { this.Load(logonName); } public Person(string badgeNumber) { //load logic here... } </code></pre> <p>...etc.</p>
<p>You might consider using custom types.</p> <p>For example, create LogonName and BadgeNumber classes.</p> <p>Then your function declarations look like...</p> <pre><code>public Person(LogonName ln) { this.Load(ln.ToString()); } public Person(BadgeNumber bn) { //load logic here... } </code></pre> <p>Such a solution might give you a good place to keep the business logic that governs the format and usage of these strings.</p>
<p>How about ...</p> <pre><code>public Person(int personId) { this.Load(personId); } public Person(string logonName) { this.Load(logonName); } public Person(Object badgeNumber) { //load logic here... } </code></pre>
5,111
<p>The <code>Close</code> method on an <code>ICommunicationObject</code> can throw two types of exceptions as MSDN outlines <a href="http://msdn.microsoft.com/en-us/library/ms195520.aspx" rel="nofollow noreferrer">here</a>. I understand why the <code>Close</code> method can throw those exceptions, but what I don't understand is why the <code>Dispose</code> method on a service proxy calls the <code>Close</code> method without a <code>try</code> around it. Isn't your <code>Dispose</code> method the one place where you want make sure you don't throw any exceptions?</p>
<p>You can mark variables as "<a href="https://velocity.apache.org/engine/1.5/user-guide.html#quietreferencenotation" rel="noreferrer">silent</a>" like this:</p> <pre><code>$!variable </code></pre> <p>If $variable is null, nothing will be rendered. If it is not null, its value will render as it normally would.</p>
<p>You will also need to be sure and use the proper syntax. Your example is missing the dollar before the variable. It should be $!{person.age}, not just {person.age}.</p>
4,368
<p>Does anyone use have a good regex library that they like to use? Most of the regexes that you find online either contain bugs or are so focused on the edge cases that it turns into a competition to validate whatever spec 100%. Of course you can write your own, but when you are billing by the hour its handy to have a library around. </p>
<p>You can search for regular expression in <a href="http://regexlib.com/" rel="nofollow noreferrer">regexlib</a>.</p>
<p>e-texteditor hilights what you're searching for as you type it. This is incredibly useful, as you can paste your 'sample text' into a file, and just type your regex into the search field, and see what it's matching right in front of you.</p> <p>None of these 'visual regex builder' things are substitutes for actually LEARNING regular expressions.</p>
3,181
<p>Currently, I am working on a new version control system as part of a final year project at University. The idea is to make it highly adaptable and pluggable.</p> <p>We're using the OSGi framework (Equinox implementation) to manage our plug ins. My problem is that I can't find a simple &amp; easy to use method for testing OSGi bundles.</p> <p>Currently, I have to build the bundle using Maven and then execute a test harness. I'm looking for something like the JUnit test runner for Eclipse, as it will save me a bunch of time.</p> <p>Is there a quick and easy way to test OSGi bundles?</p> <p>EDIT: I don't need something to test Eclipse plug ins or GUI components, just OSGi bundles.</p> <p>EDIT2: Is there some framework that supports JUnit4?</p>
<p>Spring Dynamic Modules has excellent support for <a href="http://static.springframework.org/osgi/docs/current/reference/html/testing.html" rel="noreferrer"> testing OSGi bundles</a>.</p>
<p>How about bnd-testing-maven-plugin?</p> <p>It allow running JUnit inside a running container like Felix or Equinox. If you used the BNDTools for eclipse this is very similar but just maven withpout eclipse and without a UI.</p> <p><a href="https://github.com/bndtools/bnd/tree/master/maven/bnd-testing-maven-plugin" rel="nofollow noreferrer">https://github.com/bndtools/bnd/tree/master/maven/bnd-testing-maven-plugin</a></p> <p>also look at the effectiveosgi archetype for maven. This will give you a good starting point to build your project or just add tests.</p> <p><a href="https://github.com/effectiveosgi" rel="nofollow noreferrer">https://github.com/effectiveosgi</a></p>
9,954
<p>I am interested to know whether anyone has written an application that takes advantage of a <a href="http://en.wikipedia.org/wiki/GPGPU" rel="nofollow noreferrer">GPGPU</a> by using, for example, <a href="http://www.nvidia.com/object/cuda_get.html" rel="nofollow noreferrer">nVidia CUDA</a>. If so, what issues did you find and what performance gains did you achieve compared with a standard CPU?</p>
<p>I have been doing gpgpu development with <a href="http://ati.amd.com/technology/streamcomputing/sdkdwnld.html" rel="nofollow noreferrer">ATI's stream SDK</a> instead of Cuda. What kind of performance gain you will get depends on a <strong><em>lot</em></strong> of factors, but the most important is the numeric intensity. (That is, the ratio of compute operations to memory references.)</p> <p>A BLAS level-1 or BLAS level-2 function like adding two vectors only does 1 math operation for each 3 memory references, so the NI is (1/3). This is always run <em>slower</em> with CAL or Cuda than just doing in on the cpu. The main reason is the time it takes to transfer the data from the cpu to the gpu and back.</p> <p>For a function like FFT, there are O(N log N) computations and O(N) memory references, so the NI is O(log N). If N is very large, say 1,000,000 it will likely be faster to do it on the gpu; If N is small, say 1,000 it will almost certainly be slower.</p> <p>For a BLAS level-3 or LAPACK function like LU decomposition of a matrix, or finding its eigenvalues, there are O( N^3) computations and O(N^2) memory references, so the NI is O(N). For very small arrays, say N is a few score, this will still be faster to do on the cpu, but as N increases, the algorithm very quickly goes from memory-bound to compute-bound and the performance increase on the gpu rises very quickly.</p> <p>Anything involving complex arithemetic has more computations than scalar arithmetic, which usually doubles the NI and increases gpu performance.</p> <p><a href="https://i.stack.imgur.com/kXBjR.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kXBjR.gif" width="500" height="298"></a><br> <sub>(source: <a href="http://home.earthlink.net/~mtie/CGEMM%20081121.gif" rel="nofollow noreferrer">earthlink.net</a>)</sub> </p> <p>Here is the performance of CGEMM -- complex single precision matrix-matrix multiplication done on a Radeon 4870.</p>
<p>Yes. I have implemented the <a href="http://www.cs.huji.ac.il/~cheny/reading/diffusion/classic.pdf" rel="nofollow noreferrer">Nonlinear Anisotropic Diffusion Filter</a> using the CUDA api.</p> <p>It is fairly easy, since it's a filter that must be run in parallel given an input image. I haven't encountered many difficulties on this, since it just required a simple kernel. The speedup was at about 300x. This was my final project on CS. The project can be found <a href="http://projetos.inf.ufsc.br/arquivos_projetos/projeto_833/tcc_EdisonGustavoMuenz.pdf" rel="nofollow noreferrer">here</a> (it's written in Portuguese thou).</p> <p>I have tried writing the <a href="http://www.dam.brown.edu/people/mumford/Papers/DigitizedVisionPapers--forNonCommercialUse/89-Mumford-Shah.pdf" rel="nofollow noreferrer">Mumford&amp;Shah</a> segmentation algorithm too, but that has been a pain to write, since CUDA is still in the beginning and so lots of strange things happen. I have even seen a performance improvement by adding a <code>if (false){}</code> in the code O_O.</p> <p>The results for this segmentation algorithm weren't good. I had a performance loss of 20x compared to a CPU approach (however, since it's a CPU, a different approach that yelded the same results could be taken). It's still a work in progress, but unfortunaly I left the lab I was working on, so maybe someday I might finish it.</p>
7,915
<p>I need to import a csv file into <strong>Firebird</strong> and I've spent a couple of hours trying out some tools and none fit my needs.</p> <p>The main problem is that all the tools I've been trying like <a href="http://www.sqlmanager.net/products/ibfb/dataimport" rel="noreferrer">EMS Data Import</a> and <a href="http://www.sqlmaestro.com/products/firebird/datawizard/help/06_01_05_csv/" rel="noreferrer">Firebird Data Wizard</a> expect that my CSV file contains all the information needed by my Table.</p> <p>I need to write some custom SQL in the insert statement, for example, I have a CSV file with the city name, but as my database already has all the cities in another table (normalized), I need to write a subselect in the insert statement to lookup for the city and write its ID, also I have a stored procedure to cread GUIDS.</p> <p>My insert statement would be something like this:</p> <pre><code>INSERT INTO PERSON (ID, NAME, CITY_ID) VALUES((SELECT NEW_GUID FROM CREATE_GUID), :NAME, (SELECT CITY_ID FROM CITY WHERE NAME = :CITY_NAME) </code></pre> <p>How can I approach this?</p>
<p>It's a bit crude - but for one off jobs, I sometimes use Excel.</p> <p>If you import the CSV file into Excel, you can create a formula which creates an INSERT statement by using string concatenation in the formula. So - if your CSV file has 3 columns that appear in columns A, B, and C in Excel, you could write a formula like...</p> <pre><code>="INSERT INTO MyTable (Col1, Col2, Col3) VALUES (" &amp; A1 &amp; ", " &amp; B1 &amp; ", " &amp; C1 &amp; ")" </code></pre> <p>Then you can replicate the formula down all of your rows, and copy, and paste the answer into a text file to run against your database.</p> <p>Like I say - it's crude - but it can be quite a 'quick and dirty' way of getting a job done!</p>
<p>A tool I recently tried that worked outstandingly well is <a href="http://www.volny.cz/iprenosil/interbase/fsql.htm" rel="nofollow noreferrer">FSQL</a>.</p> <p>You write an IMPORT command, paste it into <code>FSQL</code> and it imports the CSV file into the Firebird table.</p>
2,966
<p>So my company uses a delightfully buggy program called Rational Purify (as a plugin to Microsoft Visual Developer Studio) to manage memory leaks. The program is deigned to let you click on a memory leak after you have encountered it, and then jump to the line that the leak occurs on.</p> <p>Unfortunately Purify is malfunctioning and Purify will not jump to the place that the leak occurred it only mentions the class and method that the leak occurs in. Unfortunately, sometimes this is about as useful as hiring a guide to help you hunt bears and having him point to the forest and tell you there are bears there.</p> <p>Does anyone with Purify experience have any idea how I might fix this problem or have a good manual to look though?</p>
<p>Generally you have two options, one exclude modules DLL's from instrumentation in Purify, it helps some times. Second is get BoundsChecker, this does compile time instrumentation much slower but the level of detail is an order of magnitude better.</p> <p>We generally use Purify on check-in, sanity checking, and BoundsChecker when we know a bug/crash exists.</p> <p>BoundsChecker has some nice features like only instrument files A.cpp &amp; B.cpp, excluding all the rest.</p> <p>Be aware neither of these two applications function on 64 bit operating systems, and BoundsChecker will not install on 64 bit OS. Most frustrating if you make the switch to native 64 bit development with 32 bit back port!</p>
<p>Are you sure you have debug build? Or rather you have all PDB's enabled? Try WindDbg on your executable and check with !lmi command what is visible.</p> <p>Is whole code properly instrumented?</p> <p>Also consider using something else like <a href="http://www.codeproject.com/KB/applications/visualleakdetector.aspx" rel="nofollow noreferrer">free Visual Leak Detector</a> or Microsoft's tool LeakDiag.</p>
2,741
<p>I'm attempting to print some flexible TPE filament. But I failed to imagine TPE was this difficult to print.</p> <p>Specs of the shop-brand filament:<br> Red 1.75&nbsp;mm TPE (+-0.05&nbsp;mm).<br> Hardness: 45D.<br> Print temperature: 220-260&nbsp;&deg;C with 0-95&nbsp;&deg;C bed.</p> <p>I'm trying to print <a href="http://www.thingiverse.com/thing:1936797" rel="nofollow noreferrer">this</a> on my original Prusa i3 MK3S with powder coated sheet with 0.20&nbsp;mm layer with PrusaSlicer 2.0.0.</p> <p>What happens? After 3 or 4 layers, the print warps a lot and detaches from the plate. The object is 40&nbsp;mm long. The next image shows the print detaching from the build plate as well as a skirt of two layers height:</p> <p><a href="https://i.stack.imgur.com/yfIFS.jpg" rel="nofollow noreferrer" title="Image of detached TPE print from build plate"><img src="https://i.stack.imgur.com/yfIFS.jpg" alt="Image of detached TPE print from build plate" title="Image of detached TPE print from build plate"></a></p> <p>I've tried warmer/colder, more/less fan, faster/slower. I went down to 1&nbsp;mm<sup>3</sup>/s, which is 7&nbsp;mm/s. For reference, PLA prints 15&nbsp;mm<sup>3</sup>/s.</p> <p>I readjusted my z-cal, and when I test print a first layer with TPE it's difficult to remove from the bed.</p> <p>I also attempted the glue stick on smooth PEI sheet. Worked until the first few layers of infill, then it still warped.</p> <p>Do I have bad filament with too much shrink, poor settings or is this 45D just too soft for my MK3s? </p> <p><em>Bonus pile of failures:</em><br> <a href="https://i.stack.imgur.com/ufVcO.jpg" rel="nofollow noreferrer" title="Image of failed TPE prints from build plate"><img src="https://i.stack.imgur.com/ufVcO.jpg" alt="Image of failed TPE prints from build plate" title="Image of failed TPE prints from build plate"></a></p>
<p>I have experienced this problem. This picture is one that I could have taken. </p> <p>It has always been because I was putting too much plastic into the available space.</p> <p>This has been caused two things: overextrusion -- squirting out too much plastic for the intended layer height, and the bed being too "high" so that the gap between the nozzle and the bed is too thin.</p> <p>In both cases, too much plastic is trying to be placed in too small a volume. The plastic has to go somewhere, and ripples follow. Because the nozzle rubs against the adjacent lines which have already been deposited, an up-bump pushes up the nozzle on the line beside the bump, and a coherent pattern of ripples can form.</p> <p>The "bump up" is a real effect from the elasticity of the Z-axis, including all the resulting strains of twisting and lifting the nozzle.</p>
<p>This could be a number of things, I personally think it could be either over extrusion or an issue with one of the belts. Depending on the printer, you may need to manually go in and adjust your steps per millimeter, which you should be able to find a guide on. If that doesn't work, then look into belt tension adjustment. Hope this is able to help! I like to use the <a href="https://www.simplify3d.com/support/print-quality-troubleshooting/over-extrusion/" rel="nofollow noreferrer">Simplify3D Print Quality Guide</a> for situations like this, it tends to be very useful.</p>
1,395
<p>In the Visual Studio toolbar, you can enter commands into the search box by prefixing them with a > symbol. Is there any way to disable this? I've never used the feature, and it's slightly annoying when trying to actually search for something that you know is prefixed by greater-than in the code. It's particularly annoying when you accidentally search for "> exit" and the IDE quits (I knew there was a line in the code that was something like <code>if(counter &gt; exitCount)</code> so entered that search without thinking).</p> <p>At the very least, can you escape the > symbol so that you can search for it? Prefixing with ^ doesn't seem to work.</p>
<p>This is a really cool feature. I've poked through the <a href="http://msdn.microsoft.com/en-us/library/1665hyw1(VS.80).aspx" rel="nofollow noreferrer">feature documentation</a>, and the accompanying <a href="http://msdn.microsoft.com/en-us/library/c338aexd(VS.80).aspx" rel="nofollow noreferrer">command list</a>, and not a heck of a lot is showing up in terms of turning it off.</p> <p>If you want to search for <code>&gt;exit</code>, you could always type <code>&gt;Edit.Find &gt;exit</code> in the search box; that seems to do the trick. A bit verbose, though, but it really is an edge case.</p>
<blockquote> <p>Wow, I didn't know that. Where do I find the list of possible commands?</p> </blockquote> <p>The commands are the same as those you can enter in the command window, so you can pretty much drive the entire IDE and debugger using it. There are a load of predefined aliases for common commands. Open up the command window and enter <code>alias</code> for a list, to get you started.</p>
3,555
<p>By default IntelliJ IDEA 7.0.4 seems to use 4 spaces for indentation in XML files. The project I'm working on uses 2 spaces as indentation in all it's XML. Is there a way to configure the indentation in IntelliJ's editor?</p>
<p>Sure there is. This is all you need to do:</p> <ul> <li>Go to</li> </ul> <pre>File -> Settings -> Global Code Style -> General</pre> <ul> <li>Disable the checkbox next to 'Use same settings for all file types' </li> <li>The 'XML' tab should become enabled. Click it and set the 'tab' (and probably 'indent') size to 2.</li> </ul>
<p>Note: make sure to not use the <em>same</em> file in two project, or your settings might revert to the default (4 spaces), instead of the custom XML tab indent size.</p> <p>See <a href="https://youtrack.jetbrains.com/issue/IDEA-130878" rel="nofollow">bug IDEA-130878</a>, for the latest IntelliJ IDEA 14 (Oct 2014)</p>
5,882
<p>First of all I'm working with a Folger Tech Prusa i3 kit, if that makes a difference. Also I believe the Arduino is a Mega 2560.</p> <p>I know somewhere in the back of my head that electrically programmable ROM like what must be on the Arduino board storing the firmware degrades a little, each time you write to it. Right now I'm trying to calibrate away another print problem, and I think I need to modify the firmware yet again, which I've already done several times. So I'm starting to worry about how many times I can do that.</p> <p>Well, once I remembered the acronym "EEPROM", and after a little googling, I came across this, <a href="https://www.arduino.cc/en/Reference/EEPROMWrite" rel="nofollow noreferrer">Arduino - EEPROM</a>, which says that it can handle 100k cycles, so I think I'm onto the answer, but the problem is I'm not sure if a cycle is an entire file being uploaded? Wouldn't it be a single blip of data? And if so how many cycles would the average Marlin file consume?</p> <p>I also found this:</p> <blockquote> <p>but I'd be very surprised if I've uploaded to it more than 2000 times</p> </blockquote> <p>on <a href="http://forum.arduino.cc/index.php?topic=58243.0" rel="nofollow noreferrer">Mega2560 bricked? not detected, DFU failing</a>, indicating that the answer might be as low as 2000. </p> <p>Also, this:</p> <blockquote> <p><strong>Failure modes</strong></p> <p>There are two limitations of stored information; endurance, and data retention.</p> <p>During rewrites, the gate oxide in the floating-gate transistors gradually accumulates trapped electrons. The electric field of the trapped electrons adds to the electrons in the floating gate, lowering the window between threshold voltages for zeros vs ones. After sufficient number of rewrite cycles, the difference becomes too small to be recognizable, the cell is stuck in programmed state, and endurance failure occurs. The manufacturers usually specify the maximum number of rewrites being 1 million or more.[5]</p> <p>During storage, the electrons injected into the floating gate may drift through the insulator, especially at increased temperature, and cause charge loss, reverting the cell into erased state. The manufacturers usually guarantee data retention of 10 years or more.[6]</p> </blockquote> <p>from Wikipedia: <a href="https://en.wikipedia.org/wiki/EEPROM#Failure_modes" rel="nofollow noreferrer">EEPROM - Failure Modes</a>, indicating the answer might be into the millions.</p> <p>At this point I'm just wondering if an expert might see this and relieve my angst...</p>
<p>The EEPROM is <em>not</em> where the program itself is stored, what's relevant for your question is the flash. The flash in the ATmega2560 <a href="http://www.atmel.com/images/atmel-2549-8-bit-avr-microcontroller-atmega640-1280-1281-2560-2561_datasheet.pdf" rel="nofollow noreferrer">is rated for 10,000 cycles</a> (i.e. you can reprogram it <em>at least</em> 10,000 times).</p>
<p>The AVR has SRAM for variables (what is usually called RAM), it has EEPROM for non volatile variables and it has flash for the executable code. (Harvard Architecture!)</p> <p>For re-flashing the firmware neither SRAM nor EEPROM write rates are important, but the Flash rates are. The flash write rates are in the region of 100 thousand to a million so that should not be a problem.</p> <p>The article you linked also states that he did not more than 2000 rewrites and therefore should be fine. I can only agree. A few thousand re-flashes is no problem. Once you get closer to 100 thousand you can start to worry.</p> <p>Flash bits can only be written from 1 to 0. Erasing the flash writes all bits to 1. Erasing can only be done on a flash page (size is device dependent but usually a multiple of 512).</p>
237
<p>I am developing an application to install a large number of data files from multiple DVDs. The application will prompt the user to insert the next disk, however Windows will automatically try to open that disk either in an explorer window or ask the user what to do with the new disk.<br> How can I intercept and cancel auto play messages from my application?</p>
<p>There are two approaches that I know of. The first and simplest is to register the special Windows message "QueryCancelAutoPlay" and simply return 1 when the message is handled. This only works for the current window, and not a background application.</p> <p>The second approach requires inserting an object that implements the COM interface <code>IQueryCancelAutoPlay</code> COM interface into the Running Object Table.</p>
<p>Alternatively, you could just programmatically save the current state of autoplay and turn it off when your program starts, then restore the original state when your program closes. This would be a lot simpler. Check out <a href="http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/93502.mspx?mfr=true" rel="nofollow noreferrer">the NoDriveTypeAutoRun key</a>.</p>
3,282
<p>Is there a quick one-liner to call datepart in Sql Server and get back the name of the day instead of just the number?</p> <pre><code>select datepart(dw, getdate()); </code></pre> <p>This will return 1-7, with Sunday being 1. I would like 'Sunday' instead of 1.</p>
<pre><code>select datename(weekday, getdate()); </code></pre>
<p>This is not possible without using the result to select the day yourself. For one thing the textual representation of the day is locale-dependent. For another the returned value depends upon the 'datefirst' setting.</p>
3,356
<p>From the Java 6 <a href="http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html" rel="noreferrer">Pattern</a> documentation:</p> <blockquote> <p>Special constructs (non-capturing)</p> <p><code>(?:</code><i>X</i><code>)</code>&nbsp;&nbsp;&nbsp;<i>X</i>, as a non-capturing group</p> <p>…</p> <p><code>(?></code><i>X</i><code>)</code>&nbsp;&nbsp;&nbsp;<i>X</i>, as an independent, non-capturing group</p> </blockquote> <p>Between <code>(?:X)</code> and <code>(?&gt;X)</code> what is the difference? What does the <strong>independent</strong> mean in this context?</p>
<p>It means that the grouping is <a href="http://www.regular-expressions.info/atomic.html" rel="noreferrer">atomic</a>, and it throws away backtracking information for a matched group. So, this expression is possessive; it won't back off even if doing so is the only way for the regex as a whole to succeed. It's "independent" in the sense that it doesn't cooperate, via backtracking, with other elements of the regex to ensure a match.</p>
<p><code>(?&gt;X?)</code> equals <code>(?:X)?+</code>, <code>(?&gt;X*)</code> equals <code>(?:X)*+</code>, <code>(?&gt;X+)</code> equals <code>(?:X)++</code>.</p> <p>Taking away the fact that X must be a non-capturing group, the preceding equivalence is:</p> <p><code>(?&gt;X?)</code> equals <code>X?+</code>, <code>(?&gt;X*)</code> equals <code>X*+</code>, <code>(?&gt;X+)</code> equals <code>X++</code>.</p>
7,329
<p>Alright.</p> <p>So I figure it's about time I get into unit testing, since everyone's been banging on about it for long enough. I've installed NUnit and gone through a few "intro to unit testing" type tutorials.</p> <p>I'm currently putting together a small framework to help with the rebuild of one of our web apps, so I've created a VS2008 project for my framework and I want to unit test it as I go.</p> <p>How on earth do I go about unit testing the WebControls? The methods are all protected or private, and since it's a framework, there isn't much else but WebControls.</p> <p>Any pointers?</p> <p>Burns</p>
<p>You can do model-view-controller or model-view-presenter type architectures without using a full blown framework. You already found out that unit-testing ui-components is difficult. There are ways around that but you probably don't want to go that route. Usually this will make your tests very hard to maintain, more maintenance nightmare's is something programmers can do without :-)</p> <p>Try to separate out the functionality you want to test in a "controller" or "presenter" class. Then test that class. To make it more testable you can hide the usercontrol class (the view) behind an interface and make the controller or presenter talk to the view through the interface. That way you can mock up the view in your tests.</p> <p>I know this sounds like a lot of work and it seems like a workaround but if you get used to this it's a realy nice architecture that makes it far easier to change ui behaviour. You can always start using a "real" mvc framework when you realy need it :-)</p>
<p>The MVC framework mentioned above is the best way to test what the control does. However testing how it works is a bit different.</p> <p>This is totally off the cuff but you could make the user control expose some protected methods and properties to return validation information and then have a testing user control inherit it. That control could populate fields, press buttons and what not. Kind of messy but it could work.</p>
5,105
<p>What open source licenses are more corporate-friendly, i.e., they can be used in commercial products without the need to open source the commercial product?</p>
<p>I recommend the Apache License (specifically, version 2). It is not a “copy left” license and it addresses several matters that are important to established companies and their lawyers.</p> <p>“Copy left” is the philosophy of the free software foundation requiring anything incorporating the licensed opens source code to also be licensed as open source. That philosophy is regarded as poison by established companies that want to keep their products proprietary.</p> <p>Aside from not having “copy left” provisions, the Apache license specifically addresses the grant of rights from project contributors and it expressly addresses the fact that modern companies are typically made up for more than one legal entity (for example, a parent company and its subsidiaries). Most open source licenses don’t address these points.</p> <p>Whatever license you choose, if you want your code to be “corporate friendly,” in the sense that you want it to be incorporated into commercial, non-open source products, it is essential that you avoid GPL and other “copy left” type licenses. While it would be best to consult with your own lawyer before investing time or money in a project for which this is an important factor, a quick shorthand for licenses that are and are not “copy left” can be found on the Free Software Foundation’s website. They identify which licenses they don’t find meet their standards as “copy left.” The ones FSF rejects are most likely the ones that will be corporate friendly in this sense.</p> <p>(Although the question didn’t ask this, it is worth mentioning that, with very few exceptions, even GPL and other “copy left” type licenses are perfectly corporate friendly if they are only used internally by the commercial entities and not incorporated into their products.)</p>
<p>MIT, Apache and BSD tend to be the most corporate friendly. The least corporate friendly that I have ran across are usually Q Public, GPL and Mozilla...</p>
4,814
<p>I know there's a bug with conditional visibility and page breaks with SQL 2005, but I wonder if anyone has come up with a work around.</p> <p>I have a table that has a conditional visibility expression, and I need a page break at the end of the table.</p> <ul> <li>If I set the PageBreakAtEnd property to true. It is ignored no matter what. Remove the visibility condition and it works.</li> <li>If I place the table inside a rectangle with the conditional visibility on the table, and the page break on the table. Same result. The page break property is ignored.</li> <li>If I set the rectangle with the PageBreakAtEnd property and the table with the visibility condition, then I still get a page break even when the table isn't shown.</li> </ul> <p>Any other ideas on what to try? I'm almost at the point where I need a separate report rather than conditional visibility :(</p> <p><strong>Edit: @Josh:</strong> That has the same problems. If the second table has conditional visibility it doesn't work. If it doesn't have the visibility expression, then I get the page break all the time.</p> <p>@<strong>Erick:</strong> I really wanted that to be the answer but unfortunately it doesn't work. When the visibility expression evaluates to hidden, there's a big gap where the rectangles would be (which I can live with), and when it evaluates to visible, the page breaks still don't work. </p>
<p>Place two rectangles, one inside the other.<br> Place your table inside the inner rectangle and set it to always be visible.<br> Set the inner rectangle's Page Break to Insert After Rectangle.<br> Set the outer rectangle's visibility to use your conditional expression.</p> <p>The page break and the conditional visibility are now separated, and the inner rectangle's page break won't be processed if it is not visible, but it will if it is visible.</p> <p><strong>Edit</strong>: When I tried this, it did not appear to work in the Preview tab in Visual Studio, but it did work in the Print Preview and when I exported the report to PDF.</p>
<p>Add a second (empty) table immediately after the first. Page break after that.</p>
2,984
<p>I am printing some minion chess pieces for my teacher at school and on every model I have found something called "ghosting", or at least I heard that is what it is called. For example there is a strap on the model for the pants. And going left and right there is very shallow "straps" or something happening. </p> <p>I am interested to know what causes this to happen and how to fix it. It is not super bad, but would be nice to fix.</p>
<p><strong>Ghosting is an artefact in the print due to the vibrations in the printer that are induced by rapid changes of direction</strong>. It is important not to confuse them with inherent vibrations in the printer due for example to the belts being loose or the bearings not being in perfect order.</p> <p>The good news is that it is relatively easy to tell them apart: <strong>ghosting</strong> (also known as "ringing" or "ripples" or "waves" or a number of other names...) <strong>is always downstream of a change of direction, and fades rapidly</strong>.</p> <p><a href="https://i.stack.imgur.com/xsYP9.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/xsYP9.jpg" alt="ghosting"></a></p> <p>Inherent vibrations - on the other hand - tend to be consistently present when printing along a given direction, and do not fade.</p> <p><a href="https://i.stack.imgur.com/Ao2ZR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Ao2ZR.jpg" alt="inherent vibrations"></a></p> <p>Mechanically, ghosting works like this:</p> <ol> <li>The moving part is travelling along - for example - the x-axis, when suddenly the direction of movement becomes the y-axis.</li> <li>At that moment, the stepper motor of the x-axis stop rotating, but the <a href="https://en.wikipedia.org/wiki/Momentum" rel="noreferrer">momentum</a> of the moving part stretches the belt even so slightly past the intended stop point.</li> <li>At this moment the belt becomes like a rubber bend / spring, absorbs the kinetic energy of the moving mass and releases it by "throwing" it past the intended stop point in the other direction.</li> <li>This keeps on repeating a number of times, but at each pass, some of the energy is dissipated, and the moving mass moves less end less away from the ideal stopping point.</li> <li>While all of the above is happening, the object has also begun to move along the y-axis, so the extruded plastic looks "weavey" along the y-axis.</li> </ol> <p>Understanding how this process works, makes it possible to understan why the three main factors affecting ghosting are:</p> <ul> <li>The <strong>amount of mass</strong> being moved</li> <li>The <strong>speed, acceleration and jerk</strong> settings</li> <li>The <strong>elasticity of the mechanical components</strong></li> </ul> <p>Namely, <strong>mass and speed are important because their product is the momentum</strong>. That in turn means that diminishing either one of the two will reduce the amount of "overshooting" past the stopping point.</p> <p>Elasticity of the mechanical components is important as <strong>the more flex/stretch the part can take for a given amount of force, the more overshooting</strong> a given momentum will result in.</p> <p>Finally, <strong>acceleration and jerk are important because</strong> - simplifying things a bit - <strong>the faster the change of direction happens, the less time the system has to adjust</strong> without vibrating.</p> <p>So, concretely... what can you do to fix/reduce ghosting? Three things, of course! :)</p> <ol> <li><strong>Reduce the mass being moved</strong>. Depending on the geometry of your printer, the mass being moved could be the bed+print, the printing head, or an entire gantry. These are normally considerations done when designing the printer itself, and engineers normally mitigate problems by using lighter materials (plastic over metal, aluminium or carbon fiber over steel, etc...), or adopting different designs (like using a Bowden extruder instead of a direct one, to save the weight of the stepper motor).</li> <li><strong>Reduce speed, acceleration and/or jerk</strong>. Speed is normally the safest bet, as - besides your prints taking longer - there is really no penalty for it. Acceleration and jerk - on the other hand - can cause overestrusion at sharp corners.</li> <li><strong>Reduce the elasticity of the system</strong>. This is commonly achieved by tightening the belts and eventually switching to more rigid rods / tracks / rails.</li> </ol> <p>A couple of resources that may come in handy for you to understand and solve the problem better:</p> <ul> <li>A <a href="http://www.desiquintans.com/ringing" rel="noreferrer">really nice article</a> with illustrations (two of which I "stole" for this post)</li> <li>A <a href="https://www.thingiverse.com/thing:277394" rel="noreferrer">test model</a> specifically designed to highlight any possible ringing problem with the printer.</li> <li>A <a href="https://youtu.be/AKTvykTPjQw" rel="noreferrer">video</a> showing lots of different test prints done with various settings (very useful to understand how changing the above parameters affects the print).</li> </ul>
<p>To expand on the #3 solution: reducing the elasticity of the system, if you have your filament mounted on the top of your printer, placing the filament elsewhere on a separate spool holder can also reduce ghosting. Tightening the belts and moving my filament got rid of ghosting for me on my MP Maker Select.</p>
806
<p>Under what circumstances might you want to use multiple indirection (that is, a chain of pointers as in <code>Foo **</code>) in C++?</p>
<p>Most common usage as @aku pointed out is to allow a change to a pointer parameter to be visible after the function returns.</p> <pre><code>#include &lt;iostream&gt; using namespace std; struct Foo { int a; }; void CreateFoo(Foo** p) { *p = new Foo(); (*p)-&gt;a = 12; } int main(int argc, char* argv[]) { Foo* p = NULL; CreateFoo(&amp;p); cout &lt;&lt; p-&gt;a &lt;&lt; endl; delete p; return 0; } </code></pre> <p>This will print</p> <pre><code>12 </code></pre> <p>But there are several other useful usages as in the following example to iterate an array of strings and print them to the standard output.</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main(int argc, char* argv[]) { const char* words[] = { "first", "second", NULL }; for (const char** p = words; *p != NULL; ++p) { cout &lt;&lt; *p &lt;&lt; endl; } return 0; } </code></pre>
<p>A simple example would be using <code>int** foo_mat</code> as a 2d array of integers. Or you may also use pointers to pointers - lets say that you have a pointer <code>void* foo</code> and you have 2 different objects that have a reference to it with the following members: <code>void** foo_pointer1</code> and <code>void** foo_pointer2</code>, by having a pointer to a pointer you can actually check whether <code>*foo_pointer1 == NULL</code> which indicates that foo is NULL. You wouldn't be able to check whether foo is NULL if foo_pointer1 was a regular pointer. I hope that my explanation wasn't too messy :)</p>
9,655
<p>I've been working through <a href="http://gigamonkeys.com/book" rel="nofollow noreferrer">Practical Common Lisp</a> and as an exercise decided to write a macro to determine if a number is a multiple of another number:</p> <p><code>(defmacro multp (value factor)<br> `(= (rem ,value ,factor) 0))</code></p> <p>so that : <code>(multp 40 10)</code> evaluates to true whilst <code>(multp 40 13)</code> does not </p> <p>The question is does this macro <a href="http://gigamonkeys.com/book/macros-defining-your-own.html#plugging-the-leaks" rel="nofollow noreferrer">leak</a> in some way? Also is this "good" Lisp? Is there already an existing function/macro that I could have used?</p>
<p>Siebel gives an extensive rundown (for simple cases anyway) of possible sources of leaks, and there aren't any of those here. Both <code>value</code> and <code>factor</code> are evaluated only once and in order, and <code>rem</code> doesn't have any side effects.</p> <p>This is not good Lisp though, because there's no reason to use a macro in this case. A function</p> <pre><code>(defun multp (value factor) (zerop (rem value factor))) </code></pre> <p>is identical for all practical purposes. (Note the use of <code>zerop</code>. I think it makes things clearer in this case, but in cases where you need to highlight, that the value you're testing might still be meaningful if it's something other then zero, <code>(= ... 0)</code> might be better)</p>
<p>No, no symbol introduced in the macro's "lexical closure" is released to the outside.</p> <p>Note that leaking isn't NECESSARILY a bad thing, even if accidental leaking almost always is. For one project I worked on, I found that a macro similar to this was useful:</p> <pre><code>(defmacro ana-and (&amp;rest forms) (loop for form in (reverse forms) for completion = form then `(let ((it ,form)) (when it ,completion)) finally (return completion))) </code></pre> <p>This allowed me to get "short-circuiting" of things needed to be done in sequence, with arguments carried over from previous calls in the sequence (and a failure signalled by returning NIL). The specific context this code is from is for a hand-written parser for a configuration file that has a cobbled-together-enough syntax that writing a proper parser using a parser generator was more work than hand-rolling.</p>
8,510
<p>I have a service contract that defines a method with a parameter of type System.Object (xs:anyType in the WSDL). I want to be able to pass simple types as well as complex types in this parameter. Simple types work fine, but when I try to pass a complex type that is defined in my WSDL, I get this error:</p> <p>Element '<a href="http://tempuri.org/:value" rel="nofollow noreferrer">http://tempuri.org/:value</a>' contains data of the '<a href="http://schemas.datacontract.org/2004/07/MyNamespace:MyClass" rel="nofollow noreferrer">http://schemas.datacontract.org/2004/07/MyNamespace:MyClass</a>' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'MyClass' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.</p> <p>Adding it as a known type doesn't help because it's already in my WSDL. How can I pass an object of a complex type via an "xs:anyType" parameter?</p> <p>More info:</p> <p>I believe this works when using NetDataContract, but I can't use that because my client is Silverlight.</p> <p>I have seen references to complex types explicitly extending xs:anyType, but I have no idea how to make WCF generate a WSDL that does that, and I have no idea whether or not it would even help.</p> <p>Thanks</p>
<p>The NetDataContract works because the NetDataContractSerializer includes type information.</p> <p>The KnownType attribute instructs the DataContractSerializer how to deserialize the message. Being implementation specific, this is information over-and-above that defined by the public contract and doesn't belong in the WSDL.</p> <p>You're never going to be able to pass any-old data type because the deserializer needs to identify the appropriate type and create an instance.</p> <p>You may be able to derive your known types at runtime rather than having them hard-coded in the DataContract. Take a look <a href="http://electroholic.com/?p=5" rel="nofollow noreferrer">here</a> for a sample.</p>
<p>Try use data contract Surrogates to map unsupported object that is dot net specific or not interoperable types. See <a href="http://msdn.microsoft.com/en-us/library/ms733064.aspx" rel="nofollow noreferrer">MSDN</a></p>
9,330
<p>I've got some curious marks on my heatbed.</p> <p>It appears to be from my black Sunlu PLA+ (I can just feel it if I scrape my finger nail over it) but I can't scrape it off with the metal spatula.</p> <p>When I try and print over it the filament won't stick.</p> <p>Any suggestions as to what it is and how you get rid of it? <a href="https://i.stack.imgur.com/ofS5K.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ofS5K.jpg" alt="enter image description here"></a></p>
<p>Prusa ships (or has shipped) with two types of PEI build plates. The original (and what I was shipped in February 2019) is a PEI sheet held in place with an adhesive. The marks I've gotten seem to be places where the adhesive has been displaced slightly from long term pressure by the object being printed.</p> <p>In your case, it actually looks like scratches in the PEI. If, after cleaning with water, then 95% Isopropyl alcohol, and finally acetone the scratches still appear, I'd check if they are a problem. Do they transfer onto objects printed on the plate?</p> <p>If you decide you have a problem, I would use a mild kitchen scrubby sponge to "sand" out the scratches. I have two types in my kitchen. The yellow ones are too abrasive. The blue ones are better. Gently use one to make the surface uniform.</p> <p>If you have an adhesive based plate, Prusa sells replacement PEI sheets, with adhesive. The process of changing them seems onerous. Although I bought two spare sheets when I got the printer, I have never been tempted to use one. When my build plate becomes unusable, I will buy another one.</p> <p>Prusa3D also offers a textured build plate, which is more expensive and in short supply. These are a powder-coating process and from pictures and their blog, I infer they are particles of PEI which are melted onto the steel surface. I have no experience with these.</p> <p>I don't know if they are making the current smooth plates with a powder coating process, or if they are still using the adhesive.</p> <p>The adhesive is the weak link in the heated bed. It is only rated for 110 degrees C, which is the temperature limit of the bed. I find that when I print with a hot bed (such as for PETG), the visible ripples in the surface are worse than when printing PLA on a cooler bed.</p>
<p>Edit: As Trish noted, apparently Prusa printers don't ship with Buildtak stickers like the other printers I've used, so this is probably a bad idea in your specific case. For others reading this, only do the sanding shenanigans with buildtak or other stickers that you can easily replace and don't mind wearing down over time.</p> <p>Used to happen to me printing PETG on Buildtak. I ended up using a medium grit sanding sponge to remove the PLA layer. Related, you might want to grab some 1k grit sandpaper for the same reason, it does a great job of freshening up your build surface once builds stop sticking well.</p>
1,331
<p>I've had some discussions recently at work about switching from Subversion to a DVCS like bazaar, and I would like to get other people's opinion.</p> <p>I've managed to crystallize my reluctance to do so into a simple parallel.</p> <blockquote> <p>Version Control can be used well or badly. </p> </blockquote> <p>The 'light side' of version control is when you use it to keep track of your changes, are able to go back to older versions when you break stuff, and when you publish your changes so your peers can see your work-in-progress.</p> <p>The 'dark side' of version control is when you don't use it properly so you don't 'checkpoint' your work by committing regularly, you keep a bunch of changes in your local checkout, and you don't share your changes with others as you make them.</p> <p>Subversion makes both the light side and the dark side relatively hard. All the basics work, but few people really use branching in Subversion (beyond tagging and releasing) because merging is not straightforward at all. The support for it in Subversion itself is terrible, and there are scripts like svnmerge that make it better, but it's still not very good. So, these days, with good branching and merging support considered more and more like the necessity it is for collaborative development, Subversion doesn't match up.</p> <p>On the other hand, the 'dark side' is pretty tough to follow too. You only need to be bitten once by not having your local changes commited once in a while to the online repository, and breaking your code with a simple edit you don't even remember making. So you end up making regular commits and people can see the work you're doing.</p> <p>So, in the end Subversion ends up being a good middle-of-the-road VCS that, while a bit cumbersome for implementing the best practices, still makes it hard to get things very wrong.</p> <p>In contrast, with a DVCS the cost of either going completely light side or dark side is a lot lower. Branching and merging is a lot simpler with these modern VCS systems. But the distributed aspect makes it easy to work in a set of local branches on your own machine, giving you the granular commits you need to checkpoint your work, possibly without ever publishing your changes so others can see, review, and collaborate. The friction of keeping your changes in your local branches and not publishing them is typically lower than publishing them in some branch on a publically available server.</p> <p>So in a nutshell, here's the question: if I give our developers at work a DVCS, how can I make sure they use it to go to the 'light side', still publish their changes in a central location regularly, and make them understand that their one week local hack they didn't want to share yet might be just the thing some other developer could use to finish a feature while the first one is on holiday? </p> <p>If both the light side and the dark side of DVCS are so easy to get to, how do I keep them away from the dark side?</p>
<p>If there are developers on your team that don't want to share their "one week local hack" then thats the problem, not the source control tool you are using. A better term for the "dark side" you are describing is "the wrong way" of coding for a team. Source control is a tool used to facilitate collaborative work. If your team is not clear about the fact that the goal is to share the work, then the best reason to use source control is not even applicable.</p> <p>Also, I think you might be a little confused about distributed source control. There is no publishing to a central locations. Some branches are more important than others and there exists many many branches. Keeping that in mind, I think that distributed source control really works best for popular open source projects. I'm under the perception that centralized source control is still better for development withing a company or some other clearly defined entity.</p>
<p>I believe svn's merging has been somewhat overhauled in the latest release.</p>
4,670
<p>I'm wondering if there is some trick to power my OctoPi with the power supply of my 3D printer. I'm using an Geeetech I3 Pro W.</p> <p>The power supply itself should be able, but the output is as far as I'm aware of 3.3 volts. Not my desired 5&nbsp;V for USB, it would be a shame if I really would need to buy a new power supply when I have a strong one actually running. My current power supply causes a lot of "Under-voltage detected!" warnings.</p> <p>After thinking a little about the specs, there are cigarette lighter adapter for cars they use 12&nbsp;V. Has anyone experience with using that on his printer?</p>
<p>What you are looking for is called a "buck converter" or a "step down module". These literally cost about half a buck/Euro a piece. These converters convert a high voltage into a low voltage, the better ones are able to draw 2 to 3 Amps, which is required for stable operation of the Raspberry Pi.</p> <p>If you have an old computer power supply of a decent brand (probably not as you refer to a kit/assembled printer, but added for completeness), you can even use the standby 5&nbsp;V line out and switch the power supply on using a relay to short the green wire of the PSU to ground. This is how I use it on one of my printers.</p> <p>Note to power the Raspberry Pi through the micro USB port, to not bypass safety features.</p>
<p>Thank you guys for your help. I ended up with a suggested <a href="https://www.amazon.de/dp/B0768D2NYH?tag=t--21" rel="nofollow noreferrer">"Step Down Power Module"</a> which works fine for me. I connected that module directly with the power supply of the printer with a blade connector. The first startup showed me a couple of low voltage warnings, but the second start worked fine without any warnings. I didn't know how the UI looks like without the warning on the top.</p> <p>So I avoided that fancy and risky back powering since I power it now as intended. Now I have one power supply less which is great out of my opinion.</p>
1,299
<p>Does anyone know of a disassembler for <em>ARMV4i</em> executables and DLLs?</p> <p>I've got a plug-in DLL I'm writing with a very rare <code>data abort</code> (&lt;5% of the time) that I have narrowed down to a specific function (via dumpbin and the address output by the <code>data abort</code>). However, it is a fairly large function and I would like to narrow it down a little. I know it's happening in a <code>memset()</code> call, but that particular function has about 35 of them, so I was hoping that by looking at the disassembly I could figure out where about the problem actually is.</p>
<p>IDA Pro will definitely do ARM disassembly. And they (Datarescue) once arranged me a licence at about 11PM local time, so I like to recommend them...</p> <p>I see from <a href="http://www.datarescue.com/idabase/" rel="nofollow noreferrer">http://www.datarescue.com/idabase/</a> that there's been some rearrangement of the company, but I guess it's still a good product.</p> <p>Here's the link to the new publisher: <a href="http://www.hex-rays.com/idapro/" rel="nofollow noreferrer">http://www.hex-rays.com/idapro/</a></p>
<p>A couple of years ago I found an ARM disassembler I used while doing some embedded work. However, I don't remember its name - though I think it was part of a larger package like an emulator or something.</p> <p>In your case, could you ask your compiler to generate an assembly listing of the compiled code? That might help give you some scope.</p> <p>Failing that, you could break up your function into one or more new functions, if all you can get is the stack trace. Then break up the new function into one or more again. This is the tried-and-true "divide and conquer" method. And if you have 35 calls to memset() in one function, it might be a good idea from a design standpoint too!</p> <p>Update: I found the package I used: <a href="http://armphetamine.sourceforge.net/" rel="nofollow noreferrer">ARMphetamine</a>. It worked for the ARM9 code I was developing, but it looks like it hasn't been updated in quite some time.</p>
4,228
<p>I could swear I've seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so:</p> <pre><code>void foo()_ </code></pre> <p>to</p> <pre><code>void foo() { _ } </code></pre> <p>Is this a built-in feature?</p>
<p>Check out <a href="http://www.jetbrains.com/resharper/documentation/feature_map.html" rel="nofollow noreferrer">Resharper</a> - it is a Visual Studio add-on with this feature, among many other development helps.</p> <p>Also see <a href="http://www.knowdotnet.com/articles/csharpcompleter.html" rel="nofollow noreferrer">C# Completer</a>, another add-on.</p> <p>If you want to roll your own, check out <a href="http://www.developer.com/net/cplus/article.php/3347271" rel="nofollow noreferrer">this article</a>. Insane that one should have to do that, though.</p>
<p>I just created one based on @Luke's above. This one, you want to hit Enter then hit your key combination and it will insert:</p> <pre><code>if () { } else { } </code></pre> <p>And it will put your cursor in the parenthesis by the if statement.</p> <pre><code>Sub IfStatement() DTE.ActiveDocument.Selection.Text = "if ()" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text = "{" DTE.ActiveDocument.Selection.NewLine(2) DTE.ActiveDocument.Selection.Text = "}" DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text = "else" DTE.ActiveDocument.Selection.NewLine(2) DTE.ActiveDocument.Selection.Text = "{" DTE.ActiveDocument.Selection.NewLine(2) DTE.ActiveDocument.Selection.Text = "}" DTE.ActiveDocument.Selection.LineUp(False, 7) DTE.ActiveDocument.Selection.EndOfLine() DTE.ActiveDocument.Selection.CharLeft(3) End Sub </code></pre>
3,090
<p>Imagine this directory structure:</p> <pre><code>app/ __init__.py sub1/ __init__.py mod1.py sub2/ __init__.py mod2.py </code></pre> <p>I'm coding <code>mod1</code>, and I need to import something from <code>mod2</code>. How should I do it? </p> <p>I tried <code>from ..sub2 import mod2</code> but I'm getting an "Attempted relative import in non-package".</p> <p>I googled around but found only "<code>sys.path</code> manipulation" hacks. Isn't there a clean way? </p> <hr> <p>Edit: all my <code>__init__.py</code>'s are currently empty </p> <p>Edit2: I'm trying to do this because sub2 contains classes that are shared across sub packages (<code>sub1</code>, <code>subX</code>, etc.).</p> <p>Edit3: The behaviour I'm looking for is the same as described in <a href="http://www.python.org/dev/peps/pep-0366/" rel="noreferrer">PEP 366</a> (thanks John B)</p>
<p>Everyone seems to want to tell you what you should be doing rather than just answering the question.</p> <p>The problem is that you're running the module as '__main__' by passing the mod1.py as an argument to the interpreter.</p> <p>From <a href="http://www.python.org/dev/peps/pep-0328/" rel="noreferrer">PEP 328</a>:</p> <blockquote> <p>Relative imports use a module's __name__ attribute to determine that module's position in the package hierarchy. If the module's name does not contain any package information (e.g. it is set to '__main__') then relative imports are resolved as if the module were a top level module, regardless of where the module is actually located on the file system.</p> </blockquote> <p>In Python 2.6, they're adding the ability to reference modules relative to the main module. <a href="http://python.org/dev/peps/pep-0366/" rel="noreferrer">PEP 366</a> describes the change.</p> <p><strong>Update</strong>: According to Nick Coghlan, the recommended alternative is to run the module inside the package using the -m switch.</p>
<p>This method queries and auto populates the path:</p> <pre class="lang-py prettyprint-override"><code>import os import inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) os.sys.path.insert(1, parentdir) # print(&quot;currentdir = &quot;, currentdir) # print(&quot;parentdir=&quot;, parentdir) </code></pre>
9,845
<p>Waiting for a heatbed to get up to 85˚C for a relatively small part got me wondering why beds aren't hardware/G-code configurable for what area is heated? I'm sure it would be an increase in parts costs and electronics, but it seems that being able to just heat an area a little larger than the part(s) being built would save in time and energy use.</p>
<p>I've wondered that myself a while ago and fact is that such beds or silicone heating pads do <a href="http://www.formbot3d.com/dual-zone-heated-build-plate-and-digital-controller-for-t-rex-2_p0015.html" rel="nofollow noreferrer">exist</a>. Usually these are quite large (and expensive) and usually referred to as "dual zone heat beds/pads".</p> <p>As far as energy consumption; less area to heat is faster heat up times (depending on the control) and less energy consumed. For small prints this may be beneficial. The price of such beds are very high, so to break even you would have to print a lot. An alternative to buying would be to <a href="https://reprap.org/wiki/Etched_heatbed_construction" rel="nofollow noreferrer">etch your own bed</a>.</p>
<p>it is probably too late for the party but i thought about grid heated bed recently. about controlling which zone to turn on and off, i think we can treat the grid as Led matrix, the matrix led signal can be used to drive mosfets to power the heat pads.</p>
953
<p>How does one go about authoring a <em><strong>Regular Expression</strong></em> that matches against all strings that are valid URIs, while failing to match against all strings that are invalid URIs?</p> <p>To be specific about what I am referencing when I say URI, I have added a link below for the most current URI RFC standard. It defines the entity that I want to validate using a regular expression.</p> <p>I don't need it to be able to parse the URI. I just need a regular expression for validating.</p> <p>The <strong>.Net Regular Expression Format</strong> is preferred. (.Net V1.1)</p> <br> <h4>My Current Solution:</h4> <pre><code>^([a-zA-Z0-9+.-]+):(//([a-zA-Z0-9-._~!$&amp;'()*+,;=:]*)@)?([a-zA-Z0-9-._~!$&amp;'()*+,;=]+)(:(\\d*))?(/?[a-zA-Z0-9-._~!$&amp;'()*+,;=:/]+)?(\\?[a-zA-Z0-9-._~!$&amp;'()*+,;=:/?@]+)?(#[a-zA-Z0-9-._~!$&amp;'()*+,;=:/?@]+)?$(:(\\d*))?(/?[a-zA-Z0-9-._~!$&amp;'()*+,;=:/]+)?(\?[a-zA-Z0-9-._~!$&amp;'()*+,;=:/?@]+)?(\#[a-zA-Z0-9-._~!$&amp;'()*+,;=:/?@]+)?$ </code></pre>
<p>Does <a href="http://msdn.microsoft.com/en-us/library/system.uri.iswellformeduristring.aspx" rel="noreferrer">Uri.IsWellFormedUriString</a> work for you?</p>
<p>Are there some specific URIs you care about or are you trying to find a single regex that validates <a href="http://rfc.net/std0066.html" rel="nofollow noreferrer">STD66</a>?</p> <p>I was going to point you to <a href="http://www.unix.com.ua/rfc/std0066.html#p50" rel="nofollow noreferrer">this regex</a> for parsing a URI. You could then, in theory, check to see if all of the elements you care about are there. </p> <p>But I think <a href="https://stackoverflow.com/questions/30847#30858">bdukes</a> answer is better.</p>
5,070
<p>Our (beloved) designer keeps creating PNG files with transparent backgrounds for use in our applications. I'd like to make sure that this feature of the PNG works in "older" browsers as well. What's the best solution?</p> <p><em>edits below</em></p> <p>@mabwi &amp; @syd - Whether or not I agree about the use of a PNG is not the point. This is a problem that I need to solve!</p> <p>@Tim Sullivan - IE7.js looks pretty cool, but I don't think I want to introduce all of the other changes an application. I'd like a solution that fixes the PNG issue exclusively. Thanks for the link.</p>
<p>I've found what looks to be a very good solution here: <a href="http://web.archive.org/web/20170521133429/http://labs.unitinteractive.com:80/unitpngfix.php" rel="nofollow noreferrer">Unit Interactive -&gt; Labs -&gt; Unit PNG Fix</a></p> <p><em>update</em> Unit PNG is also featured on a <a href="http://nettuts.com/videos/screencasts/5-easy-ways-to-tackle-ie6s-transparency-issues/" rel="nofollow noreferrer">list of PNG fix options on NETTUTS</a></p> <p>Here are the highlights from their website:</p> <ul> <li>Very compact javascript: Under 1kb!</li> <li>Fixes some interactivity problems caused by IE’s filter attribute.</li> <li>Works on img objects and background-image attributes.</li> <li>Runs automatically. You don’t have to define classes or call functions.</li> <li>Allows for auto width and auto height elements.</li> <li>Super simple to deploy.</li> </ul>
<p>I might be mistaken, but I'm pretty sure IE6 and less just don't do transparency with PNG files.</p> <p>I have two "solutions" that I use. Either create GIF files with transparency and use those everywhere, or just use them for IE 6 and older with conditional style sheets. The second really only works if you are using them as backgrounds, etc.</p>
3,146
<p>What object do you query against to select all the table names in a schema in Oracle?</p>
<p>To see all the tables you have access to</p> <pre><code>select table_name from all_tables where owner='&lt;SCHEMA&gt;'; </code></pre> <p>To select all tables for the current logged in schema (eg, your tables)</p> <pre><code>select table_name from user_tables; </code></pre>
<p>You may use:</p> <pre><code>select tabname from tabs </code></pre> <p>to get the name of tables present in schema.</p>
7,427
<p>There is a field in my company's "Contacts" table. In that table, there is an XML type column. The column holds misc data about a particular contact. EG. </p> <pre><code>&lt;contact&gt; &lt;refno&gt;123456&lt;/refno&gt; &lt;special&gt;a piece of custom data&lt;/special&gt; &lt;/contact&gt; </code></pre> <p>The tags below <code>contact</code> can be different for each contact, and I must query these fragments alongside the relational data columns in the same table.</p> <p>I have used constructions like:</p> <pre><code>SELECT c.id AS ContactID,c.ContactName as ForeName, c.xmlvaluesn.value('(contact/Ref)[1]', 'VARCHAR(40)') as ref, INNER JOIN ParticipantContactMap pcm ON c.id=pcm.contactid AND pcm.participantid=2140 WHERE xmlvaluesn.exist('/contact[Ref = "118985"]') = 1 </code></pre> <p>This method works ok but, it takes a while for the Server to respond. I have also investigated using the nodes() function to parse the XML nodes and exist() to test if a nodes holds the value I'm searching for.</p> <p>Does anyone know a better way to query XML columns??</p>
<p>I've found the msdn xml best practices helpful for working with xml blob columns, might provide some inspiration... <a href="http://msdn.microsoft.com/en-us/library/ms345115.aspx#sql25xmlbp_topic4" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms345115.aspx#sql25xmlbp_topic4</a></p>
<p>In addition to the page mentioned by @pauljette, this page has good performance optimization advice:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms345118.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms345118.aspx</a></p> <p>There's a lot you can do to speed up the performance of XML queries, but it will never be as good as properly indexed relational data. If you are selecting one document and then querying inside just that one, you can do pretty well, but when your query needs to scan through a bunch of similar documents looking for something, it's sort of like a key lookup in a relational query plan (that is, <em>slow</em>).</p>
7,532
<p>I'm wondering if people can suggest the best tutorial that will walk me through the best way to do Drag and Drop with control collision detection etc, using MS Silverlight V2.</p> <p>I've done the <a href="http://silverlight.net/learn/tutorials.aspx" rel="nofollow noreferrer">Jesse Liberty tutorials</a> at Silverlight.net, and they were a good introduction, but I'm looking for something a bit deeper.</p> <p>Suggestions?</p> <p>UPDATE: Here is the summary of the list of answers for convenience:</p> <ol> <li><a href="http://www.adefwebserver.com/DotNetNukeHELP/Misc/Silverlight/DragAndDropTest/" rel="nofollow noreferrer">http://www.adefwebserver.com/DotNetNukeHELP/Misc/Silverlight/DragAndDropTest/</a></li> <li><a href="http://leeontech.wordpress.com/2008/04/11/drag-and-drop-in-silverlight/" rel="nofollow noreferrer">Lee’s corner</a></li> <li><a href="http://simplesilverlight.wordpress.com/2008/08/13/drag-and-drop-silverlight-example/" rel="nofollow noreferrer">Corey Schuman</a></li> <li><a href="http://blogs.msdn.com/mgrayson/archive/2008/08/18/silverlight-2-samples-dragging-docking-expanding-panels-part-2.aspx" rel="nofollow noreferrer">MARTIN GRAYSON: ADVENTURES OF A 'DEVIGNER'</a></li> <li><a href="http://www.codeplex.com/silverlightdragdrop" rel="nofollow noreferrer">http://www.codeplex.com/silverlightdragdrop</a></li> <li><a href="http://nickssoftwareblog.com/2008/10/07/silverlight-20-in-examples-part-drag-and-drop-inside-out/" rel="nofollow noreferrer">Nick Polyak’s Software Blog</a></li> </ol>
<p>Here is a page that explained the solution for my use.</p> <p><a href="http://www.adefwebserver.com/DotNetNukeHELP/Misc/Silverlight/DragAndDropTest/" rel="nofollow noreferrer">Silverlight 2 Drag, Drop, and Import Content Example</a></p>
<p>A codeplex project for drag and drop <a href="http://www.codeplex.com/silverlightdragdrop" rel="nofollow noreferrer">http://www.codeplex.com/silverlightdragdrop</a></p>
9,563
<p>How can you allow a PHP script to write to a file with high-security restrictions, such as only allowing a single user to write to it?</p> <p>The difficulty seems to be that a PHP script is running as a low-permissions user (maybe apache, or www, or nobody?), and even if I <code>chown</code> apache the_writable_file, the directory it's in might not be writable for the low-level user. In general, what's the usual way that PHP can work with local files in a secure way?</p>
<p>Unfortunately, in shared hosts that use <strong>mod_php, there is no way to restrict access</strong> to secure files to your web app and login user.</p> <p>The solution is to <strong>run your web app as your login user</strong>. When you do that, UNIX file permissions can correctly lock everyone else out. There are several ways to implement that, including <a href="http://httpd.apache.org/docs/2.0/suexec.html" rel="nofollow noreferrer">SuExec</a>, <a href="http://www.suphp.org/Home.html" rel="nofollow noreferrer">suPHP</a>, or running PHP with FastCGI with <a href="http://fastcgi.coremail.cn/" rel="nofollow noreferrer">mod_fcgid</a> or <a href="http://mproxyfcgi.sourceforge.net/" rel="nofollow noreferrer">mod_proxy_fcgid</a>. FastCGI is my favorite way.</p> <p>Another solution is to use a dedicated host or virtual private server.</p>
<p>Sure, <code>chgrp apache the_writable_file</code> and <code>chmod g+w the_writable_file</code>. After that, only your secure user and the apache user will be able to write to the file. Since the apache user is typically forbidden from logging in, you only have to worry about web users writing to your secure file using through the http daemon.</p>
5,417
<p>What is the quickest way to get a large amount of data (think golf) and the most efficient (think performance) to get a large amount of data from a MySQL database to a session without having to continue doing what I already have:</p> <pre><code>$sql = "SELECT * FROM users WHERE username='" . mysql_escape_string($_POST['username']) . "' AND password='" . mysql_escape_string(md5($_POST['password'])) . "'"; $result = mysql_query($sql, $link) or die("There was an error while trying to get your information.\n&lt;!--\n" . mysql_error($link) . "\n--&gt;"); if(mysql_num_rows($result) &lt; 1) { $_SESSION['username'] = $_POST['username']; redirect('index.php?p=signup'); } $_SESSION['id'] = mysql_result($result, '0', 'id'); $_SESSION['fName'] = mysql_result($result, '0', 'fName'); $_SESSION['lName'] = mysql_result($result, '0', 'lName'); ... </code></pre> <p>And before anyone asks yes I do really need to 'SELECT </p> <p>Edit: Yes, I am sanitizing the data, so that there can be no SQL injection, that is further up in the code.</p>
<p>I came up with this and it appears to work.</p> <pre><code>while($row = mysql_fetch_assoc($result)) { $_SESSION = array_merge_recursive($_SESSION, $row); } </code></pre>
<p>OK, this doesn't answer your question, but doesn't your current code leave you open to SQL Injection?</p> <p>I could be wrong, never worked in PHP, just saw the use of strings in the SQL and alarm bells started ringing!</p> <h3>Edit:</h3> <p>I am not trying to tamper with your post, I was correcting a spelling error, please do not roll back.</p>
4,536
<p>We have a Makerbot Replicator 2X at our school. I have a class in the computer lab and one of our focuses is using the printer. Currently, it is not printing properly. We are using PLA at 210 degrees Celcius. The built plate is not heated (using Build Tak). This has worked very well in the past. The problem is that when the extruder goes to lay down plastic, the filament is too hot and curls up in a clump around the extruder. This is characteristic of when we first tried PLA at a higher temperature. I think that our heat sensor is not working properly. Does anyone know how we can fix this problem? Is there a way to calibrate the sensor is should we install a new one?</p>
<p>Overall, it is unlikely that the problem is temp sensing accuracy. There are only a few things that will throw off the thermocouple's reading:</p> <ul> <li>Poor thermal coupling between the tip and the hot block, such as if the tip has partially pulled free of the brass thermowell crimp (this will make the hot block hotter than the reported temp)</li> <li>Loss of electrical insulation between the tip and the hot block, plus some ground loop noise or stray voltage on the hot block (this will typically add noise to the reported temp)</li> </ul> <p>You should be able to visually check for the first, and test for the second with a multimeter. The resistance between the board end of the thermocouple leads and the brass thermowell at the tip should be infinite / out of range. </p> <p>To actually check the thermocouple calibration, you have a few options:</p> <ul> <li><strong>Easy:</strong> Look at the behavior of the printed plastic. PLA that is too hot will smell of pancakes/waffles much stronger than normal, or even smell burnt. The printed material may be more shiny than usual. It will string and ooze more as you print.</li> <li><strong>Moderate:</strong> Secure another reference thermocouple (such as might come with a digital multimeter) tightly to the hot block with some Kapton tape, somewhere the aluminum block is exposed. The external TC should read within a few degrees of the printer's TC. (Assuming you get it attached well enough.)</li> <li><strong>Hard:</strong> Place the tip of the TC in boiling water to check if it reads 100C (or slightly lower if you live at a high altitude). Repeat with well-mixed ice water to check if it reads 0C. Both measurements should be within a couple degrees. You will probably need to dismantle much of the extruder to detach the thermocouple for this test. </li> </ul> <p>But, again, the problem probably isn't the TC. It's more likely either a bed tramming issue (eg too much gap between nozzle and surface) or the BuildTak is degraded and not adhering. This can happen if you do a large number of prints in the exact same place, or get the surface oily, such as with fingerprints. Try a fresh sheet of buildtak or cleaning it with rubbing alcohol and moving the print to a different location. </p> <p>In some rare cases, low-quality filament or filament stored in very high humidity may not stick well. This is pretty rare though. For the most part, if your nozzle gap is right, any extruded plastic will stick to Buildtak. </p>
<p>The temperature is fine.</p> <p>In my experience the filament curls up only when the extruder is extruding way up, far from the plate: are you experiencing this while actually printing?</p> <p>If yes: recalibrate the printer so that the extruder is closer to the build plate and this shouldn't happen. For the filament to curl up it means you are way higher than you should be.</p>
206
<p>I'm pretty keen to develop my first Ruby app, as my company has finally blessed its use internally.</p> <p>In everything I've read about Ruby up to v1.8, there is never anything positive said about performance, but I've found nothing about version 1.9. The last figures I saw about 1.8 had it drastically slower than just about everything out there, so I'm hoping this was addressed in 1.9.</p> <p>Has performance drastically improved? Are there some concrete things that can be done with Ruby apps (or things to avoid) to keep performance at the best possible level?</p>
<p>There are some benchmarks of 1.8 vs 1.9 at <a href="http://www.rubychan.de/share/yarv_speedups.html" rel="nofollow noreferrer">http://www.rubychan.de/share/yarv_speedups.html</a>. Overall, it looks like 1.9 is a lot faster in most cases.</p>
<p>I'd second the recommendation of the use of Passenger - it makes deployment and management of Rails applications trivial</p>
4,551
<p>In what situation would it be more appropriate for me to use a bitset (STL container) to manage a set of flags rather than having them declared as a number of separate (bool) variables?</p> <p>Will I get a significant performance gain if I used a bitset for 50 flags rather than using 50 separate bool variables?</p>
<p>Well, 50 bools as a bitset will take 7 bytes, while 50 bools as bools will take 50 bytes. These days that's not really a big deal, so using bools is probably fine.</p> <p>However, one place a bitset might be useful is if you need to pass those bools around a lot, especially if you need to return the set from a function. Using a bitset you have less data that has to be moved around on the stack for returns. Then again, you could just use refs instead and have even less data to pass around. :)</p>
<p>It depends what you mean by 'performance gain'. If you only need 50 of them, and you're not low on memory then separate bools is pretty much always a better choice than a bitset. They will take more memory, but the bools will be much faster. A bitset is usually implemented as an array of ints (the bools are packed into those ints). So the first 32 bools (bits) in your bitset will only take up a single 32bit int, but to read each value you have to do some bitwise operations first to mask out all the values you don't want. E.g. to read the 2nd bit of a bitset, you need to:</p> <ol> <li>Find the int that contains the bit you want (in this case, it's the first int)</li> <li>Bitwise And that int with '2' (i.e. value &amp; 0x02) to find out if that bit is set</li> </ol> <p>However, if memory is a bottleneck and you have a lot of bools using a bitset could make sense (e.g. if you're target platform is a mobile phone, or it's some state in a very busy web service)</p> <p>NOTE: A std::vector of bool usually has a specialisation to use the <a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=98" rel="nofollow noreferrer">equivalent of a bitset</a>, thus making it much smaller and also slower for the same reasons. So if speed is an issue, you'll be better off using a vector of char (or even int), or even just use an old school bool array.</p>
4,112
<p>It seems like IDataReader.Read() is always true at least one time (If I'm wrong about this let me know.) So how do you tell if it has no records without just wrapping it in a try/catch?</p>
<pre><code>if(dr.Read()) { //do stuff } else { //it's empty } </code></pre> <p>usually you'll do this though:</p> <pre><code>while(dr.Read()) { } </code></pre>
<p>You can just cast <code>System.Data.IDataReader</code> to <code>System.Data.Common.DbDataReader</code> </p> <pre><code>using (System.Data.IDataReader IReader = ICommand.ExecuteReader()) { if (((System.Data.Common.DbDataReader)IReader).HasRows) { //do stuff } } // End Using IReader </code></pre> <p>It's pure evil, but it (usually) works ;) </p> <p>(assuming your instance of <code>IDataReader</code> is implemented by a custom ADO.NET provider, and not some custom silly class of yours which just implements <code>IDataReader</code> instead of deriving from <code>DbDataReader</code> [which implements <code>IDataReader</code>]).</p>
7,402
<p>I bought a self-made Reprap Prusa Mendel 3 printer, modified to be built from cheaper materials, and immediately after the deal I got various problems. I fixed the majority of them, but don't know what the reason of the strange extruder behavior is: The stepper motor is not rotating while extruding filament, it's moving back and forth with small steps instead. I made some footage, <a href="https://www.youtube.com/watch?v=OcF9qxtxIO0" rel="nofollow noreferrer">Reprap Prusa Mendel 3d printer extruder problem</a>, hoping that someone has met a similar problem before.</p> <p>If so, please tell me what to do to make it work as it should.</p> <p>The obvious option while encountering this problem was to slacken the bolt which holds this parts together (in the left bottom corner of the video), but that did not help.</p> <p>Any ideas are very welcomed. Thanks for your time. I hope this is an appropriate kind of question here.</p>
<p>Your controller board probably requires calibration.</p> <p>It sounds like, maybe, the extruder's stepper motor is <em>not receiving sufficient</em> current, to make it turn. <strong>Or</strong>, somewhat confusingly, maybe the stepper is <em>receiving too much current</em>, and overheating.</p> <p>You don't say which controller board you are using, but regardless, there should be an adjustable potentiometer on the board, next to each of the stepper drivers, or on the stepper driver daughter boards. Like so,</p> <p><a href="https://i.stack.imgur.com/xBF9V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xBF9V.png" alt="Photo of the adjustable potentiometer" /></a></p> <p>This potentiomenter adjusts the <em>reference voltage</em> used to control the stepper motor. From this <em>reference voltage</em>, and the resistance of the stepper coils, one can determine the current, which is used to drive the stepper motor.</p> <p>For the stepper driver of the extruder, you could try turning this adjustable potentiometer slightly, in order to provide more current to the stepper, in turn to provide <em>sufficient torque</em> such that the motor is able to turn. <strong>Or</strong>, less current to stop the stepper from overheating.</p> <p>The adjustments <em>can</em> be made whilst the power is on, but a <strong>non-ferrous</strong> (i..e. plastic) screw driver should be used, so as to avoid short circuits. Also care needs to be taken, when turning the potentiometer, as they have been known to just fall apart whilst being turned. If you are paranoid, then make micro adjustments with the power turned off, and then turn back on to check the behaviour.</p> <p><strong>Note</strong>: it should go without saying that one should <strong>never disconnect a stepper whilst the power is on</strong>, as both the driver and the stepper motor may be irrevocably damaged.</p> <hr /> <p>The photo above is taken from <a href="https://bootsindustries.com/pots-calibration-ramps-1-4/" rel="noreferrer">POTs Calibration – RAMPS 1.4</a>.</p> <blockquote> <p>If a POT is set too high then the associated stepper driver will tend to overheat and go into over-temperature thermal shutdown (to prevent damage to its components). The first sign of overheating is erratic stepper motor behavior. Typically, this can be recognized by the sounds of the stepper motor suddenly losing power (thermal shutdown). If no load or movement is required of the motor, it is hard to detect whether it is over-powered as the driver is barely producing any heat.</p> </blockquote> <p>and</p> <blockquote> <p>Conversely, if the POT is set too low, the stepper motor can enter an underpowered state. This can be recognized by a lack of holding torque and a stepper motor that is skipping steps because the necessary movement requires a higher power demand than the POT setting allows for.</p> </blockquote> <hr /> <h3>Driver cooling</h3> <p>In addition to the possibility of the stepper motor over heating, it could be possible that the stepper driver is overheating, although the symptoms may be different, to those that you are experiencing. Regardless, you may still find it advantageous to cooler the controller/driver board with a fan that is always on (not temperature controlled).</p> <h3>Additional reading</h3> <ul> <li><p>RigidWiki - <a href="http://rigidtalk.com/wiki/index.php?title=Stepper_Driver_Adjustment" rel="noreferrer">Stepper Driver Adjustment</a>, which goes into further detail about the adjustment of the potentiometers, that I outlined above, as well as the <em>reference voltage</em> and the adjustment thereof.</p> </li> <li><p>RepRap Wiki - <a href="http://reprap.org/wiki/RepRapPro_Setting_Motor_Currents" rel="noreferrer">RepRapPro Setting Motor Currents</a> describes a different controller to yours, but goes into the process of adjustment, and description of the <em>reference voltage</em> (which is applicable to all boards):</p> </li> </ul> <blockquote> <p>The wiper on each potentiometer generates a DC voltage that is sent to the chip. This is the reference voltage; it defines how much current the stepping motor driver chip supplies to the motor. The bigger the reference voltage (VREF), the higher the current (A) that the chip will send to the motor. For most NEMA14 motors, the current maximum is 1A, but this will generally cause it to get warm, so a setting of 750mA is recommended. For NEMA17 motors, depending on size, the limit on current is generally between 1.3A and 1.7A. If you drive stepper motors with more current than they were designed for, the motor will get hot, and may be damaged.</p> </blockquote> <ul> <li><p>Pololu - <a href="https://www.pololu.com/product/1183" rel="noreferrer">A4988 Stepper Motor Driver Carrier with Voltage Regulators</a> - this is a very common stepper driver.</p> </li> <li><p>MyHomeFab - <a href="http://www.my-home-fab.de/epages/64756193.mobile/en_GB/?ObjectPath=/Shops/64756193/Categories/Dokumentationen/Technische_Beschreibungen/DRV8825_Schrittmotor_Strom_einstellen&amp;Locale=en_GB" rel="noreferrer">DRV8825 Adjust Stepper Current</a> goes into the adjustment of the reference voltage, for the commonly used DRV8825, which is an alternative to the popular A4988.</p> </li> <li><p>This thread, about non-actuating steppers, may also be useful, <a href="http://forums.reprap.org/read.php?41,219920" rel="noreferrer">Motors</a>, which mentions <a href="http://forums.reprap.org/read.php?41,219920,222621#msg-222621" rel="noreferrer">setting the trimpots</a> and points the OP to RepRap Wiki - <a href="http://reprap.org/wiki/Pololu_stepper_driver_board" rel="noreferrer">Pololu stepper driver board</a>, which, in turn, refers to this thread, <a href="http://forums.reprap.org/read.php?4,116813,116832,quote=1" rel="noreferrer">Strange stepper behavior</a> and this video, <a href="https://m.youtube.com/watch?v=MsOBW3lnjnI" rel="noreferrer">video-2012-02-02-16-37-26.mp4</a>, which describes a jitter in the stepper behaviour.</p> </li> </ul>
<p>I also faced similar problem. Mine was a self-made marlin/repetier. The problem was that the motor current was much less than the motor requirement and the axis were not calibrated properly. Giving recommended current according to your motor ratings and limiting your feedrate according to your calibration should work.</p>
442
<p>I upgraded from Cura 2.7 to 3.1.0 and I'm getting horrible under extrusion, I'm sure this is the software because I rolled back to 2.7 and everything is working fine again.</p> <p>My printing is a Robo3D R1+ using the "custom FDM printer" profile.</p> <p>Is there any new setting or a setting that isn't migrated properly that causes this?</p>
<p>Some users have reported upgrades to Cura changing the filament size to the default 2.85&nbsp;mm. If you are using 1.75&nbsp;mm filament (which most printers do), you will get extreme under-extrusion.</p>
<p>I hit this issue again in January 2019 with CuraEngine 3.6+git. Since support for multiple extruders was added, it now auto-loads a per-extruder settings file that overrides the main settings file <strong>and the command line</strong>, so <code>-s material_diameter=1.75</code> on the command line did not help. Given <code>$foo.def.json</code>, it seems to construct the filename <code>%$foo_extruder_0.def.json</code>, and if that does not exist, loads <code>fdmextruder.def.json</code>, which sets <code>material_width</code> to a default of <code>2.85</code>.</p> <p>I was able to solve the problem by either patching <code>fdmextruder.def.json</code>, or making a copy of it named to match my printer's settings file, with the <code>2.85</code> changed to <code>1.75</code>.</p> <p>Update: There should already be extruder files for supported printers, but they're in a different directory, so they won't be found when invoking <code>CuraEngine</code> from the command line unless you've set the <code>CURA_ENGINE_SEARCH_PATH</code> environment variable to include the path they're in. Alternatively you can copy them to the same directory as the main printer json files.</p>
770
<p>I would like to get a green tombow PITS adhesive stick. On Rakuten, it costs \$1 (USD). On my 3d printer's (XYZ) retailer's site, it costs \$20 (USD). Due to the costs and the fact that Rakuten does not ship to my country, I need an alternative. I am currently using Davinci 1.0 for my bed, which I believe is a glass bed. So, my questions are: </p> <ol> <li>What glue is best for PLA plastic?</li> <li>What glue is best for ABS plastic?</li> <li>Is there a glue that functions with both types of plastic?</li> </ol>
<p>As mentioned by Matt - PVA glues work perfect for both filaments. It works well because it's softening temperature is between 45..85C so it's more or less temperature of HB.</p> <p>Advantages:</p> <ul> <li>cheap</li> <li>easy to apply on HB</li> <li>can be applied on cold as same as on hot HB</li> <li>sticks model very well</li> <li>non toxic, no solvent, odorless</li> <li>easy to wash (from HB) (just wash it under water or scrape with sharp tool)</li> <li>works very well even with old and dry layer of glue</li> </ul> <p>Disadvantages:</p> <ul> <li>quite hard to detach model (I use paper knife)</li> <li>first layer is not glass-perfect</li> <li>after detaching, model is a bit sticky (first layer)</li> </ul> <p>I use Scotch Glue Stick by 3M. </p>
<p>Most PVA glue works well for both (Poly Vinyl Acetate).<br> There are different brands in every country.</p>
280