instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>Ultimaker Cura offers a platform support type of “<em>touching buildplate</em>” which enables the printer to only make a raft for parts of the object that should be touching the build plate. It also offers “<em>everywhere</em>” for any object that might be hanging over the build plate.</p> <p>I have a need to only offer support for overhangs up to a certain z height, such any overhang located at a z-point of 4&nbsp;mm or below. Is there a software that will enable this, either as a setting/addition to Ultimaker Cura or just a G-code export for Pronterface?</p>
<blockquote> <p>Is there a software that will enable this?</p> </blockquote> <p>Yes, as of Ultimaker Cura 3.3 Beta, Ultimaker Cura allows you to specify an area which will not be considered for adding supports. In your case you could define everything above 4&nbsp;mm to be excluded from building support structures. </p> <p>You can look <a href="https://community.ultimaker.com/topic/22192-introducing-ultimaker-cura-33-beta/" rel="nofollow noreferrer">here</a> for this very new feature, it might be what you're looking for.</p>
<blockquote> <p>Is there a software that will enable this?</p> </blockquote> <p>I don't own a copy of it, but from talking with other 3D printing enthusiasts, I know <a href="https://www.simplify3d.com/" rel="nofollow noreferrer">simplify3d</a> is the slicer out there with the most granular control over support structures.</p> <p>I'm unaware if it has a setting for <em>exactly</em> what you want, but I know it has the possibility to manually add support in selected parts of your model, so - depending on size and complexity of your model, and on the level of accuracy you need - it may well be an option for you.</p> <p>It is proprietary, commercial software with a "no question asked" refund policy.</p>
866
<p>After working for a while developing games, I've been exposed to both variable frame rates (where you work out how much time has passed since the last tick and update actor movement accordingly) and fixed frame rates (where you work out how much time has passed and choose either to tick a fixed amount of time or sleep until the next window comes).</p> <p>Which method works best for specific situations? Please consider:</p> <ul> <li>Catering to different system specifications;</li> <li>Ease of development/maintenance;</li> <li>Ease of porting;</li> <li>Final performance.</li> </ul>
<p>It seems that most 3D developers prefer variable FPS: the Quake, Doom and Unreal engines both scale up and down based on system performance.</p> <ul> <li>At the very least you have to compensate for too fast frame rates (unlike 80's games running in the 90's, way too fast)</li> <li>Your main loop should be parameterized by the timestep anyhow, and as long as it's not too long, a decent integrator like RK4 should handle the physics smoothly Some types of animation (keyframed sprites) could be a pain to parameterize. Network code will need to be smart as well, to avoid players with faster machines from shooting too many bullets for example, but this kind of throttling will need to be done for latency compensation anyhow (the animation parameterization would help hide network lag too)</li> <li>The timing code will need to be modified for each platform, but it's a small localized change (though some systems make extremely accurate timing difficult, Windows, Mac, Linux seem ok)</li> <li>Variable frame rates allow for maximum performance. Fixed frame rates allow for consistent performance but will never reach max on all systems (that's seems to be a show stopper for any serious game)</li> </ul> <p>If you are writing a networked 3D game where performance matters I'd have to say, bite the bullet and implement variable frame rates. </p> <p>If it's a 2D puzzle game you probably can get away with a fixed frame rate, maybe slightly parameterized for super slow computers and next years models.</p>
<p>My experience is fairly limited to somewhat simple games (developed with SDL and C++) but I have found that it is quite easy just to implement a static frame rate. Are you working with 2d or 3d games? I would assume that more complex 3d environments would benefit more from a variable frame rate and that the difficulty would be greater.</p>
7,661
<p>I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the <code>@parmName</code> I am assuming will be replaced is actually being sent as part of the SQL statement. Am I missing a configuration setting somewhere or is this simply not possible?</p> <p>I am not using the filter option in the tool because this appears to bring back the full dataset from the database and do the filtering on the SQL Server.</p>
<p>It sounds like you'll need to treat the SQL Statement as an expression. For example:</p> <pre><code>="Select col1, col2 from table 1 Where col3 = " &amp; Parameters!Param1.Value </code></pre> <p>If the where clause is a string you would need to do the following:</p> <pre><code>="Select col1, col2 from table 1 Where col3 = '" &amp; Parameters!Param1.Value &amp; "'" </code></pre> <p>Important: Do not use line breaks in your SQL expression. If you do you will get an error.</p> <p>Holla back if you need any more assistance.</p>
<p>I am a bit confused about this question, if you are looking for simple parameter usage then the notation is :<code>*paramName*</code> , however if you want to structurally change the <code>WHERE</code> clause (as you might in sql+ using ?) then you should really be using custom code within the report to define a function that returns the required sql for the query.</p> <p>Unfortunately, when using custom code, parameters cannot be referenced directly in the generated query but have to have there values concatenated into the resultant String, thus introducing the potential for <code>SQL</code> injection.</p>
3,068
<p><strong>Please Note:</strong> This question is <em>not</em> about the design. It's about deciding print orientation <em>after the design</em>. </p> <p>I have a small, but complex piece which I need to print. Here are two images of different orientation for you:</p> <p><a href="https://i.stack.imgur.com/jpi84.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jpi84.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/FPuGb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FPuGb.jpg" alt="enter image description here"></a></p> <p>No matter how I orient it, it will require a support structure. Any which way I print it, I believe there will be pros/cons to doing so. My question is, <strong>Is there a thought process for how to orient the part for printing?</strong> What are some of the things to consider when deciding print orientation? </p> <p>Note-1: For a size reference of the part, looking at the second image, it is approximately 60&nbsp;mm from the top of the long bottom part with the two "claws" point down, to the top of the vertical piece which has the two larger chamfered holes in it. In the same image, the left part will be at the bottom when put into use, though will be suspended (the chamfered holes will have wood screws in them, with a block of wood on the other side from the chamfers.</p> <p>Note-2: For this example, I will be using Priline PLA filament on an Anet-A8 printer. </p>
<p>(Love the question and here is my 2 cents).</p> <p>Firstly, you want to minimize supports. Even if you have dissolvable supports, you would still want to minimize the usage.</p> <p>For Example:</p> <p><a href="https://i.stack.imgur.com/LoQCE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LoQCE.jpg" alt="Smartphone and tablet Stand by bq3D"></a></p> <p>At first glance of the finished object, it is not obvious at what angle it was printed. Upon close inspection the overhang in the part is designed such that it can be printed without supports. This brings me to my first point:</p> <p><strong>Design with fabrication in mind</strong></p> <p>I've often designed myself into a corner with parts that are complex and are impossible to print properly; or they use up too much filament in the supports. To this end I try to <em>think about the shadow</em> that the part will cast on the bed if there was a light source directly over head. I often orient the part so that it will </p> <p><strong>Cast the smallest possible shadow.</strong></p> <p>Then there are the features. Does the hole need to be round? Does this flange need to be strong? If so then I try to ensure that the feature is oriented in the XY plane as much as possible, because the Z axis is the weakest. Therefore if you have a hole, and it needs to be strong, then it should be printed perpendicular to the Z axis.</p>
<p>First of all, if it were me, I'd split this into two parts at the "obvious" place (where one protrudes from a large flat surface of the other) and connect them after printing, with a push fit and glue (or solvent welding if it works for your material), or holes for threaded fasteners.</p> <p>With that said, if you opt to print it as one part, this interface is going to be the weak point of the whole print if you use the second orientation, with the "T"-like bracket part sticking up from a flat top surface of the "C" part. This is because the walls of the top part will be sitting on infill or skin, not matching walls going all the way down; even with 100% infill the walls won't be aligned and bonded with coresponding extrusion lines below them.</p> <p>I would print this <em>either</em> with the lightest-gray faces facing us in the second image against the bed, or with the dark gray rectangle face in the lower-right of the second image against the bed (same orientation as the first image, as I interpret it). Both of these will require significant support structure, and I'd be tempted to model the support rather than auto-generating it, but Cura's "experimental" "support tree" feature works very well for this kind of situation and might do just as well or better.</p> <p>Either of these orientations makes the above interface simply part of the layer contours, rather than two parts loosely stuck to each other. The holes should print fine either way - bridging works well for holes - and the pegs will need support one way but not the other.</p> <p>Andrew Morton noted in a comment:</p> <blockquote> <p>Could the part with the screw holes be the same width as the other part?</p> </blockquote> <p>And indeed I would also think about modifications you could make to the part that would facilitate easier and stronger prints.</p>
1,418
<p>I'm trying to do a simple test php script for sessions. Basically it increments a counter (stored in <code>$_SESSION</code>) every time you refresh that page. That works, but I'm trying to have a link to destroy the session which reloads the page with the <code>?destroy=1</code> parameter. I've tried a couple of if statements to see if that parameter is set and if so to destroy the session but it doesn't seem to work.</p> <p>I've even put an if statement in the main body to pop-up a message if the parameter is set - but it doesn't seem to be picked up.</p> <p>I know I'm doing something silly (I'm a PHP newbie) but I can't seem to find what it is...</p> <p>See code here:</p> <pre><code>&lt;?php if ($_POST['destroy']) { session_destroy(); } else { session_start(); } ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Session test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php if (isset($_POST['destroy'])) { echo "Destroy set"; } $_SESSION['counter']++; echo "You have visited this page " . $_SESSION['counter'] . " times" . "&lt;BR&gt;"; echo "I am tracking you using the session id " . session_id() . "&lt;BR&gt;"; echo "Click &lt;a href=\"" . $_SERVER['PHP_SELF'] . "?destroy=1\"&gt;here&lt;/a&gt; to destroy the session."; ?&gt; </code></pre>
<p>I think you put</p> <pre><code>$_POST['destroy'] </code></pre> <p>Instead of</p> <pre><code>$_GET['destroy'] </code></pre> <p>You need to use a form if you'd like to use a $_POST variable. $_GET variables are stored in the URL.</p>
<blockquote> <p>I know I'm doing something silly (I'm a php newbie) but I can't seem to find what it is...</p> </blockquote> <p>that is how you are going to learn a lot ;) enjoy it ...</p>
3,750
<p>I'm debugging a production application that has a rash of empty catch blocks <em>sigh</em>:</p> <pre><code>try {*SOME CODE*} catch{} </code></pre> <p>Is there a way of seeing what the exception is when the debugger hits the catch in the IDE?</p>
<p>In VS, if you look in the Locals area of your IDE while inside the catch block, you will have something to the effect of $EXCEPTION which will have all of the information for the exception that was just caught.</p>
<p>Can't you just add an Exception at that point and inspect it?</p>
6,097
<p>Let's say I have a complex .NET class, with lots of arrays and other class object members. I need to be able to generate a deep clone of this object - so I write a Clone() method, and implement it with a simple BinaryFormatter serialize/deserialize - or perhaps I do the deep clone using some other technique which is more error prone and I'd like to make sure is tested.</p> <p>OK, so now (ok, I should have done it first) I'd like write tests which cover the cloning. All the members of the class are private, and my architecture is so good (!) that I haven't needed to write hundreds of public properties or other accessors. The class isn't IComparable or IEquatable, because that's not needed by the application. My unit tests are in a separate assembly to the production code.</p> <p>What approaches do people take to testing that the cloned object is a good copy? Do you write (or <em>rewrite</em> once you discover the need for the clone) all your unit tests for the class so that they can be invoked with <em>either</em> a 'virgin' object <em>or</em> with a clone of it? How would you test if part of the cloning wasn't deep enough - as this is just the kind of problem which can give hideous-to-find bugs later?</p>
<p>You method of testing will depend on the type of solution you come up with. If you write some custom cloning code and have to manually implement that in each cloneable type then you should really test the cloning of each one of those types. Alternatively, if you decide to go a more generic route (where the aforementioned reflection would likely fit in), your tests would only need to test the specific scenarios that you cloning system will have to deal with.</p> <p>To answer your specific questions:</p> <blockquote> <p>Do you write (or rewrite once you discover the need for the clone) all your unit tests for the class so that they can be invoked with either a 'virgin' object or with a clone of it?</p> </blockquote> <p>You should have tests for all the methods that can be performed on both the original and cloned objects. Note that it should be pretty easy to set up a simple test design to support this without manually updating the logic for each test.</p> <blockquote> <p>How would you test if part of the cloning wasn't deep enough - as this is just the kind of problem which can give hideous-to-find bugs later?</p> </blockquote> <p>It depends on the cloning method you choose. If you have to manually update the cloneable types then you should test that each type is cloning all (and only) the members you expect. Whereas, if you are testing a cloning framework I would create some test cloneable types to test each scenario you need to support.</p>
<p>Here is a sample of how I implemented this a while back, although this will need to be tailored to the scenario. In this case we had a nasty object chain that could easily change and the clone was used as a very critical prototype implementation and so I had to patch (hack) this test together.</p> <pre><code>public static class TestDeepClone { private static readonly List&lt;long&gt; objectIDs = new List&lt;long&gt;(); private static readonly ObjectIDGenerator objectIdGenerator = new ObjectIDGenerator(); public static bool DefaultCloneExclusionsCheck(Object obj) { return obj is ValueType || obj is string || obj is Delegate || obj is IEnumerable; } /// &lt;summary&gt; /// Executes various assertions to ensure the validity of a deep copy for any object including its compositions /// &lt;/summary&gt; /// &lt;param name="original"&gt;The original object&lt;/param&gt; /// &lt;param name="copy"&gt;The cloned object&lt;/param&gt; /// &lt;param name="checkExclude"&gt;A predicate for any exclusions to be done, i.e not to expect IPolicy items to be cloned&lt;/param&gt; public static void AssertDeepClone(this Object original, Object copy, Predicate&lt;object&gt; checkExclude) { bool isKnown; if (original == null) return; if (copy == null) Assert.Fail("Copy is null while original is not", original, copy); var id = objectIdGenerator.GetId(original, out isKnown); //Avoid checking the same object more than once if (!objectIDs.Contains(id)) { objectIDs.Add(id); } else { return; } if (!checkExclude(original)) { Assert.That(ReferenceEquals(original, copy) == false); } Type type = original.GetType(); PropertyInfo[] propertyInfos = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); FieldInfo[] fieldInfos = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo memberInfo in propertyInfos) { var getmethod = memberInfo.GetGetMethod(); if (getmethod == null) continue; var originalValue = getmethod.Invoke(original, new object[] { }); var copyValue = getmethod.Invoke(copy, new object[] { }); if (originalValue == null) continue; if (!checkExclude(originalValue)) { Assert.That(ReferenceEquals(originalValue, copyValue) == false); } if (originalValue is IEnumerable &amp;&amp; !(originalValue is string)) { var originalValueEnumerable = originalValue as IEnumerable; var copyValueEnumerable = copyValue as IEnumerable; if (copyValueEnumerable == null) Assert.Fail("Copy is null while original is not", new[] { original, copy }); int count = 0; List&lt;object&gt; items = copyValueEnumerable.Cast&lt;object&gt;().ToList(); foreach (object o in originalValueEnumerable) { AssertDeepClone(o, items[count], checkExclude); count++; } } else { //Recurse over reference types to check deep clone success if (!checkExclude(originalValue)) { AssertDeepClone(originalValue, copyValue, checkExclude); } if (originalValue is ValueType &amp;&amp; !(originalValue is Guid)) { //check value of non reference type Assert.That(originalValue.Equals(copyValue)); } } } foreach (FieldInfo fieldInfo in fieldInfos) { var originalValue = fieldInfo.GetValue(original); var copyValue = fieldInfo.GetValue(copy); if (originalValue == null) continue; if (!checkExclude(originalValue)) { Assert.That(ReferenceEquals(originalValue, copyValue) == false); } if (originalValue is IEnumerable &amp;&amp; !(originalValue is string)) { var originalValueEnumerable = originalValue as IEnumerable; var copyValueEnumerable = copyValue as IEnumerable; if (copyValueEnumerable == null) Assert.Fail("Copy is null while original is not", new[] { original, copy }); int count = 0; List&lt;object&gt; items = copyValueEnumerable.Cast&lt;object&gt;().ToList(); foreach (object o in originalValueEnumerable) { AssertDeepClone(o, items[count], checkExclude); count++; } } else { //Recurse over reference types to check deep clone success if (!checkExclude(originalValue)) { AssertDeepClone(originalValue, copyValue, checkExclude); } if (originalValue is ValueType &amp;&amp; !(originalValue is Guid)) { //check value of non reference type Assert.That(originalValue.Equals(copyValue)); } } } } } </code></pre>
3,216
<p>Does anyone know of a good way to display hierarchical data with columns?</p> <p>It has to be virtualizing, as it must be able to handle several million records. </p> <p>It should also be multi-select, most treeview controls are not. </p> <p>Winforms preferred, but will ElementHost WPF if necessary.</p>
<p>I'm not quite clear what you mean about hierarchical data with columns, can you clarify? One possibility is the new WPF DataGrid. Depending on the functionality you're looking for it <em>may</em> be what you're looking for.</p> <p>The bits for datagrid are available on codeplex: <a href="http://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=14963" rel="nofollow noreferrer">http://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=14963</a></p>
<p>Take a look at the Infragistics UltraWinGrid, here's a video that demos some features: <a href="http://www.infragistics.com/howto/wingrid.aspx" rel="nofollow noreferrer">http://www.infragistics.com/howto/wingrid.aspx</a></p>
9,246
<p>I'm looking to have windows recognize that certain folders are associated to my application - maybe by naming the folder 'folder.myExt'.</p> <p>Can this be done via the registry?</p> <p>A bit more info<br> - This is for a x-platform app ( that's why I suggested the folder with an extension - mac can handle that ) <br> - The RAD I'm using doesn't read write binary data efficiently enough as the size of this 'folder' will be upwards of 2000 files and 500Mb</p>
<p>Folders in Windows aren't subject to the name.extension rules at all, there's only 1 entry in the registry's file type handling for "folder" types. (If you try to change it you're going to have very, very rough times ahead)</p> <p>The only simple way to get the effect you're after would be to do what OpenOffice, MS Office 2007, and large video games have been doing for some time, use a ZIP file for a container. (It doesn't have to be a "ZIP" exactly, but some type of readily available container file type is better than writing your own) Like OO.org and Office 2K7 you can just use a custom extension and designate your app as the handler. This will also work on Macs, so it can be cross-platform. It may not be fast however. Using low or no compression may help with that.</p>
<p>You can have an "extension" on your folder, but as far as I know, windows just treats it all as the folder name and opens the folder like normal when you click on it.</p> <p>The few times I messed with opening a .app on my windows system, it acted like it was a normal folder.</p>
9,353
<p>I have a Creatorbot 3D printer made by 3D PrinterWorks. Their website appears to be down, as well as their Facebook page. To me it appears they are no longer around.</p> <p>I've installed Slic3r as 3D PrinterWorks has recommended in the handbook but cannot download the settings for this from the 3D PrinterWorks website, since that is down. </p> <p>Does anyone know where I can get the Slic3r configuration file for the Creatorbot?</p>
<p>Looks like 3dprinterworks.net went down sometime after March 2018 and 3dprinterworks.com went down in January 2019. Luckily the Wayback Machine still has the <a href="https://web.archive.org/web/20161209084908/https://www.3dprinterworks.com/products/creatorbot-3d-pro-series-ii" rel="nofollow noreferrer">machine's specs</a>.</p> <p>Here is the instructions for entering settings in Slic3r as found <a href="https://manual.slic3r.org/expert-mode/printer-settings" rel="nofollow noreferrer">here</a> in lieu of importing a profile. (Please note that I have not used Slic3r so the following is solely based on the link)</p> <p>The key settings under General are </p> <ul> <li>Bed size*: X = 305 mm; Y = 305 mm; and Z = 457 mm</li> <li>Print center**: X = 152.5 mm; Y = 152.5 mm</li> <li>Extruders: 2</li> <li>Heated Bed: Checked</li> </ul> <p>Under Extruder (each extruder should have its own settings so be sure to set up both)</p> <ul> <li>Nozzle diameter: 0.4 mm</li> <li><p>Extruder 2 offset: 30.9 mm (good job, OP on finding the email stating this)</p></li> <li><p>Everything from Retraction and on is up to what works best for you</p></li> </ul> <p>There may be a set of setting for acceleration (there is in Ultimaker Cura) which is 3000 mm/s<sup>2</sup> for most printers, I think. This is the max acceleration, not to be confused with acceleration settings when slicing the model.</p> <p>The next set of settings, though outside of the Slic3r link, regards the filament. The diameter should be 1.75 mm and the nozzle temperature should be within the range of the filament (e.g. PLA should be set within 180-220 °C) and a heated bed set to 50-60 °C. These parameters are filament dependent and not printer dependent (other than diameter).</p> <p>That should be the settings that a profile would set for you. Thankfully there's not too many.</p> <hr> <pre>*There is a wizard for this section that may make input easier, but here is the build volume. **This setting may require whole numbers and may, in fact, not be a necessary setting at all.</pre>
<p>The configuration files were on a flash drive that came with the printer. That being said, here is the file that was located on my flash drive for Slic3r (denoted as deprecated on March 1, 2017).</p> <p>This is for a Creatorbot Pro II.</p> <p><a href="https://pastebin.com/j1dkSt8f" rel="nofollow noreferrer">https://pastebin.com/j1dkSt8f</a></p> <p>Save it as Slic3r_config.ini and import it in to Slic3r.</p> <p>Good luck!</p>
1,209
<p>I have a Simulink xPC target application that has blocks with discrete states at several different sample rates and some sections using continuous states. My intention on keeping the continuous states is for better numerical integration. </p> <p>What creates the problem: One block is reading a device at a very fast rate (500 hz). The rest of the application can and should run at a slower rate (say, 25 or 50 Hz) because it would be overkill to run it at the highest rate, and because the processor simply cannot squeeze a full application cycle into the .002 secs of the faster rate. So I need both rates. However, the continuous states run by definition in Simulink at the faster discrete rate of the whole application! This means everywhere I have continuous states now they're forced to run at 500 Hz when 25 Hz would do!</p> <p>Is there a way to force the continuous states in xPC target to a rate that is not the fastest in the application? Or alternatively, is there a way to allow certain block to run at a faster speed than the rest of the application?</p>
<p>You are thinking about continuous solvers in the wrong way - continuous doesn't only mean that it's run as fast as possible - it uses a fundamentally different algorithm to solve the equations than discrete. Due to this, they must be run at least as fast as the discrete solvers.</p> <p>From <a href="http://www.ece.northwestern.edu/IT/local-apps/matlabhelp/toolbox/simulink/ug/how_simulink_works13.html" rel="nofollow noreferrer">Using Simulink</a>:</p> <blockquote> <p>Continuous solvers use numerical integration to compute a model's continuous states at the current time step from the states at previous time steps and the state derivatives. Continuous solvers rely on the model's blocks to compute the values of the model's discrete states at each time step.</p> <p>Mathematicians have developed a wide variety of numerical integration techniques for solving the ordinary differential equations (ODEs) that represent the continuous states of dynamic systems. Simulink provides an extensive set of fixed-step and variable-step continuous solvers, each implementing a specific ODE solution method (see Solvers).</p> <p>Discrete solvers exist primarily to solve purely discrete models. They compute the next simulation time step for a model and nothing else. They do not compute continuous states and they rely on the model's blocks to update the model's discrete states.</p> </blockquote> <p>So the upshot is that <em>no</em> it's not good enough to have the continuous run more slowly than the fastest discrete solvers - otherwise they are, by definition, not continuous. You should reconsider why you are specifying them as continuous.</p> <p>What are you trying to accomplish by slowing down the continuous solvers? Is this a simulation time/performance issue?</p> <p>-Adam</p>
<p>My take on this is that it cannot be done. One way to approach this is to replace the continuous states by discrete ones (perhaps at an intermediate rate, say 100 Hz), and cross my fingers that the loss of precision is bearable.</p> <p>Maybe it's possible to isolate a block and run it separately at a faster rate somehow, but I don't know.</p>
6,482
<p>I understand how slicer programs create sets of closed-loop polygons to print on a layer-by-layer basis. For a given closed loop polygon which needs to be printed, the tool path generator will know the coordinates and how those coordinates are connected to each other, such that traversing a set of segments in that order will bring the extruder head back to the first coordinate to complete the closed loop.</p> <p>My question is: By what mechanism does the tool path generator decide which direction to traverse the closed loop? As it is a loop, that loop could be printed "clockwise" or "counter-clockwise", as it were. Any details, and links to further explanations of how some of the big-name slicer programs determine this is much appreciated.</p>
<p>While <a href="https://3dprinting.stackexchange.com/a/7972/8884">this</a> answer makes a valid attempt at answering the question, it is based on personal experience.</p> <p>I went to the literature and directly to the source code in Cura to find the answer. In the academic article "<a href="https://link.springer.com/article/10.1007/s00170-012-4706-y" rel="noreferrer">Identifying the Directions of a Set of 2D Contours for Additive Manufacturing Process Planning</a>", Volpato et al. describe several methods for identifying the arbitrary directions of each contour in each layer, and additionally identifying which contours were "internal" and which were "external". I quote from the paper:</p> <blockquote> <p>The information regarding contour direction, which is either clockwise (CW — internal) or counterclockwise (CCW — external), is needed for path planning for material processing.</p> </blockquote> <p>They go on to explain the importance of identifying which contours are external, and which are internal, such that the path planning algorithm can later determine where infill should be placed. Infill is placed internal to any external contours, and external to any internal contours. </p> <blockquote> <p>When the normal vectors in STL models are assumed to be correct, a simple way to identify whether a 2D contour is CW or CCW is to analyze the vector (cross) product between a normal vector and a vector obtained from two vertices of the facet.</p> </blockquote> <p>This assumes the slicer has already determined intersection points between slicing planes and the STL file, and has sorted those intersection points into closed-contours. This initial intersection point gathering and contour construction leads to an arbitrary directionality:</p> <blockquote> <p>As any line segment of a contour can be the first in the sequence when the segments are connected, its orientation will dictate the direction of the contour. Hence, the 2D contours formed are classified randomly, and an external contour, for example, might be assigned a CW or CCW direction. Therefore, this step is unable to correctly identify the directions of the contours generated.</p> <p>The ray-tracing method, which is actually based on the point-in-polygon test, determines which contours are contained by others, and the orientation of each contour is then alternated between CCW and CW, the outermost contours being oriented CCW.</p> </blockquote> <p>So, the default directionality of a closed contour generated by a slicing program for FDM additive manufacturing turns out to be CCW based on cross products described above (and based on additional methods outlined in the paper). Of course the standard directionality of a PRINTED contour does not HAVE to be this way, it appears to be a standard adopted by the AM community. However, when a model produces contours inside of contours, the arbitrary directionality of those contours is determined, and then alternated from outside to inside, starting with CCW. </p> <p>As confirmation, according to a simple comment in the CURA source code:</p> <pre><code>/*! * Outer polygons should be counter-clockwise, * inner hole polygons should be clockwise. * (When negative X is to the left and negative Y is downward.) */ </code></pre>
<h2>Math</h2> <p>In math, there is a way how a path is to be followed, and that is usually counterclockwise:</p> <p>Assuming a perimeter path of a circle with <span class="math-container">$r=1$</span> around <span class="math-container">$(2,2)$</span>, then the path can be defined as <span class="math-container">$f(p)={{\cos(p)+2}\choose{\sin(p)+2}}$</span> - where <span class="math-container">$p$</span> is the path parameter, in this case an angle of 0 to 360°, and just increasing the angle rotates right hand around. If we had the same path but a different starting point, a shift by <span class="math-container">$\theta$</span>, then the path would read <span class="math-container">$f(p)={{\cos(p+\theta)+2}\choose{\sin(p+\theta)+2}}$</span>. So math is usually <em>counterclockwise</em>.</p> <h2>Slicers</h2> <p>Every slicer is applying math. As far as I can tell, any Slicer generates a perimeter path, which is always performed in the same way if sliced with the same settings. For one case look at this: <a href="https://i.stack.imgur.com/nSlg7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nSlg7.png" alt="5 seconds of print sliced in cura" /></a> Counterclockwise starting from a 7 o clock position in this case. However, other slicers or other objects on the printbed might use other engines, thus doing it not that way. They might go clockwise since solving a path with <span class="math-container">$p=0°\to360°$</span> and solving it <span class="math-container">$p=360°\to0°$</span> results in producing the exact same print, just opposed print direction of the perimeter.</p> <p>As long as the perimeter of an object is solved as being done as one closed loop, the perimeter will need to have just one, prescribed direction. This direction will be clockwise or counterclockwise depending on how the slicer exactly solves its calculations. Since both directions are equally valid, it is a programmer's decision. A programmer might even prescribe clockwise or counterclockwise solution based on any factor they wanted. They might use layer number (for alternating directions) or a user setting or even an RNG, if they wanted to.</p> <p>On the other hand, how the memory is operated and written can also result in the path and the math looking differently. Two examples:</p> <ul> <li>Solving the path correctly counterclockwise and putting the slicing into a FILO memory, resulting in a clockwise operation starting from the last solved point.</li> <li>Solving counterclockwise and saving into FIFO, running counterclockwise.</li> </ul> <h2>Conclusion</h2> <p>Slicers for 3D printing have a hard-coded way to choose the direction that is followed when producing G-code. Any and all perimeters will be printed, starting from some arbitrary point, into that direction. In the end, it is a choice of the <em>programmer</em> of the slicing engine that determines if the path is to be run down &quot;forward&quot; or &quot;backward&quot; in mathematical sense.</p> <h2>Addendum</h2> <p>Slicers are derived from CAM programming. CAM - computer assisted machining - takes into account one more thing when solving the tool path that is not relevant to a 3D printer: The direction of the fluting of the tool. In fact, this one will determine into which direction the path will give a better cut and changing the fluting should swap the path direction to ensure best results.</p>
1,180
<p>What should I take care of to replace the nozzle of the hotend assembly the right way?</p> <p>What kind of data, precautions, tools, steps, and verification are important for replacing the nozzle?</p> <p>The procedure seems straightforward but tutorials differ greatly and seem often incomplete. Online videos are great but long, sometimes misleading, and difficult to compare if they use another printer model.</p> <p>For example:</p> <ul> <li>This <a href="https://www.youtube.com/watch?v=txt6sxV6X88" rel="nofollow noreferrer">Prusa 3D tutorial</a> starts from heating the nozzle to 280 °C, which is dangerous for some hotend setups. Also, it is created around a direct drive extruder, so it does not advise to what to do with a Bowden tube.</li> <li>Another <a href="https://www.youtube.com/watch?v=FRzsGttNMyk" rel="nofollow noreferrer">Changing Nozzles &amp; Bowden Tubes video</a> seems to be a great tutorial but advises heating only to ~210 °C. So I need to make sure I know my hardware limits first? Should I take something else into account about temperature, or just act by experience, <a href="/a/11648/26170">starting from 230 °C</a>?</li> <li>Is that heating mandatory, or only <a href="/a/5123/26170">when there is residue filament inside</a>? If there is something to consider about <a href="/q/8064/">replacement nozzle</a> before installing it, or cooling down again, like PID calibration?</li> </ul> <p>So I am looking for a general overview: <strong>what should I think of</strong> to be in control? And maybe a bit of <strong>why</strong>, but not necessarily how. (As always, each detail may be a separate study, so please don't to fall into troubleshooting, which could be done in separate questions like <a href="/q/11646/">E3D V6 nozzle seized into heater block</a>).</p>
<p>It's because the bed heats up. Since the bed can heat up to the point that locktite or nylon can soften, using those products to keep the screws from turning will have exactly the opposite effect.</p>
<p>Does your bed already have washers on the screws? The neopreme (red) washer under the screw head (in picture). This is the German Reprap X400 design and is worth trying.</p> <p><a href="https://i.stack.imgur.com/jucy3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jucy3.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/V3qrL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V3qrL.jpg" alt="enter image description here" /></a></p>
1,853
<p>When filament is too short for the extruder to push will there be a stop in printing on the Ender 3, meaning that I should replace the filament when the end of the filament is near the extruder?</p>
<p>The extruder can't push anymore when the filament is past the extruder gear. If your filament has run out to that point, the print will <em>not</em> halt but print without a filament, meaning that the print will fail. You need to pause the print in time and then put fresh filament into the printer.</p> <p>If the end of the filament is cut flat at the end and the new one is flat too, the new filament can push the old one out to the nozzle, reducing the waste to a minimum, if you can live without retraction for the amount of length that has to be used up. You could friction weld the two parts together to alleviate this.</p>
<p>The extruder can't push anymore when the filament is past the extruder gear. If your filament has run out to that point, the print will <em>not</em> halt but print without a filament, meaning that the print will fail. You need to pause the print in time and then put fresh filament into the printer.</p> <p>If the end of the filament is cut flat at the end and the new one is flat too, the new filament can push the old one out to the nozzle, reducing the waste to a minimum, if you can live without retraction for the amount of length that has to be used up. You could friction weld the two parts together to alleviate this.</p>
1,271
<p>Our automated build machine needs to archive the version numbers of the OS plus various tools used during each build. (In case we ever need to replicate exactly the same build later on, perhaps when the machine is long dead.)</p> <p>I see the command "msinfo32.exe" can be used to dump a whole load of system version information, which we might as well archive.</p> <p>Does anyone know of a way to easily archive the version numbers of the Visual Studio tools?</p> <p>What mechanisms do other developers use to gather this kind of information for archive purposes?</p> <hr> <p>Extra information for Fabio Gomes.</p> <p>I agree with you that in 5 years time it'll probably be impossible to recreate the exact OS and tool configuration (down to the nearest security update). Unfortunately this really comes from a contractual requirement. As part of our deliverable to a customer we must provide a copy of all source code and clear instructions on exactly how to replicate the build. It's probably impossible for us to meet this requirement perfectly.</p> <p>So - I'll just mark your answer as correct (I agree with you that it's practically impossible), and get on with playing with the rest of stack overflow. :)</p> <p>PS. It would be really great if stack overflow supported replies to answers instead of having to edit the original question.. But I see it has <a href="http://stackoverflow.uservoice.com/pages/general/suggestions/14403" rel="noreferrer">already been denied</a>.</p>
<p><strong>EMAIL ADDRESS</strong></p> <p>Rational</p> <ol> <li>Users don't change emails very often</li> <li>Removes the step of asking for username and email address, which you'll need anyway</li> <li>Users don't often forget their email address (see number one)</li> <li>Email will be unique unless the user already registered for the site, in which case forward them to a forgot your password screen</li> <li>Almost everyone is using email as the primary login for access to a website, this means the rate of adoption shouldn't be affected by the fact that you're asking for an email address</li> </ol> <hr> <p><strong>Update</strong></p> <p>After registration, be sure to ask the user to create some kind of username, don't litter a public site with their email address! Also, another benefit of using an email address as a login: you won't need any other information (like password / password confirm), just send them a temp password through the mail, or forgo passwords altogether and send them a one-use URL to their email address every time they'd like to login (see: <a href="http://mugshot.org/main" rel="noreferrer">mugshot.org</a>)</p>
<p>OpenID seems to be a very good alternative to writing your own user management/authentication piece. I'm seeing more and more sites using OpenID these days, so the barrier to entry for your users should be relatively low.</p>
2,790
<p>What is the content type for MHT files?</p>
<p>Microsoft, who co-authored the spec for MHT, seem to think that it should be '<code>message/rfc822</code>' on <a href="http://support.microsoft.com/kb/937912" rel="nofollow noreferrer">this support page</a>.</p> <p>No specific MIME type seems to be given in the spec though: <a href="https://www.rfc-editor.org/rfc/rfc2557" rel="nofollow noreferrer">RFC2557: MIME Encapsulation of Aggregate Documents, such as HTML (MHTML)</a></p>
<p>application/octet-stream</p> <p>You can stream the contents of a .eml file to a browser with this content type and .mht as the extension, and the email will be rendered similar to the way it is rendered in an email client.</p>
5,117
<p>While browsing with Chrome, I noticed that it responds extremely fast (in comparison with IE and Firefox on my laptop) in terms of rendering pages, including JavaScript heavy sites like gmail.</p> <p>This is what googlebook on Chrome has to say </p> <ol> <li>tabs are hosted in process rather than thread.</li> <li>compile javascript using V8 engine as opposed to interpreting.</li> <li>Introduce new virtual machine to support javascript heavy apps</li> <li>introduce "hidden class transitions" and apply dynamic optimization to speed up things.</li> <li>Replace inefficient "Conservative garbage colllection" scheme with more precise garbage collection scheme.</li> <li>Introduce their own task scheduler and memory manager to manage the browser environment.</li> </ol> <p>All this sounds so familiar, and Microsoft has been doing such things for long time.. Windows os, C++, C# etc compilers, CLR, and so on. </p> <p>So why isn't Microsoft or any other browser vendor taking Chrome's approach? Is there a flaw in Chrome's approach? If not, is the rest of browser vendor community caught unaware with Google's approach?</p>
<p>Chrome's approach is difficult to write, and requires forethought from the developers. IE and Firefox are both attempting to move to a process-per-tab model, but due to backwards compatibility are not able to transition quickly. Chrome, being an entirely new browser build on a clean rendering engine (WebKit), was easier to write in this way.</p>
<p>You have to keep in mind that Microsoft primary business is Rich environement (GUI) Application. Web tool is a threat to them as it is platform independant (not promoting they main product).</p> <p>Of course the IE team probably had figured something like that but... Microsoft definetly won't invest a lot of money in IE if what they are selling is a Rich application platform.</p>
6,452
<p>For a .NET component that will be used in both web applications and rich client applications, there seem to be two obvious options for caching: System.Web.Caching or the Ent. Lib. Caching Block.</p> <ul> <li>What do you use?</li> <li>Why?</li> </ul> <h2><a href="http://msdn.microsoft.com/en-us/library/system.web.caching.aspx" rel="noreferrer">System.Web.Caching</a></h2> <p>Is this safe to use outside of web apps? I've seen mixed information, but I think the answer is maybe-kind-of-not-really.</p> <ul> <li><a href="http://support.microsoft.com/kb/917411" rel="noreferrer">a KB article warning against 1.0 and 1.1 non web app use</a></li> <li>The 2.0 page has a <em>comment</em> that indicates it's OK: <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.cache(VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.web.caching.cache(VS.80).aspx</a></li> <li><a href="http://www.hanselman.com/blog/UsingTheASPNETCacheOutsideOfASPNET.aspx" rel="noreferrer">Scott Hanselman is creeped out by the notion</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx" rel="noreferrer">The 3.5 page</a> includes a warning against such use</li> <li>Rob Howard <a href="http://weblogs.asp.net/cschittko/archive/2004/07/04/172684.aspx" rel="noreferrer">encouraged use outside of web apps</a></li> </ul> <p>I don't expect to use one of its highlights, <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx" rel="noreferrer">SqlCacheDependency</a>, but the addition of <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.cacheitemupdatecallback.aspx" rel="noreferrer">CacheItemUpdateCallback</a> in .NET 3.5 seems like a Really Good Thing. </p> <h2><a href="http://msdn.microsoft.com/en-us/library/aa480453.aspx" rel="noreferrer">Enterprise Library Caching Application Block</a></h2> <ul> <li>other blocks are already in use so the dependency already exists</li> <li>cache persistence isn't necessary; regenerating the cache on restart is OK</li> </ul> <p>Some cache items should always be available, but be refreshed periodically. For these items, getting a callback <em>after</em> an item has been removed is not very convenient. It looks like a client will have to just sleep and poll until the cache item is repopulated.</p> <h2><a href="http://jehiah.cz/projects/memcached-win32/" rel="noreferrer">Memcached for Win32</a> + <a href="http://sourceforge.net/projects/memcacheddotnet/" rel="noreferrer">.NET client</a></h2> <p>What are the pros and cons when you don't need a <em>distributed</em> cache?</p>
<p>These are the items that I consider for the topic of Caching:</p> <p>MemCached Win32 Velocity .net Cache Enterprise Library Caching Application Block</p> <p><strong>MemCached Win32:</strong> Up until recently I have used MemCached Win32. This is a akin to a web farm (many servers serving the same content for high availability) but it is a cache farm. This means that you can install it locally on your web server initially if you don't have the resources to go bigger. Then as you go down the road you can scale horizontally (more servers) or vertically (more hardware). This is a product that was ported from the original MemCached to work on Windows. This product has been used extensively in very high traffic sites. <a href="http://lineofthought.com/tools/memcached" rel="nofollow noreferrer">http://lineofthought.com/tools/memcached</a></p> <p><strong>Velocity:</strong> This is Microsofts answer to products such as MemCached. MemCached has been out for quite some time, Velocity is in CTP mode. I must say that from what I have read so far this product will certainly turn my head once it is out. But I can't bring myself to run big production projects on a CTP product with zero track record. I have started playing with it though as once it gains momentum MemCached won't even compare for those locked in the windows world! <a href="http://blogs.msdn.com/velocity/" rel="nofollow noreferrer">http://blogs.msdn.com/velocity/</a></p> <p><strong>.NET Cache:</strong> There is no reason to discount the standard .NET Cache. It is built in and ready to use for free and with no (major) set up required. It offers flexibility by way of offering mechanisms for storing items in local memory, a SINGLE state server, or a centralized database. Where Velocity steps in is when you need more than a single state server (cache in memory) and don't want to use a slow database for holding your cache.</p> <p><strong>Enterprise Application Block:</strong> I stay away from all of the Enterprise Application Blocks. They are heavy frameworks that give more than I generally require! As long as you remember to wrap everything that touches code that is not your own and follow simple rules for coding, stick to any of the other methods over this one! (just my opinion of course - MySpace leverages as much as they can out of Enterprise Application Blocks!)</p> <p><strong>You don't have to choose up front!</strong> I generally create a cache wrapper that I communicate with in my code for methods such as Get, Set, Exists, Remove, ListKeys, etc. This then points to an underlying level of cache abstraction that can point to MemCached, Velocity, or .NET cache. I use StructureMap (or choose another IoC container) to inject which form of cache I want to use for a given environment. In my local dev box I might use .NET cache in the session. In production I generally use MemCached Win 32. But regardless of how it is set up you can easily swap things around to try each system out to see what works best for you. You just need to make sure that you application knows as little as possible about how things are cached! Once this layer of abstraction is in place you can then do things such as run a compression algorithm (gzip) for all the data that is going in and out of cache which would allow you to store 10 times the amount of data in cache. - <strong>transparently</strong>.</p> <p>I cover .NET Cache, MemCached Win32, StructureMap, and the appropriate abstractions in my book if you are interested!</p> <p>ASP.NET 3.5 Social Networking (<a href="https://rads.stackoverflow.com/amzn/click/com/1847194788" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/ASP-NET-3-5-Social-Networking-Enterprise-ready/dp/1847194788/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1225408005&amp;sr=8-1</a> ) Andrew Siemer www.andrewsiemer.com blog.andrewsiemer.com www.socialnetworkingin.net</p> <p><strong>Update</strong> Changed the link that lists sites using memcached. Thank you David for noticing that it was broken!</p>
<p>@Davide Vosti</p> <p>"If they put it in the web namespace, I think's it's for a good reason." Does that same logic apply to the Concurrency and Coordination Runtime (CCR) in the robotic studio? no? didn't think so.</p>
4,190
<p>I am encountering a problem with this ID3 printer using ABS -- at some point during the print the print head displaces on the y-axis by 2-3 centimeters. I cannot pinpoint how or why it is doing this. It has displaced in the positive Y direction and in the negative Y direction on separate runs of the same piece (which is just a poker chip I found on Thingiverse). </p> <p>Is this a software issue (Simplify3D) or a hardware issue? Can anybody suggest a fix?</p> <p>See the following photos:</p> <p><a href="https://i.stack.imgur.com/b9Kyv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b9Kyv.jpg" alt="3D print exhibiting positive Y displacement mid-print"></a></p> <p><a href="https://i.stack.imgur.com/1yH40.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1yH40.jpg" alt="Close up of 3D print exhibiting positive Y displacement mid-print"></a></p>
<p>This has happened to me in the past and here are a few things that I determined could have been the cause:</p> <ul> <li>Limit Switch triggered. My coworker was able to repeat the issue by manually triggering a limit switch during the print. Somehow, this seemed to cause the relative axis to shift on his MakerBot Replicator 2.</li> <li>Skipped steps. It's possible that, if stalled due to excessive load, the stepper motor could skip steps. I have a dual extruder, so if a part curls really bad then the second nozzle gets caught in the print. I'm not sure exactly how this works, but my coworker suggested this as an issue.</li> <li>USB connection. I had sliced a model and tried printing over USB connection, however each time I attempted the print I encountered the "shift" at the same exact location. However, using the slice, I exported a G-Code file and printed from the machines SD card with no errors.</li> <li>Slicing Engine bug. This is in correlation to the <em>USB connection</em> issue. I noticed that the issue occurred after updating my slicing engine. My solution in the long term was to re-install the previous version that was stable for me. I was using MakerWare 2.4.2 and reverted back to MakerWare 2.4.1.</li> </ul> <p>If you're printing via USB connection, I'd suggest exporting to G-Code if you're able to print via SD Card until you can find a stable version of software for your machine. This has been the most repeatable solution for me in the past.</p>
<p>In my case the solution was to use <a href="https://en.wikipedia.org/wiki/Slic3r" rel="nofollow noreferrer">Slic3r</a> instead of <a href="https://en.wikipedia.org/wiki/Ultimaker#History" rel="nofollow noreferrer">Cura</a>. Cura has some issues.</p>
239
<p>I'm working on a module for a CMS. This module is distributed as a class library DLL.</p> <p>I have several utility libraries I'd like to use in this module. Is there anyway I can link these libraries statically so I won't have to distribute several DLL's (thereby distributing my utility libraries separately)?</p> <p>I would like to have only one DLL.</p>
<p>You can merge your many DLLs with ILMERGE:</p> <p><a href="http://research.microsoft.com/~mbarnett/ILMerge.aspx" rel="noreferrer">http://research.microsoft.com/~mbarnett/ILMerge.aspx</a></p> <p>Haven't tried it myself. Hope it helps.</p> <hr> <p>Download here:<br /> <a href="http://www.microsoft.com/downloads/details.aspx?familyid=22914587-B4AD-4EAE-87CF-B14AE6A939B0&amp;displaylang=en" rel="noreferrer">http://www.microsoft.com/downloads/details.aspx?familyid=22914587-B4AD-4EAE-87CF-B14AE6A939B0&amp;displaylang=en</a></p> <p><strong>Brief Description</strong> <em>(from download-page)</em><br /> ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. See the accompanying documentation for details.</p>
<p>The short answer for this is no! You can not link in a dll during compilation. I don't know if there is some subtle way to do this, but you would probably have to distribute the dlls along with your cms. The best way to do this is to make some kind of re-distributable.</p>
6,019
<p>What fan speed should I use with PLA? Do I need to manually set the fan speed in ‘Control’?</p> <p>Also, on the filament cartridge Bed Temp is listed: <em>&quot;No heat/60-80 °C&quot;</em>. Does this mean heating the bed is optional?</p>
<p>Most commercial blow-molded fuel tanks for model airplane fuel (methanol or ethanol, nitromethane or nitroethane, and some combination of castor, mineral, or synthetic lubricating oil) are made from HDPE. This material isn't commonly seen as filament, in my limited experience, but it ought to be possible to arrive at settings that will give a liquid tight tank without further sealing if you can find some. As you note, limonene might be used to smooth/seal HDPE prints, but likely won't be necessary if your settings are right.</p> <p>You might want to test PETG filament for its resistance to your fuel mix(es) -- this material <em>is</em> available as filament, prints with settings little different from generic PLA (in my experience, higher nozzle and bed temperature, and a little more bed clearance for the first layer), with good layer adhesion and, with a good print, is liquid-tight as printed. It's not particularly flexible (as is the case with HDPE), but since you can customize the shape of your fuel tank, it may work for you -- or it may be more flexible in vase mode, as PLA is.</p> <p>Sealing PETG may be as simple as baking it (similar to &quot;heat treating&quot; PLA to increase print strength, albeit again at a higher temperature) -- this partial remelting will ensure that layers are adhered throughout the print, which (presuming you have avoided under-extruded areas) should be all that's needed to make a printed tank liquid tight.</p>
<p>As a supplement to the answer (doesn't fit well in the comments). This site <a href="https://www.filamentive.com/chemical-resistance-of-3d-printing-filament/" rel="nofollow noreferrer">https://www.filamentive.com/chemical-resistance-of-3d-printing-filament/</a> lists PETG has have a very high restance to alcohol, a high resitance to fuel</p> <blockquote> <p><strong>Is PETG UV Resistant?</strong></p> </blockquote> <blockquote> <p>In the long run, it is now a well-known fact that it will almost always come out on top when it comes to objects and builds that have to be resistant to ultraviolet (UV) radiation. I.e., UV resistant. This is why it is ideal for objects that have to be kept under the harsh mid-summer sun. This is because UV radiation has minimal effect on it as compared to PLA and ABS. -- From <a href="https://makershop.co/petg-uv-resistance/" rel="nofollow noreferrer">https://makershop.co/petg-uv-resistance/</a></p> </blockquote>
1,949
<p>What are some good steps to follow for a smooth migration from PHP4 to PHP5. What are some types of code that are likely to break?</p>
<p>I also once worked on an app which used PHP4's XML support quite heavily, and would have required quite a bit of work to move to PHP5.</p> <p>One of the other significant changes I was looking at at the time was the change of the default handling of function parameters. In PHP4 if I remember, they were pass-by-copy unless you specified otherwise, but in PHP5 is changed to pass-by-reference by default. In well written code, that probably won't make a big difference to you, but it could certainly cause problems.</p> <p>I think one other thing I found changed is that objects are no longer allowed to overwrite their 'this' field. I would say that was a really bad idea to begin with (and I think it may have not been an intentional feature in PHP4), but I certainly found a few parts of our system that relied on it.</p> <p>Hope some of that helps.</p>
<p>We had an app that relied heavily on the PHP 4 XML DOM functions and it required a lot of retooling to change over PHP 5.</p> <p>Beyond that most changes were improvements to things like error handling (to take advantage of exceptions) and PHP Classes.</p>
2,830
<p>Following on from my <a href="https://stackoverflow.com/questions/19454/enforce-attribute-decoration-of-classesmethods">previous question</a> I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!).</p> <p>The problem I have is that I have a collection, which is of a abstract base class type, which is populated by the concrete derived types.</p> <p>I thought it would be fine to just add the XML attributes to all of the classes involved and everything would be peachy. Sadly, thats not the case!</p> <p>So I have done some digging on Google and I now understand <em>why</em> it's not working. In that <strong>the <code>XmlSerializer</code> is in fact doing some clever reflection in order to serialize objects to/from XML, and since its based on the abstract type, it cannot figure out what the hell it's talking to</strong>. Fine.</p> <p>I did come across <a href="http://www.codeproject.com/KB/XML/xmlserializerforunknown.aspx" rel="noreferrer">this page</a> on CodeProject, which looks like it may well help a lot (yet to read/consume fully), but I thought I would like to bring this problem to the StackOverflow table too, to see if you have any neat hacks/tricks in order to get this up and running in the quickest/lightest way possible.</p> <p>One thing I should also add is that I <strong>DO NOT</strong> want to go down the <code>XmlInclude</code> route. There is simply too much coupling with it, and this area of the system is under heavy development, so the it would be a real maintenance headache!</p>
<h2>Problem Solved!</h2> <p>OK, so I finally got there (admittedly with a <strong>lot</strong> of help from <a href="http://www.codeproject.com/KB/XML/xmlserializerforunknown.aspx" rel="noreferrer">here</a>!).</p> <p>So summarise:</p> <h3>Goals:</h3> <ul> <li>I didn't want to go down the <em>XmlInclude</em> route due to the maintenence headache.</li> <li>Once a solution was found, I wanted it to be quick to implement in other applications.</li> <li>Collections of Abstract types may be used, as well as individual abstract properties.</li> <li>I didn't really want to bother with having to do &quot;special&quot; things in the concrete classes.</li> </ul> <h3>Identified Issues/Points to Note:</h3> <ul> <li><em>XmlSerializer</em> does some pretty cool reflection, but it is <em>very</em> limited when it comes to abstract types (i.e. it will only work with instances of the abstract type itself, not subclasses).</li> <li>The Xml attribute decorators define how the XmlSerializer treats the properties its finds. The physical type can also be specified, but this creates a <strong>tight coupling</strong> between the class and the serializer (not good).</li> <li>We can implement our own XmlSerializer by creating a class that implements <em>IXmlSerializable</em> .</li> </ul> <h2>The Solution</h2> <p>I created a generic class, in which you specify the generic type as the abstract type you will be working with. This gives the class the ability to &quot;translate&quot; between the abstract type and the concrete type since we can hard-code the casting (i.e. we can get more info than the XmlSerializer can).</p> <p>I then implemented the <em>IXmlSerializable</em> interface, this is pretty straight forward, but when serializing we need to ensure we write the type of the concrete class to the XML, so we can cast it back when de-serializing. It is also important to note it must be <strong>fully qualified</strong> as the assemblies that the two classes are in are likely to differ. There is of course a little type checking and stuff that needs to happen here.</p> <p>Since the XmlSerializer cannot cast, we need to provide the code to do that, so the implicit operator is then overloaded (I never even knew you could do this!).</p> <p>The code for the AbstractXmlSerializer is this:</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.Xml.Serialization; namespace Utility.Xml { public class AbstractXmlSerializer&lt;AbstractType&gt; : IXmlSerializable { // Override the Implicit Conversions Since the XmlSerializer // Casts to/from the required types implicitly. public static implicit operator AbstractType(AbstractXmlSerializer&lt;AbstractType&gt; o) { return o.Data; } public static implicit operator AbstractXmlSerializer&lt;AbstractType&gt;(AbstractType o) { return o == null ? null : new AbstractXmlSerializer&lt;AbstractType&gt;(o); } private AbstractType _data; /// &lt;summary&gt; /// [Concrete] Data to be stored/is stored as XML. /// &lt;/summary&gt; public AbstractType Data { get { return _data; } set { _data = value; } } /// &lt;summary&gt; /// **DO NOT USE** This is only added to enable XML Serialization. /// &lt;/summary&gt; /// &lt;remarks&gt;DO NOT USE THIS CONSTRUCTOR&lt;/remarks&gt; public AbstractXmlSerializer() { // Default Ctor (Required for Xml Serialization - DO NOT USE) } /// &lt;summary&gt; /// Initialises the Serializer to work with the given data. /// &lt;/summary&gt; /// &lt;param name=&quot;data&quot;&gt;Concrete Object of the AbstractType Specified.&lt;/param&gt; public AbstractXmlSerializer(AbstractType data) { _data = data; } #region IXmlSerializable Members public System.Xml.Schema.XmlSchema GetSchema() { return null; // this is fine as schema is unknown. } public void ReadXml(System.Xml.XmlReader reader) { // Cast the Data back from the Abstract Type. string typeAttrib = reader.GetAttribute(&quot;type&quot;); // Ensure the Type was Specified if (typeAttrib == null) throw new ArgumentNullException(&quot;Unable to Read Xml Data for Abstract Type '&quot; + typeof(AbstractType).Name + &quot;' because no 'type' attribute was specified in the XML.&quot;); Type type = Type.GetType(typeAttrib); // Check the Type is Found. if (type == null) throw new InvalidCastException(&quot;Unable to Read Xml Data for Abstract Type '&quot; + typeof(AbstractType).Name + &quot;' because the type specified in the XML was not found.&quot;); // Check the Type is a Subclass of the AbstractType. if (!type.IsSubclassOf(typeof(AbstractType))) throw new InvalidCastException(&quot;Unable to Read Xml Data for Abstract Type '&quot; + typeof(AbstractType).Name + &quot;' because the Type specified in the XML differs ('&quot; + type.Name + &quot;').&quot;); // Read the Data, Deserializing based on the (now known) concrete type. reader.ReadStartElement(); this.Data = (AbstractType)new XmlSerializer(type).Deserialize(reader); reader.ReadEndElement(); } public void WriteXml(System.Xml.XmlWriter writer) { // Write the Type Name to the XML Element as an Attrib and Serialize Type type = _data.GetType(); // BugFix: Assembly must be FQN since Types can/are external to current. writer.WriteAttributeString(&quot;type&quot;, type.AssemblyQualifiedName); new XmlSerializer(type).Serialize(writer, _data); } #endregion } } </code></pre> <p>So, from there, how do we tell the XmlSerializer to work with our serializer rather than the default? We must pass our type within the Xml attributes type property, for example:</p> <pre><code>[XmlRoot(&quot;ClassWithAbstractCollection&quot;)] public class ClassWithAbstractCollection { private List&lt;AbstractType&gt; _list; [XmlArray(&quot;ListItems&quot;)] [XmlArrayItem(&quot;ListItem&quot;, Type = typeof(AbstractXmlSerializer&lt;AbstractType&gt;))] public List&lt;AbstractType&gt; List { get { return _list; } set { _list = value; } } private AbstractType _prop; [XmlElement(&quot;MyProperty&quot;, Type=typeof(AbstractXmlSerializer&lt;AbstractType&gt;))] public AbstractType MyProperty { get { return _prop; } set { _prop = value; } } public ClassWithAbstractCollection() { _list = new List&lt;AbstractType&gt;(); } } </code></pre> <p>Here you can see, we have a collection and a single property being exposed, and all we need to do is add the <em>type</em> named parameter to the Xml declaration, easy! :D</p> <p><strong>NOTE: If you use this code, I would really appreciate a shout-out. It will also help drive more people to the community :)</strong></p> <p>Now, but unsure as to what to do with answers here since they all had their pro's and con's. I'll upmod those that I feel were useful (no offence to those that weren't) and close this off once I have the rep :)</p> <p>Interesting problem and good fun to solve! :)</p>
<p>I've done things similar to this. What I normally do is make sure all the XML serialization attributes are on the concrete class, and just have the properties on that class call through to the base classes (where required) to retrieve information that will be de/serialized when the serializer calls on those properties. It's a bit more coding work, but it does work much better than attempting to force the serializer to just do the right thing.</p>
4,044
<p>I have two machines in two different domains. On both I have VS 2005 installed. I want remote debug between them. Without authentication it is possible but I want to debug managed code. I don't want to debug directly since it is really crappy machine.</p> <p>When I try to attach with debugger I get message "The trust relationship between this workstation and primary domain failed." Any idea how to overcome this ? I tried tricks with adding same local username on both machines but with no luck.</p> <p>EDIT: I have same local users on both machines. I started both VS2005 and Debugging monitor with RunAs using local users. I turned Windows Auditing on debug machine and I see that local user from VS2005 machine is trying to logon. But he fails with error 0xC000018D (ERROR_TRUSTED_RELATIONSHIP_FAILURE)</p>
<p>Gregg Miskely has a <a href="http://blogs.msdn.com/greggm/archive/2004/10/04/237519.aspx" rel="noreferrer">blog post</a> on this. You might get it to work if both local accounts have the same user name and password. You might also try dropping your good box from it's domain so that you are going from a workgroup to a domain rather than domain to domain.</p>
<p>I seem to remember that I have sometimes found it useful to use RunAs when you run msvcmon (or whatever it's called this week - the remote debugging stub anyway), to force it to start as the user which you have set up to be the same on both machines. </p> <p>I would guess that on the machine you're running VS on, you will also need to log in as the local user rather than a domain user (or start VS with RunAs).</p> <p>I have never understood why this needed to be so hard, given that unmanaged debugging is so much easier, and must expose every security hole that managed debugging could.</p>
4,936
<p>We try to use Java and UTF-8 on Windows. The application writes logs on the console, and we would like to use UTF-8 for the logs as our application has internationalized logs.</p> <p>It is possible to configure the JVM so it generates UTF-8, using <code>-Dfile.encoding=UTF-8</code> as arguments to the JVM. It works fine, but the output on a Windows console is garbled.</p> <p>Then, we can set the code page of the console to 65001 (<code>chcp 65001</code>), but in this case, the <code>.bat</code> files do not work. This means that when we try to launch our application through our script (named start.bat), absolutely nothing happens. The command simple returns:</p> <pre><code>C:\Application&gt; chcp 65001 Activated code page: 65001 C:\Application&gt; start.bat C:\Application&gt; </code></pre> <p>But without <code>chcp 65001</code>, there is no problem, and the application can be launched.</p> <p>Any hints about that?</p>
<p>Try <code>chcp 65001 &amp;&amp; start.bat</code></p> <p>The <code>chcp</code> command changes the code page, and 65001 is the Win32 code page identifier for UTF-8 under Windows 7 and up. A code page, or character encoding, specifies how to convert a Unicode code point to a sequence of bytes or back again.</p>
<p>Have you tried <a href="http://en.wikipedia.org/wiki/PowerShell" rel="nofollow noreferrer">PowerShell</a> rather than old cmd.exe.</p>
7,861
<p>What would be a very fast way to determine if your connectionstring lets you connect to a database?</p> <p>Normally a connection attempt keeps the user waiting a long time before notifying the attempt was futile anyway.</p>
<p>You haven't mentioned what database you are connecting to, however. In <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005" rel="nofollow noreferrer">SQL Server 2005</a>, from .NET, you can specify a connection timeout in your connection string like so:</p> <pre><code>server=&lt;server&gt;;database=&lt;database&gt;;uid=&lt;user&gt;;password=&lt;password&gt;;Connect Timeout=3 </code></pre> <p>This will try to connect to the server and if it doesn't do so in three seconds, it will throw a timeout error.</p>
<p>Shorten the timeout on the connection string and execute something trivial.</p> <p>The wait should be about the same as the timeout.</p> <p>You would still need a second or two though.</p>
3,199
<p>Ever since moving to Vista some time ago on my development machine, connecting to SQL Servers in our DMZ active directory domain from client tools like SSMS has not worked like it used to. In XP, as long as I had authenticated in some way on the server (for example directing Explorer to \server.dmzdomain\c$ and entering valid creds into the login prompt), SSMS would use those cached credentials to connect.</p> <p>However since switching to Vista, when trying to connect SSMS to a server in the DMZ domain I get the message <em>Login failed for user ''. The user is not associated with a trusted SQL Server connection.</em> If I change the connection options to use Named Pipes instead of the default TCP/IP, my cached credentials are sent and everything works fine. This is the case whether Windows Firewall is off or on, and connections to servers in our internal domain (the same domain my dev PC is in) work fine over TCP/IP or named pipes.</p> <p>I don't mind too much using named pipes for these connections as a workaround, but it seems like TCP/IP is the recommended connection method and I don't like not understanding why it's not working as I'd expect. Any ideas?</p>
<p>"Login Failed for user ' ', the user is not associated with a trusted SQL Server connection".</p> <p>In this scenario, client may make tcp connetion, plus, running under local admin or non-admin machine account, no matter SPN is registered or not, the client credential is obviously not recognized by SQL Server.</p> <p>The workaround here is:</p> <p>Create the same account as the one on the client machine with same password on the target SQL Server machine, and grant appropriate permission to the account.</p> <p>Let's explain in more detail:</p> <p>When you create the same NT account (let's call it usr1) on both workstations, you essentially connect and impersonate the local account of the connecting station. I.e when you connect from station1 to station2, you're being authenticated via the station2's account. So, if you set the startup account for SQL Server (let's assume it's running on station2) to be station2's usr1, when you connect to SQL from station1 with station1's usr1 login, SQL will authenticate you as station2's usr1.</p> <p>Now, within SQL, you can definitely access station1's resources. Though, how much access will depend on station1's usr1 permission.</p> <p>So far, SQL only deal with an user who is part of the sysadmin role within SQL Server. To allow other users (non-sysamdin) access to network resources, you will have to set the proxy account. Take a look at the article for additional info. taken from <a href="http://blogs.msdn.com/sql_protocols/archive/2006/12/02/understanding-kerberos-and-ntlm-authentication-in-sql-server-connections.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sql_protocols/archive/2006/12/02/understanding-kerberos-and-ntlm-authentication-in-sql-server-connections.aspx</a></p>
<p>Have you tried running SSMS in elevated mode, and do you have the latest SP installed on the client?</p>
4,252
<p>I have thus far avoided the nightmare that is testing multi-threaded code since it just seems like too much of a minefield. I'd like to ask how people have gone about testing code that relies on threads for successful execution, or just how people have gone about testing those kinds of issues that only show up when two threads interact in a given manner?</p> <p>This seems like a really key problem for programmers today, it would be useful to pool our knowledge on this one imho.</p>
<p>Look, there's no easy way to do this. I'm working on a project that is inherently multithreaded. Events come in from the operating system and I have to process them concurrently.</p> <p>The simplest way to deal with testing complex, multithreaded application code is this: If it's too complex to test, you're doing it wrong. If you have a single instance that has multiple threads acting upon it, and you can't test situations where these threads step all over each other, then your design needs to be redone. It's both as simple and as complex as this.</p> <p>There are many ways to program for multithreading that avoids threads running through instances at the same time. The simplest is to make all your objects immutable. Of course, that's not usually possible. So you have to identify those places in your design where threads interact with the same instance and reduce the number of those places. By doing this, you isolate a few classes where multithreading actually occurs, reducing the overall complexity of testing your system.</p> <p>But you have to realize that even by doing this, you still can't test every situation where two threads step on each other. To do that, you'd have to run two threads concurrently in the same test, then control exactly what lines they are executing at any given moment. The best you can do is simulate this situation. But this might require you to code specifically for testing, and that's at best a half step towards a true solution.</p> <p>Probably the best way to test code for threading issues is through static analysis of the code. If your threaded code doesn't follow a finite set of thread safe patterns, then you might have a problem. I believe Code Analysis in VS does contain some knowledge of threading, but probably not much.</p> <p>Look, as things stand currently (and probably will stand for a good time to come), the best way to test multithreaded apps is to reduce the complexity of threaded code as much as possible. Minimize areas where threads interact, test as best as possible, and use code analysis to identify danger areas.</p>
<p>(if possible) don't use threads, use actors / active objects. Easy to test.</p>
3,326
<p>I have a new Tevo Tornado, which I have completed two good prints with, a 20x20 test cube from the supplied SD and the spool holder also from the SD. I say this to note that the printer was capable of producing a good print.</p> <p>Print 3 was a design I created in Fusion and it printed badly, very disappointing holes missing. Stringing gaps between material just rubbish. I downloaded a simple print from Thingiverse just to see if it was my poor design skills or the printer and that came out just as poorly: lots of strings between details. Both of these were sliced in Cura. As that doesn't have a tornado driver, I downloaded one from the support group and the prints have not even started properly, see pictures for example.</p> <p>I might be going down rabbit holes here but this is what I have found and tried:</p> <ul> <li>1 relieved bed - done to ridiculous degree of accuracy, cold gross levelling then bed and nozzle at PLA working temp using feeler gauges. I have done 0.1&nbsp;mm, 0.15&nbsp;mm, 0.2&nbsp;mm </li> </ul> <p>Now I have added to the suspicion the z axis coupler see images below: </p> <p><a href="https://i.stack.imgur.com/KX2DWm.jpg" rel="nofollow noreferrer" title="z axis flexible coupling#1"><img src="https://i.stack.imgur.com/KX2DWm.jpg" alt="z axis flexible coupling#1" title="z axis flexible coupling#1"></a><a href="https://i.stack.imgur.com/KAWNmm.jpg" rel="nofollow noreferrer" title="z axis flexible coupling#2"><img src="https://i.stack.imgur.com/KAWNmm.jpg" alt="z axis flexible coupling#2" title="z axis flexible coupling#2"></a></p> <p><a href="https://i.stack.imgur.com/djWvKm.jpg" rel="nofollow noreferrer" title="z axis flexible coupling#3"><img src="https://i.stack.imgur.com/djWvKm.jpg" alt="z axis flexible coupling#3" title="z axis flexible coupling#3"></a></p> <p>YouTube videos, that I have seen, show couplers that are not a spring - any thoughts? I would certainly appreciate the time anyone has to impart their knowledge.</p> <p><strong>EDIT 1</strong>: (Additional information posted as comment, now moved to question)</p> <p><em>The print bed is brand new from Tevo the unit has only done a few prints most aborted, and I also thought perhaps a residue from the feeler gauges had contaminated the bed, but I have cleaned it with alcohol wipes and also tried putting prints on to unused parts of the bed. You are right the g-code from the test print was from an unknown slicer, no doubt tuned by the manufacturer the part I designed in Fusion was sliced by cura. I have since tried the original test piece and it fouls the extruder nozzle almost straight away.</em> </p> <p><em>The main differences and there are not many between the set up parts, are that the Cura code does a G92 E0 G1 F1500 E-3.5 before starting layer 0 (both set z0,3). The test piece just does a G92 E0 G1 F7200 the feed rates are different the cura print sets M204 S500 and the test sample sets no acceleration. I assume there is a default in the Marlin firmware.. there is no doubt some globs of PLA stick like in dots between the strings, but the extrusion between direction changes do not kind of like join the dots where dots stick and joins don't.</em> </p> <p><em>I am going to change the coupler because, well, I don't know what else to do. Replacing it with a better one can't help. Other things I have thought about - PLA temps - I have gone up the whole range according to the manufacturers bandwidth in 5 degree increments no difference I have also done some bed changes but neither hotter nor colder (it's 30°C and humid at the moment, so maybe a materials property issue, but then again no difference in conditions between a successful first test and all the messes). I am storing the PLA in a gel bead box to reduce humidity. still basically stumped!</em></p> <p><strong>EDIT 2</strong>: (Additional information posted as comment, now moved to question)</p> <p><em>Thanks for your observation, it's a new bed and I clean down with alcohol wipes ( isopropyl) I don't think I have ever put a finger on the bed - very aware of that. While I don't know what I am talking about on the one hand I am semi convinced it is not the bed, anyway I am going to get a glass bed in part to deal with the protruding screw head issue.</em></p>
<p>The "springs" connected to the stepper motors aren't a problem. They are special shaft couplers which allow some relief if the motor mounts are not strictly perpendicular to the lead screws. They are very rotationally stiff and allow just a little bit of misalignment between the shafts.</p> <p>The first two prints were from the SD card. You didn't talk about slicing from an STL file, so it is possible that they were pre-sliced for this machine. Every G-code file has introductory code that initializes some aspects of the operation. Check the "preamble" code at the front of the files you have sliced. Are there commands that look different? Is the Z parameter for the first layer different from the pre-sliced files? Are there G-codes missing from the files you sliced?</p> <p>If you are trying to understand what the G-codes do, <a href="http://reprap.org/wiki/G-code" rel="nofollow noreferrer">this resource</a> may be helpful. Some possible commands could be commands to limit acceleration, jerk, speed, or introduce offsets. Also check that the temperatures are being set correctly in the G-code you generated.</p> <p>If you had sliced the files on the SD card, then double check that the parameters were the same. Try re-slicing the object and comparing the G-code that is generated.</p>
<p>What it may useful to improve your prints, are the following elements, according to my personal experience with the Tevo Tornado: 1) level the bed when it's warm. 2) print a cylinder that should measure 100 mm, afterwards measure it with a caliper: regulate the steps per mm according to the difference (many guides for calibration are available, for example: <a href="https://youtu.be/Wk3qYOB4E9I" rel="nofollow noreferrer">https://youtu.be/Wk3qYOB4E9I</a>) 3) print this object to be installed on the z axis and regulated with an M5 screw and nut: <a href="https://www.thingiverse.com/thing:2827664" rel="nofollow noreferrer">https://www.thingiverse.com/thing:2827664</a> 4) Print a test for temperatures, like this: <a href="https://www.thingiverse.com/thing:2131069" rel="nofollow noreferrer">https://www.thingiverse.com/thing:2131069</a> I hope it helps. Happy printing.</p>
974
<p>I started trying to play with Mono, mostly for fun at the moment. I first tried to use the Visual Studio plugin that will convert a csproj into a makefile, but there seemed to be no version available for Visual Studio 2005. I also read about the MonoDevelop IDE, which sounded nice. Unfortunately, there's no pre-fab Windows package for it. I tried to follow some instructions to build it by combining dependencies from other semi-related installs. It didn't work, but that's probably because I'm a Windows-oriented guy and can barely spell "makefile".</p> <p>So, my question is this: What's the lowest-energy way to get up and running to try some Mono-based development on Windows?</p>
<p>I'd recommend getting VMWare Player and using the free Mono development platform image that is provided on the website.</p> <p><a href="http://www.go-mono.com/mono-downloads/download.html" rel="nofollow noreferrer">Download Mono</a></p> <p>Setup time for this will be minimal, and it will also allow you to get your code working in .NET and then focus on porting issues without a massive hassle of switching machines and the like. the VMWare Player tools will allow you to simply drag and drop the files over to copy them.</p> <p>I'm looking to take a couple of my .NET apps and make them Mono compliant, and this is the path I'm going to take here shortly.</p>
<p>I liked the idea of trying to use MonoDevelop mostly just to make sure my stuff would work against the Mono runtimes. I guess it would also be possible to get crazy with msbuild and write some custom targets that tried to build against Mono, but that's basically emulating the now-defunct plug-in's functionality which I assume was non-trivial to build. I do have minor experience with cygwin, and I am happy typing "configure" and "make" all day long, but when a problem occurs in that process, I'm virtually screwed. I'll probably try to play with all this again, but if it takes me more than a couple hours to come up with a way to build comfortably against the Mono runtimes, I'll probably just bail.</p> <p>I will try the Eclipse idea. I use that for Java, so I might be able to get the c# stuff to work. We shall see...</p>
2,492
<p>There are three places where menus show up in the new MFC functionality (Feature Pack):</p> <ul> <li>In menu bars (CMFCMenuBar)</li> <li>In popup menus (CMFCPopupMenu)</li> <li>In the 'dropdown menu' version of CMFCButton</li> </ul> <p>I want to put icons (high-color and with transparancy) in the menus in all of them. I have found CFrameWndEx::OnDrawMenuImage() which I can use to custom draw the icons in front of the menu bar items. It's not very convenient, having to implement icon drawing in 2008, but it works. For the others I haven't found a solution yet. Is there an automagic way to set icons for menus?</p>
<p>This is how I got it to work:</p> <h3>First</h3> <p>, as the others said, create an invisible toolbar next to your main toolbar (I'm using the usual names based on AppWizard's names):</p> <pre><code>MainFrm.h: class CMainFrame { //... CMFCToolBar m_wndToolBar; CMFCToolBar m_wndInvisibleToolBar; //... }; MainFrm.cpp: int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { //... // Normal, visible toolbar if(m_wndToolBar.Create(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)) { VERIFY( m_wndToolBar.LoadToolBar( theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME) ); // Only the docking makes the toolbar visible m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); DockPane(&amp;m_wndToolBar); } // Invisible toolbar; simply calling Create(this) seems to be enough if(m_wndInvisibleToolBar.Create(this)) { // Just load, no docking and stuff VERIFY( m_wndInvisibleToolBar.LoadToolBar(IDR_OTHERTOOLBAR) ); } } </code></pre> <h3>Second: The images and toolbar resources</h3> <p><code>IDR_MAINFRAME</code> and <code>IDR_MAINFRAME_256</code> were generated by AppWizard. The former is the ugly 16 color version and the latter is the interesting high color version.<br> Despite its name, if I remember correctly, even the AppWizard-generated image has 24bit color depth. The cool thing: Just replace it with a 32bit image and that'll work, too. </p> <p>There is the invisible toolbar <code>IDR_OTHERTOOLBAR</code>: I created a toolbar with the resource editor. Just some dummy icons and the command IDs. VS then generated a bitmap which I replaced with my high color version. Done!</p> <h3>Note</h3> <p>Don't open the toolbars with the resource editor: It may have to convert it to 4bit before it can do anything with it. And even <em>if</em> you let it do that (because, behind Visual Studio's back, wou're going to replace the result with the high color image again, ha!), I found that it (sometimes?) simply cannot edit the toolbar. Very strange.<br> In that case I advise to directly edit the .rc file.</p>
<p>One thing that can catch a person by surprise is that for customizable (ie, non-locked) toolbars, the first toolbar you make, the framework splits up and turns into some sort of palette bitmap of all icons in the program. If you try to add more toolbars later (or different toolbars) that have bitmaps (or pngs) with a different color depth than that first one, they seem to fail because it can't add them to the same palette.</p>
9,575
<p>How can I generate UML diagrams (especially sequence diagrams) from existing Java code?</p>
<h1><a href="http://www.objectaid.com/home" rel="noreferrer">ObjectAid UML Explorer</a></h1> <p>Is what I used. It is easily <strong><a href="https://www.objectaid.com/install-objectaid" rel="noreferrer">installed</a></strong> from the repository:</p> <pre><code>Name: ObjectAid UML Explorer Location: http://www.objectaid.com/update/current </code></pre> <p>And produces quite nice UML diagrams:</p> <p><img src="https://i.stack.imgur.com/QPnZD.png" alt="Screenshot"></p> <h2>Description from the website:</h2> <blockquote> <p>The ObjectAid UML Explorer is different from other UML tools. It uses the UML notation to show a graphical representation of existing code that is as accurate and up-to-date as your text editor, while being very easy to use. Several unique features make this possible:</p> <ul> <li>Your source code and libraries are the model that is displayed, they are not reverse engineered into a different format.</li> <li>If you update your code in Eclipse, your diagram is updated as well; there is no need to reverse engineer source code.</li> <li>Refactoring updates your diagram as well as your source code. When you rename a field or move a class, your diagram simply reflects the changes without going out of sync.</li> <li>All diagrams in your Eclipse workspace are updated with refactoring changes as appropriate. If necessary, they are checked out of your version control system.</li> <li>Diagrams are fully integrated into the Eclipse IDE. You can drag Java classes from any other view onto the diagram, and diagram-related information is shown in other views wherever applicable.</li> </ul> </blockquote>
<p>I suggest PlantUML. this tools is very usefull and easy to use. PlantUML have a plugin for Netbeans that you can create UML diagram from your java code.</p> <p>you can install PlantUML plugin in the netbeans by this method:</p> <p>Netbeans Menu -> Tools -> Plugin</p> <p>Now select Available Plugins and then find PlantUML and install it.</p> <p>For more information go to website: www.plantuml.com</p>
7,500
<p>I have a client/server application that communicates with .Net remoting. I need my clients to be able to find the server(s) on the network without requiring client-side configuration. </p> <p>As far as I know, there is no support for discovery in remoting. I am prepared to implement a UDP solution where the clients will be able to find the servers via broadcast messages. </p> <p>I want to hear the collective SO wisdom before I go ahead. Is this the best way? Any other suggestions?</p>
<p>I've looked at both SSDP and UPnP for this type of functionality, but I'd recommend going with a custom UDP <a href="http://en.wikipedia.org/wiki/Multicast" rel="nofollow noreferrer">multicast</a> solution. Basically, multicast is very similar to a broadcast, but only machines that have joined the multicast group (i.e. requested the broadcast) are contacted. </p> <p>IMHO, SSDP and UPnP and bloated and overly complicated for resource discovery... but hey, it's a standard. ;) </p>
<p>The best solution I have found in my remoting work was to keep the server list in a config file on the client systems and make it updateable. Not the easiest to maintain but was fast and no broadcasting.</p>
4,231
<p>Today, I ran into this weird problem with a user using Mac OS X. This user always had a failed upload. The form uses a regular "input type=file". The user could upload using any browser except Firefox 3 on his Mac. Only this particular user was seeing this error.</p> <p>Obviously, the problem is only with this one particular user.</p>
<p>User corrected this weird problem by recreating their FireFox profile. <a href="http://support.mozilla.com/en-US/kb/Managing+profiles" rel="nofollow noreferrer">How to manage FireFox profiles</a></p> <p>I imagine a re-install of FireFox would have corrected the problem as well.</p>
<blockquote> <p>I imagine a re-install of FireFox would have corrected the problem as well.</p> </blockquote> <p>Profile related problems cannot usually be solved by re-installing Firefox since reinstalling (or upgrading) would re-use the same "damaged" profile.</p>
2,707
<p>I have a Windows Form that takes quite a bit of time to load initially. However, each subsequent request to load the Form doesn't take as long. Is there a way to optimize a Form's load time?</p>
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx" rel="noreferrer">ngen</a>.</p> <p>I also use this tip to reduce the <a href="http://www.codeproject.com/KB/smart/rssfeeder.aspx#_Toc109841754" rel="noreferrer">Memory footprint on startup</a>.</p> <p>The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly. </p>
<p>You need to find out where the time is going before you can optimise it. Don't just ngen it without finding that out first, as if the problem is loading a 150MB background bitmap resource then you won't have done anything useful at all with ngen. </p> <p>You should disregard all specific advice or hunches about optimisation which arise without any measurements being made.</p>
8,410
<p>I'm rewriting an old application and use this as a good opportunity to try out C# and .NET development (I usually do a lot of plug-in stuff in C).</p> <p>The application is basically a timer collecting data. It has a start view with a button to start the measurement. During the measurement the app has five different views depending on what information the user wants to see.</p> <p>What is the best practice to switch between the views? From start to running? Between the running views?</p> <p>Ideas:</p> <ul> <li>Use one form and hide and show controls</li> <li>Use one start form and then a form with a TabControl</li> <li>Use six separate forms</li> </ul>
<p>Creating a bunch of overlaid panels is a design-time nightmare.</p> <p>I would suggest using a tab control with each "view" on a separate tab, and then picking the correct tab at runtime. You can avoid showing the tab headers by putting something like this in your form's Load event:</p> <pre><code>tabControl1.Top = tabControl1.Top - tabControl1.ItemSize.Height; tabControl1.Height = tabControl1.Height + tabControl1.ItemSize.Height; tabControl1.Region = new Region(new RectangleF(tabPage1.Left, tabPage1.Top, tabPage1.Width, tabPage1.Height + tabControl1.ItemSize.Height)); </code></pre>
<p>I would also check out <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx" rel="nofollow noreferrer">Composite Application Guidance for WPF</a> or <a href="http://msdn.microsoft.com/en-us/library/aa480450.aspx" rel="nofollow noreferrer">Smart Client Software Factory</a> </p>
4,478
<p>I just installed Java 1.6_07 so I could try profiling with VisualVM. It tells me that my app is spending 60% of its time in <code>sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run</code> </p> <p>How do I find out what it was doing during that time? How much of the time was it waiting for something to call it, or doing something else? What was calling it and what was it calling? I just can't seem to find any way to drill down to deeper levels like there is in Quantify or the Perl profiler.</p>
<p>I don't have experience with VisualVM -- but JRockit's profiler <em>does</em> provide this information; you may consider using it instead.</p> <p><strong>Update:</strong> a question with a list of java profilers can be found <a href="https://stackoverflow.com/questions/14762/please-recommend-a-java-profiler">here</a>, for users with sufficient rep to view deleted questions.</p>
<p>I have started using <a href="https://visualvm.dev.java.net/" rel="nofollow noreferrer">the new VisualVM 1.2</a>. It allows profiling CPU and drilling down using a call graph. Try it out.</p>
8,334
<p>I am working with an API that provides bus arrival data. For every request, I get back (among other things) a list of which routes serve the stop in question. For example, if the list includes result for bus route #1, 2, and 5, then I know that those serve this stop.</p> <p>I have a many-to-many relationship set up between Route and Stop, and I want to dynamically check and update these associations on every request. There is no "master list" of which routes serve which stops, so this seems like the best way to get this data.</p> <p>I believe that the way I'm doing it now is very inefficient:</p> <pre><code># routes is an array of [number, destination] that I build while iterating over the data routes.uniq.each do |route| number = route[0] destination = route[1] r = Route.find_by_number_and_destination(number, destination) if !r r = Route.new :number =&gt; number, :destination =&gt; destination r.save end # I have to check if it already exists because I can't find a way # to create a uniqueness constraint on the join table with 2 foreign keys r.stops &lt;&lt; stop unless r.stops.include? stop end </code></pre> <p>Basically, I have to do 2 things for every route I find: 1) Create it if it doesn't already exist, 2) Add a relationship to the current stop if it doesn't already exist.</p> <p>Is there a better way to do this, for example by getting a bunch of the data in memory and doing some of the processing on the app server side, in order to avoid the multitude of database calls I'm currently doing?</p>
<p>If I get it right, you (should) have 2 models. A Route model, and a Stop model.</p> <p>Here's how I would define these models:</p> <pre><code>class Route &lt; ActiveRecord::Base has_and_belongs_to_many :stops belongs_to :stop, :foreign_key =&gt; 'destination_id' end class Stop &lt; ActiveRecorde::Base has_and_belongs_to_many :routes end </code></pre> <p>And here's how I would set up my tables:</p> <pre><code>create_table :routes do |t| t.integer :destination_id # Any other information you want to store about routes end create_table :stops do |t| # Any other information you want to store about stops end create_table :routes_stops, :primary_key =&gt; [:route_id, :stop_id] do |t| t.integer :route_id t.integer :stop_id end </code></pre> <p>Finally, here's the code I'd use:</p> <pre><code># First, find all the relevant routes, just for caching. Route.find(numbers) r = Route.find(number) r.destination_id = destination r.stops &lt;&lt; stop </code></pre> <p>This should use only a few SQL queries.</p>
<p>There's likely a good way to cleanup the stops call, but this cleans it up quite a bit assuming I'm picturing properly how routes is structured. </p> <pre><code>routes.uniq.each do |number, destination| r = Route.find_or_create_by_number_and_destination(route[0], destination) r.stops &lt;&lt; stop unless r.stops.include? stop end </code></pre>
7,062
<p>I'm failing at finding the commands I need to send to authenticate to a SMTP server using NTLM. </p> <p>I think it goes something like:</p> <pre><code>AUTH NTLM &lt;bae64encode something&gt; 334 &lt;bae64encode something&gt; 235 </code></pre>
<p>SVN with Siteminder has been implemented and is working now. Since there is not much of information out there on this, I would like to post the overview of steps followed:</p> <ol> <li>Cookie based authentcation was disabled on Siteminder end</li> <li>HTTP AUTH was enabled (in Siteminder) and all webdav methods were added to policy server to be handled by SiteMinder</li> <li>Authentication was disabled on apache end (HTTP Auth) for SVN</li> </ol>
<p>Look for information about <strong>Apache</strong> and Siteminder as Apache is responsible for the HTTP transport stuff in Subversion</p>
9,937
<p><a href="http://php.net/Interfaces" rel="noreferrer">Interfaces</a> allow you to create code which defines the methods of classes that implement it. You cannot however add any code to those methods. </p> <p><a href="http://php.net/Abstract" rel="noreferrer">Abstract classes</a> allow you to do the same thing, along with adding code to the method. </p> <p>Now if you can achieve the same goal with abstract classes, why do we even need the concept of interfaces? </p> <p>I've been told that it has to do with OO theory from C++ to Java, which is what PHP's OO stuff is based on. Is the concept useful in Java but not in PHP? Is it just a way to keep from having placeholders littered in the abstract class? Am I missing something?</p>
<p>The entire point of interfaces is to give you the flexibility to have your class be forced to implement multiple interfaces, but still not allow multiple inheritance. The issues with inheriting from multiple classes are many and varied and the <a href="http://en.wikipedia.org/wiki/Multiple_inheritance" rel="noreferrer">wikipedia</a> page on it sums them up pretty well.</p> <p>Interfaces are a compromise. Most of the problems with multiple inheritance don't apply to abstract base classes, so most modern languages these days disable multiple inheritance yet call abstract base classes interfaces and allows a class to "implement" as many of those as they want.</p>
<p>Below are the points for PHP Interface </p> <ol> <li>It is used to define required no of methods in class [if you want to load html then id and name is required so in this case interface include setID and setName].</li> <li>Interface strictly force class to include all the methods define in it. </li> <li>You can only define method in interface with public accessibility.</li> <li>You can also extend interface like class. You can extend interface in php using extends keyword.</li> <li>Extend multiple interface.</li> <li>You can not implement 2 interfaces if both share function with same name. It will throw error.</li> </ol> <p><strong>Example code :</strong></p> <pre><code>interface test{ public function A($i); public function B($j = 20); } class xyz implements test{ public function A($a){ echo "CLASS A Value is ".$a; } public function B($b){ echo "CLASS B Value is ".$b; } } $x = new xyz(); echo $x-&gt;A(11); echo "&lt;br/&gt;"; echo $x-&gt;B(10); </code></pre>
4,082
<p>I have an idea for a simple application which will monitor a group of folders, index any files it finds. A gui will allow me quickly tag new files and move them into a single database for storage and also provide an easy mechanism for querying the db by tag, name, file type and date. At the moment I have about 100+ GB of files on a couple removable hard drives, the database will be at least that big. If possible I would like to support full text search of the embedded binary and text documents. This will be a single user application.</p> <p>Not trying to start a DB war, but what open source DB is going to work best for me? I am pretty sure SQLLite is off the table but I could be wrong.</p>
<p>I'm still researching this option for one of my own projects, but <a href="http://incubator.apache.org/couchdb/" rel="nofollow noreferrer">CouchDB</a> may be worth a look.</p>
<p>why are you wasting time emulating something that the filesystem should be able to handle? more storage + grep is your answer.</p>
6,612
<p>What does the <code>volatile</code> keyword do? In C++ what problem does it solve?</p> <p>In my case, I have never knowingly needed it.</p>
<p><code>volatile</code> is needed if you are reading from a spot in memory that, say, a completely separate process/device/whatever may write to.</p> <p>I used to work with dual-port ram in a multiprocessor system in straight C. We used a hardware managed 16 bit value as a semaphore to know when the other guy was done. Essentially we did this:</p> <pre><code>void waitForSemaphore() { volatile uint16_t* semPtr = WELL_KNOWN_SEM_ADDR;/*well known address to my semaphore*/ while ((*semPtr) != IS_OK_FOR_ME_TO_PROCEED); } </code></pre> <p>Without <code>volatile</code>, the optimizer sees the loop as useless (The guy never sets the value! He's nuts, get rid of that code!) and my code would proceed without having acquired the semaphore, causing problems later on.</p>
<p>One use I should remind you is, in the signal handler function, if you want to access/modify a global variable (for example, mark it as exit = true) you have to declare that variable as 'volatile'.</p>
9,815
<p>I made a custom printer with RAMPS. I used Y-MIN endstop at beginning. After few prints I discovered that Y-axis was inverted (mirrored).</p> <p>I fixed Marlin firmware and now I have:</p> <pre><code>#define Y_MAX_ENDSTOP_INVERTING true #define INVERT_Y_DIR false #define Y_HOME_DIR 1 #define USE_YMAX_PLUG </code></pre> <p>I also connected the Y-endstop to Y-max pin on RAMPS.</p> <p>Now the printer homing in the same direction than before (in front) and the y-endstop works as expected.</p> <p>If I try to start printing or if I try to press the "center" button in Pronterface, the Y-axis moves in the wrong direction.</p> <p>Can someone help me?</p>
<p>This <a href="https://www.everybitelectronics.co.uk/blog/3d-printer-error-prints-reversed/" rel="nofollow noreferrer">blog post</a> shows 3 main solutions:</p> <ol> <li>Flipping the motor cables (As suggested in the other answer)</li> <li>Switching the x and y-axis: This may switch the direction of your y-axis depending on the way your printer is setup)</li> <li>Change the direction of the axis in firmware which you can see below how to do:</li> </ol> <blockquote> <p>"When the solution opens up, you will see many different files open. You need to navigate to the Configuration.h file. Within this file scroll down to the following lines of code:"</p> </blockquote> <pre><code>// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. define INVERT_X_DIR true define INVERT_Y_DIR true define INVERT_Z_DIR true </code></pre> <blockquote> <p>"This is where you need to switch the values around. If they are currently true, change them to false and if they are false, change them to true. Due to the fact I was having issues with my x-Axis, I have changed the above to the following:"</p> </blockquote> <pre><code>// Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. define INVERT_X_DIR false define INVERT_Y_DIR true define INVERT_Z_DIR true </code></pre>
<p>Usually I just flip the connector around on the board. This causes the stepper to reverse without fiddling around with firmware.</p>
1,601
<p>After lots of attempts and search I have never found a satisfactory way to do it with CSS2.</p> <p>A simple way to accomplish it is to wrap it into a handy <code>&lt;table&gt;</code> as shown in the sample below. Do you know how to do it avoiding table layouts and also avoiding quirky tricks?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>table { margin: 0 auto; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;test&lt;br/&gt;test&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;</code></pre> </div> </div> </p> <hr /> <p>What I want to know is how to do it without a fixed width and also being a block.</p>
<p>@Jason, yep, <code>&lt;center&gt;</code> works. Good times. I'll propose the following, though:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: center; } .my-centered-content { margin: 0 auto; /* Centering */ display: inline; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="my-centered-content"&gt; &lt;p&gt;test&lt;/p&gt; &lt;p&gt;test&lt;/p&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><strong>EDIT</strong> @Santi, a block-level element will fill the width of the parent container, so it will effectively be <code>width:100%</code> and the text will flow on the left, leaving you with useless markup and an uncentered element. You might want to try <code>display: inline-block;</code>. Firefox might complain, but <a href="http://www.w3.org/TR/CSS21/visuren.html#display-prop" rel="nofollow noreferrer">it's right</a>. Also, try adding a <code>border: solid red 1px;</code> to the CSS of the <code>.my-centered-content</code> DIV to see what's happening as you try these things out.</p>
<p>The following works well enough. note the <em>position</em>, and the use of <em>auto</em></p> <pre><code>&lt;div style="border: 1px solid black; width: 300px; height: 300px;"&gt; &lt;div style="width: 150px; height: 150px; background-color: blue; position: relative; left: auto; right: auto; margin-right: auto; margin-left: auto;"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>NOTE: not sure if it works in IE.</p>
6,845
<p>I have an application that runs as a child application in a virtual directory.</p> <p>I want to pass a value from the parent application, but I believe that Session is keyed per application, and won't work.</p> <p>To further complicate things, the parent application is WebForms, while the child is NVelocity MVC.</p> <p>Does anyone know a trick that allows me to use some sort of Session type functionality between virtual applications?</p> <p>EDIT: A webservice isn't really what I had in mind, all I need to do is pass the logged in users username to the child app. Besides, if calling a webservice back on the parent, I won't get the same session, so I won't know what user.</p>
<p>Sounds like web service is the way to go. You could do something like the following:</p> <ul> <li>Have the WebForms app create some data in its database with a key of some kind associated to it.</li> <li>Pass that key in the URL to the NVelocity MVC application.</li> <li>Allow the NVMVC application to call a web service (REST,XML-RPC,SOAP,whatever) on the WebForms app using the key that was passed.</li> </ul> <p>This will get around any kind of session keying or cookie-domain problem you may have and allow you to pass some nicely structured data.</p>
<p>You can do a server-side HTTP Request, it looks something like this in C#:</p> <pre><code>HttpWebRequest req = (HttpWebRequest)WebRequest.Create("/ASPSession.ASP?SessionVar=" + SessionVarName); req.Headers.Add("Cookie: " + SessionCookieName + "=" + SessionCookieValue); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); Stream receiveStream = resp.GetResponseStream(); System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8"); StreamReader readStream = new StreamReader(receiveStream, encode); string response = readStream.ReadToEnd(); resp.Close(); readStream.Close(); return response; </code></pre> <p>On the ASP side, I just verify that the request only comes from localhost, to prevent XSS-style attacks, and then the response is just the value of the Session variable.</p> <p>Finding the cookie is easy enough, Session cookies all have similar names, so just examine the cookies collection until you find the appropriate cookie. Note, this does only work if the cookies are valid on the entire domain, and not just on the subfolder your are on.</p>
9,343
<p>If I have Python code</p> <pre><code>class A(): pass class B(): pass class C(A, B): pass </code></pre> <p>and I have class <code>C</code>, is there a way to iterate through it's super classed (<code>A</code> and <code>B</code>)? Something like pseudocode:</p> <pre><code>&gt;&gt;&gt; magicGetSuperClasses(C) (&lt;type 'A'&gt;, &lt;type 'B'&gt;) </code></pre> <p>One solution seems to be <a href="http://docs.python.org/lib/module-inspect.html" rel="noreferrer">inspect module</a> and <code>getclasstree</code> function.</p> <pre><code>def magicGetSuperClasses(cls): return [o[0] for o in inspect.getclasstree([cls]) if type(o[0]) == type] </code></pre> <p>but is this a "Pythonian" way to achieve the goal?</p>
<p><code>C.__bases__</code> is an array of the super classes, so you could implement your hypothetical function like so:</p> <pre><code>def magicGetSuperClasses(cls): return cls.__bases__ </code></pre> <p>But I imagine it would be easier to just reference <code>cls.__bases__</code> directly in most cases.</p>
<p>The inspect module was a good start, use the <a href="http://docs.python.org/library/inspect.html#inspect.getmro" rel="nofollow noreferrer">getmro</a> function:</p> <blockquote> <p>Return a tuple of class cls’s base classes, including cls, in method resolution order. No class appears more than once in this tuple. ...</p> </blockquote> <pre><code>&gt;&gt;&gt; class A: pass &gt;&gt;&gt; class B: pass &gt;&gt;&gt; class C(A, B): pass &gt;&gt;&gt; import inspect &gt;&gt;&gt; inspect.getmro(C)[1:] (&lt;class __main__.A at 0x8c59f2c&gt;, &lt;class __main__.B at 0x8c59f5c&gt;) </code></pre> <p>The first element of the returned tuple is <code>C</code>, you can just disregard it.</p>
4,541
<p>I just received this printer and while it seems to talk to Makerbot Desktop software I'm not sure if I should be trying to update the firmware.</p> <p>The printer comes with firmware v7.2 and while Makerbot Desktop offers an upgrade to v7.5 I'm not sure if it's a good idea with this non-Makerbot branded printer.</p> <p>I've also seen information on upgrading this printer to Sailfish v7.5, is this the same thing as Makerbot firmware v7.5?</p>
<p>The Monoprice Architect is is a bare-bones FlashForge Creator that has been re-badged for Monoprice. The Creator line is a very popular set of printers, so there is lots of good advice out there. The FlashForge Google Group is a good community to join: <a href="https://groups.google.com/forum/#!forum/flashforge" rel="nofollow">https://groups.google.com/forum/#!forum/flashforge</a></p> <p>The entire FF Creator line, in turn, is cloned from the original Makerbot Replicator 1. So you can use Makerbot slicing profiles for the Replicator 1. Just keep in mind that Makerbot does not generally test new software revs with their older printers, and DEFINITELY does not test new software revs with competitor knock-offs. Sometimes they appear to break functionality for non-Makerbot machines on purpose. So recent versions of Makerbot Desktop may not "play nice" with your FlashForge. <strong>The most recent "known good" free slicer you should use with this printer is Makerware 2.4.x. You can find links by searching the FF Google Group.</strong></p> <p>On that note, you may have received instructions to use ReplicatorG with your printer. But RepG is abandonware: development stopped years ago. It should only be used for firmware updates, not as a slicer. You should also only use the most recent version posted on the Sailfish page on Thingiverse: </p> <p><a href="http://www.thingiverse.com/thing:32084" rel="nofollow">http://www.thingiverse.com/thing:32084</a></p> <p>Using older versions of RepG with newer firmware revs will corrupt your EEPROM! Only use the version downloaded from the link above. </p> <p>The firmware that comes with the printer is FlashForge's slightly-customized build of either Sailfish or Makerbot's Replicator 1/2/2x firmware. But here's the trick: Makerbot's Rep1/2/2x firmware is just an old, out-of-date, slightly customized version of Sailfish. Makerbot stopped keeping up with bug-fixes and feature additions a long time ago. <strong>Everything is Sailfish:</strong> just different versions. You should use the most recent official release version listed at:</p> <p><a href="http://www.sailfishfirmware.com/" rel="nofollow">http://www.sailfishfirmware.com/</a></p> <p>Follow the instructions in the Sailfish manual from the link above, and RepG will automatically pull the right builds from the official mirror and populate a list of printer options to choose. The trick here is which build to download. As of 1-21-16, there is not an official Monoprice Architect build yet. Which would mean editing a machine xml profile to avoid the firmware throwing warnings. I STRONGLY recommend getting used to the printer using factory firmware before trying to fight with custom machine profiles... But here is the basic process to pick a Sailfish firmware build when you're ready:</p> <p>First: which Atmega processor version do you have? The large chip in the middle of the control board will either say 1280 or 2560. You need to know which version you have. Bad things happen if you load the wrong version.</p> <p>Second: What is the tooth count on the X and Y drivetrain pulleys? To my knowledge, FF always uses 17-tooth pulleys, which matches the Replicator 1 and FF Creator profiles. The Rep2 and 2x use 18t pulleys, so only use those builds if you have those pulleys. People often mess this up and their prints end up with dimensions ~5% off in X and Y. </p> <p>Third: The Architect has one extruder and no heatbed, so firmware builds that expect those to be connected (Rep 1 Dual, Creator, etc) will throw errors if loaded. You can fix this from the LCD screen or RepG, but that's a whole separate question. Do some printing and learn about the printer before attempting any firmware update so you'll know what to do if you pick a build with the wrong parts. </p> <p>Fourth: This one is just for the sake of completeness. Some FF models were shipped with off-spec heatbeds that require special firmware builds to prevent drawing too much current and overheating / overloading the power supply. The Architect doesn't have that, but firmware builds for those printer models (eg I believe the FF Creator 2560) will under-power regular heatbeds. This is just something you need to know with the Architect if you decide to install a heatbed later. But it's a really critical safety warning for people with those off-spec heatbeds. </p> <p>If this all seems complicated, that's because FlashForge (and in turn Monoprice) relies heavily on the open source Sailfish project to maintain the software ecosystem behind this line of printers. FlashForge has some internal builds that they use for flashing new bots, but these are not kept particularly up-to-date. Nor does FlashForge release the source files, so it's quite opaque where exactly the stock firmware differs from mainstream Sailfish. In the long run, you should install mainline Sailfish. But it's ok to stick with the factory firmware until you get used to the printer. </p> <p>To summarize: Because there is not an existing Sailfish build, you're going to need to do some investigating and some experimenting to figure out which build will work. Don't try that until you're familiar with the printer. Post on the FlashForge Google Group when you're ready for help.</p>
<p>Since the printer has no heater, I'd advise some sleuthing</p> <ol> <li>Look at the motherboard. Find the big black square chip and see if it is a ATmega 1280 or 2560. Likely it's a 1280, but you never know. This will impact which firmware build you use.</li> <li>If you will eventually add a heater PCB, then figure out the size (wattage) of the power supply. It may be big enough now for a heated platform, or maybe not. I guess you can cross that bridge if/when you add a HBP (heated build platform). However, it can make a difference as to which firmware build you load as some builds of Sailfish will intentionally serialize heating so as to not put too high of a load on the power supply (PSU).</li> </ol> <p>Armed with the above info, you can then decide if you want a 1280 or 2560 build of Sailfish. And if you want a build which will serialize eventual use of an HBP or not.</p> <p>Serialized: MakerBot Replicator 1 Single &amp; Dual (implied ATmega 1280), MakerBot Replicator 1 with ATmega 2560</p> <p>Non-serialized: FlashForge Creator I, II &amp; X (implied ATmega 1280)</p> <p>For a non-serialized, 2560 build know that the FlashForge one is for a poorly behaved heater PCB and you likely won't want it. That sort of leaves you without a good, non-serialized choice. In a pinch you can use the ZYYX 3D build for a 2560. Or you can contact the Sailfish team directly: speaking with very certain knowledge, I can assure you that they'd be happy to do a targetted build for your machine. However, at present they lack info to do so (e.g., build volume, distances from endstops to center of build platform, etc.).</p>
156
<p>I want to insert some special characters at the caret inside textboxes using javascript on a button. How can this be done?</p> <p>The script needs to find the active textbox and insert the character at the caret in that textbox. The script also needs to work in IE and Firefox.</p> <p><strong>EDIT:</strong> It is also ok to insert the character "last" in the previously active textbox.</p>
<p>I think Jason Cohen is incorrect. The caret position is preserved when focus is lost.</p> <p>[<strong>Edit</strong>: Added code for FireFox that I didn't have originally.]</p> <p>[<strong>Edit</strong>: Added code to determine the most recent active text box.]</p> <p>First, you can use each text box's onBlur event to set a variable to "this" so you always know the most recent active text box.</p> <p>Then, there's an IE way to get the cursor position that also works in Opera, and an easier way in Firefox.</p> <p>In IE the basic concept is to use the document.selection object and <em>put</em> some text <em>into</em> the selection. Then, using indexOf, you can get the position of the text you added.</p> <p>In FireFox, there's a method called selectionStart that will give you the cursor position.</p> <p>Once you have the cursor position, you overwrite the whole text.value with</p> <p>text before the cursor position + the text you want to insert + the text after the cursor position</p> <p>Here is an example with separate links for IE and FireFox. You can use you favorite browser detection method to figure out which code to run.</p> <pre><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt; &lt;script language="JavaScript"&gt; &lt;!-- var lasttext; function doinsert_ie() { var oldtext = lasttext.value; var marker = "##MARKER##"; lasttext.focus(); var sel = document.selection.createRange(); sel.text = marker; var tmptext = lasttext.value; var curpos = tmptext.indexOf(marker); pretext = oldtext.substring(0,curpos); posttest = oldtext.substring(curpos,oldtext.length); lasttext.value = pretext + "|" + posttest; } function doinsert_ff() { var oldtext = lasttext.value; var curpos = lasttext.selectionStart; pretext = oldtext.substring(0,curpos); posttest = oldtext.substring(curpos,oldtext.length); lasttext.value = pretext + "|" + posttest; } --&gt; &lt;/script&gt; &lt;form name="testform"&gt; &lt;input type="text" name="testtext1" onBlur="lasttext=this;"&gt; &lt;input type="text" name="testtext2" onBlur="lasttext=this;"&gt; &lt;input type="text" name="testtext3" onBlur="lasttext=this;"&gt; &lt;/form&gt; &lt;a href="#" onClick="doinsert_ie();"&gt;Insert IE&lt;/a&gt; &lt;br&gt; &lt;a href="#" onClick="doinsert_ff();"&gt;Insert FF&lt;/a&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>This will also work with textareas. I don't know how to reposition the cursor so it stays at the insertion point.</p>
<p>Note that if the user pushes a button, focus on the textbox will be lost and there will be no caret position!</p>
7,775
<p>I need to specifically catch SQL server timeout exceptions so that they can be handled differently. I know I could catch the SqlException and then check if the message string Contains "Timeout" but was wondering if there is a better way to do it?</p> <pre><code>try { //some code } catch (SqlException ex) { if (ex.Message.Contains("Timeout")) { //handle timeout } else { throw; } } </code></pre>
<p>To check for a timeout, I believe you check the value of ex.Number. If it is -2, then you have a timeout situation.</p> <p>-2 is the error code for timeout, returned from DBNETLIB, the MDAC driver for SQL Server. This can be seen by downloading <a href="http://www.red-gate.com/products/reflector/" rel="noreferrer">Reflector</a>, and looking under System.Data.SqlClient.TdsEnums for TIMEOUT_EXPIRED. </p> <p>Your code would read:</p> <pre><code>if (ex.Number == -2) { //handle timeout } </code></pre> <p>Code to demonstrate failure:</p> <pre><code>try { SqlConnection sql = new SqlConnection(@"Network Library=DBMSSOCN;Data Source=YourServer,1433;Initial Catalog=YourDB;Integrated Security=SSPI;"); sql.Open(); SqlCommand cmd = sql.CreateCommand(); cmd.CommandText = "DECLARE @i int WHILE EXISTS (SELECT 1 from sysobjects) BEGIN SELECT @i = 1 END"; cmd.ExecuteNonQuery(); // This line will timeout. cmd.Dispose(); sql.Close(); } catch (SqlException ex) { if (ex.Number == -2) { Console.WriteLine ("Timeout occurred"); } } </code></pre>
<p>When a client sends ABORT, no transactions are rolled back. To avoid this behavior we have to use SET_XACT_ABORT ON <a href="https://learn.microsoft.com/en-us/sql/t-sql/statements/set-xact-abort-transact-sql?view=sql-server-ver15" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/sql/t-sql/statements/set-xact-abort-transact-sql?view=sql-server-ver15</a></p>
4,934
<p>In SEO people talk a lot about Google <a href="http://en.wikipedia.org/wiki/PageRank" rel="nofollow noreferrer">PageRank</a>. It's kind of a catch 22 because until your site is actually big and you don't really need search engines as much, it's unlikely that big sites will link to you and increase your PageRank!</p> <p>I've been told that it's easiest to simply get a couple high quality links to point to a site to raise it's PageRank. I've also been told that there are certain Open Directories like dmoz.org that Google pays special attention to (since they're human managed links). Can anyone speak to the validity of this or suggest another site/technique to increase a site's PageRank?</p>
<h2>Have great content</h2> <p>Nothing helps your google rank more than having <strong>content</strong> or offering a service people are interested in. If your web site is better than the competition and solves a real need you will naturally generate more traffic and inbound links.</p> <h2>Keep your content fresh</h2> <h2>Use friendly url's that contain keywords</h2> <p><strong>Good</strong>: <a href="http://cars.com/products/cars/ford/focus/" rel="noreferrer">http://cars.com/products/cars/ford/focus/</a></p> <p><strong>Bad</strong>: <a href="http://cars.com/p?id=1232" rel="noreferrer">http://cars.com/p?id=1232</a></p> <h2>Make sure the page title is relevant and well constructed</h2> <p><strong>For example</strong>: Buy A House In France :. Property Purchasing in France</p> <h2>Use a domain name that describes your site</h2> <p><strong>Good</strong>: <a href="http://cars.com/" rel="noreferrer">http://cars.com/</a></p> <p><strong>Bad</strong>: <a href="http://somerandomunrelateddomainname.com/" rel="noreferrer">http://somerandomunrelateddomainname.com/</a></p> <p><strong>Example</strong> Type car into Google, out of the top 5 links all 4 have car in the domain: <a href="http://www.google.co.uk/search?q=car" rel="noreferrer">http://www.google.co.uk/search?q=car</a></p> <h2>Make it accessible</h2> <p>Make sure people can read your content. This includes a variety of different audiences</p> <ul> <li><p>People with disabilities: Sight, motor, cognitive disabilities etc..</p> </li> <li><p>Search bots</p> <p>In particular make sure search bots can read every single relevant page on your site. Quite often search bots get blocked by the use of <strong>javascript</strong> to link between pages or the use of frames / <strong>flash</strong> / <strong>silverlight</strong>. One easy way to do this is have a site map page that gives access to the whole site, dividing it into categories / sub categories etc..</p> </li> <li><p>Down level browsers</p> </li> </ul> <h2>Submit your site map automatically</h2> <p>Most search engines allow you to submit a list of pages on your site including when they were last updated.</p> <p>Google: <a href="https://www.google.com/webmasters/tools/docs/en/about.html" rel="noreferrer">https://www.google.com/webmasters/tools/docs/en/about.html</a></p> <h2>Inbound links</h2> <p>Generate as much buzz about your website as possible, to increase the likely hood of people linking to you. Blog / podcast about your website if appropriate. List it in online directories (if appropriate).</p> <h2>References</h2> <ul> <li><a href="http://www.seomoz.org/article/search-ranking-factors" rel="noreferrer">Google Search Engine Ranking Factors, by an SEO company</a></li> <li><a href="http://www.google.com/support/webmasters/bin/topic.py?topic=8522%3E" rel="noreferrer">Creating a Google-friendly site: Best practices</a></li> <li><a href="http://en.wikipedia.org/wiki/Search_engine_optimization" rel="noreferrer">Wikipedia - Search engine optimization</a></li> </ul>
<p>A easy trick is to use</p> <p>Google webmaster tool <a href="https://www.google.com/webmasters/tools" rel="nofollow">https://www.google.com/webmasters/tools</a></p> <p>And you can generate a sitemap using <a href="http://www.xml-sitemaps.com/" rel="nofollow">http://www.xml-sitemaps.com/</a></p> <p>Then, don't miss to use www.google.com/analytics/ </p> <p>And be careful, most SEO guides are not correct, playing fair is not always the good approach. For example,everyone says that spamming .edu sites is bad and ineffective but it is effective.</p>
8,283
<p>I got a new CR-10S 3D printer (I received it at Christmas). It has been printing just fine until yesterday, I was doing a print and it randomly paused, it did not restart on its own, I had to restart the print, then the item finished just fine. I am printing today, a very small item, the printer now stopped 3 times. How can I fix this, or do I need to return it?</p>
<p>The cr10s has a filament run-out sensor. If the microswitch doesn't function properly, or you have issues with the wiring, the print pauses.</p>
<p>It would be great if you can write what the printer says when it stops. </p> <p>I suggest you try printing other small objects. If that also stops then the printer itself has a problem. But if the printer prints other objects without stopping, then the one you want to print has bad gcode files. You also need to make sure to keep it up-to-date Cura. It would also be great if you can update your printer firmware. But other than that, problems could be heat problem, power problem, and other stuff; it would be great again if you can write the problem that says on the printer as it stops... </p>
1,563
<p>I am working on a project converting a "spreadsheet application" to a database solution. A macro was written that takes screen shots of each page and pastes them into a PowerPoint presentation. Because of the nice formatting options in Excel, the presentation looks very pretty.</p> <p>The problem I'm having is that I haven't ever seen an Access report that would be pretty enough to display to upper management. I think the output still has to be a PowerPoint presentation. It needs to look as close as possible to the original output.</p> <p>I am currently trying to write some code to use a .pot (presentation template) and fill in the data programmatically. Putting the data into a PowerPoint table has been tricky because the tables are not easy to manipulate. For example, if a particular description is too long, I need to break into the next cell down (word-wrap isn't allowed because I can only have <em>n</em> lines per page).</p> <p>Is there a way to make an Access report pretty, am I headed down the right path, or should I just try to programmatically fill in the Excel spreadsheet and use the code that already exists there to produce the presentation? (I'd still need to figure out how to know when to break a line when using a non-monospaced font, as the users are currently doing that manually when they enter the data in the spreadsheet)</p> <p>Jason Z: If I set it to wrap, and I already have <em>n</em> lines, it would make <em>n</em>+1 or 2 lines on the slide, which is unacceptable.</p> <p>Dennis: That article looks very good, I should be able to glean something from it. Thanks!</p>
<p>Access has the capability to create downright beautiful reports. The problem is that it can't make a spreadsheet look better than Excel. You have to know when to use each tool.</p> <p>Use Excel when you have spreadsheet-like formatting, need a lot of boxes and lines, or want to draw charts.</p> <p>Use Access when you will output a report as a PDF. It's very useful for one-record-per-page detail reports, formatting where you need to position things very precisely, and where you need to embed subreports with related or unrelated data. </p> <p>Think about the reports that would be nasty in Excel because you'd have to merge cells all over the place and do funny things with the placement and the layout would never work. That's where Access shines.</p>
<p>I personally would not try to re-invent the wheel here. If you already have an Excel sheet that has the formatting you want, just export the data from Access into Excel for the report. Now, if you didn't have the original Excel sheet to begin with, that would be a completely different story.</p> <p>As for breaking lines with non-monospaced fonts, have you tried setting the cell format to wrap?</p>
6,532
<p>I am looking for a powerful meta-language to describa behaviour for an application i intend to use in offline mode (google-gears + javascript) and server side sqlite + (php/ruby/java etc) and looking for a good format to describe the model's behaviour which can be easily converted to the target languages. Am I completely off track, and there is a much better way?</p>
<p>Have you looked at <a href="http://code.google.com/webtoolkit/" rel="nofollow noreferrer">Google Web Toolkit</a>? GWT allows you to write server side Java objects which get translated into Javascript for you. This allows you to not deal with the browser quirks at all. I'm not sure how well integrated the Gears and GWT projects are, however. If it isn't integrated yet, I'm sure it will be in fairly short order.</p> <p>Edit: This is probably more of an alternate way of doing what you're looking for, rather than a suggestion for a meta language.</p>
<p>Maybe you should consider using <a href="http://www.codeplex.com/scriptsharp" rel="nofollow noreferrer">Script#</a>?</p>
6,416
<p>I was just assigned to do a CMS using ASP.net 3.5 and MySQL. I am kind of new to ASP.NET development (quite sufficient with C#) and <strong>I am wondering what major ASP.NET and general .NET features I am losing when I don't have the option to use Microsoft SQL Server.</strong></p> <p>I know already from quick Googling that I lose LINQ (and I was really looking forward to using this to build my model layer!), but I am not sure what other handy features I will lose. Since I've been relying on ASP.net tutorials which assume that you use MS SQL Server, I feel a chunk of my ASP.net knowledge just become invalid.</p> <p>Thanks!</p>
<p>You can leverage MySql in a number of ORMs, one of which is NHibernate. For the most part you can treat it as if you were running on SQL Server or Oracle. And with Linq2NHibernate, you can get nice LINQ syntax.</p> <p>You'd lose the SqlDataSource control, but some would argue that it would actually be a blessing :)</p> <p>And of course you'd lose Linq2SQL. EntityFramework will have 3rd party adapters MySql, Oracle and a few others soon after release.</p>
<p>Some things that come to mind:</p> <ul> <li>asp.net has nice "automatic" user management (authentication) system. I think it only goes with SQL Server, but there might be a way to make it work on other DBs. The tutorials assume SQL Server usually (or the built in file based DB for development)</li> <li>Not related to asp.net, but useful for any project is SQLCLR, which I find a great addition to sql server. Lets you delegate logic you write in the business level (supporting dll or classes) to sql server in the from of a SP, but the SP is written in vb.net/c#</li> <li><a href="http://msdn.microsoft.com/en-us/library/ms170722(SQL.90).aspx" rel="nofollow noreferrer">Notification services</a></li> </ul>
7,403
<p>Here is the full error: <code>SqlException: A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 1 - I/O Error detected in read/write operation)</code></p> <p>I've started seeing this message intermittently for a few of the unit tests in my application (there are over 1100 unit &amp; system tests). I'm using the test runner in ReSharper 4.1.</p> <p>One other thing: my development machine is a VMWare virtual machine.</p>
<p>I ran into this many moons ago. Bottom line is you are running out of available ports.</p> <p>First make sure your calling application has connection pooling on.</p> <p>If that does then check the number of available ports for the SQL Server.</p> <p>What is happening is that if pooling is off then every call takes a port and it takes by default 4 minutes to have the port expire, and you are running out of ports.</p> <p>If pooling is on then you need to profile all the ports of SQL Server and make sure you have enough and expand them if necessary.</p> <p>When I came across this error, connection pooling was off and it caused this issue whenever a decent load was put on the website. We did not see it in development because the load was 2 or 3 people at max, but once the number grew over 10 we kept seeing this error. We turned pooling on, and it fixed it.</p>
<p>We saw this in our environment, and traced part of it down to the "NOLOCK" hint in our queries. We removed the NOLOCK hint and set our servers to use Snapshot Isolation mode, and the frequency of these errors was reduced quite a bit.</p>
7,599
<p>I've been going down the learning road with two broken printers that I'm rebuilding with better parts and electronics.</p> <p>One thing that I've recognized is that there is a pretty low likelihood that any hotend or heatbed that has had the thermistor/thermocouple and/or the printer board swapped with a non-OEM part can be trusted to accurately report it's own temperature.</p> <p>Sure, there are lots of things I can (and do) do to try to make it as accurate as reasonable like calibrating with thermistors from multimeters, IR thermometers, etc., but each method has limitations. You never know if the 2nd thermistor is mounted both correctly, or if it is reading the same local temp as the printer thermistor. IR thermometers have issues with reflective surfaces (like aluminum hot ends and build plates) Calibrating the thermistor constants from experimental data isn't perfect.</p> <p>IMHO, any hotend/heatbed temp on a DIY setup might be off by a constant &plusmn;&nbsp;5&nbsp;&deg;C or so, more if it is poorly calibrated.</p> <p>Printers use PID controlled heaters to keep oscillations down to a degree or two Celsius, because people say it impacts print quality.</p> <p>Is there a good visual or experimental way to know whether your temperatures are "correct" for your printer/filament? IOW, if my filament was supposed to be heated to 220&nbsp;&deg;C, how would I know if my printer was having issues because the "true" temperature is only 215&nbsp;&deg;C (or 225&nbsp;&deg;C) when it is reporting 220&nbsp;&deg;C?</p> <p>One common problem I've experienced is the nozzle clogging after the transistion from layer 1 to layer 2. (Layer 1 = higher heat and slower speeds, Layers 2+ = lower heat and faster speeds.) It's been a struggle to know which factor (lower heat or faster speeds) are to blame for the clogs after the transition.</p>
<p>The short answer is, you use the temps and speeds that give you good results. It's trial and error. </p> <p>The temperature number your printer reports really doesn't matter. That's just a process control variable: it needs to be consistent and repeatable, but it doesn't need to be accurate against an independent reference. What you should care about is your print results. </p> <p>Some signs your printing temp is too cold:</p> <ul> <li>PLA printed parts have a dull, matte surface</li> <li>Poor layer adhesion</li> <li>Extruder stalls or strips the filament at fairly low printing speeds for your extruder and nozzle size</li> </ul> <p>Some signs your printing temp is too hot:</p> <ul> <li>PLA printed parts have a very shiny surface</li> <li>PLA has a very strong sugary/waffle smell, or any material smells burnt</li> <li>Stringiness during travel moves that you can't eliminate by tuning retraction</li> <li>Excessive oozing while the nozzle is stationary off the print</li> <li>Bubbles or cloudiness in extruded strands in extruded strands even with dry filament</li> </ul> <p>You will also calibrate speeds via trial and error. There are two main speed limits for a printer: how fast the motion mechanism can move the nozzle without running into issues or unacceptable print quality degradation (which is also a function of acceleration settings), and how fast the hot end can heat up and melt filament. </p> <p>The mechanism speed limits you have to find via trial and error. Pick a test print you like (such as Benchy) and repeat it with different tuning until you find your preferred limits.</p> <p>Melt flow restrictions are slightly more complex, because they are a function of VOLUME flow rate, not commanded speeds. Make a large boxy test print (with long straight lines) and multiply extrusion width times layer height times feedrate. That will give you your approximate flow rate in mm<sup>3</sup>/sec. Generally speaking, every extruder + hot end + material combo will have a maximum feasible flow rate. For example, most "average" hobbyist printers with 0.4&nbsp;mm nozzles and good extruders can extrude about 4-8&nbsp;mm<sup>3</sup>/sec with PLA. PTFE-lined hot ends are at the lower end, all-metal hot ends are at the higher end. The value will depend on your hardware. But you can do a few quick benchmarking tests to find the limit, and then use that to determine peak feedrates to avoid exceeding the melt capacity of your system. </p>
<p>It looks like you have to calibrate your thermometer first. The easiest way is to use well known thermistor (preferably in well working printer) and then measure temperatures with your thermometer. This way will give you proper calibration of it. Then you can measure other thermistors with this thermometer.</p> <p>Of course it requires to keep conditions constant as far as possible. </p> <p>But to be honest... I don't really feel (or see) if there is a big difference with temperature &plusmn;&nbsp;10&nbsp;°C.</p> <p>Let's say my filament has temperatures from 185&nbsp;°C to 225&nbsp;°C and I tell you there is no difference (at least I don't see it) if it's 190&nbsp;°C or 210&nbsp;°C.</p> <p>Of course this difference is crucial when you reach min/max temperature but in the middle... </p>
252
<p>How do I go about specifying and using an ENUM in a Django model?</p>
<p>From the <a href="https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.choices" rel="noreferrer">Django documentation</a>:</p> <pre><code>MAYBECHOICE = ( ('y', 'Yes'), ('n', 'No'), ('u', 'Unknown'), ) </code></pre> <p>And you define a charfield in your model :</p> <pre><code>married = models.CharField(max_length=1, choices=MAYBECHOICE) </code></pre> <p>You can do the same with integer fields if you don't like to have letters in your db.</p> <p>In that case, rewrite your choices:</p> <pre><code>MAYBECHOICE = ( (0, 'Yes'), (1, 'No'), (2, 'Unknown'), ) </code></pre>
<p>A the top of your models.py file, add this line after you do your imports:</p> <pre><code> enum = lambda *l: [(s,_(s)) for s in l] </code></pre>
4,162
<p>I recently got an Ender 3 V2 and when I go to Info -&gt; Version it says V1.0.0. <a href="https://www.creality.com/download/" rel="nofollow noreferrer">However online, there is V1.0.1 available.</a></p> <p>How can I update the Ender 3 V2. It is different as it isn't a ATMEL chip like the ATMEGA 2560 but rather an ARM processor. I own many arduino boards but apparently the chip has the bootloader already on it.</p> <p>So how can I update the board, through some uploader, specific software or what exactly.</p>
<p>I've designed similar sensor casings, sometimes the filament catches a ridge/ledge or part of the cavity, even when it is chamfered or rounded. The arm of the limit switch pushes the filament up, away from the filament straight path.</p> <p>Have you tried cutting the filament under a very sharp angle, that may work.</p>
<p>Here is 3D model that better explains why it was catching and how to remedy the problem:</p> <p><a href="https://i.stack.imgur.com/ooe48.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ooe48.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/dTy92.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dTy92.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/m4Y91.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m4Y91.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/Pv4Op.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pv4Op.png" alt="enter image description here" /></a></p> <p>The filament is likely to have some twists and the bevel you create may not be in the correct orientation once it catches the ridge.</p> <p>The out hole is not chamfered on the inside, as it is drilled from the outside, and I guess a chamfer on the inside is not available at this price range.</p> <p>I found that twisting the filament 90° at most one way or the other always helps the filament finds its way. It can be tricky because of the small diameter/stiffness of the filament, with the spool still attached to the other end.</p>
1,705
<p>I am particularly interested in Document Libraries, but in terms of general SharePoint lists, can anyone answer the following...?</p> <ol> <li>What is the maximum number of items that a SharePoint list can contain?</li> <li>What is the maximum number of lists that a single SharePoint server can host?</li> <li>When the number of items in the list approaches the maximum, does filtering slow down, and if so, what can be done to improve it?</li> </ol>
<p>In SharePoint v.2:</p> <ul> <li><strong>Max # list items</strong> : 2000 (per folder level)</li> <li><strong>Max lists per site</strong> : 2000 is a "reasonable" number</li> <li><strong>Effect when we reach the limit</strong> : Exponential degradation of performance.</li> </ul> <p>More info: <a href="http://technet.microsoft.com/en-us/library/cc287743.aspx" rel="noreferrer">http://technet.microsoft.com/en-us/library/cc287743.aspx</a></p> <p>In SharePoint v.3:</p> <ul> <li><strong>Max # list items</strong> : 2000 (per view, you can have million items as long as you don't display in a single view more than 2000 items)</li> <li><strong>Max lists per site</strong> : 2000 is a "reasonable" number</li> <li><strong>Effect when we reach the limit</strong> : Exponential degradation of performance when we enumerate more than 2000 items using the OM. An alternative is to use Search API or CAML queries.</li> </ul> <p>More info: <a href="http://technet.microsoft.com/en-us/library/cc287790.aspx" rel="noreferrer">http://technet.microsoft.com/en-us/library/cc287790.aspx</a></p>
<p>Beware, the Performance of SiteDataQuery degrades heavily he more subsites you have. A hundred subsites can take 20 seconds to query.</p>
5,509
<p>In trying to figure out <a href="https://stackoverflow.com/questions/52981/cannot-delete-from-the-database">this problem</a> (which is still unsolved and I still have no clue what is going on), I am wondering if maybe an external reference to the table in question is causing the problem. For example, a trigger or view or some other such thing.</p> <p>Is there an easy way to find all references to a given database table? Including all views, triggers, constraints, or anything at all, preferably from the command line, and also preferably without a 3rd party tool (we are using db2).</p>
<p>Wow, I wouldn't have thought it, but there seems to be.. Good ole DB2.</p> <p>I find the publib db2 docs view very very handy by the way:</p> <p><a href="http://publib.boulder.ibm.com/infocenter/db2luw/v8//index.jsp" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/db2luw/v8//index.jsp</a></p> <p>I just found the "SYSCAT.TABDEP" catalog view in it, which seems to contain more or less what you asked for. I suspect for anything not covered there you'll have to trawl through the rest of the syscat tables which are vast. (Unfortunately I can't seem to link you to the exact page on SYSCAT.TABDEP itself, the search facility should lead you to it fairly easily though).</p> <p>Most databases these days have a set of tables which contain data about the layout of your actual schema tables, quite handy for this sort of thing.</p>
<p>You can write a query search the information schema views (definition column) to find the table in all views, triggers, procedure, etc. Not sure about FK &amp; indexes though. </p>
7,657
<p>After discussion with colleagues regarding the use of the 'var' keyword in C# 3 I wondered what people's opinions were on the appropriate uses of type inference via var?</p> <p>For example I rather lazily used var in questionable circumstances, e.g.:-</p> <pre><code>foreach(var item in someList) { // ... } // Type of 'item' not clear. var something = someObject.SomeProperty; // Type of 'something' not clear. var something = someMethod(); // Type of 'something' not clear. </code></pre> <p>More legitimate uses of var are as follows:-</p> <pre><code>var l = new List&lt;string&gt;(); // Obvious what l will be. var s = new SomeClass(); // Obvious what s will be. </code></pre> <p>Interestingly LINQ seems to be a bit of a grey area, e.g.:-</p> <pre><code>var results = from r in dataContext.SomeTable select r; // Not *entirely clear* what results will be here. </code></pre> <p>It's clear what results will be in that it will be a type which implements IEnumerable, however it isn't entirely obvious in the same way a var declaring a new object is.</p> <p>It's even worse when it comes to LINQ to objects, e.g.:-</p> <pre><code>var results = from item in someList where item != 3 select item; </code></pre> <p>This is no better than the equivilent foreach(var item in someList) { // ... } equivilent.</p> <p>There is a real concern about type safety here - for example if we were to place the results of that query into an overloaded method that accepted IEnumerable&lt;int&gt; and IEnumerable&lt;double&gt; the caller might inadvertently pass in the wrong type.</p> <p><code>var</code> <em>does</em> maintain strong typing but the question is really whether it's dangerous for the type to not be immediately apparent on definition, something which is magnified when overloads mean compiler errors might not be issued when you unintentionally pass the wrong type to a method.</p>
<p>I still think <code>var</code> can make code more readable in some cases. If I have a Customer class with an Orders property, and I want to assign that to a variable, I will just do this:</p> <pre><code>var orders = cust.Orders; </code></pre> <p>I don't care if Customer.Orders is <code>IEnumerable&lt;Order&gt;</code>, <code>ObservableCollection&lt;Order&gt;</code> or <code>BindingList&lt;Order&gt;</code> - all I want is to keep that list in memory to iterate over it or get its count or something later on.</p> <p>Contrast the above declaration with:</p> <pre><code>ObservableCollection&lt;Order&gt; orders = cust.Orders; </code></pre> <p>To me, the type name is just noise. And if I go back and decide to change the type of the Customer.Orders down the track (say from <code>ObservableCollection&lt;Order&gt;</code> to <code>IList&lt;Order&gt;</code>) then I need to change that declaration too - something I wouldn't have to do if I'd used var in the first place.</p>
<p>Don't use that, makes your code unreadable.</p> <p>ALWAYS use as strict typing as possible, crutches only makes your life hell.</p>
6,278
<p>Just got a request from my boss for an application I'm working on. Basically we're getting an email address setup for an external client to submit excel files to. </p> <p>What I need is a way to automatically pick up any email sent to this address, so I can take the attachment, process it and save it to a folder.</p> <p>Any information of even where to start would be helpful.\</p> <p>Note: We're using a lotus notes server to do this, but a generic way would be more helpful (If possible).</p>
<p>Email -> mailserver ->[something] -> file-on-disk.</p> <p>File on disk is pretty easy to parse, use <a href="http://java.sun.com/products/javamail/javadocs/javax/mail/package-summary.html" rel="noreferrer">JavaMail</a>.</p> <p>The [something] could be:</p> <ul> <li>listener for smtp connections (overkill)!</li> <li><a href="http://java.sun.com/products/javamail/javadocs/com/sun/mail/pop3/package-summary.html" rel="noreferrer">Pop3</a>/<a href="http://java.sun.com/products/javamail/javadocs/com/sun/mail/imap/package-summary.html" rel="noreferrer">imap</a> client</li> <li><a href="http://en.wikipedia.org/wiki/Maildir" rel="noreferrer">Maildir</a>/Mailbox</li> </ul>
<p>Lotus Notes/Domino stores mail in a Notes database. There are APIs available for getting documents (emails), reading field values (From, Subject), and detaching files.</p> <p>APIs include</p> <p>-LotusScript (VB variant, available within the Notes database)</p> <p>-Java (from within or external to the database)</p> <p>-C API (external)</p> <p>-Same API available through COM server</p> <p>You can create a "scheduled agent" within the database (using LotusScript or Java) that can locate documents created since it last ran, locate the attachments, and extract them. The agent will need to be signed with an ID that has the appropriate permissions on the server, including those required to write to the file system and initiate any other processes.</p> <p>External to the database, you can use any API except LotusScript to log-in to the server/mail database, and follow a similar process, e.g. extracting the files locally on a client or separate server. C API and COM require a notes client install, but Java applications can be set up to run via CORBA/DIIOP without a full install.</p> <p>Consult the Domino Designer help (or IBM's website for C API) for more information.</p> <p>As to a "generic way" to do this, if you are accessing data in Notes and needing to extract attachments, I believe these APIs are your best option. If you envision porting the application to another mail system, consider decoupling the API routines via an "interface" so you only need to add a new implementation of that interface to support a new mail system.</p>
8,078
<p><strong>Facts:</strong></p> <ol> <li>Breaking down (or melting) plastic creates nanoparticles.<sup>1</sup></li> <li>3D printers melt plastic.<sup>2</sup></li> <li>Therefore, 3D printers make nanoparticles.<sup>3</sup></li> <li>Nanoparticles are evil.<sup><em>[citation needed]</em></sup></li> </ol> <p>Wait, What?</p> <hr> <p><sub>1. <a href="https://phys.org/news/2018-12-plastic-disintegrates-nanoparticles.html" rel="nofollow noreferrer">Plastic waste disintegrates into nanoparticles</a></sub><br> <sub>2. <a href="https://www.explainthatstuff.com/how-3d-printers-work.html" rel="nofollow noreferrer">How do 3D printers work?</a></sub><br> <sub>3. <a href="https://www.tandfonline.com/doi/full/10.1080/02786826.2017.1342029" rel="nofollow noreferrer">Characterization of particle emissions from consumer fused deposition modeling 3D printers</a></sub></p> <hr> <p><em>I know</em> that 3D printers make nanoparticles. But is that actually a safety concern? There are multiple <a href="https://www.zimple3d.com/zimpure/" rel="nofollow noreferrer">products</a> on the market today that will suck up your nanoparticles for you. However, I can't see an obvious danger in the particles themselves. Who decided that these nanoparticles are bad for your health? 3D printers put out plenty of heat too, but nobody thinks that's dangerous.</p> <p>So my question: <strong>Does anyone know of sources/research articles of the possible harmful effects of nanoparticles created by 3D printing?</strong> I'm looking for real scientific research. Thanks.</p>
<p>At the time of this writing (March 2019), I don't think theres any study on the health effects of nanoparticles emmitted by 3D Printers. The general consensus seems to be right now that those particles are potentially harmful, as they build up in the lungs, and therefore precautions should be taken.</p> <p>The reason why nobody has yet determined if and how harmful they are, might be that those adverse health effects are probably long term, and hard to isolate. Plastic is everywhere today - it's not that easy to just study harmful health effects caused by 3D printers.</p> <p>But we can say for sure that plastic in our bodies isn't ideal and can cause damage, so we should avoid it.</p>
<p>Perhaps FDM 3D printing does emit nanoparticles during the process of printing, but the syllogism does not prove it or even suggest it. </p> <p>Parenthetically, your headline is not actually addressed by the body of your question. As an answerer, I have been misled by other questions which seemed clear enough from the headline, but where the question body actually posed a completely different question. </p> <p>Double parenthetically, your final question does align with your headline. The discussion of 3D printing and the assertion that it is dangerous is not actually relevant to the question at all. It might be better to remove the references to 3D printing and post this in another SE group focused on human health.</p> <p>The first point, that breaking down or <em>melting</em> plastic produces nano-particles is not supported by your reference. The reference refers to the mechanical breakdown of particles in a simulated oceanic environment and does not mention melting. The reference is silent on the possibility of melting producing and emitting nanoparticles.</p> <p>In an FDM 3D printer, the melting takes place in an enclosed capsule, the hot-end. The plastic is heated to the point where the viscosity is low enough that the pressure of the unsoftened plastic filament pushes the softened material out of the hot-end through the nozzle. Upon exiting the nozzle the temperature falls, and the plastic begins to recrystallize.</p> <p>I have seen no evidence of outgassing during printing with dry filament, other than an odor. Usually melting joins separated objects, pellets, and larger particles in a unified liquid state. </p> <p>Without specific testing, one can not say there is no risk of nanoparticles emitted by FDM 3D printing. Ventilation remains a useful method of reducing local exposure to nanoparticles and odors. Airborne risks are one of the many risks to be considered, but I have no evidence that they are more serious than the burn risk, the fire risk, or the risk of a stroke from high blood pressure induced by failed prints.</p>
1,256
<p>I have a generic printer with no support documentation. </p> <p>How do I determine what firmware is in use so that I can research how to make the print run?</p>
<p>Send <code>M115</code> to the printer. This command is </p> <blockquote> <p>Request the Firmware Version and Capabilities of the current microcontroller.</p> </blockquote> <p>Response example:</p> <blockquote> <p>ok PROTOCOL_VERSION:0.1 FIRMWARE_NAME:FiveD FIRMWARE_URL:http%3A//reprap.org MACHINE_TYPE:Mendel EXTRUDER_COUNT:1</p> </blockquote> <p>For more info see here, <a href="https://reprap.org/wiki/G-code#M115:_Get_Firmware_Version_and_Capabilities" rel="noreferrer">RepRapWiki- G-code - M115: Get Firmware Version and Capabilities</a>.</p> <hr> <p><em>Of course, this isn't guaranteed to tell the truth, just whatever your generic clone firmware had in its source code.</em></p>
<h1>Startup</h1> <p>Usually, when a printer starts up, the screen shows a boot-screen. This contains usually the firmware version, but not who or what the settings are.</p> <h1>LCD: About Printer</h1> <p>Some printers have an LCD main menu item that is &quot;About Printer&quot; or similar. It would one of the last items if enabled.</p> <p>In Marlin it is disabled by default, and you'd need to uncomment <code>#define LCD_INFO_MENU</code> in <code>Configuration_adv.h</code>.</p> <h1>Terminal</h1> <p>Connect a <a href="https://3dprinting.stackexchange.com/questions/10573/what-is-a-printer-console-terminal">terminal</a> and send <a href="https://reprap.org/wiki/G-code#M115:_Get_Firmware_Version_and_Capabilities" rel="nofollow noreferrer"><code>M115</code></a>. In most cases, this will tell you the current Firmware and version, as it is annotated in the firmware. This doesn't mean that those lines always were updated by who changed the files, but it is a good indication what was the basis for the installed firmware.</p>
679
<p>I love the idea of the XYZ test cube to help diagnose my bad prints. I’m able to find online very common print issues however am looking for a resource that is more extensive. Often I run into a situation where my issue is not covered.</p> <p>Would be great if there was a resource that had pictures of numerous bad or less than ideal XYZ prints with cause and fix for each. I’m thinking of more than 50 examples.</p> <p>Does anyone know of such a resource?</p> <p><a href="https://i.stack.imgur.com/aogym.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aogym.jpg" alt="My current unknown bad XYZ print " /></a></p>
<h2>Make sure to set the scale properly for your use case!</h2> <p>In CAD, you define your measurement space in either Inch or in Millimeter units, and that is your grid. In blender, the native unit is the meter.</p> <p>This can be easily converted in exporting (remember to set it to scale!), but it is best to just set the measurement scale to actually match what you design: if you want to design a 5 mm hole, set your scale to Millimeters and make sure you export in millimeters. If you want to design in meters (maybe you design a building), then work in meters, and set your export scale in the end so that 1 meter actually is represented as 1 meter - or rather as 1000 millimeters.</p> <p><a href="https://3dprinting.stackexchange.com/a/7561/8884">The STL in the end will not know the difference</a>: it all is defined in scales of <em>unitary units</em>, and it doesn't even know if it was originally designed in meters, inch or angström. The typical slicer expects the unit to be either millimeters or inch, so any scaling of the exported model that does not result in units equivalent to 1 mm or 24.5 mm is bad procedure - converting between these two types is just scaling the model by 2450%.</p> <h2>Make sure to design closed manifolds made up of triangles!</h2> <p>When working with blender, it is very easy to leave the item in a shape that contains multiple intersecting, non-manifold surfaces and areas of inverted surfaces. While <em>interecting shells</em> is not a problem (the slicers can handle those by unionizing the item), the intersection usually covers up the non-manifold areas, making them hard to spot.</p> <p>As a result, before finalizing your project, I suggest follow this procedure:</p> <ul> <li>In Blender, turn on the visual for the normals of surfaces. If an area does not look like a hedgehog after that, the normals in that area are reversed and you need to flip the surfaces there or re-mesh it.</li> <li>Triangulate the surface using the triangulate modifier. This is to spot artifacts from conversion to STL early and be able to fix them: STL only knows triangles, while blender knows <em>bent</em> n-gons.</li> <li>Add a new object. A cube with side length 1.</li> <li>Do a test export to STL with scale 1, which also contains the 1-unit cube as an extra shell.</li> <li>Import the model into a software such as meshmixer, that has a command to separate shells.</li> <li>Separate the item to all shells. In Meshmixer this is in analyze, separate shells.</li> <li>After separating the shells, measure your 1-unit cube. If it is not 1 mm, calculate your scaling factor. It should be a multiple of 10.</li> <li>Next, you should check each shell for gaps or other errors. In meshmixer, the automatic analyze feature points to these areas with red, blue and magenta lines.</li> <li>Fix the marked errors in blender, then return to the test export. This time use the proper scaling factor. Repeat until no errors remain.</li> </ul>
<p>It doesn't matter, you scale it in the slicer or elsewhere. You're not going to slice the STL file in Blender. You'll probably need to do more work to get things print ready outside blender anyway.</p> <p>So when I use blender I don't even bother checking what units it's using. I don't use it for parts design or tech drawing.</p>
2,122
<p>Recently, my Ender 3D Pro has been unable to print any large models successfully with PLA as the filament starts to expand inside the Teflon tube, causing a clog after about an hour of printing. I am starting to suspect that the problem is heat creep.</p> <ul> <li>This occurs with the two brands of PLA filament that I use (3D Fila and Voolt 3D).</li> <li>The hotend that I am using is the one that comes with the printer, I don't know what it is made out of.</li> </ul> <p>I have tried many things to patch this problem:</p> <ul> <li>Try to unclog it with the needle</li> <li>Replace nozzle (three times)</li> <li>Check if the Teflon tube is touching the nozzle</li> <li>Increase temperature from 200 to 220 °C</li> <li>Increase temperature from 200 to 215 °C</li> </ul> <p>If the problem is indeed heat creep, I have plans to control the heat sink temperature with a Peltier and an extra thermometer. Any other ideas are appreciated.</p>
<p>Since you mentioned &quot;Check if the Teflon tube is touching the nozzle&quot;, it sounds like you've disassembled the tube from the couplings and put it back together. This is error-prone and in my experience the main/only likely cause of clogging in Creality hotends. Heat creep is unlikely unless you're operating in a very high ambient temperature or have a failing/failed fan.</p> <p>The tube can't just be &quot;touching&quot; the nozzle. It needs to be compressed against it. There are various ways to do this, but what usually worked best for me (before I moved to a different setup) was to back the coupler out of the heat sink by at least 1-2 full turns, press the tube all the way in against the nozzle, then tighten the coupler back down to compress the end of the tube against the nozzle mating surface.</p> <p>The end of the tube also needs to be clean cut, straight, and undamaged. If it's charred, bent, gnarled, whatever, cut it straight with a razor blade while holding it in a jig to make sure the cut is perpendicular. You can find several such jigs (PTFE tube cutting tools) on Thingiverse or make your own or buy one. I like to also take the razor blade and chamfer the outside of the tube end ever so slightly before inserting it. I do this by hand, but I've seen videos of it being done with a jig that looks something like a pencil sharpener, which would probably be the best way.</p>
<p>This sounds like heat creep may be the problem. For preventing heat creep to occur you should do the opposite, print at lower temperature, tweak retraction length and increase cooling of the cold end.</p> <p>A Peltier element is not very effective cooler, use a bigger fan, or a fan with a higher flow rate. Note that the Peltier element required a large cooling body and a fan as well, so this adds a lot of weight to and limits space of the hotend. You should not go there, it has been tried before.</p>
2,075
<p>Where is the best tutorial for getting Ruby On Rails working on a windows box with Mongrel? I'm a complete novice at server management, so the more detailed the better!</p>
<p>You can follow this tutorial, it will get you setup you can actually manage your Mongrel server as a Windows service (start/stop/restart, start on boot, manage programatically etc etc):</p> <p><a href="http://noobonrails.blogspot.com/2006/06/how-to-setup-mongrel-as-native-windows.html" rel="nofollow noreferrer">How to setup mongrel as a native Windows service</a></p> <p>I'm currently using this method to manage an instance of Redmine on a Windows box and it works wonderfully.</p> <p>Good luck!</p>
<p><a href="http://bitnami.org/stack/rubystack" rel="nofollow">Rubystack</a> is a free Windows Rails installer that we keep up to date and includes Mongrel support out of the box </p>
5,613
<p>Does anyone know if the Infragistics UltraGrid control provides functionality similar to that of DataGridView.HitTestInfo?</p>
<p>Check <a href="http://www.abstraction-systems.com/ttf/HTML/TTFactory_TaskBasedTutorials_UltraWinGrid.htm" rel="nofollow noreferrer">this</a> out.</p> <p>They don't convert the coordinates, but they use a special Infragistics grid event (<a href="http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.v8.2~Infragistics.Win.UltraComponentControlManagerBase~MouseEnterElement_EV.html" rel="nofollow noreferrer">MouseEnterElement</a>) to get the element, which the mouse currently hovers over.</p> <p>Maybe it helps.</p>
<p>There's a <code>.MousePosition</code> property which returns <code>System.Drawing.Point</code> and "Gets the position of the mouse cursor in screen coordinates" but I'm using an older version of their UltraWinGrid (2003).</p> <p>They have a <a href="http://www.infragistics.com/downloads/default.aspx" rel="nofollow noreferrer">free trial download</a>, so you could see if they've added it to their latest and greatest :o)</p>
9,739
<p>I am a bit rusty on my cursor lingo in PL/SQL. Anyone know this?</p>
<p>An implicit cursor is one created "automatically" for you by Oracle when you execute a query. It is simpler to code, but suffers from </p> <ul> <li>inefficiency (the ANSI standard specifies that it must fetch twice to check if there is more than one record)</li> <li>vulnerability to data errors (if you ever get two rows, it raises a TOO_MANY_ROWS exception)</li> </ul> <p>Example</p> <pre><code>SELECT col INTO var FROM table WHERE something; </code></pre> <p>An explicit cursor is one you create yourself. It takes more code, but gives more control - for example, you can just open-fetch-close if you only want the first record and don't care if there are others. </p> <p>Example</p> <pre><code>DECLARE CURSOR cur IS SELECT col FROM table WHERE something; BEGIN OPEN cur; FETCH cur INTO var; CLOSE cur; END; </code></pre>
<p>Explicit...</p> <p>cursor foo is select * from blah; begin open fetch exit when close cursor yada yada yada</p> <p>don't use them, use implicit</p> <p>cursor foo is select * from blah;</p> <p>for n in foo loop x = n.some_column end loop</p> <p>I think you can even do this</p> <p>for n in (select * from blah) loop...</p> <p>Stick to implicit, they close themselves, they are more readable, they make life easy.</p>
9,973
<p>How do you sort an array of strings <a href="http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/" rel="nofollow noreferrer">naturally</a> in different programming languages? Post your implementation and what language it is in in the answer.</p>
<p><strong>JavaScript</strong></p> <pre><code>Array.prototype.alphanumSort = function(caseInsensitive) { for (var z = 0, t; t = this[z]; z++) { this[z] = [], x = 0, y = -1, n = 0, i, j; while (i = (j = t.charAt(x++)).charCodeAt(0)) { var m = (i == 46 || (i &gt;=48 &amp;&amp; i &lt;= 57)); if (m !== n) { this[z][++y] = ""; n = m; } this[z][y] += j; } } this.sort(function(a, b) { for (var x = 0, aa, bb; (aa = a[x]) &amp;&amp; (bb = b[x]); x++) { if (caseInsensitive) { aa = aa.toLowerCase(); bb = bb.toLowerCase(); } if (aa !== bb) { var c = Number(aa), d = Number(bb); if (c == aa &amp;&amp; d == bb) { return c - d; } else return (aa &gt; bb) ? 1 : -1; } } return a.length - b.length; }); for (var z = 0; z &lt; this.length; z++) this[z] = this[z].join(""); } </code></pre> <p><a href="http://my.opera.com/GreyWyvern/blog/show.dml/1671288" rel="noreferrer">Source</a></p>
<p>For Tcl, the -dict (dictionary) option to lsort:</p> <pre><code>% lsort -dict {a b 1 c 2 d 13} 1 2 13 a b c d </code></pre>
5,481
<p>I'm trying to place this menu on the left hand side of the page:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="left-menu" style="left: 123px; top: 355px"&gt; &lt;ul&gt; &lt;li&gt; Categories &lt;/li&gt; &lt;li&gt; Weapons &lt;/li&gt; &lt;li&gt; Armor &lt;/li&gt; &lt;li&gt; Manuals &lt;/li&gt; &lt;li&gt; Sustenance &lt;/li&gt; &lt;li&gt; Test &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>The problem is that if I use absolute or fixed values, different screen sizes will render the navigation bar differently. I also have a second <code>div</code> that contains all the main content which also needs to be moved to the right, so far I'm using relative values which seems to work no matter the screen size.</p>
<p><code>float</code> is indeed the right property to achieve this. However, the example given by bmatthews68 can be improved. The most important thing about floating boxes is that they <em>must</em> specify an explicit width. This can be rather inconvenient but this is the way CSS works. However, notice that <code>px</code> is a unit of measure that has no place in the world of HTML/CSS, at least not to specify widths.</p> <p>Always resort to measures that will work with different font sizes, i.e. either use <code>em</code> or <code>%</code>. Now, if the menu is implemented as a floating body, then this means that the main content floats “around” it. If the main content is higher than the menu, this might not be what you want:</p> <p><a href="http://page.mi.fu-berlin.de/krudolph/stuff/float1.png">float1 http://page.mi.fu-berlin.de/krudolph/stuff/float1.png</a></p> <pre><code>&lt;div style="width: 10em; float: left;"&gt;Left&lt;/div&gt; &lt;div&gt;Right, spanning&lt;br/&gt; multiple lines&lt;/div&gt; </code></pre> <p>You can correct this behaviour by giving the main content a <code>margin-left</code> equal to the width of the menu:</p> <p><a href="http://page.mi.fu-berlin.de/krudolph/stuff/float2.png">float2 http://page.mi.fu-berlin.de/krudolph/stuff/float2.png</a></p> <pre><code>&lt;div style="width: 10em; float: left;"&gt;Left&lt;/div&gt; &lt;div style="margin-left: 10em;"&gt;Right, spanning&lt;br/&gt; multiple lines&lt;/div&gt; </code></pre> <p>In most cases you also want to give the main content a <code>padding-left</code> so it doesn't “stick” to the menu too closely.</p> <p>By the way, it's trivial to change the above so that the menu is on the right side instead of the left: simply change every occurrence of the word “left” to “right”.</p> <p>Ah, one last thing. If the menu's content is higher than the main content, it will render oddly because <code>float</code> does some odd things. In that case, you will have to clear the box that comes below the floating body, as in bmatthews68's example.</p> <p>/EDIT: Damn, HTML doesn't work the way the preview showed it. Well, I've included pictures instead.</p>
<p>You should use the float and clear CSS attributes to get the desired effect. </p> <p>First I defined styles for the called left and right for the two columns in my layout and a style called clearer used to reset the page flow.</p> <pre> &lt;style type="text/css"&gt; .left { float: left; width: 200px; } .right { float: right; width: 800px; } .clear { clear: both; height: 1px; } &lt;/style&gt; </pre> <p>Then I use them to layout my page.</p> <pre> &lt;div&gt; &lt;div class="left"&gt; &lt;ul&gt; &lt;li&gt;Categories&lt;/li&gt; &lt;li&gt;Weapons&lt;/li&gt; &lt;li&gt;Armor&lt;/li&gt; &lt;li&gt;Manuals&lt;/li&gt; &lt;li&gt;Sustenance&lt;/li&gt; &lt;li&gt;Test&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="right"&gt; Blah Blah Blah.... &lt;/div&gt; &lt;/div&gt; &lt;div class="clear" /&gt; </pre>
8,628
<p>I want to write a command that specifies "the word under the cursor" in VIM. For instance, let's say I have the cursor on a word and I make it appear twice. For instance, if the word is "abc" and I want "abcabc" then I could type: </p> <pre><code>:s/\(abc\)/\1\1/ </code></pre> <p>But then I'd like to be able to move the cursor to "def" and use the same command to change it to "defdef": </p> <pre><code>:s/\(def\)/\1\1/ </code></pre> <p>How can I write the command in the commandline so that it does this?</p> <pre><code>:s/\(*whatever is under the commandline*\)/\1\1 </code></pre>
<p><code>&lt;cword&gt;</code> is the word under the cursor (:help <code>&lt;cword&gt;</code>).</p> <p>Sorry, I should have been more complete in this answer.</p> <p>You can nmap a command to it, or this series of keystrokes for the lazy will work:</p> <pre><code>b #go to beginning of current word yw #yank to register </code></pre> <p>Then, when you are typing in your pattern you can hit <code>&lt;control-r&gt;0&lt;enter&gt;</code> which will paste in your command the contents of the 0-th register.</p> <p>You can also make a command for this like:</p> <pre><code>:nmap &lt;leader&gt;w :s/\(&lt;c-r&gt;=expand("&lt;cword&gt;")&lt;cr&gt;\)/ </code></pre> <p>Which will map hitting '\' and 'w' at the same time to replace your command line with</p> <pre><code>:s/\(&lt;currentword&gt;\)/ </code></pre>
<pre><code>" count word (case sensitive) nmap &lt;F4&gt; :%s/\(&lt;c-r&gt;=expand("&lt;cword&gt;")&lt;cr&gt;\)//gn&lt;cr&gt; </code></pre>
7,111
<p>I've already asked which wires I should use, and I believe I have that covered now, but I was also wondering what solder / specs on the solder are considered safe when attaching my wires to my heat bed. I have some solder here at the house, it's quite new (never been opened) it's Radio Shack <code>64-008 E</code> 60/40 Standard Rosin-Core with 0.062 diameter...</p>
<p>Old-style lead/tin solder has a melting range of about 180 to 250 degrees (the transition solid to liquid is spread out). This ought to be fine for the bed (even at the hottest hotspot) but wouldn't be good <em>in</em> the hotend.</p> <p>Modern electronics lead-free solder varies since there are several different compositions, but is typically a bit higher in melting point (by some 10s of degrees).</p> <p>Special high melting point solder transitions around 300C, but you would only need to use this in very specific scenarios.</p>
<p>That solder sounds like it should be fine.</p> <p>Any solder should work, the only difference you might find is some of the older solder will include lead. if you were overly concerned about safety you might want to check your solder doesn't contain lead. However, for the amount you are doing, even a solder that contains lead isn't going to be an issue.</p>
432
<p>I have PLA and PETG filament.</p> <p>I hear that 3D filament absorbs water and causes problems when printing but after printing they can be used with water and they are water proof.</p> <p>So my question is why is it different after printing/what has changed to make it now waterproof?</p> <ul> <li><p>Is PETG waterproof or does it absorb water?</p> </li> <li><p>Is there a limit on how much water PETG can absorb or will it keep going until it splits and turns to mush?</p> </li> </ul>
<p>Filament that absorbs water prior to printing is subject to boiling temperatures as it passes through the heater block. In extreme cases, steam will be visible and a spitting sound will be heard. The filament will expand as the water exits, causing multiple structural and printing problems.</p> <p>Once printed, dry filament may absorb water from the atmosphere, but is unlikely to be subject to boiling temperatures.</p> <p>Waterproofing as a general consideration usually means the ability to keep water out, which is possible if the model is sealed and some printing conditions will adhere each layer well enough to the previous one to provide floating-type waterproofing.</p> <p>PETG is hydroscopic, which means it will absorb moisture from the air. When printed properly (layer adhesion), the model can be waterproof.</p> <p>These terms are independent and should not be used interchangeably.</p>
<p>Filament that absorbs water prior to printing is subject to boiling temperatures as it passes through the heater block. In extreme cases, steam will be visible and a spitting sound will be heard. The filament will expand as the water exits, causing multiple structural and printing problems.</p> <p>Once printed, dry filament may absorb water from the atmosphere, but is unlikely to be subject to boiling temperatures.</p> <p>Waterproofing as a general consideration usually means the ability to keep water out, which is possible if the model is sealed and some printing conditions will adhere each layer well enough to the previous one to provide floating-type waterproofing.</p> <p>PETG is hydroscopic, which means it will absorb moisture from the air. When printed properly (layer adhesion), the model can be waterproof.</p> <p>These terms are independent and should not be used interchangeably.</p>
1,861
<p>I have a problem with an application running on Fedora Core 6 with JDK 1.5.0_08.</p> <p>After some amount of uptime (usually some days) threads begin getting stuck in native methods.</p> <p>The threads are locked in something like this:</p> <pre><code>&quot;pool-2-thread-2571&quot; prio=1 tid=0x08dd0b28 nid=0x319e waiting for monitor entry [0xb91fe000..0xb91ff7d4] at java.lang.Class.getDeclaredConstructors0(Native Method) </code></pre> <p>or</p> <pre><code>&quot;pool-2-thread-2547&quot; prio=1 tid=0x75641620 nid=0x1745 waiting for monitor entry [0xbc7fe000..0xbc7ff554] at sun.misc.Unsafe.defineClass(Native Method) </code></pre> <p>Especially puzzling to me is this one:</p> <pre><code>&quot;HealthMonitor-10&quot; daemon prio=1 tid=0x0868d1c0 nid=0x2b72 waiting for monitor entry [0xbe5ff000..0xbe5ff4d4] at java.lang.Thread.dumpThreads(Native Method) at java.lang.Thread.getStackTrace(Thread.java:1383) </code></pre> <p>The threads remain stuck until the VM is restarted.</p> <p>Can anyone give me an idea as to what is happening here, what might be causing the native methods to block? The monitor entry address range at the top of each stuck thread is different. How can I figure out what is holding this monitor?</p>
<p>My initial suspicion would be that you are experiencing some sort of class-loader realted dead lock. I imagine, that class loading needs to be synchronized at some level because class information will become available for the entire VM, not just the thread where it was initially loaded.</p> <p>The fact that the methods on top of the stack are native methods seems to be pure coincidence, since part of the class loading mechanism happens to implemented that way.</p> <p>I would investigate further what is going on class-loading wise. Maybe some thread uses the class loader to load a class from a network location which is slow/unavailable and thus blocks for a really long time, not yielding the monitor to other threads that want to load a class. Investigating the output when starting the JVM with -verbose:class might be one thing to try.</p>
<p>Maybe you should use another jdk version.<br> For your "puzzling one", there is a bug entry for 1.5.0_08. A memory leak is reported (I do not know, if this is related to your problem):<br> <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6469701" rel="nofollow noreferrer">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6469701</a> </p> <p>Also you could get the source code and look, what happens at line 1383. On the other side, it could just be the stack dump, after the original error occurred.</p>
5,829
<p>From time to time am I working in a completely disconnected environment with a Macbook Pro. For testing purposes I need to run a local DNS server in a VMWare session. I've configured the lookup system to use the DNS server (/etc/resolve.conf and through the network configuration panel, which is using configd underneath), and commands like "dig" and "nslookup" work. For example, my DNS server is configured to resolve www.example.com to 127.0.0.1, this is the output of "dig www.example.com":</p> <pre><code>; &lt;&lt;&gt;&gt; DiG 9.3.5-P1 &lt;&lt;&gt;&gt; www.example.com ;; global options: printcmd ;; Got answer: ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 64859 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.example.com. IN A ;; ANSWER SECTION: www.example.com. 86400 IN A 127.0.0.1 ;; Query time: 2 msec ;; SERVER: 172.16.35.131#53(172.16.35.131) ;; WHEN: Mon Sep 15 21:13:15 2008 ;; MSG SIZE rcvd: 49 </code></pre> <p>Unfortunately, if I try to ping or setup a connection in a browser, the DNS name is not resolved. This is the output of "ping www.example.com":</p> <pre><code>ping: cannot resolve www.example.com: Unknown host </code></pre> <p>It seems that those tools, that are more integrated within Mac OS X 10.4 (and up), are not using the "/etc/resolv.conf" system anymore. Configuring them through scutil is no help, because it seems that if the wireless or the buildin ethernet interface is <strong>inactive</strong>, basic network functions don't seem to work.</p> <p>In Linux (for example Ubuntu), it is possible to turn off the wireless adapter, without turning of the network capabilities. So in Linux it seems that I can work completely disconnected.</p> <p>A solution could be using an ethernet loopback connector, but I would rather like a software solution, as both Windows and Linux don't have this problem.</p>
<p>On OS X starting in 10.4, <code>/etc/resolv.conf</code> is no longer the canonical location for DNS IP addresses. Some Unix tools such as <code>dig</code> and <code>nslookup</code> will use it directly, but anything that uses Unix or Mac APIs to do DNS lookups will not. Instead, configd maintains a database which provides many more options, like using different nameservers for different domains. (A subset of this information is mirrored to <code>/etc/resolv.conf</code> for compatibility.)</p> <p>You can edit the nameserver info from code with <code>SCDynamicStore</code>, or use <code>scutil</code> interactively or from a script. I posted some links to sample scripts for both methods <a href="http://njr.sabi.net/2005/11/07/alternate-openvpn-os-x-dns-updating-script/" rel="nofollow noreferrer">here</a>. <a href="http://lists.apple.com/archives/Macnetworkprog/2005/Jun/msg00011.html" rel="nofollow noreferrer">This thread</a> from when I was trying to figure this stuff out may also be of some use. </p>
<p>I run into this from time to time on different notebooks, and I have found the simplest is a low-tech, non software solution - create an ethernet loopback connecter. You can do it in 2 minutes with an old network cable, just cut the end off and join the send and receive pair just above the RJ45 connector. (obviously your interface needs a static IP)</p> <p>Old school, but completely software independent and good for working in a dev environment on long flights... :)</p> <p>there is a simple diagram <a href="http://www.juniper.net/techpubs/software/nog/nog-interfaces/html/fe-ge-loopback25.html" rel="nofollow noreferrer">here</a></p>
9,155
<p>The first layer is very patchy indeed. I've calibrated the build plate pretty accurately but even if it was a badly calibrated build plate I don't think it would have this effect.</p> <p><a href="https://imgur.com/S4KsNA3.png" rel="nofollow noreferrer"><img src="https://imgur.com/S4KsNA3.png" alt="Patchy First Layer."></a></p> <p>It doesn't <em>seem</em> to have a negative effect on the print.</p> <ol> <li>Should I be concerned about this? </li> <li>Is this due to a the build plate fault?</li> </ol>
<p>First things first:</p> <h1>Don't Panic</h1> <p>Your heated bed is made from metal with some sort of Build-Tak-Clone surface. It is not broken from what I can see. Your print is <strong>not failed</strong>, however, the quality does suffer a little bit.</p> <p>Your bed does warp a little under heating. That is perfectly <strong>normal</strong>, and you should actually calibrate your layer thickness against a hot heatbed, not a cold one as metal that is heatbed extends - especially over the heating elements. The main heating element is usually in the center, so it &quot;bulges&quot; a little there, and if the heat has not equalized everywhere, it can show a dimple around it. So it warps slightly. The extent of the warping is determined by a couple factors, but from what your print looks like, it is not in a worrisome amount - the second and third layers will even it out.</p> <p>I can't tell how much time passed between reaching the print temperature of the bed and the start of the print, but you might want to make sure the heating behavior heats the bed <em>first</em> and the hotend <em>second</em>, allowing the heat energy in the bed to spread more evenly. A tiny <code>G4 P20000 ; wait 20 seconds</code> <a href="https://3dprinting.stackexchange.com/a/526/8884">(see here)</a>` in the pre-print code, before <a href="https://3dprinting.stackexchange.com/q/6355/8884">cleaning &amp; priming</a> the nozzle might also help.</p> <p>You can try to get more even first layers by positioning the parts in areas that do not suffer from warping.</p> <p>As <a href="https://3dprinting.stackexchange.com/a/7744/8884">Tom</a> mentioned, you might get better base layers if you increase the first layer thickness. I usually print with about 0.15 to 0.2 mm for the first layer, <em>regardless</em> of the following layer thickness to even out small miscalibrations and unevenness in the heating.</p>
<h2>I'm having the same problem but worse.</h2> <p>Some parts of the print are squished and towards the middle I will have bad or no bed adhesion. I always have to print with a raft or else the first layer will fail.</p> <h3>Borosilicate glass</h3> <p>From what I've read online the best solution it to replace the build plate or add a pad on top of your build surface. The most recommended one is borosilicate glass. It has good heat conductivity and is very stiff.</p>
1,140
<p>What would be the most efficient way to compare two <code>double</code> or two <code>float</code> values?</p> <p>Simply doing this is not correct:</p> <pre><code>bool CompareDoubles1 (double A, double B) { return A == B; } </code></pre> <p>But something like:</p> <pre><code>bool CompareDoubles2 (double A, double B) { diff = A - B; return (diff &lt; EPSILON) &amp;&amp; (-diff &lt; EPSILON); } </code></pre> <p>Seems to waste processing.</p> <p>Does anyone know a smarter float comparer?</p>
<p>Be extremely careful using any of the other suggestions. It all depends on context.</p> <p>I have spent a long time tracing bugs in a system that presumed <code>a==b</code> if <code>|a-b|&lt;epsilon</code>. The underlying problems were:</p> <ol> <li><p>The implicit presumption in an algorithm that if <code>a==b</code> and <code>b==c</code> then <code>a==c</code>.</p> </li> <li><p>Using the same epsilon for lines measured in inches and lines measured in mils (.001 inch). That is <code>a==b</code> but <code>1000a!=1000b</code>. (This is why <code>AlmostEqual2sComplement</code> asks for the epsilon or max ULPS).</p> </li> <li><p>The use of the same epsilon for both the cosine of angles and the length of lines!</p> </li> <li><p>Using such a compare function to sort items in a collection. (In this case using the builtin C++ operator <code>==</code> for doubles produced correct results.)</p> </li> </ol> <p>Like I said: it all depends on context and the expected size of <code>a</code> and <code>b</code>.</p> <p>By the way, <code>std::numeric_limits&lt;double&gt;::epsilon()</code> is the &quot;machine epsilon&quot;. It is the difference between <code>1.0</code> and the next value representable by a double. I guess that it could be used in the compare function but only if the expected values are less than 1. (This is in response to @cdv's answer...)</p> <p>Also, if you basically have <code>int</code> arithmetic in <code>doubles</code> (here we use doubles to hold int values in certain cases) your arithmetic will be correct. For example <code>4.0/2.0</code> will be the same as <code>1.0+1.0</code>. This is as long as you do not do things that result in fractions (<code>4.0/3.0</code>) or do not go outside of the size of an int.</p>
<p>It depends on how precise you want the comparison to be. If you want to compare for exactly the same number, then just go with ==. (You almost never want to do this unless you actually want exactly the same number.) On any decent platform you can also do the following:</p> <pre><code>diff= a - b; return fabs(diff)&lt;EPSILON; </code></pre> <p>as <code>fabs</code> tends to be pretty fast. By pretty fast I mean it is basically a bitwise AND, so it better be fast.</p> <p>And integer tricks for comparing doubles and floats are nice but tend to make it more difficult for the various CPU pipelines to handle effectively. And it's definitely not faster on certain in-order architectures these days due to using the stack as a temporary storage area for values that are being used frequently. (Load-hit-store for those who care.)</p>
3,800
<p>I'm printing PLA with the Creality Ender 2 and my print comes out totally fine with the exception of the first layer.</p> <p>Here's the weird part though, if I place a raft or a brim below/around the print - the raft or brim will print perfectly cleanly. Even on a raft though, the very first layer of the actual print comes out ugly, as seen in the photo below, but the raft itself will be perfectly printed.</p> <p>Following that first ugly layer of the actual print, the rest of the print will be 100% clean. This happens consistently every time I print any object.</p> <p>The perfectly printed raft can be seen on the right and the ugly first layer that printed on top of that raft can be seen on the left. Be sure to click the image to see the details of what I mean.</p> <p><a href="https://i.stack.imgur.com/z1Kem.jpg" rel="nofollow noreferrer" title="Ugly first layer and raft"><img src="https://i.stack.imgur.com/z1Kem.jpg" alt="Ugly first layer and raft" title="Ugly first layer and raft"></a></p>
<p>Turns out it had to do with the nature of the small holes that I was printing. I had to slow the speed of the initial layer down from 25mm/s to 15mm/s and also set Cura to 'optimize wall printing order' so that it didn't jump back and forth between holes constantly. </p> <p>I also sped up the travel speed to 50mm/s on the initial layer to minimize oozing (although I'm not sure this actually did anything). Print came out beautifully.</p> <p>Didn't even need the raft.</p>
<p>Sounds like you need to get the printing nozzle closer to the bed. In the case of the raft you can adjust the 'air gap' which is how much it raises off the top of the raft before starting the print.</p>
985
<p>How do I format a number in Java?<br /> What are the &quot;Best Practices&quot;?</p> <p>Will I need to round a number before I format it?</p> <blockquote> <p><code>32.302342342342343</code> =&gt; <code>32.30</code></p> <p><code>.7323</code> =&gt; <code>0.73</code></p> </blockquote> <p>etc.</p>
<p>From <a href="http://bytes.com/forum/thread16212.html" rel="noreferrer">this thread</a>, there are different ways to do this:</p> <pre><code>double r = 5.1234; System.out.println(r); // r is 5.1234 int decimalPlaces = 2; BigDecimal bd = new BigDecimal(r); // setScale is immutable bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); r = bd.doubleValue(); System.out.println(r); // r is 5.12 </code></pre> <hr> <pre><code>f = (float) (Math.round(n*100.0f)/100.0f); </code></pre> <hr> <pre><code>DecimalFormat df2 = new DecimalFormat( "#,###,###,##0.00" ); double dd = 100.2397; double dd2dec = new Double(df2.format(dd)).doubleValue(); // The value of dd2dec will be 100.24 </code></pre> <p>The <a href="http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html" rel="noreferrer">DecimalFormat()</a> seems to be the most dynamic way to do it, and it is also very easy to understand when reading others code.</p>
<p>There are two approaches in the standard library. One is to use java.text.DecimalFormat. The other more cryptic methods (String.format, PrintStream.printf, etc) based around java.util.Formatter should keep C programmers happy(ish).</p>
7,332
<p>There is a lot of buzz about <strong>Microsoft Silverlight</strong>, especially after the Olympics. Also <code>H264</code> will be supported in a future version. Where do you think Silverlight will be 1 year from now?</p>
<p>They were saying they were getting 1.5 million downloads per day back in March 2008, and that was before the Olympics and the Democratic National Convention. So, unless my math is off, that's more than 4 people.</p> <p>I'd expect to see it show up as a recommended Windows update, and possible included with IE8 or something in the future.</p>
<p>100% more.</p> <p>(so about 4 people)</p>
7,776
<p>PLA is flammable, but a good case can protect the main board from dirt.</p> <p>Is it worthwhile to protect a circuit board with a 3d printed case?</p>
<p>It depends.</p> <p>Protecting your electronics from being touched by random bits of conductive material which would short and fry them is always a good idea.</p> <p>If it's something that will be visible, then a pleasant printed casing might go well. You might just as well use any other casing though, there's no requirement it be 3D printed.</p> <p>For a very small circuitboard (an inch or less) heatshrink tubing might be a better form of protection. Or just insulating tape.</p> <p>If you never intend to access the circuitry again and heat dissipation isn't a big issue, then just putting the whole lot in potting compound may work best for you - complete waterproofing and environmental protection.</p> <p>Or you could just tape a bit of plastic from a 2l coke bottle over it, and get 99% of the protection you'll ever need, and still keep the circuit visible and accessible.</p> <p>Ultimately, it boils down to: Do you want it to be covered? If so, by what? If you would prefer a 3D printed case, then do you want it enough that it is worth the time and effort to you?</p>
<p>As pointed out by Ryan Carlyle, not all 3D printing filament is flammable (such as PET and PETG), and the question therefore rather becomes:</p> <p><strong>Can 3D printing be used to make proper electronic cases?</strong></p> <p>And the short answer to that is <strong>yes</strong>. 3D printing allows to make customized cases of all varieties. Also, since there is huge variety of materials available, you not only restricted to cases of plastic filaments - should this be of interest.</p> <p>Then again, it all depends on what you are protecting your electronics from. If you plan on submerging your electronics into water or throw them into a fire, 3D printing might not work for you at all. If dust protection is your only concern, however, 3D printed cases should do just fine in most cases.</p>
223
<p>Are square brackets in URLs allowed?</p> <p>I noticed that <a href="http://hc.apache.org/httpclient-3.x/index.html" rel="noreferrer">Apache commons HttpClient</a> (3.0.1) throws an IOException, wget and Firefox however accept square brackets.</p> <p>URL example:</p> <pre><code>http://example.com/path/to/file[3].html </code></pre> <p>My HTTP client encounters such URLs but I'm not sure whether to patch the code or to throw an exception (as it actually should be).</p>
<p><a href="http://www.ietf.org/rfc/rfc3986.txt" rel="noreferrer">RFC 3986</a> states</p> <blockquote> <p>A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax.</p> </blockquote> <p>So you should not be seeing such URI's in the wild in theory, as they should arrive encoded.</p>
<p>Best to URL encode those, as they are clearly not supported in all web servers. Sometimes, even when there is a standard, not everyone follows it.</p>
6,179
<p>I'm attracted to the neatness that a single file database provides. What driver/connector library is out there to connect and use SQLite with Java.</p> <p>I've discovered a wrapper library, <a href="http://www.ch-werner.de/javasqlite/" rel="noreferrer">http://www.ch-werner.de/javasqlite</a>, but are there other more prominent projects available?</p>
<p>The <a href="http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers" rel="noreferrer">wiki</a> lists some more wrappers:</p> <ul> <li>Java wrapper (around a SWIG interface): <a href="http://tk-software.home.comcast.net/" rel="noreferrer">http://tk-software.home.comcast.net/</a></li> <li>A good tutorial to use JDBC driver for SQLite. (it works at least !) <a href="http://www.ci.uchicago.edu/wiki/bin/view/VDS/VDSDevelopment/UsingSQLite" rel="noreferrer">http://www.ci.uchicago.edu/wiki/bin/view/VDS/VDSDevelopment/UsingSQLite</a></li> <li>Cross-platform JDBC driver which uses embedded native SQLite libraries on Windows, Linux, OS X, and falls back to pure Java implementation on other OSes: <a href="https://github.com/xerial/sqlite-jdbc" rel="noreferrer">https://github.com/xerial/sqlite-jdbc</a> (formerly <a href="http://www.zentus.com/sqlitejdbc" rel="noreferrer">zentus</a>)</li> <li>Another Java - SWIG wrapper. It only works on Win32. <a href="http://rodolfo_3.tripod.com/index.html" rel="noreferrer">http://rodolfo_3.tripod.com/index.html</a></li> <li>sqlite-java-shell: 100% pure Java port of the sqlite3 commandline shell built with NestedVM. (This is not a JDBC driver).</li> <li>SQLite JDBC Driver for Mysaifu JVM: SQLite JDBC Driver for Mysaifu JVM and SQLite JNI Library for Windows (x86) and Linux (i386/PowerPC). </li> </ul>
<p>Typo: <code>java -cp .:sqlitejdbc-v056.jar Test</code></p> <p>should be: <code>java -cp .:sqlitejdbc-v056.jar; Test</code></p> <p>notice the semicolon after ".jar" i hope that helps people, could cause a lot of hassle </p>
6,253
<p>I am working on a function to establish the entropy of a distribution. It uses a copula, if any are familiar with that. I need to sum up the values in the array based on which dimensions are &quot;cared about.&quot;</p> <p>Example: Consider the following example...</p> <pre> Dimension 0 (across) _ _ _ _ _ _ _ _ _ _ _ _ _ |_ 0 _|_ 0 _|_ 0 _|_ 2 _| Dimension 1 |_ 1 _|_ 0 _|_ 2 _|_ 0 _| (down) |_ 0 _|_ 3 _|_ 0 _|_ 6 _| |_ 0 _|_ 0 _|_ 0 _|_ 0 _| I "care about" dimension 0 only, and "don't care" about the rest (dim 1). Summing this array with the above specifications will "collapse" the "stacks" of dimension 1 down to a single 4 x 1 array: _ _ _ _ _ _ _ _ _ _ _ _ _ |_ 1 _|_ 3 _|_ 2 _|_ 8 _| This can then be summed, or have any operation performed. </pre> <p>I need to do this with an array of 'n' dimensions, which could feasibly be 20. Also, I need to be able to do this, caring about certain dimensions, and collapsing the rest. I am having an especially hard time with this because I cant visualize 20 dimensions :p . If anyone could help me set up some c/c++ code to collapse/sum, I would be very very grateful.</p> <h3>Update:</h3> <p>Just got home. Here is some info to answer your questions:</p> <ol> <li>Sorry for rolling back the edits, I was hoping when I clicked roll-back it would show me the changes so I could see what I messed up, a bit like wikipedia. This wasn't the case, as I found out.</li> <li>@jeff - What doesnt make sense? I am using this great service for (what I think is) a legit reason. I want to get better at my hobby, which is all it is, as I am in high school. Many of my posts regard implementing a genetic algorithm (This post, sparsearray, rank an array, pointer manipulation).</li> <li>I am using a sparse array representation, as it is possible to exceed the number of molecules in the universe using a traditional (dense) array. For now, the implementation of the sparsearray itself doesnt matter a whole lot, as I am working to make it work with a standard array before going to a sparse representation. For those who havent seen my previous questions, I am using a binary search tree as the structure to contain the sparse array points, and a &quot;driver&quot; function to traverse the tree as necessary, returning whatever the function is designed to do. This is flexible, so I can accomodate a lot of different methods of accessing the array.</li> <li>The structure is a hypercube, and the number of dimensions is specified at run time, as well as the length of each dimension (which are all the same, as it is a hypercube).</li> </ol> <p>Thanks everyone for your imput.</p>
<p>This could have applications. Lets say you implemented a 2D Conway's Game of Life (which defines a 2D plane, 1 for 'alive', 0 for 'dead') and you stored the Games history for every iteration (which then defines a 3D cube). If you wanted to know how many bacteria there was alive over history, you would use the above algorithm. You could use the same algorithm for a 3D, (and 4D, 5D etc.) version of Game of Life grid.</p> <p>I'd say this was a question for recursion, I'm not yet a C programmer but I know it is possible in C. In python,</p> <pre><code> def iter_arr(array): sum = 0 for i in array: if type(i) == type(list()): sum = sum + iter_arr(i) else: sum = sum + i return sum </code></pre> <ol> <li>Iterate over each element in array</li> <li>If element is another array, call the function again</li> <li>If element is not array, add it to the sum</li> <li>Return sum</li> </ol> <p>You would then apply this to each element in the 'cared about' dimension.</p> <p>This is easier in python due to duck-typing though ...</p>
<p>Actually, by colllapsing the colums you already summed them, so the dimension doesn't matter at all for your example. Did I miss something or did you?</p>
4,318
<p>I want to put a copyright notice in the footer of a web site, but I think it's incredibly tacky for the year to be outdated.</p> <p>How would I make the year update automatically with <a href="http://en.wikipedia.org/wiki/PHP#History" rel="noreferrer">PHP 4</a> or <a href="http://en.wikipedia.org/wiki/PHP#History" rel="noreferrer">PHP 5</a>?</p>
<p>You can use either <a href="http://php.net/manual/en/function.date.php" rel="noreferrer">date</a> or <a href="http://php.net/manual/en/function.strftime.php" rel="noreferrer">strftime</a>. In this case I'd say it doesn't matter as a year is a year, no matter what (unless there's a locale that formats the year differently?)</p> <p>For example:</p> <pre><code>&lt;?php echo date("Y"); ?&gt; </code></pre> <p>On a side note, when formatting dates in PHP it matters when you want to format your date in a different locale than your default. If so, you have to use setlocale and strftime. According to the <a href="http://php.net/manual/en/function.date.php" rel="noreferrer">php manual</a> on date:</p> <blockquote> <p>To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().</p> </blockquote> <p>From this point of view, I think it would be best to use strftime as much as possible, if you even have a remote possibility of having to localize your application. If that's not an issue, pick the one you like best.</p>
<pre><code>&lt;?php $time_now=mktime(date('h')+5,date('i')+30,date('s')); $dateTime = date('d_m_Y h:i:s A',$time_now); echo $dateTime; ?&gt; </code></pre>
8,947
<p>I have written some code in my VB.NET application to send an HTML e-mail (in this case, a lost password reminder).</p> <p>When I test the e-mail, it gets eaten by my spam filter. One of the things that it's scoring badly on is because of the following problem:</p> <pre>MIME_QP_LONG_LINE RAW: Quoted-printable line longer than 76 chars</pre> <p>I've been through the source of the e-mail, and I've broken each line longer than 76 characters into two lines with a CR+LF in between, but that hasn't fixed the problem.</p> <p>Can anyone point me in the right direction?</p> <p>Thanks!</p>
<p>Quoted printable expands 8 bit characters to "={HEX-Code}", thus making the messages longer. Maybe you are just hitting this limit?</p> <p>Have you tried to break the message at, say, 70 characters? That should provide space for a couple of characters per line.</p> <p>Or you just encode the email with Base64 - all mail client can handle that.</p> <p>Or you just set Content-Transfer-Encoding to 8bit and send the data unencoded. I know of no mail server unable to handle 8bit bytes these days.</p>
<p>This is a bug in the implementation of the Quoted-Printable encoding in System.Net.Mail.MailMessage, which has been there for a long time, but is apparently now fixed, as of .Net 4 Beta 2.</p> <p><a href="http://connect.microsoft.com/VisualStudio/feedback/details/156052/mailmessage-body-encoding-quoted-printable-violates-rfcs-soft-line-breaks-requirements" rel="nofollow noreferrer">http://connect.microsoft.com/VisualStudio/feedback/details/156052/mailmessage-body-encoding-quoted-printable-violates-rfcs-soft-line-breaks-requirements</a></p> <p>One work-around is to use Base64 encoding instead (even though it would not otherwise be good practice to send a plain-text MIME part in a non-human readable encoding like this). Asking the user of the class to manually split the lines of the message before sending it is not a general solution, as the modified message is not what they wanted to send (e.g. it might include a link which is longer than 76 chars, and so cannot be split). Quoted-Printable can handle messages with lines which are longer than 76 chars <em>before</em> encoding, as long as it is implemented correctly.</p>
8,304
<p>I'm working on a site which needs to be able to support two or more looks, changable at runtime. I'd hoped to be able to handle the change with a CSS switch, but it looks like I'll need to use a different masterpage for each design.</p> <p>So, what's the best way to set the masterpage at runtime? Page.MasterPageFile can only be set in the Page.OnPreInit event. It looks like the solutions are to make all my pages inherit from a common base which handles the PreInit event, or to use an HttpModule which does that.</p> <p>Any advice?</p>
<p>I've done this once before, I did exactly what you described (Made all pages inherit from a custom page with an OnPreInit event). Also I had a custom Application_PreRequestHandlerExecute in my Global.asax.cs for setting Page.StyleSheetTheme for doing image/css changes that didn't require a different Master Page.</p>
<p>I'm curious what decides how the page should look? Is it the user clicking a button to change the theme? Is it based on the URL that was used to get to the site?</p> <p>Code behind is supported in Master Pages, so you could put some logic in your one Master Page to decide what should be displayed.</p> <p>I've seen several sites set cookies based on user clicks (to change font size, or page width), and then have different CSS files applied based on the value of those cookies. If no cookie is present, display a default look and feel.</p> <p>EDIT:</p> <p>Another thought here, if you are simply trying to switch out CSS is to set your style tag to run at the server, and assign properties to it at run-time. Once again this would require the use of a single master page, and putting code the code-behind of the master page, probably in the PreInit event handler.</p> <p>Since I've never implemented this solution I'm not sure if the whole &lt;HEAD&gt; tag has to run at the server or not.</p> <pre><code> &lt;html&gt; &lt;head id="Head" runat="server"&gt; &lt;style id="StylePlaceholder" runat="server" type="text/css"&gt;&lt;/style&gt; &lt;/head&gt; </code></pre>
3,603
<p>How do you express an integer as a binary number with Python literals?</p> <p>I was easily able to find the answer for hex:</p> <pre><code>&gt;&gt;&gt; 0x12AF 4783 &gt;&gt;&gt; 0x100 256 </code></pre> <p>and octal:</p> <pre><code>&gt;&gt;&gt; 01267 695 &gt;&gt;&gt; 0100 64 </code></pre> <p><strong>How do you use literals to express binary in Python?</strong></p> <hr> <p><strong><em>Summary of Answers</em></strong></p> <ul> <li>Python 2.5 and earlier: can express binary using <code>int('01010101111',2)</code> but not with a literal.</li> <li>Python 2.5 and earlier: there is <em>no way</em> to express binary literals.</li> <li>Python 2.6 beta: You can do like so: <code>0b1100111</code> or <code>0B1100111</code>.</li> <li>Python 2.6 beta: will also allow <code>0o27</code> or <code>0O27</code> (second character is the letter O) to represent an octal.</li> <li>Python 3.0 beta: Same as 2.6, but will no longer allow the older <code>027</code> syntax for octals.</li> </ul>
<p>For reference&mdash;<em>future</em> Python possibilities:<br> Starting with Python 2.6 you can express binary literals using the prefix <strong>0b</strong> or <strong>0B</strong>:</p> <pre><code>&gt;&gt;&gt; 0b101111 47 </code></pre> <p>You can also use the new <strong>bin</strong> function to get the binary representation of a number:</p> <pre><code>&gt;&gt;&gt; bin(173) '0b10101101' </code></pre> <p>Development version of the documentation: <a href="http://docs.python.org/dev/whatsnew/2.6.html#pep-3127-integer-literal-support-and-syntax" rel="noreferrer">What's New in Python 2.6</a></p>
<p>As far as I can tell Python, up through 2.5, only supports hexadecimal &amp; octal literals. I did find some discussions about adding binary to future versions but nothing definite.</p>
2,385
<p>How do I open the default mail program with a Subject and Body in a cross-platform way?</p> <p>Unfortunately, this is for a a client app written in Java, not a website.</p> <p>I would like this to work in a cross-platform way (which means Windows and Mac, sorry Linux). I am happy to execute a VBScript in Windows, or AppleScript in OS X. But I have no idea what those scripts should contain. I would love to execute the user's default program vs. just searching for Outlook or whatever.</p> <p>In OS X, I have tried executing the command:</p> <pre><code>open mailto:?subject=MySubject&amp;body=TheBody </code></pre> <p>URL escaping is needed to replace spaces with <code>%20</code>.</p> <p><strong>Updated</strong> On Windows, you have to play all sorts of games to get <code>start</code> to run correctly. Here is the proper Java incantation:</p> <pre><code>class Win32 extends OS { public void email(String subject, String body) throws Exception { String cmd = "cmd.exe /c start \"\" \"" + formatMailto(subject, body) + "\""; Runtime.getRuntime().exec(cmd); } } </code></pre>
<p>In Java 1.6 you have a stardard way to open the default mailer of the platform: <a href="http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html" rel="noreferrer">the Desktop.mail(URI) method</a>.The URI can be used to set all the fields of the mail (sender, recipients, body, subject). You can check a full example of desktop integration in Java 1.6 on <a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/" rel="noreferrer">Using the Desktop API in Java SE 6</a></p>
<p>I have implemented this, and it works well on OS X. (Ryan's mention of the max URL length has not been codified.)</p> <pre><code>public void email(String subject, String body) throws Exception { String cmd = "open mailto:"; cmd += "?subject=" + urlEncode(subject); cmd += "&amp;body=" + urlEncode(body); Runtime.getRuntime().exec(cmd); } private static String urlEncode(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; s.length(); i++) { char ch = s.charAt(i); if (Character.isLetterOrDigit(ch)) { sb.append(ch); } else { sb.append(String.format("%%%02X", (int)ch)); } } return sb.toString(); } </code></pre> <p>I had to re-implement URLencode because Java's would use <code>+</code> for space and Mail took those literally. Haven't tested on Windows yet.</p>
3,804
<p>I'm printing parts for a HEVO (<a href="https://www.thingiverse.com/thing:2254103" rel="nofollow noreferrer">HyperCube Evolution</a> CoreXY), using Colorfabb XT filament. After several successful prints. I'm having a lot of failed prints. They start off pretty well but after ~15 layers the filament starts to string and blob. </p> <p>Printer details</p> <pre><code>Model: RepRap i3 Extruder: E3D 1.75 all metal hotend. Nozzle: .4 Print temp: 260°C (max. recommended). </code></pre> <p>Steps I took to troubleshoot</p> <ol> <li>First I thought my nozzle was clogged. But it's not I can push the filament by hand without issues.</li> <li>Lowered the speed to 35&nbsp;mm/s.</li> <li>Disabled retraction / disabled part cooling.</li> <li>increased the max temp with 10&nbsp;% to ensure the filament flow</li> </ol> <p>Printed parts that fail: </p> <p><a href="https://i.stack.imgur.com/2wEjO.jpg" rel="nofollow noreferrer" title="Top view printed part"><img src="https://i.stack.imgur.com/2wEjO.jpg" alt="Top view printed part" title="Top view printed part"></a> <em>Note: the two parts on the left are printed in one job</em></p> <p><a href="https://i.stack.imgur.com/1jure.jpg" rel="nofollow noreferrer" title="Side view printed part"><img src="https://i.stack.imgur.com/1jure.jpg" alt="Side view printed part" title="Side view printed part"></a></p> <p>UPDATE 26/07 Dit a few more prints with PETG to eliminate the moisture problem. Same results.</p> <p><a href="https://i.stack.imgur.com/l6vj4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l6vj4.jpg" alt="PETG"></a></p> <p><a href="https://i.stack.imgur.com/GL1IF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GL1IF.jpg" alt="PETG2"></a></p>
<p>This looks a lot like <strong>under extrusion caused by heat creep</strong>.</p> <p>Heat creep is when the nozzle temperature 'creeps' up through the filament and makes it melt (a bit) and form a blob (or just widen enough to get stuck) a centimeter or two before the nozzle.</p> <p>The characteristic is usually that everything works perfectly well for some quite fix amount of time, then there is severe under extrusion.</p> <p>Solutions:</p> <ul> <li>Lower the temperature (yes, as then the heat won't creep as much!)</li> <li>Add a fan cooling down the cooling part of the print head</li> </ul> <p>I have the same print head as you it seems (E3D 1.75 all metal) and I had heat creep when I changed the fan to a less noisy one (but also less effective).</p>
<p>I have a possible cause for my problems. XT is sensitive to moisture (hydrolytical stability) When I extruded 20mm filament manually, the string felt a bit rough. When I looked closer very tiny bubbels where visible. I baked the filament at 60°C for 2 hours.</p> <p>The baked filament allowed me to print a perfect model. </p> <p>But after one print the filament is again affected by moisture so I need to build a dry-box and do some more tests before I come to a conclusion. </p>
960
<p>What's the simplest-to-use techonlogy available to save an arbitrary Java object graph as an XML file (and to be able to rehydrate the objects later)?</p>
<p>The easiest way here is to serialize the object graph. Java 1.4 has built in support for serialization as XML.</p> <p>A solution I have used successfully is XStream (<a href="http://x-stream.github.io/)-" rel="nofollow noreferrer">http://x-stream.github.io/)-</a> it's a small library that will easily allow you to serialize and deserialize to and from XML.</p> <p>The downside is you can only very limited define the resulting XML; which might not be neccessary in your case.</p>
<p>If you are really only interested in serializing your objects to a file and then deserializing them later, then you might check out YAML instead of XML. YAML is much easier to work with than XML and the output files are very human-readable (which may or may not be a requirement). Check out <a href="http://yaml.org/" rel="nofollow noreferrer">yaml.org</a> for more information. I've used <a href="http://jyaml.sourceforge.net/" rel="nofollow noreferrer" title="JYAML">JYAML</a> successfully on a recent project.</p>
8,814
<p>For the purpose of cleaning, I need an aggressive solvent for cured or partially cured resin that will degrade resin down to its liquid state. I'm looking for one that would eat out specifically resin (I'm using regular Anycubic green resin) in a rapid fashion but would leave painted / metallic parts and screen of my 3D printer without damage.</p>
<p>Concentrated nitric acid will remove all organics, including your skin, wire insulation, etc. It will work on a glass plate, but the fumes would eventually damage the plastics on your printer unless you remove the glass plate to clean it. Nitric acid will destroy most build surfaces that are added to glass. To a lesser extent concentrated sulfuric acid works, but it tends to leave carbon behind. With these acids it takes special gloves, and I would not even depend too heavily on them always working. The more concentrated the acids (the less water), the less they will attack metals. Note: this will quickly strip the paint off metal parts.</p> <p>Thus, you probably cannot find an aggressive chemical that is practical for you to use.</p>
<p>I would try hexane, and then Dichloromethane and if those did not work, I would heat up sodium hydroxide to about 70-90 °C. These would work better if you print in PLA resin, it's available from a few sources now.</p> <p>Bucktown polymers and 3Dresyns both have a water-soluble resin. You could also print, make a soft silicone mold, cast in chocolate or isomalt and quickly seal in b72 enamel to hold its shape for your next step.</p> <p>Another great option is to cast the printed mold with Amazing Remelt as you can microwave it out of your shell afterward. Or heat up/steam.</p>
1,789
<p>I have the following C# code:</p> <pre><code>byte rule = 0; ... rule = rule | 0x80; </code></pre> <p>which produces the error: </p> <blockquote> <p><em>Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)</em></p> </blockquote> <p>[Update: first version of the question was wrong ... I misread the compiler output]</p> <p>Adding the cast <strong>doesn't</strong> fix the problem:</p> <pre><code>rule = rule | (byte) 0x80; </code></pre> <p>I need to write it as:</p> <pre><code>rule |= 0x80; </code></pre> <p>Which just seems weird. Why is the <code>|=</code> operator any different to the <code>|</code> operator?</p> <p>Is there any other way of telling the compiler to treat the constant as a byte?</p> <hr> <p><strong>@ Giovanni Galbo</strong> : yes and no. The code is dealing with the programming of the flash memory in an external device, and logically represents a single byte of memory. I could cast it later, but this seemed more obvious. I guess my C heritage is showing through too much!</p> <p><strong>@ Jonathon Holland</strong> : the 'as' syntax looks neater but unfortunately doesn't appear to work ... it produces:</p> <blockquote> <p><em>The as operator must be used with a reference type or nullable type ('byte' is a non-nullable value type)</em> </p> </blockquote>
<p>C# does not have a literal suffix for byte. u = uint, l = long, ul = ulong, f = float, m = decimal, but no byte. You have to cast it.</p>
<p>Unfortunately, your only recourse is to do it just the way you have. There is no suffix to mark the literal as a byte. The | operator does not provide for implicit conversion as an assignment (i.e. initialization) would.</p>
6,468
<p>I'm relatively new to 3d printing, and wanted to get a few things understood. Firstly, I am unclear on how Hexagonal infill is stronger than, say, diamond pattern. </p> <p>Can anyone explain how the different shape causes the structure to be stronger? I saw a few places that hex is stronger; usually, more vertices means 'weaker' shape (i.e. a triangle is stronger than a square), so how does that work with hex vs diamond?</p> <p>Also, in small objects, where the printer makes only a single dot as the infill (a dot instead of a line in larger objects), does the infill strengthen the object at all?</p> <p>EDIT: I am trying to understand the effect of the infill pattern on the <em>strength</em> of the print, regardless of print time.</p>
<p>Hex grids are used for different reasons than triangular grids (such as you often see on bridges and roof systems). Triangles are especially good at being <em>rigid</em>, while hex grids are very material-efficient for a given strength. The second reason ($) is typically more important for 3D printing.</p> <p>Triangles do have fewer vertices than squares, but it's not always true that "fewer vertices" means stronger. Vertices are one kind of weak point. But in a triangle, vertex "angle-holding" failures simply don't matter. You can fasten 3 bars together with hinges or other joints that have little resistance to changing angle, and the triangle is still rigid.</p> <p>In contrast, rectangular grids can (and do -- <a href="https://www.youtube.com/watch?v=5t9MpNTSbYg" rel="noreferrer">https://www.youtube.com/watch?v=5t9MpNTSbYg</a>) completely collapse if their vertices aren't rigid enough. That combines badly with the fact that vertices concentrate forces, so have to be much stronger than sides in comparable settings.</p> <p>A triangle cannot change without changing multiple things -- at least 2 angles and a side, or all three sides. Intuitively, the sides and vertices of a triangle work together for strength. This advantage of triangles doesn't transfer to hexagons, but hexagons have two other advantages: First, if you want to fill a space with a repeating shape, hexagons use less material than other shapes. And second, hexagons keep all the individual "walls" shorter compared to others shapes, which makes them less prone to bend.</p> <p>The material efficiency was proven by Thomas Hales in 1998, according to <a href="http://www.slate.com/articles/health_and_science/science/2015/07/hexagons_are_the_most_scientifically_efficient_packing_shape_as_bee_honeycomb.html" rel="noreferrer">http://www.slate.com/articles/health_and_science/science/2015/07/hexagons_are_the_most_scientifically_efficient_packing_shape_as_bee_honeycomb.html</a>. His paper "The Honeycomb Structure" is available at <a href="https://www.communitycommons.org/wp-content/uploads/bp-attachments/14268/honey.pdf" rel="noreferrer">https://www.communitycommons.org/wp-content/uploads/bp-attachments/14268/honey.pdf</a></p>
<p>Correction: I believe I found what you are looking for:</p> <p><a href="https://engineerdog.com/2015/09/02/mechanical-testing-3d-printed-parts-results-and-recommendations/" rel="nofollow noreferrer">Report from EngineerDog.com</a></p> <p>The author concludes that rectilinear infill with a zero degree offset is the strongest. However, I have not seen consensus for or against a certain pattern being strongest. I recommend more investigation .</p> <p>My original answer:</p> <blockquote> <p>I don't know that one pattern is significantly stronger than another, provided they each bond well with other infill deposits as well as the perimeters.</p> <p>There are studies around. In 3D printing, strength is rarely the only consideration; one must optimize for strength <em>where needed</em> versus time to print.</p> <p>See <a href="https://3dprinting.com/tips-tricks/how-to-choose-an-infill-for-your-3d-prints/" rel="nofollow noreferrer">this</a> as an example of a report which supports the hexagonal or honeycomb pattern as the optimal balance between strength and print time. <a href="http://my3dmatter.com/influence-infill-layer-height-pattern/" rel="nofollow noreferrer">This one</a> is more detailed, but only compares linear infill patterns of varying layer thickness and density. There are many such articles, some more scientifically conducted than others, available with a simple search.</p> </blockquote>
531
<p>I have a Flex swf hosted at <a href="http://www.a.com/a.swf" rel="nofollow noreferrer">http://www.a.com/a.swf</a>. I have a flash code on another doamin that tries loading the SWF:</p> <pre><code>_loader = new Loader(); var req:URLRequest = new URLRequest("http://services.nuconomy.com/n.swf"); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderFinish); _loader.load(req); </code></pre> <p>On the onLoaderFinish event I try to load classes from the remote SWF and create them:</p> <pre><code>_loader.contentLoaderInfo.applicationDomain.getDefinition("someClassName") as Class </code></pre> <p>When this code runs I get the following exception</p> <pre><code>SecurityError: Error #2119: Security sandbox violation: caller http://localhost.service:1234/flashTest/Main.swf cannot access LoaderInfo.applicationDomain owned by http://www.b.com/b.swf. at flash.display::LoaderInfo/get applicationDomain() at NuconomyLoader/onLoaderFinish() </code></pre> <p>Is there any way to get this code working?</p>
<p>This is all described in <a href="http://livedocs.adobe.com/flex/3/progAS_flex3.pdf" rel="nofollow noreferrer">The Adobe Flex 3 Programming ActionScript 3 PDF</a> on page 550 (Chapter 27: Flash Player Security / Cross-scripting):</p> <blockquote> <p>If two SWF files written with ActionScript 3.0 are served from different domains—for example, <a href="http://siteA.com/swfA.swf" rel="nofollow noreferrer">http://siteA.com/swfA.swf</a> and <a href="http://siteB.com/swfB.swf" rel="nofollow noreferrer">http://siteB.com/swfB.swf</a>—then, by default, Flash Player does not allow swfA.swf to script swfB.swf, nor swfB.swf to script swfA.swf. A SWF file gives permission to SWF files from other domains by calling Security.allowDomain(). By calling Security.allowDomain("siteA.com"), swfB.swf gives SWF files from siteA.com permission to script it.</p> </blockquote> <p>It goes on in some more detail, with diagrams and all.</p>
<p>Mayhaps <a href="http://livedocs.adobe.com/flex/15/flex_docs_en/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flex_Documentation&amp;file=00001750.htm" rel="nofollow noreferrer" title="Flex Documentation: System.Security.allowDomain">System.Security.allowDomain</a> is what you need?</p>
3,511
<p>I have a CollapsiblePanelExtender that will not collapse. I have "collapsed" set to true and all the ControlID set correctly. I try to collapse and it goes through the animation but then expands almost instantly. This is in an User Control with the following structure.</p> <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="odsPartners" Width="450px" BorderWidth="0" ShowHeader="false" ShowFooter="false" AllowSorting="true" onrowdatabound="GridView1_RowDataBound"&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Contract Partners" SortExpression="Name"&gt; &lt;ItemTemplate&gt; &lt;asp:Panel id="pnlRow" runat="server"&gt; &lt;table&gt; ...Stuff... &lt;/table&gt; &lt;/asp:Panel&gt; &lt;ajaxToolkit:CollapsiblePanelExtender runat="server" ID="DDE" Collapsed="true" ImageControlID="btnExpander" ExpandedImage="../Images/collapse.jpg" CollapsedImage="../Images/expand.jpg" TargetControlID="DropPanel" CollapseControlID="btnExpander" ExpandControlID="btnExpander" /&gt; &lt;asp:Panel ID="DropPanel" runat="server" CssClass="CollapsedPanel"&gt; &lt;asp:Table ID="tblContracts" runat="server"&gt; &lt;asp:TableRow ID="row" runat="server"&gt; &lt;asp:TableCell ID="spacer" runat="server" Width="30"&gt;&amp;nbsp;&lt;/asp:TableCell&gt; &lt;asp:TableCell ID="cellData" runat="server" Width="400"&gt; &lt;uc1:ContractList ID="ContractList1" runat="server" PartnerID='&lt;%# Bind("ID") %&gt;' /&gt; &lt;/asp:TableCell&gt; &lt;/asp:TableRow&gt; &lt;/asp:Table&gt; &lt;/asp:Panel&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="tbFilter" EventName="TextChanged" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; </code></pre>
<p>I am sorry I do not have time to trouble-shoot your code, so this is from the hip.</p> <p>There is a good chance that this a client-side action that is failing. Make certain that your page has the correct doctype tag if you took it out of your page or masterPage. Furthermore, attempt to set the ClientState as well:</p> <p>DDE.ClientState = true;</p> <p>The issue is you have that thing wrapped inside of your TemplateField. I have ran into issues using the AjaxControlToolkit on repeated fields and usually side with using a lighter weight client-side option, up to and including rolling your own show/hide method that can be reused just by passing in an DOM understood id.</p>
<p>It is working fine:</p> <pre><code>CollapsiblePanelExtender CpeForControls = (CollapsiblePanelExtender)tbl_Form.FindControl("cpe_controls"); CpeForControls.ClientState = "true"; CpeForControls.Collapsed = true; </code></pre>
4,642
<p>How safe do you think it is to run an SLA 3D printer in the bedroom? I am planning to run Mi Air Purifier 3H/C while the printer is running, I am also thinking about adding <a href="https://rads.stackoverflow.com/amzn/click/com/B086277CNQ" rel="nofollow noreferrer" rel="nofollow noreferrer">this</a> inside the actual printer (Elegoo Mini Air Purifier with carbon filter).</p> <p>Is this safe or still too risky?</p>
<p>The motor is mounted in a fixed position no matter if it's on top or bottom. You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compression instead of hanging from the rod.</p> <p>Any forces that might &quot;pull it straight&quot; are the same forces that can cause Z wobble so you would not want to even try to use the misalignment to straighten a bent lead screw.</p> <p>The only thing this that really changes with this orientation is if the lead screw is under tension or compression. Even a relatively thin lead screw can easy counter the forces of gravity and the forces is the same in both directions. Its easy and cheap to make a smooth rod or rail straight but not so easy to make a threaded one straight.</p>
<p>The motor is mounted in a fixed position no matter if it's on top or bottom. You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compression instead of hanging from the rod.</p> <p>Any forces that might &quot;pull it straight&quot; are the same forces that can cause Z wobble so you would not want to even try to use the misalignment to straighten a bent lead screw.</p> <p>The only thing this that really changes with this orientation is if the lead screw is under tension or compression. Even a relatively thin lead screw can easy counter the forces of gravity and the forces is the same in both directions. Its easy and cheap to make a smooth rod or rail straight but not so easy to make a threaded one straight.</p>
2,018
<p>Using <a href="http://www.codeplex.com/aspnet" rel="nofollow noreferrer">preview 4</a> of <a href="http://asp.net/mvc" rel="nofollow noreferrer">ASP.NET MVC</a> Code like:</p> <pre><code>&lt;%= Html.CheckBox( "myCheckBox", "Click Here", "True", false ) %&gt; </code></pre> <p>only outputs:</p> <pre><code>&lt;input type="checkbox" value="True" name="myCheckBox" /&gt; </code></pre> <p>There is a <code>name</code> there for the form post back but no <code>id</code> for javascript or labels :-(</p> <p>I was hoping that changing it to:</p> <pre><code>Html.CheckBox( "myCheckBox", "Click Here", "True", false, new { id="myCheckBox" } ) </code></pre> <p>would work - but instead I get an exception:</p> <pre><code>System.ArgumentException: An item with the same key has already been added. </code></pre> <p>As if there was already an id somewhere in a collection somewhere - I'm stumped!</p> <p>The full exception for anyone interested follows (hey - wouldn't it be nice to attach files in here):</p> <pre>System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Web.Routing.RouteValueDictionary.Add(String key, Object value) at System.Web.Mvc.TagBuilder2.CreateInputTag(HtmlInputType inputType, String name, RouteValueDictionary attributes) at System.Web.Mvc.CheckBoxBuilder.CheckBox(String htmlName, RouteValueDictionary htmlAttributes) at System.Web.Mvc.CheckBoxBuilder.CheckBox(String htmlName, String text, String value, Boolean isChecked, RouteValueDictionary htmlAttributes) at System.Web.Mvc.CheckBoxExtensions.CheckBox(HtmlHelper helper, String htmlName, String text, String value, Boolean isChecked, Object htmlAttributes) at ASP.views_account_termsandconditions_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\dev\myProject\Views\Account\Edit.ascx:line 108</pre>
<p>Try this: </p> <pre><code>&lt;%= Html.CheckBox("myCheckbox", "Click here", "True", false, new {_id ="test" })%&gt; </code></pre> <p>For any keyword you can use an underscore before the name of the attribute. Instead of class you use _class. Since class is a keyword in C#, and also the name of the attribute in HTML. Now, "id" isn't a keyword in C#, but perhaps it is in another .NET language that they want to support. From what I can tell, it's not a keyword in VB.NET, F#, or Ruby so maybe it is a mistake that they force you to use an underscore with it.</p>
<p>Apparently this is a bug. Because they are adding it to potential rendering values, they just forgot to include it. I would recommend creating a bug on codeplex, and download the source and modify it for your needs.</p>
2,964
<p>I've been able to find details on several self-balancing <code>BST</code>s through several sources, but I haven't found any good descriptions detailing which one is best to use in different situations (or if it really doesn't matter). </p> <p>I want a <code>BST</code> that is optimal for storing in excess of ten million nodes. The order of insertion of the nodes is basically random, and I will never need to delete nodes, so insertion time is the only thing that would need to be optimized. </p> <p>I intend to use it to store previously visited game states in a puzzle game, so that I can quickly check if a previous configuration has already been encountered.</p>
<p><a href="http://en.wikipedia.org/wiki/Red-black_tree" rel="nofollow noreferrer">Red-black</a> is better than AVL for insertion-heavy applications. If you foresee relatively uniform look-up, then Red-black is the way to go. If you foresee a relatively unbalanced look-up where more recently viewed elements are more likely to be viewed again, you want to use <a href="http://en.wikipedia.org/wiki/Splay_tree" rel="nofollow noreferrer">splay trees</a>.</p>
<blockquote> <p>[hash tables have] O(1) insertion and search</p> </blockquote> <p>I think this is wrong.</p> <p>First of all, if you limit the keyspace to be finite, you could store the elements in an array and do an O(1) linear scan. Or you could shufflesort the array and then do a linear scan in O(1) expected time. When stuff is finite, stuff is easily O(1).</p> <p>So let's say your hash table will store any arbitrary bit string; it doesn't much matter, as long as there's an infinite set of keys, each of which are finite. Then you have to read all the bits of any query and insertion input, else I insert y0 in an empty hash and query on y1, where y0 and y1 differ at a single bit position which you don't look at.</p> <p>But let's say the key lengths are not a parameter. If your insertion and search take O(1), in particular hashing takes O(1) time, which means that you only look at a finite amount of output from the hash function (from which there's likely to <em>be</em> only a finite output, granted).</p> <p>This means that with finitely many buckets, there must be an infinite set of strings which all have the same hash value. Suppose I insert a lot, i.e. &omega;(1), of those, and start querying. This means that your hash table has to fall back on some other O(1) insertion/search mechanism to answer my queries. Which one, and why not just use that directly?</p>
2,456