instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>When I design parts that must fit in each other, I usually keep in mind that prints are 0.2-0.5 mm wider than expected (depending on material) and I size the parts accordingly.</p> <p>However, sometimes I design the whole part and then I slice it with planes or lines. In these cases I need to push/pull afterwards each contact surface manually by the same amount (0.2-0.5 mm) and that is a time consuming task. Another option is to use a cutter to remove the outer surface layer (basically I remove the rigged surface, making it smooth again) but it's not safe and even more time consuming.</p> <p>How can I quickly generate said controlled gaps on the contact surfaces between two objects, but not on the rest of the object? to make it everywhere I could use shells, I guess, but I don't need that on the whole object.</p>
<p>Unfortunately, 123D Design doesn't have such a feature.</p> <p>You could select multiple surfaces and push/pull them all at the same time though.</p> <p>Remember, your 3D Printer's slicer should have an option to undersize or oversize holes and walls, to help reduce/remove the effect you talk about. It's called size correction, I think? Simplify3D Has it, atleast. You might have to tweak this for every filament type, though.</p>
<p>AFAICT Push/Pull faces is the closest thing to what you're looking for. eg: <div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/oSkTxuCRLMg?start=38"></iframe> </div></div></p> <p>In OnShape there is an &quot;offset face&quot; command that allows applying such an offset to multiple faces at once: <a href="https://3dprinting.stackexchange.com/questions/16596/how-to-add-tolerances-gaps-in-onshape/16597#16597">How to add tolerances/gaps in OnShape?</a></p> <p>Unfortunately I'm not aware of a way to do exactly the same thing in 123D Design, but I'm far less proficient with that tool (as Alucard Pawpad <a href="https://3dprinting.stackexchange.com/a/3717/29031">noted</a>, though, it is possible to just select multiple faces at the same time and manipulate them all together, which is somewhat similar)</p>
413
<p>On the other end of the spectrum, I would be happy if I could install a wiki and share the login credentials between <a href="http://en.wikipedia.org/wiki/WordPress" rel="nofollow noreferrer">WordPress</a> and the wiki. I hacked <a href="http://en.wikipedia.org/wiki/MediaWiki" rel="nofollow noreferrer">MediaWiki</a> a while ago to share logins with another site (in <a href="http://en.wikipedia.org/wiki/Active_Server_Pages" rel="nofollow noreferrer">ASP Classic</a>) via session cookies, and it was a pain to do and even worse to maintain. Ideally, I would like to find a plug-in or someone who knows a more elegant solution.</p>
<p>The tutorial <em><a href="https://bbpress.org/forums/topic/mediawiki-bbpress-and-wordpress-integration/" rel="nofollow noreferrer">WordPress, bbPress &amp; MediaWiki</a></em> should get you on the right track to integrating MediaWiki into your WordPress install. It's certainly going to be a <em>lot</em> easier than hacking WordPress to have wiki features, especially with the sort of granular permissions you're describing.</p>
<p>My company uses WordPress and MediaWiki internally and we use HTTP_AUTH access control to create a "single sign on". As we add more applications, we simply integrate them into the HTTP_AUTH system where practical. For security, you can run HTTP_AUTH over SSL. The basic steps are:</p> <p>Configure the .htaccess to specify the authentication type. We use MySQL in production but you could have a simple htpasswd file.</p> <p>In the WordPress directory's .htaccess file add the following:</p> <pre> &lt;Files wp-login.php&gt; AuthType Basic AuthName "Restricted Access" AuthUserFile /some/path/to/htpasswd Require valid-user &lt;/Files&gt; </pre> <p>In the WordPress wp-admin/ directory's .htaccess add the following:</p> <pre> AuthType Basic AuthName "Restricted Access" AuthUserFile /some/path/to/htpasswd Require valid-user </pre> <p>In the MediaWiki directory's .htaccess file add the following:</p> <pre> AuthType Basic AuthName "Restricted Access" AuthUserFile /some/path/to/htpasswd </pre> <p>Then install the <a href="http://www.mediawiki.org/wiki/Extension:HttpAuth" rel="nofollow noreferrer">HttpAuth</a> extension for MediaWiki and the <a href="http://wordpress.org/extend/plugins/http-authentication/" rel="nofollow noreferrer">HTTP Authentication</a> plugin for WordPress and configure. We had to make some slight modifications to the MediaWiki extension as our hosting environment does not provide mod_php but if you have mod_php it will work out of the box.</p> <p>Note that our environment is a private intranet so everyone is authenticated. The above .htaccess files will work for publicly viewable blogs but some additional tweaking may be required for the MediaWiki .htaccess depending on whether you want everyone to be required to be authenticated or not and if the site is publicly available.</p>
5,382
<p>I'm looking for an online solution for generating .ICO files. I'd like the ICO files to have the ability to have transparency as well.</p> <p>What software or web site do you use to create them?</p> <p>[Update]</p> <p>To clarify, I have an existing image in PNG format, 32 x 32 pixels. I want to generate the icon from this existing file, not create a brand new one online. Sorry for the confusion.</p>
<p>I have found the application <a href="http://icofx.ro/" rel="nofollow noreferrer">IcoFx</a> useful, you can import pretty much any image type to use for icon creation, including PNG's.</p>
<p>I can't imagine drawing icons online. Nowadays icons are usually <em>drawn</em> as vectors, and I'm not aware of any online vector packages.</p> <p>In case you decide to draw off-line instead, I use Xara (www.xara.com) to draw all my computer artwork, and I use Gif Movie Gear to create .ico files. The former is a superb vector package, the latter is just something I have lying around.</p>
2,974
<p>Got this from some mysql queries, puzzled since error 122 is usually a 'out of space' error but there's plenty of space left on the server... any ideas?</p>
<p>The answer: for some reason Mysql had its tmp tables on the /tmp partition which was limited to 100M, and was filled up by eaccelerator cache to 100M even though eaccel is limited to 16M of usage. Very weird, but I just moved eaccel cache elsewhere and problem solved.</p>
<p>I resolve this issue by increasing my disk size. try df -h to check whether there are enough disk space on your server.</p>
9,355
<p>I assume that <code>char* = "string"</code> is the same to <code>char* = new char[6]</code>. I believe these strings are created on the heap instead of the stack. So do I need to destroy them or free their memory when I'm done using them or do they get destroyed by themselves?</p>
<p>No. You only need to manually free strings when you manually allocate the memory yourself using the <code>malloc</code> function (in C) or the <code>new</code> operator (in C++). If you do not use <code>malloc</code> or <code>new</code>, then the <code>char*</code> or string will be created on the stack or as a compile-time constant.</p>
<p>new is always an allocation whereas defining a string inline actually embeds the data in the program itself and cannot be changed (some compilers allow this by a smart trick, don't bother).</p> <p>Some compilers type inline strings so that you cannot modify the buffer.</p> <pre><code>char* const sz1 = "string"; // embedded string, immutable buffer char* sz2 = new char[10]; // allocated string, should be deleted </code></pre>
7,475
<p>Is there a way to identify, from within a VM, that your code is running inside a VM?</p> <p>I guess there are more or less easy ways to identify specific VM systems, especially if the VM has the provider's extensions installed (such as for VirtualBox or VMWare). But is there a general way to identify that you are not running directly on the CPU?</p>
<p>A lot of the research on this is dedicated to detecting so-called "blue pill" attacks, that is, a malicious hypervisor that is actively attempting to evade detection. </p> <p>The classic trick to detect a VM is to populate the ITLB, run an instruction that <strong>must</strong> be virtualized (which necessarily clears out such processor state when it gives control to the hypervisor), then run some more code to detect if the ITLB is still populated. The first paper on it is located <a href="http://www.symantec.com/avcenter/reference/Virtual_Machine_Threats.pdf" rel="noreferrer">here</a>, and a rather colorful explanation from a <a href="http://web.archive.org/web/20080213212608/http://www.matasano.com/log/930/side-channel-detection-attacks-against-unauthorized-hypervisors/" rel="noreferrer">researcher's blog</a> and alternative <a href="http://web.archive.org/web/20080720153608/http://www.matasano.com/log/930/side-channel-detection-attacks-against-unauthorized-hypervisors/" rel="noreferrer">Wayback Machine link to the blog article (images broken)</a>.</p> <p>Bottom line from discussions on this is that there is always a way to detect a malicious hypervisor, and it's much simpler to detect one that isn't trying to hide.</p>
<p>If it VM does the job well, it should be invisible to the client that it's being virtualized. However, one can look at other clues.</p> <p>I would imagine that looking for known drivers or software specific to the VM environment would be the best possible way.</p> <p>For example, on a VMWare client running Windows, vmxnet.sys would be the network driver, displayed as VMware accelerated AMD PCNet Adapter.</p>
6,061
<p><a href="https://i.stack.imgur.com/qNWsZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qNWsZ.png" alt="extruded text on flat surface"></a></p> <p>Hey!</p> <p>Pretty new to all this. Wondering how you would approach this problem to have an extruded element on top of a flat surface. I want to avoid lots of support material (actually no support at all for a cleaner print and no work with sanding etc.) I intend to print this inverted in Z (i.e. text down) for the main structure.</p> <p>My only idea would be to print it separately and then glue it on. But maybe there is another solution that comes to your mind?</p> <p>Cheers!</p>
<p>welcome to 3DPrinting.</p> <p>To make this easier to talk about, let me call the surface on which you want to print the letters the "tabletop". </p> <p>Looking at your picture, let me guess that you would print the object with the tabletop down. Then everything prints naturally, with no bridging and no overhangs.</p> <p>You want to put text on the tabletop. This could be done by using support material to lift the bed up to the text height, or, in the converse, by using support material to permit the entire object to be printed with the tabletop up. I can't see enough detail in your drawing to know if the object is printable with the tabletop up without using support material, so I will assume that it is not.</p> <p>In your drawing, the lettering is a different color from the table. I'll assume that this is not your intention, and you want the entire object with the text to be printed with one material.</p> <p>I have solved this in two ways in different cases.</p> <p>In one case, I wanted extruded letters printed on a vertical surface. I surrounded the letters with a 45 degree draft so that the overhang was printable. This won't help you here unless the object is printable on the side.</p> <p>In another case, I changed my design to have letters engraved rather than extruded. That prints well against the bed, with no overhang issues, and only short bridging required.</p> <p>Engraved letters are readable, like extruded letters, and can be printed against the bed.</p>
<p>One way that I have solved that issue is by model it in openscad and embed the letters in the surface. then with my dual headed printer, print the letters in a different color. No support material is needed in that case.</p>
1,018
<p>I remember back when MS released a forum sample application, the design of the application was like this:</p> <p>/Classes/User.cs /Classes/Post.cs ... /Users.cs /Posts.cs</p> <p>So the classes folder had just the class i.e. properties and getters/setters. The Users.cs, Post.cs, etc. have the actual methods that access the Data Access Layer, so Posts.cs might look like:</p> <pre><code>public class Posts { public static Post GetPostByID(int postID) { SqlDataProvider dp = new SqlDataProvider(); return dp.GetPostByID(postID); } } </code></pre> <p>Another more traditional route would be to put all of the methods in Posts.cs into the class definition also (Post.cs).</p> <p>Splitting things into 2 files makes it much more procedural doesn't it? Isn't this breaking OOP rules since it is taking the behavior out of the class and putting it into another class definition?</p>
<p>If every method is just a static call straight to the data source, then the "Posts" class is really a Factory. You could certainly put the static methods in "Posts" into the "Post" class (this is how CSLA works), but they are still factory methods.</p> <p>I would say that a more modern and accurate name for the "Posts" class would be "PostFactory" (assuming that all it has is static methods).</p> <p>I guess I wouldn't say this is a "procedural" approach necessarily -- it's just a misleading name, you would assume in the modern OO world that a "Posts" object would be stateful and provide methods to manipulate and manage a set of "Post" objects.</p>
<p>Are you sure the classes aren't partial classes. In which case they really aren't two classes, just a single class spread across multiple files for better readability.</p>
8,252
<p>I am trying to register to a "Device added/ Device removed" event using WMI. When I say device - I mean something in the lines of a Disk-On-Key or any other device that has files on it which I can access...</p> <p>I am registering to the event, and the event is raised, but the EventType propery is different from the one I am expecting to see.</p> <p>The documentation (<a href="http://msdn.microsoft.com/en-us/library/aa394124(VS.85).aspx" rel="nofollow noreferrer">MSDN</a>) states : 1- config change, 2- Device added, 3-Device removed 4- Docking. For some reason I always get a value of 1. </p> <p>Any ideas ?</p> <p>Here's sample code : </p> <pre><code>public class WMIReceiveEvent { public WMIReceiveEvent() { try { WqlEventQuery query = new WqlEventQuery( "SELECT * FROM Win32_DeviceChangeEvent"); ManagementEventWatcher watcher = new ManagementEventWatcher(query); Console.WriteLine("Waiting for an event..."); watcher.EventArrived += new EventArrivedEventHandler( HandleEvent); // Start listening for events watcher.Start(); // Do something while waiting for events System.Threading.Thread.Sleep(10000); // Stop listening for events watcher.Stop(); return; } catch(ManagementException err) { MessageBox.Show("An error occurred while trying to receive an event: " + err.Message); } } private void HandleEvent(object sender, EventArrivedEventArgs e) { Console.WriteLine(e.NewEvent.GetPropertyValue["EventType"]); } public static void Main() { WMIReceiveEvent receiveEvent = new WMIReceiveEvent(); return; } } </code></pre>
<p>Well, I couldn't find the code. Tried on my old RAC account, nothing. Nothing in my old backups. Go figure. But I tried to work out how I did it, and I think this is the correct sequence (I based a lot of it on this <a href="http://www.codeproject.com/KB/system/HwDetect.aspx" rel="nofollow noreferrer">article</a>):</p> <ol> <li>Get all drive letters and cache them. </li> <li>Wait for the WM_DEVICECHANGE message, and start a timer with a timeout of 1 second (this is done to avoid a lot of spurious WM_DEVICECHANGE messages that start as start as soon as you insert the USB key/other device and only end when the drive is "settled").</li> <li>Compare the drive letters with the old cache and detect the new ones.</li> <li>Get device information for those.</li> </ol> <p>I know there are other methods, but that proved to be the only one that would work consistently in different versions of windows, and we needed that as my client used the ActiveX control on a webpage that uploaded images from any kind of device you inserted (I think they produced some kind of printing kiosk).</p>
<p>Oh! Yup, I've been through that, but using the raw Windows API calls some time ago, while developing an ActiveX control that detected the insertion of any kind of media. I'll try to unearth the code from my backups and see if I can tell you how I solved it. I'll subscribe to the RSS just in case somebody gets there first.</p>
6,081
<p>The company I work for makes hardware that communicates to the computer though a serial port. Third party companies write software that communicates with our hardware. </p> <p>There are times when I need to diagnose our hardware. However, a third party software app connects to the serial port when Windows starts up, blocking any other connection. I don't know the name of this application/service and it's not always the same one.</p> <p>Is there any way to either:</p> <ul> <li>Find the name/pid of the app/service that is currently using a given serial port or</li> <li>Steal the serial port connection from another app.</li> </ul> <p>vb.net preferably, but I'll take a language agnostic answer as well.</p>
<p>You can use the <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="noreferrer">process explorer</a> tool also from SysInternals to search for open handles. In this case you would want to search for 'Serial' since it uses device names that may not map to com port numbers. (e.g. COM1 is \Device\Serial0 on my system).</p> <p>If you want to take control of the serial port from another app I think you would need co-operation of the driver.</p>
<p><a href="http://technet.microsoft.com/en-us/sysinternals/default.aspx" rel="nofollow noreferrer">Sysinternals</a> has a slew of utilities I find very useful and educational for tracking down what processes are doing to the system.</p> <p>They have a utility that does exactly what you need called <a href="http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx" rel="nofollow noreferrer">Portmon</a>, and give some information on how it works near the bottom of the page. That info and a few well-asked questions will probably give you everything you need to implement it yourself if the utility isn't enough.</p> <p>-Adam</p>
6,361
<p>I'm trying to programmatically restrict the memory consumption of plugins running in a .Net AppDomain, but I can't find any setup parameters for this, nor can I find a way to query an AppDomain to figure out how much memory it is consuming. Any ideas?</p>
<p>Old question, but in the meantime (since .Net framework 4.0) a new solution is available. You will have to enable ARM (Application domain Resource Monitoring). From that point on, you can request information on total consumed processor time, memory usage etc.</p> <p><a href="https://msdn.microsoft.com/en-us/library/dd997285%28v=vs.110%29.aspx" rel="noreferrer">See Microsoft documentation over here</a></p>
<p>Using the mscoree.CorRuntimeHostClass interop from C:\WINDOWS\Microsoft.NET\Framework\vXXXXXX\mscoree.tlb</p>
4,566
<p>Imagine a DOS style .cmd file which is used to launch interdependent windowed applications in the right order.</p> <p>Example:<br> 1) Launch a server application by calling an exe with parameters.<br> 2) Wait for the server to become initialized (or a fixed amount of time).<br> 3) Launch client application by calling an exe with parameters.</p> <p>What is the simplest way of accomplishing this kind of batch job in PowerShell?</p>
<p>Remember that PowerShell can access .Net objects. The Start-Sleep as suggested by <a href="https://stackoverflow.com/questions/49402/creating-batch-jobs-in-powershell#49520">Blair Conrad</a> can be replaced by a call to <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.waitforinputidle.aspx" rel="nofollow noreferrer">WaitForInputIdle</a> of the server process so you know when the server is ready before starting the client.</p> <pre><code>$sp = get-process server-application $sp.WaitForInputIdle() </code></pre> <p>You could also use <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx" rel="nofollow noreferrer">Process.Start</a> to start the process and have it return the exact Process. Then you don't need the get-process.</p> <pre><code>$sp = [diagnostics.process]::start("server-application", "params") $sp.WaitForInputIdle() $cp = [diagnostics.process]::start("client-application", "params") </code></pre>
<p>To wait 10 seconds between launching the applications, try</p> <pre><code>launch-server-application serverparam1 serverparam2 ... Start-Sleep -s 10 launch-client-application clientparam1 clientparam2 clientparam3 ... </code></pre> <p>If you want to create a script and have the arguments passed in, create a file called runlinkedapps.ps1 (or whatever) with these contents:</p> <pre><code>launch-server-application $args[0] $args[1] Start-Sleep -s 10 launch-client-application $args[2] $args[3] $args[4] </code></pre> <p>Or however you choose to distribute the server and client parameters on the line you use to run runlinkedapps.ps1. If you want, you could even pass in the delay here, instead of hardcoding <code>10</code>.</p> <p>Remember, your .ps1 file need to be on your Path, or you'll have to specify its location when you run it. (Oh, and I've assumed that launch-server-application and launch-client-application are on your Path - if not, you'll need to specify the full path to them as well.)</p>
7,193
<p>I am wondering if anyone else is experiencing these same issues:</p> <p>My main dev machine is a Dell, running Vista Home Premium and Visual Studio 2008 - both fully patched / up-to-date.</p> <p>There are some quirks, such as the play/pause media controls on my keyboard not working while running Visual Studio 2008. These kinds of quirks are annoying, but not really problematic.</p> <p>A bigger issue is this one:</p> <p>In one of my solutions, I make use of a class called <code>Utility</code>. If I edit the class to add another field, no matter how many times I recompile/clean/manually delete the old <code>.DLL</code> files, the compiler tells me that there is no such field. If, however, I check the solution into SVN and then check it out on my laptop, which runs Windows XP SP3 with a fully patched Visual Studio 2008 - everything works fine. No idea why.</p> <p>Has anyone else experienced this, or other problems with this kind of configuration? And if so, do you have any suggestions for how to overcome them?</p>
<p>VS2008 runs fine on my Vista. All service packs (both VS &amp; Vista) are installed.</p> <p>I'm also using a MS keyboard: <a href="http://www.microsoft.com/hardware/mouseandkeyboard/ProductDetails.aspx?pid=094&amp;active_tab=overview" rel="nofollow noreferrer">Laser Desktop 4000</a>.</p>
<p>have you tried doing things in elevated privileges mode? including reinstalling and all...</p>
4,812
<p>I have a javascript function that manipulates the DOM when it is called (adds CSS classes, etc). This is invoked when the user changes some values in a form. When the document is first loading, I want to invoke this function to prepare the initial state (which is simpler in this case than setting up the DOM from the server side to the correct initial state).</p> <p>Is it better to use window.onload to do this functionality or have a script block after the DOM elements I need to modify? For either case, why is it better?</p> <p>For example:</p> <pre><code>function updateDOM(id) { // updates the id element based on form state } </code></pre> <p>should I invoke it via:</p> <pre><code>window.onload = function() { updateDOM("myElement"); }; </code></pre> <p>or:</p> <pre><code>&lt;div id="myElement"&gt;...&lt;/div&gt; &lt;script language="javascript"&gt; updateDOM("myElement"); &lt;/script&gt; </code></pre> <p>The former seems to be the standard way to do it, but the latter seems to be just as good, perhaps better since it will update the element as soon as the script is hit, and as long as it is placed after the element, I don't see a problem with it.</p> <p>Any thoughts? Is one version really better than the other?</p>
<p>Definitely use <code>onload</code>. Keep your scripts separate from your page, or you'll go mad trying to disentangle them later.</p>
<p>My take is the former becauase you can only have 1 window.onload function, while inline script blocks you have an <em>n</em> number.</p>
6,224
<p>I'm using visual studio 2008 and <a href="http://en.wikipedia.org/wiki/ReSharper" rel="noreferrer">ReSharper</a> 4 and it's kind of slow. My machine has 2 GB of RAM, dual core processor and a 7200 rpm hard disk. I know more RAM and a faster hard disk could improve performance, but do you have any tips to improve ReSharper/Visual Studio performance?</p>
<p><strong>Turn off the annoying RSS reader</strong></p> <ul> <li>Tools, Options, Environment, Startup</li> </ul> <p><strong>Turn off all the animations</strong></p> <ul> <li>Tools, Options, Environment, Animate Environment Tools</li> </ul> <p><strong>Install the <a href="http://msdn.microsoft.com/en-us/vstudio/products/cc533447.aspx" rel="noreferrer">recent Service Pack</a></strong></p> <p><strong>Clean out your WebCache</strong></p> <ul> <li>AppData\Local\Microsoft\WebSiteCache</li> </ul>
<p>I'm having the exact same issue, and from the JetBrains site, it looks like they sort-of know about it but aren't admitting anything. Turning off solution-wide analysis does seem to help quite a bit.</p>
4,359
<p>I was discussing neural networks (NN) with a friend over lunch the other day and he claimed the the performance of a NN written in Java would be similar to one written in C++. I know that with 'just in time' compiler techniques Java can do very well, but somehow I just don't buy it. Does anyone have any experience that would shed light on this issue? <a href="http://en.wikipedia.org/wiki/Comparison_of_Java_and_C%2B%2B#Performance" rel="nofollow noreferrer">This page</a> is the extent of my reading on the subject.</p>
<p>The Hotspot JIT can now produce code <em>faster</em> than C++. The reason is run-time empirical optimization.</p> <p>For example, it can see that a certain loop takes the "false" branch 99% of the time and reorder the machine code instructions accordingly.</p> <p>There's lots of articles about this. If you want all the details, read <a href="http://java.sun.com/performance/reference/whitepapers/6_performance.html" rel="noreferrer">Sun's excellent whitepaper</a>. For more informal info, <a href="http://www.javaworld.com/jw-03-1998/jw-03-hotspot.html" rel="noreferrer">try this one</a>.</p>
<p>In the grand scheme of things, you're debating maybe a 5% performance difference where you'd get several orders of magnitude increase by moving to CUDA or dedicated hardware.</p>
9,016
<p>I am calling a vendor's Java API, and on some servers it appears that the JVM goes into a low priority polling loop after logging into the API (CPU at 100% usage). The same app on other servers does not exhibit this behavior. This happens on WebSphere and Tomcat. The environment is tricky to set up so it is difficult to try to do something like profiling within Eclipse.</p> <p>Is there a way to profile (or some other method of inspecting) an existing Java app running in Tomcat to find out what methods are being executed while it's in this spinwait kind of state? The app is only executing one method when it gets in this state (vendor's method). Vendor can't replicate the behavior (of course).</p> <hr> <p>Update: </p> <p>Using JConsole I was able to determine who was running and what they were doing. It took me a few hours to then figure out why it was doing it. The problem ended up being that the vendor's API jar that was being used did not match exactly to the the database configuration that it was using. It was defaulting to having tracing and performance monitoring enabled on the servers that had the slight mis-match in configuration. I used a different jar and all is well.</p> <p>So thanks, Joshua, for your answer. JConsole was extremely easy to setup and use to monitor an existing application. </p> <p>@Cringe - I did some experimenting with some of the options you suggested. I had some problems with getting JProfiler set up, it looks good (but pricey). Going forward I went ahead and added the Eclipse Profiler plugin and I'll be looking over the different open source profilers to compare functionality.</p>
<p>If you are using Java 5 or later, you can connect to your application using <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html" rel="noreferrer">jconsole</a> to view all running threads. jstack also will do a stack dump. I think this should still work even inside a container like Tomcat.</p> <p>Both of these tools are included with JDK5 and later (I assume the process needs to be at least Java 5, though I could be wrong)</p> <p>Update: It's also worth noting that starting with JDK 1.6 update 7 there is now a bundled profiler called <a href="http://java.sun.com/javase/6/docs/technotes/guides/visualvm/" rel="noreferrer">VisualVM</a> which can be launched with 'jvisualvm'. It looks like it is a <a href="http://visualvm.java.net/" rel="noreferrer">java.net project</a>, so additional info may be available at that page. I haven't used this yet but it looks useful for more serious analysis.</p> <p>Hope that helps</p>
<p>For completeness sake: even though my company more or less standardizes on Eclipse we use Netbeans (6 and up) with its <a href="http://profiler.netbeans.org/" rel="nofollow noreferrer">included, free profiler</a> on a daily basis. It works better than the Eclipse TPTP plugin (last checked 3 months ago) and for us it removes any need for a commercial profiler such as JProfiler, which is excellent, but fast becoming unnecessary.</p>
3,400
<p>I have a table in SQL Server that I inherited from a legacy system thats still in production that is structured according to the code below. I created a SP to query the table as described in the code below the table create statement. My issue is that, sporadically, calls from .NET to this SP both through the Enterprise Library 4 and through a DataReader object are slow. The SP is called through a loop structure in the Data Layer that specifies the params that go into the SP for the purpose of populating user objects. It's also important to mention that a slow call will not take place on every pass the loop structure. It will generally be fine for most of a day or more, and then start presenting which makes it extremely hard to debug.</p> <p>The table in question contains about 5 million rows. The calls that are slow, for instance, will take as long as 10 seconds, while the calls that are fast will take 0 to 10 milliseconds on average. I checked for locking/blocking transactions during the slow calls, none were found. I created some custom performance counters in the data layer to monitor call times. Essentially, when performance is bad, it's really bad for that one call. But when it's good, it's really good. I've been able to recreate the issue on a few different developer machines, but not on our development and staging database servers, which of course have beefier hardware. Generally, the problem is resolved through restarting the SQL server services, but not always. There are indexes on the table for the fields I'm querying, but there are more indexes than I would like. However, I'm hesitant to remove any or toy with the indexes due to the impact it may have on the legacy system. Has anyone experienced a problem like this before, or do you have a recommendation to remedy it? </p> <pre><code>CREATE TABLE [dbo].[product_performance_quarterly]( [performance_id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, [product_id] [int] NULL, [month] [int] NULL, [year] [int] NULL, [performance] [decimal](18, 6) NULL, [gross_or_net] [char](15) NULL, [vehicle_type] [char](30) NULL, [quarterly_or_monthly] [char](1) NULL, [stamp] [datetime] NULL CONSTRAINT [DF_product_performance_quarterly_stamp] DEFAULT (getdate()), [eA_loaded] [nchar](10) NULL, [vehicle_type_id] [int] NULL, [yearmonth] [char](6) NULL, [gross_or_net_id] [tinyint] NULL, CONSTRAINT [PK_product_performance_quarterly_4_19_04] PRIMARY KEY CLUSTERED ( [performance_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO ALTER TABLE [dbo].[product_performance_quarterly] WITH NOCHECK ADD CONSTRAINT [FK_product_performance_quarterlyProduct_id] FOREIGN KEY([product_id]) REFERENCES [dbo].[products] ([product_id]) GO ALTER TABLE [dbo].[product_performance_quarterly] CHECK CONSTRAINT [FK_product_performance_quarterlyProduct_id] CREATE PROCEDURE [eA.Analytics.Calculations].[USP.GetCalculationData] ( @PRODUCTID INT, --products.product_id @BEGINYEAR INT, --year to begin retrieving performance data @BEGINMONTH INT, --month to begin retrieving performance data @ENDYEAR INT, --year to end retrieving performance data @ENDMONTH INT, --month to end retrieving performance data @QUARTERLYORMONTHLY VARCHAR(1), --do you want quarterly or monthly data? @VEHICLETYPEID INT, --what product vehicle type are you looking for? @GROSSORNETID INT --are your looking gross of fees data or net of fees data? ) AS BEGIN SET NOCOUNT ON DECLARE @STARTDATE VARCHAR(6), @ENDDATE VARCHAR(6), @vBEGINMONTH VARCHAR(2), @vENDMONTH VARCHAR(2) IF LEN(@BEGINMONTH) = 1 SET @vBEGINMONTH = '0' + CAST(@BEGINMONTH AS VARCHAR(1)) ELSE SET @vBEGINMONTH = @BEGINMONTH IF LEN(@ENDMONTH) = 1 SET @vENDMONTH = '0' + CAST(@ENDMONTH AS VARCHAR(1)) ELSE SET @vENDMONTH = @ENDMONTH SET @STARTDATE = CAST(@BEGINYEAR AS VARCHAR(4)) + @vBEGINMONTH SET @ENDDATE = CAST(@ENDYEAR AS VARCHAR(4)) + @vENDMONTH --because null values for gross_or_net_id and vehicle_type_id are represented in --multiple ways (true null, empty string, or 0) in the PPQ table, need to account for all possible variations if --a -1 is passed in from the .NET code, which represents an enumerated value that --indicates that the value(s) should be true null. IF @VEHICLETYPEID = '-1' AND @GROSSORNETID = '-1' SELECT PPQ.YEARMONTH, PPQ.PERFORMANCE FROM PRODUCT_PERFORMANCE_QUARTERLY PPQ WITH (NOLOCK) WHERE (PPQ.PRODUCT_ID = @PRODUCTID) AND (PPQ.YEARMONTH BETWEEN @STARTDATE AND @ENDDATE) AND (PPQ.QUARTERLY_OR_MONTHLY = @QUARTERLYORMONTHLY) AND (PPQ.VEHICLE_TYPE_ID IS NULL OR PPQ.VEHICLE_TYPE_ID = '0' OR PPQ.VEHICLE_TYPE_ID = '') AND (PPQ.GROSS_OR_NET_ID IS NULL OR PPQ.GROSS_OR_NET_ID = '0' OR PPQ.GROSS_OR_NET_ID = '') ORDER BY PPQ.YEARMONTH ASC IF @VEHICLETYPEID &lt;&gt; '-1' AND @GROSSORNETID &lt;&gt; '-1' SELECT PPQ.YEARMONTH, PPQ.PERFORMANCE FROM PRODUCT_PERFORMANCE_QUARTERLY PPQ WITH (NOLOCK) WHERE (PPQ.PRODUCT_ID = @PRODUCTID) AND (PPQ.YEARMONTH BETWEEN @STARTDATE AND @ENDDATE) AND (PPQ.QUARTERLY_OR_MONTHLY = @QUARTERLYORMONTHLY) AND (PPQ.VEHICLE_TYPE_ID = @VEHICLETYPEID ) AND (PPQ.GROSS_OR_NET_ID = @GROSSORNETID) ORDER BY PPQ.YEARMONTH ASC IF @VEHICLETYPEID = '-1' AND @GROSSORNETID &lt;&gt; '-1' SELECT PPQ.YEARMONTH, PPQ.PERFORMANCE FROM PRODUCT_PERFORMANCE_QUARTERLY PPQ WITH (NOLOCK) WHERE (PPQ.PRODUCT_ID = @PRODUCTID) AND (PPQ.YEARMONTH BETWEEN @STARTDATE AND @ENDDATE) AND (PPQ.QUARTERLY_OR_MONTHLY = @QUARTERLYORMONTHLY) AND (PPQ.VEHICLE_TYPE_ID IS NULL OR PPQ.VEHICLE_TYPE_ID = '0' OR PPQ.VEHICLE_TYPE_ID = '') AND (PPQ.GROSS_OR_NET_ID = @GROSSORNETID) ORDER BY PPQ.YEARMONTH ASC IF @VEHICLETYPEID &lt;&gt; '-1' AND @GROSSORNETID = '-1' SELECT PPQ.YEARMONTH, PPQ.PERFORMANCE FROM PRODUCT_PERFORMANCE_QUARTERLY PPQ WITH (NOLOCK) WHERE (PPQ.PRODUCT_ID = @PRODUCTID) AND (PPQ.YEARMONTH BETWEEN @STARTDATE AND @ENDDATE) AND (PPQ.QUARTERLY_OR_MONTHLY = @QUARTERLYORMONTHLY) AND (PPQ.VEHICLE_TYPE_ID = @VEHICLETYPEID) AND (PPQ.GROSS_OR_NET_ID IS NULL OR PPQ.GROSS_OR_NET_ID = '0' OR PPQ.GROSS_OR_NET_ID = '') ORDER BY PPQ.YEARMONTH ASC END </code></pre>
<p>I have seen this happen with indexes that were out of date. It could also be a parameter sniffing problem, where a different query plan is being used for different parameters that come in to the stored procedure.</p> <p>You should capture the parameters of the slow calls and see if they are the same ones each time it runs slow.</p> <p>You might also try running the tuning wizard and see if it recommends any indexes.</p> <p>You don't want to worry about having too many indexes until you can prove that updates and inserts are happening too slow (time needed to modify the index plus locking/contention), or you are running out of disk space for them.</p>
<p>Sounds like another query is running in the background that has locked the table and your innocent query is simply waiting for it to finish</p>
8,210
<p>I want to merge multiple rss feeds into a single feed, removing any duplicates. Specifically, I'm interested in merging the feeds for the <a href="https://stackoverflow.com/tags">tags</a> I'm interested in.</p> <p>[A quick <a href="http://www.google.com/search?q=rss+merge+reader" rel="nofollow noreferrer">search</a> turned up some promising links, which I don't have time to visit at the moment]</p> <hr /> <p>Broadly speaking, the ideal would be a reader that would list all the available tags on the site and toggle them on and off, allowing me to explore what's available, keep track of questions I've visited, new answers on interesting feeds, etc, etc . . . though I don't suppose such a things exists right now.</p> <p>As I randomly explore the site and see questions I think are interesting, I inevitably find &quot;oh yes, that one looked interesting a couple days ago when I read it the first time, and hasn't been updated since&quot;. It would be much nicer if my machine would keep track of such deails for me :)</p> <hr /> <p><strong>Update:</strong> You can now use &quot;and&quot;, &quot;or&quot;, and &quot;not&quot; to combine multiple tags into a single feed: <a href="https://blog.stackoverflow.com/2008/10/tags-and-tags-or-tags/">Tags AND Tags OR Tags</a></p> <hr /> <p><strong>Update:</strong> You can now use <a href="https://stackexchange.com/filters">Filters</a> to watch tags across one or multiple sites: <a href="https://blog.stackoverflow.com/2011/04/improved-tag-sets/">Improved Tag Stes</a></p>
<p>Have you heard of <strong><a href="http://pipes.yahoo.com/pipes/" rel="noreferrer">Yahoo's Pipes</a></strong>. </p> <blockquote> <p>Its an interactive feed aggregator and manipulator. List of 'hot pipes' to subscribe to, and ability to create your own (yahoo account required).</p> </blockquote> <p>I played with it during beta back in the day, however I had a blast. Its really fun and easy to aggregate different feeds and you can add logic or filters to the "pipes". You can even do more then just RSS like import images from flickr.</p>
<p><a href="http://pipes.yahoo.com/pipes/" rel="nofollow noreferrer">Yahoo Pipes</a>?</p> <p><em>23 minutes later:</em> Aww, I got answer-sniped by @<a href="https://stackoverflow.com/users/1992/bernie-perez">Bernie Perez</a>. Oh well :)</p>
4,679
<p>I have a silverlight 2 beta 2 application that accesses a WCF web service. Because of this, it currently can only use basicHttp binding. The webservice will return fairly large amounts of XML data. This seems fairly wasteful from a bandwidth usage standpoint as the response, if zipped, would be smaller by a factor of 5 (I actually pasted the response into a txt file and zipped it.). </p> <p>The request does have the "Accept-Encoding: gzip, deflate" - Is there any way have the WCF service gzip (or otherwise compress) the response?</p> <p>I did find this <a href="http://www.vistax64.com/indigo/113763-wcf-client-j2ee-server-using-gzip.html" rel="noreferrer">link</a> but it sure seems a bit complex for functionality that should be handled out-of-the-box IMHO.</p> <p>OK - at first I marked the solution using the System.IO.Compression as the answer as I could never "seem" to get the IIS7 dynamic compression to work. Well, as it turns out:</p> <ol> <li><p>Dynamic Compression on IIS7 <strong>was</strong> working al along. It is just that Nikhil's Web Developer Helper plugin for IE did not show it working. My guess is that since SL hands the web service call off to the browser, that the browser handles it "under the covers" and Nikhil's tool never sees the compressed response. I was able to confirm this by using Fiddler which monitors traffic external to the browser application. In fiddler, the response was, in fact, gzip compressed!!</p></li> <li><p>The other problem with the System.IO.Compression solution is that System.IO.Compression does not exist in the Silverlight CLR.</p></li> </ol> <p>So from my perspective, the EASIEST way to enable WCF compression in Silverlight is to enable Dynamic Compression in IIS7 and write no code at all.</p>
<p>I didn't see a native way for WCF to do compression when doing a WCF project recently. I just used the System.IO.Compression namespace and made a quick compressor. Here's the code i used</p> <pre><code>public static class CompressedSerializer { /// &lt;summary&gt; /// Decompresses the specified compressed data. /// &lt;/summary&gt; /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt; /// &lt;param name="compressedData"&gt;The compressed data.&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public static T Decompress&lt;T&gt;(byte[] compressedData) where T : class { T result = null; using (MemoryStream memory = new MemoryStream()) { memory.Write(compressedData, 0, compressedData.Length); memory.Position = 0L; using (GZipStream zip= new GZipStream(memory, CompressionMode.Decompress, true)) { zip.Flush(); var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); result = formatter.Deserialize(zip) as T; } } return result; } /// &lt;summary&gt; /// Compresses the specified data. /// &lt;/summary&gt; /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt; /// &lt;param name="data"&gt;The data.&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public static byte[] Compress&lt;T&gt;(T data) { byte[] result = null; using (MemoryStream memory = new MemoryStream()) { using (GZipStream zip= new GZipStream(memory, CompressionMode.Compress, true)) { var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); formatter.Serialize(zip, data); } result = memory.ToArray(); } return result; } } </code></pre> <p>then i just had my services take in a byte array as an input, like such</p> <pre><code>void ReceiveData(byte[] data); </code></pre> <p>Worked out well for me. </p>
<p>It should also be noted that you may need to add the mime type to <code>applicationHost.config</code> under <code>&lt;httpCompression&gt;&lt;dynamicTypes&gt;</code> section in addition to enabling compression for the site:</p> <pre><code>&lt;add mimeType="application/soap+msbin1" enabled="true" /&gt; </code></pre> <p>If certain dynamic responses are not being compressed (and some are) it could be a mime type issue. Use Fiddler to get the specifics associated with the request. Failed request tracing may be useful in determining whether or not IIS is even attempting to compression the response. If compression is correctly configured you will see a <code>NO_MATCHING_CONTENT_TYPE</code> in the <strong>complete trace</strong> section of the trace output.</p>
3,129
<p>How can I add horizontal scroll capabilities to the asp.net listbox control?</p>
<p>Example to add horizontal scroll:</p> <pre><code>&lt;asp:ListBox ID="List" runat="server" Height="320px" Width="100%" style="overflow-x:auto;"SelectionMode="Multiple"&gt; &lt;/asp:ListBox&gt; </code></pre> <p>CSS3 overflow-x Property: <a href="http://www.w3schools.com/cssref/css3_pr_overflow-x.asp" rel="nofollow">http://www.w3schools.com/cssref/css3_pr_overflow-x.asp</a></p>
<p>If you are doing it only for display purpose, You can do it in another way by using Textbox with mulitiline property. By appending the text with new line as such!</p> <pre><code> List&lt;Yourclass&gt; result = null; result = Objname.getResult(Parameter1, Parameter2); foreach (Yourclass res in result) { txtBoxUser.Text += res.Fieldname1.ToString(); txtBoxUser.Text += "\r\n" + res.Fieldname2.ToString(); txtBoxUser.Text += "\n\n"; } </code></pre> <p>Hence you will get the view of mulitline textbox with All your data arranged in good format as above code(New line and all). And also it will wrap your texts if it exceeded the width of your textbox. Also you no need to bother about the scrollsbars and here you will get only vertical scroll bar since all our results have been wrapped as per the behaviour of textbox.</p>
6,746
<p>It seems that a Bowden extruder is the most used in all cheap 3D printers by far compared to Direct Drive that is very rare under 500 USD machines. But I haven't understood the reason, since in terms of hardware a direct drive doesn't seem to have any impact on price more than Bowden (correct me if I'm wrong).</p> <p>Why?</p>
<p>As I understand it, there's really no good reason for this except &quot;momentum&quot;. At some point in the not too distant past, a Bowden extruder was seen as an &quot;upgrade&quot; over direct drive, which required a bulky toolhead that was seen as limiting speeds.</p> <p>(This perception was at best accurate only for delta and CoreXY machines at the time even, I think. As it turned out, Bowden doesn't let you print faster, at least not at any quality, because the nonlinear/hysteresis effects of the Bowden tube on the actual amount of material extruded can't fully be compensated with linear advance/pressure advance once you reach moderately high speeds. You can overcome this with the <a href="https://www.youtube.com/watch?v=cF33iXlFqVs" rel="noreferrer">Nitram Bowden</a> but good luck finding a cheap 3D printer manufacturer willing to put in that kind of custom part!)</p> <p>Anyway, all the cheap printer manufacturers jumped on Bowden as a feature, and they're slow to develop any new designs rather than just making incremental improvements and production cost optimizations to existing ones.</p> <p>Since then, direct drive designs have improved greatly, and the mass of the good ones has gotten so low that it's hardly a consideration anymore except on the most extreme agility-seeking printers (designs attempting 50k-300k acceleration). Everything should be direct drive, especially since it makes things so much easier for beginners (no difficult-to-load tube, broken filament in tube, loose fittings messing up retraction, etc.)</p> <p>Teaching Tech has a video, oddly named <a href="https://www.youtube.com/watch?v=ybTbuUBy2-s" rel="noreferrer">Why direct drive is not automatically better than bowden tube</a>, where he basically concludes that it is actually better, and goes over some of the history I've touched on.</p>
<p>Using a bowden extruder allows the manufacturer to place heavy components lower down on the printer frame. This lowers the center of gravity and reduces the amount of movement that the hot end creates when it tracks across the bed.</p> <p>This allows the hot end to move\print faster without having to reinforce the printer's frame or to include higher quality belts\motors or dampeners.</p>
2,080
<p>What is best practice when creating your exception classes in a .NET solution: To derive from <code>System.Exception</code> or from <code>System.ApplicationException</code>?</p>
<p>According to Jeffery Richter in the Framework Design Guidelines book:</p> <blockquote> <p><code>System.ApplicationException</code> is a class that should not be part of the .NET framework.</p> </blockquote> <p>It was intended to have some meaning in that you could potentially catch "all" the application exceptions, but the pattern was not followed and so it has no value.</p>
<p>I'm used to do:</p> <pre><code>private void buttonFoo_Click() { try { foo(); } catch(ApplicationException ex) { Log.UserWarning(ex); MessageVox.Show(ex.Message); } catch(Exception ex) { Log.CodeError(ex); MessageBox.Show("Internal error."); } } </code></pre> <p>It allow to do the difference between:</p> <ul> <li>C# code system error that I must repairs.</li> <li>"Normal" user error that do not need correction from me.</li> </ul> <p>I know it is not recommended to use ApplicationException, but it works great since there is <a href="http://msdn.microsoft.com/en-us/library/system.applicationexception.aspx" rel="nofollow noreferrer">very few classes</a> that do not respect the ApplicationException pattern.</p>
7,605
<p>If I remove all the ' characters from a SQL query, is there some other way to do a SQL injection attack on the database?</p> <p>How can it be done? Can anyone give me examples?</p>
<p>Yes, there is. An excerpt from <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="noreferrer">Wikipedia</a></p> <p><code>"SELECT * FROM data WHERE id = " + a_variable + ";"</code></p> <p>It is clear from this statement that the author intended a_variable to be a number correlating to the "id" field. However, if it is in fact a string then the end user may manipulate the statement as they choose, thereby bypassing the need for escape characters. For example, setting a_variable to</p> <p><code>1;DROP TABLE users</code></p> <p>will drop (delete) the "users" table from the database, since the SQL would be rendered as follows:</p> <p><code>SELECT * FROM DATA WHERE id=1;DROP TABLE users;</code></p> <p>SQL injection is <em>not</em> a simple attack to fight. I would do very careful research if I were you.</p>
<p>It depends on how you put together the query, but in essence yes.</p> <p>For example, in Java if you were to do this (deliberately egregious example):</p> <pre><code> String query = "SELECT name_ from Customer WHERE ID = " + request.getParameter("id"); </code></pre> <p>then there's a good chance you are opening yourself up to an injection attack.</p> <p>Java has some useful tools to protect against these, such as PreparedStatements (where you pass in a string like "SELECT name_ from Customer WHERE ID = ?" and the JDBC layer handles escapes while replacing the ? tokens for you), but some other languages are not so helpful for this.</p>
9,729
<p>I have a Robo 3D. However A while ago, the print bed was fractured, and now it has a long crack cutting it in half. The bed still works because it is held together, by the screws holding the bed to the tracks. So I want to continue using it, because it still is fairly good, the heating element works fine, and a replacement bed is 80$, and I am unsure if the one sold on the RoBo 3D website will be compatible with my printer as I don't have the R1, but a version before that.</p> <p><a href="https://i.stack.imgur.com/b4osS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b4osS.jpg" alt="My cracked bed, with crack running straight through the center"></a></p> <p>So my question is: How can I best align the two glass fragments, to provide as flat a print surface as possible, and two how to best hold these two pieces in place, or if it would be best to invest in a new print bed?</p> <p>EDIT: Here is a image of the heating element as well to explain the situation with how it is attached<a href="https://i.stack.imgur.com/4yr34.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4yr34.jpg" alt="The heating element attached to the underside of the glass print bed"></a></p> <p>EDIT: The RoBo 3D team have said that I just need to upgrade my y-axis with a object on thingiverse and then buy their new build plate. So I am going to experiment with a glass replacement, and if that fails to succeed then I will go along with their suggestion, and buy the upgrade. Thanks everyone for their help.</p>
<p>A little chip is fine, but I wouldn't print with that big of a crack. <strong>However</strong>, that doesn't mean you need to spend $80 on a new sheet of glass.</p> <p>Option #1- If you want borosilicate glass, you can get a sheet from either McMaster (about $40+shipping for a 10"x10" piece, less for smaller) or from a local glass maker (the price varies a lot, so you should check that also if you want to go that route). However, you won't be able to drill holes (tempered glass <em>will</em> break of you drill a hole). Borosilicate glass has the advantage of being <em>extremely</em> heat-resistant, so it won't break from thermal expansion. If you go this route, you should pick up a few binder clips also to attach the sheet to the heated bed.</p> <p>Option #2- You might be able to get picture frame glass from a hardware store. It's super cheap (mine was $3 or something from lowes) and they'll often cut it to exact size. You might be able to drill this, but you have to be extremely careful. Sometimes, the hardware store can drill holes in the sheet for you if needed. If you don't want to drill, a few binder clips will work just as well.</p> <p>Just a note for if you are using binder clips: you might need to (depending on how your hbp is set up) get a piece of glass that is slightly smaller to allow for any bed leveling screws to have room. If you're going with the picture frame glass, you should make sure that the glass will be entirely within the heated part so that there isn't any heat gradient (that's how glass cracks/shatters). </p>
<p>If your heatbed itself is aluminum/copper/other metal: Get a glass cut and replace it. The current one is probably attached to the heatbed with adhesive glue. If it the adhesive is cyanocrylate based, you can remove by rubbing with acetone. If silicone type, it will come off by some force. Don't worry, you won't damage aluminum. THe heating element is either inside the aluminum or under it. If it's not alumunum it's likely a PCB heatbed. Then I wouldn't suggest to use acetone or some "antiglue" and would just try to apply a little force and see if the glass moves a bit. If no, don't bother, PCB heatbeds can break too. Then I'd just suggest to apply some epoxy to cover the holes surrounding the cracks and keeping the glasses uniform.</p> <p>Also, about replacement glasses: picture frame glasses are very cheap. McMaster sells some high quality bearings and rods, but for glass there's no point to waste money. $5 is typical for that size borosilicate glass, if you're in USA (I'm not) I think your local Home Depot will cut it for free for you as well.</p>
178
<p>I have experience writing console and network client/server applications in C and C++, but I know next to nothing about using the win32 visual API, MFC, Qt, wxWidgets, etc. Where is a good place to start, and what method should I specialize in, so as to be future ready and robust?</p>
<p>This is a rather broad question, as programming GUI applications in Windows can be done in so many ways.</p> <p>There are two main parts to developing any GUI app: the <strong>language</strong> and the <strong>API/framework</strong>. Considering you're interested in learning to build Windows GUI apps, the language isn't really a point of focus for you. Hence, you should pick a language you already know and work with a framework or API that can be harnessed by your chosen language.</p> <p>If you want to use C you're pretty much restricted to dealing with the Win32 API yourself, in which case reading <a href="https://rads.stackoverflow.com/amzn/click/com/157231995X" rel="noreferrer" rel="nofollow noreferrer">Petzold</a> or <a href="https://rads.stackoverflow.com/amzn/click/com/0735624240" rel="noreferrer" rel="nofollow noreferrer">Richter</a> would be great places to start. The Win32 API can be quite daunting, but it's well worth the effort to learn (imho). There are plenty of tutorials on Win32 on the web, and there's always <a href="http://msdn.microsoft.com/" rel="noreferrer">MSDN</a>, with a complete reference/guide to the Win32 API. Make sure you cover not just the API, but other areas such as resources/dialogs as they are building blocks for your Win32 application.</p> <p>If you want to use C++ you have all of the options that you have when using C plus a few others. I'd recommend going with the Win32 API directly, and then moving on to a known framework such as MFC, Qt, wxWindows or GTK so that you can spend less time working with boilerplate code and instead focus on writing your application logic. The last 3 options I just listed have the added benefit of being cross-platform, so you don't have to worry too much about platform-specific issues. Given that you said you want to work with Windows, I'll assume you're keen to focus on that rather than cross-platform -- so go with MFC, but spend some time with the Win32 API first to get familiar with some of the concepts.</p> <p>When dealing with MFC and the Win32 API, it's a good idea to try and get a solid understanding of the terminology prior to writing code. For example, you need to understand what the <a href="http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows" rel="noreferrer">message pump</a> is, and how it works. You need to know about concepts such as "<a href="http://www.codeproject.com/KB/buttons/nativewin32xpthemes.aspx" rel="noreferrer">owner-drawn</a> controls", and <a href="http://msdn.microsoft.com/en-us/library/ms997565.aspx" rel="noreferrer">subclassing</a>. When you understand these things (and more), you'll find it easier to work with MFC because it uses similar terminology in its class interfaces (eg. you need to know what "translate messages" means before you can understand how and when to use <a href="http://msdn.microsoft.com/en-us/library/kkbhxcs2(VS.80).aspx" rel="noreferrer">PreTranslateMessage</a>).</p> <p>You could also use Managed C++ to write .NET GUI applications, but I've read in a few places that Managed C++ wasn't really intended to be used in this manner. Instead it should be used as a gateway between native/unmanaged code and managed code. If you're using .NET it's best to use a .NET language such as VB.NET or C# to build your GUIs.</p> <p>So if you <em>are</em> going to use .NET, you currently have the choice of the <a href="http://msdn.microsoft.com/en-us/netframework/aa497342.aspx" rel="noreferrer">WinForms</a> library, or <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation" rel="noreferrer">WPF</a>. I personally feel that you'd be wasting time learning to build WinForms applications given that WPF is designed to replace it. Over time WPF will become more prevelant and Winforms will most likely die off. WPF has a much richer API set, and doesn't suffer from many of the limitations that Winforms does. If you do choose this route, however, you'll no doubt have to learn <a href="http://msdn.microsoft.com/en-us/library/ms752059.aspx" rel="noreferrer">XAML</a>, which is a markup language that drives WPF applications. This technology is coming of age, and there are many great places to learn about it. First, there are sites such as <a href="http://learnwpf.com/" rel="noreferrer">LearnWPF</a>, and <a href="http://www.drwpf.com/" rel="noreferrer">DrWPF</a> which have some really great articles. Secondly, there are <a href="https://rads.stackoverflow.com/amzn/click/com/0321374479" rel="noreferrer" rel="nofollow noreferrer">plenty</a> of <a href="https://rads.stackoverflow.com/amzn/click/com/0596510373" rel="noreferrer" rel="nofollow noreferrer">quality</a> <a href="https://rads.stackoverflow.com/amzn/click/com/0672328917" rel="noreferrer" rel="nofollow noreferrer">books</a> on the <a href="https://rads.stackoverflow.com/amzn/click/com/1590599551" rel="noreferrer" rel="nofollow noreferrer">topic</a>.</p> <p>So, to sum up, once you've picked your language and tech, the path is actually quite easy. Just pick up a book or two, read some blogs, get into some code samples.. and most importantly ... write code. Keep writing, keep making mistakes, and keep learning from them.</p> <p>As a final note...</p> <blockquote> <p>In other words, Silverlight. If you don't want to go the MS route you might give Adobe's Flash/Flex a look see. Both Silverlight and Flash/Flex build RIA's. Which I think is where we are headed. They days of Office like apps are numbered</p> </blockquote> <p>I don't agree at all. Silverlight is not the same as WPF. Silverlight is web-specific, and only has a subset of WPF's features. Given that the question asks for Windows GUI apps, Flash/Flex Rich Internet Apps are not really a fitting suggestion. I also don't agree that the days of Rich Client Applications (such as office) are numbered at all.</p> <p>I hope that helps. Good luck :)</p>
<p>For business apps, Windows Forms is very mature. It provides a gentle path from auto-generating a lot for you into allowing fine-grained control and rolling your own. There are tons of high-quality third party controls and a large body of examples, docs, etc out there. It's hard to run into a problem that someone else hasn't solved. I highly recommend acquiring some background Win32 knowledge (e.g. <a href="http://www.charlespetzold.com/pw5/index.html" rel="nofollow noreferrer">Petzold</a>) as the WinForms framework lives on top of it.</p> <p>I have no WPF experience, but from the sample apps I've seen it looks like a good choice for apps whose interfaces would benefit from more graphical metaphors. So if you're doing a banking app, probably not worth the extra design overhead. But if you're doing, say, a warehouse management app it could be improved by dropping pretty boxes into pretty bins.</p> <p>@StephenCox: wrong answer to the wrong question. OP is asking about desktop client apps, and moreover, WPF != Silverlight.</p>
2,636
<p>I'm maintaining a .NET 1.1 application and one of the things I've been tasked with is making sure the user doesn't see any unfriendly error notifications.</p> <p>I've added handlers to <code>Application.ThreadException</code> and <code>AppDomain.CurrentDomain.UnhandledException</code>, which do get called. My problem is that the standard CLR error dialog is still displayed (before the exception handler is called).</p> <p>Jeff talks about this problem on his blog <a href="https://blog.codinghorror.com/console-apps-and-appdomain-currentdomain-unhandledexception/" rel="noreferrer">here</a> and <a href="https://blog.codinghorror.com/improved-unhandled-exception-behavior-in-net-20/" rel="noreferrer">here</a>. But there's no solution. So what is the standard way in .NET 1.1 to handle uncaught exceptions and display a friendly dialog box?</p> <p>Jeff's response was marked as the correct answer because the link he provided has the most complete information on how to do what's required.</p>
<p>Oh, in Windows Forms you definitely should be able to get it to work. The only thing you have to watch out for is things happening on different threads.</p> <p>I have an old Code Project article here which should help:</p> <p><em><a href="http://www.codeproject.com/KB/exception/ExceptionHandling.aspx" rel="nofollow noreferrer">User Friendly Exception Handling</a></em></p>
<p><strong>The Short Answer,</strong> <em>Looks like, an exception occurring in Form.Load doesn't get routed to Application.ThreadException or AppDomain.CurrentDomain.UnhandledException without a debugger attached.</em></p> <p><strong>The More accurate Answer/Story</strong> This is how I solved a similar problem. I can't say for sure how it does it, but here is what I think. Improvement suggestions are welcome.</p> <p>The three events,</p> <ol> <li>AppDomain.CurrentDomain.FirstChanceException</li> <li>AppDomain.CurrentDomain.UnhandledException</li> <li>and Application.ThreadException</li> </ol> <p>accumulatively catch most of the exceptions but not on a global scope (as said earlier). In one of my applications, I used a combination of these to catch all kinds of exceptions and even the unmanaged code exceptions like DirectX exception (through SharpDX). All exceptions, whether they are caught or not, seem to be invoking FirstChanceException without a doubt.</p> <pre><code>AppDomain.CurrentDomain.FirstChanceException += MyFirstChanceExceptionHandler; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // not sure if this is important or not. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // can't use Lambda here. need to Unsub this event later. Application.ThreadException += (s, e) =&gt; MyUnhandledExceptionHandler(e.Exception); static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { MyUnhandledExceptionHandler((Exception)e.ExceptionObject); } private void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs eventArgs) { // detect the pattern of the exception which we won't be able to get in Fatal events. if (eventArgs.Exception.Message.StartsWith(&quot;HRESULT&quot;)) MyUnhandledExceptionHandler(eventArgs.Exception); } </code></pre> <p>and the handler looks like</p> <pre><code>static void MyUnhandledExceptionHandler(Exception ex) { AppDomain.CurrentDomain.UnhandledException -= MyUnhandledExceptionHandler; // this is important. Any exception occuring in the logging mechanism can cause a stack overflow exception which triggers the window's own JIT message/App crash message if Win JIT is not available. // LogTheException() // Collect user data // inform the user in a civil way to restart/close the app Environment.Exit(0); } </code></pre> <p>Unmanaged code exceptions like DirectX exceptions appeared only in FirstChanceException where I had to decide for myself if the exception was fatal or not. I then use MyUnhandledExceptionHandler to log and let the user know in a friendly way that everything was &quot;under control&quot;.</p> <p><strong>IMPORTANT NOTE!</strong> The scheme still didn't catch one kind of exception. It did appear in FirstChanceException, but it was hard to distinguish it from other kinds of exceptions hitting this handler. Any exception occurring directly in Form.Load had this different behavior. When the VS debugger was attached, these were routed to the UnhandledException event. But without a debugger, an old-school windows message will pop up, showing the stack trace of the exception that occurred. The most annoying thing was that it didn't let MyUnhandledExceptionHandlerr get kicked once it was done and the app continued to work in an abnormal state. The final solution I did was to move all the code from Form_load to another thread using <code>MyForm.Load += (s,e) =&gt; new Thread(()=&gt;{/* My Form_Load code*/ }).Start();</code>. This way, Application.ThreadException gets triggered which is routed to MyUnhandledExceptionHandler, my safe exit.</p>
2,337
<p>A J2ME client is sending HTTP POST requests with chunked transfer encoding.</p> <p>When ASP.NET (in both IIS6 and WebDev.exe.server) tries to read the request it sets the Content-Length to 0. I guess this is ok because the Content-length is unknown when the request is loaded.</p> <p>However, when I read the Request.InputStream to the end, it returns 0.</p> <p>Here's the code I'm using to read the input stream.</p> <pre><code>using (var reader = new StreamReader(httpRequestBodyStream, BodyTextEncoding)) { string readString = reader.ReadToEnd(); Console.WriteLine("CharSize:" + readString.Length); return BodyTextEncoding.GetBytes(readString); } </code></pre> <p>I can simulate the behaiviour of the client with Fiddler, e.g.</p> <p><strong>URL</strong> <a href="http://localhost:15148/page.aspx" rel="nofollow noreferrer">http://localhost:15148/page.aspx</a></p> <p><strong>Headers:</strong> User-Agent: Fiddler Transfer-Encoding: Chunked Host: somesite.com:15148</p> <p><strong>Body</strong> rabbits rabbits rabbits rabbits. thanks for coming, it's been very useful!</p> <p>My body reader from above will return a zero length byte array...lame...</p> <p>Does anyone know how to enable chunked encoding on IIS and ASP.NET Development Server (cassini)?</p> <p>I found <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;278998" rel="nofollow noreferrer">this script</a> for IIS but it isn't working.</p>
<p>Seems to be official: <a href="http://msdn.microsoft.com/en-us/library/ee960144.aspx" rel="nofollow">Cassini does not support <code>Transfer-Encoding: chunked</code> requests.</a></p> <blockquote> <p>By default, the client sends large binary streams by using a chunked HTTP Transfer-Encoding. <strong>Because the ASP.NET Development Server does not support this kind of encoding</strong>, you cannot use this Web server to host a streaming data service that must accept large binary streams.</p> </blockquote>
<p>That url does not work any more, so it's hard to test this directly. I wondered if this would work, and google turned up someone who has experience with it at <a href="http://bytes.com/forum/thread246706.html" rel="nofollow noreferrer">bytes.com</a>. If you put your website up again, I can see if this really works there. </p> <p><strong>Joerg Jooss</strong> wrote: (<em>slightly modified for brevity</em> )</p> <pre><code>string responseText = null; WebRequest rabbits= WebRequest.Create(uri); using (Stream resp = rabbits.GetResponse().GetResponseStream()) { MemoryStream memoryStream = new MemoryStream(0x10000); byte[] buffer = new byte[0x1000]; int bytes; while ((bytes = resp.Read(buffer, 0, buffer.Length)) &gt; 0) { memoryStream.Write(buffer, 0, bytes); } // use the encoding to match the data source. Encoding enc = Encoding.UTF8; reponseText = enc.GetString(memoryStream.ToArray()); } </code></pre>
9,455
<p>How do I cast an <code>int</code> to an <code>enum</code> in C#?</p>
<p>From an int:</p> <pre><code>YourEnum foo = (YourEnum)yourInt; </code></pre> <p>From a string:</p> <pre><code>YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString); // The foo.ToString().Contains(&quot;,&quot;) check is necessary for // enumerations marked with a [Flags] attribute. if (!Enum.IsDefined(typeof(YourEnum), foo) &amp;&amp; !foo.ToString().Contains(&quot;,&quot;)) { throw new InvalidOperationException( $&quot;{yourString} is not an underlying value of the YourEnum enumeration.&quot; ); } </code></pre> <p>From a number:</p> <pre><code>YourEnum foo = (YourEnum)Enum.ToObject(typeof(YourEnum), yourInt); </code></pre>
<p>I need two instructions:</p> <pre><code>YourEnum possibleEnum = (YourEnum)value; // There isn't any guarantee that it is part of the enum if (Enum.IsDefined(typeof(YourEnum), possibleEnum)) { // Value exists in YourEnum } </code></pre>
4,913
<p>My print popped out from the bed and glued to the nozzle. As the printer was printing next hour or so, a lot of pla was extruded and formed on the nozzle. </p> <h2>I'm wondering what will be the best way to remove pla from the nozzle without overheating wires?</h2> <p>a remark: was trying to heat the nozzle over 180, but I am getting a thermal runout. The pla is hard, I don't want to broke the throat.</p> <p><a href="https://i.stack.imgur.com/jC20j.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jC20j.jpg" alt="enter image description here"></a></p>
<p>If you grab the blob with a pliers and twist, all or most of it may pop off. If not, heat the extruder up perhaps 10 degrees higher than usual, and wait for the external gunk to soften up and then pull it off.</p> <h3>edit :</h3> <p>Well, if it won't get hot enough, then try using an external source such as a soldering iron tip to cut off most of the mess, then it may be time for exacto knife blades and small files to remove the remainder.</p> <p>Unless you're a clean freak :-) a little residue around the nozzle doesn't matter - it won't touch your prints and at some time in the future it'll be &quot;cooked&quot; enough to fall off.</p>
<p>I would suggests to use a heat gun and carefully warm up the PLA to be soft and remove it carefully like a big piece of Play-Doh. Using the extruder to heat up the PLA don't sound like the best idea, for me, because the inner PLA will be fluid and it could be a bigger mess than it is up to now.</p>
898
<p>If Java application requires certain JRE version then how can I check its availability on Mac OS X during installation?</p>
<p>It should be as simple as looking at /System/Library/Frameworks/JavaVM.framework/Versions/</p> <p>E.g. from my machine:</p> <pre><code>manoa:~ stu$ ll /System/Library/Frameworks/JavaVM.framework/Versions/ total 56 774077 lrwxr-xr-x 1 root wheel 5 Jul 23 15:31 1.3 -&gt; 1.3.1 167151 drwxr-xr-x 3 root wheel 102 Jan 14 2008 1.3.1 167793 lrwxr-xr-x 1 root wheel 5 Feb 21 2008 1.4 -&gt; 1.4.2 774079 lrwxr-xr-x 1 root wheel 3 Jul 23 15:31 1.4.1 -&gt; 1.4 166913 drwxr-xr-x 8 root wheel 272 Feb 21 2008 1.4.2 168494 lrwxr-xr-x 1 root wheel 5 Feb 21 2008 1.5 -&gt; 1.5.0 166930 drwxr-xr-x 8 root wheel 272 Feb 21 2008 1.5.0 774585 lrwxr-xr-x 1 root wheel 5 Jul 23 15:31 1.6 -&gt; 1.6.0 747415 drwxr-xr-x 8 root wheel 272 Jul 23 10:24 1.6.0 167155 drwxr-xr-x 8 root wheel 272 Jul 23 15:31 A 776765 lrwxr-xr-x 1 root wheel 1 Jul 23 15:31 Current -&gt; A 774125 lrwxr-xr-x 1 root wheel 3 Jul 23 15:31 CurrentJDK -&gt; 1.5 manoa:~ stu$ </code></pre>
<p>This artical may help: <a href="http://developer.apple.com/technotes/tn2002/tn2110.html" rel="nofollow noreferrer">http://developer.apple.com/technotes/tn2002/tn2110.html</a><br /> Summery:</p> <pre><code>String javaVersion = System.getProperty("java.version"); if (javaVersion.startsWith("1.4")) { // New features for 1.4 } </code></pre>
8,876
<p>In the build log I'd like to the start and end time of each project's compilation. Is there any way to get VS to do this?</p>
<p>For VC++ builds you can enable build timing. Go to Tools->Options->Projects and Solutions->VC++ Project settings and choose the option for 'Build Timing'</p>
<p>Not without modifying the actual project file (using a text editor) to add calls in to the MSBuild script targets.</p>
6,866
<p>I'd like to add an extra motor to my board and I'm not sure where I went wrong. The motor will be used to spin a rotating wheel/carriage of potential hot ends to switch to. Because it's just a motor it doesn't need a heatrod or a temperature sensor. </p> <p>I had just a MKS_BASE 1.0 board, so I purchased a RAMPS 1.4 board from <a href="https://www.ebay.com/itm/3D-Printer-RAMPS-1-4-Controller-Board-for-Arduino-Stampante-Reprap-Prusa-Mendel/303099940701?ssPageName=STRK%3AMEBIDX%3AIT&amp;_trksid=p2057872.m2749.l2649" rel="nofollow noreferrer">Ebay</a> to be its extender.</p> <p><a href="https://i.stack.imgur.com/Ucxb5.jpg" rel="nofollow noreferrer" title="RAMPS 1.4 board"><img src="https://i.stack.imgur.com/Ucxb5.jpg" alt="RAMPS 1.4 board" title="RAMPS 1.4 board"></a></p> <p>(( **Warning ** this board is cheap because it was improperly produced and is a fire hazard: <a href="https://reprap.org/wiki/RAMPS_1.4" rel="nofollow noreferrer">https://reprap.org/wiki/RAMPS_1.4</a> . I recommend using a CNC shield instead ))</p> <p>This red board is meant to fit an Arduino Mega, but I figure I can use the extra pins on the MKS_BASE1.0 and connect them with jumper wire to the RAMPS 1.4 board. It made sense in case I want to add other things to the original MKS_BASE 1.0 board (like more hot end heater cartridges). </p> <p>I connected the 5V and one GND pin from my MKS_BASE 1.0. I also connected some of the SERVOS pins from the MKS_BASE 1.0: D37 is the 'Dir', D35 is the 'Step', and D17 is the 'Enable'. I also connected the 12V power supply to the RAMPS 1.4 board too.</p> <p><a href="https://i.stack.imgur.com/YlGDW.png" rel="nofollow noreferrer" title="RAMPS 1.4 board pinout"><img src="https://i.stack.imgur.com/YlGDW.png" alt="RAMPS 1.4 board pinout" title="RAMPS 1.4 board pinout"></a></p> <p>When it came time to modify Marlin everything was a bit annoying because although Marlin makes it easy to add more extruders, adding just motors is a little more difficult. I had to change the number of extruders to be 3 (from dual extrusion to dual extrusion + extra motor), enable an extra temperature pin (which i am leaving empty) and also modify the pins.h file. </p> <p>I probably wouldn't have had simulate this motor as an extruder if I knew the raw Arduino commands for spinning a motor using calls to <code>D37</code>, <code>D35</code>, and <code>D17</code>, so I figured simulating an extruder would be better, but now I'm second-guessing that decision.</p> <p>Here's my modification to pins.h:</p> <pre><code>#define E2_STEP_PIN 35 #define E2_DIR_PIN 37 #define E2_ENABLE_PIN 17 #define HEATER_2_PIN 17 //#define TEMP_SENSOR_2 3 in Configuration.h #define TEMP_2_PIN 3 // Marlin 0-indexes these pins, so "2" is actually for the "3"rd extruder </code></pre> <p>First thing I have to do is allow for cold extrusions by using M302 S-80. The other (real) extruder motors will all move after this command, so I have that part working.. . </p> <p>In Repetier-Host I am just selecting Extruder 3 and trying to "push filament" through it but the motor isn't moving. I'm using an A4988 stepper driver on a Kysan 1124090. Actually, I did this whole process with two motors because I wasn't sure whether the hardware itself would be an issue, so with another set of pins I'm using a Suncor Motor and it also doesn't respond and I also don't know why.</p> <p>It would be really helpful to debug if I could run a single G-code command just to get the motor running at a speed, and take that out of the equation. it doesn't have to be a command to an "extruder" but just a command to a pin out, like <code>M42 D35 S100</code> (but I don't know the raw command for just testing a motor's connections). </p>
<p><code>D35</code>, <code>D37</code>, <code>D17</code> are the pin labels on the Arduino Mega. <em>These do not correspond to pin numbers within Marlin</em>.</p> <p>I believe that <code>D35</code> actually corresponds to marlin pin <code>49</code> and this is the number you should enter in your firmware. You can find the mapping in <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/fastio_1280.h" rel="nofollow noreferrer">fastio_1280.h</a>:</p> <pre><code>Hardware Pin : 02 03 06 07 01 05 15 16 17 18 23 24 25 26 64 63 13 12 46 45 44 43 78 77 76 75 74 73 72 71 60 59 58 57 56 55 54 53 50 70 52 51 42 41 40 39 38 37 36 35 22 21 20 19 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 04 08 09 10 11 14 27 28 29 30 31 32 33 34 47 48 49 61 62 65 66 67 68 69 79 80 81 98 99 100 Port : E0 E1 E4 E5 G5 E3 H3 H4 H5 H6 B4 B5 B6 B7 J1 J0 H1 H0 D3 D2 D1 D0 A0 A1 A2 A3 A4 A5 A6 A7 C7 C6 C5 C4 C3 C2 C1 C0 D7 G2 G1 G0 L7 L6 L5 L4 L3 L2 L1 L0 B3 B2 B1 B0 F0 F1 F2 F3 F4 F5 F6 F7 K0 K1 K2 K3 K4 K5 K6 K7 E2 E6 E7 xx xx H2 H7 G3 G4 xx xx xx xx xx D4 D5 D6 xx xx J2 J3 J4 J5 J6 J7 xx xx xx xx xx Logical Pin : 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx </code></pre> <p>Look on the top row for the pin number (e.g. D35 corresponds to 35), then look on the bottom row to find the pin number to use in Marlin (in this case, 49).</p>
<p><code>D35</code>, <code>D37</code>, <code>D17</code> are the pin labels on the Arduino Mega. <em>These do not correspond to pin numbers within Marlin</em>.</p> <p>I believe that <code>D35</code> actually corresponds to marlin pin <code>49</code> and this is the number you should enter in your firmware. You can find the mapping in <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/fastio_1280.h" rel="nofollow noreferrer">fastio_1280.h</a>:</p> <pre><code>Hardware Pin : 02 03 06 07 01 05 15 16 17 18 23 24 25 26 64 63 13 12 46 45 44 43 78 77 76 75 74 73 72 71 60 59 58 57 56 55 54 53 50 70 52 51 42 41 40 39 38 37 36 35 22 21 20 19 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 04 08 09 10 11 14 27 28 29 30 31 32 33 34 47 48 49 61 62 65 66 67 68 69 79 80 81 98 99 100 Port : E0 E1 E4 E5 G5 E3 H3 H4 H5 H6 B4 B5 B6 B7 J1 J0 H1 H0 D3 D2 D1 D0 A0 A1 A2 A3 A4 A5 A6 A7 C7 C6 C5 C4 C3 C2 C1 C0 D7 G2 G1 G0 L7 L6 L5 L4 L3 L2 L1 L0 B3 B2 B1 B0 F0 F1 F2 F3 F4 F5 F6 F7 K0 K1 K2 K3 K4 K5 K6 K7 E2 E6 E7 xx xx H2 H7 G3 G4 xx xx xx xx xx D4 D5 D6 xx xx J2 J3 J4 J5 J6 J7 xx xx xx xx xx Logical Pin : 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx </code></pre> <p>Look on the top row for the pin number (e.g. D35 corresponds to 35), then look on the bottom row to find the pin number to use in Marlin (in this case, 49).</p>
1,421
<p>I am working on a project where I produce an aluminium extrusion cutting list.</p> <p>The aluminium extrusions come in lengths of 5m.</p> <p>I have a list of smaller lengths that need to be cut from the 5m lengths of aluminium extrusions.</p> <p>The smaller lengths need to be cut in the order that produces the least amount of off cut waste from the 5m lengths of aluminium extrusions.</p> <p>Currently I order the cutting list in such a way that generally the longest of the smaller lengths gets cut first and the shortest of smaller lengths gets cut last. The exception to this rule is whenever a shorter length will not fit in what is left of the 5m length of aluminium extrusion, I use the longest shorter length that will fit.</p> <p>This seems to produce a very efficient (very little off cut waste) cutting list and doesn't take long to calculate. I imagine, however, that even though the cutting list is <strong>very</strong> efficient, it is not necessarily the <strong>most</strong> efficient.</p> <p>Does anyone know of a way to calculate the most efficient cutting list which can be calculated in a reasonable amount of time?</p> <p>EDIT: Thanks for the answers, I'll continue to use the "greedy" approach as it seems to be doing a very good job (out performs any human attempts to create an efficient cutting list) and is very fast.</p>
<p>This is a classic, difficult problem to solve efficiently. The algorithm you describe sounds like a <a href="http://en.wikipedia.org/wiki/Greedy_algorithm" rel="noreferrer">Greedy Algorithm</a>. Take a look at this Wikipedia article for more information: <a href="http://en.wikipedia.org/wiki/Cutting_stock_problem" rel="noreferrer">The Cutting Stock Problem</a></p>
<p>The <a href="https://en.wikipedia.org/wiki/Column_generation" rel="nofollow noreferrer">Column generation algorithm</a> will quickly find a solution with the minimum possible waste.</p> <p>To summarize, it works well because it doesn't generate all possible combinations of cuts that can fit on a raw material length. Instead, it iteratively solves for combinations that would improve the overall solution, until it reaches an optimum solution.</p> <p>If anyone needs a working version of this, I've implemented it with python and posted it on GitHub: <a href="https://github.com/sweiss93/LengthNestPro/releases/latest" rel="nofollow noreferrer">LengthNestPro</a></p>
4,214
<p>Issue: Printing is not continuous.</p> <p>Observation: While printing, the upper layer of the nozzle is leaking. And also the printing is not continuous, the layers are not formed properly.</p> <p>Practices: Alternate nozzle has been fastened, Bed leveling has been checked, Even used the other softwares to print. Reset-failsafe is also done.</p> <p>Conclusion: Feeding of filament from the extruder motor is continuous but the printing is not smooth.</p> <p>Attachment: The pictures and <a href="https://youtu.be/Zwp45vp5AxQ" rel="nofollow noreferrer">videos</a> (working) are attached.</p> <p><img src="https://i.imgur.com/AK87Y2ab.jpg" alt="Picture of the actual print"></p> <p>Which should be a print of the following image of the model:</p> <p><img src="https://i.stack.imgur.com/WXBFdb.jpg" alt="Picture of model"></p> <p>Certainly I have made certain observations along with your suggested queries. I have listed them please comment.</p> <ol> <li><p>The brand which I'm using is the TEVO TORNADO. </p></li> <li><p>The material is PLA. </p></li> <li><p>The temperatures are 60-65C (BED) and 210-215C (EXT) </p></li> <li><p>The software I used is REPETIER. </p></li> <li><p>The extruder stepper motor works fine (No clicks) (The teeths are clean) </p></li> <li><p>This is the nozzle leak <a href="https://ibb.co/c6gf2p" rel="nofollow noreferrer"><img src="https://preview.ibb.co/hVk7hp/IMG_20180829_094755.jpg" alt="Nozzle Leak"></a></p></li> </ol>
<p>Grinding is due to attempts to advance filament faster than it can be melted and dispensed. Try one or more of the following:</p> <ul> <li>Raise the head temperature (to meet current throughput demand)</li> <li>Lower the print speed (to reduce throughput demand)</li> <li>Slice for thinner layers (to reduce throughput demand)</li> </ul>
<p>A 0.27 mm layer height is not correct for any printer, any nozzle/hotend, any file, and should never be used as a layer height variable for any FDM printer.</p> <p>Layer height should be a factor of the diameter of your nozzle size. i.e. Your nozzle is 0.4 mm, so depending on your printer, your range of resolutions/layer heights could start as low as 0.04 mm, but is monumentally more likely to begin at 0.08 or 0.12 mm, with a maximum value being 0.28 mm, and maybe 0.32 mm if you're doing some risky/experimental spiralized vase printing.</p>
1,016
<p>I'm using IdeaMaker for slicing my print objects. IdeaMaker start strings have a >T0&lt; standing alone on one line and then >T1&lt; on the next line. What does this accomplish?</p>
<p>T stands for <a href="https://en.wikipedia.org/wiki/G-code#Letter_addresses" rel="nofollow noreferrer">"Tool"</a> and has its origin in the origins of <a href="https://en.wikipedia.org/wiki/G-code#Letter_addresses" rel="nofollow noreferrer"><code>.gcode</code></a> being for other automated machine controls. Depending on the machine, everything could be a tool for <code>.gcode</code>, like an actuator or pump or a spindle motor or a drill.</p> <p>In 3D printers, the T-controlled tool is usually the <strong>extruder motor</strong>. Convention has it that the indexing always starts at 0, so T0 and T1 are your first and second Extruder respectively. It is the way to choose which tool is used. </p> <p>As a side note: E is not originally intended for extruders but for the feed rate of lathes.</p>
<p>I'm not sure what it's doing in your case, but the "T" code is there to select the extruder number. T0 would be the first and T1 would be the second extruder in a multi-extruder setup. I found the information at the end of <a href="http://www.makeit-3d.com/wp-content/uploads/RepRapGcodeCheatSheet.pdf" rel="nofollow noreferrer">this cheat sheet</a>. </p>
1,246
<p>There are many SCM systems out there. Some open, some closed, some free, some quite expensive. Which one <em>(please choose only one)</em> would you use for a 3000+ developer organization with several sites (some behind a very slow link)? Explain why you chose the one you chose. (Give some reasons, not just "because".)</p>
<ul> <li>For such a huge installation, there are at least the following major requirements: <strong>Data safety</strong>, maturity, robustness, <strong>Scalability</strong>, <strong>price</strong> (a per seat licence vs. open source always makes a huge difference regardless of the price per seat), ease of administration</li> <li>I would think that <strong>subversion</strong> would be just fine.</li> <li>There is <strong>support</strong> available (from <a href="http://www.open.collab.net/products/subversion/" rel="nofollow noreferrer">collabnet</a>, <a href="http://www.clearvision-cm.com/consulting.html" rel="nofollow noreferrer">clearvision</a>, <a href="http://wandisco.com/php/subversion_support.php" rel="nofollow noreferrer">wandisco</a> and others). You could ask them if subversion would be able to handle your task.</li> <li>subversion has a very mature database backend - FSFS. It is absolutely rock solid and since 1.5 it can handle really many revisions without performance degradation. The revisions are written in a file system. So the reliability of your subversion repository depends on the quality of your file system, os and storage system.</li> <li>This is why I would recommend <strong>Solaris 10 with ZFS</strong> as the file system. ZFS has really great file system features for production systems. But above all it provides data integrity checksumming. So with this amount of source code in the subversion repository you won't have to worry about repository corruption because of a silent hard drive bit error or controller or cable bit error. By now ZFS is mature enough that it can be safely used as a UFS or whatever replacement.</li> <li>I don't know about the hardware requirements. Maybe Collabnet could give you advice.</li> <li>But a really good start (which could be used as NFS storage or backup storage if it turns out to be too slow - you will definitely be able to make good use of it anyway) would be a 2nd generation <a href="http://www.sun.com/servers/x64/x4540/" rel="nofollow noreferrer">thumper</a>, i.e <strong>Sun Fire X4540 Server</strong>: You can have (all within a nice 4U Rack Server for 80.000$ (list price - this will be likely negotiable)): 48 TB Disk space!, 8 AMD Opteron CPU cores, 64 GB RAM, Solaris 10 preinstalled, 3 year Platinum software and hardware support from sun. So the mere hardware and support price for this server would be 25$ per seat of your 3000 Developers.</li> <li>To assure really great data safety, you could partition the 48 hard drives as follows: 3 drives for the operating system (3-way Raid-1 mirror), 3 hot spares (not used, on stand-by in the case of a failure of the other drives), a zfs pool of 14 3-way Raid 1 mirrors (14*3=42 drives) for the subversion repository. If you would like to fill the 14 TB ZFS Raid space only by 80% then this would be approximately 10 Tebibyte of real usable disk space for the repository, i.e. an average of 3 GB per developer.</li> <li><strong><em>With this configuration: Subversion 1.6 on a Sun x4540 thumper with 10 TiB 3-way Raid-1 ZFS redundant and checksummed disk space this should be a really serious start.</em></strong></li> <li>If the compute power isn't enough for 3000+ developers than you could buy a beefier server which could use the disk space of the thumper. If the disk performance is too slow you could hook up a huge array of fast scsi drives to the compute server and use the thumper as a backup solution.</li> <li>Certainly, it would make sense to get consulting services from collabnet regarding the planning and deployment of this subversion server and to get platinum support for the hardware and solaris operating system from sun.</li> <li>Edit (answer to comment #1): For <strong>distributed teams there is the possibility of a master-slave configuration</strong>: <a href="http://svn.apache.org/repos/asf/subversion/trunk/notes/http-and-webdav/webdav-proxy/" rel="nofollow noreferrer">WebDAV-Proxy</a>. Each local team has a slave server, which replicates the repository. The developers get all checkouts from this slave. The checkins are forwarded transparently from the slave to the master. In this way, the master is always current. The vast majority of traffic is checkouts: Every developer gets every checkin any developer commits. So the checkout traffic should be 99.97% of the traffic with 3000 developers. If you have a local team with 50 developers, the checkout traffic would be reduced by 98%. The checkins shouldn't be a problem: how fast can anybody type new code? Obviously, for a small team you won't buy a thumper. You just need a box with enough hard drive space (i.e. if you intend to hold the hole repository 10TB). It can be a raid5 configuration as data loss isn't the end of the company. You won't need Solaris either. You could put linux on it if the local people would be more comfortable with it. Again: ask a consultant like collabnet if this is really a sound concept. With this many seats it shouldn't be a problem to pay for a one time consultation. They can set up the whole thing. Sun delivers the box with solaris pre-installed. You have sun support. So you won't need a solaris guru on site, as the configuration shouldn't change for the next years. This configuration means that <ul> <li>the slow line from the team to the headquarter won't be clogged with redundant checkout data and</li> <li>the members of the local team can get their checkouts quickly</li> <li>it would dramatically reduce the load at the thumper - this means with that configuration you shouldn't have to worry at all whether the thumper is capable of handling the load </li> <li>it reduces the bandwidth costs</li> </ul></li> <li>Edit (after the release of the M3000): A <strong>much more extreme hardware configuration targeted even more towards insane data integrity</strong> would be the combination of a <a href="http://www.sun.com/m3000" rel="nofollow noreferrer">M3000</a> server and a <a href="http://www.sun.com/J4500" rel="nofollow noreferrer">J4500</a> array: <ul> <li>the J4500 Storage Array is practically a thumper, but without the CPU-power and external storage interfaces which enables it to be connected to a server. </li> <li>The M3000 Server is a Sparc64 server at a midrange price with high end RAS features. Most data paths and even cpu registers are checksummed, etc. The RAM is not only ECC protected but has the equivalent of the IBM Chipkill feature: It's raid on memory: not only single bit errors are detected and corrected, but entire memory chips may fail completely while no data is lost - similar to failing hard drives in raid arrays.</li> <li>As the ZFS file system does CPU-based error checksumming on the data before it comes from, or after it goes to the CPU, the quality of the storage controller and cabling of the J4500 is not important. What matters are the bit error prevention and detection capabilities of the M3000 CPU, Memory, memory controller, etc.</li> <li>Unfortuntely, the high quality memory sticks sun is using to improve the quality even more are that much expensive that the combination of the four core (eight threads) 4GB Ram M3000 + 48 TB J4500 would be roughly equivalent to the thumper, but if you would like to increase the server memory from 4GB to 8, 16 or 32 GB for in-memory caching purposes, the price goes up steeply. But maybe a 4GB configuration would even be enough if the master-slave configuration for distributed teams is used.</li> <li>This hardware combination would be worth a thought if the source code and data integrity of this 3000 developer repository is valued extremely highly by the management. Then it would also make sense to add two or more thumpers as a rotating backup solution (not neccessary to protect against hardware failure, but to protect against administrator mistakes or for off-site backups in case of physical desasters).</li> <li>As this would be a Sparc and not a x86 solution, there are certified <a href="http://www.collab.net/downloads/subversion/solaris.html" rel="nofollow noreferrer">Collabnet Subversion binaries</a> for this platform available freely.</li> </ul></li> <li>One of the advantages of subversion is also the excellent documentation: There is an excellent book from <a href="http://oreilly.com/catalog/9780596510336/" rel="nofollow noreferrer">O'Reilly</a> (<a href="http://svnbook.red-bean.com/" rel="nofollow noreferrer">Version Control with Subversion</a>) also available for free as a <a href="http://svnbook.red-bean.com/nightly/en/svn-book.pdf" rel="nofollow noreferrer">PDF</a> or <a href="http://svnbook.red-bean.com/nightly/en/index.html" rel="nofollow noreferrer">HTML</a> version.</li> <li>To sum it up: With the combination Subversion 1.6 + Solaris 10 + 3-way-raid-1 redundant and checksummed ZFS + thumper + master-slave server replication for local teams + sun support + collabnet/clearvision/orcaware/Karl Vogel consultation + excellent and free subversion manual for all developers you should have a solution which provides <ul> <li><strong>Extremely High Data Safety</strong> (very important for so much source code - you do not want to corrupt your repository, bit errors do happen, hard drives do fail!) You have one master data repository which holds all your versions/revisions really reliably: The main feature of source control systems.</li> <li><strong>Maturity</strong> - Subversion has been used by many, many companies and open source projects.</li> <li><strong>Scalability</strong> - With the master-slave replication you should not have a load problem on the master server: The load of the checkins are negligible. The checkouts are handled by the slaves.</li> <li><strong>No High Latency for local teams behind slow connections</strong> (because of the replication)</li> <li><strong>A low price:</strong> subversion is free (no per seat fee), excellent free documentation, over a three year period only 8$ per seat per year hardware and support costs for the master server, cheap linux boxes for slaves, one-time consultancy from collabnet et. al., low bandwidth costs because of master-slave-replication.</li> <li><strong>Ease of administration:</strong> Essentially no administration of the master server: The subversion consultant can deploy everything. Sun staff will swap faulty hard drives, etc. Slaves can be linux boxes or whatever administration skills are available at the local sites. Excellent subversion documentation.</li> </ul></li> </ul>
<p>If they're all working on the same product, probably Perforce.</p> <p>If there are lots of smaller projects (2 to 50), I'd run several Subversion (SVN) boxes.</p>
9,119
<h3>Background</h3> <p>Last year, I did an internship in a physics research group at a university. In this group, we mostly used <a href="http://en.wikipedia.org/wiki/LabVIEW" rel="noreferrer">LabVIEW</a> to write programs for controlling our setups, doing data acquisition and analyzing our data. For the first two purposes, that works quite OK, but for data analysis, it's a real pain. On top of that, everyone was mostly self-taught, so code that was written was generally quite a mess (no wonder that every PhD quickly decided to rewrite everything from scratch). Version control was unknown, and impossible to set up because of strict software and network regulations from the IT department.</p> <p>Now, things actually worked out surprisingly OK, but how do people in the natural sciences do their software development?</p> <h3>Questions</h3> <p>Some concrete questions:</p> <ul> <li>What languages/environments have you used for developing scientific software, especially data analysis? What libraries? (for example, what do you use for plotting?)</li> <li>Was there any training for people without any significant background in programming?</li> <li>Did you have anything like version control, and bug tracking?</li> <li>How would you go about trying to create a decent environment for programming, without getting too much in the way of the individual scientists (especially physicists are stubborn people!)</li> </ul> <h3>Summary of answers thus far</h3> <p>The answers (or my interpretation of them) thus far: (2008-10-11)</p> <ul> <li>Languages/packages that seem to be the most widely used: <ul> <li>LabVIEW</li> <li><a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29" rel="noreferrer">Python</a> <ul> <li>with <a href="http://en.wikipedia.org/wiki/SciPy" rel="noreferrer">SciPy</a>, <a href="http://en.wikipedia.org/wiki/NumPy" rel="noreferrer">NumPy</a>, <a href="http://www.scipy.org/PyLab" rel="noreferrer">PyLab</a>, etc. (See also Brandon's reply for downloads and links)</li> </ul></li> <li>C/C++</li> <li><a href="http://en.wikipedia.org/wiki/MATLAB" rel="noreferrer">MATLAB</a></li> </ul></li> <li>Version control is used by nearly all respondents; bug tracking and other processes are much less common.</li> <li>The Software Carpentry course is a good way to teach programming and development techniques to scientists.</li> <li>How to improve things? <ul> <li>Don't force people to follow strict protocols.</li> <li>Set up an environment yourself, and show the benefits to others. Help them to start working with version control, bug tracking, etc. themselves.</li> <li>Reviewing other people's code can help, but be aware that not everyone may appreciate that.</li> </ul></li> </ul>
<p>The course <a href="http://www.swc.scipy.org/" rel="noreferrer">Software Carpentry</a> is aimed specifically at people doing scientific computing and aims to teach the basics and lessons of software engineering, and how best to apply them to projects.</p> <p>It covers topics like version control, debugging, testing, scripting and various other issues.</p> <p>I've listened to about 8 or 9 of the lectures and think it is to be highly recommended.</p> <p><strong>Edit:</strong> The MP3s of the lectures are <a href="http://www.osl.iu.edu/~lums/swc/index.html" rel="noreferrer">available</a> as well.</p>
<p>I'm no expert in this area, but I've always understood that this is what <a href="http://en.wikipedia.org/wiki/MATLAB" rel="nofollow noreferrer">MATLAB</a> was created for. There is <a href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11596&amp;objectType=file" rel="nofollow noreferrer">a way to integrate MATLAB with SVN for source control</a> as well.</p>
5,915
<p>How do I make one? I am kind of a newbie in Windows API. Is there some sort of manual for this sort of thing? I am specifically interested in a Core API. Thank you for any help.</p>
<p>There are three ways of doing scroll bars: A window's scroll bar; a scroll bar control; or a custom control.</p> <p>Windows have scroll bars in the non-client (NC) area. These are part of the window frame, and as such they do not have their own window handle or anything.</p> <p>Scroll bar controls are child window implementations of a scroll bar. Because they are child windows, they offer you a bit more flexibility. You could subclass or superclass one of these controls to implement "infinite" functionality.</p> <p>The final option is a custom control: you just create your own scroll bar from scratch. Create a single child window, draw it yourself, handle all the mouse and keyboard input yourself, and implement the scroll bar messages yourself. This isn't actually as hard as it may sound.</p> <p>I'd probably recommend <a href="http://msdn.microsoft.com/en-us/library/ms633569.aspx" rel="nofollow noreferrer">superclassing</a> a scroll bar control. Process the scroll messages in your own scroll bar wndproc, and fall back to the standard scroll bar wndproc for painting and such.</p>
<p>What do you mean with "infinite"?</p> <p>If you mean a scroll bar where the user can never scroll to the ends, you have to handle the scroll bar's position change notifications and reset the position to the middle.</p>
9,735
<p>I was printing an object and it started to drag so I stopped it.</p> <p>Went to move the Z-axis up so I could clear the bed and Z-axis would not budge. I switched the printer off and manually turned the motors to get the Z up. Cleared the bed, switched on and homed the printer. When it came to home the Z, BLTouch deployed and then nothing. Motors will not turn.</p> <p>Things I tried:</p> <ul> <li>Recompiled the firmware (Marlin 2.0.x)</li> <li>Different motors - Motors were free from the printer, just resting on a desk so I know it's not binding or anything.</li> <li>Swapped stepper driver with a known working one.</li> </ul> <p>Info about the printer:</p> <ul> <li>CR10s</li> <li>SKR1.4 Turbo board</li> <li>TMC2208 Steppers</li> <li>BLTouch</li> <li>Octopi to control the printer.</li> </ul> <p>Output of <code>M122</code> for the Z:</p> <pre><code>Recv: Z Recv: Address Recv: Enabled false Recv: Set current 1000 Recv: RMS current 994 Recv: MAX current 1402 Recv: Run current 17/31 Recv: Hold current 8/31 Recv: CS actual 8/31 Recv: PWM scale Recv: vsense 0=.325 Recv: stealthChop true Recv: msteps 16 Recv: tstep max Recv: PWM thresh. 0 Recv: [mm/s] - Recv: OT prewarn false Recv: triggered Recv: OTP false Recv: pwm scale sum 10 Recv: pwm scale auto 0 Recv: pwm offset auto 36 Recv: pwm grad auto 14 Recv: off time 4 Recv: blank time 24 Recv: hysteresis Recv: -end 2 Recv: -start 1 Recv: Stallguard thrs Recv: uStep count 40 Recv: DRVSTATUS Z Recv: sg_result Recv: stst Recv: olb Recv: ola Recv: s2gb Recv: s2ga Recv: otpw Recv: to Recv: 157C Recv: 150C Recv: 143C Recv: 120C Recv: s2vsa Recv: s2vsb Recv: Driver registers: Recv: Z 0xC0:08:00:00 Recv: Recv: Recv: Testing Z connection... OK </code></pre>
<p>extruder clicking means you're getting backed up, grinding.</p> <ul> <li>Make the hotend hotter so you can melt filament 3X faster than expected; most materials have quite a range; aim high.</li> <li>Slow down the cooling fan; a lot of them can cool the hotend.</li> <li>You have a silicone boot on the nozzle? that will help some.</li> <li>Use a larger diameter nozzle to reduce backpressure and allow thicker layers.</li> <li>Try cranking the feed rate</li> </ul> <p>Lastly, consider that you simply might not get acceptable results pushing speed THAT much.</p>
<p>Changing &quot;Flow&quot; will affect whole print. So even if it helped for the middle part (I doubt), the next it would ruin the print on sides by overextrusion. However: <strong>if sides are printed ok, then why the middle couldn't?</strong> Because walls are printed slower? Indeed, the under-extrusion may quickly rise along with speed because of plastic deformation between extruder gears under pressure and slight slipping, which actually increases with speed. The video &quot;<a href="https://youtu.be/0xRtypDjNvI?t=301" rel="nofollow noreferrer">How fast can your hotend print?</a>&quot; presents experiment on this phenomena and its outcomes.</p> <p>Then we go into master question: <strong>300% of what?</strong> Turning the speed knob during print will override all considerations that slicer took into account during calculations - and defintely override <a href="https://help.prusa3d.com/en/article/max-volumetric-speed_127176" rel="nofollow noreferrer">Max volumetric speed</a>, which is key factor to limit <strong>pressure in the nozzle</strong> (vide clicking noise).</p> <p>The real limit seems to be this middle part of print, and outer part is just cosmetics (probably calculated to print slower because of quality). So if you ensure, that printing these middle surfaces is <strong>planned (in G-Code) with similar speed</strong> as walls, then (at least in theory) you may be able to increase overall speed, playing e.g. only with temperature. (I actually mean the speed of extrusion, so this may not be simple as just setting equal speed for perimeters and infill, but this does not change the conclusion below.)</p> <p>So I say <strong>all it starts in the slicer</strong> software: increase speed there and re-caclulate. This will ensure to not exceed key limitations. Then you may manipulate maximal values in slicer for further experimentation.</p>
1,841
<p>I'm not too sure what is going on here, but sometimes a particular file in my repository will change the case of its name. e.g.,:</p> <p>before: <code>File.h</code></p> <p>after: <code>file.h</code></p> <p>I don't really care why this is happening, but this causes git to think it is a new file, and then I have to go and change the file name back. Can you just make git ignore case changes?</p> <p><strong>[edit]</strong> I suspect it is Visual Studio doing something weird with that particular file, because it seems to happen most often when I open and save it after changes. I don't have any way to fix bugs in VS however, but git should be a bit more capable I hope.</p>
<p>Since version 1.5.6 there is an <code>ignorecase</code> option available in the <code>[core]</code> section of <code>.git/config</code></p> <p>e.g. add <code>ignorecase = true</code></p> <p>To change it for just one repo, from that folder run:</p> <pre><code>git config core.ignorecase true </code></pre> <p>To change it globally: </p> <pre><code>git config --global core.ignorecase true </code></pre>
<ol> <li>From the console: git config core.ignorecase true</li> <li>Change file name capitalisation</li> <li>Commit</li> <li>From the console: git config core.ignorecase false</li> </ol> <p>Step 4 fixed problems checking out branches with a different capitalisation.</p>
7,629
<p>I have an ASP.NET webservice with along the lines of:</p> <pre><code>[WebService(Namespace = "http://internalservice.net/messageprocessing")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class ProvisioningService : WebService { [WebMethod] public XmlDocument ProcessMessage(XmlDocument message) { // ... do stuff } } </code></pre> <p>I am calling the web service from ASP using something like:</p> <pre><code>provWSDL = "http://servername:12011/MessageProcessor.asmx?wsdl" Set service = CreateObject("MSSOAP.SoapClient30") service.ClientProperty("ServerHTTPRequest") = True Call service.MSSoapInit(provWSDL) xmlMessage = "&lt;request&gt;&lt;task&gt;....various xml&lt;/task&gt;&lt;/request&gt;" result = service.ProcessMessage(xmlMessage) </code></pre> <p>The problem I am encountering is that when the XML reaches the ProcessMessage method, the web service plumbing has added a default namespace along the way. i.e. if I set a breakpoint inside ProcessMessage(XmlDocument message) I see:</p> <pre><code>&lt;request xmlns="http://internalservice.net/messageprocessing"&gt; &lt;task&gt;....various xml&lt;/task&gt; &lt;/request&gt; </code></pre> <p>When I capture packets on the wire I can see that the XML sent by the SOAP toolkit is slightly different from that sent by the .NET WS client. The SOAP toolkit sends:</p> <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;SOAP-ENV:Body&gt; &lt;ProcessMessage xmlns="http://internalservice.net/messageprocessing"&gt; &lt;message xmlns:SOAPSDK4="http://internalservice.net/messageprocessing"&gt; &lt;request&gt; &lt;task&gt;...stuff to do&lt;/task&gt; &lt;/request&gt; &lt;/message&gt; &lt;/ProcessMessage&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>Whilst the .NET client sends:</p> <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;soap:Body&gt; &lt;ProcessMessage xmlns="http://internalservice.net/messageprocessing"&gt; &lt;message&gt; &lt;request xmlns=""&gt; &lt;task&gt;...stuff to do&lt;/task&gt; &lt;/request&gt; &lt;/message&gt; &lt;/ProcessMessage&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>It's been so long since I used the ASP/SOAP toolkit to call into .NET webservices, I can't remember all the clever tricks/SOAP-fu I used to pull to get around stuff like this.</p> <p>Any ideas? One solution is to knock up a COM callable .NET proxy that takes the XML as a string param and calls the WS on my behalf, but it's an extra layer of complexity/work I hoped not to do.</p>
<p>I solved this:</p> <p>The SOAP client <em>request</em> node was picking up the default namespace from:</p> <pre><code>&lt;ProcessMessage xmlns="http://internalservice.net/messageprocessing"&gt; </code></pre> <p>Adding an empty default namespace to the XML sent by the ASP client overrides this behaviour:</p> <pre><code>xmlMessage = "&lt;request xmlns=''&gt;&lt;task&gt;....various xml&lt;/task&gt;&lt;/request&gt;" </code></pre>
<p>I take it you have access to the Services code, not just the consuming client right?</p> <p>Just pull the namespace out of the XmlDocument as the first part of the method.</p> <p>Something like:</p> <pre><code>XmlDocument changeDocumentNamespace(XmlDocument doc, string newNamespace) { if (doc.DocumentElement.NamespaceURI.Length &gt; 0) { doc.DocumentElement.SetAttribute("xmlns", newNameSpace); XmlDocument newDoc = new XmlDocument(); newDoc.LoadXml(doc.OuterXml); return newDoc; } else { return doc; } } </code></pre> <p>Then:</p> <pre><code>[WebService(Namespace = "http://internalservice.net/messageprocessing")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class ProvisioningService : WebService { [WebMethod] public XmlDocument ProcessMessage(XmlDocument message) { message = changeDocumentNamespace(message,String.Empty); // Do Stuff... } } </code></pre>
3,975
<p>Also, how do <code>LEFT OUTER JOIN</code>, <code>RIGHT OUTER JOIN</code>, and <code>FULL OUTER JOIN</code> fit in?</p>
<p>Assuming you're joining on columns with no duplicates, which is a very common case:</p> <ul> <li><p>An inner join of A and B gives the result of A intersect B, i.e. the inner part of a <a href="http://en.wikipedia.org/wiki/Venn_diagram" rel="noreferrer">Venn diagram</a> intersection.</p> </li> <li><p>An outer join of A and B gives the results of A union B, i.e. the outer parts of a <a href="http://en.wikipedia.org/wiki/Venn_diagram" rel="noreferrer">Venn diagram</a> union.</p> </li> </ul> <p><strong>Examples</strong></p> <p>Suppose you have two tables, with a single column each, and data as follows:</p> <pre><code>A B - - 1 3 2 4 3 5 4 6 </code></pre> <p>Note that (1,2) are unique to A, (3,4) are common, and (5,6) are unique to B.</p> <p><strong>Inner join</strong></p> <p>An inner join using either of the equivalent queries gives the intersection of the two tables, i.e. the two rows they have in common.</p> <pre><code>select * from a INNER JOIN b on a.a = b.b; select a.*, b.* from a,b where a.a = b.b; a | b --+-- 3 | 3 4 | 4 </code></pre> <p><strong>Left outer join</strong></p> <p>A left outer join will give all rows in A, plus any common rows in B.</p> <pre><code>select * from a LEFT OUTER JOIN b on a.a = b.b; select a.*, b.* from a,b where a.a = b.b(+); a | b --+----- 1 | null 2 | null 3 | 3 4 | 4 </code></pre> <p><strong>Right outer join</strong></p> <p>A right outer join will give all rows in B, plus any common rows in A.</p> <pre><code>select * from a RIGHT OUTER JOIN b on a.a = b.b; select a.*, b.* from a,b where a.a(+) = b.b; a | b -----+---- 3 | 3 4 | 4 null | 5 null | 6 </code></pre> <p><strong>Full outer join</strong></p> <p>A full outer join will give you the union of A and B, i.e. all the rows in A and all the rows in B. If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.</p> <pre><code>select * from a FULL OUTER JOIN b on a.a = b.b; a | b -----+----- 1 | null 2 | null 3 | 3 4 | 4 null | 6 null | 5 </code></pre>
<p><strong>in Inner join</strong>, We can retrieve the data where we have the same/related data in different tables</p> <p>SELECT Sname, Tname FROM student s JOIN teacher t ON s.id = t.id;</p> <p>if you also want to get other data information from a different table in that case, we can go for outer join</p> <p>we have 3 types of outer join:</p> <p><strong>LEFT JOIN, RIGHT JOIN, and FULL JOIN</strong></p> <p>We will also retrieve the unrelated data from the left (the first) table for the <strong>LEFT OUTER JOIN.</strong></p> <p>SELECT Sname, Tname FROM student s LEFT JOIN teacher t ON s.id = t.id;</p> <p>The <strong>RIGHT OUTER JOIN</strong>, we also retrieve the unrelated data from the right table (the second table)</p> <p>SELECT Sname, Tname FROM student s RIGHT JOIN teacher t ON s.id = t.id;</p> <p>We can use the <strong>FULL OUTER JOIN</strong> when we want to retrieve all/complete data from both tables and the missing data will be filled in with NULL.</p> <p>SELECT Sname, Tname FROM student s FULL JOIN teacher t ON s.id = t.id;</p>
5,943
<p>The following code doesn't compile with gcc, but does with Visual Studio:</p> <pre><code>template &lt;typename T&gt; class A { public: T foo; }; template &lt;typename T&gt; class B: public A &lt;T&gt; { public: void bar() { cout &lt;&lt; foo &lt;&lt; endl; } }; </code></pre> <p>I get the error:</p> <blockquote> <p>test.cpp: In member function ‘void B::bar()’:</p> <p>test.cpp:11: error: ‘foo’ was not declared in this scope</p> </blockquote> <p>But it should be! If I change <code>bar</code> to</p> <pre><code>void bar() { cout &lt;&lt; this-&gt;foo &lt;&lt; endl; } </code></pre> <p>then it <em>does</em> compile, but I don't think I have to do this. Is there something in the official specs of C++ that GCC is following here, or is it just a quirk?</p>
<p>This changed in <a href="http://gcc.gnu.org/gcc-3.4/changes.html#cplusplus" rel="noreferrer">gcc-3.4</a>. The C++ parser got much more strict in that release -- per the spec but still kinda annoying for people with legacy or multi-platform code bases.</p>
<p>VC doesn't implemented two-phase lookup, while GCC does. So GCC parses templates before they are instantiated and thus finds more errors than VC. In your example, foo is a dependent name, since it depends on 'T'. Unless you tell the compiler where it comes from, it cannot check the validity of the template at all, before you instantiate it. That's why you have to tell the compiler where it comes from. </p>
3,254
<p>Is there a commercially available fume and nano particle extractor for a 3D printer, like the Ultimaker3 extended? I'm looking for a safe solution, to use at home, for around $800. </p>
<p>Following on from Harvey Lim's <a href="https://3dprinting.stackexchange.com/questions/3771/commercially-available-3d-printer-fume-and-ufp-extractor#answer-3977">answer</a>, to give a concrete example of a DIY filter, which uses active carbon, see <a href="https://web.archive.org/web/20200514160332/http://www.3dprintfilemarket.com/140629194058.html" rel="nofollow noreferrer">ABS 3d Printer Nanoparticle and Chemical Exhaust Air Filter</a>:</p> <blockquote> <p>###Description Enclose your 3d printer and use this exhaust air filter along with a recirculating air filter to eliminate nanoparticles and chemical fumes. 95 to 99.5% of partilces up to 0.1 micron in size are filtered before air is exhausted into your 3d printing room. This is 3 times better than HEPA filtration. Chemical fumes such as phenols, hydrogen bromide, hydrogen cyanide, and styrene are also filtered out. The amount of chemicals filtered out depends on the amount of carbon filtration media you put into the unit and the strength of the fan you install on the unit. If you are using this for business purposes, you'll have to experiment a bit to have it pass inspection. If you are using it for personal purposes, know that the human nose is extremely sensitive. People who have the gene for hydrogen cyanide detection can smell it down to a concentration of 2 to 10 ppm. Suffice it to say, that if you can smell no evil, you are probably not experiencing evil. This has totally cleared my 3d printing room of nasty fumes. I invite you to try it out for yourself as the cost is very low since I've designed it to use surgical masks and aquarium activated carbon filtration media, which is very affordable. You should change the filtration media and surgical mask every month or 50 hours of printing, whichever comes first. I offer no warranty of any kind as this is an experimental device.</p> </blockquote> <p>This filter is mentioned in <a href="https://3dprinting.stackexchange.com/questions/513/what-are-the-best-air-filtration-options-for-enclosures#answer-539">tbm0115's answer</a> to <a href="https://3dprinting.stackexchange.com/questions/513/what-are-the-best-air-filtration-options-for-enclosures">What are the best air filtration options for enclosures?</a></p>
<p>To try to answer your question, I found these enclosures on <a href="https://www.3dprintclean.com/store-1/" rel="nofollow noreferrer">3DPrintClean</a>, by browsing the Ultimaker forum. I'm not sure it fits your needs since you did not give any details about which Ultimaker you have, nor the amount of money you are willing to spend.</p>
552
<p>A quick glance at the present-day internet would seem to indicate that Adobe Flash is the obvious choice for embedding video in a web page. Is this accurate, or are they other effective choices? Does the choice of ASP.NET as a platform influence this decision?</p>
<p>Flash is certainly the most ubiquitous and portable solution. <a href="http://en.wikipedia.org/wiki/Adobe_Flash#Market_share" rel="noreferrer">98% of browsers</a> have Flash installed. Other alternatives are <a href="http://www.apple.com/quicktime/download/" rel="noreferrer">Quicktime</a>, <a href="http://www.microsoft.com/windows/windowsmedia/default.mspx" rel="noreferrer">Windows Media Player</a>, or even <a href="http://silverlight.net/" rel="noreferrer">Silverlight</a> (Microsoft's Flash competitor, which can be used to embed several video formats).</p> <p>I would recommend using Flash (and it's FLV video file format) for embedding your video unless you have very specific requirements as far as video quality or DRM.</p>
<p>I have worked for a company that developed a system for distributing media content to dedicated "players". It was web based and used ASP.NET technology and have tried almost every possible media format you can think of and your choice really comes down to asking yourself:</p> <p>does it needs to play directly out of the box, or can I make sure that the components required to play the videos can be installed beforehand?</p> <p>If your answer is that it needs to play out of the box then really your only option is flash (I know that it is not installed by default, but most will already have it installed)</p> <p>If it is not a big issue that extra components are needed then you can go with formats that are supported by windows media player</p> <p>The reason why windows media player falls into the second option is because for some browsers and some formats extra components must be installed.</p> <p>We had the luxury that the "players" were provided by us, so we could go for the second option, however even we tried to <a href="http://ffmpeg.mplayerhq.hu/" rel="nofollow noreferrer">convert as much as possible</a> back to flash because it handles way better than windows media player</p>
2,469
<p>I'm trying to install 'quadrupel', a library that relies on ffmpeg on Solaris x86.</p> <p>I managed to build ffmpeg and its libraries live in /opt/gnu/lib and the includes are in /opt/gnu/include but when I try to build quadrupel, it can't find the ffmpeg headers.</p> <p>What flags/configuration is required to include those two directories in the proper search paths for libraries and includes? I'm not much of a Makefile hacker.</p>
<p>I believe you need to add the following to the Makefile:</p> <pre><code>CFLAGS += -I/opt/gnu/include LDFLAGS += -L/opt/gnu/lib -R/opt/gnu/lib </code></pre> <p>The -I argument tell gcc where to find the include files. The -L flag tells ld where to find the libraries while linking. The -R flag writes /opt/gnu/lib into the library search path in the quadrupel binary, so it can find its libraries when it starts.</p>
<p>You can override the path by setting the environmental variable LD_LIBRARY_PATH. However I would suggest changing the system paths as well so you don't have to change the library path for all users. This can be done using crel. </p> <pre><code>crle -l -c /var/ld/ld.config -l /usr/lib:/usr/local/lib:/opt/gnu/lib </code></pre> <p>For the includes just add -I/opt/gnu/include to your CFLAGS variable. </p>
7,020
<p>When <strong>Eclipse</strong> creates a new file (<strong>.c</strong> or <strong>.h</strong> file) in a C project the editor always auto creates a <code>#define</code> at the top of the file like this: If the file is named 'myCFile.c' there will be a <code>#define</code> at the start of the file like this</p> <pre><code>#ifndef MYCFILE_C_ #define MYCFILE_C_ </code></pre> <p>I have seen other editors do this as well (Codewright and SlikEdit I think). The <code>#defines</code> don't seem to do anything for the editor as I can just delete them without any problem, and I can't think of a reason why <em>I</em> would want to use them. Does anyone know why they are there? </p>
<p>It's to guard against <a href="http://www.fredosaurus.com/notes-cpp/preprocessor/ifdef.html" rel="nofollow noreferrer">multiple definitions</a>.</p>
<p>I think it's a throwback of C include issues, where multiple copies of the source would get included - unless you are meticulous with include chains (One file includes n others). Checking if a symbol is defined and including only if the symbol is defined - was a way out of this.</p>
5,845
<p>Assume that I have a field called <em>price</em> for the documents in Solr and I have that field faceted. I want to get the facets as ranges of values (eg: 0-100, 100-500, 500-1000, etc). How to do it?</p> <p>I can specify the ranges beforehand, but I also want to know whether it is possible to calculate the ranges (say for 5 values) automatically based on the values in the documents?</p>
<p>To answer your first question, you can get facet ranges by using the the generic facet query support. <a href="http://wiki.apache.org/solr/SimpleFacetParameters#head-1da3ab3995bc4abcdce8e0f04be7355ba19e9b2c" rel="nofollow noreferrer">Here</a>'s an example:</p> <pre><code>http://localhost:8983/solr/select?q=video&amp;rows=0&amp;facet=true&amp;facet.query=price:[*+TO+500]&amp;facet.query=price:[500+TO+*] </code></pre> <p>As for your second question (automatically suggesting facet ranges), that's not yet implemented. Some argue that this kind of querying would be best implemented on your application rather that letting Solr "guess" the best facet ranges.</p> <p>Here are some discussions on the topic:</p> <ul> <li>(Archived) <a href="https://web.archive.org/web/20100416235126/http://old.nabble.com/Re:-faceted-browsing-p3753053.html" rel="nofollow noreferrer">https://web.archive.org/web/20100416235126/http://old.nabble.com/Re:-faceted-browsing-p3753053.html</a></li> <li>(Archived) <a href="https://web.archive.org/web/20090430160232/http://www.nabble.com/Re:-Sorting-p6803791.html" rel="nofollow noreferrer">https://web.archive.org/web/20090430160232/http://www.nabble.com/Re:-Sorting-p6803791.html</a></li> <li>(Archived) <a href="https://web.archive.org/web/20090504020754/http://www.nabble.com/Dynamically-calculated-range-facet-td11314725.html" rel="nofollow noreferrer">https://web.archive.org/web/20090504020754/http://www.nabble.com/Dynamically-calculated-range-facet-td11314725.html</a></li> </ul>
<p>There may well be a better Solr-specific answer, but I work with straight Lucene, and since you're not getting much traction I'll take a stab. There, I'd create a populate a <code>Filter</code> with a <code>FilteredQuery</code> wrapping the original <code>Query</code>. Then I'd get a <code>FieldCache</code> for the field of interest. Enumerate the hits in the filter's bitset, and for each hit, you get the value of the field from the field cache, and add it to a SortedSet. When you've got all of the hits, divide the size of the set into the number of ranges you want (five to seven is a good number according the user interface guys), and rather than a single-valued constraint, your facets will be a range query with the lower and upper bounds of each of those subsets.</p> <p>I'd recommend using some special-case logic for a small number of values; obviously, if you only have four distinct values, it doesn't make sense to try and make 5 range refinements out of them. Below a certain threshold (say 3*your ideal number of ranges), you just show the facets normally rather than ranges.</p>
5,410
<p>I'm looking for the basic loop like:</p> <pre><code>for(int i = 0; i &lt; MAX; i++) { doSomething(i); } </code></pre> <p>but for Bash.</p>
<p>From <a href="http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html" rel="noreferrer">this site</a>:</p> <pre><code>for i in $(seq 1 10); do echo $i done </code></pre>
<p>I use variations of this all the time to process files...</p> <blockquote> <p>for files in *.log; do echo "Do stuff with: $files"; echo "Do more stuff with: $files"; done;</p> </blockquote> <p>If processing lists of files is what you're interested in, look into the <strong>-execdir</strong> option for <strong>files</strong>.</p>
7,153
<p>Ulimately I just wanted to extract strings from the .rc file so I could translate them, but anything that goes with .rc files works for me.</p>
<p>I'd consider usage of <a href="http://en.wikipedia.org/wiki/Gettext" rel="nofollow">gettext</a> and <a href="http://gnu.cs.pu.edu.tw/software/gettext/manual/html_node/PO-Files.html" rel="nofollow">.PO files</a>, if your program fits GNU license</p> <p>1) I'd suggest extracting from .rc files using state machine algorithm.</p> <pre><code>void ProcessLine(const char * str) { if (strstr(str, " DIALOG")) state = Scan; else if (strstr(str, " MENU")) state = Scan; else if (strstr(str, " STRINGTABLE")) state = Scan; else if (strstr(str, "END")) state = DontScan; if (state == Scan) { const char * cur = sLine; string hdr = ...// for example "# file.rc:453" string msgid; string msgid = ""; while (ExtractString(sLine, cur, msgid)) { if (msgid.empty()) continue; if (IsPredefined(msgid)) continue; if (msgid.find("IDB_") == 0 || msgid.find("IDC_") == 0) continue; WritePoString(hdr, msgid, msgstr); } } } </code></pre> <p>2) When extracting string inside ExtractString() you should consider that char " is represented as "", and there are also chars like \t \n \r. So state machine is also a good option here.</p> <p>The following string:</p> <pre><code>LTEXT "Mother has washed ""Sony"", then \taquarium\\shelves\r\nand probably floors",IDC_TEXT1,24,14,224,19 </code></pre> <p>represents such label on a dialog:</p> <pre><code>Mother has washed "Sony", then aquarium\shelves and probably floors </code></pre> <p>3) Then on program startup you should load .po file via gettext and for each dialog translate its string on startup using a function like this:</p> <pre><code>int TranslateDialog(CWnd&amp; wnd) { int i = 0; CWnd *pChild; CString text; //Translate Title wnd.GetWindowText(text); LPCTSTR translation = Translate(text); window.SetWindowText(translation); //Translate child windows pChild=wnd.GetWindow(GW_CHILD); while(pChild) { i++; Child-&gt;GetWindowText(Text);//including NULL translation = Translate(Text); pChild-&gt;SetWindowText(translation); pChild = pChild-&gt;GetWindow(GW_HWNDNEXT); } return i; } </code></pre>
<p><a href="http://resxcrunch.com" rel="nofollow noreferrer">ResxCrunch</a> will be out sometimes soon. It will edit multiple resource files in multiple languages in one single table.</p>
7,709
<p>I've got quite a few GreaseMonkey scripts that I wrote at my work which automatically log me into the internal sites we have here. I've managed to write a script for nearly each one of these sites except for our time sheet application, which uses HTTP authentication. </p> <p>Is there a way I can use GreaseMonkey to log me into this site automatically?</p> <p>Edit: I am aware of the store password functionality in browsers, but my scripts go a step further by checking if I'm logged into the site when it loads (by traversing HTML) and then submitting a post to the login page. This removes the step of having to load up the site, entering the login page, entering my credentials, then hitting submit</p>
<p>It is possible to log in using HTTP authentication by setting the "Authorization" HTTP header, with the value of this header set to the string "basic username:password", but with the "username:password" portion of the string Base 64 encoded. </p> <p><a href="http://frontier.userland.com/stories/storyReader$2159" rel="nofollow noreferrer">http://frontier.userland.com/stories/storyReader$2159</a></p> <p>A bit of researching found that GreaseMonkey has a a function built into it where you can send GET / POST requests to the server called GM_xmlhttpRequest </p> <p><a href="http://diveintogreasemonkey.org/api/gm_xmlhttprequest.html" rel="nofollow noreferrer">http://diveintogreasemonkey.org/api/gm_xmlhttprequest.html</a></p> <p>So putting it all together (and also getting this JavaScript code to convert strings into base64 I get the following</p> <p><a href="http://www.webtoolkit.info/javascript-base64.html" rel="nofollow noreferrer">http://www.webtoolkit.info/javascript-base64.html</a></p> <pre><code>var loggedInText = document.getElementById('metanav').firstChild.firstChild.innerHTML; if (loggedInText != "logged in as jklp") { var username = 'jklp'; var password = 'jklpPass'; var base64string = Base64.encode(username + ":" + password); GM_xmlhttpRequest({ method: 'GET', url: 'http://foo.com/trac/login', headers: { 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3', 'Accept': 'application/atom+xml,application/xml,text/xml', 'Authorization':'Basic ' + base64string, } }); } </code></pre> <p>So when I now visit the site, it traverses the DOM and if I'm not logged in, it automagically logs me in. </p>
<p>"<a href="http://username:password@host/" rel="nofollow noreferrer">http://username:password@host/</a>" doesn't work on IE, FireFox works ok.</p>
7,160
<p>With the increased power of JavaScript frameworks like YUI, JQuery, and Prototype, and debugging tools like Firebug, doing an application entirely in browser-side JavaScript looks like a great way to make simple applications like puzzle games and specialized calculators.</p> <p>Is there any downside to this other than exposing your source code? How should you handle data storage for this kind of program?</p> <p>Edit: yes, Gears and cookies can be used for local storage, but you can't easily get access to files and other objects the user already has around. You also can't save data to a file for a user without having them invoke some browser feature like printing to PDF or saving page as a file.</p>
<p>I've written several application in JS including a spreadsheet.</p> <p>Upside:</p> <ul> <li>great language</li> <li>short code-run-review cycle</li> <li>DOM manipulation is great for UI design</li> <li>clients on every computer (and phone)</li> </ul> <p>Downside:</p> <ul> <li>differences between browsers (especially IE)</li> <li>code base scalability (with no intrinsic support for namespaces and classes)</li> <li>no good debuggers (especially, again, for IE)</li> <li>performance (even though great progress has been made with FireFox and Safari)</li> <li>You need to write some server code as well.</li> </ul> <p>Bottom line: Go for it. I did.</p>
<p>My RSS feeds have served me well- I found that Javascript roguelike!</p> <p>It's called <a href="http://www.icculus.org/asciiroth/" rel="nofollow noreferrer">The Tombs of Asciiroth</a>.</p>
3,592
<p>Does anyone have a good way to build MSI (vdproj) projects using MsBuild or Nant? </p> <p>I know <a href="http://forums.msdn.microsoft.com/en-US/msbuild/thread/6e213531-9d88-43ef-8262-fe0e4e7f479a/" rel="nofollow noreferrer">one answer</a> was to install Visual Studio on the build server and just use devenv.exe to build the project, but, I prefer not to install Visual Studio on our build servers.</p>
<p>Short of the method you mentioned above (devenv), there is no way to do this with the current version of MSBuild. </p> <p>The method the Visual Studio team uses to run their MSI builds is with <a href="http://wix.sourceforge.net/" rel="noreferrer">Windows Installer XML</a>. You can learn more about using WiX to deploy setup packages <a href="http://msdn.microsoft.com/en-us/magazine/cc163456.aspx" rel="noreferrer">here</a>.</p> <p>Please note WiX doesn't support vdproj files so it means you'll be recreating your installer projects.</p> <p>Edit: Looks like I was beat to the chase when grabbing my references :)</p>
<p>We use <a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">Wix</a> to automate MSI builds for IronPython and IronRuby.</p> <p>EDIT: to clarify, this probably means starting over from scratch when building your installer. While Wix has a mechanism to create a configuration directly from a preexisting MSI file, I've never gotten a satisfactory result from using this tool</p>
4,444
<p>Here's a problem I've been trying to solve at work. I'm not a database expert, so that perhaps this is a bit sophomoric. All apologies.</p> <p>I have a given database D, which has been duplicated on another machine (in a perhaps dubious manner), resulting in database D'. It is my task to check that database D and D' are in fact exactly identical.</p> <p>The problem, of course, is what to actually do if they are not. For this purpose, my thought was to run a symmetric difference on each corresponding table and see the differences.</p> <p>There is a "large" number of tables, so I do not wish to run each symmetric difference by hand. How do I then implement a symmetric difference "function" (or stored procedure, or whatever you'd like) that can run on arbitrary tables without having to explicitly enumerate the columns?</p> <p>This is running on Windows, and your hedge fund will explode if you don't follow through. Good luck.</p>
<p>My first reaction is to suggest duplicating to the other machine again in a non-dubious manner.</p> <p>If that is not an option, perhaps some of the tools available from <a href="http://www.red-gate.com/products/index.htm" rel="nofollow noreferrer">Red Gate</a> could do what you need.</p> <p>(I am in no way affliated with Red Gate, just remember Joel mentioning how good their tools were on the podcast.)</p>
<p>Use the SQL Compare tools by <a href="http://www.red-gate.com/" rel="nofollow noreferrer">Red Gate</a>. It compares scheamas, and the SQL Data Compare tool compares data. I think that you can get a free trial for them, but you might as well buy them if this is a recurring problem. There may be open source or free tools like this, but you might as well just get this one.</p>
9,386
<p>I'm building a PHP page with data sent from MySQL.</p> <p>Is it better to have</p> <ul> <li>1 <code>SELECT</code> query with 4 table joins, or</li> <li>4 small <code>SELECT</code> queries with no table join; I do select from an ID</li> </ul> <p>Which is faster and what is the pro/con of each method? I only need one row from each tables.</p>
<p>You should run a profiling tool if you're truly worried cause it depends on many things and it can vary but as a rule its better to have fewer queries being compiled and fewer round trips to the database.</p> <p>Make sure you filter things as well as you can using your where and join on clauses.</p> <p>But honestly, it usually doesn't matter since you're probably not going to be hit all that hard compared to what the database can do, so unless optimization is your spec you should not do it prematurely and do whats simplest.</p>
<p>Be careful when dealing with a merge table however. It has been my experience that although a single join can be good in most situations, when merge tables are involved you can run into strange situations.</p>
7,926
<p>We want to try Ext JS on new project. Is there any well-known best practice for integrating Ext JS with server side Java (Spring/Hibernate/JS) application? Is DWR a good choice for that?</p>
<p>My team has been using Ext with DWR for almost year a year, and have had nothing but good things to say. If you take this approach, you will end up using DWR's generated JavaScript classes for making your requests to the server. This will often be done in place of using the Ext.Ajax and Ext.data.Connection classes. When you use a class that require an Ext.data.Store (e.g. grip, combo box, etc.) and you want to fetch data from the server, you will need to use a proxy that can link in with DWR. The user-community provided Ext.ux.data.DWRProxy has worked flawlessly for us: <a href="http://extjs.com/forum/showthread.php?t=23884" rel="noreferrer">http://extjs.com/forum/showthread.php?t=23884</a>.</p>
<p>It's perfectly fine to build your application using Ext JS/DWR/Spring/Hibernate.</p>
9,628
<p>I need to empty an LDF file before sending to a colleague. How do I force SQL Server to truncate the log?</p>
<p>In management studio:</p> <ul> <li>Don't do this on a live environment, but to ensure you shrink your dev db as much as you can: <ul> <li>Right-click the database, choose <code>Properties</code>, then <code>Options</code>.</li> <li>Make sure "Recovery model" is set to "Simple", not "Full"</li> <li>Click OK</li> </ul></li> <li>Right-click the database again, choose <code>Tasks</code> -> <code>Shrink</code> -> <code>Files</code></li> <li>Change file type to "Log"</li> <li>Click OK.</li> </ul> <p>Alternatively, the SQL to do it:</p> <pre><code> ALTER DATABASE mydatabase SET RECOVERY SIMPLE DBCC SHRINKFILE (mydatabase_Log, 1) </code></pre> <p>Ref: <a href="http://msdn.microsoft.com/en-us/library/ms189493.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms189493.aspx</a></p>
<p>Another option altogether is to detach the database via Management Studio. Then simply delete the log file, or rename it and delete later. </p> <p>Back in Management Studio attach the database again. In the attach window remove the log file from list of files.</p> <p>The DB attaches and creates a new empty log file. After you check everything is all right, you can delete the renamed log file.</p> <p>You probably ought not use this for production databases.</p>
6,163
<p>How can you determine the performance consequences of your PHP code if you are not familiar with the internals? Are there ways to figure out how your code is being executed (besides simply load testing it)? I am looking for things like memory usage, the execution time for algorithms.</p> <p>Perhaps Joel would say, "learn C, then read the internals", but I really don't have time to learn C right now (though I'd love to, actually). </p>
<p>Use the <a href="http://www.xdebug.org/" rel="nofollow noreferrer">Xdebug</a> extension to profile PHP code.</p>
<p>Even if you are familiar with the internals, you should still load test your assumptions. I like to use the <a href="http://pear.php.net/package/Benchmark" rel="nofollow noreferrer">PEAR Benchmark</a> package to compare different code.</p> <p>If you can isolate your code, you can keep your load testing simple. A typical technique is to run each option some number of times and see which one is faster. For example, if you have a class, you can write a test case and that puts it through it's paces and run it several times.</p>
7,385
<p>Is it possible to call a stored procedure from another stored procedure asynchronously?</p> <p><strong>Edit:</strong> Specifically I'm working with a DB2 database. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>Executive summary: Yes, if your database has a message queue service.</p> <p>You can push a message onto a queue and the queue processor will consume it asynchronously.</p> <ul> <li>Oracle: queues</li> <li>Sql Server: service broker</li> <li>DB2: event broker</li> </ul> <p>For "pure" stored procedure languages (PL/Sql or T-Sql) the answer is no, since it works against the fundamental transaction model most databases have.</p> <p>However, if your database has a queuing mechanism, you can use that to get the same result.</p>
<p>It sounds like you need to put some scheduled jobs in place with Cron (or windows equiv). You could use the initial stored proc call to set some kind of flag in the DB, which is then checked periodically by a cron job. If you need to have a specific delay before the 2nd job executes, you should be able to do that by having the task scheduled by the cron job.</p>
4,510
<p>I am wrapping existing C++ code from a <strong>BSD</strong> project in our own custom wrapper and I want to integrate it to our code with as few changes as possible. This code uses <code>fprintf</code> to print to <strong>stderr</strong> in order to log / report errors.</p> <p>I want to redirect this to an alternative place within the same process. On <strong>Unix</strong> I have done this with a <code>socketpair</code> and a <code>thread</code>: one end of the socket is where I send <strong>stderr</strong> (via a call to <code>dup2</code>) and the other end is monitored in a thread, where I can then process the output.</p> <p>This does not work on <strong>Windows</strong> though because a socket is not the same as a file handle.</p> <p>All documents I have found on the web show how to redirect output from a child process, which is not what I want. How can I redirect <strong>stderr</strong> within the same process getting a callback of some sort when output is written? (and before you say so, I've tried <code>SetStdHandle</code> but cannot find any way to make this work)...</p>
<p>You can use a similar technique on Windows, you just need to use different words for the same concepts. :) This article: <a href="http://msdn.microsoft.com/en-us/library/ms682499.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms682499.aspx</a> uses a win32 pipe to handle I/O from another process, you just have to do the same thing with threads within the same process. Of course, in your case all output to stderr from anywhere in the process will be redirected to your consumer.</p> <p>Actually, other pieces of the puzzle you may need are <a href="http://msdn.microsoft.com/en-us/library/dye30d82(VS.80).aspx" rel="noreferrer">_fdopen</a> and <a href="http://msdn.microsoft.com/en-us/library/bdts1c9x(VS.71).aspx" rel="noreferrer">_open_osfhandle</a>. In fact, here's a related example from some <a href="http://hewgill.com/pilot/copilot/" rel="noreferrer">code</a> I released years ago:</p> <pre><code>DWORD CALLBACK DoDebugThread(void *) { AllocConsole(); SetConsoleTitle("Copilot Debugger"); // The following is a really disgusting hack to make stdin and stdout attach // to the newly created console using the MSVC++ libraries. I hope other // operating systems don't need this kind of kludge.. :) stdout-&gt;_file = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); stdin-&gt;_file = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE), _O_TEXT); debug(); stdout-&gt;_file = -1; stdin-&gt;_file = -1; FreeConsole(); CPU_run(); return 0; } </code></pre> <p>In this case, the main process was a GUI process which doesn't start with stdio handles at all. It opens a console, then shoves the right handles into stdout and stdin so the debug() function (which was designed as a stdio interactive function) can interact with the newly created console. You should be able to open some pipes and do the same sort of thing to redirect stderr.</p>
<p>You mention that you don't want to use a named pipe for internal use; it's probably worth poining out that the documentation for <a href="http://msdn.microsoft.com/en-us/library/aa365152(VS.85).aspx" rel="nofollow noreferrer">CreatePipe()</a> states, <em>"Anonymous pipes are implemented using a named pipe with a unique name. Therefore, you can often pass a handle to an anonymous pipe to a function that requires a handle to a named pipe."</em> So, I suggest that you just write a function that creates a similar pipe with the correct settings for async reading. I tend to use a GUID as a string (generated using <code>CoCreateGUID()</code> and <code>StringFromIID()</code>) to give me a unique name and then create the server and client ends of the named pipe with the correct settings for overlapped I/O (more details on this, and code, here: <a href="http://www.lenholgate.com/blog/2008/02/process-management-using-jobs-on-windows.html" rel="nofollow noreferrer">http://www.lenholgate.com/blog/2008/02/process-management-using-jobs-on-windows.html</a>).</p> <p>Once I have that I wire up some code that I have to read a file using overlapped I/O with an I/O Completion Port and, well, then I just get async notifications of the data as it arrives... However, I've got a fair amount of well tested library code in there that makes it all happen... </p> <p>It's probably possible to set up the named pipe and then just do an overlapped read with an event in your <code>OVERLAPPED</code> structure and check the event to see if data was available... I don't have any code available that does that though.</p>
2,924
<p>What things should be kept most in mind when writing cross-platform applications in C? Targeted platforms: 32-bit Intel based PC, Mac, and Linux. I'm especially looking for the type of versatility that Jungle Disk has in their USB desktop edition ( <a href="http://www.jungledisk.com/desktop/download.aspx" rel="noreferrer">http://www.jungledisk.com/desktop/download.aspx</a> )</p> <p>What are tips and "gotchas" for this type of development?</p>
<p>I maintained for a number of years an ANSI C networking library that was ported to close to 30 different OS's and compilers. The library didn't have any GUI components, which made it easier. We ended up abstracting out into dedicated source files any routine that was not consistent across platforms, and used #defines where appropriate in those source files. This kept the code that was adjusted per platform isolated away from the main business logic of the library. We also made extensive use of typedefs and our own dedicated types so that we could easily change them per platform if needed. This made the port to 64-bit platforms fairly easy.</p> <p>If you are looking to have GUI components, I would suggest looking at GUI toolkits such as WxWindows or Qt (which are both C++ libraries).</p>
<p>Try to write as much as you can with POSIX. Mac and Linux support POSIX natively and Windows has a system that can run it (as far as I know - I've never actually used it). If your app is graphical, both Mac and Linux support X11 libraries (Linux natively, Mac through X11.app) and there are numerous ways of getting X11 apps to run on Windows.</p> <p>However, if you're looking for true multi-platform deployment, you should probably switch to a language like Java or Python that's capable of running the same program on multiple systems with little or no change.</p> <p>Edit: I just downloaded the application and looked at the files. It does appear to have binaries for all 3 platforms in one directory. If your concern is in how to write apps that can be moved from machine to machine without losing settings, you should probably write all your configuration to a file in the same directory as the executable and not touch the Windows registry or create any dot directories in the home folder of the user that's running the program on Linux or Mac. And as far as creating a cross-distribution Linux binary, 32-bit POSIX/X11 would probably be the safest bet. I'm not sure what JungleDisk uses as I'm currently on a Mac.</p>
5,625
<p>Is there a way to bind a MemoryStream to asp:image control?</p>
<p>Best bet is to create an HttpHandler that would return the image. Then bind the ImageUrl property on the asp:Image to the url of the HttpHandler.</p> <p>Here is some code.</p> <p>First create the HttpHandler:</p> <pre><code>&lt;%@ WebHandler Language="C#" Class="ImageHandler" %&gt; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Web; public class ImageHandler : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.Clear(); if (!String.IsNullOrEmpty(context.Request.QueryString["id"])) { int id = Int32.Parse(context.Request.QueryString["id"]); // Now you have the id, do what you want with it, to get the right image // More than likely, just pass it to the method, that builds the image Image image = GetImage(id); // Of course set this to whatever your format is of the image context.Response.ContentType = "image/jpeg"; // Save the image to the OutputStream image.Save(context.Response.OutputStream, ImageFormat.Jpeg); } else { context.Response.ContentType = "text/html"; context.Response.Write("&lt;p&gt;Need a valid id&lt;/p&gt;"); } } public bool IsReusable { get { return false; } } private Image GetImage(int id) { // Not sure how you are building your MemoryStream // Once you have it, you just use the Image class to // create the image from the stream. MemoryStream stream = new MemoryStream(); return Image.FromStream(stream); } } </code></pre> <p>Next, just call it inside your aspx page where you are using the asp:Image.</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:Image ID="myImage" ImageUrl="~/ImageHandler.ashx?id=1" runat="server" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And that is it.</p>
<p>Nope. </p> <p>But you can create a special page to stream that image out. First, you set the URL of the image to the page that performs the streaming, including some url parameters that let you know where to get the image:</p> <pre><code>&lt;img src="GetImage.aspx?filename=foo" ... /&gt; </code></pre> <p>in GetImage.aspx, you get the filename (or whatever) from the URL, load the image in your MemoryStream, and then write the content of that memory stream directly to the HttpResponse:</p> <pre><code> response.Expires = 0; response.Buffer = false; response.Clear(); response.ClearHeaders(); response.ClearContent(); response.ContentType = "image/jpeg"; response.BinaryWrite(stream); response.Flush(); response.Close(); </code></pre>
6,895
<p>I've tried to remix this model: <a href="https://www.thingiverse.com/thing:90933" rel="nofollow noreferrer">https://www.thingiverse.com/thing:90933</a> (Bauhaus chess set) by scaling it down and inserting little magnet holes into the pieces' underside. My SCAD file looks as follows:</p> <pre><code>difference() { scale([0.5,0.5,0.5]) import("Bauhaus2Set.stl"); translate([ 6, 11 ,0]) cylinder(h=20.5,r=2.5,center=true,$fn=20); // WTH? // King/Queen translate([ 6, 11 ,0]) cylinder(h=3.5,r=2.5,center=true,<span class="math-container">$fn=20); translate([-6, 11 ,0]) cylinder(h=3.5,r=2.5,center=true,$</span>fn=20); // Rooks translate([ 6,-11.5,0]) cylinder(h=3.5,r=2.5,center=true,<span class="math-container">$fn=20); translate([-6,-11.5,0]) cylinder(h=3.5,r=2.5,center=true,$</span>fn=20); [...] </code></pre> <p>Note the third line with "WTH?" - I've done quite some trial-and-error, and if I remove that line, then I don't get any subtracted holes anymore when I render the whole thing (F6). In preview (F5), the holes are always present, but in the final render, I need to include the larger subtracted cylinder or it won't work.</p> <p>The STL file seems to be fine in itself, what's going on here?</p>
<p>It is interesting that the WTH line and the next line both should remove a cylinder of the same diameter from the same location. Only the height is different.</p> <p>It could be interesting to remove the first King/Queen line and see if there is a change.</p> <p>Have you checked the STL file with another tool, other than OpenSCAD? There may be a kink in the STL that confuses the geometry engine in OpenSCAD. The first difference could be catching the kink, and the second one carving out the magnet body in the bottom.</p>
<p>It is interesting that the WTH line and the next line both should remove a cylinder of the same diameter from the same location. Only the height is different.</p> <p>It could be interesting to remove the first King/Queen line and see if there is a change.</p> <p>Have you checked the STL file with another tool, other than OpenSCAD? There may be a kink in the STL that confuses the geometry engine in OpenSCAD. The first difference could be catching the kink, and the second one carving out the magnet body in the bottom.</p>
1,440
<p>Some people have figured out how to take raw LiDAR data and after going through multiple steps (using LAS tools, converting to digital elevation model (DEM), converting to an STL) getting an STL file that they can then slice and print.</p> <p>Could you write a program that cuts out all of those intermediate steps and converts raw LiDAR data directly to an STL that can be printed? Could you even cut out the need for slicers and just go straight to a G-code file?</p> <p>Is this even possible?</p> <p>From <a href="https://research.umn.edu/units/uspatial/news/3d-printing-models-derived-lidar-data" rel="nofollow noreferrer">3D Printing Models derived from Lidar Data</a>:</p> <blockquote> <ol> <li>Retrieve Lidar Data</li> <li>Process Lidar Data</li> <li>Create a DSM</li> <li>Export the DSM into a .STL</li> <li>Process for 3D Printing</li> <li>3D Print!</li> </ol> </blockquote>
<p>TL;DR - The problem would <em>appear</em> to be that some of the steps require a bit of manual tinkering in order to complete them successfully - it isn't just a simple question of conversion. So, no (not currently).</p> <p><em>Also, whilst writing this answer, it dawned on me that unless someone has actually managed to automate the whole process already, then your question may merely invite opinions (rather than factual solutions).</em></p> <hr /> <p>From the link that you provided the conversion stages seem to be:</p> <ol> <li>Obtain the <code>LAZ</code> file from LiDAR</li> <li><code>LAZ</code> to <code>LAS</code></li> <li><code>LAS</code> to <code>DSM</code></li> <li><code>DSM</code> to <code>STL</code></li> <li><code>STL</code> to G-code</li> </ol> <p>These stages would need to be put into an automated pipeline.</p> <h3 id="step-1-3t5u">Step 1</h3> <p>This step could be automated.</p> <h3 id="step-2-c1ql">Step 2</h3> <p>The LAZ to LAS seems to be a straightforward conversion using command line tools <code>las2las</code>, <code>lasview</code> and <code>las2dem</code>. This step <em>probably</em> could be automated (assuming that no manual intervention of the settings ​is required), as command line interfaces are easy to script (when compared with a GUI).</p> <h3 id="step-3-bjn5">Step 3</h3> <p>This step uses one of three GUI applications and looks like some manual labour (like adjusting settings) <em>may</em> be required, it is not clear. If the applications suggested by the article have APIs then a CLI option of automating the process could be possible - again it is not clear just by reading the article.</p> <h3 id="step-4-bqet">Step 4</h3> <p>This step again uses a GUI (possibly to employ the export plugin and certainly to visualise the results) and so would appear to need some settings modifications and reiteration, to quote:</p> <blockquote> <p>the conversion settings are something that will have to be explored via trial and error in order to figure out what is right for your dataset. In order to visualize the differences between the different settings you will have to open the .STL file into a software designed for 3D Printing.</p> </blockquote> <h3 id="step-5-pwke">Step 5</h3> <p>While the use of a slicer <em>can</em> be automated (assuming that you have predefined (known parameters) thresholds), it usually requires some manual intervention (at least to begin with). If you google &quot;automate slicing&quot; then some interesting links appear, but usually they are for batch processing of similar objects/models.</p> <h3 id="summary-3bxj">Summary</h3> <p>The language used in the steps above contains a lot of conditionals (may, can, could) because there are a lot of variables involved. A substantial amount of research would be required to get these elements of the pipeline to work together seamlessly. So, it is unlikely that a &quot;point and click&quot; solution exists where an STL file would just pop out at the end, with no manual intervention.</p> <p>That said, if your LiDAR datasets were consistent (i.e. similar environments, similar objects being scanned) then you <em>may</em> be able to find a range of settings, for each stage, that work consistently well for a particular scenario. Then with these settings - in combination with some command line or Python scripting and/or an appropriate GUI scripting tool - you might be able to automate some, if not all, of the process.</p> <p>Looking even further ahead, by using <em>Machine Learning</em> you may be able to train a model to learn to examine the visual feedback stages and then auto-tinker with the settings in order to get better results - however, whilst not in the realms of impossibility, it certainly is rather cutting edge (at this point in time). In a few years time though, it almost certainly will be possible.</p>
<p>The answer is highly depending on the programming skills of the programmer, but in theory, if all pieces of software exist, they can either be tied together in a workflow process (automated) or directly programmed into a new tool.</p>
1,983
<p>I've been using OpenGL extensions on Windows the <a href="https://stackoverflow.com/questions/14413/using-opengl-extensions-on-windows">painful way</a>. Is GLEW the easier way to go? How do I get started with it?</p>
<p>Yes, the <strong>OpenGL Extension Wrangler Library</strong> (GLEW) is a painless way to use OpenGL extensions on Windows. Here's how to get started on it:</p> <p>Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the <a href="http://www.opengl.org/registry/" rel="noreferrer">OpenGL Extension Registry</a>.</p> <p>Check if your graphic card supports the extensions you wish to use. Download and install the latest drivers and SDKs for your graphics card.</p> <p>Recent versions of <a href="http://developer.nvidia.com/object/sdk_home.html" rel="noreferrer">NVIDIA OpenGL SDK</a> ship with GLEW. If you're using this, then you don't need to do some of the following steps.</p> <p>Download <a href="http://glew.sourceforge.net/" rel="noreferrer">GLEW</a> and unzip it.</p> <p>Add the GLEW <strong>bin</strong> path to your Windows <strong>PATH</strong> environment variable. Alternatively, you can also place the <strong>glew32.dll</strong> in a directory where Windows picks up its DLLs.</p> <p>Add the GLEW <strong>include</strong> path to your compiler's include directory list.</p> <p>Add the GLEW <strong>lib</strong> path to your compiler's library directory list.</p> <p>Instruct your compiler to use <strong>glew32.lib</strong> during linking. If you're using Visual C++ compilers then one way to do this is by adding the following line to your code:</p> <pre><code>#pragma comment(lib, "glew32.lib") </code></pre> <p>Add a <code>#include &lt;GL/glew.h&gt;</code> line to your code. Ensure that this is placed above the includes of other GL header files. (You may actually not need the GL header files includes if you include <code>glew.h</code>.)</p> <p>Initialize GLEW using <code>glewInit()</code> after you've initialized GLUT or GL. If it fails, then something is wrong with your setup.</p> <pre><code>if (GLEW_OK != glewInit()) { // GLEW failed! exit(1); } </code></pre> <p>Check if the extension(s) you wish to use are now available through GLEW. You do this by checking a boolean variable named <strong>GLEW<em>_your_extension_name</em></strong> which is exposed by GLEW.</p> <blockquote> <p>Example:</p> </blockquote> <pre><code>if (!GLEW_EXT_framebuffer_object) { exit(1); } </code></pre> <p>That's it! You can now use the OpenGL extension calls in your code just as if they existed naturally for Windows.</p>
<p>I lost some time, but finally I managed to get GLEW working. I'm using Windows7 (x64), Eclipse CDT and MinGW, and the way is that:</p> <p>Download MSYS (for MinGW) and rember to have MinGW installed correctly (PATH enviroinment variable set correctly): <a href="http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.10/MSYS-1.0.10.exe/download?use_mirror=freefr&amp;download=" rel="nofollow">http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.10/MSYS-1.0.10.exe/download?use_mirror=freefr&amp;download=</a></p> <p>Once MSYS installed, go to: <a href="http://glew.sourceforge.net/" rel="nofollow">http://glew.sourceforge.net/</a> and download the TGZ package, which is intended to use with UNIX systems</p> <p>Then open the package (you can use 7zip as well) and find the "Makefile". Open it and with a text editor (Notepad should work fine) find the row which contains "GLEW_DEST" and replace it with something like "GLEW_DEST ?= C:/MinGW"</p> <p>Now you are ready to go, open MSYS (C:\MinGW\msys\1.0\msys.bat in my case) and in the shell opened, go to the folder where the "Makefile" is.</p> <p>Then write a simple: "make install" and the work is done (at least for me it worked)</p> <p>PS: I also copy-pasted glew-1.10.0-win32\glew-1.10.0\bin\Release\Win32 file's into my System32 folder, and in Eclipse CDT I added the library "glew32" in the linker option and added a <code>#include &lt;GL/glew.h&gt;</code> before <code>#include &lt;GL/glut.h&gt;</code></p>
3,803
<p>I recently got an Ender 3 Pro and had a blast with it for the first few days, but then I got greedy for a better print and threw off my calibration with some &quot;upgrades&quot; and ended up with some really nasty elephant's foot. The first 3 mm are all bubbly and uneven as if someone heated it up and squished it slightly.</p> <p>I've read the other forums and have made sure my belts are tight, my bed is perfectly level, and my filament is just fine. I've tried using rafts to take the blow from the deformity and that usually helps but even with my initial layer horizontal expansion setting turned to -1, I'm still getting a little bit for flaring on the base layer on the raft.</p> <p>The upgrades I got were an aluminum extruder housing (single drive) and Capricorn tubing.</p> <p><a href="https://i.stack.imgur.com/8TQ6d.png" rel="nofollow noreferrer" title="3D printed calibration cube with elephant's foot"><img src="https://i.stack.imgur.com/8TQ6d.png" alt="3D printed calibration cube with elephant's foot" title="3D printed calibration cube with elephant's foot" /></a></p> <hr /> <p>After addressing the comments, now my corners on bigger prints come up and commonly fail even bed level tests... and the prints that do work (that I do print on a raft) are incredibly weak and break when I pull it off.</p> <p>Furthermore, I’ve been fixing several things like suggested in comments and nothings worked, now for the most part every part I’ve printed that’s longer then 2 hours has failed.</p> <p><a href="https://i.stack.imgur.com/PJQul.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PJQul.jpg" alt="enter image description here" /></a></p> <p>Yes that is brand new capricorn tubing... the old fittings dug through my old tube and caused the filament to melt in the tube and ruin it.</p>
<p>The following is from the article &quot;<a href="https://all3dp.com/2/elephant-s-foot-3d-printing-problem-easy-fixes/" rel="nofollow noreferrer">Elephant's Foot - Easy Fixes</a>&quot; on All3DP.com</p> <blockquote> <p>As we’ve explained, elephant’s foot most often occurs as the result of an uncooled first layer. If the <a href="https://all3dp.com/2/the-best-printing-temperature-for-different-filaments/" rel="nofollow noreferrer">temperature</a> of the print bed is too high, or if there’s insufficient <a href="https://all3dp.com/2/3d-printer-fans-do-i-really-need-one/" rel="nofollow noreferrer">cooling</a>, the first layer may not cool properly, causing elephant’s foot.</p> <p>Here are a few things to try to reduce or even completely resolve elephant’s foot on your prints:</p> <ul> <li><strong>Level the print bed and adjust your nozzle:</strong> Before trying anything else, make sure your printing conditions are ideal. Sometimes elephant’s foot is simply the result of an unleveled build plate or an incorrect nozzle height. These issues both cause the first layer to be squished too far down, forcing it to bulge out. Fortunately, they’re easy to fix, as both <a href="https://all3dp.com/2/3d-printer-bed-leveling-step-by-step-tutorial/" rel="nofollow noreferrer">leveling the build plate</a> and slightly increasing the nozzle height (in your <a href="https://all3dp.com/topic/3d-slicer/" rel="nofollow noreferrer">slicer</a>) are simple and quick.</li> <li><strong>Lower bed temperature:</strong> Incrementally lower the temperature of your bed by 5 °C until it successfully prints without any bulging. If you lower it by more than 20 °C outside the recommended temperature and the problem isn’t getting better, the elephant’s foot is likely to be caused by something else.</li> <li><strong>Print with a raft:</strong> Because the problem exists between the first layer and the bed, a <a href="https://all3dp.com/2/3d-printing-raft-when-should-you-use-it/" rel="nofollow noreferrer">raft</a> can take the hit for you. This is less of a solution and more of a workaround, but it can be very helpful if, for example, you really need one piece to slot into another.</li> <li><strong>Add chamfers to your model:</strong> In some rare cases, elephant’s foot can be extremely difficult to get rid of. Instead of tweaking your printer, it may be easier to simply alter the model. By putting a small 45° chamfer on the bottom edge of the print, the effects of the elephant’s foot can be mitigated.</li> </ul> </blockquote> <p>There is also a great YouTube video &quot;Smooth Top Surface and No Elephants Foot Using Cura 4.7.1&quot; from CHEP:</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/FH1wUWy7Hjw?start=0"></iframe> </div></div></p> <p>I had a similar problem on my Ender 3 V2 and followed the above information and cured my issues.</p>
<p>I have 2 Ender 3 Max printers. Both suffered elephant's foot after the initial setup. After trying virtually every suggestion available on the internet I eventually was able to fix them. Assuming the bed is properly leveled, I feel the most common causes are:</p> <ol> <li>Too much tension on the X-axis guide wheels on the right side of the printer</li> <li>Too little tension on the X-axis belt (it should be quite tight)</li> <li>Over extrusion. If your initial layers still look rough (bumpy) along the edges it may be from the excess filament. Even after careful calibration, I had to back off the E-steps by -3 (to 95). The change was dramatic!</li> </ol> <p>Both printers now print the XYZ calibration cube within 0.1 mm (0.003&quot;).</p> <p>Hope this helps.</p>
2,036
<p>I have an application, built using MVC, that produces a view which delivers summary information across a number of models. Further to that, some calculations are performed across the different sets of data.</p> <p>There's no clear single model (that maps to a table at least) that seems to make sense as the starting point for this, so the various summaries are pulled from the contributing models in the controller, passed into the view and the calculations are performed there.</p> <p>But that seems, well, <em>dirty</em>. But controllers are supposed to be lightweight, aren't they? And business logic shouldn't be in views, as I have it as present.</p> <p>So where should this information be assembled? A new model, that doesn't map to a table? A library function/module? Or something else?</p> <p>(Although I see this as mostly of an architectural/pattern question, I'm working in Rails, FWIW.)</p> <p><strong>Edit</strong>: Good answers all round, and a lot of consensus, which is reassuring. I "accepted" the answer I did to keep the link to Railscasts at the top. I'm behind in my Railscast viewing - something I shall make strenuous attempts to rectify!</p>
<p>As Brian said, you can create another model that marshals out the work that needs doing. There is <a href="http://railscasts.com/episodes/121-non-active-record-model" rel="nofollow noreferrer">a great Railscast</a> on how to do this type of thing.</p> <p>HTH</p>
<p>Controllers don't have to be <em>that</em> lightweight.</p> <p>However if you have some calculations that only rely on the model/s then you probably just need some sort of model wrapper for the models to perform the calculation. You can then place that into the API for the view so the view gets the end result.</p>
4,644
<p>Whilst looking to fix a different problem I had I came across this video.</p> <p>It's a filament reel holder, but at 02:40 the person uses a mysterious fluid. I haven't seen anything like this before (though had wondered).</p> <p><a href="https://youtu.be/X6ArZeWYSZE" rel="nofollow noreferrer" title="Mystery cleaning fluid">Mystery cleaning fluid.</a></p> <p>What practical problems would this cleaning fluid mitigate?</p>
<p><a href="https://i.stack.imgur.com/gMDDx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gMDDx.png" alt="enter image description here"></a></p> <p>That's a filament cleaner/oiler combo. The black bottle is a variety of machine oil. </p> <p>The effect of oilers on prints is heavily disputed in the community. The suggestion of plant oils is a very bad one as they can create residue that stays in the hotend and create clogs.</p>
<p>For really long Bowden tubes, some people use Teflon lubricant in a cleaner bead.</p> <p>Never used it myself, since I use a small tube my printer with the stepper on top of one of the Z axis steel rod mounting plates (Anet A8).</p> <p>Off topic, but by cooking and being a vaper, I vouch that organic compounds leave gunky residues on hot surfaces/parts.</p>
1,170
<p>Given a declaration like this:</p> <pre><code>class A { public: void Foo() const; }; </code></pre> <p>What does it mean?</p> <p>Google turns up this:</p> <blockquote> <p>Member functions should be declared with the const keyword after them if they can operate on a const (this) object. If the function is not declared const, in can not be applied to a const object, and the compiler will give an error message.</p> </blockquote> <p>But I find that somewhat confusing; can anyone out there put it in better terms?</p> <p>Thanks. </p>
<p>Consider a variation of your class <code>A</code>.</p> <pre><code>class A { public: void Foo() const; void Moo(); private: int m_nState; // Could add mutable keyword if desired int GetState() const { return m_nState; } void SetState(int val) { m_nState = val; } }; const A *A1 = new A(); A *A2 = new A(); A1-&gt;Foo(); // OK A2-&gt;Foo(); // OK A1-&gt;Moo(); // Error - Not allowed to call non-const function on const object instance A2-&gt;Moo(); // OK </code></pre> <p>The <code>const</code> keyword on a function declaration indicates to the compiler that the function is contractually obligated not to modify the state of <code>A</code>. Thus you are unable to call non-<code>const</code> functions within <code>A::Foo</code> nor change the value of member variables.</p> <p>To illustrate, <em>Foo()</em> may not invoke <code>A::SetState</code> as it is declared non-<code>const</code>, <code>A::GetState</code> however is ok because it is explicitly declared <code>const</code>. The member <code>m_nState</code> may not be changed either unless declared with the keyword <code>mutable</code>.</p> <p>One example of this usage of <code>const</code> is for 'getter' functions to obtain the value of member variables.</p> <blockquote> <p>@1800 Information: I forgot about mutable!</p> </blockquote> <p>The <code>mutable</code> keyword instructs the compiler to accept modifications to the member variable which would otherwise cause a compiler error. It is used when the function needs to modify state but the object is considered logically consistent (constant) regardless of the modification.</p>
<p>that will cause the method to not be able to alter any member variables of the object</p>
7,145
<p>I need to find out the <strong>external</strong> IP of the computer a C# application is running on. </p> <p>In the application I have a connection (via .NET remoting) to a server. Is there a good way to get the address of the client on the server side?</p> <p><em>(I have edited the question, to be a little more clear. I'm apologize to all kind people who did their best to respond to the question, when I perhaps was a little too vague)</em></p> <p><strong>Solution:</strong><br> I found a way that worked great for me. By implementing a custom IServerChannelSinkProvider and IServerChannelSink where I have access to CommonTransportKeys.IPAddress, it's easy to add the client ip on the CallContext.</p> <pre><code>public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestmessage, ITransportHeaders requestHeaders, System.IO.Stream requestStream, out IMessage responseMessage, out ITransportHeaders responseHeaders, out System.IO.Stream responseStream) { try { // Get the IP address and add it to the call context. IPAddress ipAddr = (IPAddress)requestHeaders[CommonTransportKeys.IPAddress]; CallContext.SetData("ClientIP", ipAddr); } catch (Exception) { } sinkStack.Push(this, null); ServerProcessing srvProc = _NextSink.ProcessMessage(sinkStack, requestmessage, requestHeaders, requestStream, out responseMessage, out responseHeaders, out responseStream); return srvProc; } </code></pre> <p>And then later (when I get a request from a client) just get the IP from the CallContext like this.</p> <pre><code>public string GetClientIP() { // Get the client IP from the call context. object data = CallContext.GetData("ClientIP"); // If the data is null or not a string, then return an empty string. if (data == null || !(data is IPAddress)) return string.Empty; // Return the data as a string. return ((IPAddress)data).ToString(); } </code></pre> <p>I can now send the IP back to the client.</p>
<p>This is one of those questions where you have to look deeper and maybe rethink the original problem; in this case, "Why do you need an external IP address?"</p> <p>The issue is that the computer may not have an external IP address. For example, my laptop has an internal IP address (192.168.x.y) assigned by the router. The router itself has an internal IP address, but its "external" IP address is also internal. It's only used to communicate with the DSL modem, which actually has the external, internet-facing IP address.</p> <p>So the real question becomes, "How do I get the Internet-facing IP address of a device 2 hops away?" And the answer is generally, you don't; at least not without using a service such as whatismyip.com that you have already dismissed, or doing a really massive hack involving hardcoding the DSL modem password into your application and querying the DSL modem and screen-scraping the admin page (and God help you if the modem is ever replaced).</p> <p>EDIT: Now to apply this towards the refactored question, "How do I get the IP address of my client from a server .NET component?" Like whatismyip.com, the best the server will be able to do is give you the IP address of your internet-facing device, which is unlikely to be the actual IP address of the computer running the application. Going back to my laptop, if my Internet-facing IP was 75.75.75.75 and the LAN IP was 192.168.0.112, the server would only be able to see the 75.75.75.75 IP address. That will get it as far as my DSL modem. If your server wanted to make a separate connection back to my laptop, I would first need to configure the DSL modem and any routers inbetween it and my laptop to recognize incoming connections from your server and route them appropriately. There's a few ways to do this, but it's outside the scope of this topic.</p> <p>If you are in fact trying to make a connection out from the server back to the client, rethink your design because you are delving into WTF territory (or at least, making your application that much harder to deploy).</p>
<p>You can basically parse the page returned by doing a WebRequest of <a href="http://whatismyipaddress.com" rel="nofollow noreferrer">http://whatismyipaddress.com</a></p> <p><a href="http://www.dreamincode.net/forums/showtopic24692.htm" rel="nofollow noreferrer">http://www.dreamincode.net/forums/showtopic24692.htm</a></p>
9,188
<p>I'm having a problem where the relative dimensional error of cylinders is rapidly increasing as the absolute size decreases. Printing a calibration stack of cylinders of diameters 8, 7, 6, 5, 4, and 3 mm, they come out undersized by 5%, 5.3%, 7%, 8%, 10%, and 13%, respectively, as measured by a digital caliper. Cubes exhibit a less severe version of the same pattern: 2.5%, 3%, 5%, 4%, 5%, 7%. The cylinders are generated with OpenSCAD using <code>$fn=180</code>, i.e. they're actually extrusions of 180-gons, so the error should not be caused by poor chord approximation; indeed, measuring projections of the model, or reading the gcode and accounting for nozzle width, everything looks right.</p> <p>Printer is Ender 3, using PLA at 210. Slicing with CuraEngine.</p> <p>Could this be caused by underextrusion or print speed issues - or some effect where the material pulls itself together under tight curvature? What techniques might be able to compensate for it, short of fudging the model?</p> <p>Some additional information: As noted by Trish in the comments, the consistency of the absolute error, which is 0.4 for cylinders and 0.2 for cubes, is likely important. I've also subsequently tested with 110% extrusion rate and the errors for the cylinders dropped to consistently 0.2 mm (still a significant increasing relative error), but the skin layers at the top of the 3 mm cylinder bulged, suggesting the increased extrusion is wrong - an excessive total volume of material.</p>
<p>You should not look at the relative dimensional differences, you should be looking at the absolute differences. Multiplying the undersized dimensions in percentage with the cylinder diameter gives you a value of 0.4 &nbsp;mm for each cylinder give or take a few hundreds. So, basically your printer works very consistent it is just suffering from a systematic offset.</p> <p>Basically, the printing process needs to adjust the X-Y dimensions to compensate for plastic flow effects. An option or setting in Ultimaker Cura to counteract this is called <code>Horizontal Expansion</code>. Slic3r and Simplify3d have similar settings. In Slic3r it is called <code>XY size compensation</code>. </p>
<p>This problem seems to have mostly gone away - at least any remaining error is within a margin explainable by my cheap/low-quality digital caliper. Since asking the question, I've made a lot of changes that could contribute, but the biggest factor was probably the loose X-axis timing belt and <a href="https://3dprinting.stackexchange.com/a/10137/11157">misaligned X-axis</a>.</p> <p>Slicer options may also have been involved. For example, Cura's Ender 3 profile attempts to set limits on acceleration speeds, but does so in a way that requires the GUI to compute derived accelerations; if you're using the command line CuraEngine (which I am), all the derived settings are left at the very high defaults.</p>
1,266
<p>I need to prevent <a href="http://www.owasp.org/index.php/Session_Fixation" rel="noreferrer">Session Fixation</a>, a particular type of session hijacking, in a Java web application running in JBoss. However, it appears that the standard idiom <a href="http://www.owasp.org/index.php/Session_Fixation_in_Java" rel="noreferrer">doesn't work in JBoss</a>. Can this be worked around?</p>
<p><a href="https://jira.jboss.org/jira/browse/JBAS-4436" rel="nofollow noreferrer">This defect</a> (found <a href="http://forum.springframework.org/showthread.php?t=54688" rel="nofollow noreferrer">here</a>) points the way to the solution. The Tomcat instance that runs in JBoss is configured with emptySessionPath="true", rather than "false", which is the default. This can be modified in <code>.../deploy/jboss-web.deployer/server.xml</code>; both the HTTP and AJP connectors have this option.</p> <p>The feature itself is used to eliminate the context path (eg. "foo" in <a href="http://example.com/foo" rel="nofollow noreferrer">http://example.com/foo</a>) from being included in the JSESSIONID cookie. Setting it to false will break applications that rely on cross-application authentication, which includes stuff built using some portal frameworks. It didn't negatively affect the application in question, however.</p>
<p>This problem and the specific case in which it occurs is a problem in Tomcat as well as JBoss. Tomcat shares the emptySessionPath="true" effect (and actually JBoss inherits it from Tomcat).</p> <p>This really seems like a bug in Tomcat and JBoss when you are trying to prevent session fixation attacks but the servlet spec (at least version 2.3) does not actually require the JSESSIONID to be defined or redefined according to any specific logic. Perhaps this has been cleaned up in later versions.</p>
2,976
<p>What I'd like to do is something like the following:</p> <pre><code>FooClass.prototype.method = function():String { return "Something"; } var foo:FooClass = new FooClass(); foo.method(); </code></pre> <p>Which is to say, I'd like to extend a generated class with a single method, not via inheritance but via the prototype.</p> <p>The class is generated from a WSDL, it's not a dynamic class, and I don't want to touch the generated code because it will be overwritten anyway.</p> <p>Long story short, I'd like to have the moral equivalent of C# 3:s Extension Methods for AS3.</p> <p>Edit: I accepted aib's answer, because it fits what I was asking best -- although upon further reflection it doesn't really solve my problem, but that's my fault for asking the wrong question. :) Also, upmods for the good suggestions.</p>
<p>Yes, such a thing is possible.</p> <p>In fact, your example is very close to the solution.</p> <p>Try</p> <pre><code>foo["method"](); </code></pre> <p>instead of</p> <pre><code>foo.method(); </code></pre>
<p>@aib is unfortunately incorrect. Assuming strict mode (the default compiler mode) it is not possible to modify the prototype of non-dynamic class types in ActionScript 3. I'm not even sure that it's possible in non-strict mode.</p> <p>Is wrapping an option? Basically you create a class that takes one of the objects you get from the web service and just forwards all method calls to that, but also has methods of its own:</p> <pre><code>public class FooWrapper extends Foo { private var wrappedFoo : Foo; public function FooWrapper( foo : Foo ) { wrappedFoo = foo; } override public function methodFromFoo( ) : void { wrappedFoo.methodFromFoo(); } override public function anotherMethodFromFoo( ) : void { wrappedFoo.anotherMethodFromFoo(); } public function newMethodNotOnFoo( ) : String { return "Hello world!" } } </code></pre> <p>When you want to work with a <code>Foo</code>, but also have the extra method you need you wrap the <code>Foo</code> instance in a <code>FooWrapper</code> and work with that object instead.</p> <p>It's not the most convenient solution, there's a lot of typing and if the generated code changes you have to change the <code>FooWrapper</code> class by hand, but unless you can modify the generated code either to include the method you want or to make the class dynamic I don't see how it can be done.</p> <p>Another solution is to add a step to your build process that modifies the source of the generated classes. I assume that you already have a step that generates the code from a WSDL, so what you could do is to add a step after that that inserts the methods you need.</p>
2,882
<p>This is a fairly trivial matter, but I'm curious to hear people's opinions on it.</p> <p>If I have a Dictionary which I'm access through properties, which of these formats would you prefer for the property?</p> <pre><code>/// &lt;summary&gt; /// This class's FirstProperty property /// &lt;/summary&gt; [DefaultValue("myValue")] public string FirstProperty { get { return Dictionary["myKey"]; } set { Dictionary["myKey"] = value; } </code></pre> <p>This is probably the typical way of doing it. It's fairly efficient, easy to understand, etc. The only disadvantage is with a longer or more complex key it would be possible to misspell it or change only one instance or something, leading me to this:</p> <pre><code>/// &lt;summary&gt; /// This class's SecondProperty property /// &lt;/summary&gt; [DefaultValue("myValue")] private const string DICT_MYKEY = "myKey" public string SecondProperty { get { return Dictionary[DICT_MYKEY]; } set { Dictionary[DICT_MYKEY] = value; } </code></pre> <p>Which is marginally more complicated, but seems to offer additional safety, and is closer to what I would think of as the "Code Complete" solution. The downside is that when you also have a /// block and a [DefaultValue()] block above the property already, it starts getting a bit crowded up there.</p> <p>So which do you like better, and why? Does anybody have any better ideas?</p>
<p>I like the second one purely because any avoidance of magic strings/numbers in code is a good thing. IMO if you need to reference a number or string literal in code more than once, it should be a constant. In most cases even if it's only used once it should be in a constant </p>
<p>This isn't answering your question, but I don't think "DefaultValue" means what you think it means. It doesn't set a default value for your property.</p> <p>See <a href="http://support.microsoft.com/kb/311339" rel="nofollow noreferrer">MSDN</a> and <a href="https://stackoverflow.com/questions/43738/defaultvalue-for-systemdrawingsystemcolors#44073">this question</a> for more details.</p>
6,574
<p>Is there a way to detect, from within the finally clause, that an exception is in the process of being thrown?</p> <p>See the example below:</p> <pre><code> try { // code that may or may not throw an exception } finally { SomeCleanupFunctionThatThrows(); // if currently executing an exception, exit the program, // otherwise just let the exception thrown by the function // above propagate } </code></pre> <p>or is ignoring one of the exceptions the only thing you can do?</p> <p>In C++ it doesn't even let you ignore one of the exceptions and just calls terminate(). Most other languages use the same rules as java.</p>
<p>Set a flag variable, then check for it in the finally clause, like so:</p> <pre><code>boolean exceptionThrown = true; try { mightThrowAnException(); exceptionThrown = false; } finally { if (exceptionThrown) { // Whatever you want to do } } </code></pre>
<p>No I do not believe so. The catch block will run to completion before the finally block.</p> <pre><code>try { // code that may or may not throw an exception } catch { // catch block must exist. finally { SomeCleanupFunctionThatThrows(); // this portion is ran after catch block finishes } </code></pre> <p>Otherwise you can add a synchronize() object that the exception code will use, that you can check in the finally block, which would help you identify if in a seperate thread you are running an exception.</p>
9,215
<p>I am trying to develop a multimedia site and I am leaning heavily toward Silverlight however Flash is always a main player. I am a Speed and performance type developer. Which Technology will load fastest in the given scenarios? 56k, DSL and Cable?</p>
<p>It all depends on what you're doing: animation, video, calculation, etc? There are <a href="http://www.tobinharris.com/2008/8/30/performance-of-silverlight-vs-flash-vs-javascript-vs-tracemonkey" rel="nofollow noreferrer">some tests that show Silverlight being faster for raw computation</a>, while Flash's graphics engine is farther along (GPU utilization, 3D, etc.).</p> <p>If you're talking about load time, there are definitely things you can do in Silverlight to make your XAP file smaller than most images - the Hard Rock Memorabilia team got their XAP down under 70K, and that site browsed GB of photo data. I'm sure you can do the same in Flash.</p> <p>While your question is focused on performance, as others have mentioned you do have to take into account the 4.5MB install for Silverlight, since it's not widely installed yet.</p>
<p>Actually, you have to assume that Flash is probably already installed on the user's browser, and SilverLight probably not. So the cost of installing silverlight (though a small download) has to be taken in to consideration as well.</p> <p>Silverlight, however, does have some pretty neat out of the box multimedia support.</p>
9,140
<p>I want to create parts for a 3D printer using OpenSCAD. Having some STL files from the vendor, but nothing else (no technical drawing, no CAD files).</p> <p>Does anybody knows a free tool, that allows me to</p> <ul> <li>measure distances between 2 selected vertices,</li> <li>measure distances between a selected vertex and a plane defined by 3 vertices,</li> <li>measure the radio of a circle defined by 3 selected vertices?</li> </ul> <p>I very much like the way Blender allows to work with meshes, especially select vertices or planes, but unfortunately haven't found a way to measure with Blender.</p>
<p>I suggest Blender. It's not the simplest of tools but it is free and learning it will improve your 3D printing skills. :-) (I write this answer also for future viewers of this question so I start basic).</p> <p>Another answer can be found here, <a href="https://blender.stackexchange.com/q/19772/14005">How do I measure a distance between two points?</a></p> <ol> <li>Import your STL file.</li> <li>Press the Home key to view everything.</li> <li>Select the model by clicking on it with your left mouse button. (Blender changed to left-click-select as of version 2.80)</li> <li>Hit tab to enter edit-mode.</li> <li>Press N (or use View | Properties) until the Properties panel shows up.</li> <li>Select the &quot;Length&quot; checkbox in the &quot;Edge Info&quot; section of the Properties panel (see image below).</li> <li>Select &quot;Edge Select&quot; mode (see image below)</li> <li>Select the edge to measure by clicking on it with your right mouse button.</li> </ol> <p><a href="https://i.stack.imgur.com/9Oi1c.png" rel="nofollow noreferrer" title="Edge length"><img src="https://i.stack.imgur.com/9Oi1c.png" alt="Edge length" title="Edge length" /></a></p> <p><a href="https://i.stack.imgur.com/Ouw0q.png" rel="nofollow noreferrer" title="Screenshot of toolbar"><img src="https://i.stack.imgur.com/Ouw0q.png" alt="Screenshot of toolbar" title="Screenshot of toolbar" /></a></p> <p>If you need to measure the distance between to vertices with no edge. Create the edge by selecting them and pressing <kbd>F</kbd>. If you need to measure the distance between a vertex and any other point, select it and press <kbd>E</kbd> to extrude.</p>
<p>Use Meshy &quot;...a WebGL-based tool that does measurements and simple transformations on STL and OBJ files.&quot;: <a href="https://0x00019913.github.io/meshy/" rel="nofollow noreferrer">https://0x00019913.github.io/meshy/</a></p>
472
<p>In an effort to reduce code duplication in my little Rails app, I've been working on getting common code between my models into it's own separate module, so far so good.</p> <p>The model stuff is fairly easy, I just have to include the module at the beginning, e.g.:</p> <pre><code>class Iso &lt; Sale include Shared::TracksSerialNumberExtension include Shared::OrderLines extend Shared::Filtered include Sendable::Model validates_presence_of :customer validates_associated :lines owned_by :customer def initialize( params = nil ) super self.created_at ||= Time.now.to_date end def after_initialize end order_lines :despatched # tracks_serial_numbers :items sendable :customer def created_at=( date ) write_attribute( :created_at, Chronic.parse( date ) ) end end </code></pre> <p>This is working fine, now however, I'm going to have some controller and view code that's going to be common between these models as well, so far I have this for my sendable stuff:</p> <pre><code># This is a module that is used for pages/forms that are can be "sent" # either via fax, email, or printed. module Sendable module Model def self.included( klass ) klass.extend ClassMethods end module ClassMethods def sendable( class_to_send_to ) attr_accessor :fax_number, :email_address, :to_be_faxed, :to_be_emailed, :to_be_printed @_class_sending_to ||= class_to_send_to include InstanceMethods end def class_sending_to @_class_sending_to end end # ClassMethods module InstanceMethods def after_initialize( ) super self.to_be_faxed = false self.to_be_emailed = false self.to_be_printed = false target_class = self.send( self.class.class_sending_to ) if !target_class.nil? self.fax_number = target_class.send( :fax_number ) self.email_address = target_class.send( :email_address ) end end end end # Module Model end # Module Sendable </code></pre> <p>Basically I'm planning on just doing an include Sendable::Controller, and Sendable::View (or the equivalent) for the controller and the view, but, is there a cleaner way to do this? I 'm after a neat way to have a bunch of common code between my model, controller, and view.</p> <p>Edit: Just to clarify, this just has to be shared across 2 or 3 models.</p>
<p>You could pluginize it (use script/generate plugin).</p> <p>Then in your init.rb just do something like:</p> <pre><code>ActiveRecord::Base.send(:include, PluginName::Sendable) ActionController::Base.send(:include, PluginName::SendableController) </code></pre> <p>And along with your self.included that should work just fine.</p> <p>Check out some of the acts_* plugins, it's a pretty common pattern (<a href="http://github.com/technoweenie/acts_as_paranoid/tree/master/init.rb" rel="nofollow noreferrer">http://github.com/technoweenie/acts_as_paranoid/tree/master/init.rb</a>, check line 30)</p>
<p>If you do go the plugin route, do check out <a href="http://rails-engines.org/" rel="nofollow noreferrer">Rails-Engines</a>, which are intended to extend plugin semantics to Controllers and Views in a clear way. </p>
9,389
<p>I'd like to use a <code>LinqDataSource</code> control on a page and limit the amount of records returned. I know if I use code behind I could do something like this:</p> <pre><code>IEnumerable&lt;int&gt; values = Enumerable.Range(0, 10); IEnumerable&lt;int&gt; take3 = values.Take(3); </code></pre> <p>Does anyone know if something like this is possible with a <code>LinqDataSource</code> control?</p> <p><strong>[Update]</strong></p> <p>I'm going to use the <code>LinqDataSource</code> with the <code>ListView</code> control, <em>not</em> a GridView or Repeater. The <code>LinqDataSource</code> wizard does not provide the ability to limit the number of records return. The Advanced options only allow you to enabled deletes, inserts, and updates.</p>
<p>I had this same issue. The way I got round this was to use the Selecting event on the LinqDataSource and return the result manually.</p> <p>e.g.</p> <pre><code>protected void lnqRecentOrder_Selecting(object sender, LinqDataSourceSelectEventArgs e) { DataClassesDataContext dx = new DataClassesDataContext(); e.Result = (from o in dx.Orders where o.CustomerID == Int32.Parse(Request.QueryString["CustomerID"]) select o).Take(5); } </code></pre>
<p>I know that if you use a paging repeater or gridview with the linqdatasource it will automatically optimize the number of results returned, but I'm also pretty sure in the datasource wizard you can go to advanced options and limit it to </p> <pre><code>SELECT TOP 3 FROM </code></pre> <p>which should allow you to do what you need</p>
2,621
<p>There are several ways to iterate over a result set. What are the tradeoff of each?</p>
<p>The canonical way is to use the built-in cursor iterator.</p> <pre><code>curs.execute('select * from people') for row in curs: print row </code></pre> <hr> <p>You can use <code>fetchall()</code> to get all rows at once.</p> <pre><code>for row in curs.fetchall(): print row </code></pre> <p>It can be convenient to use this to create a Python list containing the values returned:</p> <pre><code>curs.execute('select first_name from people') names = [row[0] for row in curs.fetchall()] </code></pre> <p>This can be useful for smaller result sets, but can have bad side effects if the result set is large.</p> <ul> <li><p>You have to wait for the entire result set to be returned to your client process.</p></li> <li><p>You may eat up a lot of memory in your client to hold the built-up list.</p></li> <li><p>It may take a while for Python to construct and deconstruct the list which you are going to immediately discard anyways.</p></li> </ul> <hr> <p>If you know there's a single row being returned in the result set you can call <code>fetchone()</code> to get the single row.</p> <pre><code>curs.execute('select max(x) from t') maxValue = curs.fetchone()[0] </code></pre> <hr> <p>Finally, you can loop over the result set fetching one row at a time. In general, there's no particular advantage in doing this over using the iterator.</p> <pre><code>row = curs.fetchone() while row: print row row = curs.fetchone() </code></pre>
<p>There's also the way <code>psyco-pg</code> seems to do it... From what I gather, it seems to create dictionary-like row-proxies to map key lookup into the memory block returned by the query. In that case, fetching the whole answer and working with a similar proxy-factory over the rows seems like useful idea. Come to think of it though, it feels more like Lua than Python.</p> <p>Also, this should be applicable to all <a href="http://www.python.org/dev/peps/pep-0249/" rel="noreferrer">PEP-249 DBAPI2.0</a> interfaces, not just Oracle, or did you mean just <em>fastest</em> using <em>Oracle</em>?</p>
2,301
<p>Most mathematicians agree that:</p> <blockquote> <p>e<sup>πi</sup> + 1 = 0</p> </blockquote> <p>However, most floating point implementations disagree. How well can we settle this dispute?</p> <p>I'm keen to hear about different languages and implementations, and various methods to make the result as close to zero as possible. Be creative!</p>
<p>It's not that most floating point implementations disagree, it's just that they cannot get the accuracy necessary to get a 100% answer. And the correct answer is that they can't.</p> <p>PI is an infinite series of digits that nobody has been able to denote by anything other than a symbolic representation, and e^X is the same, and thus the only way to get to 100% accuracy is to go symbolic.</p>
<p>@Ryan Fox <blockquote>In fact, how does one represent i (or j for the engineers) in a conventional programming language?</blockquote></p> <p>Native complex data types are far from unknown. Fortran had it by the mid-sixties, and the OP exhibits a variety of other languages that support them in hist followup. </p> <p>And complex numbers can be added to other languages as libraries (with operator overloading they even look just like native types in the code).</p> <p>But unless you provide a special case for this problem, the "non-agreement" is just an expression of imprecise machine arithmetic, no? It's like complaining that</p> <pre><code>float r = 2/3; float s = 3*r; float t = s - 2; </code></pre> <p>ends with (t != 0) (At least if you use an dumb enough compiler)...</p>
2,348
<p>Visual Studio Solution files contain two GUID's per project entry. I figure one of them is from the AssemblyInfo.cs</p> <p>Does anyone know for sure where these come from, and what they are used for?</p>
<p>Neither GUID is the same GUID as from AssemblyInfo.cs (that is the GUID for the assembly itself, not tied to Visual Studio but the end product of the build).</p> <p>So, for a typical line in the sln file (open the .sln in notepad or editor-of-choice if you wish to see this):</p> <pre><code>Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSandbox", "ConsoleSandbox\ConsoleSandbox.csproj", "{55A1FD06-FB00-4F8A-9153-C432357F5CAC}" </code></pre> <p>The second GUID is a unique GUID for the project itself. The solution file uses this to map other settings to that project:</p> <pre><code>GlobalSection(ProjectConfigurationPlatforms) = postSolution {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Debug|Any CPU.Build.0 = Debug|Any CPU {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Release|Any CPU.ActiveCfg = Release|Any CPU {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection </code></pre> <p>The first GUID is actually a GUID that is the unique GUID for the solution itself (I believe). If you have a solution with more than one project, you'll actually see something like the following:</p> <pre><code>Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSandbox", "ConsoleSandbox\ConsoleSandbox.csproj", "{55A1FD06-FB00-4F8A-9153-C432357F5CAC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite", "..\CompositeWPF\Source\CAL\Composite\Composite.csproj", "{77138947-1D13-4E22-AEE0-5D0DD046CA34}" EndProject </code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/bb165951(VS.80).aspx" rel="noreferrer">According to MSDN</a>: </p> <blockquote> <p>[The <code>Project</code>] statement contains the unique project GUID and the project type GUID. This information is used by the environment to find the project file or files belonging to the solution, and the VSPackage required for each project. The project GUID is passed to IVsProjectFactory to load the specific VSPackage related to the project, then the project is loaded by the VSPackage.</p> </blockquote>
7,642
<p>I'm using the JFrame plugin with jquery 1.2.6.</p> <p>It works fine in FF3, however it won't display the requested pages in IE 7.</p> <p>The jQuery library and the JFrame plugin are called in the included header.cfm.</p> <p>Page code is here (note: ignore the ColdFusion calls, I don't think they're generating the problem): <a href="http://cfm.pastebin.com/m20c1b013" rel="nofollow noreferrer">http://cfm.pastebin.com/m20c1b013</a></p>
<p>When you have a problem like this, the best way of tracking down the problem is to reduce the page to the minimum necessary to reproduce the problem.</p> <p><em>"Ignore the [x] because I don't think that's the problem"</em> is no good, if you don't think that's the problem, save it to a temporary static page, delete the things you think are unrelated, and then you <em>know</em> whether or not they are the problem. Keep deleting things you think are unrelated, and eventually you will either find the bit that's screwing things up when you remove it, or you will end up with a very small file that is:</p> <ul> <li>Much easier to debug</li> <li>Much more likely to attract help from people</li> <li>Much better testcase for the times when it's a genuine bug in a library</li> </ul> <p>Not many people are willing to pick apart Coldfusion and table layout code to get to your bug - after all, you're the one with the problem, and even you couldn't be bothered to do it, so why would anybody else?</p>
<p>I would suggest updating to the newest release of jquery (v 1.3.2). This might be the simplest way to attempt to fix the bug. <a href="http://jquery.com/" rel="nofollow noreferrer">http://jquery.com/</a></p>
9,027
<p>When writing a switch statement, there appears to be two limitations on what you can switch on in case statements.</p> <p>For example (and yes, I know, if you're doing this sort of thing it probably means your <a href="https://en.wikipedia.org/wiki/Object-oriented_programming" rel="noreferrer">object-oriented</a> (OO) architecture is iffy - this is just a contrived example!),</p> <pre><code> Type t = typeof(int); switch (t) { case typeof(int): Console.WriteLine("int!"); break; case typeof(string): Console.WriteLine("string!"); break; default: Console.WriteLine("unknown!"); break; } </code></pre> <p>Here the switch() statement fails with 'A value of an integral type expected' and the case statements fail with 'A constant value is expected'.</p> <p>Why are these restrictions in place, and what is the underlying justification? I don't see any reason why the switch statement <em>has</em> to succumb to static analysis only, and why the value being switched on has to be integral (that is, primitive). What is the justification?</p>
<p>This is my original post, which sparked some debate... <strong>because it is wrong</strong>:</p> <blockquote> <p>The switch statement is not the same thing as a big if-else statement. Each case must be unique and evaluated statically. The switch statement does a constant time branch regardless of how many cases you have. The if-else statement evaluates each condition until it finds one that is true.</p> </blockquote> <hr> <p>In fact, the C# switch statement is <strong>not</strong> always a constant time branch.</p> <p>In some cases the compiler will use a CIL switch statement which is indeed a constant time branch using a jump table. However, in sparse cases as pointed out by <a href="https://stackoverflow.com/questions/44905/c-switch-statement-limitations-why#48259">Ivan Hamilton</a> the compiler may generate something else entirely.</p> <p>This is actually quite easy to verify by writing various C# switch statements, some sparse, some dense, and looking at the resulting CIL with the ildasm.exe tool.</p>
<p>I suppose there is no fundamental reason why the compiler couldn't automatically translate your switch statement into:</p> <pre><code>if (t == typeof(int)) { ... } elseif (t == typeof(string)) { ... } ... </code></pre> <p>But there isn't much gained by that.</p> <p>A case statement on integral types allows the compiler to make a number of optimizations:</p> <ol> <li><p>There is no duplication (unless you duplicate case labels, which the compiler detects). In your example t could match multiple types due to inheritance. Should the first match be executed? All of them?</p></li> <li><p>The compiler can choose to implement a switch statement over an integral type by a jump table to avoid all the comparisons. If you are switching on an enumeration that has integer values 0 to 100 then it creates an array with 100 pointers in it, one for each switch statement. At runtime it simply looks up the address from the array based on the integer value being switched on. This makes for much better runtime performance than performing 100 comparisons.</p></li> </ol>
6,666
<p>One of the things I miss the most in ActionScript is the lack of operator overloading, in particular ==. I kind of work around this issue by adding a "Compare" method to my classes, but that doesn't help in many cases, like when you want to use things like the built in Dictionary.</p> <p>Is there a good way to work around this problem?</p>
<p>Nope.</p> <p>But it doesn't hurt to add <code>equals</code> methods to your own classes. I try to never use <code>==</code> when comparing objects (the same goes for <code>===</code>, which is the same thing for objects) since it only checks <em>identity</em> .</p> <p>Sadly all the collections in Flash and Flex assume that identity is the only measure of equality that is needed.</p> <p>There are hints in Flex that someone wanted to alleviate this problem at one time, but it seems like it was abandoned: there is an interface called <a href="http://livedocs.adobe.com/flex/201/langref/mx/core/IUID.html" rel="noreferrer">IUID</a>, and it is mentioned in the <em>Flex Developer's Guide</em> , but it is not used anywhere. Not even the collections in Flex use it to determine equality. And since you are asking for a solution for Flash, it may not have helped you anyway.</p> <p>I've written some more about this (in the context of Flex) on my blog: <a href="http://blog.iconara.net/2007/11/25/architectural-atrocities-part-8-is-there-no-equality/" rel="noreferrer">Is there no equality?</a>.</p>
<p>Yes it can be done (but be careful, its hacky): <a href="http://filimanjaro.com/2012/operators-overloading-in-as3-javascript-too-%E2%80%93-workaround/" rel="nofollow">http://filimanjaro.com/2012/operators-overloading-in-as3-javascript-too-%E2%80%93-workaround/</a></p> <p>In the tutorial I wrote about +=, -= operator overloading. But it's also possible with ==, I can write more about that if it's not clear.</p> <p>Ah, the approach has some drawback (in rare cases it can be even dangerous). Think twice, before using it in a production.</p> <p><strong>EDIT:</strong></p> <p>After tests it seems the trick with +=, -= doesn't apply to == operator (what makes sense). Sorry for misleading info.</p>
7,381
<p>Here is a simplification of my database:</p> <pre>Table: Property Fields: ID, Address Table: Quote Fields: ID, PropertyID, BespokeQuoteFields... Table: Job Fields: ID, PropertyID, BespokeJobFields...</pre> <p>Then we have other tables that relate to the <strong>Quote</strong> and <strong>Job</strong> tables individually.</p> <p>I now need to add a <strong>Message</strong> table where users can record telephone messages left by customers regarding Jobs and Quotes.</p> <p>I could create two identical tables (<strong>QuoteMessage</strong> and <strong>JobMessage</strong>), but this violates the DRY principal and seems messy.</p> <p>I could create one <strong>Message</strong> table:</p> <pre>Table: Message Fields: ID, RelationID, RelationType, OtherFields...</pre> <p>But this stops me from using constraints to enforce my referential integrity. I can also forsee it creating problems with the devlopment side using Linq to SQL later on.</p> <p>Is there an elegant solution to this problem, or am I ultimately going to have to hack something together?</p> <p>Burns</p>
<p>Create one Message table, containing a unique MessageId and the various properties you need to store for a message.</p> <pre><code>Table: Message Fields: Id, TimeReceived, MessageDetails, WhateverElse... </code></pre> <p>Create two link tables - QuoteMessage and JobMessage. These will just contain two fields each, foreign keys to the Quote/Job and the Message.</p> <pre><code>Table: QuoteMessage Fields: QuoteId, MessageId Table: JobMessage Fields: JobId, MessageId </code></pre> <p>In this way you have defined the data properties of a Message in one place only (making it easy to extend, and to query across all messages), but you also have the referential integrity linking Quotes and Jobs to any number of messages. Indeed, both a Quote and Job could be linked to the <em>same</em> message (I'm not sure if that is appropriate to your business model, but at least the data model gives you the option).</p>
<p>Why not just have both QuoteId and JobId fields in the message table? Or does a message have to be regarding either a quote or a job and not both?</p>
3,998
<p>I have a huge web app that is having issues with memory leak in IE 6.</p> <p>Fixing a memory leak in a 5 line code sample that demonstrates the problem is easy. </p> <p>But if I have a very huge application, where should a start from?</p>
<p>Check out <a href="http://sourceforge.net/projects/ieleak" rel="nofollow noreferrer">Drip</a>. That usually takes the guesswork out of IE memory leaks.</p> <p>If for some reason Drip doesn't find it, take a close look at any JavaScript code that works with events. That is almost always the source of any significant memory leak in a browser.</p> <p>Destroying a DOM element with handlers attached to it, without removing those handlers first, will prevent the memory associated with those handlers from being recovered.</p>
<p>Here is how I solved the memory leak problem in IE7. The idea is to dispose/set to null all expando-properties on all DOM nodes at unloading the page. This worked for me. You may find it useful.</p> <pre><code>&lt;!--[if lt IE 8]&gt; &lt;script type="text/javascript"&gt; function disposeAll() { if (window.document.all) { for (var index = 0; index &lt; window.document.all.length; index++) { try { dispose(window.document.all[index], []); } catch (e) { debugger; } } } dispose(window.document.body, []); dispose(window.document, []); dispose(window, []); window.disposeAll = null; window.dispose = null; window.onunload = null; } function dispose(something, map) { if (something == null) return; if (something.dispose &amp;&amp; typeof (something.dispose) == 'function') { try { something.dispose(); } catch (e) { debugger; } } map.push(something); for (var key in something) { var value = null; try { value = something[key]; } catch (e) { }; if (value == null || value == dispose || value == disposeAll) continue; var processed = null; for (var index = 0; index &lt; map.length; index++) { if (map[index] === value) { processed = value; break; } } if (processed != null) continue; var constructor = value.constructor; if (constructor == Object || constructor == Array) { try { dispose(value, map); } catch (e) { debugger; } } if (constructor == Object || constructor == Array || constructor == Function) { try { something[key] = null; } catch (e) { debugger; } } } map.pop(); } (function() { var previousUnloadHandler = window.onunload; if (previousUnloadHandler == null) { window.onunload = disposeAll; } else { window.onunload = function() { previousUnloadHandler.apply(this, arguments); // &lt;== HERE YOU MAY WANT TO HAVE AN "IF" TO MAKE SURE THE ORIGINAL UNLOAD EVENT WASN'T CANCELLED disposeAll(); previousUnloadHandler = null; }; } }()); &lt;/script&gt; &lt;![endif]--&gt; </code></pre> <p>You may want to remove all "debugger;" statements if you don't feel like dealing with some occasional exceptions.</p>
4,016
<p>In interpreted programming languages, such as PHP and JavaScript, what are the repercussions of going with an Object Oriented approach over a Procedural approach?</p> <p>Specifically what I am looking for is a checklist of things to consider when creating a web application and choosing between Procedural and Object Oriented approaches, to optimize not only for speed, but maintainability as well. Cited research and test cases would be helpful as well if you know of any articles exploring this further.</p> <p>Bottom line: how big (if any) is the performance hit really, when going with OO vs. Procedural in an interpreted language?</p>
<p>Maybe I'm crazy but worrying about speed in cases like this using an interpretive language is like trying to figure out what color to paint the shed. Let's not even get into the idea that this kind of optimization is entirely pre-mature.</p> <p>You hit the nail on the head when you said 'maintainability'. I'd choose the approach that is the most productive and most maintainable. If you need speed later, it ain't gonna come from switching between procedural versus object oriented coding paradigms inside an interpreted language.</p>
<p>I've actually done a small test like this in python on a website I maintain and found that they are almost equivalent in speed, with the procedural approach winning by something like ten-thousandths of a second, but that the OO code was so significantly cleaner I didn't continue the exercise any longer than one iteration.</p> <p>So really, it doesn't matter (in my experience anyway).</p>
2,520
<p>The SQL Server Express 2008 setup allow you to assign different user account for each service. </p> <p>For a development environment, would you use a domain user, local user, NT Authority\NETWORK SERCVICE, NT Authority\Local System or some other account and why? </p>
<p><strong>Local System</strong> is not recommended, it is an administrator equivalent account and thus can lead to questionable coding that takes advantage of administrator privileges which would not be allowed in a production system since security conscious Admins/DBA's really don't like to run services as admin.</p> <p>Depending on if the server instance will need to access other domain resources or not should determine which type of low privilege account it should run under. </p> <p>If it does not need to access any (non-anonymous) domain resources than I normally create a unique local, low privilege account for it to run under in order to gain the additional security benefit of not having multiple services running in the same identity context. <a href="http://msdn.microsoft.com/en-us/library/ms143504%28v=sql.105%29.aspx" rel="noreferrer">Be aware that the Local Service account is not supported for the SQL Server or SQL Server Agent services.</a> </p> <p>If it does need to access non-anonymous domain resources then you have three options: </p> <ol> <li>Run as <strong><a href="http://msdn.microsoft.com/en-us/library/ms143504%28v=sql.105%29.aspx" rel="noreferrer">Network Service</a></strong> which is also a low privilege account but one that retains the computers network credentials. </li> <li>Run under a Local Service Account</li> <li>Run under a custom domain account with low local privileges. One advantage to running under the developers account is that it is easier to attach debuggers to processes in your own identity without compromising security so debugging is easier (since non-Admin accounts do not have the privilege to attach a debugger to another identities process by default). A disadvantage to using another domain account is the overhead of managing those accounts, especially since each service for each developer should ideally have unique credentials so you do not have any leaks if a developer were to leave.</li> </ol> <p>Most of what I tend to do does not require the service to access domain resources so I tend to use unique local low privilege accounts that I manage. I also run exclusively as a non-admin user (and have done so under XP SP2, Server 2003, Vista and Server 2008 with no major problems) so when I have cases where I need the service to access domain resources then I have no worries about using my own domain credentials (plus that way I don't have to worry the network admins about creating/maintaining a bunch of non-production domain identities).</p>
<p>Whatever it wants to use as default. Changing that is just asking for trouble later.</p>
8,915
<p>Most of time we represent concepts which can never be less than 0. For example to declare length, we write:</p> <pre><code>int length; </code></pre> <p>The name expresses its purpose well but you can assign negative values to it. It seems that for some situations, you can represent your intent more clearly by writing it this way instead:</p> <pre><code>uint length; </code></pre> <p>Some disadvantages that I can think of:</p> <ul> <li>unsigned types (uint, ulong, ushort) are not CLS compliant so you can't use it with other languages that don't support this</li> <li>.Net classes use signed types most of the time so you have to cast</li> </ul> <p>Thoughts?</p>
<p>“When in Rome, do as the Romans do.”</p> <p>While there is theoretically an advantage in using unsigned values where applicable because it makes the code more expressive, this is simply not done in C#. I'm not sure why the developers initially didn't design the interfaces to handle <code>uints</code> and make the type CLS compliant but now the train has left the station.</p> <p>Since consistency is generally important I'd advise taking the C# road and using <code>int</code>s.</p>
<p>Your two points are good. The primary reason to avoid it is casting, though. Casting makes them incredibly annoying to use. I tried using unisigned variables once but I had to sprinkle casts absolutely everywhere because the framework methods all use signed integers. Therefore, whenever you call a framework method, you have to cast.</p>
5,397
<p>Consider this problem: I have a program which should fetch (let's say) 100 records from a database, and then for each one it should get updated information from a web service. There are two ways to introduce parallelism in this scenario:</p> <ol> <li><p>I start each request to the web service on a new Thread. The number of simultaneous threads is controlled by some external parameter (or dynamically adjusted somehow).</p></li> <li><p>I create smaller batches (let's say of 10 records each) and launch each batch on a separate thread (so taking our example, 10 threads).</p></li> </ol> <p>Which is a better approach, and why do you think so?</p>
<p>Option 3 is the best:</p> <p>Use Async IO.</p> <p>Unless your request processing is complex and heavy, your program is going to spend 99% of it's time waiting for the HTTP requests.</p> <p>This is exactly what Async IO is designed for - Let the windows networking stack (or .net framework or whatever) worry about all the waiting, and just use a single thread to dispatch and 'pick up' the results.</p> <p>Unfortunately the .NET framework makes it a right pain in the ass. It's easier if you're just using raw sockets or the Win32 api. Here's a (tested!) example using C#3 anyway:</p> <pre><code>using System.Net; // need this somewhere // need to declare an class so we can cast our state object back out class RequestState { public WebRequest Request { get; set; } } static void Main( string[] args ) { // stupid cast neccessary to create the request HttpWebRequest request = WebRequest.Create( "http://www.stackoverflow.com" ) as HttpWebRequest; request.BeginGetResponse( /* callback to be invoked when finished */ (asyncResult) =&gt; { // fetch the request object out of the AsyncState var state = (RequestState)asyncResult.AsyncState; var webResponse = state.Request.EndGetResponse( asyncResult ) as HttpWebResponse; // there we go; Debug.Assert( webResponse.StatusCode == HttpStatusCode.OK ); Console.WriteLine( "Got Response from server:" + webResponse.Server ); }, /* pass the request through to our callback */ new RequestState { Request = request } ); // blah Console.WriteLine( "Waiting for response. Press a key to quit" ); Console.ReadKey(); } </code></pre> <p>EDIT:</p> <p>In the case of .NET, the 'completion callback' actually gets fired in a ThreadPool thread, not in your main thread, so you will still need to lock any shared resources, but it still saves you all the trouble of managing threads.</p>
<p>The computer running the program is probably not the bottleneck, so: Remember that the HTTP protocol has a keep-alive header, that lets you send several GET requests on the same sockets, which saves you from the TCP/IP hand shake. Unfortunately I don't know how to use that in the .net libraries. (Should be possible.)</p> <p>There will probably also be a delay in answering your requests. You could try making sure that you allways have a given number of outstanding requests to the server.</p>
3,144
<p>Following on from <a href="https://3dprinting.stackexchange.com/questions/6342/what-level-of-voltage-does-the-creality-ender-3-run-at/6521#comment9993_6521">What level of voltage does the Creality Ender-3 run at?</a></p> <p><a href="https://3dprinting.stackexchange.com/questions/6342/what-level-of-voltage-does-the-creality-ender-3-run-at#answer-6521">Dave's answer</a> states that both 12&nbsp;V and 24&nbsp;V can be used on the controller board. It also goes on to say that the controller board is used in both configurations in two different printers:</p> <ul> <li>Ender 3 and;</li> <li>CR-10</li> </ul> <p>I would like to know how this dual voltage operation works:</p> <ul> <li>Does it use both voltages at the same time, or either one or the other? </li> <li>Are there two different electrical inlets or are they the same?</li> <li>Does it auto-detect or are there jumpers used to configure or are the components tolerant to both voltage levels? </li> </ul> <p>Also related:</p> <ul> <li>What is the board used? </li> <li>Is the board a proprietary design or a standard third party board? </li> <li>Does anyone have any photos of the board and/or schematics?</li> </ul>
<p>I own the Ender 3, and it runs on 24V, as this photo of the power supply shows: <a href="https://i.stack.imgur.com/3VrGx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3VrGx.jpg" alt="Ender3 Power supply" /></a></p> <p>From power supply to the board, it uses a 2-wire line connected with a XT60 plug/jack that is common on RC cars: <a href="https://i.stack.imgur.com/uXc5B.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uXc5B.jpg" alt="XT60 connector on Ender3" /></a></p> <p>The board itself is a proprietary design and labeled as &quot;V1.1.2&quot;. The Voltage in is the lowest input on the left: <a href="https://i.stack.imgur.com/xQBpB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xQBpB.jpg" alt="Creality3D V1.1.2" /></a></p> <p>The Cooling fan (blue-yellow wire), the hotend cooling fan, heater cartridge (white shielded), bed heater (left black-red), board cooling fan (middle red-black) run (in this setup) on 24V. The Logic connectors (black-black &amp; White-white) run 5V logic. I could not figure out the voltage of the stepper motors (upper row).</p> <p>I have not figured out how the power management circut works, but it achieves this:</p> <ul> <li>Supply voltage <span class="math-container">$ U_S = 12\ \text V \lor 24\ \text V $</span></li> <li>Logic Voltage <span class="math-container">$ U_L = 5\ \text V $</span></li> <li>Sensor Voltage <span class="math-container">$ U_{sens} = U_L$</span></li> <li>Hotend Cooling Fan <span class="math-container">$ U_{cool} = U_S$</span></li> <li>Hotend Heating Cartridge <span class="math-container">$ U_{hot} = U_S $</span></li> <li>Heatbed <span class="math-container">$ U_{bed} = U_S $</span></li> </ul> <p>The chip's caption can't be read on the photo, but it is labeled as &quot;Δ ATMEL // ATMEGA1284P // AU 1726&quot;</p> <p>For the pinout, a <a href="https://www.chaos-drucker.de/anleitungen-und-tutorials/creality-ender3-mit-marlin-ausstatten/" rel="nofollow noreferrer">german maker</a> did determine, that it the configuration of a <a href="https://github.com/Lauszus/Sanguino" rel="nofollow noreferrer">Sanguino</a> equipped with an Atmega1284P 16Bit works for compiling firmware and flashing via a bootloader.</p>
<p>This answer addresses the input voltage. If you look up the official replacement board at the official Creality store the board features a single pair of connectors next to it says: 12 V / 24 V. So you can either use 12 V, or 24 V, not both. An internal regulator will most probably reduce the voltage anyways. </p> <p><a href="https://i.stack.imgur.com/W1xgl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W1xgl.png" alt="Detail of the replacement board, single 12/24 V power connector is encircled"></a></p> <p>Please note that (kindly reminded by user profesor79 through the comments) that the microprocessor on these boards only use 5 V. So any voltage you supply (12 or 24 V), the voltage regulator will always make sure the microprocessor does not get more than 5 V. However, that does not necessarily apply to all peripherals connected to the board! This should be verified if for the peripherals also a voltage regulator is used. One of my own boards, <a href="https://reprap.org/wiki/RUMBA" rel="nofollow noreferrer">the RUMBA board</a> can be fed by any voltage ranging from 12 V - 35 V, but this also applies to the peripherals like the heater cartridge and the fans! I use the RUMBA with a 24 V power supply, so I need to use 24 V fans heater elements and heat bed.</p>
981
<p>I've seen references to curried functions in several articles and blogs but I can't find a good explanation (or at least one that makes sense!)</p>
<p>Currying is when you break down a function that takes multiple arguments into a series of functions that each take only one argument. Here's an example in JavaScript:</p> <pre class="lang-js prettyprint-override"><code>function add (a, b) { return a + b; } add(3, 4); // returns 7 </code></pre> <p>This is a function that takes two arguments, a and b, and returns their sum. We will now curry this function:</p> <pre class="lang-js prettyprint-override"><code>function add (a) { return function (b) { return a + b; } } </code></pre> <p>This is a function that takes one argument, <code>a</code>, and returns a function that takes another argument, <code>b</code>, and that function returns their sum.</p> <pre class="lang-js prettyprint-override"><code>add(3)(4); // returns 7 var add3 = add(3); // returns a function add3(4); // returns 7 </code></pre> <ul> <li>The first statement returns 7, like the <code>add(3, 4)</code> statement.</li> <li>The second statement defines a new function called <code>add3</code> that will add 3 to its argument. (This is what some may call a closure.)</li> <li>The third statement uses the <code>add3</code> operation to add 3 to 4, again producing 7 as a result.</li> </ul>
<p>There is an example of "Currying in ReasonML". </p> <pre><code>let run = () =&gt; { Js.log("Curryed function: "); let sum = (x, y) =&gt; x + y; Printf.printf("sum(2, 3) : %d\n", sum(2, 3)); let per2 = sum(2); Printf.printf("per2(3) : %d\n", per2(3)); }; </code></pre>
5,696
<p><a href="https://electronics.stackexchange.com/questions/244366/how-do-i-tell-if-my-thermistors-are-10k-or-100k">This question</a> was migrated to electronics.SE. To me the migration makes no sense:</p> <ul> <li><p>The question deals with a problem that is relevant to the users of this site</p></li> <li><p>This site can provide a more specialized answer than electronics.SE can provide: you don't just need to know whether it's a 10k or 100k thermistor, but also figure out the correct thermistor table in your firmware. electronics.SE does not have knowledge of 3D printer firmware, which is the issue underlying this question.</p></li> </ul> <p>Obviously there's some overlap between Arduino/Electronics/3D printing, but what determines whether a question should be migrated?</p>
<p>The question was migrated because the specific question of "<em>How do I tell if my Thermistors are 10k or 100k?</em>" is going to be best answered by users of Electrical Engineering SE. This also provides the SE network with more appropriate traffic based on the question at hand.</p> <p>However, if the question of "<em>How can I change the thermistors settings in Marlin firmware?</em>" were to arise, then the question would be best suited here on 3D Printing. It might help both SE sites by providing links to each other's relevant questions for future users to reference.</p> <p>If the question was something like "<em>How can I wire a hotend?</em>", this would be more appropriate here on 3D Printing SE as users in Electrical Engineering SE may not know as much about the topic compared to users in 3D Printing. This may be a poor example, but the idea is that there is strict correlation between <em>hotends</em> and 3D printing, whereas identifying thermistors is not a specific topic to just 3D printing.</p> <p><strong>Update</strong></p> <p>After reading a few posts on SE meta, <a href="https://meta.stackexchange.com/questions/10249/what-is-migration-and-how-does-it-work">this one</a> leads me to agree with you that this particular question may not have needed to be migrated. However, it exposes an important question of how we want to proceed with questions like this in the future? How far down the rabbit hole do we want to allow this site to go in this topic? I'd recommend others pitch in recommendations in answers here on what would be the appropriate topic in this case that can be applied to our <a href="https://3dprinting.stackexchange.com/help/on-topic">On-Topic</a> page so that it may be amended.</p>
<p>I don't think the question should be migrated. For EE.SE, the question is just stupidly obvious. Even a fairly inexperienced lab tech. would know how to go about answering that question. It really isn't an electronic engineering question at all.</p> <p>Here, the answer (assuming the question is actually the question that the user needed to ask) would be 'buy the cheapest meter you can find', or 'buy both, you might not make much use of a cheap meter anyway'. Context makes a big difference.</p>
32
<p>I have spent ages debugging this problem but I can't figure out what I am doing wrong.</p> <p>I have a Wanhao duplicator i3 (Prusa i3 clone) and until recently I used Wanhao's adapted version of the Cura slicer. But it's quite an old Cura version and I wanted to make use of the improved supports in the new Cura.</p> <p>Unfortunately it seems like I just can't get the infill in the newest Cura to work. I copied all the settings from my Wanhao branded Cura version and printed the same file.</p> <p><strong>This is the result:</strong></p> <p><a href="https://i.stack.imgur.com/RJPkN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RJPkN.jpg" alt="Infill of tiny pillars"></a></p> <p>The infill is shaped like many tiny pillars. They are super fragile and while they do support material to be printed on top, they hardly withstand any pressure.</p> <p>I have gone through quite a few testing cubes each with some setting altered, but nothing seemed to help.</p> <p>It can't be the printers fault as I have successfully printed test cubes sliced with the old Cura in between (and not only once). Increasing temperature or slowing down the infill didn't help either. Neither did increasing flow rate or switching to triangular infill pattern. Also I have tried printing with all speeds set to 50mm/s and it still failed.</p> <p><strong>My standard settings</strong> <em>(from which I have created many test cubes with each cube having some settings tweaked)<strong></em>:</strong></p> <pre><code>Layer Height: 0.12 mm Init. Layer Height: 0.10 mm Wall Line Count: 2 Top Layers: 6 Bottom Layers: 4 Infill Line distance: 5 mm (used to be 20 % in old Cura, but this is very dense in the new Cura) Infill Pattern: Lines Infill Overlap Percentage: 20 % Printing Temperature: 200 °C Build Plate Temperature: 60 °C Retraction: Enabled, Distance: 2 mm, Speed: 60 mm/s Speeds: Print:60 mm/s, Infill: 60 mm/s, Outer Wall: 30 mm/s, Inner Wall: 60 mm/s, Top/Bottom: 40 mm/s, Travel: 100 mm/s, Initial Layer: 20 mm/s Combing Mode: All </code></pre>
<p>This problem is most commonly caused by infill speeds which are too high.</p> <p>Instead of printing lines, the filament is caught on one of the lines of the previous layer, leaves a blob there and only restarts extrusion when it hits the next line. Instead of extruding continuously the filament comes out in blobs at the locations where there's filament on the previous layer.</p> <p>You can have good infill up to some layer and suddenly start getting this problem as of some layer. When the problem occurs the next layer is more likely to show the problem. It's snowballing.</p>
<p>I am using the same printer (v1.2) with some upgrades and have been using the latest Ultimaker Cura (4.1) ever since they came out. For the first few prints I used an imported Ultimaker Cura profile, but after 3-4 bad prints I created a new profile from scratch, using a percentage for infill, with no problems at all.</p>
637
<p>Since I'm running a 3D printing facility of an engineering school, students are always wondering how much infill percentage affects the stiffness of the part. I know that it is impossible to get a numerical solution for this question, but maybe there is an option to simulate in software an already sliced model. I haven't seen in any slicer an option to export as .stl or .step or any other format which can be accepted by simulation software. Has anyone seen or thought about something similar? </p>
<p>I don't believe that slicing engines create any sort of solid model that would be useful for CAD simulation. When a slicing engine slices a 3D model, it's goal is to spit out the preferred machine paths in G-Code (of some kind). However, I've read a few articles, done some tests, and heard through the grape vine that anywhere between 10%-35% is good enough for most applications. I once watched a webinar for understanding the new MakerWare interface that explained how they chose such settings. Although I can't find the clip directly, <a href="http://www.makerbot.com/resources/webinars" rel="nofollow">here</a> is the page for all of MakerBot's webinars. I think <a href="http://pages.makerbot.com/intro-makerbot-desktop-software-webinar.html?utm_source=leadgen&amp;utm_medium=resource-center&amp;utm_content=webinar&amp;utm_campaign=rc-intro-makerbot-desktop-webinar" rel="nofollow">this</a> webinar was the one I watched explaining a little bit about preferred infill percentages.</p> <p>From experience, anything over 35% doesn't yield much more strength from infill side of things. Beyond 35% and you're going to want to reconsider how you're orienting the print when you print it and what you're printing to utilize the grain structure for proper strength.</p> <p>However, infill percentage/patterns are not the only variable for creating strong parts. Infill is really just a way to save time and material. Here are some other ways to potentially increase strength:</p> <ul> <li>Increase your shell. Shell is the number of profile patterns per layer. Typically (in FDM/FFF), each shell is <strong>about</strong> the diameter of your extruder nozzle.</li> <li>Increase your floor/roof. Similar to shell, floor/roof refers to the number of layers that make up the "bottom" and "top" of the part with regard to the build plate.</li> <li>Print orientation. Pay attention to which areas of the part are susceptible to strain along the "grain" of the layers. Try to rotate your part on the build plate in a way that minimizes potential failure both in print and post-print use.</li> <li>Post process. Don't be afraid to do some post-processing to increase the strength. There are <a href="https://markforged.com/" rel="nofollow">some 3D printers on the market</a> that go as far as including Kevlar strands in the printing process to beef up their prints. However, it may be as simple as just coating the part in an epoxy with some basic finishing techniques. It's a bit more work, but it turns weak 3D printed parts into full production quality prints.</li> </ul> <p><strong>Update:</strong> Based on some of the comments, it sounds like your best bet might be to find a custom application that can either convert the g-code file into a solid model (try CAM software?), or create a plugin for your CAD software (I know Unigraphics NX and Solidworks allow for this) and essentially recreate your own slicing engine that takes your solid model and generates the same infill pattern dynamically inside.</p> <p>Perhaps look into the works of <a href="http://www.simlab-soft.com/index.aspx" rel="nofollow">Simlab</a> or similar which has a lot of 3D software plugins. I'm not promoting them and I don't work for them, this is just a reference of what to look for.</p>
<p>If you're an engineering class, you may very well print out big cubes of different infils and test them. </p>
266
<p>I have a tree representation of pages in a CMS application. I understand how to persist the tree in the database. However, I don't have a good way to:</p> <p>A) Reorder subpages under a particular parent page.<br> B) Provide a UI implementation that allows the user to change the order.</p> <p>Any suggestions?</p>
<p><a href="http://www.javaworld.com/javaworld/jw-12-2004/jw-1220-toolbox.html" rel="nofollow noreferrer">Write custom appenders for log4j</a></p>
<p>May I suggest that you leverage the existing SyslogAppender?</p>
6,934
<p>I recently installed Windows 2008 Server to replace a crashed hard drive on a web server with a variety of web pages including several classic ASP applications. One of these makes extensive use of file uploads using a com tool that has worked for several years.</p> <p>More information: </p> <p>My users did not provide good information in that very small zips (65K) work once I tested it myself, but larger ones do not. I did not test for the cut-off, but 365K fails. And it is not only zip files after all. A 700K doc file failed also. ErrorCode 800a0035.</p>
<p>There is a size limit that you will probably need to set - what's the 500 error?</p>
<p>There is a size limit that you will probably need to set - what's the 500 error?</p>
9,519
<p>What is the best way to transparently rewrite a URL over an SSL connection with Apache 2.2?</p> <p>Apache 2 does not natively support multiple name-based virtual hosts for an SSL connection and I have heard that mod_rewrite can help with this. I would like to do something like this:</p> <p>I have set up the server so that the sites can be accessed by</p> <p><a href="https://secure.example.com/dbadmin" rel="nofollow noreferrer">https://secure.example.com/dbadmin</a></p> <p>but I would like to have this as <a href="https://dbadmin.example.com" rel="nofollow noreferrer">https://dbadmin.example.com</a></p> <p>How do I set it up so that the Rewrite rule will rewrite dbadmin.example.com to secure.example.com/dbadmin, but without displaying the rewrite on the client's address bar (i.e. the client will still just see dbadmin.example.com), all over https?</p>
<p>Configure a single VirtualHost to serve both secure.example.com and dbadmin.example.com (making it the only *:443 VirtualHost achieves this). You can then use <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="nofollow noreferrer">mod_rewrite</a> to adjust the URI for requests to dbadmin.example.com:</p> <pre><code>&lt;VirtualHost *:443&gt; ServerName secure.example.com ServerAlias dbadmin.example.com RewriteEngine on RewriteCond %{SERVER_NAME} dbadmin.example.com RewriteRule !/dbadmin(.*)$ /dbadmin$1 &lt;/VirtualHost&gt; </code></pre> <p>Your SSL certificate will need to be valid for both secure.example.com and dbadmin.example.com. It can be a wildcard certificate as mentioned by Terry Lorber, or you can use the <a href="http://wiki.cacert.org/wiki/VhostTaskForce#A1.Way.3ASubjectAltNameOnly" rel="nofollow noreferrer">subjectAltName</a> field to add additional host names.</p> <p>If you're having trouble, first set it up on <code>&lt;VirtualHost *&gt;</code> and check that it works without SSL. The SSL connection and certificate is a separate layer of complexity that you can set up after the URI rewriting is working.</p>
<p>There is apaches mod_rewrite, or you could setup apache to direct <a href="https://dbadmin.example.com" rel="nofollow noreferrer">https://dbadmin.example.com</a> to path/to/example.com/dbadmin on the server</p> <pre><code>&lt;VirtualHost *&gt; ServerName subdomain.domain.com DocumentRoot /home/httpd/htdocs/subdomain/ &lt;/VirtualHost&gt; </code></pre>
2,979