instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I have IIS 5.1 installed on Windows XP Pro SP2. Besides I have installed VS 2008 Express with .NET 3.5. So obviously IIS is configured for ASP.NET automatically for .NET 3.5</p> <p>The problem is whenever I access <a href="http://localhost" rel="noreferrer">http://localhost</a> IE &amp; Firefox both presents authentication box. Even if I enter Administrator user and its password, the authentication fails. I have already checked the anonymous user access (with IUSR_ user and password is controlled by IIS) in Directory Security options of default website.</p> <p>However other deployed web apps work fine (does not ask for any authentication).</p> <p>In IE this authentication process stops if I add <a href="http://localhost" rel="noreferrer">http://localhost</a> in Intranet sites option.</p> <p>Please note that the file system is FAT32 when IIS is installed.</p> <p>Regards, Jatan</p>
<p>This is most likely a NT file permissions problem. IUSR_ needs to have file system permissions to read whatever file you're requesting (like /inetpub/wwwroot/index.htm).<p>If you still have trouble, check the IIS logs, typically at \windows\system32\logfiles\W3SVC*.</p>
<p>What worked for me is ,,,</p> <p>Click Start>control panel>Administrative Tools>Internet Information Services</p> <p>Expand the left tree, right-click your WebSite>Properties</p> <p>Click on Directory Security, then in "Anonymous access and authentication control" click on Edit</p> <p>Enable Anonymous access>browse> enter the credentials of the admin (like Administrator) (check names),> Click OK</p> <p>Apply the settings and it should work fine.</p>
7,691
<p>I have an existing application that is written in C++ for Windows. This application uses the Win32 CryptoAPI to generate a TripleDES session key for encrypting/decrypting data. We're using the <a href="http://www.phdcc.com/cryptorc4.htm" rel="nofollow noreferrer">exponent of one trick</a> to export the session key out as a blob, which allows the blob to be stored somewhere in a decrypted format.</p> <p>The question is how can we use this in our .NET application (C#). The framework encapsulates/wraps much of what the CryptoAPI is doing. Part of the problem is the CryptAPI states that the TripleDES algorithm for the <a href="http://msdn.microsoft.com/en-us/library/aa386986(VS.85).aspx" rel="nofollow noreferrer">Microsoft Enhanced Cryptographic Provider</a> is 168 bits (3 keys of 56 bits). However, the .NET framework states their keys are 192 bits (3 keys of 64 bits). Apparently, the 3 extra bytes in the .NET framework is for parity?</p> <p>Anyway, we need to read the key portion out of the blob and somehow be able to use that in our .NET application. Currently we are not getting the expected results when attempting to use the key in .NET. The decryption is failing miserably. Any help would be greatly appreciated. </p> <h2>Update:</h2> <p>I've been working on ways to resolve this and have come up with a solution that I will post in time. However, still would appreciate any feedback from others.</p>
<h2>Intro</h2> <p>I'm Finally getting around to posting the solution. I hope it provides some help to others out there that might be doing similar type things. There really isn't much reference to doing this elsewhere.</p> <h2>Prerequisites</h2> <p>In order for a lot of this to make sense it's necessary to read the <a href="http://www.phdcc.com/cryptorc4.htm" rel="nofollow noreferrer"><em>exponent of one trick</em></a>, which allows you to export a session key out to a blob (a well known byte structure). One can then do what they wish with this byte stream, but it holds the all important key.</p> <h2>MSDN Documentation is Confusing</h2> <p>In this particular example, I'm using the <a href="http://msdn.microsoft.com/en-us/library/aa386986(VS.85).aspx" rel="nofollow noreferrer">Microsoft Enhanced Cryptographic Provider</a>, with the Triple DES (<a href="http://msdn.microsoft.com/en-us/library/aa382020(VS.85).aspx" rel="nofollow noreferrer">CALG_3DES</a>) algorithm. The first thing that threw me for a loop was the fact that the key length is listed at 168 bits, with a block length of 64 bits. How can the key length be 168? Three keys of 56 bits? What happens to the other byte? </p> <p>So with that information I started to read elsewhere how the last byte is really parity and for whatever reason CryptoAPI strips that off. Is that really the case? Seems kind of crazy that they would do that, but OK.</p> <h2>Consumption of Key in .NET</h2> <p>Using the <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.tripledescryptoserviceprovider(VS.80).aspx" rel="nofollow noreferrer">TripleDESCryptoServiceProvider</a>, I noticed the remarks in the docs indicated that:</p> <blockquote> <p>This algorithm supports key lengths from 128 bits to 192 bits in increments of 64 bits.</p> </blockquote> <p>So if CryptoAPI has key lengths of 168, how will I get that into .NET which supports only supports multiples of 64? Therefore, the .NET side of the API takes parity into account, where the CryptoAPI does not. As one could imagine... <em>confused was I</em>.</p> <p>So with all of this, I'm trying to figure out how to reconstruct the key on the .NET side with the proper parity information. Doable, but not very fun... let's just leave it at that. Once I got all of this in place, everything ended up failing with a CAPITAL <strong>F</strong>. </p> <p>Still with me? Good, because I just fell off my horse again.</p> <h2>Light Bulbs and Fireworks</h2> <p>Low and behold, as I'm scraping MSDN for every last bit of information I find a conflicting piece in the Win32 <a href="http://msdn.microsoft.com/en-us/library/aa379931(VS.85).aspx" rel="nofollow noreferrer">CryptExportKey</a> function. Low and behold I find this piece of invaluble information:</p> <blockquote> <p>For any of the DES key permutations that use a PLAINTEXTKEYBLOB, only the full key size, including parity bit, may be exported. The following key sizes are supported.</p> <p>Algorithm Supported key size </p> <p>CALG_DES 64 bits </p> <p>CALG_3DES_112 128 bits </p> <p>CALG_3DES 192 bits </p> </blockquote> <p>So it does export a key that is a multiple of 64 bits! Woohoo! Now to fix the code on the .NET side.</p> <h2>.NET Import Code Tweak</h2> <p>The byte order is important to keep in mind when importing a byte stream that contains a key that was exported as a blob from the CryptoAPI. The two API's do not use the same byte order, therefore, as <a href="https://stackoverflow.com/questions/49211/how-can-i-use-a-key-blob-generated-from-win32-cryptoapi-in-my-net-application#49232">@nic-strong</a> indicates, reversing the byte array is essential before actually trying to use the key. Other than that, things work as expected. Simply solved:</p> <pre><code>Array.Reverse( keyByteArray ); </code></pre> <h2>Conclusion</h2> <p>I hope this helps somebody out there. I spent way too much time trying to track this down. Leave any comments if you have further questions and I can attempt to help fill in any details. </p> <p>Happy Crypto!</p>
<p>Ok, forget the last answer I can't read :) You are working with 3Des keys not RSA keys.</p> <p>I worked on a bunch of code to share keys between .NET, CryptoAPI and openssl. Found a lot of good example code here for doing the key conversions: </p> <p><a href="http://www.jensign.com/JavaScience/cryptoutils/index.html" rel="nofollow noreferrer">http://www.jensign.com/JavaScience/cryptoutils/index.html</a></p> <p>There is some 3des stuff in some of those examples, but it was related to openssl -> .NET iirc.</p> <p>I also just looked back over the RSA key code and one thing I notice I am doing is using Array.Reverse() on all the key parts of the RSA key (D,DP,DQ,InverseQ,Modulus,P,Q) i guess to convert endian. I remember that being non-obvious when first tackling the problem.</p> <p>Hope some of that helps. Good luck.</p>
7,169
<p>Faulty endstop caused the printer (a traditional cartesian FDM) to try to move over the maximum axis limit at top, the noise has been atrocious, I don't see damages (apparently) but I'm wondering if this could have damaged something or the motors aren't strong enough to do any serious physical damage to mechanics of movement.</p> <p>Could you clarify this?</p>
<p>It's highly unlikely this crash caused any physical or electrical damage to your printer. Printers are designed to be able to withstand an occasional crash as typically, no Axis Maximum endstops are installed. The 'atrocious' noise you describe hearing is the sound of the stepper motor having lost (or, in this case, repeatedly losing) steps. If you are worried, I would check that the X/Y Gantries are still in-tram and that the printer can still home itself without any problems.<br /> If this was a Z-Max runout (ie, printer tried to move too high), I would also check that the Z carriage is still on the Z axis Leadscrews before attempting to home, because if the Z carriage is not on one or both of the leadscrews, It is possible for the machine to engage them at different heights, throwing the X gantry out of tram or worse if only one leadscrew manages to re-engage.</p>
<p>The noise you heard was likely caused by the extruder keeping turning, resulting in the belt stretching enough to jump a tooth or more. I guess it was like &quot;TRRRRR&quot;.</p> <p>If the belt tension is properly set (not too tight), no damage can be caused. In fact, the belt should be loose enough so that such a mistake won't cause damages.</p> <p>You could also reduce the current to the stepper motors in the future, to reduce even further the risk of damage.</p>
2,085
<p>I am re-writing this question because, well, it needs to be updated.</p> <p>I have the Anet A6, but in a general sense of things, what kind of threads can I produce before it no longer works? </p>
<p>This depends on the nozzle diameter, the layer thickness, and the material. </p> <p>I've made very good M8 and acceptable M6 threads (nut and bolt) at 0.2mm layers with a 0.5mm nozzle, out of ABS, and also out of PETG. </p>
<p>I have found that I get slightly different results with different printers and different plastics and print temperatures. For doing parts like nuts and bolts you will probably have to print several prototype parts once you get your printer to get the setting and tolerances right, once you get a print. But just decreasing the layer height and getting the nozzle temp and cooling right should let you get some working parts. <a href="https://i.stack.imgur.com/WUcio.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WUcio.png" alt="Slope failure"></a> You can get the sloped surfaces the still look ok but are not dimensional accurate with to high an angle. I find if is easiest to print and then test and then adjust the tolerances on the design. <a href="https://i.stack.imgur.com/rvkGA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rvkGA.png" alt="enter image description here"></a></p>
710
<p>Would using WSDualHttpBinding for duplex callbacks work in real-world scenarios? Say, I have a .NET application that uses a random port, would the service be able to resolve the client's base addresses and port for callbacks?</p>
<p>A complete answer to your question depends on the "real-world scenario" being either an Intranet or an Internet scenario. Although WSDualHttpBinding works in both scenarios there are specifics to be aware of:</p> <p><strong>Intranet</strong></p> <p>WSDualHttpBinding will work with your .NET application using a preconfigured custom port in an Intranet scenario and "Yes" the service will be able to resolve the client's base addresses and port for callbacks: exactly how is explained below. The reason it's explained below is that WSDualHttpBinding is primarily designed to be used over the Internet.</p> <p>Duplex callbacks in an Intranet scenario when you can use WCF on both client and server is best achieved by using NetTcpBinding or NetNamedPipeBinding. These bindings use TCP and ICP respectively as transport (rather than HTTP) and a custom binary encoding which is why WCF is required on both sides. For calls-back to the client the same channel used to connect to the Service via the Binding is re-used without requiring a new port to be opened.</p> <p><strong>Internet</strong></p> <p>In an Internet scenario valid HTTP requests and responses only travel in one direction, HTTP is designed as a one-way protocol. When using the WSDualHttpBinding WCF therefore creates a seperate HTTP channel for callbacks. In answer to your second question: the destination address for this call-back to the client is composed of the client machine hostname and port 80 by default. If the client is a development machine for example and has IIS installed, port 80 will be exclusively reserved in some scenarios which will cause conflicts with your prototype application. This is what <a href="http://blogs.msdn.com/wenlong/archive/2006/10/19/how-to-use-wsdualhttpbinding-on-windows-xp-for-hosted-services.aspx" rel="noreferrer">this blog post</a> presents a solution for and what the ClientBaseAddress property is designed to help with. Regardless of which port you go with - the default or a custom one, you must ensure all firewalls and routers on both sides are configured correctly to allow both the outgoing channel and the seperate callback channel to be established.</p> <p>A .NET application can also denote a Silverlight application. Because of the fact that a Silverlight application running in a browser cannot accept new incoming HTTP connections, WSDualHttpBinding with it's seperate back channel will not work. Hence PollingDuplexHttpBinding was created firstly in Silverlight 2 which can be thought of as a clever 'trick' to get around the fact that HTTP is unidirectional by keeping the request channel open for a long time (long polling) and using it as a back channel for calls back to the client. This has a number of implications on both the client and server side particularly relevant to scaling, for more detail please see <a href="http://petermcg.wordpress.com/2008/09/03/silverlight-polling-duplex-part-1-architecture/" rel="noreferrer">this post from my blog</a>.</p> <p>With an idea of your particular "real-world scenario" and your use-cases hopefully this will help you work out the correct binding to use for duplex callbacks.</p>
<p>If it's an application behind a firewall, theoretically yes. It depends on what you mean by "real world"; if by that you mean "high performance" perhaps NetTcpBinding is a better appraoch.</p>
8,435
<p>I recently discovered this kit after reading this Instructables, <a href="https://www.instructables.com/id/Adding-More-Extruders-to-Any-3d-Printer/" rel="nofollow noreferrer">Adding More Extruders to Any 3d Printer</a>: </p> <blockquote> <p><a href="https://i.stack.imgur.com/Lq4uQ.png" rel="nofollow noreferrer" title="New CNC Shield v3 engraving machine / 3D Printer / + 4pcs A4988/DRV8825/AT2100 Driver Expansion Board for Arduino"><img src="https://i.stack.imgur.com/Lq4uQ.png" alt="CNC Shield v3 engraving machine / 3D Printer / + 4pcs A4988/DRV8825/AT2100 Driver Expansion Board for Arduino" title="New CNC Shield v3 engraving machine / 3D Printer / + 4pcs A4988/DRV8825/AT2100 Driver Expansion Board for Arduino"></a></p> </blockquote> <p>I'm pretty sure I can use this kit with my board since it uses the same drivers as mine. But that's for motors, not fans. And while I know G-code pretty well, I'm not sure how I would use this to activate and deactivate a fan from G-code. There is probably a better way to do this.</p> <p>The board I am using is from an FLSUN Large Scale 3D printer. Here is a picture of the board: </p> <p><a href="https://i.stack.imgur.com/Bq8w1.jpg" rel="nofollow noreferrer" title="FLSUN printer board"><img src="https://i.stack.imgur.com/Bq8w1.jpg" alt="FLSUN printer board" title="FLSUN printer board"></a></p> <p>There appears to be only one labeled pin for the fan. BUT even if there are other pins that I don't recognize, they would have to be controlled by a micro controller (G-code commands). There appear to be a bunch of un-used pins in the bottom right of the board. But if this board just can't do it, there is a newer board here: [link removed]. </p> <p>It does seem like it is using Arduino and the newer board might have extra pins for a fan. But at that point, would it be easier (cheaper) to just control the fan from the extruder extender kit? Would I just set it as an extruder with a really high filament extrusion speed and send appropriate G-code commands when needed to run it at max voltage?</p> <p>I know on my Lulzbot Mini there is a "parts cooling" fan which allows you to cool off the layers as your structure rises vertically. This is a fan I want. The parts cooling fan <em>must</em> be controlled by the micro controller. It only comes on when printing vertically.</p> <p>I would like to actually add two fans like this to my 3D printer. One of them is a >= 5&nbsp;V cooling fan like above. Another is a regular 12&nbsp;V cooling fan for an extra extruder that I am adding.</p>
<p>The <a href="http://www.robotrebels.org/index.php?topic=769.0" rel="nofollow noreferrer">MKS Gen L v1.0</a> Board you are using does support microcontroller controlled fans without doing some surface level modification to the board via the <code>D9/FAN</code>. The port you marked FAN is not a controllable port, it runs a direct 12/24&nbsp;V all the time and should be used for the Hotend cooling solution. The ports <code>D7/HE1</code> and <code>D10/HE0</code> are for two hotendes, corresponding to <code>E0</code> and <code>E1</code>.</p> <p><a href="https://i.stack.imgur.com/YlGDW.png" rel="nofollow noreferrer" title="MKS Gen L port/pin layout"><img src="https://i.stack.imgur.com/YlGDW.png" alt="MKS Gen L port/pin layout" title="MKS Gen L port/pin layout"></a></p> <h2>Variant A: Swappy Fans</h2> <p>This is the more tricky variant and does need both coding and wiring expertise.</p> <p>You'll have to run both hotend cooling fans via that one port in the top left corner. Make sure they are running fast enough to keep the heatsinks cool and prevent heat creep!</p> <p>Your <strong>custom</strong> Firmware will have to define <code>D9</code> as a microcontroller controlled Fan instead of a 100&nbsp;% running fan as the normal firmware is most likely.</p> <p>Without extra hardware, you can't get 2 individually controllable ports from <code>D9</code>, but you can use, the fact that you don't want part cooling for a hotends in 'resting' position. So a pair of couple Normally Closed switches cab achieve disabling of the resting hotend's part cooling fan:</p> <ul> <li>make a wire splitter for D9, so that you have both <code>+</code> and both <code>-</code>-wires connect to the one <code>+</code>/<code>-</code>-pin on the board. You'll have the part cooling fans in parallel now. <ul> <li>Do the same for the Hotend Cooling Fans!</li> </ul></li> <li>connect each <code>+</code>-line to a Normally Closed switch, which is installed on the hotend in a way so it triggers and opens the line if the hotend is in the resting (homing) position.</li> <li>As the line connects when the hotend moves into the build volume, the part cooling fan on the currently active hotend starts to spin while the one of the non-active hotend is isolated.</li> </ul> <h2>Variant B: MOSFETs and Safety</h2> <p>An alternate source for the part cooling fan signals might be the SERVOS1/SERVOS2 group, where <code>D4</code> to <code>D6</code> and <code>D11</code> are accessible. This leaves the FAN and top-left 12 V pinnings free for the hotend cooling. The downside is, that these pins don't likely provide 12 V but at best a 5 V digital output. However, a 0 to 5 V signal can be used to control a separate MOSFET which outputs 0 to 12 V, which then can power the part cooling fans. Due to the power draw of the Fans, a simple step-up converter is not a solution it needs a separate power supply.</p> <p>The Main benefit is, that this does draw less power from the board than Variant A and does not re-pin <code>D9</code>. The "Cooling Fan Board" could use a 6-line ribbon cable to connect to the <code>SERVOS1</code> pins, using the 5V as reference for the MOSFETs, <code>D4</code>/<code>D5</code> as the trigger signal and GND as return lines.</p> <p>A pre-assembled board that could serve in this position would be a <a href="https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/" rel="nofollow noreferrer">L298N Driver</a>. Due to how it is set up, one could run both part cooling fans, if their speed is set up to be always equal.</p>
<p>You can use the <code>M42</code> g-code to manually set any supported digital pin, which can then be used to either enable one of the on-board MOSFETs (D7, D8, D9, D10) or an external MOSFET. For example, <code>M42 P9 S255</code> would enable the parts cooling fan at 100&nbsp;%.</p> <p>You should never run any fan or heater directly off of a microcontroller pin (the ATmega2560 on your board supports up to <strong>40&nbsp;mA</strong>. Standard 5&nbsp;V fans I found online tend to draw <strong>100&nbsp;mA</strong> or more).</p> <p>Your board supports up to four switchable "power" outputs - bed, heater 0, heater 1 and FAN. Depending on what you use so far, one of those may be usable for your fans.</p> <p>Note that on-board MOSFETs usually switch the ground side of the connected device. This means that you for your 12&nbsp;V fan, you can connect it directly to one of those connectors. The 5&nbsp;V would have to receive +5&nbsp;V from elsewhere (like the +5&nbsp;V pins near the bottom right mounting hole), but you can still control the fan by connecting its ground lead over one of the on-board MOSFETs.</p> <p>If four MOSFETs are not enough for you, the L298N module provides an easy way to control four additional fans, while using normal digital pins to control the L298N.</p>
1,397
<p>This is a follow up question for <a href="https://3dprinting.stackexchange.com/q/20196/20803">What are viable substitutes for Raspberry Pi to run Octoprint or similar software for Prusa i3 MK3S+?</a></p> <p>I was able to grab Raspberry Pi 400 for around $70, so <a href="https://www.raspberrypi.com/news/raspberry-pi-400-the-70-desktop-pc/" rel="nofollow noreferrer">at MSRP</a>, and about half of the current pi 4b prices nowadays. Good deal given shortages, so I ordered it when it was available, and only now I started to think if I can really use it.</p> <p>Thus, are there any special challenges to using Raspberry Pi 400 as OctoPrint server, and does it have any benefits over regular Pi 4B? Is there any ready-made manual about it I could use?</p>
<p>The recommended hardware for OctoPi is <a href="https://octoprint.org/download/" rel="nofollow noreferrer">listed</a> as:</p> <blockquote> <p>Recommended hardware: Raspberry Pi 3B, 3B+, 4B or Zero 2. Expect print artifacts and long loading times with other options, especially when adding a webcam or installing third-party plugins.</p> </blockquote> <p>Now if we compare the specification of the two Pi units:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Raspberry Pi</th> <th>Processor</th> <th>RAM</th> </tr> </thead> <tbody> <tr> <td><a href="https://www.raspberrypi.com/products/raspberry-pi-400-unit/" rel="nofollow noreferrer">400</a></td> <td>BCM2711 quad-core Cortex-A72 @ 1.8GHz</td> <td>4GB LPDDR4-3200</td> </tr> <tr> <td><a href="https://www.raspberrypi.com/products/raspberry-pi-4-model-b/specifications/" rel="nofollow noreferrer">4B</a></td> <td>BCM2711 quad-core Cortex-A72 @ 1.5GHz</td> <td>1GB, 2GB, 4GB, 8GB LPDDR4-3200</td> </tr> </tbody> </table> </div> <p>So they are very close in capabilities. The 4B has a slightly slower processor but does have the ability to have more RAM. The 400 does come with a keyboard but its feasibility would depend on your usage (probably not much for OctoPi).</p> <p>Given the slight disparity in specs, the Raspberry Pi 400 should work fine for OctoPi.</p>
<p>While the server will work, there are some challenges.</p> <p>Raspberry Pi 400 lacks the camera and screen connectors, specifically:</p> <ul> <li>2-lane MIPI DSI display port</li> <li>2-lane MIPI CSI camera port</li> </ul> <p>so you can't use Pi screens and camera modules. You need to find compatible USB webcam if you want to make time lapse of your print or stream your build to oversee it. If you want to add a touch screen, you need to use HDMI+USB one, as most of the screens dedicated for Pi won't work without DSI port.</p> <p>Pi 4b has:</p> <ul> <li>2 × USB 3.0 ports</li> <li>2 × USB 2.0 ports</li> </ul> <p>Pi 400:</p> <ul> <li>2 × USB 3.0</li> <li>1 × USB 2.0</li> </ul> <p>One of these will be, of course, occupied by the printer, so if you want to connect a touchscreen and webcam, with 4b you still have up to three usb ports free, when with 400 you are all out.</p> <p>Built-in keyboard is somewhat redeeming quality, especially if you are old time console jockey and don't need a mouse or touchscreens, and 20% faster CPU is nothing to sneeze at if you want to use AI plugin to oversee your print. For end users not interested in any kind of hardware hacking, 400 being already assembled with case and cooling is a great benefit, too.</p> <p><strong>In summary</strong>: it's compatible, faster and more convenient for end users, but less hackable. It's also significantly cheaper during 2022/2023 Pi Shortage, sometimes being available at MSRP and in stock.</p>
2,229
<p>Disclaimer: Near zero with marshalling concepts..</p> <p>I have a struct B that contains a string + an array of structs C. I need to send this across the giant interop chasm to a COM - C++ consumer.<br> <strong>What are the right set of attributes I need to decorate my struct definition ?</strong> </p> <pre><code>[ComVisible (true)] [StructLayout(LayoutKind.Sequential)] public struct A { public string strA public B b; } [ComVisible (true)] [StructLayout(LayoutKind.Sequential)] public struct B { public int Count; [MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.Struct, SizeParamIndex=0)] public C [] c; } [ComVisible (true)] [StructLayout(LayoutKind.Sequential)] public struct C { public string strVar; } </code></pre> <p>edit: @Andrew Basically this is my friends' problem. He has this thing working in .Net - He does some automagic to have the .tlb/.tlh created that he can then use in the C++ realm. Trouble is he can't <strong>fix</strong> the array size.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms379617%28VS.80%29.aspx#vs05cplus_topic12" rel="nofollow noreferrer">C++: The Most Powerful Language for .NET Framework Programming</a></p> <p>I was about to approach a project that needed to marshal structured data across the C++/C# boundary, but I found what could be a better way (especially if you know C++ and like learning new programming languages). If you have access to Visual Studio 2005 or above you might consider using C++/CLI rather than marshaling. It basically allows you to create this magic hybrid .NET/native class library that's 100% compatible with C# (as if you had written everything in C#, for the purposes of consuming it in another C# project) that is also 100% compatible with C and/or C++. In your case you could write a C++/CLI wrapper that marshaled the data from C++ in memory to CLI in memory types.</p> <p>I've had pretty good luck with this, using pure C++ code to read and write out datafiles (this could be a third party library of some kind, even), and then my C++/CLI code converts (copies) the C++ data into .NET types, in memory, which can be consumed directly as if I had written the read/write library in C#. For me the only barrier was syntax, since you have to learn the CLI extensions to C++. I wish I'd had StackOverflow to ask syntax questions, back when I was learning this!</p> <p>In return for trudging through the syntax, you learn probably the most powerful programming language imaginable. Think about it: the elegance and sanity of C# and the .NET libraries, and the low level and native library compatibility of C++. You wouldn't want to write all your projects in C++/CLI but it's great for getting C++ data into C#/.NET projects. It "just works."</p> <p>Tutorial:</p> <ul> <li><a href="http://www.codeproject.com/KB/mcpp/cppcliintro01.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/mcpp/cppcliintro01.aspx</a></li> </ul>
<p>The answer depends on what the native definitions are that you are trying to marshal too. You haven't provided enough information for anyone to be able to really help.</p> <p>A common thing that trips people up when marshalling strings in native arrays is that native arrays often use a fixed-size buffer for the string that is allocated inline with the struct. Your definition is marshalling the strings as a pointer to another block of memory containing the string (which is the default).</p> <p>[MarshalAs(UnmanagedType.ByValTStr, SizeConst = ##)] might be what you are looking for...</p>
5,176
<p>Does the Java language have delegate features, similar to how C# has support for delegates?</p>
<p>Not really, no.</p> <p>You may be able to achieve the same effect by using reflection to get Method objects you can then invoke, and the other way is to create an interface with a single 'invoke' or 'execute' method, and then instantiate them to call the method your interested in (i.e. using an anonymous inner class).</p> <p>You might also find this article interesting / useful : <a href="https://web.archive.org/web/20210225165533/https://www.blueskyprojects.com/print-design/" rel="nofollow noreferrer">A Java Programmer Looks at C# Delegates (@blueskyprojects.com)</a></p>
<p>Java doesn't have delegates and is proud of it :). From what I read here I found in essence 2 ways to fake delegates: 1. reflection; 2. inner class</p> <p>Reflections are slooooow! Inner class does not cover the simplest use-case: sort function. Do not want to go into details, but the solution with inner class basically is to create a wrapper class for an array of integers to be sorted in ascending order and an class for an array of integers to be sorted in descending order.</p>
6,668
<p>I'm learning XML, currently of Wikibooks, but that is kinda huge and not oversee-able...</p> <p>anybody know a better place?</p>
<p><a href="http://www.w3schools.com/xml/default.asp" rel="noreferrer">W3Schools</a> are generally good for this type of stuff.</p>
<p>Even though there are plenty of tutorials about XML , I agree with Galwegian . I learned XML from <a href="http://www.w3schools.com/xml/default.asp" rel="nofollow noreferrer">W3Schools</a>.</p>
9,709
<p>I have a generic Repository&lt;T&gt; class I want to use with an ObjectDataSource. Repository&lt;T&gt; lives in a separate project called DataAccess. According to <a href="http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/767f1a821d9b23da/b1e045958ae427a5?lnk=st#b1e045958ae427a5" rel="noreferrer">this post from the MS newsgroups</a> (relevant part copied below):</p> <blockquote> <p>Internally, the ObjectDataSource is calling Type.GetType(string) to get the type, so we need to follow the guideline documented in Type.GetType on how to get type using generics. You can refer to MSDN Library on Type.GetType:</p> <p><a href="http://msdn2.microsoft.com/en-us/library/w3f99sx1.aspx" rel="noreferrer">http://msdn2.microsoft.com/en-us/library/w3f99sx1.aspx</a></p> <p>From the document, you will learn that you need to use backtick (`) to denotes the type name which is using generics.</p> <p>Also, here we must specify the assembly name in the type name string.</p> <p>So, for your question, the answer is to use type name like follows:</p> <p>TypeName="TestObjectDataSourceAssembly.MyDataHandler`1[System.String],TestObjectDataSourceAssembly"</p> </blockquote> <p>Okay, makes sense. When I try it, however, the page throws an exception:</p> <pre><code>&lt;asp:ObjectDataSource ID="MyDataSource" TypeName="MyProject.Repository`1[MyProject.MessageCategory],DataAccess" /&gt; </code></pre> <blockquote> <p>[InvalidOperationException: The type specified in the TypeName property of ObjectDataSource 'MyDataSource' could not be found.]</p> </blockquote> <p>The curious thing is that this only happens when I'm viewing the page. When I open the "Configure Data Source" dialog from the VS2008 designer, it properly shows me the methods on my generic Repository class. Passing the TypeName string to Type.GetType() while debugging also returns a valid type. So what gives?</p>
<p>Do something like this.</p> <pre><code>Type type = typeof(Repository&lt;MessageCategory); string assemblyQualifiedName = type.AssemblyQualifiedName; </code></pre> <p>get the value of assemblyQualifiedName and paste it into the TypeName field. Note that Type.GetType(string), the value passed in must be</p> <blockquote> <p>The assembly-qualified name of the type to get. See <a href="http://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx" rel="noreferrer">AssemblyQualifiedName</a>. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.</p> </blockquote> <p>So, it may work by passing in that string in your code, because that class is in the currently executing assembly (where you are calling it), where as the ObjectDataSource is not.</p> <p>Most likely the type you are looking for is </p> <pre><code>MyProject.Repository`1[MyProject.MessageCategory, DataAccess, Version=1.0.0.0, Culture=neutral, PublicKey=null], DataAccess, Version=1.0.0.0, Culture=neutral, PublicKey=null </code></pre>
<p>Darren,</p> <p>Many, many thanks for your post. I've been fighting with this all day. Strangely, in my case, I need to double the square brackets, e.g. for your piece of code:</p> <p>MyProject.Repository`1[[MyProject.MessageCategory, DataAccess, Version=1.0.0.0, Culture=neutral, PublicKey=null]], DataAccess, Version=1.0.0.0, Culture=neutral, PublicKey=null</p> <p>Roger</p>
7,636
<p>I am building an open search add-on for Firefox/IE and the image needs to be Base64 Encoded so how can I base 64 encode the favicon I have?</p> <p>I am only familiar with PHP</p>
<p>As far as I remember there is an xml element for the image data. You can use this <a href="http://www.motobit.com/util/base64-decoder-encoder.asp" rel="noreferrer">website</a> to encode a file (use the upload field). Then just copy and paste the data to the XML element.</p> <p>You could also use PHP to do this like so:</p> <pre><code> &lt;?php $im = file_get_contents('filename.gif'); $imdata = base64_encode($im); ?&gt; </code></pre> <p>Use <a href="http://developer.mozilla.org/en/Creating_OpenSearch_plugins_for_Firefox" rel="noreferrer">Mozilla's guide</a> for help on creating OpenSearch plugins. For example, the icon element is used like this:</p> <pre><code>&lt;img width="16" height="16"&gt;data:image/x-icon;base64,imageData&lt;/&gt; </code></pre> <p>Where <code>imageData</code> is your base64 data.</p>
<p>Google led me to <a href="http://fr.php.net/base64_encode" rel="nofollow noreferrer">this</a> solution (base64_encode). Hope this helps!</p>
5,646
<p>This question comes on the heels of the question asked <a href="https://stackoverflow.com/questions/371/how-do-you-make-sure-email-you-send-programmatically-is-not-automatically-marke">here</a>.</p> <p>The email that comes from our web server comes from an IP address that is different than that for the Exchange server. Is this okay if the SPF and Domain keys are setup properly?</p>
<p>The use of <code>System.exit</code> is frowned upon when the 'application' is really a sub-application (e.g. servlet, applet) of a larger Java application (server): in this case the <code>System.exit</code> could stop the JVM and hence also all other sub-applications. In this situation, throwing an appropriate exception, which could be caught and handled by the application framework/server is the best option.</p> <p>If the java application is really meant to be run as a standalone application, there is nothing wrong with using <code>System.exit</code>. in this case, setting an exit value is probably the easiest (and also most used) way of communicating failure or success to the parent process.</p>
<p>It's frowned upon for <em>normal</em> exits. If "not everything is going according to plan", then System.exit is fine.</p> <p>Update: I should add that I assume your '1' has meaning that is documented somewhere.</p>
5,280
<p>I am working on a new project. Is there any benefit with going with a WCF web service over a regular old fashion web service?</p> <p>Visual Studio offers templates for both. What are the differences? Pros and cons?</p>
<p>What is a "regular old fashioned web service?" An ASMX service, or are you using WSE as well? ASMX services are not naturally interoperable, don't support WS-* specs, and ASMX is a technology that is aging very quickly. WSE (Web Service Enhancements) services DO add support for WS-* and can be made to be interoperable, but WCF is meant to replace WSE, so you should take the time to learn it. I would say that unless your application is a quick an dirty one-off, you will gain immense flexibility and end up with a better design if you choose WCF. WCF <em>does</em> have a learning curve beyond a [WebMethod] attribute, but the learning curve is over-exaggerated in my opinion, and it is exponentially more powerful and future proof than legacy ASMX services.</p> <p>Unless your time line simply cannot tolerate the learning curve, you would be doing yourself a huge favor learning WCF instead of just sticking with ASP.NET Web Services. Applications will only continue to become more and more distributed and interconnected, and WCF is the future of distributed computing on the Microsoft platform.</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa738737.aspx" rel="noreferrer">Here is a comparison</a> between the two.</p>
<p>In my experience</p> <p><strong>WCF</strong></p> <p>It is absurdly verbose to work with it, it is not quite compatible with other microsoft products and, of course, it is not widely accepted outside ot the microsoft world.</p> <p>But my main problem is it is not stable, it trends to fail (in some situation) and it requires to tweak it before it can be used.</p> <p><strong>Instead</strong></p> <p>SOAP (aka standard Webservice), it works, it is easy to work and it is widely compatible (Java-JAX accepts it without any modification).</p> <p>To add authentication in SOAP could be a bit tricky but not impossible.</p>
2,841
<p>My dilemma is, basically, how to share an enumeration between two applications.</p> <p>The users upload documents through a front-end application that is on the web. This application calls a web service of the back-end application and passes the document to it. The back-end app saves the document and inserts a row in the <em>Document</em> table.</p> <p>The document type (7 possible document types: <em>Invoice</em>, <em>Contract</em> etc.) is passed as a parameter to the web service's <em>UploadDocument</em> method. The question is, what should the type (and possible values) of this parameter be?</p> <p>Since you need to hardcode these values in both applications, I think it is O.K. to use a descriptive string (<em>Invoice</em>, <em>Contract</em>, <em>WorkOrder</em>, <em>SignedWorkOrder</em>). </p> <p>Is it maybe a better approach to create a <em>DocumentTypes</em> enumeration in the first application, and to reproduce it also in the second application, and then pass the corresponding integer value to the web service between them?</p>
<p>I'd suggest against passing an integer between them, simply for purposes of readability and debugging. Say you're going through your logs and you see a bunch of 500 errors for DocumentType=4. Now you've got to go look up which DocumentType is 4. Or if one of the applications refers to a number that doesn't exist in the other, perhaps due to mismatched versions.</p> <p>It's a bit more code, and it rubs the static typing part of the brain a bit raw, but in protocols on top of HTTP the received wisdom is to side with legible strings over opaque enumerations.</p>
<p>I've noticed that when using "Add Service Reference" as opposed to "Add Web Reference" from VS.net, the actual enum values come across as well as the enum names. This is really annoying as I need to support both 2.0 and 3.5 clients. I end up having to go into the 2.0 generated web service proxy code and manually adding the enum values every time I make a change!</p>
2,402
<p>This is a bit of a weird question, and I imagine the answer might simply be "no." But here goes anyway:</p> <p>I'm writing some code that generates shapes for 3D printing via "implicit surfaces," i.e. a mathematical function f(x,y,z) that is positive inside the shape and negative outside it. This works pretty well for designing the kind of shapes I want to print, but the problem is, turning the implicit surface into a good mesh is <em>hard</em> - there are some libraries that can do it, but they're kind of finnicky and you have to play with parameters a lot to get it to work well.</p> <p>But I was thinking: the only reason I need a mesh in the first place is to send it to a slicer, which will ultimately throw away the mesh and turn it into gcode instead. My plan was to do</p> <p><code>implicit function --&gt; STL file --&gt; gcode</code></p> <p>but I'm wondering if there are any slicers that will let me skip the intermediate step and let me just do</p> <p><code>implicit function --&gt; gcode</code></p> <p>instead. That is, my code would supply a 3D grid of voxels, containing the value of the function at each 3D point, and the slicer would create the gcode from that instead of from an STL file.</p> <p>It seems that Shapeways have a nice and simple format called <a href="https://abfab3d.com/svx-format/" rel="nofollow noreferrer">SVX</a> that is exactly this, but as far as I can tell, this is only supported by Shapeways and not by any FDM slicing software.</p> <p>Another option would be for my code to supply a sequence of 2D polygons, one for each layer of the printed model, so the sequence would be</p> <p><code>implicit function --&gt; big list of slices --&gt; gcode</code></p> <p>This would be both easier and more accurate than first converting it into a mesh, and I assume the slicer must generate this kind of representation anyway, before it calculates the path for the print head to take.</p> <p>I suppose the question is, is there an existing CAD format that supports either of these options, that is also supported by existing slicer software? If so then I can just write my code to output in that format and it should just work.</p>
<h2>No, not natively</h2> <p>To the current point, all slicers in frequent use do use some kind of 3D model with explicit surfaces to cut up into slices and then solve the path functions to create the G-code. The model can be in STL or OBJ or some other format, depending on the slicer, but at this point (November 2019), no slicing program I know about supports direct math as input.</p> <h2>Probably make it yourself?</h2> <p>However, you have a way to design the models by solving a mathematical formula. You could probably use the program that solves the formulae to also act as a slicer of some sorts.</p> <p>One software that might form a base could be Cura, which allows writing plugins, so there might be a way to have Cura automatically solve the surface formula and then plug that into the slicing without storing the intermediate data as an STL.</p> <p>Slic3r might also work as a base since the whole source code is open. It would be a similar endeavor as modifying Cura.</p>
<p>This is a partial answer that I might make into a full answer if I follow it up later. (I'm posting in case someone else has the same question, in which case this might be helpful despite being incomplete.)</p> <p>It seems that the 3mf format has a <a href="https://github.com/3MFConsortium/spec_slice/blob/master/3MF%20Slice%20Extension.md" rel="nofollow noreferrer">slice extension</a> that does pretty much what I want - it allows the model to be specified as a series of polygons representing the slices, instead of a 3D mesh. So in principle I could simply output a 3mf file containing slice data, and load it into any slicer that supports this extension.</p> <p>Unfortunately, this would mean learning what seems to be a rather complicated XML based file format, and I'm unsure which slicers currently support the slice extension. This seems to be quite a recent thing, and it might be a case of waiting until better support is available, in terms of Python libraries to write 3mf files as well as slicer support. (There are Python bindings for lib3mf, but their documentation currently consists of a single word, "TODO".)</p> <p>There is also a requirement in the spec that any 3mf file containing slice data must also contain a mesh representation of the object. This is annoying because the whole point of this idea is to avoid generating a mesh. I suppose I could just output a bounding box or something instead.</p>
1,400
<p>GDI+ DrawLines function has a clipping bug that can be reproduced by running the following c# code. When running the code, two line paths appear, that should be identical, because both of them are inside the clipping region. But when the clipping region is set, one of the line segment is not drawn. </p> <pre><code>protected override void OnPaint(PaintEventArgs e) { PointF[] points = new PointF[] { new PointF(73.36f, 196), new PointF(75.44f, 32), new PointF(77.52f, 32), new PointF(79.6f, 196), new PointF(85.84f, 196) }; Rectangle b = new Rectangle(70, 32, 20, 164); e.Graphics.SetClip(b); e.Graphics.DrawLines(Pens.Red, points); // clipped incorrectly e.Graphics.TranslateTransform(80, 0); e.Graphics.ResetClip(); e.Graphics.DrawLines(Pens.Red, points); } </code></pre> <p>Setting the antials mode on the graphics object resolves this. But that is not a real solution.</p> <p>Does anybody know of a workaround?</p>
<p>It appears that this is a known bug...</p> <p>The following code appears to function as you requested:</p> <pre><code>protected override void OnPaint(PaintEventArgs e) { PointF[] points = new PointF[] { new PointF(73.36f, 196), new PointF(75.44f, 32), new PointF(77.52f, 32), new PointF(79.6f, 196), new PointF(85.84f, 196) }; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Rectangle b = new Rectangle(70, 32, 20, 165); e.Graphics.SetClip(b); e.Graphics.DrawLines(Pens.Red, points); // clipped incorrectly e.Graphics.TranslateTransform(80, 0); e.Graphics.ResetClip(); e.Graphics.DrawLines(Pens.Red, points); } </code></pre> <p>Note: I have AntiAlias'ed the line and extended your clipping region by 1</p> <p>it appears that the following work arounds might help (although not tested):</p> <ul> <li>The pen is more than one pixel thick</li> <li>The line is perfectly horizontal or vertical</li> <li>The clipping is against the window boundaries rather than a clip rectangle</li> </ul> <p>The following is a list of articles that might / or then again might not help:</p> <p><a href="http://www.tech-archive.net/pdf/Archive/Development/microsoft.public.win32.programmer.gdi/2004-08/0350.pdf" rel="nofollow noreferrer">http://www.tech-archive.net/pdf/Archive/Development/microsoft.public.win32.programmer.gdi/2004-08/0350.pdf</a> <a href="http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.gdi/2004-08/0368.html" rel="nofollow noreferrer">http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.gdi/2004-08/0368.html</a></p> <p>OR...</p> <p>the following is also possible:</p> <pre><code>protected override void OnPaint ( PaintEventArgs e ) { PointF[] points = new PointF[] { new PointF(73.36f, 196), new PointF(75.44f, 32), new PointF(77.52f, 32), new PointF(79.6f, 196), new PointF(85.84f, 196) }; Rectangle b = new Rectangle( 70, 32, 20, 164 ); Region reg = new Region( b ); e.Graphics.SetClip( reg, System.Drawing.Drawing2D.CombineMode.Union); e.Graphics.DrawLines( Pens.Red, points ); // clipped incorrectly e.Graphics.TranslateTransform( 80, 0 ); e.Graphics.ResetClip(); e.Graphics.DrawLines( Pens.Red, points ); } </code></pre> <p>This effecivly clips using a region combined/unioned (I think) with the ClientRectangle of the canvas/Control. As the region is difned from the rectangle, the results should be what is expected. This code can be proven to work by adding</p> <pre><code>e.Graphics.FillRectangle( new SolidBrush( Color.Black ), b ); </code></pre> <p>after the setClip() call. This clearly shows the black rectangle only appearing in the clipped region.</p> <p>This could be a valid workaround if Anti-Aliasing the line is not an option.</p> <p>Hope this helps</p>
<p>What appears to be the matter with the code?</p> <p>OK, the question should be... what should the code do that it doesn't already.</p> <p>When I run the code, I see 2 red 'spikes' am I not ment to?</p> <p>You appear to draw the first spike within the clipped rectangle region verified by adding the the following after the declaration of teh Rectangle :</p> <p><code>e.Graphics.FillRectangle( new SolidBrush( Color.Black ), b );</code></p> <p>Then you perform a translation, reset the clip so at this point I assume the clientRectangle is being used as the appropriate clip region and then attempt to redarw the translated spike. Where's the bug?!?</p>
3,628
<p>I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this different from a list?</p>
<ul> <li>Tuples are used whenever you want to return multiple results from a function.</li> <li>Since they're immutable, they can be used as keys for a dictionary (lists can't).</li> </ul>
<p>In addition to the places where they're syntactically required like the string % operation and for multiple return values, I use tuples as a form of lightweight classes. For example, suppose you have an object that passes out an opaque cookie to a caller from one method which is then passed into another method. A tuple is a good way to pack multiple values into that cookie without having to define a separate class to contain them.</p> <p>I try to be judicious about this particular use, though. If the cookies are used liberally throughout the code, it's better to create a class because it helps document their use. If they are only used in one place (e.g. one pair of methods) then I might use a tuple. In any case, because it's Python you can start with a tuple and then change it to an instance of a custom class without having to change any code in the caller.</p>
6,344
<p>How do I create a branch in SVN?</p>
<p>Branching in Subversion is facilitated by a very very light and efficient copying facility.</p> <p>Branching and tagging are effectively the same. Just copy a whole folder in the repository to somewhere else in the repository using the <code>svn copy</code> command.</p> <p>Basically this means that it is by convention what copying a folder means - whether it be a backup, tag, branch or whatever. Depending upon how you want to think about things (normally depending upon which SCM tool you have used in the past) you need to set up a folder structure within your repository to support your style.</p> <p>Common styles are to have a bunch of folders at the top of your repository called <code>tags</code>, <code>branches</code>, <code>trunk</code>, etc. - that allows you to copy your whole <code>trunk</code> (or sub-sets) into the <code>tags</code> and/or <code>branches</code> folders. If you have more than one project you might want to replicate this kind of structure under each project:</p> <p>It can take a while to get used to the concept - but it works - just make sure you (and your team) are clear on the conventions that you are going to use. It is also a good idea to have a good naming convention - something that tells you why the branch/tag was made and whether it is still appropriate - consider ways of archiving branches that are obsolete.</p>
<p>Below are the steps to create a branch from trunk using TortoiseSVN in windows machine. This obviously needs TortoiseSVN client to be installed.</p> <ol> <li>Right Click on updated trunk from local windows machine</li> <li>Select TortoiseSVN</li> <li>Click branch/Tag</li> <li>Select the To path in SVN repository. Note that destination URL is updated according to the path and branch name given</li> <li>Do not create folder inside branches in repository browser</li> <li>Add branches path. For example, branches/</li> <li>Add a meaningful log message for your reference</li> <li>Click Ok, this creates new folder on local system</li> <li>Checkout the branch created into new folder</li> </ol>
2,425
<p>I have 150+ SQL queries in separate text files that I need to analyze (just the actual SQL code, not the data results) in order to identify all column names and table names used. Preferably with the number of times each column and table makes an appearance. Writing a brand new SQL parsing program is trickier than is seems, with nested SELECT statements and the like. </p> <p>There has to be a program, or code out there that does this (or something close to this), but I have not found it.</p>
<p>I actually ended up using a tool called <a href="http://www.dpriver.com/pp/sqlformat.htm" rel="noreferrer">SQL Pretty Printer</a>. You can purchase a desktop version, but I just used the free online application. Just copy the query into the text box, set the Output to "List DB Object" and click the Format SQL button. </p> <p>It work great using around 150 different (and complex) SQL queries.</p>
<p>Please go with antlr... Write a grammar n follow the steps..which is given in antlr site..eventually you will get AST(abstract syntax tree). For the given query... we can traverse through this and bring all table ,column which is present in the query..</p>
8,069
<p>I know how to test an object to see if it is of a type, using the IS keyword e.g.</p> <pre><code>if (foo is bar) { //do something here } </code></pre> <p>but how do you test for it not being "bar"?, I can't seem to find a keyword that works with IS to test for a negative result. </p> <p>BTW - I have a horrible feeling this is soooo obvious, so apologies in advance...</p>
<pre><code>if (!(foo is bar)) { } </code></pre>
<p>There is no specific keyword</p> <pre><code>if (!(foo is bar)) ... if (foo.GetType() != bar.GetType()) .. // foo &amp; bar should be on the same level of type hierarchy </code></pre>
7,985
<p>I'd like to be able to write a ruby program that can restart without dropping it's socket connections.</p>
<p>This program gets Google's homepage and then when you pass it SIG_INT via <kbd>Ctrl</kbd>-<kbd>C</kbd> it restarts the program and reads the output of the homepage from the open socket with Google.</p> <pre><code>#!/usr/bin/ruby #simple_connector.rb require 'socket' puts &quot;Started.&quot; if ARGV[0] == &quot;restart&quot; sock = IO.open(ARGV[1].to_i) puts sock.read exit else sock = TCPSocket.new('google.com', 80) sock.write(&quot;GET /\n&quot;) end Signal.trap(&quot;INT&quot;) do puts &quot;Restarting...&quot; exec(&quot;ruby simple_connector.rb restart #{sock.fileno}&quot;) end while true sleep 1 end </code></pre>
<p>You're talking about network sockets, not UNIX sockets I assume?</p> <p>I'm not sure this suits your needs, but the way I would do it is by seperating the networking and logic part, and only restart the logic part, then reconnect the logic part to the networking part.</p>
5,947
<p>We are developing a middleware SDK, both in C++ and Java to be used as a library/DLL by, for example, game developers, animation software developers, Avatar developers to enhance their products.</p> <p>What I would like to know is this: Are there standard "Best Practices" for the development of these types of API?</p> <p>I am thinking in terms of usability, readability, efficiency etc.</p>
<p>My two favourite resources on the subject: <a href="http://mollyrocket.com/873" rel="nofollow noreferrer">http://mollyrocket.com/873</a> and <del><a href="http://video.google.com/videoplay?docid=-3733345136856180693" rel="nofollow noreferrer">http://video.google.com/videoplay?docid=-3733345136856180693</a></del></p>
<p>There are lots of ways to design apis, depending on what you are solving. I think a full answer to this question would be worthy off a whole book, such as the <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="nofollow noreferrer" rel="nofollow noreferrer">gang of four patterns book</a>. For Java specifically, and also just OO programming in general, I would recommend <a href="https://rads.stackoverflow.com/amzn/click/com/0321356683" rel="nofollow noreferrer" rel="nofollow noreferrer">Effective Java 2nd Edition</a>. The first is general and a lot of popular programming patterns, when they apply and their benefits. Effective Java is Java centered, but parts of it is general enough to apply to any programming language.</p>
8,779
<p>Are there any tools or plugins to design a Panel independently of a Form (Windows, not Web Form) within Visual Studio?</p> <p>I've been using the designer and manually extracting the bits I want from the source, but surely there is a nicer way.</p>
<p>You could do all the design work inside of a UserControl.</p> <p>If you go that route, instead of just copying the bits out of the user control, simply use the user control itself.</p>
<p>As Chris Karcher said, you should probably use a user control. This will allow easy, VS-supported/-integrated reuse without having to manually fiddle with designer code.</p>
5,759
<p>I am in college and am doing a team competition to print PPSU filament, and get the best results. This is being put on by the Solvay company, who makes the material. Our team signed up and the university bought us an <a href="https://www.intamsys.com/" rel="nofollow noreferrer">Intamsys</a> <a href="https://www.intamsys.com/funmat-ht-3d-printer/" rel="nofollow noreferrer">Funmat HT</a> 3D Printer, which said it was capable of printing PPSU. However, the company doing the competition did not release the information that the bed plate must be a high temperature to avoid warping (Greater than 200 °C). However, our plate only reaches a temperature of 160. Does anyone know of any aftermarket heaters that would work with this printer?</p> <p>Maximum temperatures according to Intamys: Chamber 90 °C, Magnetic Build Plate 160 °C, Extruder 450 °C</p>
<p>If you're a brave individual you might try insulating the bottom of your heated bed. You're going to want to get fiberglass or something that can actually withstand the temperatures you're trying to reach; anything past about 230&nbsp;&deg;C and you'll get organic things like cork and cotton starting to smoke. 200&nbsp;&deg;C is pretty absurd for a print bed temperature unless you're printing some pretty exotic materials.</p> <p>Aside from insulating the bottom of the bed to aid in heat retention, you might also try getting an external FET chip for your heated bed, like is recommended for the RAMPS1.4 boards since their connectors don't handle high amperage loads well. External FET plus a 24&nbsp;V PSU might give you the kind of temperature range you're apparently aiming for. Best of luck with that, and try not to set your entire setup on fire, 200&nbsp;&deg;C really is kind of absurd for an entire print plate.</p> <p><strong>TL;DR:</strong></p> <ol> <li>Insulate</li> <li>External FET chip</li> <li>24V PSU</li> </ol>
<p>Inspired by the answer from Nach0z, according to my back of the notepad radiative emission approximation, you need about a 3x increase in bed dissipation to get from <span class="math-container">$ \Delta T$</span> of 130 °C up to 170 °C. So that would correspond to an increase from 12 V <em>at the bed</em> to 18 V. As the current increases, the wire losses would also increase. </p> <p>Sounds like a high power laptop charger could possibly fit the bill at 19V. Obviously this leaves a risk that the bed will be damaged, but I think it is better to aim for a steady load rather than pwm and a higher peak energy than necessary.</p>
1,187
<p>The .NET <code>System.Security.Cryptography</code> namespace has a rather bewildering collection of algorithms that I could use for encryption of credit card details. Which is the best?</p> <p>It clearly needs to be secure for a relatively short string. </p> <p>EDIT: I'm in the UK, where I understand we're OK storing encrypted credit card details so long as the three-digit CVV number is never stored. And thanks all for the great responses.</p>
<p>No offense, but the question is a little "misguided". There is no "silver bullet" solution. I would recommend to read up on cryptography in general and then do some threat modeling. Some questions (by no means a comprehensive list) you should ask yourself:</p> <ul> <li>Is the module doing the encryption the one which needs to decrypt it (in this case use symmetric crypto) or will it send data to an other module (on an other machine) which will use it (in which case you should consider public-key crypto)</li> <li>What do you want to protect against? Someone accessing the database but not having the sourcecode (in which case you can hardcode the encryption key directly into the source)? Someone sniffing your local network (you should consider transparent solutions like IPSec)? Someone stealing your server (it can happen even in data centers - in which case full disk encryption should be considered)?</li> <li>Do you really need to keep the data? Can't you directly pass it to the credit card processor and erase it after you get the confirmation? Can't you store it locally at the client in a cookie or Flash LSO? If you store it at the client, make sure that you encrypt it at the server side before putting it in a cookie. Also, if you are using cookies, make sure that you make them http only.</li> <li>Is it enough to compare the equality of the data (ie the data that the client has given me is the same data that I have)? If so, consider storing a hash of it. Because credit card numbers are relatively short and use a reduced set of symbols, a unique salt should be generated for each before hashing.</li> </ul> <p><em>Later edit</em>: note that standard encryption algorithms from the same category (for example 3DES and AES - both being symmetric block cyphers) are of comparable strength. Most (commercial) systems are not broken because somebody bruteforced their encryption, but because their threat modelling was not detailed enough (or flat out they didn't have any). For example you can encrypt all the data, but if you happen to have a public facing web interface which is vulnerable to SQL injection, it won't help you much.</p>
<p>3des is pretty good, store the salt along side, and keep a standard key somewhere not in the database or a config file. That way if you get pwned, they can't decrypt it.</p>
6,252
<p>I have just finished building a Tronxy P802M Prusa i3.</p> <p>When I try to move the Z-axis, using the hardware buttons in the LCD menu (without a computer connected), it only goes down, when I both increase, and decrease, the value of Z.</p> <p>Any suggestions?</p>
<p>It could be a hardware fault. </p> <p>First check, and compare, the control board connections to the motors of the three axes. You don't state it in your question but, presumably, the X and Y axes move correctly? If so, then compare the connections for the Z-axis motors with the connections for the motors of the axes that work as expected.</p> <p>If they are correct then the problem is likely to be with the firmware.</p> <p>Have you...</p> <ul> <li>homed the Z-axis yet?</li> <li>installed the endstops?</li> </ul> <p>From <a href="https://makerware.thingiverse.com/groups/prusa-i3/topic:7370" rel="noreferrer">X Y Z axis only move one direction?</a>:</p> <blockquote> <p>Using Marlin? Before you do a <code>G28</code> homing the axes will only move towards the endstops. But also check your endstops with <code>M119</code> to make sure they are triggered at the right time. On older Marlin, you may need to set <code>DISABLE_MAX_ENDSTOPS</code> (on a machine that has no max endstops). Newer Marlin uses <code>USE_XMIN_PLUG</code>, etc., to specifically set which endstops are connected. If the switches show the opposite state (off when triggered) then set the <code>[XYZ]_(MIN|MAX)_ENDSTOP_INVERTING</code> flags, as needed.</p> </blockquote> <p>Likewise, from <a href="http://www.instructables.com/id/Building-a-Prusa-i3-3D-Printer/" rel="noreferrer">Building a Prusa I3 3D Printer</a>:</p> <blockquote> <p>You will probably also find the motor will turn only in one direction. This is normal for now as we don't have end-stops installed and haven't homed the axis - so the software doesn't know how far it can go in one direction or the other.</p> </blockquote> <hr> <p>As Mark states in his <a href="https://3dprinting.stackexchange.com/questions/4158/prusa-i3-z-axis-only-goes-down-even-on-up-command#comment5758_4162">comment</a>, the P802M uses a Melzi board. From <a href="https://github.com/repetier/Repetier-Firmware/tree/master/boards/Zonestar%20P802M" rel="noreferrer">Github: Repetier-Firmware/boards/Zonestar P802M/</a>:</p> <blockquote> <p>There are some printers sold under different names like 'Zonestar P802M', 'Prusa i3 P802M DIY kit', 'Anet A8-B', etc, which have LCD 20x4 with 5 keys controller connected to Melzi V2.0 board via 10 wires cable. Keys are connected to a single analog input using resistive divider.</p> </blockquote>
<p>It could be a hardware fault. </p> <p>First check, and compare, the control board connections to the motors of the three axes. You don't state it in your question but, presumably, the X and Y axes move correctly? If so, then compare the connections for the Z-axis motors with the connections for the motors of the axes that work as expected.</p> <p>If they are correct then the problem is likely to be with the firmware.</p> <p>Have you...</p> <ul> <li>homed the Z-axis yet?</li> <li>installed the endstops?</li> </ul> <p>From <a href="https://makerware.thingiverse.com/groups/prusa-i3/topic:7370" rel="noreferrer">X Y Z axis only move one direction?</a>:</p> <blockquote> <p>Using Marlin? Before you do a <code>G28</code> homing the axes will only move towards the endstops. But also check your endstops with <code>M119</code> to make sure they are triggered at the right time. On older Marlin, you may need to set <code>DISABLE_MAX_ENDSTOPS</code> (on a machine that has no max endstops). Newer Marlin uses <code>USE_XMIN_PLUG</code>, etc., to specifically set which endstops are connected. If the switches show the opposite state (off when triggered) then set the <code>[XYZ]_(MIN|MAX)_ENDSTOP_INVERTING</code> flags, as needed.</p> </blockquote> <p>Likewise, from <a href="http://www.instructables.com/id/Building-a-Prusa-i3-3D-Printer/" rel="noreferrer">Building a Prusa I3 3D Printer</a>:</p> <blockquote> <p>You will probably also find the motor will turn only in one direction. This is normal for now as we don't have end-stops installed and haven't homed the axis - so the software doesn't know how far it can go in one direction or the other.</p> </blockquote> <hr> <p>As Mark states in his <a href="https://3dprinting.stackexchange.com/questions/4158/prusa-i3-z-axis-only-goes-down-even-on-up-command#comment5758_4162">comment</a>, the P802M uses a Melzi board. From <a href="https://github.com/repetier/Repetier-Firmware/tree/master/boards/Zonestar%20P802M" rel="noreferrer">Github: Repetier-Firmware/boards/Zonestar P802M/</a>:</p> <blockquote> <p>There are some printers sold under different names like 'Zonestar P802M', 'Prusa i3 P802M DIY kit', 'Anet A8-B', etc, which have LCD 20x4 with 5 keys controller connected to Melzi V2.0 board via 10 wires cable. Keys are connected to a single analog input using resistive divider.</p> </blockquote>
611
<p>I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.</p> <p>On OSX, I can open a window in the finder with</p> <pre><code>os.system('open "%s"' % foldername) </code></pre> <p>and on Windows with</p> <pre><code>os.startfile(foldername) </code></pre> <p>What about unix/linux? Is there a standard way to do this or do I have to special case gnome/kde/etc and manually run the appropriate application (nautilus/konqueror/etc)?</p> <p>This looks like something that could be specified by the <a href="http://freedesktop.org" rel="noreferrer">freedesktop.org</a> folks (a python module, similar to <code>webbrowser</code>, would also be nice!).</p>
<pre><code>os.system('xdg-open "%s"' % foldername) </code></pre> <p><code>xdg-open</code> can be used for files/urls also</p>
<p>this would probably have to be done manually, or have as a config item since there are many file managers that users may want to use. Providing a way for command options as well.</p> <p>There might be an function that launches the defaults for kde or gnome in their respective toolkits but I haven't had reason to look for them.</p>
6,338
<p>I'm looking for a book/site/tutorial on best practices for relational database design, tuning for performance etc. It turns out this kind of resource is a bit difficult to find; there's a lot of "here's normalization, here's ER diagrams, have at it," but not much in the way of real examples. Anyone have any ideas?</p>
<p>Book: <a href="https://rads.stackoverflow.com/amzn/click/com/0201752840" rel="noreferrer" rel="nofollow noreferrer">Database Design for Mere Mortals</a></p>
<p>Here are some resources I could find on the web. They include examples you are looking for:</p> <ul> <li><a href="http://databases.ncl.ac.uk/databases/Design/default.aspx" rel="nofollow noreferrer">Designing and creating a Relational Database - Dr Lorna Scammell: Newcastle University Database Adviser</a></li> <li><a href="http://www.databasedev.co.uk/data_models.html" rel="nofollow noreferrer">Sample Data Models for Relational Database Design </a></li> </ul>
3,270
<p>I love list comprehensions in Python, because they concisely represent a transformation of a list.</p> <p>However, in other languages, I frequently find myself writing something along the lines of:</p> <pre><code>foreach (int x in intArray) if (x &gt; 3) //generic condition on x x++ //do other processing </code></pre> <p>This example is in C#, where I'm under the impression LINQ can help with this, but is there some common programming construct which can replace this slightly less-than-elegant solution? Perhaps a data structure I'm not considering?</p>
<p>The increment in the original <code>foreach</code> loop will not affect the contents of the array, the only way to do this remains a <code>for</code> loop:</p> <pre><code>for(int i = 0; i &lt; intArray.Length; ++i) { if(intArray[i] &gt; 3) ++intArray[i]; } </code></pre> <p>Linq is not intended to modify existing collections or sequences. It creates new sequences based on existing ones. It is possible to achieve the above code using Linq, though it is slightly against its purposes:</p> <pre><code>var newArray1 = from i in intArray select ((i &gt; 3) ? (i + 1) : (i)); var newArray2 = intArray.Select(i =&gt; (i &gt; 3) ? (i + 1) : (i)); </code></pre> <p>Using <code>where</code> (or equivalent), as shown in some of the other answers, will exclude any values less than or equal to 3 from the resulting sequence.</p> <pre><code>var intArray = new int[] { 10, 1, 20, 2 }; var newArray = from i in intArray where i &gt; 3 select i + 1; // newArray == { 11, 21 } </code></pre> <p>There is a <code>ForEach</code> method on arrays that will allow you to use a lambda function instead of a <code>foreach</code> block, though for anything more than a method call I would stick with <code>foreach</code>.</p> <pre><code>intArray.ForEach(i =&gt; DoSomething(i)); </code></pre>
<p>Depends on the language and what you need to do, a "map" as it's called in many languages could be what you're looking for. I don't know C#, but according to <a href="http://blogs.msdn.com/devdev/archive/2006/06/30/652802.aspx" rel="nofollow noreferrer">this</a> page, .NET 2.0 calls map "ConvertAll".</p> <p>The meaning of "map" is pretty simple - take a list, and apply a function to each element of it, returning a new list. You may also be looking for "filter", which would give you a list of items that satisfy a predicate in another list.</p>
3,433
<p>Database? Page variables? Enum?</p> <p>I'm looking for opinions here. </p>
<p>The ASP.NET Sitemap feature is built for that and works well in a lot of cases. If you get in a spot where you want your <a href="http://weblogs.asp.net/jgalloway/archive/2008/01/26/asp-net-menu-and-sitemap-security-trimming-plus-a-trick-for-when-your-menu-and-security-don-t-match-up.aspx" rel="nofollow noreferrer">Menu to look different from your Sitemap, here are some workarounds</a>.</p> <p>If you have a dynamic site structure, you can <a href="http://msdn.microsoft.com/en-us/library/aa479320.aspx#custsit_topic4" rel="nofollow noreferrer">create a custom sitemap provider</a>. You might get to the point where it's more trouble than it's worth, but in general populating your menu from your sitemap gives you some nice features like security trimming, in which the menu options are appropriate for the logged-in user.</p>
<p>IF the menu is dynamic <em>per-user</em> then you'll have to hit the database for each user. From then on I would probably store it in session to avoid future round-trips to the database.</p> <p>If it's dynamic, but the entire site sees the same items, then put it in the database and cache the results</p>
7,772
<p>I need a Datepicker for a WPF application. What is considered to be the best one? </p>
<h3>There is also the <a href="http://www.codeplex.com/wpf" rel="noreferrer">WPF Tool Kit</a> which has a DatePicker/Calendar control</h3> <p>(i added emphasis because this is the answer)</p>
<p>I'm thinking of using this one: <a href="http://marlongrech.wordpress.com/2007/09/11/wpf-datepicker/" rel="nofollow noreferrer">Marlon Grech Date Picker</a>.</p>
7,309
<p>My code needs to determine how long a particular process has been running. But it continues to fail with an access denied error message on the <code>Process.StartTime</code> request. This is a process running with a User's credentials (ie, not a high-privilege process). There's clearly a security setting or a policy setting, or <em>something</em> that I need to twiddle with to fix this, as I can't believe the StartTime property is in the Framework just so that it can fail 100% of the time.</p> <p>A Google search indicated that I could resolve this by adding the user whose credentials the querying code is running under to the "Performance Log Users" group. However, no such user group exists on this machine.</p>
<p>I've read something similar to what you said in the past, Lars. Unfortunately, I'm somewhat restricted with what I can do with the machine in question (in other words, I can't go creating user groups willy-nilly: it's a server, not just some random PC).</p> <p>Thanks for the answers, Will and Lars. Unfortunately, they didn't solve my problem.</p> <p>Ultimate solution to this is to use WMI:</p> <pre><code>using System.Management; String queryString = "select CreationDate from Win32_Process where ProcessId='" + ProcessId + "'"; SelectQuery query = new SelectQuery(queryString); ManagementScope scope = new System.Management.ManagementScope(@"\\.\root\CIMV2"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); ManagementObjectCollection processes = searcher.Get(); //... snip ... logic to figure out which of the processes in the collection is the right one goes here DateTime startTime = ManagementDateTimeConverter.ToDateTime(processes[0]["CreationDate"].ToString()); TimeSpan uptime = DateTime.Now.Subtract(startTime); </code></pre> <p>Parts of this were scraped from Code Project:</p> <p><a href="http://www.codeproject.com/KB/system/win32processusingwmi.aspx" rel="noreferrer">http://www.codeproject.com/KB/system/win32processusingwmi.aspx</a></p> <p>And "Hey, Scripting Guy!":</p> <p><a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/jul05/hey0720.mspx" rel="noreferrer">http://www.microsoft.com/technet/scriptcenter/resources/qanda/jul05/hey0720.mspx</a></p>
<p>OK, sorry that didn't work... I am no expert on ASP.NET impersonation, I tend to use app pools which I don't think you can do on W2K Have you tried writing a tiny little test app which does the same query, and then running that as various users? </p> <p>I am reluctant to post a chunk of MS framework code here, but you could use either Reflector or this: <a href="http://www.codeplex.com/NetMassDownloader" rel="nofollow noreferrer">http://www.codeplex.com/NetMassDownloader</a> to get the source code for the relevant bits of the framework so that you could try implementing various bits to see where it fails. </p> <p>Can you get any other info about the process without getting Access Denied?</p>
4,831
<p>I'm trying to create a webapplication where I want to be able to plug-in separate assemblies. I'm using MVC preview 4 combined with Unity for dependency injection, which I use to create the controllers from my plugin assemblies. I'm using WebForms (default aspx) as my view engine.</p> <p>If I want to use a view, I'm stuck on the ones that are defined in the core project, because of the dynamic compiling of the ASPX part. I'm looking for a proper way to enclose ASPX files in a different assembly, without having to go through the whole deployment step. Am I missing something obvious? Or should I resort to creating my views programmatically?</p> <hr> <p>Update: I changed the accepted answer. Even though Dale's answer is very thorough, I went for the solution with a different virtual path provider. It works like a charm, and takes only about 20 lines in code altogether I think.</p>
<p>Essentially this is the same issue as people had with WebForms and trying to compile their UserControl ASCX files into a DLL. I found this <a href="http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx" rel="noreferrer">http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx</a> that might work for you too.</p>
<p>An addition to all you who are still looking for the holy grail: I've come a bit closer to finding it, if you're not too attached to the webforms viewengine.</p> <p>I've recently tried out the Spark viewengine. Other than being totally awesome and I wouldn't go back to webforms even if I was threathened, it also provides some very nice hooks for modularity of an application. The example in their docs is using Windsor as an IoC container, but I can't imagine it to be a lot harder if you want to take another approach.</p>
4,013
<p>Say I have an array of records which I want to sort based on one of the fields in the record. What's the best way to achieve this?</p> <pre><code>TExample = record SortOrder : integer; SomethingElse : string; end; var SomeVar : array of TExample; </code></pre>
<p>You can add pointers to the elements of the array to a <code>TList</code>, then call <code>TList.Sort</code> with a comparison function, and finally create a new array and copy the values out of the TList in the desired order.</p> <p>However, if you're using the next version, D2009, there is a new collections library which can sort arrays. It takes an optional <code>IComparer&lt;TExample&gt;</code> implementation for custom sorting orders. Here it is in action for your specific case:</p> <pre><code>TArray.Sort&lt;TExample&gt;(SomeVar , TDelegatedComparer&lt;TExample&gt;.Construct( function(const Left, Right: TExample): Integer begin Result := TComparer&lt;Integer&gt;.Default.Compare(Left.SortOrder, Right.SortOrder); end)); </code></pre>
<p>I created a very simple example that works correctly if the sort field is a string.</p> <pre><code>Type THuman = Class Public Name: String; Age: Byte; Constructor Create(Name: String; Age: Integer); End; Constructor THuman.Create(Name: String; Age: Integer); Begin Self.Name:= Name; Self.Age:= Age; End; Procedure Test(); Var Human: THuman; Humans: Array Of THuman; List: TStringList; Begin SetLength(Humans, 3); Humans[0]:= THuman.Create('David', 41); Humans[1]:= THuman.Create('Brian', 50); Humans[2]:= THuman.Create('Alex', 20); List:= TStringList.Create; List.AddObject(Humans[0].Name, TObject(Humans[0])); List.AddObject(Humans[1].Name, TObject(Humans[1])); List.AddObject(Humans[2].Name, TObject(Humans[2])); List.Sort; Human:= THuman(List.Objects[0]); Showmessage('The first person on the list is the human ' + Human.name + '!'); List.Free; End; </code></pre>
6,313
<p>When making a cylinder, sometimes I need to only take a pie slice. I'm currently using <a href="http://forum.openscad.org/Creating-pie-pizza-slice-shape-need-a-dynamic-length-array-tp3148p3149.html" rel="noreferrer">this</a> neat trick to make pie slices for angles under 90 degrees. However, I have need of a few angles over 90 but under 180 degrees. Is there a way to generalize/extend this to work for these bigger angles? </p> <pre><code>module pie_slice(r=3.0,a=30) { intersection() { circle(r=r); square(r); rotate(a-90) square(r); } } pie_slice(r=10,a=15); </code></pre>
<p>This is what I use:</p> <pre><code>module pieSlice(a, r, h){ // a:angle, r:radius, h:height rotate_extrude(angle=a) square([r,h]); } pieSlice(110,20,3); </code></pre>
<p>Although generating complex shapes by combining primitive OpenSCAD shapes is a well-established tradition, and is often all that is needed, it would be more elegant in this case to generate a pie slice directly using the <code>polygon</code> function and a list comprehension.</p> <pre><code>module pie_slice(r=3.0, a=30) { polygon(points=[ [0, 0], for(theta=0; theta&lt;a; theta=theta+$fa) [r*cos(theta), r*sin(theta)], [r*cos(a), r*sin(a)] ]); } </code></pre> <p>Note that the above code is a little crude, since it does no error checking, but it works. It uses the <code>$fa</code> special variable for the step angle.</p>
1,419
<p>I have developed a simple page using JQuery. It works fine in almost all browsers (i.e. Firefox, IE, Chrome) but whenever the page is opened in IE, it prompts Javascript error like,</p> <pre><code>'guid' is null or not an object on line 1834 </code></pre> <p>Do you have any idea ?</p>
<p>Thanks guys for your messages.</p> <p>The error was on my part. For hover event, I was not passing function for "out". Therefore the handler was passed as undefined in jQuery.event function and that causing error for statement ,</p> <p>if ( !handler.guid )</p> <p>written at 1834 line of jquery-1.2.6.js file.</p> <p>While using I thought that out handler is not mandatory to specify, but I guess I am wrong.</p> <p>Strangely, FF / Chrome does not prompt error but IE does :) which is bit different than what it used to be.</p> <p>Regards, Jatan</p>
<p>Maybe you're using the parentNode or parentElement property? There are some issues with that in IE vs other browsers.</p>
9,656
<p>I have just built my Anet A8 and it won't print. </p> <p>I will preheat it (190°C 60°C) and then press "<code>Print File</code>" and select, then it starts for a second, gets to around 11% and stops and shows "<code>Preheat PLA</code>". The PLA is already preheated - it is coming out of the nozzle. </p> <p>Any help would be appreciated.</p>
<p>I had a similar problem last week where the thermostat's heat shrink was being melted by the block and the two wires were touching. I fixed this by securing the thermistor and putting a thermal insulator between the block and the wires. I also put a small piece of heat shrink between the wires to insulate them so they will never touch. Thank you and I hope this helps.</p>
<p>The Anet A8 files that come preloaded are <code>.stl</code> so if you try to print those it will say printing zero percent and then just switch right back to preheating PLA without any error message. Download a free slicer tool if that's the case.</p>
580
<p>Recently, I started changing some of our applications to support <code>MS SQL Server</code> as an alternative back end. </p> <p>One of the compatibility issues I ran into is the use of MySQL's CREATE TEMPORARY TABLE to create in-memory tables that hold data for very fast access during a session with no need for permanent storage.</p> <p>What is the equivalent in MS SQL?</p> <p>A requirement is that I need to be able to use the temporary table just like any other, especially <code>JOIN</code> it with the permanent ones.</p>
<p>@Keith</p> <p>This is a common misconception: Table variables are NOT necessarily stored in memory. In fact SQL Server decides whether to keep the variable in memory or to spill it to TempDB. There is no reliable way (at least in SQL Server 2005) to ensure that table data is kept in memory. For more detailed info look <a href="http://blogs.msdn.com/sqlserverstorageengine/archive/2008/03/30/sql-server-table-variable-vs-local-temporary-table.aspx" rel="noreferrer">here</a></p>
<p>CREATE TABLE #tmptablename</p> <p>Use the hash/pound sign prefix</p>
4,749
<p>I've been making some ABS prints, but it's really hard to remove it afterwards. I've read a lot of different ways of removing it, including using the included chisel/spatula, using air duster, 50/50 alcohol/water, reheating the bed...</p> <p>I've also read about using a flexible bed that can flex it out. I'm eager to try this approach but don't know what magnetic bed I should get that's compatible with it.</p> <p>But if you have other tricks for it, please let me know. Thanks!</p>
<p>No, you did not set all the settings to the same speed, there are 2 different print speeds defined:</p> <ul> <li>Infill Solid: <strong>60</strong> mm/s</li> <li>First Layer Speed: <strong>30%</strong></li> </ul> <p>This means, that some walls will be printed 10 mm/s faster than the others, and that <em>first layer</em> should be printed at 30% of 50 mm/s, so at 15 mm/s - try to define it as a speed. Make sure to save and apply the settings and only <em>then</em> slice your model, as you might have sliced the model with the previous settings.</p>
<p>Make sure that on the Print Settings tab, under Advanced, you have set the Extrusion widths for your custom nozzle settings.</p>
1,118
<p>I am using Firefox 3 to debug my ASP.NET applications in Visual Studio 2008. How can I configure either FF3 or VS2008 so that when I 'x' out of Firefox I don't have to hit the stop debugging button in Visual Studio? (The behavior you get with IE)</p>
<p>My solution to this has been to manually attach the debugger to the relevant browser and the aspnet_wp process. When I'm finished, I simply detach all.</p>
<p>I have the same thing. I assume you're working with Cassini (the integrated web server).</p> <p>I've yet to find an answer to that (I just go back to VS and press <em>Shift+F5</em> to stop the debugger), but I can tell you that if you check the <em>"Edit and Continue"</em> box in the project's properties (web tab), your web server will stop and restart whenever you run your application.</p> <p>It doesn't solve the whole of the problem, but it suffices for me.</p>
8,447
<p>When I build my <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nofollow noreferrer">ASP.NET</a> web application I get a .dll file with the code for the website in it (which is great) but the website also needs all the .aspx files and friends, and these need to be placed in the correct directory structure. How can I get this all in one directory as the result of each build? Trying to pick the right files out of the source directory is a pain.</p> <p>The end result should be xcopy deployable.</p> <p><strong>Update:</strong> I don't want to have to manually use the Publish command which I'm aware of. I want the full set of files required by the application to be the build output - this means I also get the full set of files in one place from running <a href="http://en.wikipedia.org/wiki/MSBuild" rel="nofollow noreferrer">MSBuild</a>.</p>
<p>One solution appears to be Web Deployment Projects (WDPs), an add-on for Visual Studio (and msbuild) available that builds a web project to a directory and can optionally merge assemblies and alter the web.config file. The output of building a WDP is all the files necessary to deploy the site in one directory.</p> <p>More information about Web Deployment Projects:</p> <ol> <li><a href="http://blogs.msdn.com/webdevtools/archive/2008/01/25/announcing-rtw-of-visual-studio-2008-web-deployment-projects-wdp.aspx" rel="nofollow noreferrer">Announcement on webdevtools MSDN blog</a> for WDP 2008</li> <li><a href="http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx" rel="nofollow noreferrer">ScottGu introduction to WDP 2005</a></li> </ol> <p>The only disadvantage to this solution is the requirement on an add-on which must be available on the build machine. Still, it's good enough for now!</p>
<p>Have you tried right clicking the website in Solution Explorer and clicking 'Publish Website'?</p>
7,905
<p>Around here we have been working with a bunch of Visual Source Safe repositories for about 10 years or so. </p> <p>Now I want to get rid of sourcesafe and move on to Team Foundation Server.</p> <p>Do you have any tips or tricks for me before I embark on this migration? What are the things I have to be careful about? </p> <p>I am sure this migration will mean that our working habits have to be modified in some way. Do you think that these changes could be a problem for the organization? Think about a group of about 20 .NET developers in a single site.</p>
<p>There are a few different ways you can migrate. The tool will pull your history, etc. over, but the more pragmatic and simple way is to lock VSS as a history archive and start fresh:</p> <ol> <li>Have everyone check in all changes into VSS, make sure everything builds, etc.</li> <li>Set all VSS databases to "locked" (read-only rights for all users) </li> <li>Get Latest on the entire VSS database into a "clean" set of folders on a workstation </li> <li>Check all of the files into TFS from the workstation</li> </ol> <p>For any history prior to the conversion, folks need to go to VSS, but after a week or two it's realistically unlikely to happen all that often. And you know that the history in VSS is accurate and not corrupted by the conversion process.</p>
<p>Good guidance there from my former colleage Guy Starbuck. Another thing to add with that approach - you may have decided over time that you want to refactor the way your application is organized (folders etc) and this will give you an oppurtunity to do so.</p> <p>I've been in situations where we organized a solution haphazardly without thought (let alone major changes in the application) which led to a desire to organize things differently - and the move from VSS to TFS is a great oppurtunity to do so.</p> <p>As far as the original question:</p> <blockquote> <p>And: this migration will for sure mean that our working habits have to be modified in some way. Do you think that this changes could be a problem for the organization? Think to a group of about 20 .net developers, in a single site</p> </blockquote> <p>I would say - yes your working habits will change but much more for the better.</p> <ol> <li>You no should use "Check-out" Locks and "Get-Latest on Check-out". </li> <li>You can now effectively Branch and Merge</li> <li>You will now have "Changesets" all files checked-in at the same time will be grouped together. This makes historical change tracking much easier - but more importantly - rollbacks are much easier (ie find all files checked in at the same time and roll them back)</li> <li>Associating Check-ins to Work Items. Don't overlook Work Items! The biggest mistake you can make is to only use TFS as a VSS replacement. The Build and Project Management features are excellent - you paid for them - USE THEM!</li> </ol> <p>As far as details on how your experience will change, another former colleague of mine (and Team System MVP) Steve St. Jean wrote a detailed article on the differences: <a href="http://sstjean.blogspot.com/2006/10/document-from-vss-to-tfs-introduction.html" rel="nofollow noreferrer">From VSS to TFS</a></p>
4,964
<p>In IE, the dropdown-list takes the same width as the dropbox (I hope I am making sense) whereas in Firefox the dropdown-list's width varies according to the content. </p> <p>This basically means that I have to make sure that the dropbox is wide enough to display the longest selection possible. This makes my page look very ugly :(</p> <p>Is there any workaround for this problem? How can I use CSS to set different widths for dropbox and the dropdownlist?</p>
<p>Here's another <a href="http://jquery.com" rel="noreferrer">jQuery</a> based example. In contrary to all the other answers posted here, it takes all keyboard and mouse events into account, especially clicks:</p> <pre><code>if (!$.support.leadingWhitespace) { // if IE6/7/8 $('select.wide') .bind('focus mouseover', function() { $(this).addClass('expand').removeClass('clicked'); }) .bind('click', function() { $(this).toggleClass('clicked'); }) .bind('mouseout', function() { if (!$(this).hasClass('clicked')) { $(this).removeClass('expand'); }}) .bind('blur', function() { $(this).removeClass('expand clicked'); }); } </code></pre> <p>Use it in combination with this piece of CSS:</p> <pre><code>select { width: 150px; /* Or whatever width you want. */ } select.expand { width: auto; } </code></pre> <p>All you need to do is to add the class <code>wide</code> to the dropdown element(s) in question.</p> <pre><code>&lt;select class="wide"&gt; ... &lt;/select&gt; </code></pre> <p><a href="http://jsfiddle.net/HnV9Q/" rel="noreferrer">Here is a jsfiddle example</a>. Hope this helps.</p>
<p>You can add a style directly to the select element:</p> <p><code>&lt;select name="foo" style="width: 200px"&gt;</code></p> <p>So this select item will be 200 pixels wide.</p> <p>Alternatively you can apply a class or id to the element and reference it in a stylesheet</p>
9,968
<p>I'm a beginner in 3d printing, so please bear with me.</p> <p>I downloaded a zip with about 100 STL files. I now want to pick one or two to print. The names of the stl files are not very helpful so I need to look at them to find the ones I want. I can open all of them one by one using Cura, or Tinkercad, but that is a very slow and long process with so many files. Ideally I would like to have an overview of all the files in little previews so that I can get an idea what they are to narrow down which files I need to open to inspect the details.</p> <p>Is there a program with which I can do something like that? I'm on Linux, but tips about Windows/Mac software would also help since I can use it to search for Linux alternatives to that software. All tips are welcome!</p>
<p>Using the search terms, &quot;linux stl viewer,&quot; a number of results appear. One of the more promising programs, for Mac, Windows and Linux appears to be <a href="https://github.com/fstl-app/fstl" rel="noreferrer">fast stl viewer</a>, aka fstl. Image from linked site. Instructions included on the linked site to make fstl the default viewer for STL files.</p> <p><a href="https://i.stack.imgur.com/4jJl1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4jJl1.png" alt="fstl screen capture" /></a></p>
<p>Cura's probably your best bet. You can select several STL files and it will open them all, (memory allowing) then try to place them for printing. If they can't fit on your print bed the items get placed off to the side. Clicking on the object will show its name in the lower-left, so you can go rename the file to be more representative.</p> <p>Tinkercad can only import one item at a time, and tops out at 25 Mbytes.</p>
2,175
<p>Are there any programs or IDEs that support refactoring for Ruby or RoR?</p>
<p>The best refactoring tool is good test coverage. If your tests cover your code and they all past you can just make whatever changes you want and the tests will find any dependencies you have broken. This is the main reason why IDE-based refactoring tools are less prevalent in Ruby than elsewhere.</p>
<p>There's also <a href="http://www.codegear.com/products/3rdrail" rel="nofollow noreferrer">3rdRail</a> from CodeGear (from Delphi fame). The only catch is that it's not free.</p>
9,848
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/83073/why-not-use-tables-for-layout-in-html">Why not use tables for layout in HTML?</a> </p> </blockquote> <p>Under what conditions should you choose tables instead of DIVs in HTML coding?</p>
<p>The whole "Tables vs Divs" thing just barely misses the mark. It's not "table" or "div". It's about using semantic html.</p> <p>Even the div tag plays only a small part in a well laid out page. Don't overuse it. You shouldn't need that many if you put your html together correctly. Things like lists, field sets, legends, labels, paragraphs, etc can replace much of what a div or span is often used to accomplish. Div should be used primarily when it makes sense to indicate a logical <b>div</b>ision, and only appropriated for extra layout when absolutely necessary. The same is true for table; use it when you have tabular data, but not otherwise.</p> <p>Then you have a more semantic page and you don't need quite as many classes defined in your CSS; you can target the tags directly instead. Possibly most importantly, you have a page that will score much better with Google (anecdotally) than the equivalent table or div-heavy page. Most of all it will help you better connect with a portion of your audience.</p> <p>So if we go back and look at it in terms of table vs div, it's my opinion that we've actually come to the point where div is over-used and table is under-used. Why? Because when you really think about it, there are a lot of things out there that fall into the category of "tabular data" that tend to be overlooked. Answers and comments on this very web page, for example. They consist of multiple records, each with the same set of fields. They're even stored in a sql server table, for crying out loud. This is the exact definition of tabular data. This means an html table tag would absolutely be a good semantic choice to layout something like the posts here on Stack Overflow. The same principle applies to many other things as well. It may not be a good idea to use a table tag to set up a three column layout, but it's certainly just fine to use it for grids and lists... except, of course, when you can actually use the ol or ul (list) tags.</p>
<blockquote> <p>One other use I would have for it would be forms, particularly label : textbox pairs. This could technically be done in div boxes, but it's much, much easier to do this in tables, and one can argue that label:textbox pairs are in fact tabular in nature.</p> </blockquote> <p>I see that a fair amount, especially among MS developers. And I've done it a fair amount in the past. It works, but it ignores some accessibility and best-practice factors. You should use labels, inputs, fieldsets, legends, and CSS to layout your forms. Why? Because that's what they are for, it's more efficient, and I think accessibility is important. But that's just my personal preference. I think everyone should try it that way first before condemning it. It's quick, easy, and clean. </p>
5,013
<p>I'm interested in 3d printed reaction chambers, but can't find any good information on chemical resistances of PLA, just vague claims that it "might not be" "because it's biodegradable" or that it depends on additives (likely true, but it would be nice to know if there's hope of finding PLA without problematic additives if the PLA itself is okay). Is there any published research or even anecdotes (which could suggest it's worth spending effort to investigate further) on this topic?</p>
<p>The paper <a href="https://www.researchgate.net/publication/326697946_Chemical_Compatibility_of_Fused_Filament_Fabrication-based_3-D_Printed_Components_with_Solutions_Commonly_Used_in_Semiconductor_Wet_Processing" rel="nofollow noreferrer">Chemical Compatibility of Fused Filament Fabrication-based 3-D Printed Components with Solutions Commonly Used in Semiconductor Wet Processing</a>, found by user R Kiselev in the comments on <a href="https://3dprinting.stackexchange.com/questions/13897/how-to-get-a-quality-print-of-a-thin-single-walled-shell">another question</a>, has results for this, and finds (this is summarized; details in paper) that PLA has fairly good resistance to HCl at 37%. It did not fare as well against other acids or solvents except IPA.</p>
<p>As @T. M. notes in his comment, there are many good charts of chemical compatibility with various agents. Very few (I found none) include information about PLA. By all means, use search engines to find some information.</p> <p>But, no data source is as true to your specific needs as is testing your candidate materials with your agents. </p> <p>As a first test put the agent in a tall thin jar or test tube. Use a few test filaments so that the ends are dipping into the agent. Check for signs of dissolution, swelling, softening, or any relevant change in the material's characteristics. Examine the candidate filaments right away, then after minutes, then hours, and if any material survives, perhaps in days.</p> <p>Print test objects. Test them with your agent. Try until you find something that works.</p> <p>The online material compatibility tables will help you eliminate materials before testing them. If it says a material is incompatible, it probably is incompatible. If rated as highly compatible, it should be tested because the formulation of a filament may not match the material tested for the compatibility tables. If you are running out of options, try the intermediate compatibility plastics.</p> <p>Bottom line, use the online information to help direct your search, but you should do your own tests.</p>
1,273
<p>I need to pass a UUID instance via http request parameter. Spring needs a custom type converter (from String) to be registered. How do I register one?</p>
<p>Please see chapter 5 of the spring reference manual here: <a href="http://static.springframework.org/spring/docs/2.5.x/reference/validation.html#beans-beans-conversion-customeditor-registration" rel="nofollow noreferrer">5.4.2.1. Registering additional custom PropertyEditors</a></p>
<p>Not sure what you are asking?</p> <p>Spring comes with a <a href="http://static.springframework.org/spring/docs/2.5.5/api/org/springframework/beans/factory/config/CustomEditorConfigurer.html" rel="nofollow noreferrer">CustomEditorConfigurer</a> to supply custom String &lt;-> Object converters.</p> <p>To use this, just add the CustomEditorConfigurer as bean to your config, and add the custom converters. However, these converters are typically used when converting string attributes in the config file into real objects.</p> <p>If you are using Spring MVC, then take a look at the section on <a href="http://static.springframework.org/spring/docs/2.5.5/reference/mvc.html#mvc-annotation" rel="nofollow noreferrer">annotated MVC</a></p> <p>Specifically, have a look at the <strong>@RequestParam</strong> and the <strong>@ModelAttribute</strong> annotations?</p> <p>Hope this helps? </p>
9,350
<p>I have a very large code base that contains extensive unit tests (using CppUnit). <b>I need to work out what percentage of the code is exercised by these tests</b>, and (ideally) generate some sort of report that tells me on a per-library or per-file basis, how much of the code was exercised.</p> <p>Here's the kicker: this has to run completely unnatended (eventually inside a continuous integration build), and has to be cross platform (well, WIN32 and *nix at least).</p> <p>Can anyone suggest a tool, or set of tools that can help me do this? I can't change away from CppUnit (nor would I want to - it kicks ass), but otherwise I'm eager to hear any recommendations you might have.</p> <p>Cheers,</p>
<h3>Which tool should I use?</h3> <p>This <a href="http://web.archive.org/web/20090527141110/http://www.kimbly.com/blog/000331.html" rel="noreferrer">article describes</a> another developers frustrations searching for C++ code coverage tools. The author's final solution was <a href="http://www.bullseye.com/" rel="noreferrer">Bullseye Coverage</a>.</p> <p><strong><a href="http://www.bullseye.com/" rel="noreferrer">Bullseye Coverage</a> features:</strong></p> <ul> <li><a href="http://www.bullseye.com/platform.html" rel="noreferrer">Cross Platform Support</a> (win32, unix, and embedded), (supports linux gcc compilers and MSVC6)</li> <li><a href="http://www.bullseye.com/usability.html" rel="noreferrer">Easy to use</a> (up and running in a few hours).</li> <li><a href="http://www.bullseye.com/measurementTechnique.html" rel="noreferrer">Provides &quot;best&quot; metrics</a>: Function Coverage and Condition/Decision Coverage.</li> <li>Uses source code instrumentation.</li> </ul> <p>As for hooking into your continuous integration, it depends on which CI solution you use, but you can likely hook the instrumentation / coverage measurement steps into the make file you use for automated testing.</p> <hr /> <h3>Testing Linux vs Windows?</h3> <p>So long as all your tests run correctly in both environments, you should be fine measuring coverage on one or the other. (Though Bullseye appears <a href="http://www.bullseye.com/platform.html" rel="noreferrer">to support both platforms</a>). But why aren't you doing continuous integration builds in both environments?? If you deliver to clients in both environments then you <em>need</em> to be testing in both.</p> <p>For that reason, it sounds like you might need to have two continuous build servers set up, one for a linux build and one for a windows build. Perhaps this can be easily accomplished with some virtualization software like <a href="http://www.vmware.com/" rel="noreferrer">vmware</a> or <a href="http://www.virtualbox.org/" rel="noreferrer">virtualbox</a>. You may not need to run code coverage metrics on both OSs, but you should definitely be running your unit tests on both.</p>
<p>I guess I should have specified the compiler - we're using gcc for Linux, and MSVC 6 (yeah I know, it's old, but it works (mostly) for us) for WIn32.</p> <p>For that reasons, gcov won't work for our Win32 builds, and Bullseye won't work for our Linux builds.</p> <p>Then again maybe I only need coverage in one OS...</p>
5,300
<p>Yacc does not permit objects to be passed around. Because the %union can only contain POD types, complex objects must be new'd and passed around by pointer. If a syntax error occurs, the yacc parser just stops running, and references to all of those created objects are lost.</p> <p>The only solution I've come up with is that all new'd object inherit a particular base class, be added to a container when allocated, and if there is an error everything in that container can be deleted.</p> <p>Does anyone know of any better yacc tricks to solve this problem?</p> <p>Please don't tell me to choose a different parser.</p>
<p>I love Yacc, but the discriminating union stack does present a challenge.</p> <p>I don't know whether you are using C or C++. I've modified Yacc to generate C++ for my own purposes, but this solution can be adapted to C.</p> <p>My preferred solution is to pass an interface to the owner down the parse tree, rather than constructed objects up the stack. Do this by creating your own stack outside of Yacc's. Before you invoke a non-terminal that allocates an object, push the owner of that object to this stack.</p> <p>For example:</p> <pre><code>class IExpressionOwner { public: virtual ExpressionAdd *newExpressionAdd() = 0; virtual ExpressionSubstract *newExpressionSubtract() = 0; virtual ExpressionMultiply *newExpressionMultiply() = 0; virtual ExpressionDivide *newExpressionDivide() = 0; }; class ExpressionAdd : public Expression, public IExpressionOwner { private: std::auto_ptr&lt;Expression&gt; left; std::auto_ptr&lt;Expression&gt; right; public: ExpressionAdd *newExpressionAdd() { ExpressionAdd *newExpression = new ExpressionAdd(); std::auto_ptr&lt;Expression&gt; autoPtr(newExpression); if (left.get() == NULL) left = autoPtr; else right = autoPtr; return newExpression; } ... }; class Parser { private: std::stack&lt;IExpressionOwner *&gt; expressionOwner; ... }; </code></pre> <p>Everything that wants an expression has to implement the IExpressionOwner interface and push itself to the stack before invoking the expression non-terminal. It's a lot of extra code, but it controls object lifetime.</p> <p><strong>Update</strong></p> <p>The expression example is a bad one, since you don't know the operation until after you've reduced the left operand. Still, this technique works in many cases, and requires just a little tweaking for expressions.</p>
<p>Use <a href="http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smart_ptr.htm" rel="nofollow noreferrer">smart pointers</a>!</p> <p>Or, if you're uncomfortable depending on yet another library, you can always use <a href="http://www.gotw.ca/publications/using_auto_ptr_effectively.htm" rel="nofollow noreferrer">auto_ptr</a> from the C++ standard library.</p>
9,063
<p>Currently, 3D Builder is telling me "one or more objects are invalidly defined. Click here to repair." What is this and what does it mean? When I click it, it totally messes up my model (I can't tell what it even did due to the orthogonal camera). Model stats: </p> <ul> <li>Made with Sketchup</li> <li>Used STL Exporter to export it</li> <li>Last I knew what the repairing did to it was to remove my sinks and reduced them to holes in the floor</li> <li>I used ASCII encoding for my STL (I tried using Binary, but it didn't help)</li> <li>I tried subdividing it but it didn't help.</li> </ul> <p>Screenshots:</p> <p>This is a picture of the model before repairing: <a href="https://www.mediafire.com/convkey/173c/2026o54i3pm7h1szg.jpg" rel="noreferrer"><img src="https://www.mediafire.com/convkey/173c/2026o54i3pm7h1szg.jpg" alt="This is a picture of the model before repairing"></a></p> <p>This is a picture of the model after repairing: <a href="https://www.mediafire.com/convkey/cd41/uh5e97ak6j79zoyzg.jpg" rel="noreferrer"><img src="https://www.mediafire.com/convkey/cd41/uh5e97ak6j79zoyzg.jpg" alt="This is a picture of the model after repairing"></a></p> <p>(Just in case you wonder. I actually <strong>have</strong> to use STL for this project)</p>
<p>Those wavy lines could be artefacts caused by closely-spaced infill, but they could also be resonance patterns caused by noisy stepper motors and over-tight belts. Since you have said that you have your belts nice and tight, I would suggest reducing the tension on them and see what happens. I know that some pundits say that it is not possible to have timing belts too tight, but I disagree with that. Belts should obviously be tight enough to eliminate free play in the system, and you may have a lot of latitude in the tensions that you can use, but if you make them drum-tight, they will transmit motor vibrations very effectively to the build plate (and onto your models).</p> <p>If your stepper motors are noisy, you may want to invest in some vibration dampers. They can reduce noise and vibration significantly. Another solution would be to use more sophisticated stepper motor drivers, such as the TMC2100.</p> <p><a href="http://reprap.org/wiki/TMC2100" rel="noreferrer">RepRapWiki: TMC2100</a></p>
<p>It is difficult to see with the lighting and the shiny green, but try printing a more complex object, like the usual <a href="https://www.thingiverse.com/thing:1278865" rel="nofollow noreferrer">XYZ cube</a>. Does it look like this one? which means big waves after a change of direction, but then getting smaller?</p> <p><a href="https://i.stack.imgur.com/m8t6k.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8t6k.jpg" alt="enter image description here" /></a></p> <p>If so, it is &quot;ringing&quot; or &quot;ghosting&quot;, which means that the acceleration you set is too high for the mechanics of your printer and the machine vibrates too much.</p> <p>Does it look like this one? Which means, exactly aligned vertically, and everywhere, not only after changes of direction?</p> <p><a href="https://i.stack.imgur.com/Bujra.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bujra.png" alt="enter image description here" /></a></p> <p>Then it is NOT ringing, it is due</p> <ul> <li>too tight belt (almost always!)</li> <li>poor quality belt</li> <li>poor bearings or idlers (not common)</li> </ul> <p>I also had it and it was the belt, too tight. Loosen it, it can be much looser than you think before you get issues.</p> <p>Check <a href="https://3dprinting.stackexchange.com/questions/8020/how-to-fix-evenly-spaced-vertical-print-pattern">How to fix evenly spaced vertical print pattern</a> to get more information about the second issue.</p> <p>There is another potential cause for wavy walls, however I'm mentioning it for completeness, it is not the case of the question.</p> <p>If the waves repeat horizontally, but are not aligned vertically, and the extruder is a direct drive, it could be caused by the issue explained in this video, which shows that the dual gear of direct drives introduce periodic changes in flow, which are visible sometimes.</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/dL6u0UwPJOQ?start=0"></iframe> </div></div></p>
705
<p>I am using the Photoshop's javascript API to find the fonts in a given PSD.</p> <p>Given a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the disc.</p> <p>This is all happening in a python program running on OSX so I guess I'm looking for one of:</p> <ul> <li>Some Photoshop javascript</li> <li>A Python function</li> <li>An OSX API that I can call from python</li> </ul>
<p>Unfortunately the only API that isn't deprecated is located in the ApplicationServices framework, which doesn't have a bridge support file, and thus isn't available in the bridge. If you're wanting to use ctypes, you can use ATSFontGetFileReference after looking up the ATSFontRef.</p> <p>Cocoa doesn't have any native support, at least as of 10.5, for getting the location of a font.</p>
<p>open up a terminal (Applications->Utilities->Terminal) and type this in:</p> <pre><code>locate InsertFontHere </code></pre> <p>This will spit out every file that has the name you want.</p> <p>Warning: there may be alot to wade through.</p>
2,291
<p>One of the sites I maintain relies heavily on the use of <code>ViewState</code> (it isn't my code). However, on certain pages where the <code>ViewState</code> is extra-bloated, Safari throws a <code>"Validation of viewstate MAC failed"</code> error.</p> <p>This appears to only happen in Safari. Firefox, IE and Opera all load successfully in the same scenario.</p>
<p>I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it).</p> <p>I have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL State service to store the viewstate avoiding the postback issue and also page size.</p> <p><a href="http://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702" rel="nofollow noreferrer">http://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702</a></p> <p>Does this seem like the best solution?</p>
<p>My first port of call would be to go through the elements on the page and see which controls:</p> <ol> <li>Will still work when I switch ViewState off</li> <li>Can be moved out of the page and into an AJAX call to be loaded when required</li> </ol> <p>Failing that, and here's the disclaimer - I've never used this solution on a web-facing site - but in the past where I've wanted to eliminate massive ViewStates in limited-audience applications I have stored the ViewState in the Session.</p> <p>It has worked for me because the hit to memory isn't significant for the number of users, but if you're running a fairly popular site I wouldn't recommend this approach. However, if the Session solution works for Safari you could always detect the user agent and fudge appropriately.</p>
2,361
<p>I have an <code>ArrayList&lt;String&gt;</code> that I'd like to return a copy of. <code>ArrayList</code> has a clone method which has the following signature:</p> <pre><code>public Object clone() </code></pre> <p>After I call this method, how do I cast the returned Object back to <code>ArrayList&lt;String&gt;</code>?</p>
<p>Why would you want to clone? Creating a new list usually makes more sense.</p> <pre><code>List&lt;String&gt; strs; ... List&lt;String&gt; newStrs = new ArrayList&lt;&gt;(strs); </code></pre> <p>Job done.</p>
<pre><code>ArrayList first = new ArrayList (); ArrayList copy = (ArrayList) first.clone (); </code></pre>
7,857
<p>Does anyone know how to transform a enum value to a human readable value?</p> <p>For example:</p> <blockquote> <p>ThisIsValueA should be "This is Value A".</p> </blockquote>
<p>Converting this from a vb code snippet that a certain Ian Horwill left at a <a href="http://secretgeek.net/progr_purga.asp" rel="noreferrer">blog post long ago</a>... i've since used this in production successfully.</p> <pre><code> /// &lt;summary&gt; /// Add spaces to separate the capitalized words in the string, /// i.e. insert a space before each uppercase letter that is /// either preceded by a lowercase letter or followed by a /// lowercase letter (but not for the first char in string). /// This keeps groups of uppercase letters - e.g. acronyms - together. /// &lt;/summary&gt; /// &lt;param name="pascalCaseString"&gt;A string in PascalCase&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public static string Wordify(string pascalCaseString) { Regex r = new Regex("(?&lt;=[a-z])(?&lt;x&gt;[A-Z])|(?&lt;=.)(?&lt;x&gt;[A-Z])(?=[a-z])"); return r.Replace(pascalCaseString, " ${x}"); } </code></pre> <p>(requires, 'using System.Text.RegularExpressions;')</p> <p>Thus:</p> <pre><code>Console.WriteLine(Wordify(ThisIsValueA.ToString())); </code></pre> <p>Would return, </p> <pre><code>"This Is Value A". </code></pre> <p>It's much simpler, and less redundant than providing Description attributes.</p> <p>Attributes are useful here only if you need to provide a layer of indirection (which the question didn't ask for).</p>
<p>I found it best to define your enum values with an under score so ThisIsValueA would be This_Is_Value_A then you can just do a enumValue.toString().Replace("_"," ") where enumValue is your varible.</p>
3,455
<p>I am looking for a simple JavaScript example that updates DOM.<br> Any suggestions?</p>
<p>Here is a short pure-javascript example. Assume you have a div with the id "maincontent".</p> <pre><code>var newnode = document.createTextNode('Here is some text.'); document.getElementById('maincontent').appendChild(newnode); </code></pre> <p>Of course, things are a lot easier (especially when you want to do more complicated things) with jQuery.</p>
<p>I believe that this tutorial on jQuery has an example that might help you: <a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery" rel="nofollow noreferrer">http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery</a></p>
6,589
<p>I have a <code>XmlDocument</code> in java, created with the <code>Weblogic XmlDocument</code> parser.</p> <p>I want to replace the content of a tag in this <code>XMLDocument</code> with my own data, or insert the tag if it isn't there.</p> <pre><code>&lt;customdata&gt; &lt;tag1 /&gt; &lt;tag2&gt;mfkdslmlfkm&lt;/tag2&gt; &lt;location /&gt; &lt;tag3 /&gt; &lt;/customdata&gt; </code></pre> <p>For example I want to insert a URL in the location tag:</p> <pre><code>&lt;location&gt;http://something&lt;/location&gt; </code></pre> <p>but otherwise leave the XML as is.</p> <p>Currently I use a <code>XMLCursor</code>:</p> <pre><code> XmlObject xmlobj = XmlObject.Factory.parse(a.getCustomData(), options); XmlCursor xmlcur = xmlobj.newCursor(); while (xmlcur.hasNextToken()) { boolean found = false; if (xmlcur.isStart() &amp;&amp; "schema-location".equals(xmlcur.getName().toString())) { xmlcur.setTextValue("http://replaced"); System.out.println("replaced"); found = true; } else if (xmlcur.isStart() &amp;&amp; "customdata".equals(xmlcur.getName().toString())) { xmlcur.push(); } else if (xmlcur.isEnddoc()) { if (!found) { xmlcur.pop(); xmlcur.toEndToken(); xmlcur.insertElementWithText("schema-location", "http://inserted"); System.out.println("inserted"); } } xmlcur.toNextToken(); } </code></pre> <p>I tried to find a "quick" <code>xquery</code> way to do this since the <code>XmlDocument</code> has an <code>execQuery</code> method, but didn't find it very easy. </p> <p>Do anyone have a better way than this? It seems a bit elaborate.</p>
<p>How about an XPath based approach? I like this approach as the logic is super-easy to understand. The code is pretty much self-documenting.</p> <p>If your xml document is available to you as an org.w3c.dom.Document object (as most parsers return), then you could do something like the following:</p> <pre><code>// get the list of customdata nodes NodeList customDataNodeSet = findNodes(document, "//customdata" ); for (int i=0 ; i &lt; customDataNodeSet.getLength() ; i++) { Node customDataNode = customDataNodeSet.item( i ); // get the location nodes (if any) within this one customdata node NodeList locationNodeSet = findNodes(customDataNode, "location" ); if (locationNodeSet.getLength() &gt; 0) { // replace locationNodeSet.item( 0 ).setTextContent( "http://stackoverflow.com/" ); } else { // insert Element newLocationNode = document.createElement( "location" ); newLocationNode.setTextContent("http://stackoverflow.com/" ); customDataNode.appendChild( newLocationNode ); } } </code></pre> <p>And here's the helper method findNodes that does the XPath search.</p> <pre><code>private NodeList findNodes( Object obj, String xPathString ) throws XPathExpressionException { XPath xPath = XPathFactory.newInstance().newXPath(); XPathExpression expression = xPath.compile( xPathString ); return (NodeList) expression.evaluate( obj, XPathConstants.NODESET ); } </code></pre>
<p>You should be able to do this with <code>query</code></p> <p>try </p> <pre><code> fn:replace(string,pattern,replace) </code></pre> <p>I am new to xquery myself and I have found it to be a painful query language to work with, but it does work quiet well once you get over the initial learning curve. </p> <p>I do still wish there was an easier way which was as efficient? </p>
3,670
<p>Using Terminal.app on OS X 10.5, often you see the commands get garbled when you do a reverse-search with Bash. Is there some kind of termcap or perhaps a bash shopt command that can fix this? It is very annoying. </p> <p>Steps to reproduce: Open Terminal.app, reverse-search to a longish command. Hit &lt;ctrl&gt;-E once you've found the command. The cursor goes to the end of the line, but the display doesn't update. </p> <p>I'm guessing this is some kind of problem with the readline library on OS X. It's more of a problem with updating the cursor position after a search than anything else. Basically, ctrl-a and ctrl-e tend to break the search output. </p> <p><a href="http://involution.com/images/osxterminal.png">os x terminal failure image http://involution.com/images/osxterminal.png</a></p> <p>In the above, the first part of the command should be displayed, and the cursor should be at the end of the line, but it isn't. You literally can't see what you're editing when this happens. </p>
<p>I was able to set my TERM to xterm instead of xterm-color and it solves the problem. (export TERM=xterm).</p>
<p>In worst case, you could launch the X server (somewhere under utilities) and launch a real xterm. </p>
5,612
<p>What's are the best practices for versioning web sites?</p> <ul> <li>Which revision control systems are well suited for such a job?</li> <li>What special-purpose tools exist?</li> <li>What other questions should I be asking?</li> </ul>
<p>Firstly you can - and should - use a revision control system, most will handle binary files although unlike text files you can't merge two different set of changes so you may want to set the system up to lock these files whilst they are being changed (assuming that that's not the default mode of operation for you rcs in the first place).</p> <p>Where things get a bit more interesting for Websites is managing those files that are required for the site but don't actually form part of the site - the most obvious example being something like .psd files from which web graphics are produced but which don't get deployed.</p> <p>We therefore have a tree for each site which has two folders: assets and site. Assets are things that aren't in the site, and site is - well the site. </p> <p>What you have to watch with this is that designers tend to have their own "systems" for "versioning" graphic files (count the layers in the PSD). You don't need necessarily to stop them doing this but you do need to ensure that they commit each change too.</p> <p>Other questions? </p> <p>Deployment. We're still working on this one (-: But we're getting better (I'm happier now with what we do!)</p> <p>Murph</p>
<p>I use <a href="http://svnbook.red-bean.com/" rel="nofollow noreferrer">Subversion</a>. As an easy way to reference the website version (production, testing, development), I use a very simple trick. I add the revision number somewhere on the site (eg in the admin footer). Something like this:</p> <pre><code>&lt;?php print("$Revision: 1 $"); ?&gt; </code></pre> <p>Each time you checkout (development versions) or export (for production), the "1" will be replaced by the revision number in your repository, thus making it easy to setup the customer version on your test server, for example.</p>
5,781
<p>I was wondering if anyone could suggest a utility library that has useful functions for handling dates in ASP.NET easily taking away some of the leg work you normally have to do when handling dates?</p> <p>Subsonic Sugar has some really nice functions:</p> <p><a href="http://subsonichelp.com/html/1413bafa-b5aa-99aa-0478-10875abe82ec.htm" rel="nofollow noreferrer">http://subsonichelp.com/html/1413bafa-b5aa-99aa-0478-10875abe82ec.htm</a> <a href="http://subsonicproject.googlecode.com/svn/trunk/SubSonic/Sugar/" rel="nofollow noreferrer">http://subsonicproject.googlecode.com/svn/trunk/SubSonic/Sugar/</a></p> <p>Is there anything better out there?</p> <p>I was wanting to work out the start(mon) and end(sun) dates of the last 5 weeks.</p> <p>I was thinking something like this:</p> <pre><code> DateTime Now = DateTime.Now; while(Now.DayOfWeek != DayOfWeek.Monday) { Now.AddDays(-1); } for(int i=0; i&lt;5;i++) { AddToDatesList(Now, Now.AddDays(7)); Now.AddDays(-7); } </code></pre> <p>but this seems crappy? Plus this is not exactly what i want because i need the time of that start date to be <code>00:00:00</code> and the time of the end date to be <code>23:59:59</code></p>
<p>Is there a specific problem you are trying to handle with dates? If the existing date API in .NET can handle your problem cleanly, I see no reason to consider a 3rd party library to do it. When I was in .NET, we had to deal with dates quite a bit, and the standard libraries provided a fair amount of functionality to us.</p>
<p>What exactly do you want to do that System.DateTime and System.Timespan can't handle?</p>
8,687
<p>I would like to be able to add a "message" to a unit test, such that it actually appears within the TestResult.xml file generated by NUnit. For example, this is currently generated:</p> <pre><code>&lt;results&gt; &lt;test-case name="MyNamespace.Tests.MyTest" executed="True" success="True" time="0.203" asserts="4" /&gt; &lt;/results&gt; </code></pre> <p>I would like to be able to have an additional attribute (or node as the case may be), such as:</p> <pre><code>&lt;results&gt; &lt;test-case name="MyNamespace.Tests.MyTest" executed="True" success="True" time="0.203" asserts="4" message="Tested that some condition was met." /&gt; &lt;/results&gt; </code></pre> <p>The idea is that "message" above would somehow be defined within the test method itself (in my case, generated at run-time). Is there a property somewhere that I'm missing to be able to do something like this?</p>
<p>This may be missing the point, but how about naming the tests so they indicate what they test - then you may not even need the message. </p> <p>If it proves to be absolutely necessary, I think you'll need to produce your own testrunner that would (off the top of my head) read an additional attribute off the TestCase and attach it to the output.</p>
<p>I can't see anything available at run time, but there are a couple of features that you might want to investigate: the <a href="http://www.nunit.org/index.php?p=description&amp;r=2.4.8" rel="nofollow noreferrer">Description</a> attribute and the <a href="http://www.nunit.org/index.php?p=property&amp;r=2.4.8" rel="nofollow noreferrer">Property</a> attribute both add text to the XML output file. Unfortunately, they're both defined at compile time.</p>
6,638
<p>Is there a difference between 3D printing and additive manufacturing if any then explain?</p>
<p>Yes and No at the same time:</p> <h1>3D Printing is a subset of Additive Manufacturing</h1> <h3>but treated as a synonym at this time</h3> <p>3D printing is a process that takes some material, in a fluid state that fuses with the model to shape an object from it. The material could be plastics, ceramic paste or even metal. The fluid state could be the normal state, or just be present for the fusing process (think powder and resin based systems), or be a transitional phase (as in filament based systems).</p> <p>Additive manufacturing is just a slight bit bigger: at the moment most, if not all, AM processes are some sort of 3D printing. But AM could include other processes that don't fit 3D printing. For example, an automatic bricklaying machine could, under some view, be Additive Manufacturing, but it is not 3D printing in the traditional sense.</p> <p>So: All 3D Printing is Additive Manufacturing, but not all Additive Manufacturing is necessarily 3D Printing.</p>
<h3>Origin</h3> <p>3D printing and additive manufacturing (AM) both refer to a <a href="https://en.wikipedia.org/wiki/3D_printing_processes" rel="nofollow noreferrer">range of processes</a> where, opposed to subtractive manufacturing methodologies, materials are joined to create products. E.g. <a href="https://en.wikipedia.org/wiki/Fused_filament_fabrication" rel="nofollow noreferrer">FFF</a>, <a href="https://en.wikipedia.org/wiki/Selective_laser_sintering" rel="nofollow noreferrer">SLS</a>, etc.</p> <p>From <a href="https://wohlersassociates.com/additive-manufacturing.html" rel="nofollow noreferrer">this reference</a> you see a reference to 3D printing:</p> <blockquote> <p>Additive manufacturing is the official industry standard term (ASTM F2792) for all applications of the technology. It is defined as the process of joining materials to make objects from 3D model data, usually layer upon layer, as opposed to subtractive manufacturing methodologies.</p> </blockquote> <p>From e.g. <a href="https://www.tth.com/difference-3d-printing-additive-manufacturing-rapid-prototyping/" rel="nofollow noreferrer">this reference</a> one reads that there is no difference:</p> <blockquote> <p>Between the terms 3D printing and additive manufacturing, there is no difference. 3D printing and additive manufacturing are synonyms for the same process.</p> </blockquote> <h3>Useage now</h3> <p>However, as the AM processes and applications grew in time, 3D printing has become a subset of AM. As worded by <a href="https://www.additivemanufacturing.media/columns/additive-manufacturing-and-3d-printing-are-two-different-things" rel="nofollow noreferrer">Peter Zelinski</a> in August 2017:</p> <blockquote> <p>To be sure, the terms overlap. They can be used in ways that make them sound like synonyms. But the relationship between them and the difference between them is this: <strong>3D printing is the operation at the heart of additive manufacturing</strong>, just as “turning” or “molding” might be the operation at the heart of a conventional manufacturing process. In short, <strong>additive manufacturing requires and includes 3D printing, but it also entails more than 3D printing, and it refers to something more rigorous</strong>.</p> </blockquote>
1,095
<p>I could only find the function <code>confirm()</code> that gives OK/Cancel buttons. Is there any way to give Yes/No buttons?</p>
<p>Javascript offers 3 modal boxes. <code>prompt</code>, <code>confirm</code> and <code>alert</code>. None of those satisfy your request. </p> <p>There are a plethora of js modal popup solutions. Here's an example.</p> <ul> <li><a href="https://github.com/okonet/modalbox" rel="nofollow noreferrer">ModalBox</a></li> </ul>
<p>Use dialog box to display yes or no</p> <pre><code> &lt;div id="dialog_box" class="mnk-modal-bg" style="display:none"&gt; &lt;div id="dbg" class="mnk-modal-box"&gt; &lt;i class="uk-icon-exclamation-triangle" style="color:#757575; padding-right:5px;"&gt; &lt;/i&gt;Confirm? &lt;div class="uk-text-center" style="margin-top:10px;"&gt; &lt;button class="md-btn md-btn-small md-btn-primary" id="ok_btn"&gt; &lt;i class="uk-icon-save" style="padding-right:3px;"&gt;&lt;/i&gt;OK &lt;/button&gt; &lt;button class="md-btn md-btn-small md-btn-danger" id="close_btn"&gt; &lt;i class="uk-icon-remove" style="padding-right:3px;"&gt;&lt;/i&gt;Cancel &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <pre><code>&lt;script&gt; $("#ok_btn").click(function(){ alert("OK"); $("#dialog_box").hide(); }); $("#close_btn").click(function(){ alert("CANCEL"); $("#dialog_box").hide(); }); &lt;/script&gt; </code></pre>
3,971
<p>It's getting close to the time when I need to submit training and travel requests. I'm looking for conferences and classes in the coming 12 months that are geared toward improving coding and software development, best practices, system architecture, etc. They need to be in the US or Canada since I'll never get approval for anything else.</p> <p>Here are a few that I've found, but I'm looking for other suggestions. Also feedback on any of these would be appreciated too:<br> <a href="http://www.spsymposium.com/agenda.html" rel="nofollow noreferrer">Software Process Symposium</a><br> <a href="http://sdbestpractices.com/index.php?option=com_frontpage&amp;Itemid=1" rel="nofollow noreferrer">Software Development Best Practices</a><br> <a href="http://www.sqe.com/bettersoftwareconf/" rel="nofollow noreferrer">Better Software Conference</a><br> <a href="http://www.iasaconnections.com/shows/iasa2008fall/default.asp?s=119" rel="nofollow noreferrer">IASA Connections</a></p> <p>The IASA event looks like the closest match for me but doesn't give me enough lead time to request &amp; schedule it.</p>
<p>If you are using Microsoft technologies, the <a href="http://www.pnpsummit.com/" rel="nofollow noreferrer">patterns &amp; practices Summit</a> is a good event -- if you are not working pretty much 100% in the Microsoft .NET space, though, it would be of less use.</p>
<p><a href="http://infoq.com/" rel="nofollow noreferrer">InfoQ</a>'s conferences seem to be valuable. Some parts of their materials is available online.</p>
7,842
<p>I've been asked to prepare a 3D model for 3D printing in sandstone. I've been told that it needs to be 3" tall and the walls have to be at least 2&nbsp;mm thick. It's an absolute pain in the neck having to make sure everything is the right thickness. So, I was wondering, can the whole model just be printed as a solid object, with 100% infill, and does that work for sandstone?</p>
<p>Yes, you can just print it solid. However, it might be significantly more expensive to print your object entirely solid. For instance, Shapeways charges \$0.75 per cm³ of material for their full-color sandstone. A solid cube of 5x5x5 cm would cost \$96 to print, whereas it would only cost around \$6 if you printed it hollow with 2mm walls.</p>
<p>To add to the selected answer, again, yes you can, however making all of the walls AT LEAST 2mm thick shouldn't be too hard, depending on your model and modelling app.</p> <p>If your modelling app doesn't have a good shell function (or if it's too finicky on your model) you could easily define SOME negative space within the larger volumes of your model in order to save costs without having to actually make perfectly consistent wall thicknesses. Just make sure you leave a hole through which the excess material can escape from the interior void.</p> <p>Shapeways has a good set of guidelines for their full color sandstone prints, which work about the same as any: <a href="http://www.shapeways.com/materials/full-color-sandstone" rel="nofollow">http://www.shapeways.com/materials/full-color-sandstone</a> However, you'll want to double check exact measurements with your printing service.</p>
249
<p>I have a C++ app that needs to connect to a JAVA web app, are there any good, open source SOAP packages for this, or would it be easier to just roll my own?</p>
<p>I'll vote up darkhelmet since <a href="http://www.cs.fsu.edu/~engelen/soap.html" rel="noreferrer">gSoap</a> would also be my recommendation. We're mostly a Java shop but with some C++ bits and gSoap has been our preferred SOAP integration way. It is indeed more work than your typical Java stacks but it seems solid.</p>
<p>Take a look at Apache's <a href="http://ws.apache.org/axis/index.html" rel="nofollow noreferrer">Axis</a> project. It's well supported on C++ (and Java) and if you have the good fortune to start with a good WSDL for the target service you'll be home-free.</p>
6,689
<p>I want to build an ASP.NET MVC application with Boo instead of C#. If you know the steps to configure this type of project setup, I'd be interested to know what I need to do. </p> <p>The MVC project setup is no problem. What I'm trying to figure out how to configure the pages and project to switch to use the Boo language and compiler.</p>
<p>So there are two levels of "work with Boo". One would be all the code (namely, the Controllers), and the other would be the views.</p> <p>For the code, I assume Boo compiles to standard .NET assemblies, so simply properly following the naming conventions using by ASP.NET MVC should allow you to write Controllers. You will probably need to start with a C# or VB version of the MVC web application project template and port some of the boilerplate code over into Boo to get the solution entirely in Boo (I presume Boo supports Web Application projects?).</p> <p>The other half is views. Someone will need to port the Brail view engine over to the ASP.NET MVC view engine system. This may already be done, but I don't know for sure. If it's not, then this is probably a significant amount of work to be done.</p> <p>Probably the best place to get answers to these kinds of questions is the <a href="http://www.codeplex.com/MVCContrib" rel="nofollow noreferrer">MvcContrib community on CodePlex</a>.</p>
<p>The Brail view engine has been implemented to be used in ASP.NET MVC. The <a href="http://www.mvccontrib.org" rel="nofollow noreferrer">MvcContrib</a> project implemented the code. The <a href="http://code.google.com/p/mvccontrib/" rel="nofollow noreferrer">source code</a> is located on Google Code.</p> <p>As far as the controllers, I really am not sure. I am not that familiar with Boo. I know a lot of developers use it for configuration instead of using xml for instance. My tips would be, if Boo can inherit off the Controller base class and you stick to the naming conventions, you should be alright. If you vary off the naming conventions, well you would need to implement your own IControllerFactory to instantiate the boo controllers as the requests come in.</p> <p>I have been following the ASP.NET MVC bits since the first CTP and through that whole time, I have not seen somebody use Boo to code with. I think you will be the first to try to accomplish this.</p>
5,060
<p>I read that G-code commands can be sent through a console/terminal over USB. What is a console/terminal and how do you use that?</p>
<p>There are several programs that could serve as a console to connect to a printer, put let's start somewhere: the USB connection.</p> <h1>Step 1: Connection with USB</h1> <p>When connecting the printer via USB for the first time, we will get a notification that some unknown item is connected. If we use windows we can learn what device it decided we now have via the <code>device manager</code> (<code>Windows Key</code> then typing in <code>manager</code> and <code>Enter</code>). It should be a COM Port as this picture shows.</p> <p><a href="https://i.stack.imgur.com/e76LF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e76LF.png" alt="Windows Device Manager" /></a></p> <p>In this case, we have connected to <strong><code>COM4</code></strong>. To change the COM port, we can do so via a <code>Rightclick</code>-&gt;<code>properties</code>, then the <code>connection settings</code> and <code>advanced</code>. In the new window, we can change the COM port number to anything from 1 to 256, but it is recommended to keep the number somewhat low.</p> <p>Make sure you run the printer's power supply <strong>and</strong> the connection via USB, as you can't use motor control commands if you have the power supply for the printer off.</p> <h1>Step 2: Using the COM-port</h1> <p>Now, we need a program that can use the COM port to connect to the printer. There are, as said, several out there. One such is <strong><a href="https://www.repetier.com/" rel="nofollow noreferrer">Repetier Host</a></strong>, which comes with slicer and a good graphical interface. Another is <strong><a href="https://ultimaker.com/software/ultimaker-cura" rel="nofollow noreferrer">Ultimaker Cura</a></strong>, which has the same capacities but lacks logging of all the commands exchanged. Because many are familiar with it as a slicer, I will look at it first. As a third option, I will take a look at <strong><a href="https://www.pronterface.com/" rel="nofollow noreferrer">Pronterface</a></strong>.</p> <p>CAVEAT: Only <strong>one</strong> program that actively uses the COM port can be properly run at the same time, as the first program accessing the port will claim all uses for the COM port till it is shut down - any program or even other instances of the same program trying to access the port after that will have no control of the port.</p> <h2>Ultimaker Cura</h2> <p>After launching Ultimaker Cura, choose your printer. many printers are available as presets by now, so just import the printer you use or make a custom profile. At the moment the latest version of Cura is 4.1.0, and will look like this:</p> <p><a href="https://i.stack.imgur.com/q9L10.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q9L10.png" alt="Cura GUI: Top toolbar" /></a></p> <p>After switching to <code>Monitor</code>, it will automatically connect to the Printer via the COM port, in my case 4.</p> <p><a href="https://i.stack.imgur.com/f7wtl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f7wtl.png" alt="Cura GUI: Monitor Interface" /></a></p> <p>Once more we test the connection via Home <a href="https://i.stack.imgur.com/h2eaI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h2eaI.png" alt="Home Cura" /></a> and then use the Send G-Code prompt, confirming lines via <code>Enter</code>.</p> <p><a href="https://i.stack.imgur.com/gKgaI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gKgaI.png" alt="Cura GUI: G-code Prompt" /></a></p> <h2>Repetier Host</h2> <p>After running Repetier Host the first time, you need to configure your printer. <code>Ctrl</code>+<code>P</code> opens the config window for the printer. We need to know the Baud Rate of our printer, so I looked up the documentation of my Ender3, which told me 115200 is the right setting. Most printers seem to run on this setting. The other tabs decide the speeds, extruder number and limits and the bed shape. The rest isn't needed for this. My settings for the Ender3 are these: <a href="https://i.stack.imgur.com/ONkso.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ONkso.png" alt="Repetier GUI: Connection Tab" /></a> <a href="https://i.stack.imgur.com/l7srk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l7srk.png" alt="Repetier GUI: Printer Tab" /></a><a href="https://i.stack.imgur.com/CT8kE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CT8kE.png" alt="Repetier GUI: Extruder Tab" /></a><a href="https://i.stack.imgur.com/e9ATK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e9ATK.png" alt="Repetier GUI: Printer Shape Tab" /></a></p> <p>Ok, we made our settings and saved via <code>OK</code>.</p> <p>Now, we press the Connect button on the left side of the menu:</p> <p><a href="https://i.stack.imgur.com/VOyRF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VOyRF.png" alt="Repetier GUI: Disconnected left side menu" /></a></p> <p>It should change to the blue Disconnect button and display other parts of the print now, showing that we have connected. Note that at the bottom of the screen a log is filled with all the commands and exchanges.</p> <p><a href="https://i.stack.imgur.com/3jkbn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3jkbn.png" alt="Repetier Host GUI: Connected left side menu" /></a> <a href="https://i.stack.imgur.com/EFNtD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EFNtD.png" alt="Repetier Host Log snipped - very detailed" /></a></p> <p>On the right side, we now can choose the Tab <code>Manual Control</code> <a href="https://i.stack.imgur.com/zqhoY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zqhoY.png" alt="Repetier Host: Right side of Interface" /></a></p> <p>Before sending any commands, it is a good idea to press the Home <a href="https://i.stack.imgur.com/yXA1h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yXA1h.png" alt="Home" /></a> button. This also serves as an extra test to see if the printer is connected correctly. Now we can use the Prompt G-Code to send our commands. The commands will be put into the log below.</p> <p><a href="https://i.stack.imgur.com/uwa5V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uwa5V.png" alt="send G-Code line" /></a> <a href="https://i.stack.imgur.com/iZr7R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iZr7R.png" alt="Repetier Log" /></a></p> <h2>Pronterface</h2> <p>This is the first time that I used <a href="https://www.pronterface.com/" rel="nofollow noreferrer">Pronterface</a>. The first thing to do after downloading the Printrun package and running the Pronterface application is to press <code>Port</code>, then set the right Baudrate (115200 seems to work for many machines) and press <code>connect</code>.</p> <p><a href="https://i.stack.imgur.com/8qefc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8qefc.png" alt="Pronterface GUI extract: connect button" /></a></p> <p>The GUI will saturate and the right log will show lots of things tested in connection. Note that in the lower right of the GUI, there is a temperature curve log, which can be very handy for troubleshooting, as it shows the change over a little time.</p> <p><a href="https://i.stack.imgur.com/GhATh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GhATh.png" alt="Pronterface GUI extract: after connecting" /></a> <a href="https://i.stack.imgur.com/qxxUI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qxxUI.png" alt="Pronterace Log" /></a></p> <p>Below the log, we find the input for commands, and if we send a command, we get a log entry of it:</p> <p><a href="https://i.stack.imgur.com/LMwp9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LMwp9.png" alt="Pronterface Lower Right Command Prompt" /></a></p>
<p>In addition to <a href="https://3dprinting.stackexchange.com/a/10574/5740">this answer</a>, the OctoPrint 3D print server software contains a terminal which you can use to send G-code commands from a browser:</p> <h2>OctoPrint</h2> <p>In the bottom string input box (under the check mark items) you put in a G-code command, which will be send to the printer when you hit the <em>Send</em> button. If the printer gives a reply to that command, it will be displayed in the log window above the check mark interface items.</p> <p><a href="https://i.stack.imgur.com/8X5EO.png" rel="noreferrer" title="OctoPrint terminal interface"><img src="https://i.stack.imgur.com/8X5EO.png" alt="OctoPrint terminal interface" title="OctoPrint terminal interface"></a></p>
1,407
<p>I've got a table of URLs and I don't want any duplicate URLs. How do I check to see if a given URL is already in the table using PHP/MySQL?</p>
<p>If you don't want to have duplicates you can do following:</p> <ul> <li>add uniqueness constraint</li> <li>use "<a href="http://dev.mysql.com/doc/refman/5.0/en/replace.html" rel="noreferrer">REPLACE</a>" or "<a href="http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html" rel="noreferrer">INSERT ... ON DUPLICATE KEY UPDATE</a>" syntax</li> </ul> <p>If multiple users can insert data to DB, method suggested by @Jeremy Ruten, can <strong>lead to an error</strong>: after you performed a check someone can insert similar data to the table.</p>
<p>You could do this query:</p> <pre><code>SELECT url FROM urls WHERE url = 'http://asdf.com' LIMIT 1 </code></pre> <p>Then check if <a href="http://php.net/mysql_num_rows" rel="nofollow noreferrer">mysql_num_rows()</a> == 1 to see if it exists.</p>
8,613
<p>What is the best way to support multiple languages for the interface in an ASP.NET MVC application? I've seen people use resource files for other applications. Is this still the best way?</p>
<p>If you're using the default view engines, then local resources work in the views. However, if you need to grab resource strings within a controller action, you can't get local resources, and have to use global resources.</p> <p>This makes sense when you think about it because local resources are local to an aspx page and in the controller, you haven't even selected your view.</p>
<p>This is another option, and you'll have access to the CurrentUICulture in the controller: </p> <p>Check <a href="http://subvert.ca/Blog/MVC3-multi-language" rel="nofollow">MVC3-multi-language</a></p>
2,604
<p>Is it possible to detect when the user clicks on the browser's back button?</p> <p>I have an Ajax application and if I can detect when the user clicks on the back button I can display the appropriate data back</p> <p>Any solution using PHP, JavaScript is preferable. Hell a solution in any language is fine, just need something that I can translate to PHP/JavaScript</p> <h3>Edit: Cut and paste from below:</h3> <p>Wow, all excellent answers. I'd like to use Yahoo but I already use Prototype and Scriptaculous libraries and don't want to add more ajax libraries. But it uses <em>iFrames</em> which gives me a good pointer to write my own code.</p>
<p>There are multiple ways of doing it, though some will only work in certain browsers. One that I know off the top of my head is to embed a tiny near-invisible iframe on the page. When the user hits the back button the iframe is navigated back which you can detect and then update your page. <a href="http://www.ajaxonomy.com/2007/web-design/a-better-ajax-back-button-solution" rel="noreferrer">Here</a> is another solution.</p> <p>You might also want to go view source on something like gmail and see how they do it.</p> <p><a href="http://www.codeproject.com/KB/ajax/Salajax.aspx" rel="noreferrer">Here's</a> a library for the sort of thing you're looking for by the way</p>
<p>The dojo toolkit has functionality to deal with this in javascript. I don't think there is any good way to handle it in pure PHP.</p> <p>Here is the docs page they have: <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/back-button-undo" rel="nofollow noreferrer">http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/back-button-undo</a></p>
7,973
<p>I have a Singleton/Factory object that I'd like to write a JUnit test for. The Factory method decides which implementing class to instantiate based upon a classname in a properties file on the classpath. If no properties file is found, or the properties file does not contain the classname key, then the class will instantiate a default implementing class.</p> <p>Since the factory keeps a static instance of the Singleton to use once it has been instantiated, to be able to test the "failover" logic in the Factory method I would need to run each test method in a different classloader. </p> <p>Is there any way with JUnit (or with another unit testing package) to do this?</p> <p>edit: here is some of the Factory code that is in use:</p> <pre><code>private static MyClass myClassImpl = instantiateMyClass(); private static MyClass instantiateMyClass() { MyClass newMyClass = null; String className = null; try { Properties props = getProperties(); className = props.getProperty(PROPERTY_CLASSNAME_KEY); if (className == null) { log.warn("instantiateMyClass: Property [" + PROPERTY_CLASSNAME_KEY + "] not found in properties, using default MyClass class [" + DEFAULT_CLASSNAME + "]"); className = DEFAULT_CLASSNAME; } Class MyClassClass = Class.forName(className); Object MyClassObj = MyClassClass.newInstance(); if (MyClassObj instanceof MyClass) { newMyClass = (MyClass) MyClassObj; } } catch (...) { ... } return newMyClass; } private static Properties getProperties() throws IOException { Properties props = new Properties(); InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(PROPERTIES_FILENAME); if (stream != null) { props.load(stream); } else { log.error("getProperties: could not load properties file [" + PROPERTIES_FILENAME + "] from classpath, file not found"); } return props; } </code></pre>
<p>This question might be old but since this was the nearest answer I found when I had this problem I though I'd describe my solution.</p> <p><strong>Using JUnit 4</strong></p> <p>Split your tests up so that there is one test method per class (this solution only changes classloaders between classes, not between methods as the parent runner gathers all the methods once per class)</p> <p>Add the <code>@RunWith(SeparateClassloaderTestRunner.class)</code> annotation to your test classes.</p> <p>Create the <code>SeparateClassloaderTestRunner</code> to look like this:</p> <pre><code>public class SeparateClassloaderTestRunner extends BlockJUnit4ClassRunner { public SeparateClassloaderTestRunner(Class&lt;?&gt; clazz) throws InitializationError { super(getFromTestClassloader(clazz)); } private static Class&lt;?&gt; getFromTestClassloader(Class&lt;?&gt; clazz) throws InitializationError { try { ClassLoader testClassLoader = new TestClassLoader(); return Class.forName(clazz.getName(), true, testClassLoader); } catch (ClassNotFoundException e) { throw new InitializationError(e); } } public static class TestClassLoader extends URLClassLoader { public TestClassLoader() { super(((URLClassLoader)getSystemClassLoader()).getURLs()); } @Override public Class&lt;?&gt; loadClass(String name) throws ClassNotFoundException { if (name.startsWith("org.mypackages.")) { return super.findClass(name); } return super.loadClass(name); } } } </code></pre> <p>Note I had to do this to test code running in a legacy framework which I couldn't change. Given the choice I'd reduce the use of statics and/or put test hooks in to allow the system to be reset. It may not be pretty but it allows me to test an awful lot of code that would be difficult otherwise.</p> <p>Also this solution breaks anything else that relies on classloading tricks such as Mockito.</p>
<p>Below you can find a sample that does not need a separate JUnit test runner and works also with classloading tricks such as Mockito.</p> <pre><code>package com.mycompany.app; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import java.net.URLClassLoader; import org.junit.Test; public class ApplicationInSeparateClassLoaderTest { @Test public void testApplicationInSeparateClassLoader1() throws Exception { testApplicationInSeparateClassLoader(); } @Test public void testApplicationInSeparateClassLoader2() throws Exception { testApplicationInSeparateClassLoader(); } private void testApplicationInSeparateClassLoader() throws Exception { //run application code in separate class loader in order to isolate static state between test runs Runnable runnable = mock(Runnable.class); //set up your mock object expectations here, if needed InterfaceToApplicationDependentCode tester = makeCodeToRunInSeparateClassLoader( "com.mycompany.app", InterfaceToApplicationDependentCode.class, CodeToRunInApplicationClassLoader.class); //if you want to try the code without class loader isolation, comment out above line and comment in the line below //CodeToRunInApplicationClassLoader tester = new CodeToRunInApplicationClassLoaderImpl(); tester.testTheCode(runnable); verify(runnable).run(); assertEquals("should be one invocation!", 1, tester.getNumOfInvocations()); } /** * Create a new class loader for loading application-dependent code and return an instance of that. */ @SuppressWarnings("unchecked") private &lt;I, T&gt; I makeCodeToRunInSeparateClassLoader( String packageName, Class&lt;I&gt; testCodeInterfaceClass, Class&lt;T&gt; testCodeImplClass) throws Exception { TestApplicationClassLoader cl = new TestApplicationClassLoader( packageName, getClass(), testCodeInterfaceClass); Class&lt;?&gt; testerClass = cl.loadClass(testCodeImplClass.getName()); return (I) testerClass.newInstance(); } /** * Bridge interface, implemented by code that should be run in application class loader. * This interface is loaded by the same class loader as the unit test class, so * we can call the application-dependent code without need for reflection. */ public static interface InterfaceToApplicationDependentCode { void testTheCode(Runnable run); int getNumOfInvocations(); } /** * Test-specific code to call application-dependent code. This class is loaded by * the same class loader as the application code. */ public static class CodeToRunInApplicationClassLoader implements InterfaceToApplicationDependentCode { private static int numOfInvocations = 0; @Override public void testTheCode(Runnable runnable) { numOfInvocations++; runnable.run(); } @Override public int getNumOfInvocations() { return numOfInvocations; } } /** * Loads application classes in separate class loader from test classes. */ private static class TestApplicationClassLoader extends URLClassLoader { private final String appPackage; private final String mainTestClassName; private final String[] testSupportClassNames; public TestApplicationClassLoader(String appPackage, Class&lt;?&gt; mainTestClass, Class&lt;?&gt;... testSupportClasses) { super(((URLClassLoader) getSystemClassLoader()).getURLs()); this.appPackage = appPackage; this.mainTestClassName = mainTestClass.getName(); this.testSupportClassNames = convertClassesToStrings(testSupportClasses); } private String[] convertClassesToStrings(Class&lt;?&gt;[] classes) { String[] results = new String[classes.length]; for (int i = 0; i &lt; classes.length; i++) { results[i] = classes[i].getName(); } return results; } @Override public Class&lt;?&gt; loadClass(String className) throws ClassNotFoundException { if (isApplicationClass(className)) { //look for class only in local class loader return super.findClass(className); } //look for class in parent class loader first and only then in local class loader return super.loadClass(className); } private boolean isApplicationClass(String className) { if (mainTestClassName.equals(className)) { return false; } for (int i = 0; i &lt; testSupportClassNames.length; i++) { if (testSupportClassNames[i].equals(className)) { return false; } } return className.startsWith(appPackage); } } } </code></pre>
6,348
<p>I'm printing a lot of draft parts so I don't care if they fall apart in my fingers, I just need the shape. I can scroll to the Tune menu on my Ender 3 Pro console and set the speed to 200% and it doubles the speed. But when I set the Print Speed setting to 100 instead of 50 mm/s in Cura, it doesn't save much time, even if I adjust the individual first layer speed, wall speed, top layer speed, etc. What is the difference?</p> <p>Ideally, I would like the first layer to print normally, and then print at 2x speed.</p>
<p>If you use a build surface such as PEI, acetone frosts your surface, leaving a white film appearance. If you have no additional surface on a glass or metal bed, it is incomplete cleaning. If incomplete cleaning, you could try isopropyl alcohol (IPA) immediately after acetone, followed immediately by a water based cleaner or DI/distilled water. (IPA dissolves acetone and water dissolves IPA. Once the film dries the next step may not work.)</p> <p>You can't clean off a frosted surface. The black surface of the hot bed in images of the CR-10S Pro appears to indicate that the steel bed has a build surface with a plastic material such as PEI. Reviews of the build surface being difficult to remove prints also implies a plastic build surface on the steel. Thus, it appears that the white film after cleaning with acetone is actually a frosted surface.</p> <p>If you use an Elmer's washable glue stick or one with PWP, it will form a barrier between your print and the build surface, that not only will protect your build surface, but will make it easier to clean your build surface with IPA or water based cleaners.</p>
<p>If you use a build surface such as PEI, acetone frosts your surface, leaving a white film appearance. If you have no additional surface on a glass or metal bed, it is incomplete cleaning. If incomplete cleaning, you could try isopropyl alcohol (IPA) immediately after acetone, followed immediately by a water based cleaner or DI/distilled water. (IPA dissolves acetone and water dissolves IPA. Once the film dries the next step may not work.)</p> <p>You can't clean off a frosted surface. The black surface of the hot bed in images of the CR-10S Pro appears to indicate that the steel bed has a build surface with a plastic material such as PEI. Reviews of the build surface being difficult to remove prints also implies a plastic build surface on the steel. Thus, it appears that the white film after cleaning with acetone is actually a frosted surface.</p> <p>If you use an Elmer's washable glue stick or one with PWP, it will form a barrier between your print and the build surface, that not only will protect your build surface, but will make it easier to clean your build surface with IPA or water based cleaners.</p>
1,872
<p>Is there a performance difference between <code>i++</code> and <code>++i</code> if the resulting value is not used?</p>
<p>Executive summary: No.</p> <p><code>i++</code> could potentially be slower than <code>++i</code>, since the old value of <code>i</code> might need to be saved for later use, but in practice all modern compilers will optimize this away.</p> <p>We can demonstrate this by looking at the code for this function, both with <code>++i</code> and <code>i++</code>.</p> <pre><code>$ cat i++.c extern void g(int i); void f() { int i; for (i = 0; i &lt; 100; i++) g(i); } </code></pre> <p>The files are the same, except for <code>++i</code> and <code>i++</code>:</p> <pre><code>$ diff i++.c ++i.c 6c6 &lt; for (i = 0; i &lt; 100; i++) --- &gt; for (i = 0; i &lt; 100; ++i) </code></pre> <p>We'll compile them, and also get the generated assembler:</p> <pre><code>$ gcc -c i++.c ++i.c $ gcc -S i++.c ++i.c </code></pre> <p>And we can see that both the generated object and assembler files are the same.</p> <pre><code>$ md5 i++.s ++i.s MD5 (i++.s) = 90f620dda862cd0205cd5db1f2c8c06e MD5 (++i.s) = 90f620dda862cd0205cd5db1f2c8c06e $ md5 *.o MD5 (++i.o) = dd3ef1408d3a9e4287facccec53f7d22 MD5 (i++.o) = dd3ef1408d3a9e4287facccec53f7d22 </code></pre>
<p>My C is a little rusty, so I apologize in advance. Speedwise, I can understand the results. But, I am confused as to how both files came out to the same MD5 hash. Maybe a for loop runs the same, but wouldn't the following 2 lines of code generate different assembly?</p> <pre><code>myArray[i++] = "hello"; </code></pre> <p>vs</p> <pre><code>myArray[++i] = "hello"; </code></pre> <p>The first one writes the value to the array, then increments i. The second increments i then writes to the array. I'm no assembly expert, but I just don't see how the same executable would be generated by these 2 different lines of code.</p> <p>Just my two cents.</p>
4,452
<p>I know that we shouldn't being using the registry to store Application Data anymore, but in updating a Legacy application (and wanting to do the fewest changes), what Registry Hives are non-administrators allowed to use? </p> <p>Can I access all of <code>HKEY_CURRENT_USER</code> (the application currently access <code>HKEY_LOCAL_MACHINE</code>) without Administrator privileges? </p>
<p>In general, a non-administrator user has this access to the registry:</p> <p>Read/Write to:</p> <ul> <li><code>HKEY_CURRENT_USER</code></li> </ul> <p>Read Only:</p> <ul> <li><code>HKEY_LOCAL_MACHINE</code></li> <li><code>HKEY_CLASSES_ROOT</code> (which is just a <em>link</em> to <code>HKEY_LOCAL_MACHINE\Software\Classes</code>)</li> </ul> <p>It is possible to change some of these permissions on a key-by-key basis, but it's extremely rare. You should not have to worry about that.</p> <p>For your purposes, your application should be writing settings and configuration to <code>HKEY_CURRENT_USER</code>. The canonical place is anywhere within <code>HKEY_CURRENT_USER\Software\YourCompany\YourProduct\</code></p> <p>You could potentially hold settings that are global (for all users) in <code>HKEY_LOCAL_MACHINE</code>. It is very rare to need to do this, and you should avoid it. The problem is that any user can "read" those, but only an administrator (or by extension, your setup/install program) can "set" them.</p> <p>Other common source of trouble: your application should not write to anything in the <code>Program files</code> or the <code>Windows</code> directories. If you need to write to files, there are several options at hand; describing all of them would be a longer discussion. All of the options end up writing to a subfolder or another under <code>%USERPROFILE%</code> for the user in question.</p> <p>Finally, your application should stay out of <code>HKEY_CURRENT_CONFIG</code>. This hive holds hardware configuration, services configurations and other items that 99.9999% of applications should not need to look at (for example, it holds the current plug-and-play device list). If you need anything from there, most of the information is available through supported APIs elsewhere.</p>
<p>Yes, you should be able to write to any place under HKEY_CURRENT_USER without having Administrator privileges. But this is effectively a private store that no other user on this machine will be able to access, so you can't put any shared configuration there.</p>
7,656
<p>The original bed surface of my Ender 3 has become brittle and finally cracked, requiring replacement. I'm trying to figure out what the cause might have been to avoid it happening again. It seems to have started after using "flex PLA", which involves both high temperatures (225&nbsp;&deg;C) and plasticizers mixed in the PLA. Could either of these have contributed to the problem? I'm not sure what material the bed surface is - it's the new one that's removable and held on by clips. If it's PEI, the glass transition temperature is supposedly 217&nbsp;&deg;C, just above what I use for normal PLA but well below what I'm using for the flex, so perhaps that's the cause?</p> <p>Image of the damage: <img src="https://i.stack.imgur.com/wXWW4.jpg" alt="Image of the damage"></p>
<p>The build surface on the Ender3 is a BuildTak clone. The picture is a bit unclear, but given my experience with BuildTak (clones) this certainly damage because of heat. You can, as suggested before, replace the bed surface, but I do not think it is necessary at this stage. </p> <p>Normally these surfaces do not get damaged that easily but to prolong the life try to keep the following points in mind:</p> <ul> <li>Correct height between nozzle and bed.</li> <li>Don't let the nozzle heat up/cool down close to the bed (for example after a failed first layer).</li> <li>When using sharp tools to remove prints be careful nut to dig into the surface.</li> <li>Don't use too high of a bed temperature (my BuildTak clone once had bubbles forming because the layers separated)</li> <li>Clean/degrease the bed, although this is more to ensure proper bed adhesion.</li> <li>I found out that if the bed stops sticking you can revive it by sanding it a bit.</li> </ul>
<p>The material used for the Build surface is not PEI but a BuildTak Clone that offers adhesion through a rough surface texture. I do not know what exactly is in the composition of the polymer, but I can say that my bed surface needed replacement about 9 months after purchase after I vigorously removed a piece I printed. As a matter of fact, most build surfaces - even PEI - are pretty much going to wear out over time and need occasional replacement. Luckily, a build surface isn't expensive usually.</p> <p>To prolong the life of the bed surface, I suggest:</p> <ul> <li>check the nozzle distance to the bed, as printing too close can make plastic residue extremely hard to remove.</li> <li>be very careful when using sharp tools to remove parts - don't let a corner bite into the surface!</li> <li>don't use a soldering iron or hot air gun on the build platform to remove stuck parts, you'll melt the surface and degrade it</li> <li>clean the surface at times.</li> </ul> <p>However, replacing the bed is easy enough, as I found out <a href="https://3dprinting.stackexchange.com/questions/7960/how-to-clean-up-my-buildpate-for-a-new-build-surface">here</a>.</p>
1,295
<p>Is it possible to remote-debug a Visual C++ 6.0 application running on a Windows NT machine from a developer workstation running Windows XP? If so, is there a procedure written up somewhere?</p>
<p>Take a look at <a href="http://www.codeproject.com/KB/debug/remotedebug.aspx" rel="nofollow noreferrer">this article.</a> Also <a href="http://msdn.microsoft.com/en-us/library/bt727f1t.aspx" rel="nofollow noreferrer">this</a> may be helpful although you don't mention which version of the IDE you're using. </p>
<p>Yes -- you can also use a newer version of Visual Studio. As long as you have the PDB file for the target application it doesn't matter what version it was built with (well, VS6 might not understand a newer PDB, but backwards should be fine).</p> <p>The remote debugging experience on newer VS versions is a lot smoother than old versions in my experience. It is also easier to set up if you can arrange things so that you are attaching to an existing process that you have started manually rather than kicking off the process (avoid a lot of the path setup).</p>
6,812
<p>I am running an Ender 3 pro with an Octoprint connected. I accidentally set the print speed too slow in Cura and the print will take very long. Is there a Marlin command I can issue to the printer to speed it up without stopping the print?</p>
<h1>yes</h1> <p>Print speed is a setting that can be altered by just turning the click-wheel of the Ender 3. You don't need to push it to gain access to menus. A turn to the right does increase the speed, left lowers it. It is applied only some moments after stopping the turning - then the firmware does inject a <code>M220</code> command as the next line. This means the current running movement is ended with the last set speed, the new speed is set and the following command will be done with the new speed.</p> <p>As towe correctly states, one can also send a <code>M220</code> command to the printer via a terminal, but then you need to have one set up <em>before</em> the print starts, as plugging in a terminal will <strong>reset</strong> your printer and abort the print!</p>
<h1>yes</h1> <p>Print speed is a setting that can be altered by just turning the click-wheel of the Ender 3. You don't need to push it to gain access to menus. A turn to the right does increase the speed, left lowers it. It is applied only some moments after stopping the turning - then the firmware does inject a <code>M220</code> command as the next line. This means the current running movement is ended with the last set speed, the new speed is set and the following command will be done with the new speed.</p> <p>As towe correctly states, one can also send a <code>M220</code> command to the printer via a terminal, but then you need to have one set up <em>before</em> the print starts, as plugging in a terminal will <strong>reset</strong> your printer and abort the print!</p>
1,769
<p>Does anyone know of a good method for editing PDFs in PHP? Preferably open-source/zero-license cost methods. :)</p> <p>I am thinking along the lines of opening a PDF file, replacing text in the PDF and then writing out the modified version of the PDF?</p> <p>On the front-end</p>
<p>If you are taking a 'fill in the blank' approach, you can precisely position text anywhere you want on the page. So it's relatively easy (if not a bit tedious) to add the missing text to the document. For example with Zend Framework:</p> <pre><code>&lt;?php require_once 'Zend/Pdf.php'; $pdf = Zend_Pdf::load('blank.pdf'); $page = $pdf-&gt;pages[0]; $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); $page-&gt;setFont($font, 12); $page-&gt;drawText('Hello world!', 72, 720); $pdf-&gt;save('zend.pdf'); </code></pre> <p>If you're trying to replace inline content, such as a "[placeholder string]," it gets much more complicated. While it's technically possible to do, you're likely to mess up the layout of the page.</p> <p>A PDF document is comprised of a set of primitive drawing operations: line here, image here, text chunk there, etc. It does not contain any information about the layout intent of those primitives.</p>
<p>We use <a href="http://www.pdflib.com/pdflib-gmbh/" rel="nofollow noreferrer">pdflib</a> to create PDF files from our rails apps. It has bindings for PHP, and a ton of other languages.</p> <p>We use the commmercial version, but they also have a <a href="http://www.pdflib.com/download/pdflib-family/pdflib-lite/" rel="nofollow noreferrer">free/open source version</a> which has some limitations.</p> <p>Unfortunately, this only allows creation of PDF's.</p> <p>If you want to open and 'edit' existing files, pdflib do provide <a href="http://www.pdflib.com/products/pdflib-family/pdi/" rel="nofollow noreferrer">a product which does this this</a>, but costs a <a href="https://www.pdflib.com/buy/online-shop/pdflib-pdflib-pdi-pps/" rel="nofollow noreferrer">LOT</a></p>
2,896
<p>I have a strange problem with my cake (cake_1.2.0.7296-rc2). My start()-action runs twice, under certain circumstances, even though only one request is made.</p> <p>The triggers seem to be : - loading an object like: <code>$this-&gt;Questionnaire-&gt;read(null, $questionnaire_id);</code> - accessing $this-data </p> <p>If I disable the call to <code>loadAvertisement()</code> from the <code>start()</code>-action, this does not happen. If I disable the two calls inside <code>loadAdvertisement():</code></p> <pre><code>$questionnaire = $this-&gt;Questionnaire-&gt;read(null, $questionnaire_id); $question = $this-&gt;Questionnaire-&gt;Question-&gt;read(null, $question_id); </code></pre> <p>... then it doesn't happen either.</p> <p>Why?</p> <p>See my code below, the Controller is "questionnaires_controller".</p> <pre><code>function checkValidQuestionnaire($id) { $this-&gt;layout = 'questionnaire_frontend_layout'; if (!$id) { $id = $this-&gt;Session-&gt;read('Questionnaire.id'); } if ($id) { $this-&gt;data = $this-&gt;Questionnaire-&gt;read(null, $id); //echo "from ".$questionnaire['Questionnaire']['validFrom']." ".date("y.m.d"); //echo " - to ".$questionnaire['Questionnaire']['validTo']." ".date("y.m.d"); if ($this-&gt;data['Questionnaire']['isPublished'] != 1 //|| $this-&gt;data['Questionnaire']['validTo'] &lt; date("y.m.d") //|| $this-&gt;data['Questionnaire']['validTo'] &lt; date("y.m.d") ) { $id = 0; $this-&gt;flash(__('Ungültiges Quiz. Weiter zum Archiv...', true), array('action'=&gt;'archive')); } } else { $this-&gt;flash(__('Invalid Questionnaire', true), array('action'=&gt;'intro')); } return $id; } function start($id = null) { $this-&gt;log("start"); $id = $this-&gt;checkValidQuestionnaire($id); //$questionnaire = $this-&gt;Questionnaire-&gt;read(null, $id); $this-&gt;set('questionnaire', $this-&gt;data); // reset flow-controlling session vars $this-&gt;Session-&gt;write('Questionnaire',array('id' =&gt; $id)); $this-&gt;Session-&gt;write('Questionnaire'.$id.'currQuestion', null); $this-&gt;Session-&gt;write('Questionnaire'.$id.'lastAnsweredQuestion', null); $this-&gt;Session-&gt;write('Questionnaire'.$id.'correctAnswersNum', null); $this-&gt;loadAdvertisement($id, 0); $this-&gt;Session-&gt;write('Questionnaire'.$id.'previewMode', $this-&gt;params['named']['preview_mode']); if (!$this-&gt;Session-&gt;read('Questionnaire'.$id.'previewMode')) { $questionnaire['Questionnaire']['participiantStartCount']++; $this-&gt;Questionnaire-&gt;save($questionnaire); } } function loadAdvertisement($questionnaire_id, $question_id) { //$questionnaire = array(); $questionnaire = $this-&gt;Questionnaire-&gt;read(null, $questionnaire_id); //$question = array(); $question = $this-&gt;Questionnaire-&gt;Question-&gt;read(null, $question_id); if (isset($question['Question']['advertisement_id']) &amp;&amp; $question['Question']['advertisement_id'] &gt; 0) { $this-&gt;set('advertisement', $this-&gt;Questionnaire-&gt;Question-&gt;Advertisement-&gt;read(null, $question['Question']['advertisement_id'])); } else if (isset($questionnaire['Questionnaire']['advertisement_id']) &amp;&amp; $questionnaire['Questionnaire']['advertisement_id'] &gt; 0) { $this-&gt;set('advertisement', $this-&gt;Questionnaire-&gt;Question-&gt;Advertisement-&gt;read(null, $questionnaire['Questionnaire']['advertisement_id'])); } } </code></pre> <p>I really don't understand this... it don't think it's meant to be this way. Any help would be greatly appreciated! :)</p> <p>Regards, Stu</p>
<p>Check your layout for non-existent links, for example a misconfigured link to favicon.ico will cause the controller action to be triggered for a second time. Make sure favicon.ico points towards the webroot rather than the local directory, or else requests will be generated for /controller/action/favicon.ico rather than /favicon.ico - and thus trigger your action.</p> <p>This can also happen with images, stylesheets and javascript includes.</p> <p>To counter check the $id is an int, then check to ensure $id exists as a primary key in the database before progressing on to any functionality.</p>
<p>I had the same problem in chrome, I disabled my 'HTML Validator' add on. Which was loading the page twice</p>
8,932
<p>What is the best way to create fluid width/height rounded corners with jQuery?</p> <hr> <p>That plugin doesn't keep the height the same. I have a 10px high div that I want to round the corners on, when I use that script it adds about 10px onto whats there.</p>
<pre><code>$(this).corner(); </code></pre> <p>See: <a href="http://malsup.com/jquery/corner" rel="nofollow noreferrer">malsup.com/jquery/corner</a> and <a href="http://github.com/malsup/corner" rel="nofollow noreferrer">github repository for future ref</a></p>
<p>If you want full control about the border an d gradient, you can use my iQuery Background Canvas plugin. It works with a HTML5 Canvas element and allows to draw borders and backgrounds in any variation. But you should be able to program JavaScript</p> <p>This is a full featured sample with a background gradient and rounded corners. as you can see, the drawing is completely done in JavaScript, you can set every parameter you want. The drawing is redone on every resize (Due to the resize Event), you can adapt the background drawing to show wat you want on this specific size. </p> <pre><code>$(document).ready(function(){ $(".Test").backgroundCanvas(); }); function DrawBackground() { $(".Test").backgroundCanvasPaint(TestBackgroundPaintFkt); } // Draw the background on load and resize $(window).load(function () { DrawBackground(); }); $(window).resize(function() { DrawBackground(); }); function TestBackgroundPaintFkt(context, width, height, elementInfo){ var options = {x:0, height: height, width: width, radius:14, border: 0 }; // Draw the red border rectangle context.fillStyle = "#FF0000"; $.canvasPaint.roundedRect(context,options); // Draw the gradient filled inner rectangle var backgroundGradient = context.createLinearGradient(0, 0, 0, height - 10); backgroundGradient.addColorStop(0 ,'#AAAAFF'); backgroundGradient.addColorStop(1, '#AAFFAA'); options.border = 5; context.fillStyle = backgroundGradient; $.canvasPaint.roundedRect(context,options); } </code></pre> <p>Here is the plugin, and this site makes a vast use of it: <a href="http://www.maierhofer.de/en/open-source/jquery-background-canvas-plugin.aspx" rel="nofollow noreferrer">jQuery Background Canvas Plugin</a></p>
5,597
<p>What are the different database options on Windows Mobile available? I have used CEDB and EDB for linear dataset needs.</p> <p>I have heard of SQL server 2005 Mobile edition. But what are the advantages over others (if there is any)</p>
<p>I've found both sqllite and codebase to be easy to implement and install. Easier (and more stable) than the Microsoft options, which seem to be in serious flux.</p>
<p>I would avoid using CEDB any more as I beleave that WM7 is dropping support for it. </p>
7,887
<p>does anyone have a clue why the TortoiseSVN windows client (in Win32 XP and Vista) is so incredible slow when used with Putty and PAM? It seems it connects for each request since datatransfers (checkout) are not slow at all?</p> <p>Any ideas how to change it?</p> <p>Update: I had no problems with SSH before. But I have to use key based authentification. </p>
<p>Do you have a problem with standard SSH connections to the server as well? If it's generally slow to connect to your server via SSH, this could be a problem with reverse DNS lookups.</p> <p>Andrew</p>
<p>What type of system are you connecting to? If you connect to OpenSUSE, for example, default DNS Reverse Lookup settings generally cause SSH connections to be very slow. If you can, put your client side IP address into the /etc/hosts table on the server. If Reverse DNS is your issue, this will resolve (remember to restart nscd daemon - "/etc/init.d/nscd restart" so that the change will take effect.)</p> <p>SSH will be slower than native SVN protocol but not by an order or magnitude and not likely to a level that you will notice. But Reverse DNS timeouts could be several seconds per request.</p>
3,551
<p>gnuplot is giving the error: "sh: kpsexpand: not found." </p> <p>I feel like the guy in Office Space when he saw "PC LOAD LETTER". What the heck is kpsexpand?</p> <p>I searched Google, and there were a lot of pages that make reference to kpsexpand, and say not to worry about it, but I can't find anything, anywhere that actually explains <em>what it is.</em></p> <p>Even the man page stinks:</p> <pre><code>$ man kpsexpand kpsetool - script to make teTeX-style kpsetool, kpsexpand, and kpsepath available </code></pre> <p>Edit: Again, I'm not asking what to do -- I know what to do, thanks to Google. What I'm wondering is what the darn thing <em>is.</em></p>
<p>kpsexpand, kpsetool and kpsepath are all wrappers for kpsewhich that deals with finding tex-related files kpsexpand is used to expand environment varibles. Say $VAR1 is "Hello World" and $VAR2 is "/home/where/I/belong" then</p> <pre><code>$ kpsexpand $VAR1</code></pre> <p>will return</p> <pre><code>Hello World</code></pre> <p>and <pre><code>$ kpsexpand $VAR2</code></pre> will return</p> <pre>/home/where/I/belong</pre> <p><code>kpsewhich</code> is reminiscent to <code>which</code> just like <code>which progname</code> will search the directories in the $PATH environment variable and return the path of the first found progname, <code>kpsewhich filename</code> will search the directories in the various tex-paths, fonts, packages, etc. for filename.</p> <p>to find out more lookup kpsewhich either in man or on google, and check out the source of kpsexpand</p> <pre><code>less `which kpsexpand`</code></pre> <p>Cheers /B2S</p>
<p>This is on the first page of google search results for "kpexpand gnuplot":</p> <p><a href="http://dschneller.blogspot.com/2007/06/visualize-hard-disk-temperature-with.html" rel="nofollow noreferrer">http://dschneller.blogspot.com/2007/06/visualize-hard-disk-temperature-with.html</a></p> <p>It says that you do not need to care about the error-messages.</p> <p>Here is the manual page for kpsexpand:</p> <p><a href="http://linux.die.net/man/1/kpsexpand" rel="nofollow noreferrer">http://linux.die.net/man/1/kpsexpand</a></p>
9,493
<p>I have one field that I need to sum lets say named items However that field can be part of group a or b In the end I need to have all of the items summed for group a and group b</p> <p>when I say grouped I mean there is a LEFT OUTER JOIN to another table the previous table has a type for the items and the one being joined has a group assigned for this item type</p> <p>Sorry guys Im a little new to sql I am going to try out what you have given me an get back to you</p> <p>Ok I feel like we are getting close just not yet allain's I can get them to separate but the issue I need to have both groups to sum on the same row which is difficult because I also have several LEFT OUTER JOIN's involved</p> <p>Tyler's looks like it might work too so I am trying to hash that out real fast</p> <p>Alain's seems to be the way to go but I have to tweek it a little more</p>
<p>Maybe I'm not understanding the complexity of what you're asking but... shouldn't this do?</p> <pre><code>SELECT groupname, SUM(value) FROM items WHERE groupname IN ('a', 'b') GROUP BY groupname </code></pre> <p>And if you don't care which of a or b the item belongs to then this will do:</p> <pre><code>SELECT SUM(value) FROM items WHERE groupname IN ('a', 'b') </code></pre>
<p>Please refer this Image (<a href="https://i.stack.imgur.com/5R9ou.png" rel="nofollow noreferrer">1</a>)</p> <pre><code>SELECT category_id,SUM(amount) AS count FROM expense GROUP BY category_id; </code></pre>
5,044
<p>I am writing an immutable DOM tree in Java, to simplify access from multiple threads.*</p> <p>However, it does need to support inserts and updates as fast as possible. And since it is immutable, if I make a change to a node on the N'th level of the tree, I need to allocate at least N new nodes in order to return the new tree.</p> <p>My question is, would it be dramatically faster to pre-allocate nodes rather than create new ones every time the tree is modified? It would be fairly easy to do - keep a pool of several hundred unused nodes, and pull one out of the pool rather than create one whenever it was required for a modify operation. I can replenish the node pool when there's nothing else going on. (in case it isn't obvious, execution time is going to be much more at a premium in this application than heap space is)</p> <p>Is it worthwhile to do this? Any other tips on speeding it up?</p> <p>Alternatively, does anyone know if an immutable DOM library already? I searched, but couldn't find anything.</p> <p>*Note: For those of you who aren't familiar with the concept of immutability, it basically means that on any operation to an object that changes it, the method returns a copy of the object with the changes in place, rather than the changed object. Thus, if another thread is still reading the object it will continue to happily operate on the "old" version, unaware that changes have been made, rather than crashing horribly. See <a href="http://www.javapractices.com/topic/TopicAction.do?Id=29" rel="nofollow noreferrer">http://www.javapractices.com/topic/TopicAction.do?Id=29</a></p>
<p>These days, object creation is pretty dang fast, and the concept of object pooling is kind of obsolete (at least in general; connection pooling is of course still valid).</p> <p>Avoid premature optimization. Create your nodes when you need them when doing your copies, and then see if that becomes prohibitively slow. If so, then look into some techniques to speed it up. But unless you already know that what you've got isn't fast enough, I wouldn't go introducing all the complexity you're going to need to get pooling going.</p>
<p>I'm a little confused about what you're trying to do in the first place. You want all of the nodes to be immutable AND you want to pool them? Aren't these 2 ideas mutually exclusive? When you pull an object out of the pool, won't you have to invoke a setter to link up the children?</p> <p>I think that using immutable nodes is probably not going to give you the kind of thread-safety you need in the first place. What happens if 1 thread is iterating over the nodes (a search or something), while another thread is adding/removing nodes? Won't the results of the search be invalid? I'm not sure if you can avoid explicitly synchronizing certain methods in order to make sure everything is thread-safe.</p>
6,382
<p>I'm writing a C/C++ DLL and want to export certain functions which I've done before using a .def file like this</p> <pre><code>LIBRARY "MyLib" EXPORTS Foo Bar </code></pre> <p>with the code defined as this, for example:</p> <pre><code>int Foo(int a); void Bar(int foo); </code></pre> <p>However, what if I want to declare an overloaded method of Foo() like:</p> <pre><code>int Foo(int a, int b); </code></pre> <p>As the def file only has the function name and not the full prototype I can't see how it would handle the overloaded functions. Do you just use the one entry and then specify which overloaded version you want when passing in the properly prototyped function pointer to LoadLibrary() ?</p> <p>Edit: To be clear, this is on Windows using Visual Studio 2005</p> <p>Edit: Marked the non-def (__declspec) method as the answer...I know this doesn't actually solve the problem using def files as I wanted, but it seems that there is likely no (official) solution using def files. Will leave the question open, however, in case someone knows something we don't have overloaded functions and def files.</p>
<p>In the code itself, mark the functions you want to export using __declspec(dllexport). For example:</p> <pre><code>#define DllExport __declspec(dllexport) int DllExport Foo( int a ) { // implementation } int DllExport Foo( int a, int b ) { // implementation } </code></pre> <p>If you do this, you do not need to list the functions in the .def file.</p> <p>Alternatively, you may be able to use a default parameter value, like:</p> <pre><code>int Foo( int a, int b = -1 ) </code></pre> <p>This assumes that there exists a value for b that you can use to indicate that it is unused. If -1 is a legal value for b, or if there isn't or shouldn't be a default, this won't work.</p> <p>Edit (Adam Haile): Corrected to use __declspec as __dllspec was not correct so I could mark this as the official answer...it was close enough. </p> <p>Edit (Graeme): Oops - thanks for correcting my typo!</p>
<p>There isn't a language or version agnostic way of exporting an overloaded function since the mangling convention can change with each release of the compiler.</p> <p>This is one reason why most WinXX functions have funny names like *Ex or *2.</p>
4,568
<p>I'm getting wavy lines on the first layer only in both the x and y direction identically. The first layer is 0.4 mm with a 0.4 mm tip. The other layers are 0.2 mm. I've tried changing the Z offset all the way from -1.2 to 0.5 mm. I've tried changing the hot end leveling the heated bed. None of these changes affected the wavy lines. The waves have about a 1 mm period. The printer is a German RipRap. The material is ABS. The heated bed is 110&nbsp;&deg;C. I've tried the hot end at 220&nbsp;&deg;C and 240&nbsp;&deg;C. So far, nothing has changed the waves. </p> <p><a href="https://i.stack.imgur.com/e74SF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e74SF.jpg" alt="enter image description here"></a></p>
<p>You have a too thick layer: to get straight lines, the plastic has to be squished together to some degree as it is pushed out of the nozzle. The result is a shape similar to a circle with the top and bottom cut. This works well until your layer thickness is more than 3 quarters of the nozzle diameter - above the "squishing" is practically nonexistent, and if you go above the nozzle diameter, there is almost no way to get the desired thickness out of the nozzle at all.</p> <p>To aid in depositing the layers, it is <em>also</em> advised to demand a line width that is about 10 % larger than the nozzle diameter. As illustration, this is roughly what 0.4 mm extrusion width with 0.4 mm layer height (blue) and 0.45 mm extrusion width with 0.3 mm extrusion height (yellow) look like:</p> <p><a href="https://i.stack.imgur.com/BzIa5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BzIa5.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/yZqG8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yZqG8.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/ElU6V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ElU6V.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/GPRyP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GPRyP.png" alt="enter image description here"></a></p>
<p>The general recommendation for layer height is to go no thicker than 75% of the nozzle diameter. Your post states 0.4 mm layer height with a 0.4 nozzle, exceeding the recommendation.</p> <p>If your first layer is dropped to 0.3 mm, you'll fall into the recommendation, but the thickness is a reference for ALL layers.</p>
1,545
<p>In php, how can I get the number of apache children that are currently available <br>(<code>status = SERVER_READY</code> in the apache scoreboard)?</p> <p>I'm really hoping there is a simple way to do this in php that I am missing.</p>
<p>You could execute a shell command of <code>ps aux | grep httpd</code> or <code>ps aux | grep apache</code> and count the number of lines in the output.</p> <pre><code>exec('ps aux | grep apache', $output); $processes = count($output); </code></pre> <p>I'm not sure which status in the status column indicates that it's ready to accept a connection, but you can filter against that to get a count of ready processes.</p>
<p>If you have access to the Apache server status page, try using the ?auto flag:</p> <p><a href="http://yourserver/server-status?auto" rel="nofollow noreferrer">http://yourserver/server-status?auto</a></p> <p>The output is a machine-readable version of the status page. I <em>believe</em> you are looking for "IdleWorkers". Here's some simple PHP5 code to get you started. In real life you'd probably want to use cURL or a socket connection to initiate a timeout in case the server is offline.</p> <pre><code>&lt;?php $status = file('http://yourserver/server-status?auto'); foreach ($status as $line) { if (substr($line, 0, 10) == 'IdleWorkers') { $idle_workers = trim(substr($line, 12)); print $idle_workers; break; } } ?&gt; </code></pre>
9,338
<p>In <a href="https://3dprinting.stackexchange.com/a/3116/37">this question</a> I was told that I should use silver solder to connect the heating element to the power supply.</p> <p>(I was also told that a ceramic extruder head was the way to go, but I'm working with what I have)</p> <p>I bought two types of silver solider from Radio Shack: </p> <ul> <li>96/4 Silver-Bearing Solder, Lead-Free 0.62" diameter.</li> <li>62/36/2 Silver-Bearing Solder, 0.15" diameter.</li> </ul> <p>Is there any reason I should use one of these over the other to power the heading element of the J-Head extruder?</p>
<p>The first is not suitable. ASTM96TS Sn96Ag4 has a melting point of 221–229&nbsp;&deg;C according to <a href="https://en.wikipedia.org/wiki/Solder" rel="nofollow noreferrer">Wikipedia</a>. Pb96Ag4 would be OK, but that is not lead free so doesn't seem to match your description. <em>Update from comment to explain the letters and numbers: the data comes from wikipedia, the numbers are Tin(Sn) 62%, Pb(Lead) 36%, Ag(Silver) 2%, for example, see below for an electronics solder compound</em>. </p> <p>Sn62Pb36Ag2 is an ordinary expensive electronics solder (but not lead free), with an even lower melting point.</p> <p>You need to find a high temperature silver solder, with a melting point of about 305&nbsp;&deg;C (which confusingly might be a soft silver solder), for example one of <a href="http://www.cupalloys.co.uk/soft-solders/" rel="nofollow noreferrer">these</a>. Hard silver solders melt at 600&nbsp;&deg;C, that would be excessive in this application.</p> <p>The nomenclature 'silver solder' came about before lead-free electronics solder was introduced, since when more alloys containing silver have become popular as general purpose solders.</p>
<p>Use ferrules to join wires, and on your board either solder directly (it doesn't matter what solder you use because it's not going to get hot if your wires are gauged properly). Or use soft copper wires and clamping terminals without the wires being tinned or risk a fire hazard. </p> <p>Tinning makes the surface harder which makes for less contact area. If it deforms from heat , it can come loose and cause arcs, which is where the fire hazard comes from.</p>
482
<p>I've been using Eclipse with RDT (not RadRails) a lot lately, and I'm quite happy with it, but I'm wondering if you guys know any decent alternatives. I know NetBeans also supports Ruby these days, but I'm not sure what it has to offer over Eclipse.</p> <p>Please, list any features you think are brilliant or useful when suggesting an IDE, makes it easier to compare.</p> <p>Also, I said Ruby, not Rails. While Rails support is a plus, I prefer things to be none Rails-centric. It should also be available on Linux and optionally Solaris.</p>
<p>Have you tried <a href="http://www.aptana.com/" rel="nofollow noreferrer">Aptana</a>? It's based on Eclipse and they have a sweet <a href="http://www.aptana.com/rails" rel="nofollow noreferrer">Rails</a> plugin.</p>
<p>+1 for TextMate on Mac OS X.</p> <p>See also answers to <a href="https://stackoverflow.com/questions/16064/what-ide-to-use-for-developing-in-ruby-on-rails-on-windows#16086">this question</a>. I <a href="https://stackoverflow.com/questions/16064/what-ide-to-use-for-developing-in-ruby-on-rails-on-windows#16086">recommend</a> trying <a href="http://en.wikipedia.org/wiki/NetBeans" rel="nofollow noreferrer">NetBeans</a> if you're on Windows.</p>
3,770
<p>I'm currently working on a quite large library (5M lines of code, in C++ under VS2005, 1 solution and close to 100 projects). Even though we distribute compilation, and use incremental linking, recompilation and relinking after small source modifications takes between a few minutes (usually at least 3) and close to one hour.</p> <p>This means that our modify code/build/debug cycles tend to be really long (to my taste!), and it's quite easy to lose the 'flow' during a build: there's typically not much time to do anything useful (maybe do a bit of email, otherwise read some article online or a few pages of a book).</p> <p>When writing new code or doing major refactoring, I try to compile one file at a time only. However, during debugging for example, it really gets on my nerves!</p> <p>I'm wondering how I could optimize my time? I guess I'm not the only one in that situation: what do/would <em>you</em> do?</p>
<p>I don't know much about development at that level, but... it seems like it would be a good idea to separate into multiple solutions. You could have a final "pre-ship" step that consolidates them all into a single .dll if you/your customers really insist.</p> <p>Compare, e.g., to the .NET Framework where we have lots of different assemblies (System, System.Drawing, System.Windows.Forms, System.Xml...). Presumably all of these could be in different solutions, referencing each other's build results (as opposed to all in a single solution, referencing each other as projects).</p>
<p>@Domenic: indeed, it would be a good thing... However, a whole team's been at it for some time now, and until they succeed we are stuck with a single .dll and something quite monolithic :-(</p>
5,933
<p>I'd like to do some server-side scripting using Python. But I'm kind of lost with the number of ways to do that.</p> <p>It starts with the do-it-yourself CGI approach and it seems to end with some pretty robust frameworks that would basically do all the job themselves. And a huge lot of stuff in between, like <a href="http://webpy.org/" rel="nofollow noreferrer">web.py</a>, <a href="http://pyroxide.org/" rel="nofollow noreferrer">Pyroxide</a> and <a href="http://wiki.python.org/moin/Django" rel="nofollow noreferrer">Django</a>.</p> <ul> <li>What are the <strong>pros</strong> and <strong>cons</strong> of the frameworks or approaches that <em>you've worked on</em>?</li> <li>What <strong>trade-offs</strong> are there?</li> <li>For <strong>what kind of projects</strong> they do well and for what they don't?</li> </ul> <p>Edit: I haven't got much experience with web programing yet.</p> <p>I would like to avoid the basic and tedious things like parsing the URL for parameters, etc.<br /> On the other hand, while the video of <a href="http://www.rubyonrails.org/screencasts" rel="nofollow noreferrer">blog created in 15 minutes</a> with <a href="http://www.rubyonrails.org/" rel="nofollow noreferrer">Ruby on Rails</a> left me impressed, I realized that there were hundreds of things hidden from me - which is cool if you need to write a working <code>webapp</code> in no time, but not that great for really understanding the magic - and that's what I seek now.</p>
<p>CGI is great for low-traffic websites, but it has some performance problems for anything else. This is because every time a request comes in, the server starts the CGI application in its own process. This is bad for two reasons: 1) Starting and stopping a process can take time and 2) you can't cache anything in memory. You can go with FastCGI, but I would argue that you'd be better off just writing a straight <a href="http://www.python.org/dev/peps/pep-0333/" rel="noreferrer">WSGI</a> app if you're going to go that route (the way WSGI works really isn't a whole heck of a lot different from CGI).</p> <p>Other than that, your choices are for the most part how much you want the framework to do. You can go with an all singing, all dancing framework like Django or Pylons. Or you can go with a mix-and-match approach (use something like CherryPy for the HTTP stuff, SQLAlchemy for the database stuff, paste for deployment, etc). I should also point out that most frameworks will also let you switch different components out for others, so these two approaches aren't necessarily mutually exclusive.</p> <p>Personally, I dislike frameworks that do too much magic for me and prefer the mix-and-match technique, but I've been told that I'm also completely insane. :)</p> <p>How much web programming experience do you have? If you're a beginner, I say go with Django. If you're more experienced, I say to play around with the different approaches and techniques until you find the right one.</p>
<p>OK, rails is actually pretty good, but there is just a little bit too much magic going on in there (from the Ruby world I would much prefer merb to rails). I personally use Pylons, and am pretty darn happy. I'd say (compared to django), that pylons allows you to interchange ints internal parts easier than django does. The downside is that you will have to write more stuff all by youself (like the basic CRUD). </p> <p>Pros of using a framework:</p> <ol> <li>get stuff done quickly (and I mean lighning fast once you know the framework)</li> <li>everything is compying to standards (which is probably not that easy to achieve when rolling your own)</li> <li>easier to get something working (lots of tutorials) without reading gazillion articles and docs</li> </ol> <p>Cons:</p> <ol> <li>you learn less</li> <li>harder to replace parts (not that much of an issue in pylons, more so with django)</li> <li>harder to tweak some low-level stuff (like the above mentioned SQLs)</li> </ol> <p>From that you can probably devise what they are good for :-) Since you get all the code it is possible to tweak it to fit even the most bizzare situations (pylons supposedly work on the Google app engine now...).</p>
6,527
<p>I keep thinking it means that I can plug it directly into <a href="http://rads.stackoverflow.com/amzn/click/B007KG0ZYI" rel="nofollow noreferrer">my power supply</a> instead of running it though my RAMPs 1.4; is that correct?</p> <p>Here is the link to it, <a href="http://www.robotdigg.com/product/209" rel="nofollow noreferrer">200*200mm Square Silicone Heater Pad</a>.</p>
<p>"Mains voltage" is the alternating current provided by your wall outlets (eg 120v in USA). In order to use a mains voltage heatbed in a 3d printer, you will need to wire up your controller to switch an AC SSR. That way, your low-voltage-DC RAMPS board can control AC current. </p> <p>If you plug a heatbed directly into a power supply, it will never stop heating, and may burn itself up or even cause a fire. Don't do that. </p> <p>Because mains voltage has enough voltage to kill you, it should only be used for STATIONARY components, such as the PSU supply wiring and Delta heatbeds. With moving beds, particularly Mendel/i3 style Y-beds, wire fatigue and rubbing can expose the electrical conductors and create a serious safety hazard. </p> <p>200x200mm is a very reasonable size for a DC bed heater, so there's really no good reason to use an AC heater here. It's more complex and less safe. I recommend getting a different heater. </p>
<p>"Mains voltage" is the alternating current provided by your wall outlets (eg 120v in USA). In order to use a mains voltage heatbed in a 3d printer, you will need to wire up your controller to switch an AC SSR. That way, your low-voltage-DC RAMPS board can control AC current. </p> <p>If you plug a heatbed directly into a power supply, it will never stop heating, and may burn itself up or even cause a fire. Don't do that. </p> <p>Because mains voltage has enough voltage to kill you, it should only be used for STATIONARY components, such as the PSU supply wiring and Delta heatbeds. With moving beds, particularly Mendel/i3 style Y-beds, wire fatigue and rubbing can expose the electrical conductors and create a serious safety hazard. </p> <p>200x200mm is a very reasonable size for a DC bed heater, so there's really no good reason to use an AC heater here. It's more complex and less safe. I recommend getting a different heater. </p>
346
<p>On my <strong>Windows XP</strong> machine Visual Studio 2003 2005 and 2008 all complain that I cannot start debugging my <strong>web application</strong> because I must either be a member of the Debug Users group or of the Administrators group. So, I am an Administrator and I added Debug Users just in case, and it still complains.</p> <p>Short of reformatting my machine and starting over, has anyone encountered this and fixed it [with some undocumented command]?</p>
<p>Which users and/or groups are in your "Debug programs" right (under User Rights Assignment)? Maybe that setting got overridden by group policy (Daniel's answer), or just got out of whack for some reason. It should, obviously, include the "Debug Users" group.</p>
<p>You could try running "<code>VsJITDebugger.exe -p &lt;PID&gt;</code>" on the command line. I've had a simalar situation and been able to debug the application using the above.</p> <p>"<code>VsJITDebugger.exe /?</code>" will show you all the options.</p> <p>The PID can be found either in the task manager (view->Select Columns...) or Visual Studio's Attach to Process.</p>
3,281
<p>I am thinking about the design of an iPhone app I'd like to create. One possible problem is that this application will have to run as root (to access certain network ports). In a typical UNIX app, I'd just get the app to run with setuid, but I'm wondering if that is possible with an iPhone app.</p> <p>I've read this question in Apple's forum, which is discouraging:</p> <p><a href="http://discussions.apple.com/thread.jspa?threadID=1664575" rel="nofollow noreferrer">http://discussions.apple.com/thread.jspa?threadID=1664575</a></p> <p>I understand that Apple wants to limit what a program can do, but there are plenty of good, legitimate reasons for a user to run a program with elevated privileges. I'm not trying to create a hacker tool here.</p> <p>I'm sure I could get around this on a jail-broken iPhone, but that's not what I'm after. Is there any way to run an app with elevated privileges on an unbroken iPhone?</p> <p>(BTW, there is no need to warn me about the NDA.)</p>
<p>Section 3.3.4 of the iPhone SDK Agreement suggests that you mustn't work outside your sandbox.</p> <p>Given that <a href="http://speirs.org/2008/09/12/app-store-im-out/" rel="nofollow noreferrer">Apple has been somewhat arbitrary on which applications they permit</a>, you should definitely double-check with them <em>before</em> you start developing.</p> <p>Compared to 2.0.x, <a href="http://daringfireball.net/linked/2008/09/12/iphone-21-security" rel="nofollow noreferrer">the sandbox restrictions have actually increased in 2.1</a>; you can no longer even read from another application's sandbox. So, even if it currently <em>is</em> possible to elevate your app's privileges, it very likely won't be in a future release.</p>
<p>Doesn't matter one bit if you can do this on your normal desktop computer. The iPhone is not a normal desktop computer.</p> <p>Unlike a desktop computer, the <em>only</em> way to get an application on the iPhone without a jailbreak is to get it from the App Store. The <em>only</em> way to get on the App Store is to follow Apple's rules, and Apple's rules <em>clearly</em> include "no privilege escalation", "no escaping the sandbox", and "no accessing network ports outside the existing, provided APIs".</p> <p>What you want to do is <strong>not possible</strong>.</p>
8,652
<p>I have an Ender 3 that I have been pretty happy with so far, however it recently started an odd behavior and I can't figure out what's causing it. </p> <p>What happens is that the first ~3&nbsp;mm of the print comes out "sloppy". After that, everything clears up and it prints fine for the rest of the print. (Although it perhaps looks a little under extruded on the top layer)</p> <p><a href="https://i.stack.imgur.com/0UAfD.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/0UAfD.jpg" alt="enter image description here"></a></p> <p>It looks almost like it's over extruding. But if that's the case, why would it only be for the first 3&nbsp;mm? Then the top layer looking under extruded makes that possibility even more unlikely.</p> <p>This is consistently happening regardless of what I am printing, the brand of filament (I only print PLA), or the bed temp or hot end temp. I've tried tweaking with the bed leveling and giving a little more gap on the first layer, but that doesn't seem to change anything either. I also calibrated the extrusion multiplier and it's spot on now. </p> <p>I use Ultimaker Cura 3.6 as my slicer. I tried resetting back to defaults to see if maybe I had inadvertently changed something but that didn't help either.</p> <p>I have done a few upgrades - Marlin firmware, Capricorn tubing, glass bed, replaced the (broken) plastic extruder with one of the metal ones, new PTFE fittings. I didn't notice the problem until recently so I can't say if it started corresponding with any of those upgrades. </p> <p>When I first got it, the prints came out beautifully from the first layer, so this is really frustrating me. I'd like to get it back the way it was.</p> <p>Any suggestions on where to look?</p> <p>Update: I did some slightly more controlled experimemts and I did get it looking a little better. It does seem related mostly to bed tempurature. The cooler I make the bed, the better it looks. However as it gets cooler, the prints are also starting to warp and break loose, so the print ends up failing completely. I had a hard time getting a successful print below about 45 degrees, and even at that temperature it still isn't completely clean. I'm using glue stick for adhesion and it just doesn't seem able to hold it without some heat. I traditionally have run around 50 degrees before this problem started though, so it seems odd I have to drop below that now.</p> <p>Also, for more info, the cube dimensions are pretty close in the X and Y, but were about .5mm short in the Z. So the layers do seem to be settling. </p> <p>I did check the bed temp with a non-contact thermometer and it was consistent with what the printer reported, so it doesnt seem to be a bad thermostat throwing things off.</p>
<p>After much trial and error, I think I finally figured out the solution. </p> <p>Even though I could get better prints by tweaking with the temperatures, I could never totally eliminate the problem. The better I made it look by cooling down the bed, the more likely it would break free and the print would fail completely.</p> <p>At one point though I happened to print something taller, and interestingly enough a similar band of ugly layers appeared higher up in the print as well.</p> <p>So I started a closer inspection of the Z axis rollers. The Ender 3 has a funky setup where there are 3 rollers at each end of the X axis. Two are fixed and one can be adjusted to change the tension of the rollers against the Z rails. What I discovered was that a couple of the non-adjustable rollers weren't terribly tight and could be turned by fairly easily with my fingers. At the same time, the adjustable rollers are starting to wear a groove. </p> <p>On a hunch, I decided to try re-adjusting the tension so that I could no longer turn any of them with my fingers. It definitely had an effect...now the bed was too high and it would no longer extrude the first layer because the nozzle was too close. This required going through the complete bed leveling process to get it back in spec. </p> <p>Once I got it re-leveled, low and behold it's printing like new! The height is coming out spot-on too.</p> <p><a href="https://i.stack.imgur.com/81uYN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/81uYN.jpg" alt="Measuring the calibration cube"></a></p> <p>I suspect what was happening is that the rollers were too loose and at certain heights they we allowing movement in the Z axis. Perhaps there is a flat spot that was allowing the X rail to droop, then once it got past the flat spot it would print cleanly again.</p> <p>I haven't printed anything tall enough yet to see if the bad layers still show up higher in the print, if they do, I think it is probably a sign that I need to replace some rollers. In the mean time, I'm thrilled to be getting decent prints again!</p> <p>Update: This ended up NOT being the solution to my problem. However it does seem to be related. As I mentioned in the comments, the problem returned after a few days of the printer sitting unused. I have since been able to get it printing better by going the opposite route - loosening up the Z axis bearings. At the moment it is printing somewhat better, but still not perfect. I am also having under extrusion issues when may or may not be related. I have ordered some new rollers to see if that helps since some of them had a pretty good groove worn in them. </p> <p>Another Update: I replaced several of the Z rollers that had become grooved with some that claimed to be a little harder material. So far this seems to have mostly cleared up the issue. I have now completed several large print jobs and the first layers have been coming out pretty good. </p> <p>I also ended up taking out the Capricorn tubing on the extruder. The extruder skips were becoming quite bad and causing under extrusion issues throughout the print. The Capricorn has a little smaller inside diameter than the stock tubing and I wondered if it was too tight on some filaments. I went back to some plain white cheap PTFE and that problem mostly went away as well. I still hear the "click" once in a while, but it is fairly rare. I may try tweaking the motor current a little to see if I can get rid of that. All in all though, the printer seems to be printing about as good as it ever has.</p>
<p>I had similar problem with my Tevo Tarantula. Tried all the options mentioned above as well. It seemed to be Z-axis height related. Changed my Z-axis flexible coupling to a solid coupling which solved it for me.</p>
1,190
<p>I need to print out data into a pre-printed A6 form (1/4 the size of a landsacpe A4). I do not need to print paragraphs of text, just short lines scattered about on the page.</p> <p>All the stuff on MSDN is about priting paragraphs of text. </p> <p>Thanks for any help you can give, Roberto</p>
<p>VARCHAR(255). It won't use all 255 characters of storage, just the storage you need. It's 255 and not 256 because then you have space for 255 plus the null-terminator (or size byte).</p> <p>The "N" is for Unicode. Use if you expect non-ASCII characters.</p>
<p>If you will be supporting languages other than English, you will want to use nvarchar.</p> <p>HTML should be okay as long as it contains standard ASCII characters. I've used nvarchar mainly in databases that were multi-lingual support. </p>
7,813
<p>I've just started skimming 'Debugging MS .Net 2.0 Applications' by John Robbins, and have become confused by his evangelism for Debug.Assert(...).</p> <p>He points out that well-implemented Asserts store the state, somewhat, of an error condition, e.g.:</p> <pre><code>Debug.Assert(i &gt; 3, "i &gt; 3", "This means I got a bad parameter"); </code></pre> <p>Now, personally, it seems crazy to me that he so loves restating his test without an actual sensible 'business logic' comment, perhaps "i &lt;= 3 must never happen because of the flobittyjam widgitification process".</p> <p>So, I think I get Asserts as a kind-of low-level "Let's protect my assumptions" kind of thing... assuming that one feels this is a test one only needs to do in debug - i.e. you are protecting yourself against colleague and future programmers, and hoping that they actually test things.</p> <p>But what I don't get is, he then goes on to say that you should use assertions in addition to normal error handling; now what I envisage is something like this:</p> <pre><code>Debug.Assert(i &gt; 3, "i must be greater than 3 because of the flibbity widgit status"); if (i &lt;= 3) { throw new ArgumentOutOfRangeException("i", "i must be &gt; 3 because... i=" + i.ToString()); } </code></pre> <p>What have I gained by the Debug.Assert repetition of the error condition test? I think I'd get it if we were talking about debug-only double-checking of a very important calculation...</p> <pre><code>double interestAmount = loan.GetInterest(); Debug.Assert(debugInterestDoubleCheck(loan) == interestAmount, "Mismatch on interest calc"); </code></pre> <p>...but I don't get it for parameter tests which are surely worth checking (in both DEBUG and Release builds)... or not. What am I missing?</p>
<p>Assertions are not for parameter checking. Parameter checking should always be done (and precisely according to what pre-conditions are specified in your documentation and/or specification), and the <code>ArgumentOutOfRangeException</code> thrown as necessary.</p> <p>Assertions are for testing for "impossible" situations, i.e., things that you (in your program logic) <em>assume</em> are true. The assertions are there to tell you if these assumptions are broken for any reason.</p> <p>Hope this helps!</p>
<p>Here is by 2 cents.</p> <p>I think that the best way is to use both assertions and exceptions. The main differences between the two methods, imho, if that Assert statements can be removed easily from the application text (defines, conditional attributes...), while Exception thrown are dependent (tipically) by a conditional code which is harder to remove (multine section with preprocessor conditionals).</p> <p>Every application exception shall be handled correctly, while assertions shall be satisfied only during the algorithm developement and testing.</p> <p>If you pass an null object reference as routine parameter, and you use this value, you get a null pointer exception. Indeed: why you should write an assertion? It's a waste of time in this case. But what about private class members used in class routines? When these value are set somewhere, is better to check with an assertion if a null value is set. That's only because when you use the member, you get a null pointer exception but you don't know how the value was set. This cause a restart of the program breaking on all entry point use to set the private member.</p> <p>Exception are more usefull, but they can be (imho) very heavy to manage and there is the possibility to use too much exceptions. And they requires additional check, maybe undesired to optimize the code. Personally I use exceptions only whenever the code requires a deep catch control (catch statements are very low in the call stack) or whenever the function parameters are not hardcoded in the code.</p>
8,636