instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I recently installed a SKR 1.3 Board with a 3DTouch-Probe on my Creality Ender 3 Pro. The probe works, <code>G29</code> does its magic, but:</p> <p>If i issue a plain <code>G28</code>, the hotend first homes X and Y like before the Z-probe. The probe is now next to, not above, the bed. As the next step, the printer is supposed to home the Z-axis. The probe deploys and Z starts to lower until it smashes into the bed, because the probe misses the bed (if I don't stop it, that is).</p> <p>I configured X/Y offsets for the probe, but they don't seem to be honored when performing the <code>G28</code> code.</p> <p>If I home X/Y "manually" with <code>G28 X Y</code>, move the hotend with like <code>G1 X45 Y10</code>, then home Z with <code>G28 Z</code> it works fine.</p> <p>What did I miss? Is this intended behaviour &amp; the user has to take care never to issue a plain <code>G28</code>?!</p>
<p>You need to enable the constant <code>Z_SAFE_HOMING</code> (like: <code>#define Z_SAFE_HOMING</code>) in your <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h" rel="nofollow noreferrer">printer configuration file</a> (if you're using Marlin firmware that is). This will move the nozzle to the middle of the plate prior to lowering the nozzle by default:</p> <pre><code>#if ENABLED(Z_SAFE_HOMING) #define Z_SAFE_HOMING_X_POINT ((X_BED_SIZE) / 2) // X point for Z homing when homing all axes (G28). #define Z_SAFE_HOMING_Y_POINT ((Y_BED_SIZE) / 2) // Y point for Z homing when homing all axes (G28). #endif </code></pre>
<p>Use <code>Z Safe Homing</code> to avoid homing with a Z probe outside the bed area</p> <p>According to Marlin firmware with this feature enabled:</p> <ul> <li>Allow Z homing only after X and Y homing AND stepper drivers still enabled.</li> <li>If stepper drivers time out, it will need X and Y homing again before Z homing.</li> <li>Move the Z probe (or nozzle) to a defined XY point before Z Homing when homing all axes (G28).</li> <li>Prevent Z homing when the Z probe is outside the bed area.</li> </ul> <p>To Enable Z SAFE HOMING, In the <code>configuration.h</code> file search (Ctrl+F) for <code>#define Z_SAFE_HOMING</code>. By default, it will be disabled to enable it just uncomment the line</p> <p><a href="https://i.stack.imgur.com/5KfmU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5KfmU.png" alt="enter image description here"></a></p>
1,479
<p>I'm looking for a clear, concise and accurate answer. </p> <p>Ideally as the actual answer, although links to good explanations welcome.</p>
<p>Boxed values are <a href="http://en.wikipedia.org/wiki/Data_structure" rel="noreferrer">data structures</a> that are minimal wrappers around <a href="http://en.wikipedia.org/wiki/Primitive_type" rel="noreferrer">primitive types</a>*. Boxed values are typically stored as pointers to objects on <a href="http://en.wikipedia.org/wiki/Dynamic_memory_allocation" rel="noreferrer">the heap</a>.</p> <p>Thus, boxed values use more memory and take at minimum two memory lookups to access: once to get the pointer, and another to follow that pointer to the primitive. Obviously this isn't the kind of thing you want in your inner loops. On the other hand, boxed values typically play better with other types in the system. Since they are first-class data structures in the language, they have the expected metadata and structure that other data structures have.</p> <p>In Java and Haskell generic collections can't contain unboxed values. Generic collections in .NET can hold unboxed values with no penalties. Where Java's generics are only used for compile-time type checking, .NET will <a href="http://msdn.microsoft.com/en-us/library/f4a6ta2h.aspx" rel="noreferrer">generate specific classes for each generic type instantiated at run time</a>.</p> <p>Java and Haskell have unboxed arrays, but they're distinctly less convenient than the other collections. However, when peak performance is needed it's worth a little inconvenience to avoid the overhead of boxing and unboxing.</p> <p>* For this discussion, a primitive value is any that can be stored on <a href="http://en.wikipedia.org/wiki/Call_stack" rel="noreferrer">the call stack</a>, rather than stored as a pointer to a value on the heap. Frequently that's just the machine types (ints, floats, etc), structs, and sometimes static sized arrays. .NET-land calls them value types (as opposed to reference types). Java folks call them primitive types. Haskellions just call them unboxed.</p> <p>** I'm also focusing on Java, Haskell, and C# in this answer, because that's what I know. For what it's worth, Python, Ruby, and Javascript all have exclusively boxed values. This is also known as the "Everything is an object" approach***. </p> <p>*** Caveat: A sufficiently advanced compiler / JIT can in some cases actually detect that a value which is semantically boxed when looking at the source, can safely be an unboxed value at runtime. In essence, thanks to brilliant language implementors your boxes are sometimes free.</p>
<p>Like anything else, autoboxing can be problematic if not used carefully. The classic is to end up with a NullPointerException and not be able to track it down. Even with a debugger. Try this:</p> <pre><code>public class TestAutoboxNPE { public static void main(String[] args) { Integer i = null; // .. do some other stuff and forget to initialise i i = addOne(i); // Whoa! NPE! } public static int addOne(int i) { return i + 1; } } </code></pre>
3,409
<p>I have a repeatable business process that I execute every week as part of my configuration management responsibilities. The process does not change: I download change details into Excel, open the spreadsheet and copy out details based on a macro, create a Word document from an agenda template, update the agenda with the Excel data, create PDFs from the Word document, and email them out.</p> <p>This process is very easily represented in a sequence workflow and that's how I have it so far, with COM automation to handle the Excel and Word pieces automatically. The wrench in the gears is that there is a human step between "create agenda" and "send it out," wherein I review the change details and formulate questions about them, which are added to the agenda. I currently have a Suspend activity to suspend the workflow while I manually do this piece of the process.</p> <p>My question is, should I rewrite my workflow to make it a state machine to follow a best practice for human interaction in a business process, or is the Suspend activity a reasonable solution?</p>
<p>Depending on the nature of your data and the parties that upload the excel files, you might want to consider having them save the data in .csv format. It will be much easier to parse on your end.</p> <p>Assuming that isn't an option a quick google search turned up <a href="http://sourceforge.net/projects/phpexcelreader/" rel="nofollow noreferrer">http://sourceforge.net/projects/phpexcelreader/</a> which might suit your needs.</p>
<p>The open-source ETL tool Talend (<a href="http://wwww.talend.com" rel="nofollow noreferrer">http://wwww.talend.com</a>) will generate Java or Perl code and package such code with the necessary 3rd party libraries. </p> <p>Talend should be able to handle all versions of Excel and output the result set in any format you require (including loading it directly into a database if need be).</p>
9,827
<p>We're currently using Lucene 2.1.0 for our site search and we've hit a difficult problem: one of our index fields is being ignored during a targeted search. Here is the code for adding the field to a document in our index:</p> <pre><code>// Add market_local to index contactDocument.add( new Field( "market_local" , StringUtils.objectToString( currClip.get( "market_local" ) ) , Field.Store.YES , Field.Index.UN_TOKENIZED ) ); </code></pre> <p>Running a query ( * ) against the index will return the following results:</p> <pre><code>Result 1: title: Foo Bar market_local: Local Result 2: title: Bar Foo market_local: National </code></pre> <p>Running a targeted query:</p> <pre><code>+( market_local:Local ) </code></pre> <p>won't find any results.</p> <p>I realize this is a highly specific question, I'm just trying to get information on where to start debugging this issue, as I'm a Lucene newbie.</p> <hr> <p><strong>UPDATE</strong></p> <p>Installed Luke, checking out latest index... the Field <em>market_local</em> is available in searches, so if I execute something like:</p> <pre><code>market_local:Local </code></pre> <p>The search works correctly (in Luke). I'm going over our Analyzer code now, is there any way I could chalk this issue up to the fact that our search application is using Lucene 2.1.0 and the latest version of Luke is using 2.3.0?</p>
<p>For debugging Lucene, the best tool to use is <a href="http://www.getopt.org/luke/" rel="noreferrer">Luke</a>, which lets you poke around in the index itself to see what got indexed, carry out searches, etc. I recommend downloading it, pointing it at your index, and seeing what's in there.</p>
<p>Another simple thing to do would be to use a debugger or logging statement to check the value of </p> <blockquote> <p>StringUtils.objectToString(currClip.get("market_local"))</p> </blockquote> <p>to make sure it is what you think it is.</p>
6,412
<p>I'm looking for a 3D printer for applications in the dental field, for printing digital dental models (not for itra-oral use parts).</p> <p>Resolution and finish are the main requirements that we consider necessary.</p> <p>Any suggestion?</p>
<p>If resolution is your upmost concern then resin 3d printers are the way to go. They use a liquid resin that does not harden until a UV laser is shined through them. Apparently they get ultra high resolution and smooth finishes right out of the box. The downside is they are generally more expensive machines and the resin material itself is also a higher cost. but if you are in the dental field then money is not a problem. Look into resin 3d printers.</p> <p>otherwise if you want to try FDM printers then try looking into .1mm brass nozzles which will increase resolution but vastly increase print time. Not sure what material would be best. ABS has toxic smelling fumes, but is the same as LEGOS and is able to be easily smoothed (if necessary) with Acetone fumes. PLA might work well at .1mm nozzle resolution though and is a starch/dextrin based non-toxic biodegradable filament.</p>
<p>As mentionned by Andrew, resins should do the trick : most commons processes are SLA and DLP (DLP is faster but more expensive).</p> <ul> <li>If you aren't looking for precisions (or looking for low budget), FDM machines should do the trick. </li> <li>If you need metal, I think Solidscape or micro SLM should both work.</li> </ul> <p>You should specify what are your exigences, it's not the same to do an ultra-high precision metal part and to have a $300 maximum-budget machine.</p>
372
<p>I'm currently printing 11 copies of the same model. I noticed as it's printing that it seems to work on one model at a time but doesn't travel to the nearest model next. I suspect it's traveling around the bed in the order that I put the models in the slicer. This is resulting in extra unnecessary travel and therefore, increasing print time. I slice in Cura 4.9.</p> <p>Is there a slicer that handles this better? Or is there a way to optimize movements in Cura?</p>
<p>It's well known in mathematical circles that the &quot;salesman problem&quot; is what mathematicians call &quot;hard&quot; -- in their usage, that means a lot of extremely smart people have worked on the problem for many years (more than a century?) and still not found a robust, works-every-time solution.</p> <p>What's probably happening with Cura and other slicers is that, for their version of this issue (the most efficient way to visit multiple locations) the decision was made that reducing computing time in slicing was more practical than optimizing travel time of the machine. This is a reasonable decision, from a programming standpoint, because you're likely to be sitting in front of a screen, getting more and more impatient (and thinking less and less of the software you're using) every second the slicing takes, but when the actual printing is going on, you can be doing something else (sleeping, working at your day job, etc.)</p> <p>Therefor, it's likely that what you see in Cura <em>is</em> optimized -- to minimize <em>your</em> time on the way to a solution, rather than to minimize the time for a machine that simply doesn't care if a print takes five hours or nine.</p>
<p><strong>Long story short:</strong> I only know the setting &quot;Combing Mode OFF&quot; that improves the travel paths. In my case it did not help. In your case I suggest you should give PrusaSlicer a try. I assume that the overall print duration will be improved because of a better calculation of the travel paths. But this is only my personal opinion between these two Slicers.</p> <p><strong>Further explanation:</strong> I downloaded the Cura 4.9 and made an install from scratch. I tried to reproduce your issue by placing lots of copies of the same part. As printer I selected the Ultimaker S5 and used the standard configuration for slicing. I let Cura arrange the parts on the print plate. I checked the travel paths between the parts and in most cases Cura has chosen the nearest distance to move the printhead to the next part. In my opinion, there could be a more efficient choice for the next part to print. After this first test I experimented with the settings (e.g. &quot;Combing Mode&quot; OFF) but without an improvement in travel movements.</p> <p>In the past I used Cura in combination with an Ultimaker S5 at work to print parts for production usecases. Over the past two years I recognized lots of parts where the travel movements have been chosen very unefficiently at the cost of high print duration.</p> <p>For comparison I used my standard slicer &quot;PrusaSlicer&quot; and did the test under the same conditions: standard settings, auto-arrangement of the parts. Overall the travel paths are calculated more efficiently, but there is also some room for improvement.</p>
1,991
<p>What is the best way to create redundant subversion repositories?</p> <p>I have a subversion repository (linked through apache2 and WebDAV) and would like to create a mirror repository on a different server in the event of outages, but I am not certain of the best way to proceed.</p> <p>I am thinking that post-commit scripts could be used to propagate changes, but I am not sure if this is the best way to go, anyone have any input</p>
<p>Sounds like what you are looking for is basically federated (synced) servers... I asked the same question recently...and while I didn't find the exact solution I was looking for it came close. <a href="https://stackoverflow.com/questions/1790/federated-synced-subversion-servers">See here:</a></p>
<p>If you only need read-only access to the mirrored repository, you can use <a href="https://svn.apache.org/repos/asf/subversion/trunk/notes/svnsync.txt" rel="nofollow noreferrer">svnsync</a> which was added in SVN 1.4 for mirroring.</p> <p>We use a secondary repository on our build server to run CruiseControl.NET against, but the mirrored repository is read-only.</p>
2,975
<p>When considering enclosures able to reach higher chamber temperatures, insulation is essential to keep the heater power low.</p> <p>Typical insulation materials are not transparent: cork (fire retardant, good for the inner hot side), rock wool, styrofoam panels, aluminium insulating panels (aluminium walls with foam in between).</p> <p>Still, most of the time it's preferable to have one side of the enclosure transparent, to see what is happening inside without having to use a webcam (which may not work well or which may have a reduced lifespan when operated at 60-80 °C, due to capacitors and thermal noise in the sensor).</p> <p>Rock wool, styrofoam panels and cork all offer about 0.032-0.038 W/(m K) thermal conductivity. In other words, a panel which is 50 * 50 * 1 cm will require about 0.85 W per each °C of temperature increase, or 8.5 W per 10 °C. A cubic 50 * 50 * 50 cm enclosure 2 cm thick would require 26 W to increase the inner temperature by 10 °C.</p> <p>Replacing just one side with a transparent acrylic panel 3 mm thick would push the power requirement to about 190 W for every 10 °C of temperature increase, therefore finding a transparent insulation would be quite interesting.</p> <p><strong>What are the options to have a transparent, but still reasonably insulating, panel?</strong></p>
<p>Unfortunately there are very little solutions for fully transparent and thermally insulating materials. You may be able to use panels commonly used for greenhouses and hydroponics if you can accept losing full transparency and only being translucent. Another option may be to have <strong>two layers of your transparent material</strong>, with an air-gap in between, as dry and still air is a very good thermal insulator.</p>
<p>How about using thermally insulating transparent silicone rubber sheets?</p>
1,982
<p>Html Textarea elements only wrap when they reach a space or tab character. This is fine, until the user types a looooooooooooooooooooooong enough word. I'm looking for a way to strictly enforce line breaks (eg.: even if it results in "loooooooooooo \n ooooooooooong").</p> <p><img src="https://i.stack.imgur.com/sUmHB.png" alt="alt text"></p> <p>The best I've found is to add a zero-width unicode space after every letter, but this breaks copy and paste operations. Anyone know of a better way?</p> <p>Note: I'm referring to the "textarea" element here (i.e.: the one that behaves similarly to a text input) - not just a plain old block of text.</p>
<p>The CSS settings <code>word-wrap:break-word</code> and <code>text-wrap:unrestricted</code> appear to be CSS 3 features. Good luck finding a way to do this on current implementations.</p>
<p>I tested the <strong>&lt;wbr&gt;</strong>, <strong>&amp;#8203;</strong> and <strong>&amp;shy;</strong> techniques. All three worked well in IE 7, Firefox 3 and Chrome. </p> <p>The only one that did not break the copy/paste was the <strong>&lt;wbr&gt;</strong> tag.</p>
7,007
<p>Everyone I work with is obsessed with the data-centric approach to enterprise development and hates the idea of using custom collections/objects. What is the best way to convince them otherwise?</p>
<p>Do it by example and tread lightly. Anything stronger will just alienate you from the rest of the team.</p> <p>Remember to consider the possibility that they're onto something you've missed. Being part of a team means taking turns learning &amp; teaching.</p> <p>No single person has all the answers.</p>
<p>There is already some very good advice here but you'll still have a job to convince your colleagues if all you have to back you up is a few supportive comments on stackoverflow. And, if they are as sceptical as they sound, you are going to need more ammo. First, get a copy of Martin Fowler's "Patterns of Enterprise Architecture" which contains a detailed analysis of a variety of data access techniques. Read it. Then force them all to read it. </p> <p>Job done. </p>
5,804
<p>My application uses 2.0. At some point in the future I may want to start using newer features added in later framework versions. Should I wait until then? Or are there advantages to updating to the latest .NET 3.5 now?</p> <p>I suppose by the time I am ready for next spring's release 4.0 will be out. Perhaps I should stick with 2.0 for my fall release and save my customers the HD space and install time of another framework version?</p>
<p>In my opinion, you should ship with what your app needs. Otherwise you are making your install longer for no reason and as you noted using your customer's HD space again essentially for no reason.</p>
<p>I appreciate the new language features in .NET 3.5 but until you're making use of them I would avoid upgrading to the latest runtime as it is a larger file / install that your users may have to deal with.</p>
8,143
<p>What Direct3D render states should be used to implement Java's Porter-Duff compositing rules (CLEAR, SRC, SRCOVER, etc.)?</p>
<p>I'm haven't used Java too much, but based on the <a href="http://keithp.com/~keithp/porterduff/p253-porter.pdf" rel="nofollow noreferrer">white paper from 1984</a>, it should be a fairly straightforward mapping of render state blend modes.</p> <p>There are of course more that you can do than just these, like normal alpha blending (SourceAlpha, InvSourceAlpha) or additive (One, One) to name a few. <em>(I assume that you are asking about these specifically because you are porting some existing functionality? In that cause you may not care about other combinations...)</em></p> <p>Anyway, these assume a BlendOperation of Add and that AlphaBlendEnable is true.</p> <p>Clear</p> <pre><code>SourceBlend = Zero DestinationBlend = Zero </code></pre> <p>A</p> <pre><code>SourceBlend = One DestinationBlend = Zero </code></pre> <p>B</p> <pre><code>SourceBlend = Zero DestinationBlend = One </code></pre> <p>A over B</p> <pre><code>SourceBlend = One DestinationBlend = InvSourceAlpha </code></pre> <p>B over A</p> <pre><code>SourceBlend = InvDestinationAlpha DestinationBlend = One </code></pre> <p>A in B</p> <pre><code>SourceBlend = DestinationAlpha DestinationBlend = One </code></pre> <p>B in A</p> <pre><code>SourceBlend = Zero DestinationBlend = SourceAlpha </code></pre> <p>A out B</p> <pre><code>SourceBlend = InvDestinationAlpha DestinationBlend = Zero </code></pre> <p>B out A</p> <pre><code>SourceBlend = Zero DestinationBlend = InvSourceAlpha </code></pre> <p>A atop B</p> <pre><code>SourceBlend = DestinationAlpha DestinationBlend = InvSourceAlpha </code></pre> <p>B atop A</p> <pre><code>SourceBlend = InvDestinationAlpha DestinationBlend = SourceAlpha </code></pre> <p>A xor B</p> <pre><code>SourceBlend = InvDestinationAlpha DestinationBlend = InvSourceAlpha </code></pre> <p>Chaining these is a little more complex and would require either multiple passes or multiple texture inputs to a shader.</p>
<p>When I implement the render states for "A" (that is paint the source pixel color/alpha and ignore the destination pixel color/alpha), Direct3D doesn't seem to perform the operation correctly if the source has an alpha value of zero. Instead of filling the target area with transparency, I'm seeing the target area remain unchanged. However, if I change the source alpha value to 1, the target area becomes "virtually" transparent. This happens even when I disable the alphablending render state, so I would presume this is an attempt at optimization that's actually a bug in Direct3D.</p> <p>Except for this situation, it would appear that Corey's render states are correct. Thanks, Corey!</p>
8,816
<p>I'm creating a reverse Bowden setup to guide my filament from spool to extruder, through a path which contains two <a href="http://amzn.eu/almYaNi" rel="nofollow noreferrer">couplers</a> in the middle as follows:</p> <p><code>[spool] --- |#= --- =#| --- [extruder]</code></p> <p>So I have to connect a tube to the <em>back</em> of a coupler (<code>---=#|</code>) and not just to the front (<code>---|#=</code>). That's the end that contains the screw thread, and it's not designed to take a tube. I can't manage to make it a smooth transition. When I try to push my 1.75&nbsp;mm filament through, it will often get stuck there. After it's through, the extruder seems to have no problem with it anymore.</p> <p>Is there a trick to making this a smooth transition?</p>
<p>The solution might be to countersink the opening at the threaded portion within the tube. There are various angles available for countersinks, although the more common angles are 82 degrees and 90 degrees.</p> <p>Drive the countersink to the point where the wall thickness is zero, unlike the drawing below showing some material outside the beveled area.</p> <p><a href="https://i.stack.imgur.com/WCXhM.png" rel="nofollow noreferrer" title="Cross section of center bit drilled holes"><img src="https://i.stack.imgur.com/WCXhM.png" alt="enter image description here" title="Cross section of center bit drilled holes"></a></p> <p>For your purposes, you'd want the steepest angle possible, the 60 degree tool. If you decided to purchase a countersink, pick a diameter slightly larger than the outside diameter of the wall thickness of the coupler. You could use a countersink of the same diameter as the outside diameter of the threads. </p> <p>Center drills are available with 60 degree angles as well: <a href="https://rads.stackoverflow.com/amzn/click/com/B00M54BPRQ" rel="nofollow noreferrer" rel="nofollow noreferrer">Amazon specific item</a> <a href="https://i.stack.imgur.com/6edXI.jpg" rel="nofollow noreferrer" title="Center drill bits"><img src="https://i.stack.imgur.com/6edXI.jpg" alt="enter image description here" title="Center drill bits"></a></p> <p>The second smallest center drill listed here has a 1.5&nbsp;mm center point with a 4&nbsp;mm drill point. If your coupling is larger than 4&nbsp;mm, the next size up will not work as well, as the center point is 2.5&nbsp;mm. You'd have to resort to a countersink only.</p> <p>If you are near a machine shop or have a friend with a mill or even a decent drill press, those resources may be able to perform the countersink for a minimal (or possibly zero) fee.</p> <p>I have a mini-mill and a collection of countersinks as well as center drills. I found my bag of unused couplers. They are for 5&nbsp;mm tubing and were flat on the threaded end. This is the result after a quick trip to the mill. It appears in the close up that I could have driven the center drill deeper into the fitting, and also cleaned off the swarf a bit as well. </p> <p><a href="https://i.stack.imgur.com/t6WTO.jpg" rel="nofollow noreferrer" title="Chamfered inner hole backside of the pneumatic coupler"><img src="https://i.stack.imgur.com/t6WTO.jpg" alt="Chamfered inner hole backside of the pneumatic coupler" title="Chamfered inner hole backside of the pneumatic coupler"></a></p>
<p>An alternative to chamfering the connector is buying a different type of connectors with a larger bore hole all the way through the connector and let the tube pass all the way through. These are used in my similar spool to extruder setup (reversed Bowden setup in OP's terminology).</p> <p><a href="https://i.stack.imgur.com/cZi6Z.png" rel="nofollow noreferrer" title="Large hole pneumatic tube connector"><img src="https://i.stack.imgur.com/cZi6Z.png" alt="Large hole pneumatic tube connector" title="Large hole pneumatic tube connector"></a></p>
490
<p>I have an SLA printed part I want to put a brass threaded insert in using a soldering iron. The insert is slightly larger than the hole so I would assume the edge will melt and re-freeze around the teeth. Are there any issues with melting SLA or this idea in general? </p>
<p>The plastic used in SLA printing is what is known as a <em>thermoset</em> plastic, as opposed to the <em>thermoplastic</em> plastics used in FDM printing. What this means, is that it <em>can not be melted</em>. The reaction that hardens SLA materials is irreversible. If you heat up the plastic it won't melt, it will just burn (if it gets hot enough). What you're planning is a bad idea, and it won't work.</p>
<p>Is it possible to make the hole larger, put the brass insert with a pre-installed screw inside the hole, fill the area with resin and cure with UV lamp?</p>
1,066
<p>I have to POST some parameters to a URL outside my network, and the developers on the other side asked me to not use HTTP Parameters: instead I have to post my key-values in <strong>HTTP Headers</strong>.</p> <p>The fact is that I don't really understand what they mean: I tried to use a ajax-like post, with XmlHttp objects, and also I tried to write in the header with something like</p> <pre><code>Request.Headers.Add(key,value); </code></pre> <p>but I cannot (exception from the framework); I tried the other way around, using the Response object like</p> <pre><code>Response.AppendHeader("key", "value"); </code></pre> <p>and then redirect to the page... but this doesn't work, as well.</p> <p>It's evident, I think, that I'm stuck there, any help?</p> <hr> <p><strong>EDIT</strong> I forgot to tell you that my environment is .Net 2.0, c#, on Win server 2003. The exception I got is</p> <pre><code>System.PlatformNotSupportedException was unhandled by user code Message="Operation is not supported on this platform." Source="System.Web" </code></pre> <p>This looks like it's caused by my tentative to Request.Add, MS an year ago published some security fixes that don't permit this. </p>
<p>Like @lassevk said, a redirect won't work.</p> <p>You should use the WebRequest class to do an HTTP POST from your page or application. There's an example <a href="http://msdn.microsoft.com/en-us/library/debx8sh9.aspx" rel="nofollow noreferrer">here</a>.</p>
<p>You should post more information.</p> <p>For instance, is this C#? It looks like it, but I might be wrong.</p> <p>Also, you say you get an exception, what is the exception type and message?</p> <p>In any case, you can't redirect to a page for POST, you need to submit it from the browser, not from the server redirect, so if you want to automate this, I would guess you would need to generate a html page with a form tag, with some hidden input fields, and then submit it with javascript.</p>
6,167
<p>Heads up: I'm not good with electronics and only have a vague idea of it's inner workings.</p> <p>I have a <a href="https://ru.aliexpress.com/item/3D-Printer-V6-Wade-Short-distance-J-head-Hotend-12V-for-1-75mm-3-0mm-Extruder/32810022530.html?spm=a2g0v.10010108.1000016.1.197a7c35uzmRpw&amp;isOrigTitle=true" rel="noreferrer">E3D V6 Extruder rated for 24&nbsp;V</a>, that i plan to use in my 3D printer. Will there be any problems with it if powered by 12&nbsp;V? Will it take longer to heat up? Will it be able to heat up enough to melt PLA? Will it work at all for that matter? If there are any other quirks or potential problems that I overlooked, please let me know.</p>
<p>Electrical engineering can be quite complex, but in this case you can save yourself with same simple equations/relations. Using the following formulae:</p> <ul> <li><strong><em>Voltage (<span class="math-container">$\ U$</span>) equals current (<span class="math-container">$I$</span>) multiplied by the electrical resistance (<span class="math-container">$R$</span>)</em></strong></li> </ul> <p><span class="math-container">$$ U=I \times R $$</span> </p> <p>and </p> <ul> <li><strong><em>Power (<span class="math-container">$P$</span>) equals the square of the current multiplied by the electrical resistance</em></strong></li> </ul> <p><span class="math-container">$$ P=I^2 \times R $$</span> can be rewritten using the first formula to: <span class="math-container">$$ P= \frac{U^2}{R} $$</span></p> <p>Applying these formulae to a <strong>40&nbsp;Watt, 24&nbsp;V</strong> heater element, the electrical resistance (in <span class="math-container">$\Omega $</span>) is calculated by: <span class="math-container">$$ \frac{{(24\ V)}^2}{40\ W}=14.4\ \Omega $$</span></p> <p>Running this heater element with 12&nbsp;V will lead to a power of <span class="math-container">$$ \frac{{(12\ V)}^2}{14.4\ \Omega}=10\ W $$</span> </p> <p>The heat produced is proportional to the square of the current multiplied by the electrical resistance, <strong><em>halving the voltage</em></strong> is <strong><em>quartering the heat output</em></strong>. This will heat up very slowly! If it is able to reach the required temperature that is. Calculating the temperature is far more difficult, but if you are interested in doing so, please look into <a href="https://electronics.stackexchange.com/a/33009/">this answer</a> from the <a href="https://electronics.stackexchange.com/">Electrical Engineering</a> Stack Exchange.</p>
<p>It will take longer to heat up. However if you use a <a href="https://rads.stackoverflow.com/amzn/click/com/B06XWSV89D" rel="nofollow noreferrer" rel="nofollow noreferrer">boost converter</a> (like I did on my Anet A8 when I upgraded to a <a href="https://www.hot-end.com/" rel="nofollow noreferrer">Maxiwatt</a> 24&nbsp;V hot end), then it will work just fine without any further adjustments; to the power supply or the gauges of the wire etc. I set the boost from 12 to 24 volts. Now my A8 heats up in 56 seconds!</p>
1,207
<p>I have a table which is full of arbitrarily formatted phone numbers, like this</p> <pre><code>027 123 5644 021 393-5593 (07) 123 456 042123456 </code></pre> <p>I need to search for a phone number in a similarly arbitrary format ( e.g. <code>07123456</code> should find the entry <code>(07) 123 456</code></p> <p>The way I'd do this in a normal programming language is to strip all the non-digit characters out of the 'needle', then go through each number in the haystack, strip all non-digit characters out of it, then compare against the needle, eg (in ruby)</p> <pre><code>digits_only = lambda{ |n| n.gsub /[^\d]/, '' } needle = digits_only[input_phone_number] haystack.map(&amp;digits_only).include?(needle) </code></pre> <p>The catch is, I need to do this in MySQL. It has a host of string functions, none of which really seem to do what I want.</p> <p>Currently I can think of 2 'solutions'</p> <ul> <li>Hack together a franken-query of <code>CONCAT</code> and <code>SUBSTR</code></li> <li>Insert a <code>%</code> between every character of the needle ( so it's like this: <code>%0%7%1%2%3%4%5%6%</code> )</li> </ul> <p>However, neither of these seem like particularly elegant solutions.<br /> Hopefully someone can help or I might be forced to use the %%%%%% solution</p> <h3>Update: This is operating over a relatively fixed set of data, with maybe a few hundred rows. I just didn't want to do something ridiculously bad that future programmers would cry over.</h3> <p>If the dataset grows I'll take the 'phoneStripped' approach. Thanks for all the feedback!</p> <hr /> <blockquote> <p>could you use a &quot;replace&quot; function to strip out any instances of &quot;(&quot;, &quot;-&quot; and &quot; &quot;,</p> </blockquote> <p>I'm not concerned about the result being numeric. The main characters I need to consider are <code>+</code>, <code>-</code>, <code>(</code>, <code>)</code> and <code>space</code> So would that solution look like this?</p> <pre><code>SELECT * FROM people WHERE REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(phonenumber, '('),')'),'-'),' '),'+') LIKE '123456' </code></pre> <p>Wouldn't that be terribly slow?</p>
<p>This looks like a problem from the start. Any kind of searching you do will require a table scan and we all know that's bad.</p> <p>How about adding a column with a hash of the current phone numbers after stripping out all formatting characters. Then you can at least index the hash values and avoid a full blown table scan.</p> <p>Or is the amount of data small and not expected to grow much? Then maybe just sucking all the numbers into the client and running a search there.</p>
<blockquote> <p>MySQL can search based on regular expressions.</p> </blockquote> <p>Sure, but given the arbitrary formatting, if my haystack contained <code>"(027) 123 456"</code> (bear in mind position of spaces can change, it could just as easily be <code>027 12 3456</code> and I wanted to match it with <code>027123456</code>, would my regex therefore need to be this?</p> <pre><code>"^[\D]+0[\D]+2[\D]+7[\D]+1[\D]+2[\D]+3[\D]+4[\D]+5[\D]+6$" </code></pre> <p>(actually it'd be worse as the mysql manual doesn't seem to indicate it supports <code>\D</code>)</p> <p>If that is the case, isn't it more or less the same as my %%%%% idea?</p>
6,215
<p>I was looking out for a free plugin for developing/debugging JSP pages in eclipse.<br> Any suggestions? </p>
<p>The <a href="http://wiki.eclipse.org/Category:Eclipse_Web_Tools_Platform_Project" rel="noreferrer">Eclipse Web Tools Platform Project</a> includes a JSP debugger. I have only ever needed to use it with Tomcat so I cannot say how well it works with other servlet containers.</p>
<p>The former BEA Workshop is now <a href="http://www.oracle.com/technology/software/products/ias/bea_main.html#devtools" rel="nofollow noreferrer">Oracle Workshop</a>. It is the best JSP editor with WYSIWYG support and it is free. It is not specific to WebLogic. Basic JSP editing is server neutral anyway. However, it supports launching and debugging on many servers.</p> <p>You can read my <a href="http://blog.zvikico.com/2008/08/the-best-jspstrutsjsf-development-tool-is-now-free.html" rel="nofollow noreferrer">blog post</a> about it.</p>
7,064
<p>PHP has a great function called <a href="http://us2.php.net/manual/en/function.htmlspecialchars.php" rel="noreferrer">htmlspecialcharacters()</a> where you pass it a string and it replaces all of HTML's special characters with their safe equivalents, it's <em>almost</em> a one stop shop for sanitizing input. Very nice right?</p> <p>Well is there an equivalent in any of the .NET libraries?</p> <p>If not, can anyone link to any code samples or libraries that do this well?</p>
<p>Try this.</p> <pre><code>var encodedHtml = HttpContext.Current.Server.HtmlEncode(...); </code></pre>
<p>In an addition to the given answers: When using <a href="http://en.wikipedia.org/wiki/ASP.NET_Razor_view_engine" rel="nofollow">Razor view engine</a> (which is the default view engine in ASP.NET), using the '@' character to display values will automatically encode the displayed value. This means that you don't have to use encoding.</p> <p>On the other hand, when you <strong>don't</strong> want the text being encoded, you have to specify that explicitly (by using <a href="https://msdn.microsoft.com/en-us/library/gg480740%28v=vs.118%29.aspx" rel="nofollow">@Html.Raw</a>). Which is, in my opinion, a good thing from a security point of view.</p>
3,747
<p>How do I set a property of a user control in <code>ListView</code>'s <code>LayoutTemplate</code> from the code-behind?</p> <pre><code>&lt;asp:ListView ...&gt; &lt;LayoutTemplate&gt; &lt;myprefix:MyControl id="myControl" ... /&gt; &lt;/LayoutTemplate&gt; ... &lt;/asp:ListView&gt; </code></pre> <p>I want to do this:</p> <pre><code>myControl.SomeProperty = somevalue; </code></pre> <p>Please notice that my control is not in <code>ItemTemplate</code>, it is in <code>LayoutTemplate</code>, so it does not exist for all items, it exists only once. So I should be able to access it once, not for every data bound item.</p>
<p>To set a property of a control that is inside the LayoutTemplate, simply use the FindControl method on the ListView control.</p> <pre><code>var control = (MyControl)myListView.FindControl("myControlId"); </code></pre>
<p>The layout gets created, and fires a LayoutCreated event that says the layout has been created in the system.</p> <p>Then, you can use listview.FindControl to get a reference to that control.</p>
7,109
<p>In order to merge independant HTML changes, I'm looking for recomendations for a 3-way comparison / merge library for HTML. The common 3-way text merge algorithms perform poorly because they do not understand the tree like structure of HTML and XML. Of course, such a library must understand the looser syntax of HTML, i.e. tags are not always closed. My platform is .Net.</p>
<p>You could also just go cheep: Run the files through <a href="http://tidy.sourceforge.net/" rel="nofollow noreferrer">tidy</a> and then compare. This will result in similar structures, where new / deleted children will show up with traditional diff tools. It breaks down on removal / addition of surrounding nodes - good luck on solving that one...</p> <p>Also, the <a href="http://www.snapfiles.com/get/xmlnotepad.html" rel="nofollow noreferrer">XML Notepad</a> (sorry, couldn't find a link that works on microsoft.com) by Microsoft can compare XML files and does this in a tree based fashion.</p>
<p>A simple google search offered up: <a href="http://www.codeproject.com/KB/cs/differ.aspx" rel="nofollow noreferrer">Differ</a>. I've never used it so I can't vouch for the quality of that :-)</p>
9,120
<p>I recently upgraded my Creality Ender 5 with an SKR Mini E3 V2.0 running Marlin 2.0.7.2. The printer has also been modified with an all-metal hotend and a direct drive conversion kit that uses the extruder stepper motor. In test prints of the XYZ calibration cube, I have found that the edges of the cube are rounded over. After some research, it appears this is due to either the acceleration/jerk settings or the junction deviation settings.</p> <p>The issue now comes in that no matter what setting I change, the prints do not change. Currently in the Marlin firmware, I found that the Classic Jerk is disabled in Configuration.h line ~786. The default JUNCTION_DEVIATION_MM is 0.013. Since Classic Jerk is disabled, Junction Deviation shows up in the menu under Menu --&gt; Configuration --&gt; Advanced Settings. I printed 4 cubes for 4 different Junction Deviation settings: 0.013, 0.075, 0.130, 0.300. All cubes have the same characteristic over-corrected corner with no visible changes (Picture below) <a href="https://i.stack.imgur.com/eue3y.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/eue3y.jpg" alt="enter image description here" /></a></p> <p>My questions are:</p> <ul> <li>Why aren't the prints being affected by changing the Junction Deviation setting via the menu? The Junction Deviation setting is stored in memory using Menu --&gt; Configuration --&gt; Store Settings and I have confirmed the values remain in memory after cycling the printer.</li> <li>If Classic Jerk is disabled in Marlin firmware, would an M205 X[Jerk] Y[Jerk] Z[Jerk] command before a print enable Classic Jerk for that print?</li> <li>What happens if an M205 command is sent that sets XYZ as well as J? (e.g. M205 X[Jerk] Y[Jerk] Z[Jerk] J[Dev]). Would it ignore Classic Jerk values if Classic Jerk is disabled in firmware?</li> </ul> <p>I have read through the following posts already</p> <ul> <li><a href="https://3dprinting.stackexchange.com/questions/11261/setting-junction-deviation-in-firmware-has-no-effect">Setting Junction Deviation in firmware has no effect</a></li> <li><a href="https://reprap.org/forum/read.php?1,739819" rel="noreferrer">https://reprap.org/forum/read.php?1,739819</a></li> <li><a href="https://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html" rel="noreferrer">https://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html</a></li> <li><a href="https://www.reddit.com/r/3Dprinting/comments/dx8bd/here_is_why_you_should_disable_junction_deviation/" rel="noreferrer">https://www.reddit.com/r/3Dprinting/comments/dx8bd/here_is_why_you_should_disable_junction_deviation/</a></li> </ul> <p>My next steps:</p> <ul> <li>Re-enable Classic Jerk in Marlin and see if the print behavior changes</li> <li>Other?</li> </ul>
<p>Contrary to what's implied by its name, <em>junction deviation</em> does not produce rounded corners. It merely allows violations of the acceleration profile at corners that would be allowed <em>if the corner were rounded</em> by the deviation. So you should not expect changes to it to create or eliminate unwanted &quot;rounded corners&quot;.</p> <p>However I don't think what you're seeing are rounded corners. They're <em>bulging</em> corners, likely produced as a consequence of the toolhead moving slower just before and after the corner in order to honor the acceleration profile. My guess is that your acceleration limits in Marlin 2.0 (500 mm/s² if I recall correctly) are a lot lower than on the original Creality firmware.</p> <p>You can and probably should increase the acceleration limits. The machine should handle 1000 mm/s² easily and up to 3000 mm/s² or even higher with some ringing; I use lower acceleration for the outer walls and let it run wild for inner walls and infill. But the real solution to your bulging corners problem is to enable and calibrate <a href="https://marlinfw.org/docs/features/lin_advance.html" rel="nofollow noreferrer">Linear Advance</a> to get a consistent extrusion rate with varing speed. For my Ender 3, the right constant is around 0.5-0.6 s (yes the units are seconds - it's mm/(mm/s)) for PLA. You can use the <a href="http://marlinfw.org/tools/lin_advance/k-factor.html" rel="nofollow noreferrer">calibration pattern generator</a> to run the calibration yourself, but I would expect the same results.</p> <p>This will significantly impact your print speed, since Marlin applies E-axis speed, acceleration, and jerk limits to the advance offsets. You can get a lot of it back though by increasing those limits though; the defaults are a whole lot lower than what the machine can handle. 200 mm/s speed limit and 10000-15000 mm/s² acceleration limit (vs 25 and 5000 defaults in Marlin, respectively) are within reason.</p>
<p>When a junction deviation is set too low it will mess up every other thing you have been trying to do to perfect your extrusion.</p> <p>It messes up</p> <ul> <li>retraction,</li> <li>linear advance,</li> <li>s-curve,</li> <li>the entire print.</li> </ul> <p>I had been messing around with my jerk and acceleration values, my retraction values, and my linear advance values, and no matter what I did, nothing fixed the actual issues. I even gave up on Bowden and tomorrow a Hemera direct drive will be delivered.</p> <p>Now I found this setting in my printer menu, changed the value from 0.017 to 0.2 and those bulging corners are now gone (in fact I had to up my linear advance a bit because it was actually rounding off the corners making them too thin).</p> <p>The stringing is gone now as well (low jerk on retraction and you might as well not retract at all).</p> <p>Seriously, unless you are using a CNC or CoreXY, I don't see why you would even use junction deviation.</p> <p>As to why nothing is changing for you, this is because other settings are bad as well. So it's still slowing down too much in the corners while material is still oozing out.</p>
1,805
<p>I want to be able to get an estimate of how much code &amp; static data is used by my C++ program?</p> <p>Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime?</p> <p>Will otool help?</p>
<ul> <li>"size" is the traditional tool and works on all unix flavors. </li> <li>"otool" has a bit finer grain control and has a lot of options.</li> </ul> <p>.</p> <pre><code>$ size python __TEXT __DATA __OBJC others dec hex 860160 159744 0 2453504 3473408 350000 </code></pre>
<p>I think otool can help. Specifically, "otool -s {segment} {section}" should print out the details. I'm not sure if you can get information about __DATA or __TEXT without specifying a section. Maybe those sizes are reported in the mach header: "otool -h"?</p> <pre><code>otool -s __DATA __data MyApp.bundle/Contents/MacOS/MyApp otool -s __TEXT __text MyApp.bundle/Contents/MacOS/MyApp </code></pre> <p>Anyway, Apple documents what gets copied into each section per-segment here: <a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html#//apple_ref/doc/uid/TP40000895-CH248-95874" rel="nofollow noreferrer">Apple's mach-o format documentation</a></p>
5,599
<p>Is it possible to 3D print a QR code? or to engrave it using a 3D printer? I tried to convert it to individual boxes but that takes too long and is very inaccurate. Is there a better way?</p>
<p>From the excellent Thingiverse link, <a href="https://www.thingiverse.com/thing:4967931" rel="nofollow noreferrer">Customizable QR Keyring or Tag</a> by <a href="https://www.thingiverse.com/outwardb/designs" rel="nofollow noreferrer"><em>OutwardB</em></a> - which was provided in the (now deleted) <a href="https://3dprinting.stackexchange.com/a/18296/4762">link-only answer</a>:</p> <blockquote> <ol> <li><h3>Create the QR code</h3> <ul> <li><p>Go to <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a></p> </li> <li><p><strong>Only change the Content settings</strong></p> <p>DO NOT change the color, logo or design settings</p> </li> <li><p>Click <strong>Create QR Code</strong></p> </li> <li><p>Click <strong>Download PNG</strong> and wait for the file to download</p> </li> </ul> </li> <li><h3>Convert to SVG</h3> <ul> <li>Go to <a href="https://convertio.co/png-svg/" rel="nofollow noreferrer">PNG to SVG Converter</a> and convert the PNG image you just downloaded to a .SVG file</li> </ul> </li> <li><h3>Customise in OpenSCAD</h3> <p>You will need <a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a> from the <a href="https://www.thingiverse.com/thing:4967931/files" rel="nofollow noreferrer">files repository on Thingverse</a></p> <ol> <li><p>Download OpenSCAD from here and install it - <a href="https://openscad.org/downloads.html" rel="nofollow noreferrer">https://openscad.org/downloads.html</a></p> </li> <li><p>Put the downloaded SVG file in the same folder as the .SCAD file from this page</p> </li> <li><p>Double-click the .SCAD file to open it</p> </li> <li><p>Click <strong>Window</strong>, then untick <strong>Hide Customizer</strong></p> <p><em>Optional</em>: Click <strong>Window</strong>, then tick <strong>Hide Editor</strong></p> </li> <li><p>Enter the SVG file name in the basic settings tab (or rename the file to qr-code.svg before opening OpenSCAD)</p> </li> <li><p>Customize the settings. After changing a setting, you may need to click outside the text box to apply the change</p> </li> <li><p>Click <strong>Design</strong> &gt; <strong>Render</strong> and wait for the design to render</p> </li> <li><p>Click <strong>File</strong> &gt; <strong>Export</strong> &gt; <strong>Export to STL</strong></p> </li> <li><p>Save the file</p> </li> </ol> <p><a href="https://i.stack.imgur.com/VyzXZ.gif" rel="nofollow noreferrer" title="QR Customisation - optional"><img src="https://i.stack.imgur.com/VyzXZ.gif" alt="QR Customisation - optional" title="QR Customisation - optional" /></a></p> </li> </ol> <h3>Notes</h3> <ul> <li><strong>Raised</strong> and <strong>Cut-Out</strong> types are for changing filament at layer height</li> <li><strong>Multi-color</strong> and <strong>Code</strong> are to be used together for inlay/multi-color printers</li> <li>You can also set <em>Base Height</em> or <em>Code Height</em> to 0 and export each part on it's own</li> <li>If you want to print a <strong>double sided tag</strong>, you can set <em>Base Height</em> to 0 and export the second side. Then just flip this over in the slicer</li> <li>The text options are a okay for basic text, but if you want to use another program to add some, you can add extra height to the top/bottom of the card under <strong>Extra Size Setting</strong></li> </ul> <h3>Advanced Notes</h3> <ul> <li>There is some logic in the script that stop you from making the size too small if you have Line Size set, you can set Line Size to 0 or half your line size value if you really want to override this.</li> <li>You can change the Customize Design settings before generating the QR Code (on <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a>), but you'll need to set Line Size to 0 and there are no promises that it'll print well</li> <li>If you want to use a different site to create the QR code, resize the image to 1147x1147 pixels before converting it to an SVG. Or if the QR code in the image doesn't have a border, resize it to 1000x1000 px.</li> <li>If you want to use a different source for the SVG file, there are instructions for working out the size in the code (<a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a>) at line 215. You'll need to export it as a STL and measure it outside of OpenSCAD, then enter the values into the script.</li> </ul> </blockquote> <p>The linked to Thingiverse page also has some extra steps for adding an icon:</p> <blockquote> <h3>Add an icon</h3> <p>You can import another SVG file as a logo or use logo fonts.</p> <p>The below example uses an <a href="https://iconmonstr.com/?s=wifi" rel="nofollow noreferrer">wifi SVG file</a> from IconMonstr</p> <ul> <li>Download the wifi SVG file</li> <li>Place it in the same folder as the .SCAD file</li> <li>In the customizer: <ul> <li>Add some extra space to the top or bottom of the card under <strong>Extra Size Settings</strong></li> <li>Go to SVG Logo Settings</li> <li>Tick <strong>enable svg logo</strong></li> <li>Enter the filename under <strong>svg logo name</strong></li> <li>Set the <strong>svg y nudge</strong> position and <strong>svg logo scale</strong></li> </ul> </li> </ul> <p><a href="https://i.stack.imgur.com/A2xCK.png" rel="nofollow noreferrer" title="Adding Wi-Fi logo"><img src="https://i.stack.imgur.com/A2xCK.png" alt="Adding Wi-Fi logo" title="Adding Wi-Fi logo" /></a></p> </blockquote>
<p>From the excellent Thingiverse link, <a href="https://www.thingiverse.com/thing:4967931" rel="nofollow noreferrer">Customizable QR Keyring or Tag</a> by <a href="https://www.thingiverse.com/outwardb/designs" rel="nofollow noreferrer"><em>OutwardB</em></a> - which was provided in the (now deleted) <a href="https://3dprinting.stackexchange.com/a/18296/4762">link-only answer</a>:</p> <blockquote> <ol> <li><h3>Create the QR code</h3> <ul> <li><p>Go to <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a></p> </li> <li><p><strong>Only change the Content settings</strong></p> <p>DO NOT change the color, logo or design settings</p> </li> <li><p>Click <strong>Create QR Code</strong></p> </li> <li><p>Click <strong>Download PNG</strong> and wait for the file to download</p> </li> </ul> </li> <li><h3>Convert to SVG</h3> <ul> <li>Go to <a href="https://convertio.co/png-svg/" rel="nofollow noreferrer">PNG to SVG Converter</a> and convert the PNG image you just downloaded to a .SVG file</li> </ul> </li> <li><h3>Customise in OpenSCAD</h3> <p>You will need <a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a> from the <a href="https://www.thingiverse.com/thing:4967931/files" rel="nofollow noreferrer">files repository on Thingverse</a></p> <ol> <li><p>Download OpenSCAD from here and install it - <a href="https://openscad.org/downloads.html" rel="nofollow noreferrer">https://openscad.org/downloads.html</a></p> </li> <li><p>Put the downloaded SVG file in the same folder as the .SCAD file from this page</p> </li> <li><p>Double-click the .SCAD file to open it</p> </li> <li><p>Click <strong>Window</strong>, then untick <strong>Hide Customizer</strong></p> <p><em>Optional</em>: Click <strong>Window</strong>, then tick <strong>Hide Editor</strong></p> </li> <li><p>Enter the SVG file name in the basic settings tab (or rename the file to qr-code.svg before opening OpenSCAD)</p> </li> <li><p>Customize the settings. After changing a setting, you may need to click outside the text box to apply the change</p> </li> <li><p>Click <strong>Design</strong> &gt; <strong>Render</strong> and wait for the design to render</p> </li> <li><p>Click <strong>File</strong> &gt; <strong>Export</strong> &gt; <strong>Export to STL</strong></p> </li> <li><p>Save the file</p> </li> </ol> <p><a href="https://i.stack.imgur.com/VyzXZ.gif" rel="nofollow noreferrer" title="QR Customisation - optional"><img src="https://i.stack.imgur.com/VyzXZ.gif" alt="QR Customisation - optional" title="QR Customisation - optional" /></a></p> </li> </ol> <h3>Notes</h3> <ul> <li><strong>Raised</strong> and <strong>Cut-Out</strong> types are for changing filament at layer height</li> <li><strong>Multi-color</strong> and <strong>Code</strong> are to be used together for inlay/multi-color printers</li> <li>You can also set <em>Base Height</em> or <em>Code Height</em> to 0 and export each part on it's own</li> <li>If you want to print a <strong>double sided tag</strong>, you can set <em>Base Height</em> to 0 and export the second side. Then just flip this over in the slicer</li> <li>The text options are a okay for basic text, but if you want to use another program to add some, you can add extra height to the top/bottom of the card under <strong>Extra Size Setting</strong></li> </ul> <h3>Advanced Notes</h3> <ul> <li>There is some logic in the script that stop you from making the size too small if you have Line Size set, you can set Line Size to 0 or half your line size value if you really want to override this.</li> <li>You can change the Customize Design settings before generating the QR Code (on <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a>), but you'll need to set Line Size to 0 and there are no promises that it'll print well</li> <li>If you want to use a different site to create the QR code, resize the image to 1147x1147 pixels before converting it to an SVG. Or if the QR code in the image doesn't have a border, resize it to 1000x1000 px.</li> <li>If you want to use a different source for the SVG file, there are instructions for working out the size in the code (<a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a>) at line 215. You'll need to export it as a STL and measure it outside of OpenSCAD, then enter the values into the script.</li> </ul> </blockquote> <p>The linked to Thingiverse page also has some extra steps for adding an icon:</p> <blockquote> <h3>Add an icon</h3> <p>You can import another SVG file as a logo or use logo fonts.</p> <p>The below example uses an <a href="https://iconmonstr.com/?s=wifi" rel="nofollow noreferrer">wifi SVG file</a> from IconMonstr</p> <ul> <li>Download the wifi SVG file</li> <li>Place it in the same folder as the .SCAD file</li> <li>In the customizer: <ul> <li>Add some extra space to the top or bottom of the card under <strong>Extra Size Settings</strong></li> <li>Go to SVG Logo Settings</li> <li>Tick <strong>enable svg logo</strong></li> <li>Enter the filename under <strong>svg logo name</strong></li> <li>Set the <strong>svg y nudge</strong> position and <strong>svg logo scale</strong></li> </ul> </li> </ul> <p><a href="https://i.stack.imgur.com/A2xCK.png" rel="nofollow noreferrer" title="Adding Wi-Fi logo"><img src="https://i.stack.imgur.com/A2xCK.png" alt="Adding Wi-Fi logo" title="Adding Wi-Fi logo" /></a></p> </blockquote>
2,044
<p>Here is an extreme example of notches caused by the printer. They go along all sides but are the strongest on the Y faces. They also happen quite randomly sometimes they are tiny sometimes they are strong. </p> <p><a href="https://i.stack.imgur.com/VQ7Sr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VQ7Sr.jpg" alt="enter image description here"></a></p> <p>I have tightened the belts already and while that reduced the ghosting on the X face a lot, it did nothing on the Y and actually never helped with the notches. This test cube has notches and ripples too but not that strong (the skirting on the bottom of that cube is my fault I set the bed level a little too low).</p> <p><a href="https://i.stack.imgur.com/ZJDG4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZJDG4.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/968jC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/968jC.jpg" alt="enter image description here"></a></p> <p>All models have been sliced with Ultimaker Cura and printed on an Anet A8. Flow = 110&nbsp;%, layer height of 0.1&nbsp;mm for the first example and 0.2&nbsp;mm for the cube, printing temperature = 195&nbsp;°C, no change on jerking and acceleration from default settings. Cube size = 20x20x20&nbsp;mm.</p> <p>The printer has frame support <a href="https://www.thingiverse.com/thing:1672959" rel="nofollow noreferrer">https://www.thingiverse.com/thing:1672959</a> but no other upgrades yet.</p>
<p>I see two problems with your printer: your filament seems to overheat in some areas, and you overextrude a little. My suspicion is, that your heating behavior is not well tuned and it overshoots the target temperature, leading to an overcooked filament, then the temperature drops below the temperature you need, leading to a wavy pattern and brown lines.</p> <h2>fixing</h2> <p>I suggest running a PID-tune cycle to get better heating behavior and then recalibrating the printer's extruder.</p>
<p>I noticed that thermistors provided with Chinese kits are not up to specs. Do yourself a favor and go to mouser or digikey and order a proper thermistor that is rated for the temperature range in question.</p>
1,229
<p>As a self-taught computer programmer, I'm often at a loss to estimate the O() value for a particular operation. Yeah, I know off the top of my head most of the important ones, like for the major sorts and searches, but I don't know how to calculate one when something new comes along, unless it's blindingly obvious. Is there a good web site or text that explains how to do that? Heck, I don't even know what computer scientists call it, so I can't google it.</p>
<p>It's called <a href="http://en.wikipedia.org/wiki/Big_O_notation" rel="nofollow noreferrer">Big O Notation</a>, and it's used in <a href="http://en.wikipedia.org/wiki/Computational_complexity_theory" rel="nofollow noreferrer">Computational Complexity Theory</a>.</p> <p>The wikipedia articles are a pretty good starting point, as are the bibliography at the bottom of the page.</p>
<blockquote> <p><em>Your links takes me to a site in</em> <em>Russian that seems to want a userid</em> <em>and password. Legitimate mistake, or</em> <em>troll? Paul Tomblin</em></p> </blockquote> <p>The site is in Bulgarian and you shouldn't need a password to access the list of files I linked to and download some of them. Unless of course there is an access restiction for IPs from outside Bulgaria, which I really don't know.</p> <p>Sorry, I don't know how to make a comment.</p>
8,820
<p>What are the best methods for tracking and/or automating DB schema changes? Our team uses Subversion for version control and we've been able to automate some of our tasks this way (pushing builds up to a staging server, deploying tested code to a production server) but we're still doing database updates manually. I would like to find or create a solution that allows us to work efficiently across servers with different environments while continuing to use Subversion as a backend through which code and DB updates are pushed around to various servers.</p> <p>Many popular software packages include auto-update scripts which detect DB version and apply the necessary changes. Is this the best way to do this even on a larger scale (across multiple projects and sometimes multiple environments and languages)? If so, is there any existing code out there that simplifies the process or is it best just to roll our own solution? Has anyone implemented something similar before and integrated it into Subversion post-commit hooks, or is this a bad idea?</p> <p>While a solution that supports multiple platforms would be preferable, we definitely need to support the Linux/Apache/MySQL/PHP stack as the majority of our work is on that platform.</p>
<p>In the Rails world, there's the concept of migrations, scripts in which changes to the database are made in Ruby rather than a database-specific flavour of SQL. Your Ruby migration code ends up being converted into the DDL specific to your current database; this makes switching database platforms very easy. </p> <p>For every change you make to the database, you write a new migration. Migrations typically have two methods: an "up" method in which the changes are applied and a "down" method in which the changes are undone. A single command brings the database up to date, and can also be used to bring the database to a specific version of the schema. In Rails, migrations are kept in their own directory in the project directory and get checked into version control just like any other project code.</p> <p><a href="http://www.oracle.com/technology/pub/articles/kern-rails-migrations.html" rel="noreferrer" title="Oracle guide to Ruby on Rails migrations">This Oracle guide to Rails migrations</a> covers migrations quite well.</p> <p>Developers using other languages have looked at migrations and have implemented their own language-specific versions. I know of <strong><a href="https://github.com/ruckus/ruckusing-migrations" rel="noreferrer" title="Ruckusing">Ruckusing</a></strong>, a PHP migrations system that is modelled after Rails' migrations; it might be what you're looking for.</p>
<p>There is a command-line <a href="http://bitbucket.org/stepancheg/mysql-diff/" rel="nofollow noreferrer">mysql-diff</a> tool that compares database schemas, where schema can be a live database or SQL script on disk. It is good for the most schema migration tasks.</p>
2,393
<p>I'm trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have this string:</p> <pre><code>12||34||56 </code></pre> <p>I want to replace the second set of pipes with ampersands to get this string:</p> <pre><code>12||34&amp;&amp;56 </code></pre> <p>The regex function needs to be able to handle x amount of pipes and allow me to replace the nth set of pipes, so I could use the same function to make these replacements:</p> <pre><code>23||45||45||56||67 -&gt; 23&amp;&amp;45||45||56||67 23||34||98||87 -&gt; 23||34||98&amp;&amp;87 </code></pre> <p>I know that I could just split/replace/concat the string at the pipes, and I also know that I can match on <code>/\|\|/</code> and iterate through the resulting array, but I'm interested to know if it's possible to write a single expression that can do this. Note that this would be for Javascript, so it's possible to generate a regex at runtime using <code>eval()</code>, but it's not possible to use any Perl-specific regex instructions.</p>
<p>here's something that works:</p> <pre><code>"23||45||45||56||67".replace(/^((?:[0-9]+\|\|){n})([0-9]+)\|\|/,"$1$2&amp;&amp;") </code></pre> <p>where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0)</p> <p>And if you'd like a function to do this:</p> <pre><code>function pipe_replace(str,n) { var RE = new RegExp("^((?:[0-9]+\\|\\|){" + (n-1) + "})([0-9]+)\|\|"); return str.replace(RE,"$1$2&amp;&amp;"); } </code></pre>
<p>Thanks Binda, I have modified the code for generic uses:</p> <pre><code>private replaceNthMatch(original, pattern, n, replace) { let m = -1; return original.replaceAll(pattern, x =&gt; { m++; if ( n == m ) { return replace; } else { return x; } }); } </code></pre>
5,687
<p>If you were running a news site that created a list of 10 top news stories, and you wanted to make tweaks to your algorithm and see if people liked the new top story mix better, how would you approach this? </p> <p>Simple Click logging in the DB associated with the post entry? </p> <p>A/B testing where you would show one version of the algorithm togroup A and another to group B and measure the clicks? </p> <p>What sort of characteristics would you base your decision on as to whether the changes were better? </p>
<p>Thirding <a href="https://github.com/mono/taglib-sharp" rel="noreferrer">TagLib Sharp</a>.</p> <pre><code>TagLib.File f = TagLib.File.Create(path); f.Tag.Album = "New Album Title"; f.Save(); </code></pre>
<p>I wrapped mp3 decoder library and made it available for .net developers. You can find it here:</p> <p><a href="http://sourceforge.net/projects/mpg123net/" rel="nofollow noreferrer">http://sourceforge.net/projects/mpg123net/</a></p> <p>Included are the samples to convert mp3 file to PCM, and read ID3 tags.</p>
9,379
<p>Recently, I've been dealing with an error with accessing MAPI via the .NET framework (as described in <a href="http://blogs.msdn.com/mstehle/archive/2007/10/03/fyi-why-are-mapi-and-cdo-1-21-not-supported-in-managed-net-code.aspx" rel="nofollow noreferrer">this article</a>). I am now left with a series of memory access violation errors.</p> <p>To get past the issues, I have been trying to use <a href="http://www.codeproject.com/KB/IP/CMapiEx.aspx" rel="nofollow noreferrer">this 3rd party component</a>, which has a Visual C++ core. Unfortunately - we are still having the same errors.</p> <p>I've personally never used Visual C++, but my question is: if the C++ library is compiled using Visual Studio 2005, using Visual C++ - does the memory of the project become managed by the .NET framework, as well, which would therefore make it subject to the same issues as the .NET libraries we're using? Or am I barking up the wrong tree?</p>
<p>I'm not entirely sure what you're asking, but i'll give it a shot.</p> <p>Visual C++ is a pure C/C++ compiler so has none of .NET's memory management, nor any of its runtime -- You have to manually call new and delete.</p> <p>.NET also provides C++/CLI, which is a slightly modified version of C++ that targets the .NET runtime, and is GC aware -- eg. its memory is managed by the .NET runtime.</p> <p>Without more details about your bug I can't really make any suggestions, beyond suggesting that you make sure you use the appropriate GC guards, and the provide finalizers in any place they are needed.</p>
<p>Unless you are using Managed C++ (which it doesn't sound like you are) then no, the memory is not managed by the CLR.</p> <p>The recommended method of talking to Exchange in .Net is via WebDAV.</p>
4,005
<p>In my work I deal mostly with C# code nowadays, with a sprinkle of java from time to time. What I absolutely love about Eclipse (and I know people using it daily love it even more) is a sophisticated code formatter, able to mould code into any coding standard one might imagine. Is there such a tool for C#? Visual Studio code formatting (Crtl+K, Crtl+D) is subpar and StyleCop only checks the source without fixing it.</p> <p>My dream tool would run from console (for easy inclusion in automated builds or pre-commit hooks and for execution on Linux + Mono), have text-file based configuration easy to store in a project repository and a graphical rule editor with preview - just like the Eclipse Code Formatter does.</p>
<p>For Visual Studio, take a look at <a href="http://www.jetbrains.com/resharper" rel="nofollow noreferrer">ReSharper</a>. It's an awesome tool and a definite must-have. Versions after 4.0 have the code formatting and clean-up feature that you are looking for. There's also <a href="http://stylecopforresharper.codeplex.com/" rel="nofollow noreferrer">plugin integration with StyleCop</a>, including formatting settings file.</p> <p>You'll probably want <a href="https://resharper-plugins.jetbrains.com/packages/ReSharper.AgentSmith/" rel="nofollow noreferrer">Agent Smith plugin</a> as well, for spell-checking the identifiers and comments. ReSharper supports per-solution formatting setting files, which can be checked into version control system and shared by the whole team. The keyboard shortcut for code cleanup is <kbd>Ctrl</kbd> + <kbd>E</kbd>, <kbd>C</kbd>.</p> <p>In 'vanilla' Visual Studio, the current file can be automatically formatted with <kbd>Ctrl</kbd> + <kbd>K</kbd>, <kbd>Ctrl</kbd> + <kbd>D</kbd>, and <kbd>Ctrl</kbd> + <kbd>K</kbd>, <kbd>Ctrl</kbd> + <kbd>F</kbd> formats the selected text.</p> <p>As for a runs-everywhere command line tool to be used with commit hooks, try <a href="http://www.narrange.net/" rel="nofollow noreferrer">NArrange</a>. It's free, can process whole directories at once and runs on Mono as well as on Microsoft .NET.</p> <p>Some people also use the <a href="http://astyle.sourceforge.net/" rel="nofollow noreferrer">Artistic Style</a> command line tool, although it requires Perl and works better with C/C++ code than with C#.</p>
<p>Here is an open source code formatting tool which has amazing features</p> <p><a href="http://www.codemaid.net/" rel="nofollow">CodeMaid</a></p>
4,998
<p>Which C#/.NET Dependency Injection frameworks are worth looking into? And what can you say about their complexity and speed.</p>
<p><strong>edit</strong> (not by the author): There is a comprehensive list of IoC frameworks available at <a href="https://github.com/quozd/awesome-dotnet/blob/master/README.md#ioc" rel="nofollow noreferrer">https://github.com/quozd/awesome-dotnet/blob/master/README.md#ioc</a>:</p> <ul> <li><a href="https://github.com/castleproject/Windsor" rel="nofollow noreferrer">Castle Windsor</a> - Castle Windsor is best of breed, mature Inversion of Control container available for .NET and Silverlight</li> <li><a href="https://github.com/unitycontainer/unity" rel="nofollow noreferrer">Unity</a> - Lightweight extensible dependency injection container with support for constructor, property, and method call injection</li> <li><a href="https://github.com/autofac/Autofac" rel="nofollow noreferrer">Autofac</a> - An addictive .NET IoC container</li> <li><a href="https://github.com/dadhi/DryIoc" rel="nofollow noreferrer">DryIoc</a> - Simple, fast all fully featured IoC container.</li> <li><a href="https://github.com/ninject/ninject" rel="nofollow noreferrer">Ninject</a> - The ninja of .NET dependency injectors</li> <li><a href="https://github.com/spring-projects/spring-net" rel="nofollow noreferrer">Spring.Net</a> - Spring.NET is an open source application framework that makes building enterprise .NET applications easier</li> <li><a href="https://jasperfx.github.io/lamar/" rel="nofollow noreferrer">Lamar</a> - A fast IoC container heavily optimized for usage within ASP.NET Core and other .NET server side applications.</li> <li><a href="https://github.com/seesharper/LightInject" rel="nofollow noreferrer">LightInject</a> - A ultra lightweight IoC container</li> <li><a href="https://github.com/simpleinjector/SimpleInjector" rel="nofollow noreferrer">Simple Injector</a> - Simple Injector is an easy-to-use Dependency Injection (DI) library for .NET 4+ that supports Silverlight 4+, Windows Phone 8, Windows 8 including Universal apps and Mono.</li> <li><a href="https://github.com/aspnet/DependencyInjection" rel="nofollow noreferrer">Microsoft.Extensions.DependencyInjection</a> - The default IoC container for ASP.NET Core applications.</li> <li><a href="https://github.com/khellang/Scrutor" rel="nofollow noreferrer">Scrutor</a> - Assembly scanning extensions for Microsoft.Extensions.DependencyInjection.</li> <li><a href="https://github.com/Microsoft/vs-mef" rel="nofollow noreferrer">VS MEF</a> - Managed Extensibility Framework (MEF) implementation used by Visual Studio.</li> <li><a href="https://github.com/grumpydev/TinyIoC" rel="nofollow noreferrer">TinyIoC</a> - An easy to use, hassle free, Inversion of Control Container for small projects, libraries and beginners alike.</li> <li><a href="https://github.com/z4kn4fein/stashbox" rel="nofollow noreferrer">Stashbox</a> - A lightweight, fast and portable dependency injection framework for .NET based solutions.</li> </ul> <p>Original answer follows.</p> <hr /> <p>I suppose I might be being a bit picky here but it's important to note that DI (Dependency Injection) is a programming pattern and is facilitated by, but does not require, an IoC (Inversion of Control) framework. IoC frameworks just make DI much easier and they provide a host of other benefits over and above DI.</p> <p>That being said, I'm sure that's what you were asking. About IoC Frameworks; I used to use <a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.Net</a> and <a href="https://github.com/castleproject/Windsor/blob/master/docs/README.md" rel="nofollow noreferrer">CastleWindsor</a> a lot, but the real pain in the behind was all that pesky XML config you had to write! They're pretty much all moving this way now, so I have been using <a href="http://structuremap.github.io/" rel="nofollow noreferrer">StructureMap</a> for the last year or so, and since it has moved to a fluent config using strongly typed generics and a registry, my pain barrier in using IoC has dropped to below zero! I get an absolute kick out of knowing now that my IoC config is checked at compile-time (for the most part) and I have had nothing but joy with StructureMap and its speed. I won't say that the others were slow at runtime, but they were more difficult for me to setup and frustration often won the day.</p> <p><strong>Update</strong></p> <p>I've been using <a href="http://ninject.org/" rel="nofollow noreferrer">Ninject</a> on my latest project and it has been an absolute pleasure to use. Words fail me a bit here, but (as we say in the UK) this framework is 'the Dogs'. I would highly recommend it for any green fields projects where you want to be up and running quickly. I got all I needed from a <a href="http://www.dimecasts.net/Casts/ByAuthor/Justin%20Etheredge" rel="nofollow noreferrer">fantastic set of Ninject screencasts</a> by Justin Etheredge. I can't see that retro-fitting Ninject into existing code being a problem at all, but then the same could be said of <a href="http://structuremap.github.io/" rel="nofollow noreferrer">StructureMap</a> in my experience. It'll be a tough choice going forward between those two, but I'd rather have competition than stagnation and there's a decent amount of healthy competition out there.</p> <p>Other IoC screencasts can also be found <a href="http://www.dimecasts.net/Casts/ByTag/IoC" rel="nofollow noreferrer">here on Dimecasts</a>.</p>
<p>I've used <a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.NET</a> in the past and had great success with it. I never noticed any substantial overhead with it, though the project we used it on was fairly heavy on its own. It only took a little time reading through the <a href="http://www.springframework.net/documentation.html#Reference_Manual_and_API" rel="nofollow noreferrer">documentation</a> to get it set up.</p>
4,152
<p>Using CuraEngine with my Ender 3, I'm getting what I'd call inconsistent inner and outer dimensions - for example, a nominally 3&nbsp;mm peg is significantly larger than a 3&nbsp;mm hole, and it takes dimensions something like 2.9&nbsp;mm for the peg and 3.1&nbsp;mm for the hole to get them to fit. Is this level of error normal? Is it caused by overextrusion, or does CuraEngine run its paths along the curve of the slice rather than offset by approximately half the nozzle width inside the sliced region? The magnitude of the error being almost exactly 0.2&nbsp;mm, which is half of the 0.4&nbsp;mm nozzle diameter, makes me wonder if it's the latter.</p>
<p>Filament expands slightly as it is extruded. Also, the width of the extrusion depends on the volume of plastic extruded (not the nozzle size), as well as the amount that it is "squidged" down. Some slicers (e.g. Simplify3D) allow you to specify the width of the extrusion that you desire, but I'm not sure if Cura does this. You can fine tune the width of extrusions by adjusting the flow rate. Note that apertures get larger as nozzles wear out, but this should not affect the width of the extrusion very much since the determining factor is volumetric flow rate.</p> <p>I would say that if you are getting a dimensional accuracy of +/- 0.1mm, you are doing pretty well. If you want to improve on this, you will need to calibrate your extruder and also monitor closely the average diameter of the filament that you are using. I have included a link to an external article, since doing this is beyond the scope of my answer. However, I doubt if it is possible to get push-fit accuracy with FDM printing without fudging the dimensions of the objects that you want to print.</p> <p><a href="https://www.3dhubs.com/talk/t/howto-calibrate-tune-and-fine-tune-your-printer-and-filament/5695" rel="nofollow noreferrer">3D Hubs: How to calibrate, tune and fine tune your printer and filament</a></p>
<p>Cura does correctly account for line extrusion widths wheen positioning the lines, and attempting to fix this with negative <code>xy_offset</code> was a mistake that led to lots of problems: in some cases, it completely eliminated tiny components of the model and left gaps in layers. At some point after asking this question, I did a new test with 8mm peg and hole, and I was actually able to force the 8mm peg into the hole (but not remove it) using tools, without cracking the parts, so I think past tiny sizes where dimensional accuracy is very difficult to achieve, everything is just about right.</p>
1,212
<p>In the <a href="https://stackoverflow.com/questions/39447/how-can-i-expose-only-a-fragment-of-ilist">How Can I Expose Only a Fragment of IList&lt;></a> question one of the answers had the following code snippet:</p> <pre><code>IEnumerable&lt;object&gt; FilteredList() { foreach(object item in FullList) { if(IsItemInPartialList(item)) yield return item; } } </code></pre> <p>What does the yield keyword do there? I've seen it referenced in a couple places, and one other question, but I haven't quite figured out what it actually does. I'm used to thinking of yield in the sense of one thread yielding to another, but that doesn't seem relevant here.</p>
<p>The <code>yield</code> contextual keyword actually does quite a lot here.</p> <p>The function returns an object that implements the <code>IEnumerable&lt;object&gt;</code> interface. If a calling function starts <code>foreach</code>ing over this object, the function is called again until it &quot;yields&quot;. This is syntactic sugar introduced in <strong>C# 2.0</strong>. In earlier versions you had to create your own <code>IEnumerable</code> and <code>IEnumerator</code> objects to do stuff like this.</p> <p>The easiest way understand code like this is to type-in an example, set some breakpoints and see what happens. Try stepping through this example:</p> <pre><code>public void Consumer() { foreach(int i in Integers()) { Console.WriteLine(i.ToString()); } } public IEnumerable&lt;int&gt; Integers() { yield return 1; yield return 2; yield return 4; yield return 8; yield return 16; yield return 16777216; } </code></pre> <p>When you step through the example, you'll find the first call to <code>Integers()</code> returns <code>1</code>. The second call returns <code>2</code> and the line <code>yield return 1</code> is not executed again.</p> <p>Here is a real-life example:</p> <pre><code>public IEnumerable&lt;T&gt; Read&lt;T&gt;(string sql, Func&lt;IDataReader, T&gt; make, params object[] parms) { using (var connection = CreateConnection()) { using (var command = CreateCommand(CommandType.Text, sql, connection, parms)) { command.CommandTimeout = dataBaseSettings.ReadCommandTimeout; using (var reader = command.ExecuteReader()) { while (reader.Read()) { yield return make(reader); } } } } } </code></pre>
<p>It's trying to bring in some Ruby Goodness :)<br> <strong>Concept:</strong> This is some sample Ruby Code that prints out each element of the array </p> <pre><code> rubyArray = [1,2,3,4,5,6,7,8,9,10] rubyArray.each{|x| puts x # do whatever with x } </code></pre> <p>The Array's each method implementation <strong>yields</strong> control over to the caller (the 'puts x') with <strong>each</strong> element of the array neatly presented as x. The caller can then do whatever it needs to do with x.</p> <p>However <strong>.Net</strong> doesn't go all the way here.. C# seems to have coupled yield with IEnumerable, in a way forcing you to write a foreach loop in the caller as seen in Mendelt's response. Little less elegant.</p> <pre><code>//calling code foreach(int i in obCustomClass.Each()) { Console.WriteLine(i.ToString()); } // CustomClass implementation private int[] data = {1,2,3,4,5,6,7,8,9,10}; public IEnumerable&lt;int&gt; Each() { for(int iLooper=0; iLooper&lt;data.Length; ++iLooper) yield return data[iLooper]; } </code></pre>
6,056
<p>My CR-10 S5 has a feature, that stops the print, when the filament runs out.</p> <p>However, when the printer pauses, the bed cools down and the print plops if the bed. Is there a way to tell the printer to keep the bed heated, when paused (by the runout detector)?</p>
<p>This is varying underextrusion due to loss of material to oozing in the interior of the model.</p> <p>When printing the infill pattern, the nozzle doesn't follow a single continuous extrusion path, but moves from the end of one path to the beginning of the next, and under Cura defaults, <em>does this without retracting the filament</em>. This causes unpredictable amounts to ooze out during travel from one to the next, thereby desynchronizing the planned/intended amount of material extruded so far and the actual amount. This means, when the next outer-wall extrusion starts, there's an unpredictable deficiency between the amount of material at the nozzle to extrude, and the amount the slicer intended to extrude. The result is what you're seeing.</p> <p>To fix it, you need to eliminate oozing, not just outside the model where it appears as visible stringing, but inside too. Either disable &quot;Combing&quot; entirely in Cura, or set &quot;Max Comb Distance With No Retract&quot; to something very low (0.8 mm or less). Also set &quot;Minimum Extrusion Distance Window&quot; to 0 to ensure Cura doesn't skip retractions for other reasons.</p> <p>You may also want to play with extrusion length and speed. Too short or too long can be bad; 5-7 mm is the reasonable range for PLA with a bowden. Higher speed generally helps too; the printer should be able to handle 50 mm/s or faster.</p>
<p>If this matches the horizontal planes - like &quot;solid floor&quot; than I would advice to check overlap settings. My suspicion is slight overextrusion, which might be the reason of many small horizontal differences. Using 3 mm filament I often suffer of similar inconsistencies, until I find proper flowrate to avoid overextrusion. Adding first to second, the solid plane will push walls more to sides.</p> <p>Do you print &quot;Infill Before Walls&quot; (Cura setting)? You may try to disable this checkbox and observe if the result persisted. Also you may enable &quot;Outer Before Inner Walls&quot; - to ensure, that outer wall is printed first with least interference (though some other issues may appear after travel, layer change, etc.).</p> <ul> <li>So try print from outside to inside (outer walls &gt; inner walls &gt; infill).</li> <li>Then try to reduce &quot;Flow&quot; until you see no overextrusion (or even small gaps in the surface).</li> <li>Finally revert these settings (infill &gt; inner &gt; outer) and check again.</li> </ul>
1,835
<p>I'm trying to build a headrest for my Sayl office chair. For that, I'm designing a 3d-printed part that's going to fit on one of the existing rods of the chair.</p> <p>Check out this picture:</p> <p><a href="https://i.stack.imgur.com/PMzGy.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/PMzGy.jpg" alt=""></a></p> <p>How would you go about in getting the exact measurements of that white rod? I tried a caliper, and I'm able to get the width and depth, and I can just assume that the rod's profile is a perfect ellipse, which is probably a close estimate. But say that I want to get a more precise measurement. Is there any technique to do that? </p>
<p>In an earlier comment you stated that you cannot take it apart. So without taking it apart, you could try to determine the profile the old-fashion way with a piece of cardboard and a short pencil, just cut the rough shape of the rod and place it onto the rod, then take the short pencil and draw the profile onto the cardboard with the pencil parallel to the rod. Measuring the distance from the pencil center to the pencil radius will give you the profile of the rod with that off-set. This technique, or the technique used to create <a href="https://www.youtube.com/watch?v=w9FlfMIMv7Q" rel="nofollow noreferrer">notches in logs</a> for log cabins may be used to find the profile at various sections which have to be entered in a 3D CAD model program and splined/lofted to get the surface of the rod.</p> <p>Alternatively you could use a profile shape tool carpenters use: <a href="https://i.stack.imgur.com/NZyN8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NZyN8.jpg" alt="enter image description here"></a></p>
<p>You could pull it apart and have it 3d scanned if you want to know the exact dimensions. There are companies that can do that for you at a certain price. Our company has used such services in scanning various parts before we obtained our own laser scanning device. </p> <p>The question is whether you want exactly the same (dimension wise) part (maybe you do for ecstatic reasons) while a part that is a little more beefier would work also.</p> <p><strong>Edit:</strong> Although tagged with 3D scanning, the OP did not mention whether he would be able to disassemble the part. 3D scanning is an option when taken apart. Another solution has been posted since.</p>
907
<p>I've always felt that my graphic design skills have lacked, but I do have a desire to improve them. Even though I'm not the worlds worst artist, it's discouraging to see the results from a professional designer, who can do an amazing mockup from a simple spec in just a few hours. I always wonder how they came up with their design and more importantly, how they executed it so quickly. </p> <p>I'd like to think that all good artists aren't naturally gifted. I'm guessing that a lot of skill/talent comes from just putting in the time. </p> <p>Is there a recommended path to right brain nirvana for someone starting from scratch, a little later in life? I'd be interested in book recommendations, personal theories, or anything else that may shed some light on the best path to take. I have questions like should I read books about color theory, should I draw any chance I have, should I analyze shapes like an architect, etc...</p> <p>As far as my current skills go, I can make my way around Photoshop enough where I can do simple image manipulation...</p> <p>Thanks for any advice</p>
<p>Most of artistic talent comes from putting in the time. However, as in most skills, practicing bad habits doesn't help you progress.</p> <p>You need to learn basic drawing skills (form, mainly) and practice doing them well and right (which means slowly). As you practice correctly, you'll improve much faster.</p> <p>This is the kind of thing that changes you from a person who says, "It doesn't look right, but I can't tell why - it's just 'off' somehow" to a person who says, "Oops, the arm is a bit long. If I shorten the elbow end it'll change the piece in this way, if I shorten the hand end it'll change the piece this way..."</p> <p>So you've got to study the forms you intend to draw, and recognize their internally related parts (the body height is generally X times the size of the head, the arms and legs are related in size but vary from the torso, etc). Same thing with buildings, physical objects, etc.</p> <p>Another thing that will really help you is understanding light and shadow - humans pick up on shape relationships based on outlines and based on shadows.</p> <p>Color theory is something that will make your designs attractive, or evoke certain responses and emotions, but until you get the form and lighting right the colors are not something you should stress. One reason why art books and classes focus so much on monochrome drawings.</p> <p>There are books and classes out there for these subjects - I could recommend some, but what you really need is to look at them yourself and pick the ones that appeal to you. You won't want to learn if you don't like drawing fruit bowls, and that's all your book does. Though you shouldn't avoid what you don't like, given that you're going the self taught route you should make it easy in the beginning, and then force yourself to draw the uninteresting and bland once you've got a bit of confidence and speed so you can go through those barriers more quickly.</p> <p>Good luck!</p> <p>-Adam</p>
<p>I, too was not born with a strong design skillset, in fact quite the opposite. When I started out, my philosophy was that if the page or form <em>just works</em> then my job was done! </p> <p>Over the years though, I've improved. Although I believe I'll never be as good as someone who was born with the skills, sites like <a href="http://www.csszengarden.com" rel="nofollow noreferrer">CSS Zen Garden</a> among others have helped me a lot. </p> <p>Read into usability too, as I think usability and design for computer applications are inextricably entwined. Books such as Don Norman's "The Design of Everyday Things" to Steve Krug's "Don't Make Me Think", have all helped improve my 'design skills'... slightly! ;-)</p> <p>Good luck with it.</p>
5,242
<p>I load some XML from a servlet from my Flex application like this:</p> <pre><code>_loader = new URLLoader(); _loader.load(new URLRequest(_servletURL+"?do=load&amp;id="+_id)); </code></pre> <p>As you can imagine <code>_servletURL</code> is something like <a href="http://foo.bar/path/to/servlet" rel="nofollow noreferrer">http://foo.bar/path/to/servlet</a></p> <p>In some cases, this URL contains accented characters (long story). I pass the <code>unescaped</code> string to <code>URLRequest</code>, but it seems that flash escapes it and calls the escaped URL, which is invalid. Ideas?</p>
<p>My friend Luis figured it out:</p> <p>You should use encodeURI does the UTF8URL encoding <a href="http://livedocs.adobe.com/flex/3/langref/package.html#encodeURI()" rel="noreferrer">http://livedocs.adobe.com/flex/3/langref/package.html#encodeURI()</a></p> <p>but not unescape because it unescapes to ASCII see <a href="http://livedocs.adobe.com/flex/3/langref/package.html#unescape()" rel="noreferrer">http://livedocs.adobe.com/flex/3/langref/package.html#unescape()</a></p> <p>I think that is where we are getting a %E9 in the URL instead of the expected %C3%A9.</p> <p><a href="http://www.w3schools.com/TAGS/ref_urlencode.asp" rel="noreferrer">http://www.w3schools.com/TAGS/ref_urlencode.asp</a></p>
<p>From the livedocs: <a href="http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequest.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequest.html</a></p> <blockquote> <p>Creates a URLRequest object. If System.useCodePage is true, the request is encoded using the system code page, rather than Unicode. If System.useCodePage is false, the request is encoded using Unicode, rather than the system code page.</p> </blockquote> <p>This page has more information: <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_3.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_3.html</a></p> <p>but basically you just need to add this to a function that will be run before the URLRequest (I would probably put it in a creationComplete event)</p> <p><code>System.useCodePage = false</code>;</p>
8,787
<p>I was wondering if adding (an) extra fan(s) (not connected to the printer, but blowing on the print area) could improve the quality of PLA based prints(printing at 210 C). The printer already has a built in fan with a fan shroud that directs air to the hotend, but is it beneficial to add an extra fan in order to get better results on overhangs, fine details, etc, or does extra cooling negatively/not affect print quality? </p>
<blockquote> <p>The printer already has a built in fan with a fan shroud that directs air to the hotend</p> </blockquote> <p><strong>Unless your printer is defective, it may look like so, but the airflow should really be directed towards the print, not the hot-end</strong>. Cooling the hot-end will at best just waste energy, requiring extra heat to keep it hot, at worst affect your print quality negatively.</p> <blockquote> <p>is it beneficial to add an extra fan in order to get better results on overhangs?</p> </blockquote> <p>The issue with external fans, not connected to the printer, is that you can't properly direct their ariflow, so:</p> <ul> <li>you <em>will</em> direct some of it on the hot-end itself (see above on why that's not good)</li> <li>you will potentially cool your print unevenly, which - depending from how much, how fast, and what type of filament you are using - may warp your prints</li> </ul> <p>That said, depending from a number of factors, including your ability to position the fans appropriately, <strong>you <em>may</em> gain some benefit from them (I saw people doing this to help with PETG stringing), but I would recommend instead to upgrade the part fan of your printer (e.g.: larger diameter, higher RPM) and your duct (better focus on the extruded filament)</strong>, as these upgrades will have no drawbacks and will perform consistently on each part of the print.</p> <p>For most common printer, there are printable mods that allow to do both, often available off thingiverse or on dedicated user community forums.</p>
<p>Fan blow at hot end is necessary because hotend needs cooling.</p> <p>For PLA it will yield better result with a seperate controllable fan direct airflow across the print head, but just like everything with 3D printing, you will need to test out every possible configuration to get the best for your setup.</p>
819
<p>When looking at a SSI printenv dump I see a variable URI_REQUEST.</p> <p>When reading the Apache mod_include docs I see DOCUMENT_URI which they define as "The (%-decoded) URL path of the document requested by the user."</p> <p>Anyone know the difference between the two?</p> <p>TIA.</p>
<p>REQUEST_URI includes the Query String (?q=testing...) where DOCUMENT_URI does not.</p>
<p>ok. seems like it is exactly the opposite according to Apache docs and RFC 2616.</p> <p>REQUEST_URI does not contain the query string. DOCUMENT_URI does contain the query string.</p> <p>cheers,</p> <p>Rob</p>
6,031
<p>My current project is in Rails. Coming from a Symfony (PHP) and Django (Python) background, they both have excellent admin generators. Seems like this is missing in Rails.</p> <p>For those who aren't familiar with Symfony or Django, they both allow you to specify some metadata around your models to automatically (dynamically) generate an admin interface to do the common CRUD operations. You can create an entire Intranet with only a few commands or lines of code. They have a good appearance and are extensible enough for 99% of your admin needs.</p> <p>I've looked for something similar for Rails, but all of the projects either have no activity or they died long ago. Is there anything to generate an intranet/admin site for a rails app other than scaffolding?</p>
<p><strong>Active Admin</strong> (<a href="http://activeadmin.info/" rel="noreferrer">http://activeadmin.info/</a>) was released in May of 2011, and looks like it's going to become the best Rails 3 option.</p> <p><img src="https://i.stack.imgur.com/mtjrr.png" alt="features"></p>
<p>The most common way to create a CRUD interface is to use Scaffold. </p> <pre><code>./script/generate scaffold_resource MyModel property:type property2:type2 </code></pre> <p>This command would generate a CRUD interface for the model named MyModel (singular) with two properties. Properties is what's called columns in DB lingo. So you could have name:string age:integer active:boolean etc.</p>
8,657
<p><a href="http://www.stackoverflow.com/questions/61088/hidden-features-of-javascript#61118">Alan Storm's comments</a> in response to my answer regarding the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with" rel="noreferrer"><code>with</code> statement</a> got me thinking. I've seldom found a reason to use this particular language feature, and had never given much thought to how it might cause trouble. Now, I'm curious as to how I might make effective use of <code>with</code>, while avoiding its pitfalls.</p> <p>Where have you found the <code>with</code> statement useful?</p>
<p>Another use occurred to me today, so I searched the web excitedly and found an existing mention of it: <a href="http://web.archive.org/web/20090111183416/http://www.hedgerwow.com/360/dhtml/js_block_scope.html" rel="noreferrer">Defining Variables inside Block Scope</a>.</p> <h3>Background</h3> <p>JavaScript, in spite of its superficial resemblance to C and C++, does not scope variables to the block they are defined in:</p> <pre><code>var name = &quot;Joe&quot;; if ( true ) { var name = &quot;Jack&quot;; } // name now contains &quot;Jack&quot; </code></pre> <p>Declaring a closure in a loop is a common task where this can lead to errors:</p> <pre><code>for (var i=0; i&lt;3; ++i) { var num = i; setTimeout(function() { alert(num); }, 10); } </code></pre> <p>Because the for loop does not introduce a new scope, the same <code>num</code> - with a value of <code>2</code> - will be shared by all three functions.</p> <h3>A new scope: <code>let</code> and <code>with</code></h3> <p>With the introduction of the <code>let</code> statement in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let" rel="noreferrer">ES6</a>, it becomes easy to introduce a new scope when necessary to avoid these problems:</p> <pre><code>// variables introduced in this statement // are scoped to each iteration of the loop for (let i=0; i&lt;3; ++i) { setTimeout(function() { alert(i); }, 10); } </code></pre> <p>Or even:</p> <pre><code>for (var i=0; i&lt;3; ++i) { // variables introduced in this statement // are scoped to the block containing it. let num = i; setTimeout(function() { alert(num); }, 10); } </code></pre> <p>Until ES6 is universally available, this use remains limited to the newest browsers and developers willing to use transpilers. However, we can easily simulate this behavior using <code>with</code>:</p> <pre><code>for (var i=0; i&lt;3; ++i) { // object members introduced in this statement // are scoped to the block following it. with ({num: i}) { setTimeout(function() { alert(num); }, 10); } } </code></pre> <p>The loop now works as intended, creating three separate variables with values from 0 to 2. Note that variables declared <em>within</em> the block are not scoped to it, unlike the behavior of blocks in C++ (in C, variables must be declared at the start of a block, so in a way it is similar). This behavior is actually quite similar to a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#let_blocks" rel="noreferrer"><code>let</code> block syntax</a> introduced in earlier versions of Mozilla browsers, but not widely adopted elsewhere.</p>
<p>Just wanted to add you can get "with()" functionality with pretty syntax and no ambiguity with your own clever method...</p> <pre><code> //utility function function _with(context){ var ctx=context; this.set=function(obj){ for(x in obj){ //should add hasOwnProperty(x) here ctx[x]=obj[x]; } } return this.set; } //how calling it would look in code... _with(Hemisphere.Continent.Nation.Language.Dialect.Alphabet)({ a:"letter a", b:"letter b", c:"letter c", d:"letter a", e:"letter b", f:"letter c", // continue through whole alphabet... });//look how readable I am!!!! </code></pre> <p>..or if you <em>really</em> want to use "with()" without ambiguity and no custom method, wrap it in an anonymous function and use .call </p> <pre><code>//imagine a deeply nested object //Hemisphere.Continent.Nation.Language.Dialect.Alphabet (function(){ with(Hemisphere.Continent.Nation.Language.Dialect.Alphabet){ this.a="letter a"; this.b="letter b"; this.c="letter c"; this.d="letter a"; this.e="letter b"; this.f="letter c"; // continue through whole alphabet... } }).call(Hemisphere.Continent.Nation.Language.Dialect.Alphabet) </code></pre> <p>However as others have pointed out, its somewhat pointless since you can do...</p> <pre><code> //imagine a deeply nested object Hemisphere.Continent.Nation.Language.Dialect.Alphabet var ltr=Hemisphere.Continent.Nation.Language.Dialect.Alphabet ltr.a="letter a"; ltr.b="letter b"; ltr.c="letter c"; ltr.d="letter a"; ltr.e="letter b"; ltr.f="letter c"; // continue through whole alphabet... </code></pre>
8,679
<p>Is there a standard library method that converts a string that has duration in the standard ISO 8601 Duration (also used in XSD for its <code>duration</code> type) format into the .NET TimeSpan object?</p> <p>For example, P0DT1H0M0S which represents a duration of one hour, is converted into New TimeSpan(0,1,0,0,0).</p> <p>A Reverse converter does exist which works as follows: Xml.XmlConvert.ToString(New TimeSpan(0,1,0,0,0)) The above expression will return P0DT1H0M0S.</p>
<p>This will convert from xs:duration to TimeSpan:</p> <pre><code>System.Xml.XmlConvert.ToTimeSpan("P0DT1H0M0S") </code></pre> <p>See <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.totimespan.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.totimespan.aspx</a></p>
<p>As @ima dirty troll said TimeSpan translates always years as 365 days and months as 30 days.</p> <pre><code>TimeSpan ts = System.Xml.XmlConvert.ToTimeSpan("P5Y"); DateTime now = new DateTime(2008,2,29); Console.WriteLine(now + ts); // 27/02/2013 0:00:00 </code></pre> <p>To address it you should add each field individually rather than using TimeSpan.</p> <pre><code>DateTime now = new DateTime (2008, 2, 29); string duration = "P1Y"; Regex expr = new Regex (@"(-?)P((\d{1,4})Y)?((\d{1,4})M)?((\d{1,4})D)?(T((\d{1,4})H)?((\d{1,4})M)?((\d{1,4}(\.\d{1,3})?)S)?)?", RegexOptions.Compiled | RegexOptions.CultureInvariant); bool positiveDuration = false == (input [0] == '-'); MatchCollection matches = expr.Matches (duration); var g = matches [0]; Func&lt;int,int&gt; getNumber = x =&gt; { if (g.Groups.Count &lt; x || string.IsNullOrEmpty (g.Groups [x].ToString ())) { return 0; } int a = int.Parse (g.Groups [x].ToString ()); return PositiveDuration ? a : a * -1; }; now.AddYears (getNumber (3)); now.AddMonths (getNumber (5)); now.AddDays (getNumber (7)); now.AddHours (getNumber (10)); now.AddMinutes (getNumber (12)); now.AddSeconds (getNumber (14)); Console.WriteLine (now); // 28/02/2012 0:00:00 </code></pre>
8,829
<p>I have an application that writes information to file. This information is used post-execution to determine pass/failure/correctness of the application. I'd like to be able to read the file as it is being written so that I can do these pass/failure/correctness checks in real time.</p> <p>I assume it is possible to do this, but what are the gotcha's involved when using Java? If the reading catches up to the writing, will it just wait for more writes up until the file is closed, or will the read throw an exception at this point? If the latter, what do I do then? </p> <p>My intuition is currently pushing me towards BufferedStreams. Is this the way to go?</p>
<p>Could not get the example to work using <code>FileChannel.read(ByteBuffer)</code> because it isn't a blocking read. Did however get the code below to work:</p> <pre><code>boolean running = true; BufferedInputStream reader = new BufferedInputStream(new FileInputStream( "out.txt" ) ); public void run() { while( running ) { if( reader.available() &gt; 0 ) { System.out.print( (char)reader.read() ); } else { try { sleep( 500 ); } catch( InterruptedException ex ) { running = false; } } } } </code></pre> <p>Of course the same thing would work as a timer instead of a thread, but I leave that up to the programmer. I'm still looking for a better way, but this works for me for now.</p> <p>Oh, and I'll caveat this with: I'm using 1.4.2. Yes I know I'm in the stone ages still.</p>
<p>I've never tried it, but you should write a test case to see if reading from a stream after you have hit the end will work, regardless of if there is more data written to the file.</p> <p>Is there a reason you can't use a piped input/output stream? Is the data being written and read from the same application (if so, you have the data, why do you need to read from the file)?</p> <p>Otherwise, maybe read till end of file, then monitor for changes and seek to where you left off and continue... though watch out for race conditions.</p>
2,613
<p>How can I construct my ajaxSend call, this seems like the place to put it, to preview what is being passed back to the broker? also, can I stop the ajax call in ajaxSend?..so I can perfect my url string before dealing with errors from the broker?</p> <p>This is the complete URL that, when passed to the broker, will return the JSON code I need:</p> <pre><code>http://myServer/cgi-bin/broker?service=myService&amp;program=myProgram&amp;section=mySection&amp;start=09/08/08&amp;end=09/26/08 </code></pre> <p>This is my $.post call (not sure it is creating the above url string)</p> <pre><code>$(function() { $("#submit").bind("click", function() { $.post({ url: "http://csewebprod/cgi-bin/broker" , datatype: "json", data: { 'service' : myService, 'program' : myProgram, 'section' : mySection, 'start' : '09/08/08', 'end' : '09/26/08' }, error: function(request){ $("#updateHTML").removeClass("hide") ; $("#updateHTML").html(request.statusText); }, success: function(request) { $("#updateHTML").removeClass("hide") ; $("#updateHTML").html(request) ; } }); // End post method }); // End bind method }); // End eventlistener </code></pre> <p>Thanks</p>
<p>As far as I know, the only way to do that is to enter something (anything) on that line, then delete it. Or hit space and you'll never see it there until you return to that line.</p> <p>Once VS determines that you've edited a line of text, it won't automatically modify it for you (at least, not in that way that you've described).</p>
<p>This is an annoyance to myself as well. Anytime the code is reformatted the blank lines are de-tabbed. You might look at this: <a href="http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7" rel="nofollow">http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7</a> it's not exactly a solution but a step in the right direction</p>
9,957
<p>I am a broke college student. I have built a small web app in PHP5 and MySQL, and I already have a domain. What is an affordable way to get it online? A few people have suggested amazon's cloud services, but that seems equivalent to slitting my wrists and watching money slowly trickle out. So suggestions? Hosting companies, CIA drop sites, anything?</p> <p><strong>Update:</strong> A lot of suggestions have been for Dreamhost. Their plan allows for 5TB of bandwidth. Could anyone put this in perspective? For instance, how much bandwidth does a site with the kind of traffic StackOverflow get? </p>
<p>I say pay the 50-80 bucks for a real host. The classic "you get what you pay for" is <strong>very</strong> true for hosting. This will save you time, time you can spend getting those $80.</p>
<p>I've been at HostingMatters for years. They're relatively cheap, and their service is awesome. &lt;12 hours for any support ticket I've ever had.</p> <p>Additionally, since I've been with them for about ten years, they bumped me to an unmetered plan for no cost (at the same $10/month I was paying.) .... </p>
3,738
<p>In Python you can use <a href="https://docs.python.org/library/struct.html" rel="noreferrer">StringIO</a> for a file-like buffer for character data. <a href="https://docs.python.org/library/mmap.html" rel="noreferrer">Memory-mapped file</a> basically does similar thing for binary data, but it requires a file that is used as the basis. Does Python have a file object that is intended for binary data and is memory only, equivalent to Java's <a href="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayOutputStream.html" rel="noreferrer">ByteArrayOutputStream</a>?</p> <p>The use-case I have is I want to create a ZIP file in memory, and <a href="https://docs.python.org/library/zipfile.html" rel="noreferrer">ZipFile</a> requires a file-like object.</p>
<p>You are probably looking for <a href="http://docs.python.org/release/3.1.3/library/io.html#binary-i-o">io.BytesIO</a> class. It works exactly like StringIO except that it supports binary data:</p> <pre><code>from io import BytesIO bio = BytesIO(b"some initial binary data: \x00\x01") </code></pre> <p>StringIO will throw TypeError:</p> <pre><code>from io import StringIO sio = StringIO(b"some initial binary data: \x00\x01") </code></pre>
<p>Look at the struct package: <a href="https://docs.python.org/library/struct.html" rel="nofollow noreferrer">https://docs.python.org/library/struct.html</a>, it allows you to interpret strings as packed binary data.</p> <p>Not sure if this will completely answer your question but you can use struct.unpack() to convert binary data to python objects.</p> <pre> <code> import struct f = open(filename, "rb") s = f.read(8) x, y = struct.unpack(">hl", s) </code> </pre> <p>int this example, the ">" tells to read big-endian the "h" reads a 2-byte short, and the "l" is for a 4-byte long. you can obviously change these to whatever you need to read out of the binary data...</p>
4,472
<p>In one of my applications, I am querying active directory to get a list of all users below a given user (using the "Direct Reports" thing). So basically, given the name of the person, it is looked up in AD, then the Direct Reports are read. But then for every direct report, the tool needs to check the direct reports of the direct reports. Or, more abstract: The Tool will use a person as the root of the tree and then walk down the complete tree to get the names of all the leaves (can be several hundred)</p> <p>Now, my concern is obviously performance, as this needs to be done quite a few times. My idea is to manually cache that (essentially just put all the names in a long string and store that somewhere and update it once a day).</p> <p>But I just wonder if there is a more elegant way to first get the information and then cache it, possibly using something in the System.DirectoryServices Namespace?</p>
<p>In order to take control over the properties that you want to be cached you can call 'RefreshCache()' passing the properties that you want to hang around:</p> <pre class="lang-c# prettyprint-override"><code>System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(); // Push the property values from AD back to cache. entry.RefreshCache(new string[] {"cn", "www" }); </code></pre>
<p>Active Directory is pretty efficient at storing information and the retrieval shouldn't be that much of a performance hit. If you are really intent on storing the names, you'll probably want to store them in some sort of a tree stucture, so you can see the relationships of all the people. Depending on how the number of people, you might as well pull all the information you need daily and then query all the requests against your cached copy. </p>
5,327
<p>For a model that has raised text on it, how do go about painting the very top layer of text, to make it stand out from the background? Lets say I printed the whole model the same color, what type of paint would work well, and not get on the background too?</p> <p>Here's an example of a model that has raised text: <a href="https://www.thingiverse.com/thing:3025280" rel="nofollow noreferrer">https://www.thingiverse.com/thing:3025280</a></p>
<p>You don't provide any dimensions or sizes, but...</p> <p>Assuming that the text is sufficiently elevated from the rest of the model, you could use a firm solid (as opposed to soft and spongey) roller, of an appropriate width.</p> <p>This should enable you to paint just the text without getting paint on the rest of the model.</p> <ul> <li><p>If the text is small and in a "valley" or groove, then a narrow roller would be required, in order to avoid the surface either side of the text.</p></li> <li><p>If the text is not on a flat, or smooth surface, then a small diameter roller might be required.</p></li> <li><p>If you can't find a tiny paint roller, you could <em><a href="https://en.wikipedia.org/wiki/Jury_rigging" rel="nofollow noreferrer">jerry-rig</a></em> one using a paper clip and a roller wheel from an old cassette tape</p></li> </ul>
<p>The technique you look for is <em>drybrushing</em> and not dependant on a specific type of color, as long as it can be applied with a brush.</p> <p>An alternative technique might be carefully applying glue and leaf metal.</p>
1,513
<p>I need to modify the MBR of Windows, and I would really like to do this from Windows.</p> <p>Here are my questions. I know that I can get a handle on a physical device with a call to CreateFile. Will the MBR always be on \\.\PHYSICALDRIVE0? Also, I'm still learning the Windows API to read directly from the disk. Is readabsolutesectors and writeabsolutesectdors the two functions I'm going to need to use to read/write to the disk sectors which contain the MBR?</p> <p>Edit from from what I've learned on my own. The MBR will not always be on \\.\PHYSICALDRIVE0. Also, you can write to the bootsector (at least as Administrator on XP) by call CreateFile with the device name of the drive that contains the MBR. Also, you can write to this drive by simply calling WriteFile and passing the handle of the device created by calling CreateFile.</p> <p>Edit to address Joel Coehoorn. I need to edit the MBR because I'm working on a project that needs to modify hardware registers after POST in BIOS, but before Windows will be allowed to boot. Our plan is to make these changes by modifying the bootloader to execute our code before Windows boots up. </p> <p>Edit for Cd-MaN. Thanks for the info. There isn't anything in your answer, though, that I didn't know and your answer doesn't address my question. The registry in particular absolutely will not do what we need for multiple reasons. The big reason being that Windows is the highest layer among multiple software layers that will be running with our product. These changes need to occur even before the lower levels run, and so the registry won't work. </p> <p>P.S. for Cd-MaN. As I understand it, the information you give isn't quite correct. For Vista, I think you can write to a volume if the sectors being written to are boot sectors. See <a href="http://support.microsoft.com/kb/942448" rel="nofollow noreferrer">http://support.microsoft.com/kb/942448</a></p>
<p>Once the OS is started the MBR is typically protected for virus reasons - this is one of the oldest virus tricks in the books - goes back to passing viruses from floppy to floppy.</p> <p>Even if it wasn't restricted, you have to write low level code - it isn't part of the file system, but exists on a specific location on the hard drive.</p> <p>Due to that, you pretty much are restricted to writing low level (most programs implement this in assembly) or C code targeting 16 bit DOS.</p> <p>Most of these programs use the <a href="http://oopweb.com/Assembly/Documents/ArtOfAssembly/Volume/Chapter_13/CH13-1.html" rel="noreferrer">BIOS interface</a> (13h, I believe) to access the sectors of the disk directly. You can access these in C using some inline assembly, or compiler provided interfaces. You will generally not get access to BIOS without the cooperation of the OS, though, so your program, again, will be restricted to DOS. If you can access these you're almost home free - the nice thing about BIOS is you don't have to worry about what type of HD is in the system - even RAID cards often insert themselves into the BIOS routines so they can be accessed without knowing where in memory the ATA or SATA controller is, and executing commands on that low level.</p> <p>If you absolutely must access it within an OS, though, you pretty much have to write a device driver to access the BIOS or the memory space where the HD controllers exist. I wouldn't recommend it, though, as this is very tricky to deal with - modern computers put the HD controllers in different spots in memory, with different IRQs, and each chipset has become a little more esoteric because they can provide a minimum interface to bios for bootup, and then a specific driver for Windows. They skip all the other interface niceties that would be considered compatible with other controllers because it's more expensive to be compatible. </p> <p>You may find that at the driver level inside windows you'll have methods for accessing the drive sectors directly (or pseudo directly), but again, they are likely very well protected due to the aforementioned virus issues.</p> <p>Good luck!</p>
<p>Modifying the bootloader is bad, bad idea. Here are just a few of the possible gotcha's:</p> <ul> <li>it will potentially kill full disk encryption products (Truecrypt, PGP, Vista's BitLocker, etc)</li> <li>it will potentially trip up AV products (scaring users)</li> <li>it will potentially kill complicated booting scenarios (chained boot loaders, etc)</li> <li>it will kill off the chain of trust when using the TPM module (because it checks the MBR for change before executing it)</li> <li>direct disk access is not allowed starting from Vista (only using drivers)</li> </ul> <p>Alternatives (like modifying the hardware register during the Windows bootup via a driver which is set to load at boot time or after Windows has booted) should really be considered. If the modification is as simple as writing to a port, ie:</p> <pre><code>OUT AX, BL </code></pre> <p>then drivers exists for all versions of Window which can do this (reading/writing a value from/to a certain port) which can be called from user mode.</p>
6,058
<p>Two users wanted to share the same database, originally written in MS Access, without conflicting with one another over a single MDB file.</p> <p>I moved the tables from a simple MS Access database to MySQL using its <a href="http://www.mysql.com/products/tools/migration-toolkit/" rel="noreferrer">Migration Toolkit</a> (which works well, by the way) and set up Access to link to those tables via ODBC.</p> <p>So far, I've run into the following:</p> <ul> <li>You can't insert/update/delete rows in a table without a primary key (no surprise there).</li> <li>AutoNumber fields in MS Access must be the primary key or they'll just end up as integer columns in MySQL (natch, why wouldn't it be the PK?)</li> <li>The tables were migrated to MySQL's InnoDB table type, but the Access relationships didn't become MySQL foreign key constraints.</li> </ul> <p>Once the database is in use, can I expect any other issues? Particularly when both users are working in the same table?</p>
<p>I had an application that worked likewise: an MS Access frontend to a MySQL backend. It was such a huge pain that I ended up writing a Win32 frontend instead. From the top of my head, I encountered the following problems:</p> <ul> <li>Development of the ODBC link seems to have ceased long ago. There are various different versions floating around --- very confusing. The ODBC link doesn't support Unicode/UTF8, and I remember there were other issues with it as well (though some could be overcome by careful configuration).</li> <li>You probably want to manually tweak your db schema to make it compatible with MS Access. I see you already found out about the needed surrogate keys (i.e., int primary keys) :-)</li> <li>You should keep in mind that you may need to use pass-through queries to do more sophisticated SQL manipulations of the MySQL database.</li> <li>Be careful with using lots of VBA, as that tends to corrupt your frontend file. Regularly compressing the database (using main menu, Tools | Database utilities | Compress and restore, or something like that --- I'm using the Dutch version) and making <em>lots</em> of backups is necessary.</li> <li>Access tends to cause lots of network traffic. Like, really huge lots. I haven't been able to find a solution for that. Using a network monitor is recommended if you want to keep an eye on that!</li> <li>Access insists on storing booleans as 0/-1. IMHO, 0/+1 makes more sense, and I believe it is the default way of doing things in MySQL as well. Not a huge problem, but if your checkboxes don't work, you should definitely check this.</li> </ul> <p>One possible alternative would be to put the backend (with the data) on a shared drive. I remember this is well-documented, also in the help. You may want to have a look at <a href="http://allenbrowne.com/ser-01.html" rel="noreferrer">some general advice on splitting into a frontend and a backend</a> and <a href="http://allenbrowne.com/ser-13.html" rel="noreferrer">code that automatically reconnects to the backend on startup</a>; I can also send you some more sample code, or post it here.</p> <p>Otherwise, you might also want to consider MS SQL. I don't have experience with that, but I presume it works together with MS Access much more nicely!</p>
<p>If it's only two users, then Access should do just fine if you put the .mdb on a shared drive.</p> <p>Have you tried it first rather than just assume it will be a problem. </p> <p>I believe the recommended max concurrent users for Access is 5 but on occasion I've pushed it past this and never come unstuck.</p> <p>On the other hand I did once use Access as the front end to MySQL in a single user environment (me). It was a singularly unpleasant experience, I can't imagine it would become nicer with two users.</p>
2,767
<p>I'm trying to grasp the concept of continuations and I found several small teaching examples like this one from the <a href="http://en.wikipedia.org/wiki/Continuation" rel="noreferrer">Wikipedia article</a>:</p> <pre><code>(define the-continuation #f) (define (test) (let ((i 0)) ; call/cc calls its first function argument, passing ; a continuation variable representing this point in ; the program as the argument to that function. ; ; In this case, the function argument assigns that ; continuation to the variable the-continuation. ; (call/cc (lambda (k) (set! the-continuation k))) ; ; The next time the-continuation is called, we start here. (set! i (+ i 1)) i)) </code></pre> <p>I understand what this little function does, but I can't see any obvious application of it. While I don't expect to use continuations all over my code anytime soon, I wish I knew a few cases where they can be appropriate. </p> <p>So I'm looking for more explicitely usefull code samples of what continuations can offer me as a programmer.</p> <p>Cheers!</p>
<p>In Algo &amp; Data II we used these all the times to "exit" or "return" from a (long) function</p> <p>for example the BFS algorthm to traverse trees with was implemented like this:</p> <pre><code>(define (BFS graph root-discovered node-discovered edge-discovered edge-bumped . nodes) (define visited (make-vector (graph.order graph) #f)) (define q (queue.new)) (define exit ()) (define (BFS-tree node) (if (node-discovered node) (exit node)) (graph.map-edges graph node (lambda (node2) (cond ((not (vector-ref visited node2)) (when (edge-discovered node node2) (vector-set! visited node2 #t) (queue.enqueue! q node2))) (else (edge-bumped node node2))))) (if (not (queue.empty? q)) (BFS-tree (queue.serve! q)))) (call-with-current-continuation (lambda (my-future) (set! exit my-future) (cond ((null? nodes) (graph.map-nodes graph (lambda (node) (when (not (vector-ref visited node)) (vector-set! visited node #t) (root-discovered node) (BFS-tree node))))) (else (let loop-nodes ((node-list (car nodes))) (vector-set! visited (car node-list) #t) (root-discovered (car node-list)) (BFS-tree (car node-list)) (if (not (null? (cdr node-list))) (loop-nodes (cdr node-list))))))))) </code></pre> <p>As you can see the algorithm will exit when the node-discovered function returns true:</p> <pre><code> (if (node-discovered node) (exit node)) </code></pre> <p>the function will also give a "return value": 'node'</p> <p>why the function exits, is because of this statement:</p> <pre><code>(call-with-current-continuation (lambda (my-future) (set! exit my-future) </code></pre> <p>when we use exit, it will go back to the state before the execution, emptying the call-stack and return the value you gave it.</p> <p>So basically, call-cc is used (here) to jump out of a recursive function, instead of waiting for the entire recursion to end by itself (which can be quite expensive when doing lots of computational work)</p> <p>another smaller example doing the same with call-cc:</p> <pre><code>(define (connected? g node1 node2) (define visited (make-vector (graph.order g) #f)) (define return ()) (define (connected-rec x y) (if (eq? x y) (return #t)) (vector-set! visited x #t) (graph.map-edges g x (lambda (t) (if (not (vector-ref visited t)) (connected-rec t y))))) (call-with-current-continuation (lambda (future) (set! return future) (connected-rec node1 node2) (return #f)))) </code></pre>
<p>Continuations can be used to implement exceptions, a debugger.</p>
5,434
<p>I am developing a Reporting Services solution for a DOD website. Frequently I'll have a report and want to have as a parameter the Service (in addition to other similar mundane, but repetitive parameters like Fiscal Year, Data Effective Date, etc). Basically everything I've seen of SSRS 2005 says it can't be done... but I personally refuse to believe that MS would be so stupid/naive/short-sited to leave something like sharing datasets out of reporting entirely.</p> <p>Is there a clunky (or not so clunky way) to share datasets and still keep the reporting server happy? Will SSRS2008 do this?</p> <p>EDIT:</p> <p>I guess I worded that unclearly. I have a stack of reports. Since I'm in a DoD environment, one common parameter for these reports is Service (army, navy, etc. for those non US users). Since "Business rules" cause me to not be able to use stored procedures; is there a way I can make 1 dataset and link to it from the various reports? Will Reporting 2008 support something like this? I'm getting sick of re-typing the same query in a bunch of reports.</p>
<p>I am not clear if you need to share a dataset, since you have some SQL results that you need to use twice, and don't want to re-compute the same data twice, or you want to do something regarding parameters. So with this "I didn't really understand the question" preface... </p> <ol> <li>You cannot share a dataset. Meaning, you can't, lets say, have a dataset returning table <code>A</code>, and in dataset <code>B</code> try to join with <code>A</code>.</li> <li>If this is really what you want to do, you could use temporary tables to store <code>A</code> and then in dataset <code>B</code> use the temporary table. There are best practices around that, but since I am not sure this is what you need, I won't spend time talking about that right now.</li> </ol>
<p>If you cannot use Stored Procedures, I hope you can use a view.</p> <p>Else you could leave SQL Server and use CSV sheets as data storage.</p>
3,901
<p>I have a new Prusa i3 MK3 and I have noticed that my prints consistently turn out worse on 0.05 mm layer heights than on 0.10 mm. The edges of the 0.05 mm prints turn out rough and sometimes stringy.</p> <p><a href="https://i.stack.imgur.com/KOLcv.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/KOLcv.jpg" alt="Detail of a 0.05 mm layer height printed model"></a></p> <p>Seems similar to a retraction problem but I never have this issue on 0.10 mm prints with the same retraction settings. </p> <p>What might be causing this issue?</p>
<p>When printing at small layer heights (high resolution), you probably need to do some test prints first to see if your normal settings work for the lower layer height. You are most probably experiencing an increased pressure build-up in the nozzle due to the nozzle being closer to the bed. A test that might be useful for you is spacing several objects at different distances to see if the retraction, which you already suspect, may be not working optimally or that the nozzle leaks/oozes an excess amount of filament due to pressure build-up. This shows an example of such a test where the nozzle shows oozing.</p> <p><a href="https://i.stack.imgur.com/xsmW1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/xsmW1.jpg" alt="Effect of object distance"></a></p> <p>Tuning the extruder to alleviate the pressure could be:</p> <ul> <li>an increased retraction length, and/or </li> <li>retraction speed, or </li> <li>looking into the option called coasting where you stop extruding before the printer reaches the end of the deposition path while it still prints material caused by the pressure build-up.</li> </ul> <p><a href="https://i.stack.imgur.com/E1GOE.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/E1GOE.jpg" alt="Tuned extruder"></a></p> <hr> <p><sub><em>When printing at 0.05 mm on my home-build CoreXY I experience much smoother prints opposed to printing in higher layer heights (less resolution), but I also get some very fine stringing, noticeable when printing multiple objects or objects with voids.</em> </sub></p>
<p>One thing that I have learned in my extensive youtubing is that sometimes the hot end can soften the previous layers. Though, take the following advice with a grain of salt as the following is just conceptual for me (I'm still waiting for my first printer to arrive to follow this advice).</p> <p>Tomb of 3D Printed Horrors has a pretty <a href="https://www.youtube.com/watch?v=AqEWl51s9Rw" rel="nofollow noreferrer">good video</a> on printing D&amp;D miniatures that require high detail at small sizes (particularly at the 2 minute mark). His recommendation is to have 0.2 mm thick lines as thinner lines are more susceptible melting when the hot end is laying down subsequent layers. Thicker layers means more plastic to absorb the heat and less deformity. This is probably why your 0.1 mm lines look better than your 0.05 mm lines.</p> <p>Another fix is to keep print speeds somewhat normal or slightly slow. A faster print head heats the previous layers less and can counteract the issue. Running at 60 mm/s may be too quick for quality prints, but running at 10 mm/s is too slow and can reheat the lower layers. Keeping an "average" pace paired with thick enough lines could help you get the prints you want. Though, finding what speeds/thickness is up to you. I don't have the experience to suggest any at the moment.</p>
1,097
<p>The <a href="http://win32.perl.org/" rel="noreferrer">win32.perl.org</a> web site provides references to several Perl distributions for MS Windows.</p> <p>For a long time I have been using ActivePerl from <a href="http://www.activestate.com/" rel="noreferrer">ActiveState</a> but recently I switched to <a href="http://strawberryperl.com/" rel="noreferrer">Strawberry Perl</a>.</p> <p>IMHO The only advantage that Active Perl still has over Strawberry Perl is the fact that it comes with Perl Tk which means its easy to install <a href="http://search.cpan.org/dist/Devel-ptkdb/" rel="noreferrer">Devel::ptkdb</a> the graphical debugger. Other than that, I think Strawberry Perl has all the advantages.</p>
<p><a href="http://strawberryperl.com/" rel="noreferrer">Strawberry Perl</a> is just getting better and better. One problem I've repeatedly had with ActiveState is that my modules sometimes fail to install because I need an upgrade to a core module, but they won't allow that. Thus, everybody who <em>doesn't</em> use Windows can use my code, but they can't do that with ActiveState's Perl.</p> <p>ActiveState also has a very dodgy build system which often fails to report exactly why a module failed to build. I got so tired of emailing and asking for this information that I eventually gave up. I want my code to run on Windows, but if ActiveState doesn't provide me with that information and doesn't give me any option for upgrading core modules, I just can't use it. Some of my modules have NO build failures on any operating system -- except those with ActiveState Perl. Support Strawberry Perl and just don't worry about ActiveState.</p> <p>If ActiveState has fixed their build system and their 'no upgrade to core modules' policy, it's worth revisiting.</p>
<p>The code I write lands in Fortune 500 companies so a "corporate" feeling is helpful. I've used ActivePerl so far, and it's worked fine for both internal tooling and for distribution to those large'ish customers.</p>
9,702
<p>Do you often see in API documentation (as in 'javadoc of public functions' for example) the description of "value limits" as well as the classic documentation ?</p> <p><strong>Note:</strong> I am not talking about <a href="https://stackoverflow.com/questions/20922/do-you-comment-your-code">comments within the code</a></p> <p>By "value limits", I mean:</p> <ul> <li>does a parameter can support a null value (or an empty String, or...) ?</li> <li>does a 'return value' can be null or is guaranteed to never be null (or can be "empty", or...) ?</li> </ul> <p><strong>Sample:</strong></p> <p>What I often see (without having access to source code) is:</p> <pre><code>/** * Get all readers name for this current Report. &lt;br /&gt; * &lt;b&gt;Warning&lt;/b&gt;The Report must have been published first. * @param aReaderNameRegexp filter in order to return only reader matching the regexp * @return array of reader names */ String[] getReaderNames(final String aReaderNameRegexp); </code></pre> <p>What I <em>like to see</em> would be:</p> <pre><code>/** * Get all readers name for this current Report. &lt;br /&gt; * &lt;b&gt;Warning&lt;/b&gt;The Report must have been published first. * @param aReaderNameRegexp filter in order to return only reader matching the regexp * (can be null or empty) * @return array of reader names * (null if Report has not yet been published, * empty array if no reader match criteria, * reader names array matching regexp, or all readers if regexp is null or empty) */ String[] getReaderNames(final String aReaderNameRegexp); </code></pre> <p><strong>My point is:</strong></p> <p>When I use a library with a getReaderNames() function in it, I often do not even need to read the API documentation to guess what it does. But I need to be sure <em>how to use it</em>.</p> <p>My only concern when I want to use this function is: what should I expect in term of parameters and return values ? That is all I need to know to safely setup my parameters and safely test the return value, yet I almost never see that kind of information in API documentation...</p> <p><strong>Edit:</strong> </p> <p>This can influence the usage or not for <em><a href="https://stackoverflow.com/questions/27578#73355">checked or unchecked exceptions</a></em>.</p> <p>What do you think ? value limits and API, do they belong together or not ?</p>
<p>I think they <strong>can</strong> belong together but don't necessarily <strong>have</strong> to belong together. In your scenario, it seems like it makes sense that the limits are documented in such a way that they appear in the generated API documentation and intellisense (if the language/IDE support it).</p> <p>I think it does depend on the language as well. For example, Ada has a native data type that is a "restricted integer", where you define an integer variable and explicitly indicate that it will only (and always) be within a certain numeric range. In that case, the datatype itself indicates the restriction. It should still be visible and discoverable through the API documentation and intellisense, but wouldn't be something that a developer has to specify in the comments.</p> <p>However, languages like Java and C# don't have this type of restricted integer, so the developer would have to specify it in the comments if it were information that should become part of the public documentation.</p>
<p>I think they do, and have always placed comments in the header files (c++) arcordingly.</p> <p>In addition to valid input/output/return comments, I also note which exceptions are likly to be thrown by the function (since I often want to use the return value for...well returning a value, I prefer exceptions over error codes)</p> <pre><code>//File: // Should be a path to the teexture file to load, if it is not a full path (eg "c:\example.png") it will attempt to find the file usign the paths provided by the DataSearchPath list //Return: The pointer to a Texture instance is returned, in the event of an error, an exception is thrown. When you are finished with the texture you chould call the Free() method. //Exceptions: //except::FileNotFound //except::InvalidFile //except::InvalidParams //except::CreationFailed Texture *GetTexture(const std::string &amp;File); </code></pre>
8,681
<p>What considerations do I need to make if I want my code to run correctly on both 32bit and 64bit platforms ?</p> <p>EDIT: What kind of areas do I need to take care in, e.g. printing strings/characters or using structures ?</p>
<p>Options:</p> <p>Code it in some language with a <a href="http://en.wikipedia.org/wiki/Virtual_machine" rel="nofollow noreferrer">Virtual Machine</a> (such as Java)</p> <p>Code it in .NET and don't target any specific architecture. The <a href="http://www.dotnet-guide.com/jit.html" rel="nofollow noreferrer">.NET JIT compiler</a> will compile it for you to the right architecture before running it.</p>
<p>I assume you are still talking about <em>compiling</em> them separately for each individual platform? As running them on both is completely doable by just creating a 32bit binary.</p>
5,247
<p>Suppose your git history looks like this:</p> <p>1 2 3 4 5</p> <p>1–5 are separate revisions. You need to remove 3 while still keeping 1, 2, 4 and 5. How can this be done?</p> <p>Is there an efficient method when there are hundreds of revisions after the one to be deleted?</p>
<p>To combine revision 3 and 4 into a single revision, you can use git rebase. If you want to remove the changes in revision 3, you need to use the edit command in the interactive rebase mode. If you want to combine the changes into a single revision, use squash.</p> <p>I have successfully used this squash technique, but have never needed to remove a revision before. The git-rebase documentation under "Splitting commits" should hopefully give you enough of an idea to figure it out. (Or someone else might know).</p> <p>From the <a href="http://git-scm.com/docs/git-rebase" rel="noreferrer">git documentation</a>:</p> <blockquote> <p>Start it with the oldest commit you want to retain as-is:</p> <blockquote><code>git rebase -i &lt;after-this-commit&gt;</code></blockquote> <p>An editor will be fired up with all the commits in your current branch (ignoring merge commits), which come after the given commit. You can reorder the commits in this list to your heart's content, and you can remove them. The list looks more or less like this:</p> <blockquote><pre>pick deadbee The oneline of this commit pick fa1afe1 The oneline of the next commit ...</pre></blockquote> <p>The oneline descriptions are purely for your pleasure; git-rebase will not look at them but at the commit names ("deadbee" and "fa1afe1" in this example), so do not delete or edit the names.</p> <p>By replacing the command "pick" with the command "edit", you can tell git-rebase to stop after applying that commit, so that you can edit the files and/or the commit message, amend the commit, and continue rebasing.</p> <p>If you want to fold two or more commits into one, replace the command "pick" with "squash" for the second and subsequent commit. If the commits had different authors, it will attribute the squashed commit to the author of the first commit.</p> </blockquote>
<p>Answers of rado and kareem do nothing for me (only message "Current branch is up to date." appears). Possibly this happens because '^' symbol doesn't work in Windows console. However, according to <a href="https://stackoverflow.com/questions/37219/how-do-you-remove-a-specific-revision-in-the-git-history#comment75641303_13389977">this</a> comment, replacing '^' by '~1' solves the problem.</p> <pre><code>git rebase --onto &lt;commit-id&gt;^ &lt;commit-id&gt; </code></pre>
5,789
<p>I'm looking for a simple algorithm to 'serialize' a directed graph. In particular I've got a set of files with interdependencies on their execution order, and I want to find the correct order at compile time. I know it must be a fairly common thing to do - compilers do it all the time - but my google-fu has been weak today. What's the 'go-to' algorithm for this?</p>
<p><a href="http://en.wikipedia.org/wiki/Topological_sorting" rel="noreferrer">Topological Sort</a> (From Wikipedia):</p> <blockquote> <p>In graph theory, a topological sort or topological ordering of a directed acyclic graph (DAG) is a linear ordering of its nodes in which each node comes before all nodes to which it has outbound edges. Every DAG has one or more topological sorts.</p> </blockquote> <p>Pseudo code:</p> <pre><code>L ← Empty list where we put the sorted elements Q ← Set of all nodes with no incoming edges while Q is non-empty do remove a node n from Q insert n into L for each node m with an edge e from n to m do remove edge e from the graph if m has no other incoming edges then insert m into Q if graph has edges then output error message (graph has a cycle) else output message (proposed topologically sorted order: L) </code></pre>
<p>I would expect tools that need this simply walk the tree in a depth-first manner and when they hit a leaf, just process it (e.g. compile) and remove it from the graph (or mark it as processed, and treat nodes with all leaves processed as leaves).</p> <p>As long as it's a DAG, this simple stack-based walk should be trivial.</p>
2,617
<p>I often need to implement some sort of rule system that is user-editable -- the requirements are generally different enough that the same system isn't directly applicable, so I frequently run into the same problem--how do I design a rule system that</p> <ol> <li>is maintainable</li> <li>properly balances expressiveness with ease of use</li> <li>is easily extended (if/when I get (2) wrong). </li> </ol> <p>I think Rule systems / DSLs are extremely valuable, but I don't feel comfortable with my ability to design them properly. </p> <p>What references / tips do you have to offer that may help make this easier?<br> Because of the nature of the problems I run into, existing languages are generally not applicable. (For example, you would <em>not</em> require that general computer users learn python in order to write an email filter.) Similarly, rule <em>languages</em>, such as <a href="http://herzberg.ca.sandia.gov/" rel="noreferrer">JESS</a>, are only a partial solution, since some (simpler) user interface needs to be built on-top of the rule language so non-programmers can make use of it. This interface invariably involves removing some features, or making those features more difficult to use, and that <a href="http://herzberg.ca.sandia.gov/" rel="noreferrer">process</a> poses the same problems described above.</p> <p><em>Edit:</em> To clarify, the question is about <em>designing</em> a rule engine, I'm not looking for a pre-built rule engine. If you suggest a rule engine, please explain how it addresses the question about making good design decisions.</p>
<p>We had an in-house demo of this tool by it's vendor: <a href="http://www.rulearts.com/rulexpress.php" rel="nofollow noreferrer">http://www.rulearts.com/rulexpress.php</a></p> <p>As a company, we have a lot of experience with rule engines (e.g. Cleverpath Aion), but mostly developer-oriented tools. This tool (rulexpress) is very business-people oriented. It's not a rule engine. But it can output all the data in xml (so basically any format you like), and this is something we would then consider as input for a real rule engine, e.g. Windows Workflow Foundation (not one of the bigger/better rule engines, but still).</p> <p>The tool in itself looked pretty good, some stuff I had never seen in any developer-oriented tool.</p> <p>There are also some tools for rule management built around WF, if that's your rule engine of choice, check out InRule.</p> <hr> <p>Edited after original question was clarified: Although I have dabbled in this a long time ago (writing a little language in javacc), I would consider this a bad time investment now. My comment above is in the same spirit: take a simple rule engine, a simple (commercial) UI that makes it easy for business users to maintain, and only invest time in tying the two together.</p>
<p>A Ruby implementation to consider is Ruleby (<a href="http://ruleby.org/wiki/Ruleby" rel="nofollow noreferrer">http://ruleby.org/wiki/Ruleby</a>)</p>
9,301
<p>Why does the Ultimaker 3D Printer has a Heater + Heater transfer plate (aluminium) + Glass?</p> <p>I wonder why a glass plate, and if is possible to remove the glass and print directly in the aluminium plate adjusting the heating.</p> <p><a href="https://ultimaker.com/en/products/ultimaker-3" rel="nofollow noreferrer">Link to the ultimaker</a>.</p> <p>Pictures:</p> <p><a href="https://i.stack.imgur.com/hBsTd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hBsTd.jpg" alt="Ultimaker view"></a></p> <p><a href="https://i.stack.imgur.com/uf2vc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uf2vc.jpg" alt="PCB Heater view"></a></p>
<p>Printing directly onto aluminum is something I've never seen before, likely due to the fact that PLA (and other materials) do not adhere reliably to aluminum. Instead, many opt to use blue tape, kapton tape, PEI, buildtak/commercial build surface, or an additional build surface, such as glass. When heated, clean glass can be directly printed on. The use of a glue stick, wood glue, isopropyl alcohol, the above adhesion aids, and others can help adhere your part better hot or cold.</p> <p>Can you remove the glass, add any of the above to the aluminum plate, and print on that? So long as it's a clean, flat surface, yes. But it'll be more work for you to replace or clean the build surface, as you won't be able to simply remove the glass and replace it. You're not gaining much by taking out the glass. A slightly faster bed heat-up, perhaps.</p> <p>As for <em>why</em> Ultimaker went with an aluminum transfer plate, that is a slightly more <a href="https://engineering.stackexchange.com/questions/14722/why-does-the-ultimaker-3d-printer-has-a-heater-heater-transfer-plate-aluminiu/14725#14725">engineering</a> oriented question.</p>
<p>Printing directly onto aluminum is something I've never seen before, likely due to the fact that PLA (and other materials) do not adhere reliably to aluminum. Instead, many opt to use blue tape, kapton tape, PEI, buildtak/commercial build surface, or an additional build surface, such as glass. When heated, clean glass can be directly printed on. The use of a glue stick, wood glue, isopropyl alcohol, the above adhesion aids, and others can help adhere your part better hot or cold.</p> <p>Can you remove the glass, add any of the above to the aluminum plate, and print on that? So long as it's a clean, flat surface, yes. But it'll be more work for you to replace or clean the build surface, as you won't be able to simply remove the glass and replace it. You're not gaining much by taking out the glass. A slightly faster bed heat-up, perhaps.</p> <p>As for <em>why</em> Ultimaker went with an aluminum transfer plate, that is a slightly more <a href="https://engineering.stackexchange.com/questions/14722/why-does-the-ultimaker-3d-printer-has-a-heater-heater-transfer-plate-aluminiu/14725#14725">engineering</a> oriented question.</p>
562
<p>I have an Anet A8, and recently updated the firmware to Marlin 1.1.8. My only change was replacing the configuration files by the Anet A8 sample files built in with the firmware zip file.</p> <p>Everything works fine but, sometimes, right after finishing a printing (while doing the "home all"), the LCD shows some weird data, like this:</p> <p><a href="https://i.stack.imgur.com/8H1Vn.jpg" rel="nofollow noreferrer" title="LCD weird data"><img src="https://i.stack.imgur.com/8H1Vn.jpg" alt="LCD weird data" title="LCD weird data"></a></p> <p>The same happens when push the "confirm", after the mesh bed leveling.<br> I'd like to know why it happens. Is it a Marlin bug?</p>
<p>This is a known problem of the Anet A8 display, it is caused by electrical interference. Pressing the middle button will refresh the display.</p> <p>This is prone to happen when doing long prints. </p> <p>There are some reported successes of people inserting ferrite beads or toroidal rings. </p> <p>No, this is not a firmware issue, this is a hardware issue.</p>
<p>I have solved completely, I covered the flat cable, with copper tape, this shield should be connected to the 0V of the power supply. All disorders will disappear.</p>
946
<p>Is it possible for UDP data to come to you corrupted? I know it is possible for it to be lost.</p>
<p>UDP packets use a 16 bit checksum. It is not impossible for UDP packets to have corruption, but it's pretty unlikely. In any case it is not more susceptible to corruption than TCP.</p>
<p>Short answer: YES.</p> <p>Detailed answer:</p> <p>About 7 years ago(maybe 2011?) We found that UDP datagrams are unintentionally changed when a UDP datagram is exchanged between a computer in China and another one in Korea. Of course, Checksum in UDP packet header is also reculculated regarding to the payload change. There were no malware software in two computers.</p> <p>We found that the unintentional change only occurs when these conditions match:</p> <ul> <li>First several bytes of datagrams are similar to the previous datagram</li> <li>Only occurse when UDP datagrams go from one nation to another</li> </ul> <p>I don't the cause exactly, but I roughly guess it is <a href="https://en.wikipedia.org/wiki/Golden_Shield_Project" rel="nofollow noreferrer">China Golden Shield</a>. </p> <p>So we added datagram garbling algorithm into out software ProudNet and the problem went away. It is not difficult to implement. Just encode or obfuscate first several bytes of your datagram.</p>
7,023
<p>The Benchy looks good for the most part except for some boogers on the chimney</p> <p><a href="https://i.stack.imgur.com/fV2oD.jpg" rel="nofollow noreferrer" title="Photo of a printed Benchy with zits on the chimney"><img src="https://i.stack.imgur.com/fV2oD.jpg" alt="Photo of a printed benchy with zits on the chimney" title="Photo of a printed Benchy with zits on the chimney" /></a></p> <p>And some stringing on the bow, near the front deck.</p> <p><a href="https://i.stack.imgur.com/EimB6.jpg" rel="nofollow noreferrer" title="Photo of the top of a printed Benchy with minor stringing problems"><img src="https://i.stack.imgur.com/EimB6.jpg" alt="Photo of the top of a printed benchy with minor stringing problems" title="Photo of the top of a printed Benchy with minor stringing problems" /></a></p> <p>Here are my settings. On another roll of Inland PETG, I printed a Benchy at 30 mm/s and it came out perfect. Is there any way to improve my results at higher speeds? Maybe 4 or 5 for retraction and/or faster retraction speeds? I figure I ask before taking shots in the dark. I was told to not go below 235 °C for PETG so that seems like lowering the temperature is out of the question.</p> <p>Any ideas? Below are my settings.</p> <p>The printer is a Sovol Sv01 Pro (this is similar to an Ender 3 S1)</p> <ul> <li>direct drive extruder</li> <li>Creality silent board</li> <li>CR Touch</li> <li>Marlin 2.0</li> <li>hot end like and Ender 3 Pro with an MK8</li> <li>PEI sheet</li> <li>K value 2.0 - this was the factory setting</li> </ul> <p>All the parts are pretty new since I bought the printer on an Amazon Prime day about a month ago.</p> <p>Settings (using Inland PETG - Yellow):</p> <ul> <li>a few days ago it had a 6hr session in a filament dryer</li> <li>235 °C nozzle</li> <li>70 °C bed</li> <li>retraction 3.0 mm</li> <li>print speed 40 mm/s</li> <li>print acceleration 500 mm/s</li> <li>jerk 12 mm/s</li> </ul>
<p>The application doesn't look to be demanding at all from a material point of view. Operation below 40 °C and 70-90% RH is not that special.</p> <p>Once taken out PLA for creep, most rigid filaments would work. Nylon deform under constant stress, so screws may get loose over time.</p> <p>PETG, ABS, ABS+ (TitanX/niceABS are about as easy to print as PLA), ASA, ...</p> <p>For ease of print, PETG or ABS+ should be fine, but ABS will deform more before breaking, while PETG tends to shatter when it breaks.</p>
<p>My first choice for this would be PET. Not PETG, which is a mess of blobbing, stringing, warping, creep under load, etc., but real PET, also known as BPET (bottle PET) or HTPET (high temperature PET, because it needs high temperatures to print and has high HDT)</p> <p>Unlike ASA, PC, and nylon, PET is easy to print. It does not need a heated chamber or even a heated bed (although it does a little better with the bed a little above room temperature, at 30-45°C) and you don't have to fight with warping or compensate for significant part shrinkage.</p> <p>The HTPET I use is rated for high HDT, 87°C as-is, and 100°C annealed. You can probably arrange for it to self-anneal during the printing process with the right settings; I'm planning to experiment with this at some point. To give you an idea how readily it anneals, the smokestack of a Benchy tends to anneal while printing it just from the accumulation of heat in a small area.</p> <p>It needs high print temperatures. 275°C is about the minimum. The manufacturer of the HTPET I used recommends 285°C for high speed, but I've found flow increases all the way up to around 320°C if you want to go faster.</p> <p>It is somewhat hard to find PET filament, despite it being fairly easy to make your own from recycling bottles. I would not really recommend that for your project because it's hard to get perfect flow to simultaneously ensure precision and part strength. There are at least a few manufacturers selling it in the US and probably elsewhere though.</p>
2,196
<p>I've followed the <a href="http://incubator.apache.org/couchdb/index.html" rel="noreferrer">CouchDB</a> project with interest over the last couple of years, and see it is now an Apache Incubator project. Prior to that, the CouchDB web site was full of <em>do not use for production code</em> type disclaimers, so I'd done no more than keep an eye on it. I'd be interested to know your experiences if you've been using CouchDB either for a live project, or a technology pilot. </p>
<p>I use the CouchDB to power a Facebook application (over 35k monthly active users). For a while it was using MySQL but after porting the entire project over from Perl to Erlang, I decided to go for the gold and migrate all of the data into CouchDB and use that instead.</p> <p>CouchDB has been a great data store to work with. I think that it is on track to becoming a major player in web-based services.</p>
<p>I used couchdb twice in production. First was the wiki likes project and I think that couchdb was perfect candidate for that role. Saving the version of all docs helps a lot. The second project was quite query loaded and idea was dumping social data first, then query it with various filters. It was looked like standard CouchDB query features looks a bit pure for our needs. But we add Lucene like a full text indexer and after that doing many queries during Lucene part. And that solution looks good enough. </p>
4,865
<p>Stack Overflow has a subversion version number at the bottom:</p> <blockquote> <p>svn revision: 679</p> </blockquote> <p>I want to use such automatic versioning with my <code>.NET Web Site/Application</code>, Windows Forms, WPD projects/solutions.</p> <p>How do I implement this?</p>
<p>Looks like Jeff is using <a href="https://web.archive.org/web/20090130045625/http://confluence.public.thoughtworks.org/display/CCNET/What+is+CruiseControl.NET" rel="nofollow noreferrer">CruiseControl.NET</a> based on some leafing through the podcast transcripts. This seems to have automated deployment capabilities from source control to production. Might this be where the insertion is happening?</p>
<p><code>$rev</code> and others like it are revisions for the individual files, so they won't change unless the file changes. The number on the webpage is (most likely, I'm assuming here) the svn revision number for the whole project. That is different than the file revisions, which others have been pointing to.</p> <p>In this case I assume that CCNET is pulling the revision number of the project and rewriting a part of the webpage with that number. Any CI solution should be able to do this, set this up myself with CCNET and Teamcity (although not webpages, but automatic versioning of deployment/assembly versions).</p> <p>In order for you to do this, use a CI solution that supports it, or use your build process (MSbuild/Nant) to store that version and write it to the files before "deploying" it.</p>
2,262
<p>So I'm not quite convinced about OpenID yet, and here is why:</p> <p>I already have an OpenID because I have a Blogger account. But I discovered that Blogger seems to be a poor provider when I tried to identify myself on the <a href="http://altdotnet.org" rel="nofollow noreferrer">altdotnet</a> page and recieved the following message: </p> <blockquote> <p><strong>You must use an OpenID persona that specifies a valid email address.</strong></p> </blockquote> <p>Lets forget the details of this little error and assume that I want to change to a different provider. So I sign up with a different provider and get a new, different OpenID - how would I switch my existing StackOverflow account to be associated with my new OpenID?</p> <p>I understand this would be easy if I had my own domain set up to delegate to a provider, because I could just change the delegation. Assume I do not have my own domain.</p>
<p>Ideally Stack Overflow would allow you to change your OpenID.</p> <p>OTOH, ideally you would have set up <a href="http://wiki.openid.net/Delegation" rel="nofollow noreferrer">OpenID delegation</a> on your own site, and used that to identify yourself.</p> <p>With delegation, you would need only change which service you delegate to. You'd still be identified by your own URL that you control. But that doesn't help now unless Stack Overflow lets you change it. Most sites tie OpenIDs to real accounts, and would let you switch or at least add additional OpenIDs. Doesn't seem like you could map OpenIDs to accounts 1:1 unless the result of access is totally trivial; otherwise you're in a situation like this where you lose your existing questions, answers, and reputation for switching IDs.</p>
<p>This is a problem for me because I changed my email in the way of the new fad of firstName.lastName@gmail.com. After much scouring of this Web site, I am confirming that those of you in my situation are out of luck until further notice because of the issue described in the question.</p> <p>Either hold on to that old ID or give up your points.</p>
3,471
<p>Ender3 v2, SIENOC PETG which advises temperature of 230-250 °C on the box. I'm printing on top of cleaned blue tape, using a temperature of 230 °C for the nozzle and 80 °C for the bed.</p> <p>I've had all sorts of trouble getting first layer to stick but finally managed it. However the thin end of this hook has now warped and the other end is too.</p> <p><a href="https://i.imgur.com/AfdQyGk.jpg" rel="nofollow noreferrer" title="Photo showing warped hook (left hand side)"><img src="https://i.imgur.com/AfdQyGk.jpg" alt="Photo showing warped hook (left hand side)" title="Photo showing warped hook (left hand side)" /></a></p> <p>Looking at the image above, you can see it's much thinner at that end. Should I try a lower nozzle temperature? Or bed? Or both?</p> <p>The fans are at 50 % (set in Cura), should I have left them on 100 %?</p> <hr /> <p>I have to mention that the tape has been cleaned with isopropyl alcohol. I can print PLA no problem direct to the bed but am having so much trouble with PETG - rather than warping this could actually be adhesion problems. I've tried a higher initial layer (0.3 mm vs 0.2 mm), 0.1 mm Z offset, gapped to 1 sheet of paper as per PLA, then 2 sheets - I've done that 50 mm in on each corner and then checked it in the middle of the bed too. Initial layer is at 10 mm/s and then to 40 mm/s</p> <p>As you can see in the picture the brim looks rather flattened, but if I give more gap (e.g. 3 sheets) it doesn't even stick at all.</p> <p>I have managed to print a benchy after maybe 6 attempts, but this was luck and had really poor adhesion, a gentle tap with my finger dislodged it. The actual print was fine.</p> <p>Tempted to try another PETG but wanted to make sure I'm not missing anything obvious - at the moment I can't even print the brim again because it won't stick.</p> <p>I'm really confused because a lot of I read suggests PETG sticks really well but I've having the exact opposite experience.</p>
<p>There are many types of <a href="https://3dprinting.stackexchange.com/questions/10998/e3d-v6-original-vs-clone/11012#11012">heatbreak clones</a>. In cour case, your clone effectively turns your hotend into an e3d Lite6, not an all-metal e3d v6. To function properly, the PTFE liner needs to butt against the nozzle or you will quickly develop leak and clog issues.</p> <p>This means, handle it like a Lite6, which has a max of 245 °C listed, but under usual operation should not exceed 230 °C.</p>
<p>Long story short, you can print Nylon with a Teflon tube. I've done it. P.S. The nylon absorbs water like nothing you've ever seen. Even after the part is printed, it absorbs water, and expands!</p>
1,713
<p>I use a stream reader to import some data and at the moment I hardcode a small sample file in the test to do the job.</p> <p>Is it sensible to use Mock Objects with this and how ?</p>
<p>I don't see any points to mock StreamReader unless you're making StreamReader derived class. If you need to provide test input via StreamReader, just read some predefined data from any suitable source.</p>
<p>When testing code that depends on streams, streamreaders and streamwriters I usually use the memorystream object for testing. No mocking framework needed here.</p>
8,753
<p>I am looking into game programming in Java to see if it is feasible. When googling for it I find several old references to Java2D, Project Darkstar (Sun's MMO-server) and some books on Java game programming. But alot of the information seems to be several years old.</p> <p>So the question I am asking, is anyone creating any games in Java SE 1.5 or above?</p> <p>If so, what frameworks are used and are there any best practices or libraries available?</p>
<p>there is the excellent open source 3d engine called jMonkey (<a href="http://www.jmonkeyengine.com" rel="noreferrer">http://www.jmonkeyengine.com</a>) which is being used for a few commercial projects as well as hobby developers... there is also at a lower level the lwjgl library which jmonkeyengine is built on which is a set of apis to wrap opengl as well as provide other game specific libs...</p>
<p>I've made a <a href="http://www.java-gaming.org/index.php/topic,23958.msg199708.html#msg199708" rel="nofollow noreferrer">list of a bunch of tutorials</a> that should be of help</p>
8,992
<p>I have a few internal .net web application here that require users to "log out" of them. I know this may seem moot on an Intranet application, but nonetheless it is there.</p> <p>We are using Windows authentication for our Intranet apps, so we tie in to our Active Directory with Basic Authentication and the credentials get stored in the browser cache, as opposed to a cookie when using .net forms authentication.</p> <p>In IE6+ you can leverage a special JavaScript function they created by doing the following:</p> <pre><code>document.execCommand("ClearAuthenticationCache", "false") </code></pre> <p>However, for the other browsers that are to be supported (namely Firefox at the moment, but I strive for multi-browser support), I simply display message to the user that they need to close their browser to log out of the application, which effectively flushes the application cache.</p> <p>Does anybody know of some commands/hacks/etc. that I can use in other browsers to flush the authentication cache?</p>
<p>I've come up with a fix that seems fairly consistent but is hacky and <a href="https://stackoverflow.com/questions/6277919">I'm still not happy with it</a>.</p> <p>It does work though :-)</p> <p>1) Redirect them to a Logoff page</p> <p>2) On that page fire a script to ajax load another page with dummy credentials (sample in jQuery):</p> <pre><code>$j.ajax({ url: '&lt;%:Url.Action("LogOff401", new { id = random })%&gt;', type: 'POST', username: '&lt;%:random%&gt;', password: '&lt;%:random%&gt;', success: function () { alert('logged off'); } }); </code></pre> <p>3) That should always return 401 the first time (to force the new credentials to be passed) and then only accept the dummy credentials (sample in MVC):</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult LogOff401(string id) { // if we've been passed HTTP authorisation string httpAuth = this.Request.Headers["Authorization"]; if (!string.IsNullOrEmpty(httpAuth) &amp;&amp; httpAuth.StartsWith("basic", StringComparison.OrdinalIgnoreCase)) { // build the string we expect - don't allow regular users to pass byte[] enc = Encoding.UTF8.GetBytes(id + ':' + id); string expected = "basic " + Convert.ToBase64String(enc); if (string.Equals(httpAuth, expected, StringComparison.OrdinalIgnoreCase)) { return Content("You are logged out."); } } // return a request for an HTTP basic auth token, this will cause XmlHttp to pass the new header this.Response.StatusCode = 401; this.Response.StatusDescription = "Unauthorized"; this.Response.AppendHeader("WWW-Authenticate", "basic realm=\"My Realm\""); return Content("Force AJAX component to sent header"); } </code></pre> <p>4) Now the random string credentials have been accepted and cached by the browser instead. When they visit another page it will try to use them, fail, and then prompt for the right ones.</p>
<p>Hopefully this will be useful until someone actually comes along with an explicit answer - <a href="http://forums.mozillazine.org/viewtopic.php?t=366028&amp;" rel="nofollow noreferrer"><strong>this issue was discussed two years ago on a message board</strong></a>.</p> <p>HTH</p>
5,126
<p>I recently read this Question about <a href="https://stackoverflow.com/questions/3630/sqlite-vs-mysql">SQLite vs MySQL</a> and the answer pointed out that SQLite doesn't scale well and the official website <a href="http://www.sqlite.org/whentouse.html" rel="noreferrer">sort-of confirms this</a>, however.</p> <p>How scalable is SQLite and what are its upper most limits?</p>
<p>Yesterday I released a small site<sup>*</sup> to track your rep that used a shared SQLite database for all visitors. Unfortunately, even with the modest load that it put on my host it ran quite slowly. This is because the entire database was locked every time someone viewed the page because it contained updates/inserts. I soon switched to MySQL and while I haven't had much time to test it out, it seems much more scaleable than SQLite. I just remember slow page loads and occasionally getting a database locked error when trying to execute queries from the shell in sqlite. That said, I am running another site from SQLite just fine. The difference is that the site is static (i.e. I'm the only one that can change the database) and so it works just fine for concurrent reads. Moral of the story: only use SQLite for websites where updates to the database happen rarely (less often than every page loaded).</p> <p><strong>edit</strong>: I just realized that I may not have been fair to SQLite - I didn't index any columns in the SQLite database when I was serving it from a web page. This partially caused the slowdown I was experiencing. However, the observation of database-locking stands - if you have particularly onerous updates, SQLite performance won't match MySQL or Postgres.</p> <p><strong>another edit:</strong> Since I posted this almost 3 months ago I've had the opportunity to closely examine the scalability of SQLite, and with a few tricks it can be quite scalable. As I mentioned in my first edit, database indexes dramatically reduce query time, but this is more of a general observation about databases than it is about SQLite. However, there is another trick you can use to speed up SQLite: <a href="http://www.sqlite.org/lang_transaction.html" rel="noreferrer">transactions</a>. Whenever you have to do multiple database writes, put them inside a transaction. Instead of writing to (and locking) the file each and every time a write query is issued, the write will only happen once when the transaction completes.</p> <p>The site that I mention I released in the first paragraph has been switched back to SQLite, and it's running quite smoothly once I tuned my code in a few places.</p> <p><sup>* the site is no longer available</sup></p>
<p>SQLite's website (the part that you referenced) indicates that it can be used for a variety of multi-user situations.</p> <p>I would say that it can handle quite a bit. In my experience it has always been very fast. Of course, you need to index your tables and when coding against it, you need to make sure you use parameritized queries and the like. Basically the same stuff you would do with any database to improve performance.</p>
7,870
<p>What are the different approaches for creating scheduled tasks for web applications, with or without a separate web/desktop application?</p>
<p>If we're talking Microsoft platform, then I'd always develop a separate Windows Service to handle such batch tasks.</p> <p>You can always reference the same assemblies that are being used by your web application to avoid any nasty code duplication.</p>
<p>I think there are easier ways than using cron (Linux) or Task Scheduler (Windows). You can build this into your web-app using: (a) quartz scheduler, </p> <p>or if you don't want to integrate another 3rd party library into your application: (b) create a thread on startup which uses the standard Java 'java.util.Timer' class to run your tasks.</p>
4,335
<p>In Python, given a module X and a class Y, how can I iterate or generate a list of all subclasses of Y that exist in module X?</p>
<p>Here's one way to do it:</p> <pre><code>import inspect def get_subclasses(mod, cls): """Yield the classes in module ``mod`` that inherit from ``cls``""" for name, obj in inspect.getmembers(mod): if hasattr(obj, "__bases__") and cls in obj.__bases__: yield obj </code></pre>
<p>Given the module foo.py</p> <pre><code>class foo(object): pass class bar(foo): pass class baz(foo): pass class grar(Exception): pass def find_subclasses(module, clazz): for name in dir(module): o = getattr(module, name) try: if issubclass(o, clazz): yield name, o except TypeError: pass &gt;&gt;&gt; import foo &gt;&gt;&gt; list(foo.find_subclasses(foo, foo.foo)) [('bar', &lt;class 'foo.bar'&gt;), ('baz', &lt;class 'foo.baz'&gt;), ('foo', &lt;class 'foo.foo'&gt;)] &gt;&gt;&gt; list(foo.find_subclasses(foo, object)) [('bar', &lt;class 'foo.bar'&gt;), ('baz', &lt;class 'foo.baz'&gt;), ('foo', &lt;class 'foo.foo'&gt;), ('grar', &lt;class 'foo.grar'&gt;)] &gt;&gt;&gt; list(foo.find_subclasses(foo, Exception)) [('grar', &lt;class 'foo.grar'&gt;)] </code></pre>
6,609
<p>I was using Codeplex and tried connecting to their source control using Team Explorer, with no joy. </p> <p>I also tried connecting with HTTPS or HTTP, using the server name and the project name. As I do not have a user account on Codeplex I could not login.</p> <p>I am just trying to check out some code without changing it. My question is:</p> <p>How can I connect Team Explorer to a Codeplex server anonymously?</p>
<p>I think you have to use the <a href="http://www.codeplex.com/CodePlexClient" rel="nofollow noreferrer">CodePlex Source Control Client</a>. In includes cpc.exe which supports the anonymous access features of CodePlex TFS servers for non-coordinator/developer access. But according to the site:</p> <blockquote> <p>The CodePlex Client is not currently being maintained. The focus of the CodePlex team now is on the <a href="http://www.codeplex.com/SvnBridge" rel="nofollow noreferrer">SvnBridge</a>.</p> </blockquote> <p>I'm using TortoiseSVN with SvnBridge with no problems. </p>
<p>I think it's not possible with Team Explorer. But you can with <a href="http://www.codeplex.com/CodePlexClient" rel="nofollow noreferrer">CodePlex Source Control Client</a> or <a href="http://www.codeplex.com/CodePlex/Wiki/View.aspx?title=Using%20TortoiseSVN%20with%20CodePlex&amp;referringTitle=Source%20control%20clients" rel="nofollow noreferrer">Tortoise</a></p>
5,839
<p>At my work we are running a group of tests that consist of about 3,000 separate test cases. Previously we were running this entire test suite on one machine, which took about 24-72 hours to complete the entire test run. We now have created our own system for grouping and distributing the tests among about three separate machines and the tests are prioritized so that the core tests get run first for more immediate results and the extra tests run when there is an available machine.</p> <p>I am curious if anyone has found a good way to distribute their tests among several machines to reduce total test time for a complete run and what tools were used to achieve that. I've done some research and it looks like TestNG is <a href="http://beust.com/weblog/archives/000362.html" rel="noreferrer">moving in this direction</a>, but it looks like it is still under quite a bit of development. </p> <p>We don't plan on rewriting any of our tests, but as we add new tests and test new products or add-ons I'd like to be able to deal with the fact that we are working with very large numbers of tests. On the other hand, if we can find a tool that would help distribute our Junit <code>3.x</code> tests even in a very basic fashion, that <em>would</em> be helpful since we wouldn't have to maintain our own tooling to do that.</p>
<p>I've seen some people having a play with <a href="http://216.93.179.140:8080/wiki/display/GG15UG/Distributed+JUnit+Overview" rel="nofollow noreferrer">distributed JUnit</a>. I can't particularly vouch for how effective it is, but the other teams I've seen seemed to think it was straight forward enough. Hope that helps.</p>
<p>Our build people use Mozilla Tinderbox. It seems to have some hooks for distributed testing. I'm sorry not to know the details but I thought I would at least pass on the pointer to you.</p> <p>It's also nice coz you can find out immediately when a build breaks, and what checkin might have been the culprit.</p> <p><a href="http://www.mozilla.org/tinderbox.html" rel="nofollow noreferrer">http://www.mozilla.org/tinderbox.html</a></p>
2,968
<p>We're in the process of upgrading one of our SQL Server instances from 2000 to 2005. I installed the performance dashboard (<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=1d3a4a0d-7e0c-4730-8204-e419218c1efc&amp;displaylang=en" rel="noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyId=1d3a4a0d-7e0c-4730-8204-e419218c1efc&amp;displaylang=en</a>) for access to some high level reporting. One of the reports shows missing (recommended) indexes. I think it's based on some system view that is maintained by the query optimizer.</p> <p>My question is what is the best way to determine when to take an index recommendation. I know that it doesn't make sense to apply all of the optimizer's suggestions. I see a lot of advice that basically says to try the index and to keep it if performance improves and to drop it if performances degrades or stays the same. I wondering if there is a better way to make the decision and what best practices exist on this subject.</p>
<p>First thing to be aware of:</p> <p>When you upgrade from 2000 to 2005 (by using detach and attach) make sure that you:</p> <ol> <li>Set compability to 90</li> <li>Rebuild the indexes</li> <li>Run update statistics with full scan</li> </ol> <p>If you don't do this you will get suboptimal plans.</p> <p>IF the table is mostly write you want as few indexes as possible IF the table is used for a lot of read queries you have to make sure that the WHERE clause is covered by indexes.</p>
<p>Your best researching the most common type of queries that happen on your database and creating indexes based on that research.</p> <p>For example, if there is a table which stores website hits, which is written to very very often but hardly even read from. Then don't index the table in away.</p> <p>If how ever you have a list of users which is access more often than is written to, then I would firstly create a clustered index on the column that is access the most, usually the primary key. I would then create an index on commonly search columns, and those which are use in order by clauses.</p>
2,598
<p>If you have a site which sends out emails to the customer, and you want to save a copy of the mail, what is an effective strategy?</p> <p>If you save it to a table in your database (e.g. create a table called Mail), it gets very large very quickly.</p> <p>Some strategies I've seen are:</p> <ol> <li>Save it to the file system</li> <li>Run a scheduled task to clear old entries from the database - but then you wind up not having a copy;</li> <li>Create a separate table for each time frame (one each year, or one each month)</li> </ol> <p>What strategies have you used?</p>
<p>I don't agree that gmail is an effective backup for business data.</p> <p>Why trust your business information to a provider who makes no guarantees of service, or over who you have no control whatsoever?</p> <p>Makes no sense to me.</p> <p>Depending on how frequently you need to access this information, I'd say go with the filesystem or database archive. At least that way, you have control over your own data.</p>
<p>We save the email to a database table. It really doesn't get that big that quickly. We've a table with 32,000 emails in it (they're biggish emails too @ 50kb per email) and with compression, the file only uses 16MB. </p> <p>If you're sending a shed load of email, then know that GMail(free) currently only allows 7GB of data. I'd be happy holding that on a disk. </p>
7,462
<p>When I use the default java locale on my linux machine it comes out with the US locale settings, where do I change this so that it comes out with the correct locale?</p>
<p>With the <code>user.language</code>, <code>user.country</code> and <code>user.variant</code> properties.</p> <p>Example:</p> <p><code>java -Duser.language=th -Duser.country=TH -Duser.variant=TH SomeClass</code></p>
<p>One way to control the locale settings is to set the java system properties user.language and user.region.</p>
8,953
<p>I recently bought an Anet A8 (<a href="https://pevly.com/anet-a8-3d-printer-review/" rel="noreferrer">https://pevly.com/anet-a8-3d-printer-review/</a>). I've managed to get everything up and running, leveled the board, but am now running into a problem.</p> <p>At the start of the print, the printer moves to 0,0,0, bumps into the switches a couple times (I assume to calibrate or so?), and then starts "printing". But the nozzle "randomly" moves to either an X of 0 or an Y of 0 before returning to the printing position. This movement seems to pull off any basis the printer managed to lay down, which then forms a nice "ball" on the nozzle, to which the rest gets stuck. (I'm still having some other issues with getting the filament to stick to the bed, but there's plenty I still have to try out for that.)</p> <p>During one attempt of printing a very simple small cube, I carefully pulled the filament "ball" from the nozzle while it did one of those movements to X 0, and afterwards it managed to lay down the bottom layer perfectly fine. This causes me to believe those movements are the biggest problem I'm facing right now.</p> <p>After it did the first layer, it moved up a bit, moved to X 0, back to the model, and got stuck on a piece of plastic that was standing upwards.</p> <p>These movements seem to happen at around the same phase in the print, and happen quite consistently. Is this normal behavior? If so, how do I make sure the filament does not get pulled off during these weird movements? If not, how do I get rid of them?</p> <p>(No, not a duplicate of <a href="https://3dprinting.stackexchange.com/questions/962/printer-randomly-moves-to-home-during-printing-then-resumes-as-normal">Printer randomly moves to home during printing, then resumes as normal</a> as I print directly from PC.)</p> <hr> <p>Edit to add more information:</p> <p>I use Cura 3.0.4 for printing, the stock Anet A8 firmware, and am attempting to print the cube model that comes with Windows 10. (Yes, I've tried different models, same result.)</p> <p>I seem to have more issues, in the video it's visible that the feeding does not seem to work too great, but I think the random movements are the most clear and biggest problem right now, so I should tackle that first.</p> <p>In Cura I've used the Pruisa I3 printer, with the following G-codes:</p> <pre><code>G21 ;metric values G90 ;absolute positioning M82 ;set extruder to absolute mode M107 ;start with the fan off G28 X0 Y0 ;move X/Y to min endstops G28 Z0 ;move Z to min endstops G29 G1 Z15.0 F9000 ;move the platform down 15mm G92 E0 ;zero the extruded length G1 F200 E3 ;extrude 3mm of feed stock G92 E0 ;zero the extruded length again G1 F9000 M117 Printing... </code></pre> <p>and end</p> <pre><code>M104 S0 ;extruder heater off M140 S0 ;heated bed heater off (if you have it) G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way M84 ;steppers off G90 ;absolute positioning </code></pre> <p>(Yes, I added in the G29 in the start code manually, as I bought the official auto-leveling sensor. I'm not sure if it works though, but I read somewhere that I might need a different version of the firmware to support it properly.)</p> <p><a href="https://youtu.be/lrk8iG1H4ig" rel="noreferrer">And here's a video showing what my printer does do exactly.</a> It started printing from the center in this case, it seems to randomly either move to the middle or to 0,0,0 when I abort the print.</p>
<p>I switched to different firmware (the latest Marlin), now the problem has been resolved. So it seems to me that those random movements are not in fact normal, but a flaw in the firmware.</p>
<p>Formating SD card fixes issue for me. I think that writing many times to the same block of SD card corrupt some block of flash SD card memory.</p>
757
<p>My employer was recently acquired by a much larger company. In the process of sorting out all the legal details around our licenses for our development software, we have learned that the vendor of our IDE charges a "nominal" fee of 25% of the cost of a new license to transfer our existing licenses to the new corporate name.</p> <p>This struck me as absurd. I have not seen such a customer-unfriendly policy from any other vendor. Has anyone else seen this type of policy? Am I way off base in considering this unfriendly and abnormal?</p>
<p>Unfriendly? Yes. Abnormal? No. Its actually very common for tools with a hefty per-seat license fee to charge for a transfer after acquisition. I believe they do it because they can: the cost of transferring license is either overlooked during the M&amp;A due diligence or is considered inconsequential compared to the rest.</p> <p>The tool vendor justifies the fee because they now have one less potential customer, and the combined company will be paying a lower price per seat due to volume discounts.</p>
<p>I would have expected your new overlords to have been made aware of this as part of their takeover plans. Part of the process involves checking for exactly this kind of gotcha.</p> <p>Sounds like they chose to ignore the information or did not check it out.</p>
7,278
<p>I'm working with an older MakerBot Replicator clone, actually a Flashforge Creator 1, with original Creator firmware.</p> <ul> <li>I'm able to design objects, using Solidworks, and exporting the file as xxx.stl (ascii)</li> <li>Then I use Slic3r to generate tool paths with output as xxx.gcode</li> <li>finally, I use <a href="https://markwal.github.io/GpxUi/" rel="nofollow noreferrer">GPX UI</a> to generate a xxx.x3g file.</li> </ul> <p>I don't understand where on the build plate the print starts. Is that controlled by the 3d printer's firmware values, or something else in the chain from .stl --&gt; .gcode --&gt; x3g ?? Right now my prints start in the corner nearest 0,0.0, instead of in the middle of the build plate.</p> <p>How do I control where to place the 3d print on the build plate?</p> <p>edit: Apologies for the delay. As a result of the answers posted here, I did a whole bunch more testing. The initial response from @mick, seems to indicate that what you see in the Slicer preview is what you'll see on the print bed. That makes sense, but <strong>that is definitely not what I'm seeing</strong>. I definitely don't see anywhere anything that remotely looks like a check the box [] center. Here's what I do see:</p> <p>When I drop the object into Slic3r, it goes to middle of build plate.</p> <p><a href="https://i.stack.imgur.com/kNiWQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kNiWQ.jpg" alt="Slicer Preview" /></a></p> <p><a href="https://i.stack.imgur.com/JFgvU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JFgvU.jpg" alt="Slic3r Settings" /></a></p> <p><a href="https://i.stack.imgur.com/LLqrd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LLqrd.jpg" alt="GPX UI" /></a></p> <p>Unfortunately here's what gets printed.</p> <h1>Attempt #1, off in space</h1> <p><a href="https://i.stack.imgur.com/IkzsV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IkzsV.jpg" alt="print fail #1" /></a></p> <h1>Attempt #2, Right Hand Margin</h1> <p><a href="https://i.stack.imgur.com/mJATD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mJATD.jpg" alt="print fail #2" /></a></p> <h1>Attempt #3, Near the front.</h1> <p><a href="https://i.stack.imgur.com/v3aLM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v3aLM.jpg" alt="print #3" /></a></p> <p>I tried moving the print head to center of build plate, thinking that might be a logical start point. No go. Print start moves head to home (rear right corner of print bed) then after elements heat up to temp, it seems to select a random spot on the build plate to start. I never touched the .x3g file between these attempts. So I'm right back to where I started, per the title of this posting &quot;What determines print start location on the build plate?&quot;</p>
<p>So it turns out there are elements from each of the previous answers that make sense here, but its not a clear picture. I've spent a whole lot of time trying to make sense of this. I also upgraded my firmware to <a href="https://www.thingiverse.com/thing:32084" rel="nofollow noreferrer">Sailfish.</a> </p> <p>For the MakerBot Replicator (or FastForge Creator) family of 3d printers, the origin of the build plate is NOT at any of the corners, its right in the center of the build plate. Reference <a href="https://www.sailfishfirmware.com/doc/parameters-home-offsets.html#x20-630004.1" rel="nofollow noreferrer">here.</a> </p> <blockquote> <p>4.1 Home Offsets:<br> By convention, <strong>the center of the build platform</strong> is assumed to be the point (0,0,0) in XYZ space. The X, Y, and Z <strong>home offsets</strong> tell the printer the location of the X, Y, and Z <strong>endstops</strong> in relation to the build platform’s center.</p> </blockquote> <p>Looks like this:</p> <p><a href="https://i.stack.imgur.com/c2YlJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c2YlJ.png" alt="Center of build plate is origin"></a></p> <p>And it would appear that most other 3D printers are not using this convention. Sigh. From my testing, the main control of print location is within the G-Code generated by the slicer. The tool I was using, Slic3r does give one a chance to correct that adjustment. You have to go to top menu <code>Settings --&gt; Printer Settings --&gt; Size and Coordinates (Bed Shape) --&gt; Set</code> to get a nice popup visual tool. See below.</p> <p>Unfortunately the default setting is accurate for the overall bed size, but is a fail for the origin location on the bed. The default origin is set at 0,0, in the corner. Ouch. Big ouch. The origin needs to be located right in the center of the build plate (to be consistent with the firmware controlling the print for this family of printers). It <strong>should</strong> look like this:</p> <p><a href="https://i.stack.imgur.com/iXV61.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iXV61.png" alt="print bed origin setup"></a></p> <p>Note, when you tell the printer to go to 'home' it doesn't go to origin (0,0,0) it goes to the endstops. </p> <pre><code> G68 X0 Y0 F500 ; Perform Homing Routine </code></pre> <p>So as long as you understand the quirks of these printers things will work out. You have to ensure offsets are set accurately in firmware config files. (Replicator / Sailfish) And you have to indicate the correct center location to the slicer program. I will say the advice given here was of some help in understanding this. Many thanks. I'm posting here in case others using the Replicator or FastForge Creator series of printers is having troubles centering their prints on the build plate. </p> <p>Additional info for anybody using a MakerBot Replicator or Flashforge Creator series printer with Slic3r. I wanted to add my custom G-code stuff. The default Slic3r stuff definitely did not work. </p> <p>Printer Settings --> Custom G-Code --> Start G-Code</p> <pre><code>M103 ; Turn all extruders off, Extruder Retraction G21 ; set units to mm G90 ; Use absolute coordinates (**** begin homing ****) G162 X Y F2500 ; home XY axes to maximum stops G161 Z F1100 ; home Z axis to minimum stop G92 Z-5 ; Set Position Z =-5mm G1 Z0.0 ; move Z to "0" G161 Z F100 ; home Z axis to minimum stop slowly M132 X Y Z A B ; Recall stored home offsets for XYZAB axis ; Loads the axis offset of the current home position from the EEPROM and waits for the buffer to empty. G90 ; Use absolute coordinates G1 X0 Y0 Z50 F3300.0 ; move to waiting position near center of build plate </code></pre> <p>Printer Settings --> Custom G-Code --> End G-Code</p> <pre><code>M109 S0 T0 ; Cool down the build platform M104 S0 T0 ; Cool down the Right Extruder M104 S0 T1 ; Cool down the Left Extruder M73 P100 ; End build progress G0 Z150 ; Send Z axis to bottom of machine M18 ; Disable steppers G162 X Y F2500 ; Home XY endstops M18 ; Disable stepper motors M70 P30 ; We &lt;3 Making Things! Yipee, you made it... ; display message above for 30 seconds M72 P1 ; Play Ta-Da song </code></pre> <p>One other thing I do with Slic3r. I print a single loop of print on the periphery of a phantom skirt. I do this as a printer head clean extrude exercise. </p> <p>Print Settings --> Skirt and Brim --> Skirt --> Loops (minimum): 1, Distance from object: 6mm, Skirt height: 1 This works well. I do this in lieu of the G-code startup used in ReplicatorG software (which went to the lower left hand corner, and did this odd 4mm extrude exercise, with odd timing...) The skirt thing works just fine. </p>
<p>It sounds like you have "Origin at center" checked in your slicer's printer definition. That is generally only used with delta printers. Most Cartesian printers have the origin at the front-left corner of the build plate. Uncheck "Origin at center" and re-slice.</p> <p>Providing that you have set up your slicer with the build plate dimensions and origin correctly defined, your models will be printed where the slicer shows them in the preview. You can rearrange the models before you slice, of course.</p>
1,495
<p>If user input is inserted without modification into an SQL query, then the application becomes vulnerable to <a href="https://stackoverflow.com/a/332367/">SQL injection</a>, like in the following example:</p> <pre class="lang-php prettyprint-override"><code>$unsafe_variable = $_POST['user_input']; mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')"); </code></pre> <p>That's because the user can input something like <code>value'); DROP TABLE table;--</code>, and the query becomes:</p> <pre><code>INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--') </code></pre> <p>What can be done to prevent this from happening?</p>
<p>The <em>correct</em> way to avoid SQL injection attacks, no matter which database you use, is to <strong>separate the data from SQL</strong>, so that data stays data and will <strong>never be interpreted</strong> as commands by the SQL parser. It is possible to create an SQL statement with correctly formatted data parts, but if you don't <em>fully</em> understand the details, you should always <strong>use prepared statements and parameterized queries.</strong> These are SQL statements that are sent to and parsed by the database server separately from any parameters. This way it is impossible for an attacker to inject malicious SQL.</p> <p>You basically have two options to achieve this:</p> <ol> <li><p>Using <a href="http://php.net/manual/en/book.pdo.php" rel="noreferrer"><strong>PDO</strong></a> (for any supported database driver):</p> <pre class="lang-php prettyprint-override"><code>$stmt = $pdo-&gt;prepare('SELECT * FROM employees WHERE name = :name'); $stmt-&gt;execute([ 'name' =&gt; $name ]); foreach ($stmt as $row) { // Do something with $row } </code></pre> </li> <li><p>Using <a href="http://php.net/manual/en/book.mysqli.php" rel="noreferrer"><strong>MySQLi</strong></a> (for MySQL):</p> <pre class="lang-php prettyprint-override"><code>$stmt = $dbConnection-&gt;prepare('SELECT * FROM employees WHERE name = ?'); $stmt-&gt;bind_param('s', $name); // 's' specifies the variable type =&gt; 'string' $stmt-&gt;execute(); $result = $stmt-&gt;get_result(); while ($row = $result-&gt;fetch_assoc()) { // Do something with $row } </code></pre> </li> </ol> <p>If you're connecting to a database other than MySQL, there is a driver-specific second option that you can refer to (for example, <code>pg_prepare()</code> and <code>pg_execute()</code> for PostgreSQL). PDO is the universal option.</p> <hr /> <h2>Correctly setting up the connection</h2> <h4>PDO</h4> <p>Note that when using <strong>PDO</strong> to access a MySQL database <em>real</em> prepared statements are <strong>not used by default</strong>. To fix this you have to disable the emulation of prepared statements. An example of creating a connection using <strong>PDO</strong> is:</p> <pre class="lang-php prettyprint-override"><code>$dbConnection = new PDO('mysql:dbname=dbtest;host=127.0.0.1;charset=utf8mb4', 'user', 'password'); $dbConnection-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $dbConnection-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); </code></pre> <p>In the above example, the error mode isn't strictly necessary, <strong>but it is advised to add it</strong>. This way PDO will inform you of all MySQL errors by means of throwing the <code>PDOException</code>.</p> <p>What is <strong>mandatory</strong>, however, is the first <code>setAttribute()</code> line, which tells PDO to disable emulated prepared statements and use <em>real</em> prepared statements. This makes sure the statement and the values aren't parsed by PHP before sending it to the MySQL server (giving a possible attacker no chance to inject malicious SQL).</p> <p>Although you can set the <code>charset</code> in the options of the constructor, it's important to note that 'older' versions of PHP (before 5.3.6) <a href="http://php.net/manual/en/ref.pdo-mysql.connection.php" rel="noreferrer">silently ignored the charset parameter</a> in the DSN.</p> <h4>Mysqli</h4> <p>For mysqli we have to follow the same routine:</p> <pre class="lang-php prettyprint-override"><code>mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // error reporting $dbConnection = new mysqli('127.0.0.1', 'username', 'password', 'test'); $dbConnection-&gt;set_charset('utf8mb4'); // charset </code></pre> <hr /> <h2>Explanation</h2> <p>The SQL statement you pass to <code>prepare</code> is parsed and compiled by the database server. By specifying parameters (either a <code>?</code> or a named parameter like <code>:name</code> in the example above) you tell the database engine where you want to filter on. Then when you call <code>execute</code>, the prepared statement is combined with the parameter values you specify.</p> <p>The important thing here is that the parameter values are combined with the compiled statement, not an SQL string. SQL injection works by tricking the script into including malicious strings when it creates SQL to send to the database. So by sending the actual SQL separately from the parameters, you limit the risk of ending up with something you didn't intend.</p> <p>Any parameters you send when using a prepared statement will just be treated as strings (although the database engine may do some optimization so parameters may end up as numbers too, of course). In the example above, if the <code>$name</code> variable contains <code>'Sarah'; DELETE FROM employees</code> the result would simply be a search for the string <code>&quot;'Sarah'; DELETE FROM employees&quot;</code>, and you will not end up with <a href="http://xkcd.com/327/" rel="noreferrer">an empty table</a>.</p> <p>Another benefit of using prepared statements is that if you execute the same statement many times in the same session it will only be parsed and compiled once, giving you some speed gains.</p> <p>Oh, and since you asked about how to do it for an insert, here's an example (using PDO):</p> <pre class="lang-php prettyprint-override"><code>$preparedStatement = $db-&gt;prepare('INSERT INTO table (column) VALUES (:column)'); $preparedStatement-&gt;execute([ 'column' =&gt; $unsafeValue ]); </code></pre> <hr /> <h2>Can prepared statements be used for dynamic queries?</h2> <p>While you can still use prepared statements for the query parameters, the structure of the dynamic query itself cannot be parametrized and certain query features cannot be parametrized.</p> <p>For these specific scenarios, the best thing to do is use a whitelist filter that restricts the possible values.</p> <pre><code>// Value whitelist // $dir can only be 'DESC', otherwise it will be 'ASC' if (empty($dir) || $dir !== 'DESC') { $dir = 'ASC'; } </code></pre>
<p>I've written this little function several years ago:</p> <pre><code>function sqlvprintf($query, $args) { global $DB_LINK; $ctr = 0; ensureConnection(); // Connect to database if not connected already. $values = array(); foreach ($args as $value) { if (is_string($value)) { $value = "'" . mysqli_real_escape_string($DB_LINK, $value) . "'"; } else if (is_null($value)) { $value = 'NULL'; } else if (!is_int($value) &amp;&amp; !is_float($value)) { die('Only numeric, string, array and NULL arguments allowed in a query. Argument '.($ctr+1).' is not a basic type, it\'s type is '. gettype($value). '.'); } $values[] = $value; $ctr++; } $query = preg_replace_callback( '/{(\\d+)}/', function($match) use ($values) { if (isset($values[$match[1]])) { return $values[$match[1]]; } else { return $match[0]; } }, $query ); return $query; } function runEscapedQuery($preparedQuery /*, ...*/) { $params = array_slice(func_get_args(), 1); $results = runQuery(sqlvprintf($preparedQuery, $params)); // Run query and fetch results. return $results; } </code></pre> <p>This allows running statements in an one-liner C#-ish String.Format like:</p> <pre><code>runEscapedQuery("INSERT INTO Whatever (id, foo, bar) VALUES ({0}, {1}, {2})", $numericVar, $stringVar1, $stringVar2); </code></pre> <p>It escapes considering the variable type. If you try to parameterize table, column names, it would fail as it puts every string in quotes which is an invalid syntax.</p> <p>SECURITY UPDATE: The previous <code>str_replace</code> version allowed injections by adding {#} tokens into user data. This <code>preg_replace_callback</code> version doesn't cause problems if the replacement contains these tokens.</p>
8,501
<p>I'm new to 3D printing and I recently got my first 3D printer, an Ender 3 Pro by Creality.</p> <p>I've tried to find information about the type of nozzles should I look for. I'm trying to find stainless steel nozzles but there are so many models (M7, M8, etc.) and I have no idea what nozzle type I should get.</p> <p>I've tried searching on Google but the only info I could find is that the extruder is an MK-10.</p> <p>I am also looking for a heating cartridge for the hot end, but I still cannot find no information about the size that I need (15 mm/20 mm/30 mm). Also looked for info about the heated bed so I know what kind of thermistor I need (I found two types and no clue which one to get).</p> <p>Where can I find some technical information about these?</p>
<p>The Ender 3 takes an M6 thread (metric 6&nbsp;mm diameter). Measurement of stock nozzle shown. </p> <p>Most sellers will list compatible printers Ender 2, Ender 3, Ender 4, CR-10, CR-10S, CR-10 Mini, CR-10-S4, CR-10-S5, CR-8, CR-7. Will Also Fit Any Other MK10 Heater Blocks. </p> <p>I recently bought some titanium alloy nozzles as the brass one got closed over after crashing into the glass bed. </p> <p><a href="https://i.stack.imgur.com/I1UPK.jpg" rel="nofollow noreferrer" title="Measurement of nozzle in digital calipers"><img src="https://i.stack.imgur.com/I1UPK.jpg" alt="Measurement of nozzle in digital calipers" title="Measurement of nozzle in digital calipers"></a></p>
<p>There is no such thing as a single MK10 hotend design. The Chinese aftermarket has mingled the designations.</p> <p>If it has a <a href="https://groups.google.com/forum/m/#!topic/wanhao-printer-3d/TEdslEknny4" rel="nofollow noreferrer">MK10 like Makerbot</a> hotend, then the nozzles you are looking for are M7 threads. It appears (see <a href="https://3dprinting.stackexchange.com/a/7367/5740">this answer</a>) that your hotend is a cloned MK10 and has different dimensions, you have the M6 version.</p> <p>Quote from link above: (this is about the Makerbot MK10)</p> <blockquote> <p>MK10 was a complete change of the hotend. MK10 uses smooth OD thermal barriers with a larger 4mm OD 2mm ID PTFE liner. MK10 also uses M7 threads, vs the M6 of all previous models. This is because a 4mm PTFE liner is barely enough metal to make the outer tube with m6 threads. MK10 is completely incompatible with all previous hotend parts. Every part is different. Mk10 still uses MK9 feeder parts.</p> </blockquote> <p>You could measure your current heat block (the width of the Aluminium block); if you look at the MK10 drawings of a proper M7 MK10 Makerbot (or derivative) hotend (below) you see that the width of the block is about 19 mm (which would be the length of the heater cartridge).</p> <p><a href="https://i.stack.imgur.com/9TftHm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9TftHm.jpg" alt="MK10 Aluminium heater block dimensions"></a></p> <p>The CEO of ToyBuilder labs explains the difference between an "MK10" and an MK8 in <a href="https://www.youtube.com/watch?v=UnI0aeTw9iA" rel="nofollow noreferrer">this video</a>:</p> <p><a href="https://i.stack.imgur.com/Ah8Od.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ah8Od.png" alt="&quot;MK10&quot; vs. MK8 nozzle"></a></p> <p>As can be seen, your nozzle clearly is not an MK10.</p>
1,082
<p>See here <a href="http://www.hanselman.com/blog/InSearchOfThePerfectMonospacedProgrammersFontInconsolata.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/InSearchOfThePerfectMonospacedProgrammersFontInconsolata.aspx</a> - for want of a better description - the statement block highlighting - eg in the pics on the link the "statement blocks" are grouped with a vertical line. I understand this is a feature of CodeRush - does R# have either anything similar, or a plugin to do the same?</p>
<p>I use the latest version of ReSharper that is currently available — ReSharper 4.5 — but unfortunately I don't believe there is any feature for drawing a vertical line between matching braces, as in the screen-shots you referenced.</p> <p>The feature I find useful, which Ben mentioned, is the matching brace highlighting, however this only takes effect when your cursor is adjacent to an opening or closing brace.</p>
<p>Notepad ++ has a nice brace matching feature, with vertical lines matching the braces. It's not VS, so I only use it when I am faced with some confusing JS, cut and paste, figure out the braces and go back to VS. It would be GREAT if this sort of feature existed in VS, or R#. </p>
7,394
<p>I have a list of more than 15 thousand latitude and longitude coordinates. Given any X,Y coordinates, what is the fastest way to find the closest coordinates on the list?</p>
<p>You will want to use a geometric construction called a <a href="http://mathworld.wolfram.com/VoronoiDiagram.html" rel="nofollow noreferrer">Voronoi diagram</a>. This divides up the plane into a number of areas, one for each point, that encompass all the points that are closest to each of your given points.</p> <p>The code for the exact algorithms to create the Voronoi diagram and arrange the data structure lookups are too large to fit in this little edit box. :)</p> <p>@Linor: That's essentially what you would do after creating a Voronoi diagram. But instead of making a rectangular grid, you can choose dividing lines that closely match the lines of the Voronoi diagram (this way you will get fewer areas that cross dividing lines). If you recursively divide your Voronoi diagram in half along the best dividing line for each subdiagram, you can then do a tree search for each point you want to look up. This requires a bit of work up front but saves time later. Each lookup would be on the order of log N where N is the number of points. 16 comparisons is a lot better than 15,000!</p>
<p>Even if you create a voronoi diagram, that still means you need to compare your x, y coordinates to all 15 thousand created areas. To make that easier, the first thing that popped into my mind though was to create some sort of grid over the possible values, so that you can easily place and x/y coordinate into one of the boxes in a grid, if the same is done for the list of areas you should quickly shrink the possible candidates for comparison (because the grid would be more rectangular, it's possible for an area to be in multiple grid positions). </p>
5,645
<p>Just what the title says, I need to change the password for an existing sql server login and I want to do it via sql script.</p>
<p>ALTER LOGIN</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms189828.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms189828.aspx</a></p>
<pre><code>alter login mylogin with password = 'mylogin' </code></pre>
8,106
<p>What is the least expensive 3D printer available today? I am looking for something suitable for general use in a home office.</p>
<p><strong>Depends on your definition of "available" and your definition of "suitable for general use."</strong> </p> <p>The cheapest 3D printers are mostly Kickstarter promises that take a year or more to ship, if they ever do. For example, the Peachy 3D printer Kickstarter just imploded and failed. There have been many other failed low-cost 3D printer crowdfunding campaigns. Another low cost Kickstarter printer, the 101Hero, is ongoing now (May 2016), but most competent observers I've talked to don't believe it will succeed at delivering working printers to all backers at that price point. If they do deliver, it will be painfully low-cost components and the printer will not perform well or last long. <strong>Stay away from crowdfunding campaigns for your first printer.</strong> At best, you get a beta product with lots of kinks to work out. At worst, you get nothing and lose your money. </p> <p>For actual products you can purchase today, there's a wide spectrum of quality/cost tradeoffs.</p> <ul> <li>Under \$200 there's nothing credible. The Tiko (\$179) might deliver, but post-Kickstarter units are widely expected to cost more.</li> <li>Around \$200-300 you get into low-quality Prusa i3 kits from China. These aren't a great value -- most people end up spending another few hundred dollars on upgrades to get them working reliably and with high quality.</li> <li>Around \$300-400 you can get an <em>ok</em> 3D printer, often with "chipped" proprietary filament so the vendor can make high profits on locked-in consumables. ("Razors and blades" model.) For example, the XYZPrinting Da Vinci Jr is \$350 but locks you into high-cost chipped filament. The Wanhao Duplicator i3 is currently a community favorite for value-for-money at \$399. The Printrbot Play is much higher quality/reliability but much smaller at the same price. </li> <li>If you get up around \$600, a big range of decent printers opens up. But this is no longer the "least expensive" option, so I won't get into it. </li> </ul> <p>If you want to tinker, the Duplicator i3 is a good choice. If you want a machine that just prints, the Play is a good choice. There are other printers and cheaper printers, but most of what you'll find below $400 is going to end up causing pain unless your goal is simply to tinker with printer troubleshooting and upgrades. </p>
<p>You can get an A8 3D printer on Gearbest at 149$, It's a version of an i3, with easy assemble and pre configured, and it have a suprising good quality.</p> <p>I thinks is the best price/quality that you can find at the moment. It prints with a good quality by default and you can upgrade it if you need it without spending hundreds of dollars.</p> <p><a href="http://www.gearbest.com/3d-printers-3d-printer-kits/pp_337314.html" rel="nofollow">http://www.gearbest.com/3d-printers-3d-printer-kits/pp_337314.html</a></p>
295
<p>I've gotten comfy with SVN, and now I need a way to deploy my code to staging or live servers more easily. I'd also like some method for putting build info in the footer of this site to aid in testing. Site is PHP/MySQL.</p>
<p>A script to svn update on an as needed basis. </p> <p>SVN supports keywords. You can add which keywords you want to expand to the keywords property, and SVN will expand then. See $Id$ or $Rev$, or keywords described in the SVN book.</p>
<p>A really simple way to manage this is to setup your app in the following way:</p> <p>Simply make your deployment app a working copy of your trunk (<code>svn co</code> the project to your /www root) and you run an <code>svn up</code> through an ssh console (<code>ssh user@host.com svn up /path/to/project</code>) when you need to update. You can also rollback with the appropriate checkout mechanisms. This is important: <strong>if you do this, add RewriteRules (or equivalent) to your .htaccess (or equivalent) to disallow access to .svn directories</strong>. If you can't do the above, run an <code>svn export</code> through ssh instead (so it won't be a 'working copy'), but this will naturally be slower than doing an <code>up</code>.</p> <p>Also, you can look at what Ruby on Rails does with Capistrano.. it's the same basic concept but supports transactional backups if the update goes wrong in the middle by storing each checkout in a separate folder and symlinking the "latest" to your /www directory.</p>
9,218
<p>I'm leading a project where we'll be recording metrics data. I'd like to retain the data for years. However, I'd also like to keep the primary table from becoming bloated with data that, while necessary for long term trending, isn't required for short term reporting.</p> <p>What is the best strategy for handling this situation? Simply archive the old data to another table? Or "roll it up" via some consolidation of the data itself (and then store it off to a different table)? Or something else entirely?</p> <p><i>Additional info: we are using SQL Server 2005.</i></p>
<p>We use both methods at my work, but slightly different, we keep all sales data in the primary table for 30 days, then at night (part of the nightly jobs) the days sales are rolled up into summaries (n qty of x product sold today ect) in a separate table for reporting reasons, and sales over 30 days are archived into a different database, then once a year (we go on tax years) a new archive database is started. not exactly perfect but..</p> <p>this way we get the summaries data fast, keep all current sales data at hand and have an unlimited space for the detailed archive data. we did try keeping it all in one database (in different tables) but the file size of the database (interbase) would grow so large that it would drag the system down.</p> <p>the only real problem we have is accessing detailed data that spans several database, as connecting and disconnecting is slow, and analysis has to be done in code rather than sql</p>
<p>Either of those options are excellent, but it really depends on the problem domain. For things like cash balances or statistical data, I think that rolling up records and consolidating them is the best way, you can then move the rolled up records into a parallel archive table, keying them in such a way that you can "unroll" if necessary. This keeps your primary data table clean and quick, but allows you to retain the extra data for auditing or whatever. The key question is, how do you implement the "roll-up" process. Either automatically, via a trigger or server side process, or by user intervention at the application level?</p>
4,011
<p>I want to check out all files in all subdirectories of a specified folder.</p> <p>(And it is painful to do this using the GUI, because there is no recursive checkout option).</p>
<p>Beware: ClearCase is File-centric, not repository centric (like SVN or CVS).</p> <p>That means it is rarely a good solution to checkout all files (and it can be fairly long with ClearCase ;) )</p> <p>That being said, the question is perfectly legitimate and I would like to point out another way:</p> <p>open a <code>cleartool</code> session in the 'specified folder':</p> <pre><code>c:\MyFolder&gt; cleartool cleartool&gt; co -c "Reason for massive checkout" .../* </code></pre> <p>does the trick too. But as the aku's answer, it does checkout <em>everything</em>: files and directories... and you may most <em>not need</em> to checkout directories! </p> <pre><code>cleartool find somedir -type f -exec "cleartool checkout -c \"Reason for massive checkout\" \"%CLEARCASE_PN%\"" </code></pre> <p>would only checkout files...</p> <p>Now the problem is to checkin everything that has changed. It is problematic since often <em>not everything</em> has changed, and CleaCase will trigger an error message when trying to check in an identical file. Meaning you will need 2 commands:</p> <pre><code>ct lsco -r -cvi -fmt "ci -nc \"%n\"\n" | ct ct lsco -r -cvi -fmt "unco -rm %n\n" | ct </code></pre> <p>(with '<code>ct</code> being '<code>cleartool</code>' : type '<code>doskey ct=cleartool $*</code>' on Windows to set that alias)</p> <p>Note that <code>ct ci -nc</code> will check-in with the comment used for the checkout stage.<br> So it is <em>not</em> a checkin without a comment (like the <code>-nc</code> option -- or "no comment" -- could make believe).</p>
<pre><code>cleartool find somedir -exec "cleartool checkout -nc \"%CLEARCASE_PN%\"" </code></pre> <p>Also an article "<a href="http://www.ibm.com/developerworks/rational/library/4687.html" rel="noreferrer">ClearCase: The ten best scripts</a>" might be helpful</p>
5,366
<p><strong><em>Background:</em></strong> I'm running a full-time job and a part-time job in the weekends, and both my employers have supplied a laptop for me to work on. Of course I also have my powerful workstation at home to work from, and sometimes when I'm at the office at my weekend job (it's in another city) I'm working from yet another workstation.</p> <p><strong><em>Problem:</em></strong> That makes a full 4 PC's I'm maintaining (software versions, licences and settings) just to do my work, and believe me, my list of prefered software is way too big.</p> <p>I want to setup a Virtual Desktop on my VMware server, so I can work from the same installation and same session no matter which PC I'm working from.</p> <p>Now I don't have the time and money to go through a full test of each setup, so I'd like to hear your experiences on the subject.</p> <p><strong><em>Question:</em></strong> Should I use a VMware virtual workstation with some remote logon software (like <a href="http://www.realvnc.com/" rel="nofollow noreferrer">realVNC</a>, <a href="http://www.teamviewer.com/" rel="nofollow noreferrer">teamviewer</a>, <a href="https://secure.logmein.com/" rel="nofollow noreferrer">logmein</a>, whatever...) or should I invest in a full VDI system like <a href="http://www.sun.com/software/vdi/index.jsp" rel="nofollow noreferrer">Sun</a> or <a href="http://www.vmware.com/products/vdi/" rel="nofollow noreferrer">VMware</a> provide?</p> <p><strong><em>Edit:</em></strong> I'm programming in Adobe Dreamweaver on Windows XP - but I run my servers on Debian and sometimes do quick edits in VIM too. First I intend to virtualize a WinXP with base installation, to see how it runs.</p>
<p>I am a consultant and tend to work in a variety of environments. I carry a Thinkpad running VMWare Server over Ubuntu64 with 4GB of RAM. I've got a 320GB secondary hard drive that I use just for VM's and have 25 or so different virtual machines that I boot up as the circumstances demand.</p> <p>They're a mix of Linux servers and workstations, Vista workstations and XP Workstations. I rarely use the VMWare server console. I access every one of them via one of the remote access methods.</p> <p>For Linux, I usually install FreeNX or NXServer for desktop access and just SSH for commandline. On Windows, I always use Remote Desktop (RDP), but, on XP, that only works on the "Pro" versions, not the "Home" versions. If all else fails, I install VNC and use that. VNC is at the bottom of my list because it really is a last resort. The only thing it's better than is not actually being able to use the machine.</p> <p>However, NX on Linux and RDP on Windows work WAY better than VNC. Other than little things like font smoothing and fancy desktop effects, the only big glitch would be if you are doing much with video or audio or DirectX-based stuff. Things like YouTube or other video do NOT like to work with any remote desktop protocol that I know of.</p> <p>As far as performance, using Linux as a host for VMWare provides really good management of system resources. The Windows-based VM's aren't able to just gobble up memory, but still get it when they need to.</p> <p>I do C# development all day in a virtual Vista workstation on Visual Studio 2008 and have absolutely no problems having 3-4 different solutions all open at once along with the normal stuff alongside over RDP on another machine, connected via wireless VPN. </p> <p>I can flip over to the host OS and it won't even be touching swap space at all. As far as I'm concerned, it's a great way to work.</p>
<p>I guess you can live with Logmein Free. [Or Pro if u want those features]</p>
9,693
<p>The company I work for is wanting to add blog functionality to our website and they were looking to spend an awful amount of money to have some crap being built on top of a CMS they purchased (sitecore). I pointed them to Telligent's Community Server and we had a sales like meeting today to get the Marketing folks on board. My question is if anyone has had issues working with Community Server, skinning it and extending it?<br /> I wanted to explain a bit why I am thinking Community Server, the company is wanting multiple blogs with multiple authors. I want to be out of the admin part of this as much as possible and didn't think there were too many engines that having multiple blogs didn't mean db work. I also like the other functionality that Community Server provides and think the company will find it useful, particularly the media section as right now we have some really shotty way of dealing with whitepapers and stuff.</p> <p>edit: We are actually using the Sitecore blog module for a single blog on our intranet (which is actually what the CMS is serving). Some reasoning for why I don't like it for our public site are they are on different servers, it doesn't support multiple authors, there is no built in syndication, it is a little flimsy feeling to me from looking at the source and I personally think the other features of Community Server make its price tag worth it.</p> <p>another edit: Need to stick to .net software that run on sql server in my company's case, but I don't mind seeing recommendations for others. ExpressionEngine looks promising, will try it out on my personal box.</p>
<p>I've done quite a few projects using Community Server. If you're okay with the out-of-the-box functionality, or you don't mind sticking to the version you start with, I think you'll be very happy.</p> <p>The times I've run into headaches using CS is when the client wants functionality CS does not provide, but also insists on keeping the ability to upgrade to the latest version whenever Telligent releases an update. You can mostly support that by making all of your changes either in a separate project or by only modifying aspx/ascx files (no codebehinds). Some kind of merge is going to be required though no matter how well you plan it out.</p>
<p>Have you had a look at the <a href="http://trac.sitecore.net/Blog" rel="nofollow noreferrer">Shared Source blog module</a> for Sitecore?</p>
2,736
<p>Is there a way to have Linux read ahead when cloning a disk? I use the program named "dd" to clone disks. The last time I did this it seemed as though the OS was reading then writing but never at the same time. Ideally, the destination disk would be constantly writing without waiting that's of course if the source disk can keep up.</p> <p>UPDATE: I normally choose a large block size when cloning (ex. 16M or 32MB).</p>
<p>Commodore Jaeger is right about:</p> <pre><code>dd if=/dev/sda of=/dev/sdb bs=1M </code></pre> <p>Also, adjusting "readahead" on the drives usually improves performance. The default may be something like 256, and optimal 1024. Each setup is different, so you would have to run benchmarks to find the best value.</p> <pre><code># blockdev --getra /dev/sda 256 # blockdev --setra 1024 /dev/sda # blockdev --getra /dev/sda 1024 # blockdev --help Usage: blockdev -V blockdev --report [devices] blockdev [-v|-q] commands devices Available commands: --getsz (get size in 512-byte sectors) --setro (set read-only) --setrw (set read-write) --getro (get read-only) --getss (get sectorsize) --getbsz (get blocksize) --setbsz BLOCKSIZE (set blocksize) --getsize (get 32-bit sector count) --getsize64 (get size in bytes) --setra READAHEAD (set readahead) --getra (get readahead) --flushbufs (flush buffers) --rereadpt (reread partition table) --rmpart PARTNO (disable partition) --rmparts (disable all partitions) # </code></pre>
<p>Are you sure it isn't doing that at the same time? I would expect the disk caches to make sure it that happens. If not, non-blocking or even asynchronous reads/writes may help,</p>
7,823
<p>I have a rather large file (150 million lines of 10 chars). I need to split it in 150 files of 2 million lines, with each output line being alternatively the first 5 characters or the last 5 characters of the source line. I could do this in Perl rather quickly, but I was wondering if there was an easy solution using bash. Any ideas?</p>
<p>Homework? :-)</p> <p>I would think that a simple pipe with sed (to split each line into two) and split (to split things up into multiple files) would be enough.</p> <p>The man command is your friend.</p> <hr> <p>Added after confirmation that it is not homework:</p> <p>How about</p> <pre><code>sed 's/\(.....\)\(.....\)/\1\n\2/' input_file | split -l 2000000 - out-prefix- </code></pre> <p>?</p>
<p>I think that something like this could work:</p> <pre><code>out_file=1 out_pairs=0 cat $in_file | while read line; do if [ $out_pairs -gt 1000000 ]; then out_file=$(($out_file + 1)) out_pairs=0 fi echo "${line%?????}" &gt;&gt; out${out_file} echo "${line#?????}" &gt;&gt; out${out_file} out_pairs=$(($out_pairs + 1)) done </code></pre> <p>Not sure if it's simpler or more efficient than using Perl, though.</p>
8,928
<p>With <a href="/questions/tagged/fdm" class="post-tag" title="show questions tagged &#39;fdm&#39;" rel="tag">fdm</a> printers, the 3D object that should be printed can be positioned anywhere in the build volume. But it's only practical to place it on the bottom, because otherwise support material would be necessary.</p> <p>stereolithography has the same problem. Even though the photopolymer can be cured at any position in the build volume, the result would drift away if it was not held in place by support material.</p> <p>The powderbed based printers (either powder+binder or any of the laser/electron beam sintering/melting variants) do not have this problem, because they continuously fill the entire build volume with powder. The support material that other printing technologies require is part of the powder based printing anyway. It would be possible to pack the build volume with many prints and print them in one go.</p> <p>Given that the machines are relatively expensive, it would be economical to increase the throughput. A company that does use such printers heavily could wait a certain amount of time until a few print queued up that fit together in the build volume and only then start the process. Do people do this?</p>
<p>There are several things you could try without spending much but even PLA will warp on an unheated bed. I had a Legacy Kossel that I switched to an acrylic bed and had many issues with warping and prints pulling off the bed. </p> <p>Some cheap things to try would be...</p> <ol> <li>Adding a brim to the print.</li> <li>Blue painters tape on the acrylic, remove the other material if doing this.</li> <li>Place cheap piece of glass/mirror on bed and use hairspray/gluestick.</li> <li>Use hairspray/gluestick directly on acrylic. You must be careful here because first layer height is very critical to prevent damage to the acrylic from the plastic welding. A layer of hairspray or glue should prevent it but dial in your height before printing.</li> <li>If you aren't currently using a fan, you could try sealing the sides to prevent drafts. I doubt this would change much since you are using PLA but it's an option.</li> <li>If these are your designs, there are steps you can take to reduce warping as seen <a href="http://hackaday.com/2011/11/15/a-technique-to-avoid-warping-on-large-3d-prints/">here.</a></li> </ol> <p>Also many other suggestions <a href="http://www.makerbot.com/blog/2011/06/23/12-ways-to-fight-warping-and-curling">here.</a></p>
<p>Try a dilute solution of PVA glue (approx. 5:1 water:PVA) applied to the bed or the BuildTak like sheet and allowed to dry. Keep the ambient temperature as high as possible (but not so high as to soften any plastic on the printer obviously). Big brims help - consider adding them to the model rather than just applying them in the slicer. I've used 12&nbsp;mm by 0.5&nbsp;mm deep circles to good effect, particularly on acutely angled parts of the model or the extremities.</p>
147
<p>I have a .NET 2.0 windows forms app, which makes heavy use of the <code>ListView</code> control.</p> <p>I've subclassed the <code>ListView</code> class into a templated <code>SortableListView&lt;T&gt;</code> class, so it can be a bit smarter about how it displays things, and sort itself.</p> <p>Unfortunately this seems to break the Visual Studio Forms Designer, in both VS2005 and 2008.</p> <p>The program compiles and runs fine, but when I try view the owning form in the designer, I get these Errors:</p> <ul> <li>Could not find type 'MyApp.Controls.SortableListView'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.</li> </ul> <p>There is no stack trace or error line information available for this error </p> <ul> <li>The variable 'listViewImages' is either undeclared or was never assigned. </li> </ul> <p>At MyApp.Main.Designer.cs Line:XYZ Column:1</p> <pre><code>Call stack: at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) </code></pre> <p>The line of code in question is where it is actually added to the form, and is</p> <pre><code>this.imagesTab.Controls.Add( this.listViewImages ); </code></pre> <p>listViewImages is declared as</p> <pre><code>private MyApp.Controls.SortableListView&lt;Image&gt; listViewImages; </code></pre> <p>and is instantiated in the <code>InitializeComponent</code> method as follows:</p> <pre><code>this.listViewImages = new MyApp.Controls.SortableListView&lt;Image&gt;(); </code></pre> <p>As mentioned earlier, the program compiles and runs perfectly, and I've tried shifting the <code>SortableListView</code> class out to a seperate assembly so it can be compiled seperately, but this makes no difference.</p> <p>I have no idea where to go from here. Any help would be appreciated!</p>
<p>It happened to me because of x86 / x64 architecture.</p> <p>Since Visual Studio (the development tool itself) has no x64 version, it's not possible to load x64 control into GUI designer.</p> <p>The best approach for this might be tuning GUI under x86, and compile it for x64 when necessary.</p>
<p>In my case the problem was the folder's name of my project! Why I think this: I use SVN and in the 'trunk\SGIMovel' works perfectly. But in a branch folder named as 'OS#125\SGIMovel' I can't open the designer for a form that uses a custom control and works in the trunk folder.</p> <p>Just get off the # and works nice.</p>
3,074
<p>I just came across the proposed <a href="http://web.archive.org/web/20171008232044/http://dancinghacker.com:80/code/dataflow/dataflow/introduction/dataflow.html" rel="nofollow noreferrer">Boost::Dataflow</a> library. It seems like an interesting approach and I was wondering if there are other such alternative frameworks for C++, and if there are any related design patterns. I have not ruled out Boost::Dataflow, I am just looking into any available alternatives so I can understand the domain and my options better (or roll my own if necessary).</p>
<p><strong>Wikipedia</strong></p> <p>There are a couple of good articles in the Wikipedia about the theory of the dataflow programming:</p> <ul> <li><a href="http://en.wikipedia.org/wiki/Dataflow" rel="nofollow noreferrer">Dataflow</a></li> <li><a href="http://en.wikipedia.org/wiki/Dataflow_programming" rel="nofollow noreferrer">Dataflow programming</a></li> <li><a href="http://en.wikipedia.org/wiki/Flow-based_programming" rel="nofollow noreferrer">Flow based programming</a></li> <li><a href="http://en.wikipedia.org/wiki/Actor_model" rel="nofollow noreferrer">Actor model</a></li> <li><a href="http://en.wikipedia.org/wiki/Visual_programming" rel="nofollow noreferrer">Visual programming</a></li> </ul> <p>These articles are written by various authors, so there are some overlaps, and some important stuff are missing, but it is a very good start point.</p> <p><strong>TinyOS</strong></p> <p>This is an open source operating system based on the dataflow principle. I have bad feelings about that: they don't even mention the term "dataflow". Altough, it is that, and maybe it's <a href="http://www.tinyos.net/" rel="nofollow noreferrer">worth studying it</a>.</p>
<p>If your area is sound generation/processing, use <a href="http://www.synthedit.com/" rel="nofollow noreferrer">http://www.synthedit.com/</a> </p> <p>It looks promising, I've found a good answers for a deep problem in the SDK docs (polyphony). Funny, but they don't mention the word <em>dataflow</em>.</p>
9,753
<p>Does anybody have any pointers on how to successfully draw a bitmap that has an alpha channel using Graphics::DrawImage() when the Graphics context is created based on a printer HDC? The printer drivers don't generally support alpha blending - so is there an alternative to rendering everything to an offscreen bitmap and just sending that to the printer. This is often not feasible, especially for high res printing to large format printers.</p>
<p>What kind of printer is that? Regular printers don't print white. Create in-memory image and 'flatten' it (remove alpha channel) and then print the result.</p>
<p>Have you tried drawing a white rectangle to initialize the image before you call the DrawImage method?</p>
8,817
<p>I have a text file on my local machine that is generated by a daily Python script run in cron. </p> <p>I would like to add a bit of code to have that file sent securely to my server over SSH.</p>
<p>You can call the <a href="https://en.wikipedia.org/wiki/Secure_copy" rel="noreferrer"><code>scp</code></a> bash command (it copies files over <a href="https://en.wikipedia.org/wiki/Secure_Shell" rel="noreferrer">SSH</a>) with <a href="https://docs.python.org/library/subprocess.html#subprocess.run" rel="noreferrer"><code>subprocess.run</code></a>:</p> <pre><code>import subprocess subprocess.run(["scp", FILE, "USER@SERVER:PATH"]) #e.g. subprocess.run(["scp", "foo.bar", "joe@srvr.net:/path/to/foo.bar"]) </code></pre> <p>If you're creating the file that you want to send in the same Python program, you'll want to call <code>subprocess.run</code> command outside the <code>with</code> block you're using to open the file (or call <code>.close()</code> on the file first if you're not using a <code>with</code> block), so you know it's flushed to disk from Python.</p> <p>You need to generate (on the source machine) and install (on the destination machine) an ssh key beforehand so that the scp automatically gets authenticated with your public ssh key (in other words, so your script doesn't ask for a password).</p>
<p>Kind of hacky, but the following should work :)</p> <pre><code>import os filePath = "/foo/bar/baz.py" serverPath = "/blah/boo/boom.py" os.system("scp "+filePath+" user@myserver.com:"+serverPath) </code></pre>
9,384