instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I've changed SD cards, printed from USB connection, upgraded/reloaded firmware and attempted using different software packages. Nothing has worked yet. When connected via USB, I get a &quot;disconnected&quot; error after a few minutes into the print. Also, the LED lights now either don't work at all or will randomly go out after a few minutes - usually indicating that the print failure is imminent. I've had the printer for about 4 years without issues. I don't want to replace the motherboard only to find out it's the power source or vice versa. Help?</p>
<p>I recently had this problem and narrowed it down to the part cooling fan (on the side of the extruder head). I diagnosed the problem by noticing that the printer would reboot shortly after the second layer started, only on PLA prints. Of course, the part cooling fan is not usually started until after the first layer. It was shorted and when the printer got to the second layer it would overload the power supply and cause a reboot. Took a while to determine this, but it is worth looking at if somebody else is having this problem.</p> <p>I would guess that any shorted fan, even the extruder fans, might cause a similar issue, however, I don't know this for sure.</p>
<p>I had a similar problem with my Ender 3 that started after relocating the power supply to a (3D printed) bracket to give additional clearance from the edge of the bed (it was touching the magnetic build sheet, potentially causing prints to lift or warp at +X +Y corner).</p> <p>What I found was that the brackets I had printed allowed enough movement of power supply to make the 24V output connection intermittent, even despite tightening the slip-on terminal. I solved the problem by printing another bracket piece that constrains the top of the power supply as well as the bottom (in the originally printed bracket); I haven't had a random restart during a print since then.</p>
2,030
<p>I would like to make custom insoles for my wife.</p> <p>This company makes a flexible filament that will be soft to stand on: <a href="http://recreus.com/en/" rel="noreferrer">http://recreus.com/en/</a></p> <p>I do not currently own a printer.</p> <p>How can I measure her feet and transfer the measurements to the printer? (one of these comes to mind: <a href="http://www.eggheadtoys.com/pin-art/" rel="noreferrer">http://www.eggheadtoys.com/pin-art/</a>)</p> <p>How can I measure the inside of the shoe?</p> <p>What kind of printer can print with the flexible filament?</p>
<p>Here is a post that covers how to scan a foot and make a form fitting insole - <a href="https://web.archive.org/web/20180429035945/http://www.gyrobot.co.uk/blog/my-adventures-with-3d-printed-insoles-part-4-4" rel="nofollow noreferrer">https://web.archive.org/web/20180429035945/http://www.gyrobot.co.uk/blog/my-adventures-with-3d-printed-insoles-part-4-4</a></p> <p>Here are links to the rest of the blog - <a href="https://web.archive.org/web/20180307181312/http://www.gyrobot.co.uk:80/blog/my-adventures-with-3d-printed-insoles-part-1-4" rel="nofollow noreferrer">Part 1 of 4</a> - <a href="https://web.archive.org/web/20180307181409/http://www.gyrobot.co.uk:80/blog/my-adventures-with-3d-printed-insoles-part-2-4" rel="nofollow noreferrer">Part 2 of 4</a> - <a href="https://web.archive.org/web/20180305020707/http://www.gyrobot.co.uk:80/blog/my-adventures-with-3d-printed-insoles-part-3-4" rel="nofollow noreferrer">Part 3 of 4</a></p> <p>Any printer should be capable of the temperature required for flexible filament. The main problem with flexible filament is the path between the drive gears and entrance to the hotend must be completely constrained or the filament will push out of any gap. Ninjaflex is very flexible and absolutely will not work unless you constrain it right after the contact point with the drive gear. Semiflex is another flexible filament but quite a bit stiffer than Ninjaflex, I've never used it but it should be a bit more forgiving on the path requirements.</p> <p>I know there are several other flexible filaments but I've never worked with them so I only mentioned Ninjaflex which I have used.</p> <p>The model used in the blog can be found here - <a href="http://www.thingiverse.com/thing:586514" rel="nofollow noreferrer">http://www.thingiverse.com/thing:586514</a></p>
<p>Many questions in one post, but I'll address only the first. Consider to use a shoe with a flat insole, perhaps even what is commonly called a flip-flop. If your objective is to perfectly match the curve of her foot bottom, this should work. Apply a layer of polymer modeling clay, plasticine or similar material. It should be warm enough to permit her foot/feet to settle in and push enough material away to remove any voids. If voids appear, one could then add a few blobs and repeat the pressure.</p> <p>Obviously some will ooze from the sides, which will have to be trimmed away. Trim a sufficient amount to fit her regular shoes and you'll have a reasonable match of the necessary fit.</p> <p>The resulting shape can then be scanned with a 3d scanner and converted to a 3d model. Even if the clay is excessively thick, the typical 3d model editor can slice away the excess, although one would have to make an almost arbitrary judgement for the location of the slicing plane.</p> <p>Another option comes to mind. There are various silicone molding products. I've used one from makeyourownmolds.com that is of a consistency of frosting. When mixed together and applied, it makes a perfect duplicate of the item, in reverse. Another product sold at the local HobbyLobby is a similar molding compound that is more akin to the modeling clay.</p> <p>Both compounds will release easily from skin, are non-toxic and would provide a more durable model from which to scan. </p> <p>I think one difficulty you may have is how to determine the correct foot pressure and posture to achieve the desired results. The modeling clay would give you more support and probably be more accurate. If your objective is to provide the same support as a bare foot, the silicone molding method would be more accurate.</p> <p>If you stretch the concept even further, once you have the silicone or clay mold, you would be able to use the pin-art concept. The idea of measuring each tiny pin is mind-boggling, though.</p>
226
<p>What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app.</p>
<p>XHTML is easy, use <a href="http://lxml.de/validation.html" rel="noreferrer">lxml</a>.</p> <pre><code>from lxml import etree from StringIO import StringIO etree.parse(StringIO(html), etree.HTMLParser(recover=False)) </code></pre> <p>HTML is harder, since there's traditionally not been as much interest in validation among the HTML crowd (run StackOverflow itself through a validator, yikes). The easiest solution would be to execute external applications such as <a href="http://www.jclark.com/sp/" rel="noreferrer">nsgmls</a> or <a href="http://openjade.sourceforge.net/" rel="noreferrer">OpenJade</a>, and then parse their output.</p>
<p>I think that <a href="http://tidy.sourceforge.net/" rel="nofollow noreferrer">HTML tidy</a> will do what you want. There is a Python binding for it.</p>
5,606
<p>We need to regularly synchronize many dozens of binary files (project executables and DLLs) between many developers at several different locations, so that every developer has an up to date environment to build and test at. Due to nature of the project, updates must be done often and on-demand (overnight updates are not sufficient). This is not pretty, but we are stuck with it for a time.</p> <p>We settled on using a regular version (source) control system: put everything into it as binary files, get-latest before testing and check-in updated DLL after testing.</p> <p>It works fine, but a version control client has a lot of features which don't make sense for us and people occasionally get confused.</p> <p>Are there any tools better suited for the task? Or may be a completely different approach?</p> <p><strong>Update:</strong> </p> <p>I need to clarify that it's not a tightly integrated project - more like extensible system with a heap of "plugins", including thrid-party ones. We need to make sure those modules-plugins works nicely with recent versions of each other and the core. Centralised build as was suggested was considered initially, but it's not an option.</p>
<p>I'd probably take a look at rsync.</p> <p>Just create a .CMD file that contains the call to rsync with all the correct parameters and let people call that. rsync is very smart in deciding what part of files need to be transferred, so it'll be very fast even when large files are involved.</p> <p>What rsync doesn't do though is conflict resolution (or even detection), but in the scenario you described it's more like reading from a central place which is what rsync is designed to handle.</p>
<p>Building the project should be a centralized process in order to allow for better control soon your solution will be caos in the long run. Anyway here is what I'd do.</p> <ul> <li>Create the usual repositories for source files, resources, documentation, etc for each project.</li> <li>Create a repository for resources. There will be the latest binary versions for each project as well as any required resources, files, etc. Keep a good folder structure for each project so developers can "reference" the files directly.</li> <li>Create a repository for final buidls which will hold the actual stable release. This will get the stable files, done in an automatic way (if possible) from the checked in sources. This will hold the real product, the real version for integration testing and so on.</li> </ul> <p>While far from being perfect you'll be able to define well established protocols. Check in your latest dll here, generate the "real" versión from latest source here.</p>
8,288
<p>There are all sorts of stories of what to put on your printer bed to make your part not come loose when it is printing but can be removed after it is done without requiring a hammer and chisel.</p> <p>Is there anything out there that shows an analytical comparison?</p> <p>My biggest interest is PLA on a heated glass base. </p>
<p>I use a product called <a href="http://www.3dlac.com/index.php/en/" rel="nofollow noreferrer">3DLAC</a> but I suppose it's regular hairspray. Makes my PLA stick to the heated bed like a charm. After cooling down the print can be removed from the bed with ease.</p> <p>Only today, after a few thousand prints the glass bed of my printer broke. But I suppose this is because we didn't have enough patience to let the bed cool down to room temperature before removing the printed piece.</p>
<p>I use a product called <a href="http://www.3dlac.com/index.php/en/" rel="nofollow noreferrer">3DLAC</a> but I suppose it's regular hairspray. Makes my PLA stick to the heated bed like a charm. After cooling down the print can be removed from the bed with ease.</p> <p>Only today, after a few thousand prints the glass bed of my printer broke. But I suppose this is because we didn't have enough patience to let the bed cool down to room temperature before removing the printed piece.</p>
597
<p>I'm looking for good/working/simple to use PHP code for parsing raw email into parts.</p> <p>I've written a couple of brute force solutions, but every time, one small change/header/space/something comes along and my whole parser fails and the project falls apart.</p> <p>And before I get pointed at PEAR/PECL, I need actual code. My host has some screwy config or something, I can never seem to get the .so's to build right. If I do get the .so made, some difference in path/environment/php.ini doesn't always make it available (apache vs cron vs CLI).</p> <p>Oh, and one last thing, I'm parsing the raw email text, NOT POP3, and NOT IMAP. It's being piped into the PHP script via a .qmail email redirect.</p> <p>I'm not expecting SOF to write it for me, I'm looking for some tips/starting points on doing it &quot;right&quot;. This is one of those &quot;wheel&quot; problems that I know has already been solved.</p>
<p>What are you hoping to end up with at the end? The body, the subject, the sender, an attachment? You should spend some time with <a href="http://www.faqs.org/rfcs/rfc2822.html" rel="noreferrer">RFC2822</a> to understand the format of the mail, but here's the simplest rules for well formed email:</p> <pre><code>HEADERS\n \n BODY </code></pre> <p>That is, the first blank line (double newline) is the separator between the HEADERS and the BODY. A HEADER looks like this:</p> <pre><code>HSTRING:HTEXT </code></pre> <p>HSTRING always starts at the beginning of a line and doesn't contain any white space or colons. HTEXT can contain a wide variety of text, including newlines as long as the newline char is followed by whitespace.</p> <p>The "BODY" is really just any data that follows the first double newline. (There are different rules if you are transmitting mail via SMTP, but processing it over a pipe you don't have to worry about that).</p> <p>So, in really simple, circa-1982 <a href="http://www.faqs.org/rfcs/rfc822.html" rel="noreferrer">RFC822</a> terms, an email looks like this:</p> <pre><code>HEADER: HEADER TEXT HEADER: MORE HEADER TEXT INCLUDING A LINE CONTINUATION HEADER: LAST HEADER THIS IS ANY ARBITRARY DATA (FOR THE MOST PART) </code></pre> <p>Most modern email is more complex than that though. Headers can be encoded for charsets or <a href="http://www.faqs.org/rfcs/rfc2047.html" rel="noreferrer">RFC2047</a> mime words, or a ton of other stuff I'm not thinking of right now. The bodies are really hard to roll your own code for these days to if you want them to be meaningful. Almost all email that's generated by an MUA will be <a href="http://www.faqs.org/rfcs/rfc2045.html" rel="noreferrer">MIME</a> encoded. That might be uuencoded text, it might be html, it might be a uuencoded excel spreadsheet.</p> <p>I hope this helps provide a framework for understanding some of the very elemental buckets of email. If you provide more background on what you are trying to do with the data I (or someone else) might be able to provide better direction.</p>
<p>yeah, ive been able to write a basic parser, based off that rfc and some other basic tutorials. but its the multipart mime nested boundaries that keep messing me up.</p> <p>i found out that MMS (not SMS) messages sent from my phone are just standard emails, so i have a system that reads the incoming email, checks the from (to only allow from my phone), and uses the body part to run different commands on my server. its sort of like a remote control by email.</p> <p>because the system is designed to send pictures, its got a bunch of differently encoded parts. a mms.smil.txt part, a text/plain (which is useless, just says 'this is a html message'), a application/smil part (which the part that phones would pic up on), a text/html part with a advertisement for my carrier, then my message, but all wrapped in html, then finally a textfile attachment with my plain message (which is the part i use) (if i shove an image as an attachment in the message, its put at attachment 1, base64 encoded, then my text portion is attached as attachment 2)</p> <p>i had it working with the exact mail format from my carrier, but when i ran a message from someone elses phone through it, it failed in a whole bunch of miserable ways.</p> <p>i have other projects i'd like to extend this phone->mail->parse->command system to, but i need to have a stable/solid/generic parser to get the different parts out of the mail to use it.</p> <p>my end goal would be to have a function that i could feed the raw piped mail into, and get back a big array with associative sub-arrays of headers var:val pairs, and one for the body text as a whole string</p> <p>the more and more i search on this, the more i find the same thing: giant overdeveloped mail handling packages that do everything under the sun thats related to mails, or useless (to me, in this project) tutorials.</p> <p>i think i'm going to have to bite the bullet and just carefully write something my self.</p>
3,397
<p>I have just built my first 3D printer, and I am having some problems. It is a Cartesian based 3D printer, using Marlin firmware and Pronterface software. My problem is homing the 3D printer. I do not have a probe to calibrate the z offset but I have all 6 endstops. The problem is that the "ZMIN" endstop isn't precise enough and my hotend is always either too far from or too close to the heatbed. Is there a way to manually set the home position, so when I start the printer, It just starts printing and it doesn't have to home again; Or maybe some other way to set the correct offset. It would also be helpful if I could use just the "ZMAX" plug, and then manually set the minimum Z position using a piece of paper.</p>
<p>It is possible to "home a printer" without having endstops, technically, you don't <strong>require</strong> endstops, but it makes your job a lot easier if you want to print something!</p> <p>Basically, when you don't have endstops or limit switches, you need to define where the head of the printer is located. E.g. you can set the nozzle at [0, 0, 0] (origin in [x, y, z]) and add the command <a href="https://reprap.org/wiki/G-code#G92:_Set_Position" rel="nofollow noreferrer"><code>G92</code></a> to your print G-code file that it is at that position using <code>G92 X0 Y0 Z0</code> (or any other location you use, e.g. you could engineer a parking position and refer to that position instead, note that you also need to write the movement commands to get out of that location safely). Don't forget to remove the homing command from your start code in your slicer, replace <code>G28</code> with the <code>G92</code> command with appropriate X, Y and Z values.</p> <p>Regarding the inaccurate repetitive accuracy of your Z min endstop, it might be worth to find out why this is causing such a spread in triggering, maybe you need to invest in some new endstop switches or look more closely to the heated bed attachment to the frame.</p> <p>Using Z max as a reference point is e.g. used by Ultimaker machines. The heated platform lowers to Z max; the printer knows from calibration and geometry how far it needs to rise to get to Z=0.</p>
<p>You can reconfigure marlin to use the MAXZ endstop instead of MINZ in Configuration.h, and then reflash it to your printer.</p> <p><a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h#L877" rel="nofollow noreferrer">https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h#L877</a></p> <p>Now this is highly unusual, as most printers only have MIN endstops. If you post a pic of your faulty MINZ endstop, we can probably figure out how you could fix it. Zipties come to mind as a likely solution.</p>
1,216
<p>I'm looking for a clear, concise and accurate answer. </p> <p>Ideally as the actual answer, although links to good explanations welcome.</p> <p>This also applies to VB.Net, but the keywords are different - <code>ByRef</code> and <code>ByVal</code>.</p>
<p>By default (in C#), passing an object to a function actually passes a copy of the reference to that object. Changing the parameter itself only changes the value in the parameter, and not the variable that was specified.</p> <pre><code>void Test1(string param) { param = "new value"; } string s1 = "initial value"; Test1(s1); // s1 == "initial value" </code></pre> <p>Using <code>out</code> or <code>ref</code> passes a reference to the variable specified in the call to the function. Any changes to the value of an <code>out</code> or <code>ref</code> parameter will be passed back to the caller.</p> <p>Both <code>out</code> and <code>ref</code> behave identically except for one slight difference: <code>ref</code> parameters are required to be initialised before calling, while <code>out</code> parameters can be uninitialised. By extension, <code>ref</code> parameters are guaranteed to be initialised at the start of the method, while <code>out</code> parameters are treated as uninitialised.</p> <pre><code>void Test2(ref string param) { param = "new value"; } void Test3(out string param) { // Use of param here will not compile param = "another value"; } string s2 = "initial value"; string s3; Test2(ref s2); // s2 == "new value" // Test2(ref s3); // Passing ref s3 will not compile Test3(out s2); // s2 == "another value" Test3(out s3); // s3 == "another value" </code></pre> <p><strong>Edit</strong>: As <a href="https://stackoverflow.com/questions/13060/what-do-ref-val-and-out-mean-on-method-parameters#13105" title="dp">dp</a> points out, the difference between <code>out</code> and <code>ref</code> is only enforced by the C# compiler, not by the CLR. As far as I know, VB has no equivalent for <code>out</code> and implements <code>ref</code> (as <code>ByRef</code>) only, matching the support of the CLR.</p>
<p><code>out</code> means that the parameter will be initialised by the method:</p> <pre><code>int result; //not initialised if( int.TryParse( "123", out result ) ) //result is now 123 else //if TryParse failed result has still be // initialised to its default value (0) </code></pre> <p><code>ref</code> will force the underlying reference to be passed:</p> <pre><code>void ChangeMyClass1( MyClass input ) { input.MyProperty = "changed by 1"; input = null; //can't see input anymore ... // I've only nulled my local scope's reference } void ChangeMyClass2( ref MyClass input ) { input.MyProperty = "changed by 2"; input = null; //the passed reference is now null too. } MyClass tester = new MyClass { MyProperty = "initial value" }; ChangeMyClass1( tester ); // now tester.MyProperty is "changed by 1" ChangeMyClass2( ref tester ); // now tester is null </code></pre>
3,410
<p>Is it possible to build Visual Studio solutions without having to fire up MonoDevelop?</p>
<p>Current status (Mono 2.10, 2011): xbuild is now able to build all versions of Visual Studio / MSBuild projects, including .sln files. Simply run <code>xbuild</code> just as you would execute <code>msbuild</code> on Microsoft .Net Framework. You don't need Monodevelop installed, xbuild comes with the standard Mono installation.</p> <p>If your build uses custom tasks, they should still work if they don't depend on Windows executables (such as <code>rmdir</code> or <code>xcopy</code>).</p> <p>When you are editing project files, use standard Windows path syntax - they will be converted by xbuild, if necessary. One important caveat to this rule is case sensitivity - don't mix different casings of the same file name. If you have a project that does this, you can enable compatibility mode by invoking <code>MONO_IOMAP=case xbuild foo.sln</code> (or try <code>MONO_IOMAP=all</code>). Mono has a page describing more advanced <a href="http://www.mono-project.com/Porting_MSBuild_Projects_To_XBuild" rel="noreferrer">MSBuild project porting</a> techniques.</p> <p>Mono 2.0 answer (2008): <strike><a href="http://www.mono-project.com/Microsoft.Build" rel="noreferrer">xbuild</a> is not yet complete (it works quite well with VS2005 .csproj files, has problems with VS2008 .csproj and does not handle .sln). Mono 2.1 plans to merge the code base of mdtool (MonoDevelop command line build engine) into it, but currently <a href="http://www.monodevelop.com/MonoDevelop_1.0_Released#Command_line_tools" rel="noreferrer">mdtool</a> is a better choice. <code>mdtool build -f:project.sln</code> or <a href="http://ubuntu.dustinkirkland.com/manpages/intrepid/man1/mdtool.html" rel="noreferrer"><code>man mdtool</code></a> if you have MonoDevelop installed.</strike></p>
<p>I think you are looking for xbuild: <a href="http://www.mono-project.com/Microsoft.Build" rel="nofollow noreferrer">http://www.mono-project.com/Microsoft.Build</a></p>
7,841
<p>I'm looking for a simple way to encrypt my soap communication in my C# Web-Service.</p> <p>I was looking into <a href="http://www.google.com/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fwww.microsoft.com%2Fdownloads%2Fdetails.aspx%3Ffamilyid%3D018a09fd-3a74-43c5-8ec1-8d789091255d&amp;ei=x1isSPTUO4bS0QXsjIzWAw&amp;usg=AFQjCNHn7aOkIXoysM1woIgRBe20Ptu_6g&amp;sig2=RTyvtw71nWYyoDGIEh0TlQ" rel="noreferrer">WSE 3.0</a> but it seems Microsoft dropped support for it, and therefore it's not straightforward to use.<br> It seems WCF could've been an option but I prefer not to upgrade from .NET 2.0 .</p> <p>Any <strong>simple</strong>, straightforward encryption method?</p>
<p>I think this can help; last year we used this to compress the webservices and it performed very well, I believe it could be enhanced with encryption classes;</p> <p><a href="http://www.mastercsharp.com/article.aspx?ArticleID=86&amp;&amp;TopicID=7" rel="noreferrer">Creating Custom SOAP Extensions - Compression Extension</a></p>
<p>Perhaps I'm being naive, but would forcing the communication to be via https be acceptable? I develop web services that run on 2.0 and have had success with just getting IIS to enforce https on the virtual directory. </p> <p>Alternatively, or in addition, you can check the <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.issecureconnection.aspx" rel="nofollow noreferrer">HttpRequest.IsSecureConnection property</a>. </p>
3,902
<p>I'm trying to bind the following shortcut: <strong>Ctrl + W</strong> to close tabs</p> <p>How can you customize VS to add/change shortcuts? Also, what are the most useful shortcuts you guys have found?</p>
<p>Tools > Options > (Show all settings), then Environment > Keyboard.</p> <p>Here, rebind the key “File.Close” to <kbd>Ctrl</kbd>+<kbd>W</kbd>.</p>
<p><kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>Space</kbd> shows the syntax/overloads for the current function you are typing parameters for.</p>
4,600
<p>Can I get some recommendations (preferably with some reasons) for good log analysis software for Apache 2.2 access log files?</p> <p>I have heard of <a href="http://www.webalizer.org/" rel="noreferrer">Webalizer</a> and <a href="http://awstats.sourceforge.net/" rel="noreferrer">AWStats</a>, but have never really used any of them, and would like to know:</p> <ul> <li>What they can do</li> <li>Why they are useful</li> <li>Interesting uses for them</li> </ul> <p>Any and all comments and thoughts are welcome.</p>
<p>AWStats and Webalizer are both good and free (I think both free speech as well as free beer). I generally prefer the look of AWStats - it has a nice modern look whereas Webalizer looks like something created in about 1992.</p> <p>They both give roughly the same information which includes:</p> <ul> <li>Most frequently accessed pages</li> <li>Which hosts (IPs and Domain Names) visitors come from</li> <li>Proportion of users using different browsers</li> <li>Proportion of downloads of different file types</li> </ul> <p>All of this information is usually viewable on a hour by hour, day by day, month by month and year by year basis. Normally the raw data is available but also with bar charts and pie charts. Both AWStats and Webalizer will (I think) try and work out where your visitors come from by using services such as GeoIP, although I never bothered to set this up. Some also try to work out what order people have visited pages in and things like that - but that is very difficult to do so the results are guesses at the best.</p> <p>I generally find them both useful - even if just to get an overview of what is going on with my server and who is accessing it. They are both relatively easy to install - although I seem to remember Webalizer being a little easier than AWStats, and they both have varied configuration options to let you decide exactly what you want to get out of them.</p> <p>For more information see their sites at <a href="http://awstats.sourceforge.net/" rel="noreferrer">awstats.sourceforge.net/</a> and <a href="http://www.webalizer.org/" rel="noreferrer">http://www.webalizer.org/</a>.</p> <p>Hope that helps.</p> <p>Robin</p>
<p>If you are looking for stats that are meant to be given to a customer and provide them with realistic data (not number of hits based on every file), then check out <a href="http://www.google.com/analytics" rel="nofollow noreferrer">Google Analytics</a>. Free and looks pretty.</p>
3,684
<p>How often should you use git-gc? </p> <p>The <a href="http://www.kernel.org/pub/software/scm/git/docs/git-gc.html" rel="noreferrer">manual page</a> simply says:</p> <blockquote> <p>Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.</p> </blockquote> <p>Are there some commands to get some object counts to find out whether it's time to gc?</p>
<p>It depends mostly on how much the repository is used. With one user checking in once a day and a branch/merge/etc operation once a week you probably don't need to run it more than once a year.</p> <p>With several dozen developers working on several dozen projects each checking in 2-3 times a day, you might want to run it nightly.</p> <p>It won't hurt to run it more frequently than needed, though.</p> <p>What I'd do is run it now, then a week from now take a measurement of disk utilization, run it again, and measure disk utilization again. If it drops 5% in size, then run it once a week. If it drops more, then run it more frequently. If it drops less, then run it less frequently.</p>
<p>I use when I do a big commit, above all when I remove more files from the repository.. after, the commits are faster</p>
7,956
<p>I have an Ender 3 Pro with the BTT SKR E3 V2.0 mini with Marlin firmware 2.0.8.2.x. I am trying to print PETG, which requires decently high temperatures.</p> <p>I initially replaced the stock board after a thermal runaway event that seemed to have damaged it. After installing the new board and getting all the settings dialed in (typically 260 °C hotend and 90 °C bed), it worked great for about 2 weeks until I got the thermal runaway event error again.</p> <p>Here is what I have tried so far</p> <ul> <li>replaced the thermistor with <a href="https://smile.amazon.com/dp/B08YNX79H8?ref=ppx_yo2ov_dt_b_product_details&amp;th=1" rel="nofollow noreferrer">this</a></li> <li>replaced the heating cartridge with <a href="https://smile.amazon.com/dp/B01HGIMI2G?psc=1&amp;ref=ppx_yo2ov_dt_b_product_details" rel="nofollow noreferrer">this</a></li> <li>replaced the hotend with <a href="https://smile.amazon.com/dp/B09Y8VY5J8?psc=1&amp;ref=ppx_yo2ov_dt_b_product_details" rel="nofollow noreferrer">this</a> an all-metal one</li> <li>measured voltage coming from the power supply and coming out of the board going to heater cartridge (both ~24 V)</li> </ul> <p>I PID tuned the printer using <code>M303 E0 S260 C10</code> and stored new PID values in EEPROM + firmware. A note, running this multiple times seemed to constantly increase the P and D values. I stuck with the initial values given (<code>kP 13.97 kI 0.84 kD 57.96</code>). I still continued to get thermal runaway events.</p> <p>I then tested the heater cartridge and thermistor with my multimeter. The heater was 13.5 ohms which seems about right. I was unable to measure the thermistor value. Searching online shows I likely need a better multimeter to do so. It's possible it is bad, but I find that hard to believe considering this issue was happening prior to my replacing it.</p> <p><a href="https://pastebin.com/Ykhqfpdc" rel="nofollow noreferrer">Example log</a> of the failure happening. All I did was heat the printer up, leave it on for a bit, set it to cool down briefly, then tell it to heat up again. The printer was heated for ~5-8 minutes before this log starts.</p> <p>Could this be the board again, or is there something else I'm missing?</p>
<p>I'm fairly certain I have solved this issue, and it ended up having nothing to do with the printer and everything to do with what it was plugged into!</p> <p>I had it on a smart outlet with some automations set up to kill the power if there was ever a fire. Unfortunately, the outlet I was using was only rated for 8A, while the Ender 3 Pro can draw up to 15 amps. When it was unable to draw more than 8A to heat the hotend, this likely caused the printer to think there was a problem, triggering the thermal runaway failsafe.</p> <p>After moving it to an outlet with a higher amperage rating, I have had no more issues.</p>
<blockquote> <p>Recv: T:224.24 /<strong>260.00</strong> B:88.95 /<strong>90.00</strong> @:127 B@:127</p> </blockquote> <h1>You are trying to achieve too much!</h1> <p>The maximum rated temperature for an Ender3 is 260 °C, yes, but to achieve this you need to insulate the heater block with a silicon sock from losing heat to the surroundings and with some tinfoil from an airstream over it from the cooling fan. And even then, you are trying to work at the absolute maximum the printer can theoretically reach - which means it is above the temperature you can operate it while printing.</p> <p>Likewise, you try to have the bed at 90 °C and that is too high to consistently reach with the heater installed.</p> <p>To print at those elevated temperatures you need different gear:</p> <ul> <li>You absolutely need a heated chamber.</li> <li>You need a specialized hotend that does not suffer heatcreep and is rated to <strong>at least</strong> 275 °C</li> <li>The rest of the printer needs to be able to work at those elevated temperatures.</li> </ul>
2,155
<p>There has been a lot of questions and confusion about what is acceptable here on 3D Printing SE. Let's go ahead and discuss what types of questions should be acceptable on the site.</p> <p>We're going to do this based on votes. I'll leave it up to debate in the comments below, but we'll emulate Area51 question requirements. Here are the guidelines:</p> <ul> <li><strong>10 positive votes</strong>, passes.</li> <li><strong>One answer per topic</strong>. The focus is voting on topics, and votes pertain to the validity of the topic.</li> <li>Similar topics that can be merged should explicitly mention the deprecated topic.</li> <li>Appropriately passed topics should have closed questions re-opened (as appropriate).</li> </ul>
<p>I absolutely agree. I believe we all want this site to maintain high quality, but right now almost no questions fall within our desired scope and form.</p> <p>I think we either need to:</p> <ul> <li>Change the acceptable scope of questions to be asked</li> <li>Change how we welcome new users</li> </ul> <p>Right now most new users do not ask questions "the SE way", which quickly leads to down-votes and closing votes. For new users this is a direct slap in the face.</p> <p>What we rather should do is to <em>encourage</em> new users to improve their question, and if they do, give them the highly desired up-votes to make them come back for more. </p> <p>I think the reputation system on SE sites is a great motivator for writing good questions and answers. And if we want this site to grow, we need to let our fellow users grow with it.</p>
<p>I've been active on SO since it was in beta, and have participated in numerous SE sites when they were in beta.</p> <p>It's my impression that there is much more enthusiasm for close votes here than in other sites which launched out of beta. I know that seems to discourage me from participating more, and may discourage others likewise.</p> <p>Whereas for programming and electronics my first goto is always stack, I'm finding that other sites are having better answers and a "nicer" approach to my n00bism in 3d printing.</p> <p>Just IMHO and FWIW!</p>
26
<p>I'm currently playing around with <a href="http://pear.php.net/package/HTML_QuickForm" rel="noreferrer">HTML_QuickForm</a> for generating forms in PHP. It seems kind of limited in that it's hard to insert my own javascript or customizing the display and grouping of certain elements.</p> <p>Are there any alternatives to QuickForm that might provide more flexibility?</p>
<p>If you find it hard to insert Javascript into the form elements, consider using a JavaScript framework such as <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype</a> or <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>. There, you can centralize the task of injecting event handling into form controls.</p> <p>By that, I mean that you won't need to insert event handlers into the HTML form code. Instead, you register those events from somewhere else. For example, in Prototype you would be able to write something like this:</p> <pre><code>$('myFormControl').observe('click', myClickFunction) </code></pre> <p>Also have a look at the answers to <a href="https://stackoverflow.com/questions/34126/whats-the-best-way-to-add-event-in-javascript">another question</a>.</p> <p>/EDIT: of course, you can also insert custom attributes and thus event handlers into the form elements using HTML_QuickForm. However, the above way is superior.</p>
<p>I can't really say anything about it but, the other day, I ran across the <a href="http://www.phpformclass.com/page/index" rel="nofollow noreferrer">clonefish</a> form library. It looked promising enough to end up in my bookmarks list as a "look at this later".</p>
8,524
<p>I have made some prints with the Ultimaker 2+ and Ultimaker 2 Extended+. The prints are in PLA. For slicing, I use Cura and I check the support checkbox (haven't gone to advanced settings to adjust support yet). I can clearly see that there is a little space between the support and the print. The supports often look like long pillars and such. </p> <p>My question then is: "What is the best technique for removing the support?". Is it to use a knife, pliers or perhaps PLA-water? Is it possible to use PLA-water to remove support when printed with Ulitmaker 2+ or is that just the Ultimaker 3? What type of technique would give a good looking print?</p> <p>Ultimaker 3 has <a href="https://ultimaker.com/materials/pva" rel="nofollow noreferrer">support filament that's water-soluble</a>. Is there something similar for Ultimaker 2+? </p>
<p>The Ultimaker 2+ is a single extruder 3D printer. Without changing the PLA spool and PVA spool continuously during the print you practically cannot make water soluble supports on the Ultimaker 2+ which can be done on the Ultimaker 3. Note that PVA (from experience) is strange material to print, the filament is very hygroscopic and will form bubbles during printing when moist. Also, PVA is prone to clog the nozzle (it cooks easily) it therefore has its own printer core (nozzle assembly) on the Ultimaker 3 (still it clogs easily). Furthermore, it takes a while to dissolve in water.</p> <p>If you have a single extruder and nozzle, your best option is to use the same material for support, but modify the support settings as such that it can be easily removed. E.g. on thin layer heights (0.1&nbsp;mm) I usually increase the gap between support and product over the default value, see <a href="https://3dprinting.stackexchange.com/a/7991">this answer</a>.</p> <p>On dual extruder printers, e.g. on the Ultimaker 3 and S5, my colleagues have better experience using <a href="https://ultimaker.com/en/products/materials/breakaway" rel="nofollow noreferrer">Ultimaker Breakaway</a> filament rather than using PVA. As with the PLA supports, you need to "break them away" from the actual product; I use a Leatherman Charge or FREE P4 as these tools have fine pointed pliers. Note that there are removal tools available that are best described as soldering irons that can aid in the removal of support structures:</p> <p><a href="https://i.stack.imgur.com/81q27.png" rel="nofollow noreferrer" title="Modifi3d support removal tool"><img src="https://i.stack.imgur.com/81q27.png" alt="Modifi3d support removal tool" title="Modifi3d support removal tool"></a></p> <p>Note that I have mixed feelings about this product; it is hard to neatly remove supports using these small soldering irons, but it sometimes works.</p>
<p>PLA and ABS are hard plastics. They are not water-soluble. If you print with these materials, just snap printed support materials off and clean the interface layer with a knife and sanding.</p> <p>To remove the support, it is best to use strong tweezers or a pair of pliers to grip and then apply some force. Generally, I use needle pliers, but occasionally I also use snippets to cut up the support towers into more manageable chunks and keep the printed part safer. It can help to remove it in pieces and score the breaking lines.</p> <p>As PLA is brittle, I prefer to break away from the object and not pull.</p>
1,491
<p>I am trying to print a model that requires support material to be on the first layer, what is the best way to accomplish this? I am currently using Cura. It seems that the support material is too flaky. I have the infill for the support at around 8%</p>
<p>I had the same problem printing a miniature just recently. As always, settings are somewhat dependent from the object you want to print, but here are some suggestions:</p> <ul> <li>Increase the support density: 15% (8% is very low!)</li> <li>Support pattern: zig-zag with "connect zig-zag" option enabled (add stiffness to the "column" of support)</li> <li>Enable support interface (increase adhesion to the plate, and provide a more "beefy" base for the support material)</li> </ul> <p>For reference, here's a screenshot of my settings as I tweaked them for that miniature (printed a 0.1mm layer height).</p> <p><a href="https://i.stack.imgur.com/WNjki.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WNjki.png" alt="complete support settings"></a></p> <p>("Support line distance 1mm" is the same as "Support density 15%", or at least it is the same with my nozzle size)</p> <p>If your problem was not only with the "flakiness" of the material, but also with it adhesion to the bed, then prepping your printing bed somehow (with a bit of painter tape, glue, etc... can help. Alternatively using a brim or a raft (as also suggested by another responder) could also help.</p> <p><strong>EDIT</strong>: all the above still standing true, it turns out the OP had a hardware problem as well, his timing belt being loose (see comments).</p>
<p>I cannot comment on your infill percentage for supports, since I never use them. In any case, increasing the infill may well have little or no effect.</p> <p>However, you could try two things: If your slicer includes supports when generating brims, then use brims. Otherwise, use a raft.</p>
796
<p>What is the best way to typeset a function with arguments for readibility, brevity, and accuracy? I tend to put empty parentheses after the function name like <code>func()</code>, even if there are actually arguments for the function. I have trouble including the arguments and still feeling like the paragraph is readable.</p> <p>Any thoughts on best practices for this?</p>
<p>I usually take that approach, but if I feel like it's going to cause confusion, I'll use ellipses like: <code>myFunction(...)</code></p> <p>I guess if I were good, I would use those <em>any</em> time I was omitting parameters from a function in text.</p>
<p>I would simply be a little more careful with the name of my variables and parameters, most people will then be able to guess much more accurately what type of data you want to hold in it.</p>
2,585
<p>I am using the webbrowser control in winforms and discovered now that background images which I apply with css are not included in the printouts.</p> <p>Is there a way to make the webbrowser print the background of the displayed document too?</p> <p>Edit: Since I wanted to do this programatically, I opted for this solution:</p> <pre><code>using Microsoft.Win32; ... RegistryKey regKey = Registry.CurrentUser .OpenSubKey("Software") .OpenSubKey("Microsoft") .OpenSubKey("Internet Explorer") .OpenSubKey("Main"); //Get the current setting so that we can revert it after printjob var defaultValue = regKey.GetValue("Print_Background"); regKey.SetValue("Print_Background", "yes"); //Do the printing //Revert the registry key to the original value regKey.SetValue("Print_Background", defaultValue); </code></pre> <p>Another way to handle this might be to just read the value, and notify the user to adjust this himself before printing. I have to agree that tweaking with the registry like this is not a good practice, so I am open for any suggestions.</p> <p>Thanks for all your feedback</p>
<p>If you're going to go and change an important system setting, make sure to first read the current setting and restore it when you are done.</p> <p>I consider this <em>very bad</em> practice in the first place, but if you must do it then be kind.</p> <pre><code>Registry.LocalMachine </code></pre> <p>Also, try changing <code>LocalUser</code> instead of <code>LocalMachine</code> - that way if your app crashes (and it will), then you'll only confounded the user, not everyone who uses the machine.</p>
<p>By default, the browser does not print background images at all. </p> <p>In Firefox</p> <pre><code>* File &gt; Page Setup &gt; Check Off "Print Background" * File &gt; Print Preview </code></pre> <p>In IE</p> <pre><code>* Tools &gt; Internet Options &gt; Advanced &gt; Printing * Check Off "Print Background Images and Colors" </code></pre> <p>In Opera</p> <pre><code>* File &gt; Print Options &gt; Check Off "Print Page Background" * File &gt; Print Preview (You may have to scroll down/up to see it refresh) </code></pre>
7,068
<p>Are there any defacto standards for interfacing between common 3D printers and custom extruders or other tooling? I was thinking how it would be good to have switchable nozzle widths mounted on the same heat block and switched between using a solenoid so you could have say a 0.25&nbsp;mm for surface layer and details, then swap to 0.6&nbsp;mm for the infill.</p> <p>What would be the path of least resistance so it could be accessed in generic firmware? </p> <p>The design I was thinking would be similar to a generic aluminium heat block with two nozzles screwed in side by side with there inputs meeting in an inverted Y junction with its center drilled out and replaced by a rod with appropriate channeling to divert the already molten plastic between nozzles. Turning the rod would be done from a solenoid mounted somewhere behind the heat-break.with a clamping mechanism.</p>
<h2>Generally: nozzles are not changed, the whole tool head is</h2> <p>While &quot;tool change&quot; is easy to implement in a G-code and could be easily adapted in the firmware, there are several practical issues to hot-swapping nozzles without swapping the whole hotend assembly:</p> <ul> <li>The hotend is a fluid-dynamic system that needs to be sealed to operate under pressure and temperature.</li> <li>The seal of the nozzle-heatbreak system is in most systems a metal-on-metal pressure seal</li> <li>Rubber seals are not an option in a system that runs over 180°C</li> <li>Moving metal seals are very hard to make and run smoothly.</li> </ul> <h1>Your idea: especially <strong>No</strong></h1> <p>There is literally no way to design a turning Y-switch that fits the following bills:</p> <ul> <li>sealed</li> <li>filament path ~2 mm</li> <li>screw-in diameter for heatbreak and nozzles M6</li> <li>creates enough free space between the lower outlets to mount 2 M6 nozzles with enough space to hold a wrench (=15mm diameter of centers)</li> <li>fit into the form factor of a conventional heater block</li> </ul> <p>Your idea would need to be considerably larger, need a stronger heater element and creates an impossibly to clean area around the turning junction peg. Atop that, you would trade 1 area of possible leak (between heatbreak and nozzle) for 3 areas of possible leaks (nozzle-block and heatbreak block) and one area of guaranteed leak (the turning peg).</p> <h2>How is it done then?!</h2> <p>Currently, there are the following ways to swap between different of nozzles mid-print that have been proven to work somewhat reliably:</p> <ol> <li>fixed independent print heads with independent carriages.</li> <li>fixed independent nozzles and heaters on one carriage.</li> <li>swapping print heads on one carriage.</li> </ol> <p>The first design is used for example in the Leapfrog Bolt, combined heads are for example the <a href="https://e3d-online.com/hotends/multi-extrusion" rel="nofollow noreferrer">e3D Chimera, Cyclops and Kraken</a>. e3D also designed on a reliable printhead - or rather tool - swapping system starting about 2018 and did release it to the public in <a href="https://e3d-online.com/blog/2019/04/18/toolchanger-the-update-youve-all-been-waiting-for/" rel="nofollow noreferrer">late 2019</a>.</p> <p>Type 1 needs you to level the printheads well and to the same height in the easy case, but with the right setup of firmware, a Z-offset of the two tools can be included and compensated for - possibly even automatically. Type 3 does usually demands you to include very accurate offsets of the used tools or includes a way to measure the offset during operation, though I lack insight into how e3D solves it. Both setups can mitigate oozing of the unused nozzles out of the printing volume.</p> <p>Type 2 not only demands hyper exact leveling, but it <em>also</em> is very prone to create some sort of oozing of the unused nozzle.</p>
<p>Tool change is M06 (then some value specifying what change to occur). You will need to implement the necessary changes in the firmware to support whatever electronics is required to perform the tool change (eg stepper driver | hobby servo, mosfets to run the solenoid). Once done, your slicer now has to do the work of knowing that there is a different nozzle size for different parts of the model. I know of no, slicer that can do that for different sizes on the same layer.</p> <p>As for your idea: manual "tool changes" might be a better way to go, otherwise you would have to put the entire hot end on a carousel. <a href="https://www.polync.com/2019/08/hotend-ejection-mechanism/" rel="nofollow noreferrer">Proposed hot end ejection mechanism</a> The link (authored by me) describes a fast removal system for manually changing the hot end nozzles before prints. The electronics would need to be connected via pogo pins so that the installer doesn't need to connect any wires. </p> <p>Further in this video (<a href="https://www.youtube.com/watch?time_continue=11&amp;v=RMoyh84kEiw&amp;feature=emb_logo" rel="nofollow noreferrer">Printhead swapping</a>), the author shows a magnetically attached and registered quick swap hot end, which can even swap the extruder.</p>
1,641
<p>I have wondered about the appropriateness of reflection in C# code. For example I have written a function which iterates through the properties of a given source object and creates a new instance of a specified type, then copies the values of properties with the same name from one to the other. I created this to copy data from one auto-generated LINQ object to another in order to get around the lack of inheritance from multiple tables in LINQ.</p> <p>However, I can't help but think code like this is really 'cheating', i.e. rather than using using the provided language constructs to achieve a given end it allows you to circumvent them.</p> <p>To what degree is this sort of code acceptable? What are the risks? What are legitimate uses of this approach?</p>
<p>Sometimes using reflection can be a bit of a hack, but a lot of the time it's simply the most fantastic code tool.</p> <p>Look at the .Net property grid - anyone who's used Visual Studio will be familiar with it. You can point it at any object and it it will produce a simple property editor. That uses reflection, in fact most of VS's toolbox does.</p> <p>Look at unit tests - they're loaded by reflection (at least in NUnit and MSTest).</p> <p>Reflection allows dynamic-style behaviour from static languages.</p> <p>The one thing it really needs is duck typing - the C# compiler already supports this: you can <code>foreach</code> anything that looks like <code>IEnumerable</code>, whether it implements the interface or not. You can use the C#3 collection syntax on any class that has a method called <code>Add</code>.</p> <p>Use reflection wherever you need dynamic-style behaviour - for instance you have a collection of objects and you want to check the same property on each.</p> <p>The risks are similar for dynamic types - compile time exceptions become run time ones. You code is not as 'safe' and you have to react accordingly.</p> <p>The .Net reflection code is very quick, but not as fast as the explicit call would have been.</p>
<p>Reflection makes it very easy to implement plugin architectures where plugin DLLs are automatically loaded at runtime (not explicitly linked at compile time).</p> <p>These can be scanned for classes that implement/extend relevant interfaces/classes. Reflection can then be used to instantiate instances of these on demand.</p>
7,012
<p>In a web interface, I've got a text field. When user enters text and accepts with enter, application performs an action.</p> <p>I wanted to test the behavior with Selenium. Unfortunately, invoking 'keypress' with chr(13) insert representation of the character into the field.</p> <p>Is there a way other then submitting the form? I'd like to mimic intended user interaction, without any shortcuts...</p>
<p>This Java code works for me:</p> <pre><code>selenium.keyDown(id, "\\13"); </code></pre> <p>Notice the escape. You probably need something like chr(\13)</p>
<p>Though I haven't tested this I imagine you can use "\r\n" appended to a string to simulate a new line. If not look for the languages equivalent to "Environment.NewLine;" ?</p>
9,706
<p>Short version: What is the cleanest and most maintainable technique for consistant presentation and AJAX function across all browsers used by both web developers and web developers' end-users?</p> <ul> <li>IE 6, 7, 8</li> <li>Firefox 2, 3</li> <li>Safari</li> <li>Google Chrome</li> <li>Opera</li> </ul> <p>Long version: I wrote a <a href="http://con.appspot.com" rel="nofollow noreferrer">web app aimed at other web developers</a>. I want my app to support the major web browsers (plus Google Chrome) in both presentation and AJAX behavior.</p> <p>I began on Firefox/Firebug, then added conditional comments for a consistent styling under IE 6 and 7. Next, to my amazement, I discovered that jQuery does not behave identically in IE; so I <a href="http://github.com/jhs/app-engine-console/commit/4fe7741ad1856208b565eeab4260a64933929c01" rel="nofollow noreferrer">changed my Javascript to be portable on FF and IE</a> using conditionals and less pure jQuery.</p> <p>Today, I started testing on Webkit and Google Chrome and discovered that, not only are the styles inconsistant with both FF and IE, but Javascript is not executing at all, probably due to a syntax or parse error. I expected some CSS work, but now I have more Javascript debugging to do! At this point, I want to step back and think before writing piles of special cases for all situations.</p> <p>I am <b>not looking for a silver bullet, just best practices</b> to keep things as understandable and maintainable as possible. I prefer if this works with no server-side intelligence; however if there is a advantage to, for example, check the user-agent and then return different files to different browsers, that is fine if the total comprehensibility and maintainability of the web app is lower. Thank you all very much!</p>
<p>I am in a similar situation, working on a web app that is targeted at IT professionals, and required to support the same set of browsers, minus Opera.</p> <p>Some general things I've learned so far:</p> <ul> <li>Test often, in as many of your target browsers as you can. Make sure you have time for this in your development schedule.</li> <li>Toolkits can get you part of the way to cross-browser support, but will eventually miss something on some browser. Plan some time for debugging and researching fixes for specific browsers.</li> <li>If you need something that's not in a toolkit and can't find a free code snippet, invest some time to write utility functions that encapsulate the browser-dependent behavior.</li> <li>Educate yourself about known browser bugs, so that you can steer your implementation around them.</li> </ul> <p>A few more-specific things I've learned:</p> <ul> <li>Use conditional code based on the user-agent only as a last resort, because different generations of the "same" browser may have different features. Instead, test for standards-compliant behavior first &mdash; e.g., <code>if(node.addEventListener)...</code>, then common non-standard functions &mdash; e.g., <code>if(window.attachEvent)...</code>, and then, if you must, look at the user-agent for a specific browser type &amp; version number.</li> <li>Knowing when the DOM is 'ready' for script access is different in just about every browser. A good toolkit will abstract this for you.</li> <li>Event handlers are different in just about every browser. A good toolkit will abstract this for you.</li> <li>Creating DOM elements, particularly form controls or elements with attributes, can be tricky with document.createElement and element.setAttribute. While not standard (and kinda yucky), using node.innerHTML with strings that contain bits of HTML seems to be more reliable across browser types. I have yet to find a toolkit that will let you use element.setAttribute to add a 'name' to a form element in IE.</li> <li>CSS differences (and bugs) are just as important as JS differences.</li> <li>The 'core' Javascript features (String, Date, RegExp, Array functions) seem to be pretty reliable and consistent across browsers, especially relative to the DOM/CSS/Window functions. There's some small joy in the fact that the language isn't entirely different on every platform. :-)</li> </ul> <p>I haven't really run into any Chrome-specific JS bugs, but it's always one of the first browsers I test.</p> <p>HTH</p>
<p>If your very top priority is exactly consistent presentation on all the browsers listed with no disparities, you should probably be looking at AS3 and Flex.</p>
6,707
<p>I have an ASP.NET webforms application (3.5 SP1) that I'm working on, and attempting to enable gzip fpr HTML and CSS that comes down the pipe. I'm using <a href="http://www.stardeveloper.com/articles/display.html?article=2007110401&amp;page=1" rel="nofollow noreferrer">this implementation</a> (and tried a few others that hook into Application_BeginRequest), and it seems to be corrupting the external CSS file that the pages use, but intermittently...suddenly all styles will disappear on a page refresh, stay that way for awhile, and then suddenly start working again.</p> <p>Both IE7 and FF3 exhibit this behavior. When viewing the CSS using the web developer toolbar, it returns jibberish. The cache-control header is coming through as "private," but I don't know enough to figure out if that's a contributing factor or not.</p> <p>Also, this is running on the ASP.NET Development Server. Maybe it'd be fine with IIS, but I'm developing on XP and it'd be IIS5.</p>
<p>Is it only CSS files that get corrupted? Do JS files (or any other static text files) come through ok?</p> <p>Also can you duplicate the behavior if you browse directly to the CSS file?</p> <p>I've only enabled compression on Windows 2003 server's IIS using this approach:</p> <ol> <li>IIS → Web Sites → Properties → Service tab, check both boxes</li> <li>IIS → Web Service Extensions → Right click, Add New<pre> Name Http Compression Required Files %systemroot%\system32\inetsrv\gzip.dll </pre></li> <li>IIS → Right click top node, Internet Information Services, check <em>Enable Direct Metabase Edit</em></li> <li>Backup and Edit <code>%systemroot%\system32\inetsrv\MetaBase.xml</code> <ol> <li>Find <code>Location ="/LM/W3SVC/Filters/Compression/gzip"</code> <ul> <li>Add <code>png</code>, <code>css</code>, <code>js</code> and any other static file extensions to <code>HcFileExtensions</code></li> <li>Add <code>aspx</code> and any other executable extensions to <code>HcScriptFileExtensions</code></li> <li>Save </li> </ul></li> </ol></li> <li>Restart IIS (run <code>iisreset</code>) </li> </ol> <p>If you have a Windows 2003/2008 server to play with you could try that approach.</p>
<p>If you will be deploying on IIS 6 or IIS 7, just use the built-in IIS compression. We're using it on production sites for compressing HTML, CSS, and JavaScript with no errors. It also caches the compressed version on the server, so the compression hit is only taken once.</p>
4,255
<p>I need to implement a 4-to-1 function in Veriog. The input is 4 bits, a number from 0-15. The output is a single bit, 0 or 1. Each input gives a different output and the mapping from inputs to outputs is known, but the inputs and outputs themselves are not. I want vcs to successfully optimizing the code and also have it be as short/neat as possible. My solution so far:</p> <pre><code>wire [3:0] a; wire b; wire [15:0] c; assign c = 16'b0100110010111010; //for example but could be any constant assign b = c[a]; </code></pre> <p>Having to declare c is ugly and I don't know if vcs will recognize the K-map there. Will this work as well as a case statement or an assignment in conjunctive normal form?</p>
<p>What you have is fine. A case statement would also work equally well. It's just a matter of how expressive you wish to be. </p> <p>Your solution, indexing, works fine if the select encodings don't have any special meaning (a memory address selector for example). If the select encodings do have some special semantic meaning to you the designer (and there aren't too many of them), then go with a case statement and enums.</p> <p>Synthesis wise, it doesn't matter which one you use. Any decent synthesis tool will produce the same result.</p>
<p>Apparently I am using a lousy synthesis tool. :-) I just synthesized both versions (just the module using a model based on fan-outs for wire delays) and the indexing version from the question gave better timing and area results than the case statements. Using Synopsys DC Z-2007.03-SP.</p>
6,427
<p>Is anyone out there using Team Foundation Server within a team that is geographically distributed? We're in the UK, trying work with a team in Australia and we're finding it quite tough.</p> <p>Our main two issues are:</p> <ol> <li>Things are being checked out to us without us asking on a get latest. </li> <li>Even when using a proxy, most thing take a while to happen. </li> </ol> <p>Lots of really annoying little things like this are hardening our arteries, stopping us from delivering code and is frankly creating a user experience akin to pushing golden syrup up a sand dune.</p> <p>Is <em>anyone</em> out there actually using TFS in this manner, on a daily basis with (relative) success?</p> <p>If so, do you have any hints, tips, tricks or gotchas that would be worth knowing?</p> <p>P.S. Upgrading to CruiseControl.NET is not an option.</p>
<p>Definitely upgrade to TFS 2008 and Visual Studio 2008, as it is the "v2" version of Team System in every way. Fixes lots of small and medium sized problems.</p> <p>As for "things being randomly checked out" this is almost <em>always</em> due to Visual Studio deciding to edit files on your behalf. Try getting latest from the Team Explorer, with nothing open in Visual Studio, and see if that behavior persists. I bet it won't!</p> <p>Multiple TFS servers is a bad idea. Make sure your proxy is configured correctly, as it caches repeated GETs. That said, TFS is a server connected model, so it'll always be a bit slower than true "offline" source control systems.</p> <p>Also, if you could edit your question to contain more specific complaints or details, that would help -- right now it's awfully vague, so I can't answer very well.</p>
<p>From my understanding you can have multiple TFS Application servers in different locations. They either can both talk to the same SQL Server or you could use SQL Server mirroring. Having your own local TFS server would likely speed up your development times.</p>
3,220
<p>Navision 5.0 includes a feature to export to Word or Excel. Is it possible to make this work with OpenOffice.org Writer or Calc instead? If so, what has to be done to set it up?</p> <p>I have been told by my Navision reseller that the feature works best with Office 2007, and export to Excel 2003 works. No mention of Office 2000 (which is what we mostly have installed currently) or OpenOffice.org. I'm hoping to be able to standardise on OpenOffice.org across the company when 3.0 is released, to avoid the expense of upgrading everyone to Microsoft Office 2007.</p>
<p>I know this is an old question, but I'll add the answer just in case anyone comes here:</p> <p>You can export directly to OpenOffice without customizations. The only thing you need is to go into Tools > Manage Style Sheets... and modify the existing StyleSheets so that they open OpenCalc and OpenWrite instead of Excel and Word.</p> <p>Note: it's been a while since I last configured it, but I seem to remember that you might need to export and reimport the stylesheets to change the associated program.</p> <p>It's quite easy, and you can actually keep both options (Export to Excel/Export to OpenCalc) so that users who need MS Office can use Excel, while the rest use OpenCalc.</p> <p>This answer applies to the functionality to export to Word and Excel in Dynamics Nav 5.0 and Nav 5.0SP1. I haven't tried it in Dynamics Nav 2009 (Role Tailored Client).</p>
<p>You should be able to export the documents to word or excel and then use OpenOffice to open the documents. No additional set up required.</p>
7,302
<p>Our company is currently writing a GUI automation testing tool for compact framework applications. We have initially searched many tools but none of them was right for us. </p> <p>By using the tool you can record test-cases and group them together to test-suites. For every test-suite there is generated an application, which launches the application-under-test and simulates user-input.</p> <p>In general the tool works fine, but as we are using <strong>window handles</strong> for simulation user input, you can't do very many things. For example it is impossible for us to get the name of a control (we just get the caption). </p> <p>Another problem using window handles is checking for a change. At the moment we simulate a click on a control and depending on the result we know if the application has gone to the next step.</p> <p>Is there any other (simpler) way for doing such things (for example the message queue or anything else)?</p>
<p>If the Automated GUI testing tool has knowledge about the framework the application is written in it could use that information to make better or more advanced scripts. <a href="http://www.automatedqa.com/products/testcomplete/index.asp" rel="nofollow noreferrer">TestComplete</a> for example knows about Borland's VCL and WinForms. If you test applications build using Windows Presentation Foundation has advanced support for this <a href="http://msdn.microsoft.com/en-us/library/aa348551.aspx" rel="nofollow noreferrer">build in</a>.</p>
<p>I finally found a solution to communicate between the testing-application and the application-under-test: <a href="http://msdn.microsoft.com/en-us/magazine/cc163617.aspx" rel="nofollow noreferrer">Managed Spy</a>. It's basically a .NET application build on top of ManagedSpyLib. </p> <p>ManagedSpyLib allows programmatic access to the Windows Forms controls of another process. For this it uses Window Hooks and memory-mapping files.</p> <p>Thanks for all who helped me to get to this solution!</p>
3,924
<p>I'm having a problem obtaining the total row count for items displayed in a Gridview using Paging and with a LinqDataSource as the source of data.</p> <p>I've tried several approaches:</p> <pre><code>protected void GridDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e) { totalLabel.Text = e.TotalRowCount.ToString(); } </code></pre> <p>returns -1 every time.</p> <pre><code>protected void LinqDataSource1_Selected(object sender, LinqDataSourceStatusEventArgs e) { System.Collections.Generic.List&lt;country&gt; lst = e.Result as System.Collections.Generic.List&lt;country&gt;; int count = lst.Count; } </code></pre> <p>only gives me the count for the current page, and not the total.</p> <p>Any other suggestions?</p>
<p>The LinqDataSourceEventArgs returned in those events return -1 on these occasions:</p> <blockquote> <p>-1 if the LinqDataSourceStatusEventArgs object was created during a data modification operation; -1 if you enabled customized paging by setting AutoPage to true and by setting RetrieveTotalRowCount to false. </p> </blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linqdatasourcestatuseventargs.totalrowcount.aspx" rel="nofollow noreferrer">Check here for more information</a> - the table towards the bottom, shows different properties to set to get the rowcount back, but it looks like you either have to set AutoPage and AllowPage properties to either both true or both false.</p> <p>Judging by the table in the link above and the example you provide you have Autopage set to false, but AllowPaging set to true, therefore it is returning the amount of rows in the page.</p> <p>HTH</p>
<p>The TotalRowCount property is only valid for certain values of AutoPage and AllowPaging. They should both be true (in your case) or both be false.</p> <p>chech out the following page for an explanation of the TotalRowCount property.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linqdatasourcestatuseventargs.totalrowcount.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linqdatasourcestatuseventargs.totalrowcount.aspx</a></p>
4,735
<p>I'm trying to leverage the using block more and more these days when I have an object that implements IDisposable but one thing I have not figured out is how to catch an exception as I would in a normal try/catch/finally ... any code samples to point me in the right direction?</p> <p>Edit: The question was modified after reading through the replies. It was "How to Throw an exception in a using block with .NET 2.0?" but I was actually looking for a way to catch these exceptions inside a using block.</p> <hr> <p>I'm looking for more detail on rolling my own catching block inside a using block.</p> <p>Edit: What I wanted to avoid is having to use a try/catch/finally inside my using block like @Blair showed. But maybe this is a non issue...</p> <p>Edit: @Blair, this is exactly what I was looking for, thanks for the detailed reply!</p>
<p>I don't really understand the question - you throw an exception as you normally would. If <code>MyThing</code> implements <code>IDisposable</code>, then:</p> <pre><code>using ( MyThing thing = new MyThing() ) { ... throw new ApplicationException("oops"); } </code></pre> <p>And <code>thing.Dispose</code> will be called as you leave the block, as the exception's thrown. If you want to combine a try/catch/finally and a using, you can either nest them:</p> <pre><code>try { ... using ( MyThing thing = new MyThing() ) { ... } ... } catch ( Exception e ) { .... } finally { .... } </code></pre> <p>(Or put the try/catch/finally in the using):</p> <pre><code>using ( MyThing thing = new MyThing() ) { ... try { ... } catch ( Exception e ) { .... } finally { .... } ... } // thing.Dispose is called now </code></pre> <p>Or you can unroll the <code>using</code> and explicitly call <code>Dispose</code> in the <code>finally</code> block as @Quarrelsome demonstrated, adding any extra exception-handling or -recovery code that you need in the <code>finally</code> (or in the <code>catch</code>).</p> <p>EDIT: In response to @Toran Billups, if you need to process exceptions aside from ensuring that your <code>Dispose</code> method is called, you'll either have to use a <code>using</code> and <code>try/catch/finally</code> or unroll the <code>using</code> - I don't thinks there's any other way to accomplish what you want.</p>
<p>You need to have a try statement to catch an exception </p> <p>Either you can use an try statement within the using block or you can use a using block in a try block </p> <p>But you need to use a try block to catch any exceptions occuring </p>
5,673
<p>After test driving Google Chrome for 30 minutes or so, I like it, even if it seems bare-bones at the moment. The obvious way to add a few things I can't live without would be through plugins. Does anyone have any links to resources on how to get started building a plugin/addon for Chrome? Thanks.</p>
<p><a href="http://www.mattcutts.com/blog/common-google-chrome-objections/" rel="nofollow noreferrer">Matt Cutts</a> (the Google SEO guru) has a Q&amp;A about chrome, and writes about it: </p> <blockquote>Q: But I can’t install extension X! Google Chrome is dead to me if I can’t use extension X!<br/> A: Then you’ll have to use another browser for a while. Google Chrome currently doesn’t support browser extensions (it does support plug-ins, such as Flash). I’m sure that extensions/add-ons are something that the Chrome team would like to do down the road, but the Chrome team will be a bit busy for a while, what with the feedback from the launch plus working on Mac and Linux support. I’d suggest that you give Google Chrome a try for a few days to see if enjoy browsing even without extension X. A lot of really cool extension-like behaviors such as resize-able textareas and drag-and-drop file upload are already built into Google Chrome. </blockquote>
<p>The accepted answer is out of date. A couple of useful URLs:</p> <ul> <li>For developers: <a href="http://developer.chrome.com/extensions/index.html" rel="nofollow">http://developer.chrome.com/extensions/index.html</a></li> <li>For end users: <a href="https://chrome.google.com/webstore/category/home?hl=en-US" rel="nofollow">https://chrome.google.com/webstore/category/home?hl=en-US</a></li> </ul> <p>There's a difference between a 'plugin' and an 'extension'. Chrome supports NPAPI plugins:</p> <ul> <li><a href="http://developer.chrome.com/extensions/npapi.html" rel="nofollow">http://developer.chrome.com/extensions/npapi.html</a></li> </ul> <p>Chrome may also support a new Pepper Plugin API (ppapi):</p> <ul> <li><a href="http://code.google.com/p/ppapi/" rel="nofollow">http://code.google.com/p/ppapi/</a></li> </ul>
6,192
<p>I've recently been working on a beginner's project in Scala, and have a beginner question about Scala's Lists.</p> <p>Say I have a list of tuples ( <code>List[Tuple2[String, String]]</code>, for example). Is there a convenience method to return the first occurence of a specified tuple from the List, or is it necessary to iterate through the list by hand?</p>
<pre> scala> val list = List(("A", "B", 1), ("C", "D", 1), ("E", "F", 1), ("C", "D", 2), ("G", "H", 1)) list: List[(java.lang.String, java.lang.String, Int)] = List((A,B,1), (C,D,1), (E,F,1), (C,D,2), (G,H,1)) scala> list find {e => e._1 == "C" && e._2 == "D"} res0: Option[(java.lang.String, java.lang.String, Int)] = Some((C,D,1)) </pre>
<p>You could also do this, which doesn't require knowing the field names in the Tuple2 class--it uses pattern matching instead:</p> <pre><code>list find { case (x,y,_) =&gt; x == "C" &amp;&amp; y == "D" } </code></pre> <p>"find" is good when you know you only need one; if you want to find all matching elements you could either use "filter" or the equivalent sugary for comprehension:</p> <pre><code>for ( (x,y,z) &lt;- list if x == "C" &amp;&amp; y == "D") yield (x,y,z) </code></pre>
7,759
<p>Can you cast a <code>List&lt;int&gt;</code> to <code>List&lt;string&gt;</code> somehow?</p> <p>I know I could loop through and .ToString() the thing, but a cast would be awesome.</p> <p>I'm in C# 2.0 (so no <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" rel="noreferrer">LINQ</a>).</p>
<p>.NET 2.0 has the <code>ConvertAll</code> method where you can pass in a converter function:</p> <pre><code>List&lt;int&gt; l1 = new List&lt;int&gt;(new int[] { 1, 2, 3 } ); List&lt;string&gt; l2 = l1.ConvertAll&lt;string&gt;(delegate(int i) { return i.ToString(); }); </code></pre>
<p>You have to build a new list. The underlying bit representations of <code>List&lt;int&gt;</code> and <code>List&lt;string&gt;</code> are completely incompatible -- on a 64-bit platform, for instance, the individual members aren't even the same size.</p> <p>It is theoretically possible to treat a <code>List&lt;string&gt;</code> as a <code>List&lt;object&gt;</code> -- this gets you into the exciting worlds of covariance and contravariance, and is not currently supported by C# or VB.NET.</p>
6,673
<p>I was messing around with <a href="http://www.ayende.com/projects/rhino-mocks.aspx" rel="nofollow noreferrer">RhinoMocks</a> this morning and couldn't run my tests because RhinoMocks.dll was not in a "trusted location". The assembly is in my c:\documents and settings\\My Documents\Visual Studio 2008\Projects (and so on) folder. What's the deal?</p>
<p>Did you download a zip file from the internet and then extract it using the standard explorer tools. I think this marks the directory as untrusted and Visual studio detects this.</p>
<p>Right click the file or location and choose Properties. At the very bottom, you should see the button "Unblock". Click it and press OK.</p>
8,310
<p>The print is very solid except for the 4 walls.</p> <p>From the top, I can slide a paper down to the bottom. This is ONLY between the walls, the rest of the print is solid. The filament is PLA 1.75&nbsp;mm.</p> <p>But the bottom is solid, no gaps.</p> <p>I have checked the usual problems on Ultimaker troubleshooting photo gallery, but I can find anything similar.</p> <p>Any advice to fix this would be very welcome.</p> <p><a href="https://i.stack.imgur.com/FAJNf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FAJNf.jpg" alt="3d print wall separation"></a></p> <p><em>Print settings:</em><br> <a href="https://i.stack.imgur.com/LvRFW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LvRFW.png" alt="cura settings 1"></a> <a href="https://i.stack.imgur.com/pYMH2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pYMH2.png" alt="cura settings 2"></a> <a href="https://i.stack.imgur.com/cnUB0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cnUB0.png" alt="cura settings 3"></a></p>
<p>I've experienced this too, especially with flex modified PLA filament. For that, fixing underextrusion and increasing temperature made it go away. Sadly Cura has no option to overlap walls slightly (if printed in the right order, this could be done without affecting dimensional accuracy) except possibly the outer one, so you really have to get extrusion rate calibrated right or this will happen.</p>
<p>Look for the <strong>horizontal expansion</strong> setting in Cura. By default it should be zero. The description includes this:</p> <blockquote> <p>Positive values can help compensate for too big holes.</p> </blockquote> <p>The "holes" here includes these gaps. You can set it to something very small (ie: .01 or .03, probably no more than .05) and that will likely be enough to get it to fill in those gaps.</p> <p>Unfortunately, I only have a little direct personal experience with this setting, hence the probably/likely weasel words, and I can't give much real guidance on exactly how big or small you can go with this.</p>
1,358
<p>I have a base class that represents a database test in TestNG, and I want to specify that all classes extending from this class are of a group "db-test", however I have found that this doesn't seem possible. I have tried the @Test annotation:</p> <pre><code>@Test(groups = { "db-test" }) public class DBTestBase { } </code></pre> <p>However, this doesn't work because the @Test annotation will try to make a bunch of methods into tests, and warnings/errors pop up in eclipse when the tests are run.</p> <p>So I tried disabling the test, so at least the groups are assigned:</p> <pre><code>@Test(enabled = false, groups = { "db-test" }) public class DBTestBase { } </code></pre> <p>but then any @BeforeTest (and other similar annotations) ALSO get disabled... which is of course not what I want.</p> <p>I would like some way to annotate a class as being of a particular type of group, but it doesn't quite seem possible in TestNG. Does anyone have any other ideas?</p>
<p>The answer is through a custom <strong>org.testng.IMethodSelector</strong>:</p> <p>Its <strong>includeMethod()</strong> can exclude any method we want, like a public not-annotated method.</p> <p>However, to register a custom <em>Java</em> MethodSelector, you must add it to the <strong>XMLTest</strong> instance managed by any TestRunner, which means you need your own <strong>custom TestRunner</strong>.</p> <p>But, to build a custom TestRunner, you need to register a <strong>TestRunnerFactory</strong>, through the <strong>-testrunfactory</strong> option.</p> <p>BUT that -testrunfactory is NEVER taken into account by <strong>TestNG</strong> class... so you need also to define a custom TestNG class :</p> <ul> <li>in order to override the configure(Map) method, </li> <li>so you can actually set the TestRunnerFactory</li> <li>TestRunnerFactory which will build you a custom TestRunner,</li> <li>TestRunner which will set to the XMLTest instance a custom XMLMethodSelector</li> <li>XMLMethodSelector which will build a custom IMethodSelector</li> <li>IMethodSelector which will exclude any TestNG methods of your choosing!</li> </ul> <p>Ok... it's a nightmare. But it is also a code-challenge, so it must be a little challenging ;)</p> <p>All the code is available at <a href="http://snippets.dzone.com/posts/show/6446" rel="nofollow noreferrer"><strong>DZone snippets</strong></a>.</p> <p>As usual for a code challenge:</p> <ul> <li>one java class (and quite a few inner classes)</li> <li>copy-paste the class in a 'source/test' directory (since the package is 'test')</li> <li>run it (no arguments needed)</li> </ul> <hr> <p><strong>Update from Mike Stone:</strong></p> <p>I'm going to accept this because it sounds pretty close to what I ended up doing, but I figured I would add what I did as well.</p> <p>Basically, I created a Groups annotation that behaves like the groups property of the Test (and other) annotations.</p> <p>Then, I created a GroupsAnnotationTransformer, which uses IAnnotationTransformer to look at all tests and test classes being defined, then modifies the test to add the groups, which works perfectly with group exclusion and inclusion.</p> <p>Modify the build to use the new annotation transformer, and it all works perfectly!</p> <p>Well... the one caveat is that it doesn't add the groups to non-test methods... because at the time I did this, there was another annotation transformer that lets you transform ANYTHING, but it somehow wasn't included in the TestNG I was using for some reason... so it is a good idea to make your before/after annotated methods to alwaysRun=true... which is sufficient for me.</p> <p>The end result is I can do:</p> <pre><code>@Groups({ "myGroup1", "myGroup2"}) public class MyTestCase { @Test @Groups("aMethodLevelGroup") public void myTest() { } } </code></pre> <p>And I made the transformer work with subclassing and everything.</p>
<p>You can specify the @Test annotation at method level that allows for maximum flexibility.</p> <pre><code>public class DBTestBase { @BeforeTest(groups = "db-test") public void beforeTest() { System.out.println("Running before test"); } public void method1() { Assert.fail(); // this does not run. It does not belong to 'db-test' group. } @Test(groups = "db-test") public void testMethod1() { Assert.assertTrue(true); } } </code></pre> <p>Does this works for you or I am missing something from your question.</p>
3,053
<h3>TL;DR</h3> <p>Is it possible to build a hotend, using separate parts, sourced on eBay, from China, and still achieve a high quality print?</p> <hr /> <p>In my opinion, the E3D V6 hotend is rather expensive, at $/£70, especially to those building to a tight budget. Now, obviously/presumably, there is some quite rigorous QA and testing of the build, and they have to pay for their research costs and initial machining set ups and this is reflected in the high cost. Also, the expression, <em>you get what you pay for</em>, springs to mind.</p> <p>However, I wondered if I sourced the individual parts from China, for a dollar apiece, that is to say the:</p> <ul> <li>Throat (with Teflon lining)</li> <li>Heating block</li> <li>Heatsink</li> <li>Nozzle</li> <li>Pneumatic connector (PC4-05/PC4-M06)</li> <li>Heater</li> <li>Thermistor</li> </ul> <p>could I too, end up with a hotend, that performs as well as, or even out performs, an E3D hotend, or am I living in cloud cuckoo land?</p> <p>After all, let's not forget that most, if not, all of the parts used in a E3D hotend probably come from China anyway, these days, as most production facilites have moved from the US/EU to the cheaper manufacturing bases and machining shops, in SE Asia.</p> <p>I have read <em>so many times</em> that people were experiencing extrusion problems, shoddy prints, etc, from their cheap printer, until they finally shelled out the cash and upgraded to a genuine E3D hotend. After that the prints were much improved. I have read this <em>countless</em> times, in blogs, threads, etc., so I presume that it is not possible.</p> <p>I realise that if the parts are not finished correctly, and end up with burring on the inside of the throat, nozzle, etc., then the filament will not extrude correctly. See <a href="https://3dprinting.stackexchange.com/questions/3985/how-long-is-an-extruders-nozzles-life/3988#3988">tbm0115's answer</a> to <a href="https://3dprinting.stackexchange.com/questions/3985/how-long-is-an-extruders-nozzles-life/">How long is an extruder&#39;s/nozzle&#39;s life?</a> However, assuming that the parts that I receive are machined, and finished, correctly then there should not be a problem, right?</p> <p>Has anyone actually done this? Is tinkering with hotends a done thing? Does anyone have any good pointers and/or tips?</p> <p>NOTE: This question is not really after opinionated answers, in order to stay within SE rules - although opinions are always welcome - but I just want to know if anyone has first hand (positive or negative) experience of this.</p>
<p>Hard to say for sure - my whole printer is cheap parts bought as a kit in China by a Chinese student who abandoned it in the US (I resurrected it after it was abandoned.) It includes all the parts you list, and I think we finally sorted out what the thermistor actually is so the temperatures are more accurate now.</p> <p>It prints. </p> <p>Could it print better? - Probably, but at some point replacing all the various cheap parts starts to look foolish .vs. just build a new printer with better parts all around, leaving the original functional. I doubt I've ever met a "E3D V6" and I'd have to google it to see what sort of paragon of printing it's supposed to be. The only thing I'm actually considering replacing is the nozzle itself, partly because I'm just guessing what size it is (mostly based on the way it prints when set to various sizes.) I'm also contemplating adding some sort of insulation for the heater block, having squnched some aluminum foil around it as a first stop-gap.</p> <p>Likewise, if your concern is with burrs, etc. a degree of fettling by you can sort that sort of thing out, if you know to do it and how to do it (i.e. you need to be somewhat mechanically ept.) But of course "parts from China" are not a monolithic entity - there are good parts and bad parts that both come from China - given the state of internet sales, you may well have (unknown to you) the choice of parts that passed quality control, parts that failed quality control, and parts that quality control never looked at (some of which might pass, some of which might fail), from the same production facility, available to you from various vendors at various price points. And then there are many different production facilities as well.</p> <p>Production in the US or Europe is no magic bullet either - competing with imports on price is difficult, so one hopes that superior quality is on offer, but it may or may not actually be from a given vendor, or a given batch of parts.</p>
<p><em>Sorry for digging up the topic, but I'd like to share my experience with cheap Chinese parts obtained from those obvious auction sites.</em></p> <hr> <p>For my <a href="https://www.thingiverse.com/thing:2254103" rel="nofollow noreferrer">Hypercube Evolution</a> I have ordered all parts from Chinese suppliers except for the Aluminium extrusion profiles. This includes belts, screws, nuts, electric cables, printer board, steppers and drivers, hotend parts, you name it. </p> <p>I do not own, or have ever owned, an official E3D hotend, so I cannot compare the clone E3D hotends to the official directly. However, I do own an Ultimaker 3 Extended (UM3E) that I manage for a group of printing enthusiasts to promote building your own printer and produce spare parts that are not sold commercially or sold at ridiculous prices. The quality of the products produced by the UM3E are very good, as expected from this quality brand, so I can compare the products from my own printer with the ones from the UM3E. </p> <p>It is often said <strong>by others</strong> that the prints I have created with my HyperCube Evolution are at least as good as the products produced on the UM3E, or sometimes even better. In that respect, it is very hard to see any differences in the products. The UM3E is known for the simplicity of use and it's relative low need to tinker to get or keep it working, but my own creation does not require a lot of tinkering either. E.g. I have never had any clogs (several kilometers of 2.85 mm filament printed) while I use a relative high retraction length (the same as on the UM3E as default in Cura). In this respect I have never had the need to upgrade to an official E3D hotend, and most likely will never do need to.</p> <p>So <strong>to answer your question</strong> if it is possible to build a hotend, using separate parts, sourced from China, to achieve a high quality print (while maintaining a low need for tinkering), I can vouch <strong>that it is indeed possible</strong>.</p> <hr> <p><em>Sidemark: Note that if you source your materials locally, e.g. local webshops, you probably also end up with imported Chinese parts! (usually <strong>at much higher costs</strong>; but at least they <strong>arrive sooner</strong>!)</em></p>
620
<p>What's the best (halting) algorithm for determining if a linked list has a cycle in it?</p> <p>[Edit] Analysis of asymptotic complexity for both time and space would be sweet so answers can be compared better.</p> <p>[Edit] Original question was not addressing nodes with outdegree > 1, but there's some talk about it. That question is more along the lines of "Best algorithm to detect cycles in a directed graph".</p>
<p>Have two pointers iterating through the list; make one iterate through at twice the speed of the other, and compare their positions at each step. Off the top of my head, something like:</p> <pre><code>node* tortoise(begin), * hare(begin); while(hare = hare-&gt;next) { if(hare == tortoise) { throw std::logic_error("There's a cycle"); } hare = hare-&gt;next; if(hare == tortoise) { throw std::logic_error("There's a cycle"); } tortoise = tortoise-&gt;next; } </code></pre> <p>O(n), which is as good as you can get.</p>
<p>What about using a hash table to store the already seen nodes (you look at them in order from the start of the list)? In practise, you could achieve something close to O(N).</p> <p>Otherwise, using a sorted heap instead of a hash table would achieve O(N log(N)).</p>
5,444
<p>Is it possible for the compiler to remove statements used for debugging purposes (such as logging) from production code? The debug statements would need to be marked somehow, maybe using annotations.</p> <p>It's easy to set a property (debug = true) and check it at each debug statement, but this can reduce performance. It would be nice if the compiler would simply make the debug statements vanish.</p>
<p>Two recommendations.</p> <p><strong>First:</strong> for real logging, use a modern logging package like log4j or java's own built in logging. Don't worry about performance so much, the logging level check is on the order of nanoseconds. (it's an integer comparison).</p> <p>And if you have more than a single log statement, guard the whole block:</p> <p>(log4j, for example:)</p> <pre><code>if (logger.isDebugEnabled()) { // perform expensive operations // build string to log logger.debug("...."); } </code></pre> <p>This gives you the added ability control logging at runtime. Having to restart and run a debug build can be very inconvenient.</p> <p><strong>Second:</strong></p> <p>You may find <a href="http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html" rel="noreferrer">assertions</a> are more what you need. An assertion is a statement which evaluates to a boolean result, with an optional message:</p> <pre><code> assert (sky.state != FALLING) : "The sky is falling!"; </code></pre> <p>Whenever the assertion results in a false, the assertion fails and an AssertionError is thrown containing your message (this is an unchecked exception, intended to exit the application). </p> <p>The neat thing is, these are treated special by the JVM and can toggled at runtime down to the class level, using a VM parameter (no recompile needed). If not enabled, there is zero overhead.</p>
<p>To directly answer your question: I don't know.</p> <p>But here is another solution to your problem: In my mind, there are two statements that collide with each other here: "debug statements" and "production code". </p> <p>What is the purpose of debug statements? Help to get rid of bugs while (unit) testing. If a piece of software is properly tested and works according to the requirements, debug statements are nothing else but OBSOLETE.</p> <p>I strongly disagree with leaving any debug statements in production code. I bet nobody bothers testing side-effects of debug code in production code. The code probably does what it's supposed to do, but does it do more than that? Do all your #defines work correctly and really take ALL of the debug code out? Who analyzes 100000 lines of pre-processed code to see if all the debug stuff is gone?</p> <p>Unless we have a different definition of production code, you should consider taking out the debug statements after the code is tested and be done with it.</p>
5,199
<p>When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash.</p> <p>I'm currently doing the following, but am sure there must be a library function for this, or at least a more elegant/robust/efficient option:</p> <pre><code>def sh_escape(s): return s.replace("(","\\(").replace(")","\\)").replace(" ","\\ ") os.system("cat %s | grep something | sort &gt; %s" % (sh_escape(in_filename), sh_escape(out_filename))) </code></pre> <p><em>Edit:</em> I've accepted the simple answer of using quotes, don't know why I didn't think of that; I guess because I came from Windows where ' and " behave a little differently.</p> <p>Regarding security, I understand the concern, but, in this case, I'm interested in a quick and easy solution which os.system() provides, and the source of the strings is either not user-generated or at least entered by a trusted user (me).</p>
<p>This is what I use:</p> <pre><code>def shellquote(s): return "'" + s.replace("'", "'\\''") + "'" </code></pre> <p>The shell will always accept a quoted filename and remove the surrounding quotes before passing it to the program in question. Notably, this avoids problems with filenames that contain spaces or any other kind of nasty shell metacharacter.</p> <p><strong>Update</strong>: If you are using Python 3.3 or later, use <a href="http://docs.python.org/dev/library/shlex.html#shlex.quote" rel="noreferrer">shlex.quote</a> instead of rolling your own.</p>
<p>On UNIX shells like Bash, you can use <code>shlex.quote</code> in Python 3 to escape special characters that the shell might interpret, like whitespace and the <code>*</code> character:</p> <pre><code>import os import shlex os.system(&quot;rm &quot; + shlex.quote(filename)) </code></pre> <p>However, this is not enough for security purposes! You still need to be careful that the command argument is not interpreted in unintended ways. For example, what if the filename is actually a path like <code>../../etc/passwd</code>? Running <code>os.system(&quot;rm &quot; + shlex.quote(filename))</code> might delete <code>/etc/passwd</code> when you only expected it to delete filenames found in the current directory! The issue here isn't with the shell interpreting special characters, it's that the filename argument isn't interpreted by the <code>rm</code> as a simple filename, it's actually interpreted as a path.</p> <p>Or what if the valid filename starts with a dash, for example, <code>-f</code>? It's not enough to merely pass the escaped filename, you need to disable options using <code>--</code> or you need to pass a path that doesn't begin with a dash like <code>./-f</code>. The issue here isn't with the shell interpreting special characters, it's that the <code>rm</code> command interprets the argument as a filename <em>or</em> a path <em>or</em> an option if it begins with a dash.</p> <p>Here is a safer implementation:</p> <pre><code>if os.sep in filename: raise Exception(&quot;Did not expect to find file path separator in file name&quot;) os.system(&quot;rm -- &quot; + shlex.quote(filename)) </code></pre>
5,639
<p>One of the bullet point features for Windows Vista Enterprize and Ultimate is the Unix subsystem for windows, which allows you to write posix... stuff? Anyway I'm outa my league talking about it... Anyone use this feature? Or explain it... </p> <p>I know next to nothing about Unix programming.</p>
<p>It's probably best not to try to use the Posix subsystem for Windows. It was never really complete and is just a useless marketing tick box.</p> <p>If you're truly interested in programming stuff for Unix, download one of the many Linux distributions (ie. <a href="http://ubuntu.com" rel="nofollow noreferrer">Ubuntu</a>) and <a href="http://virtualbox.org" rel="nofollow noreferrer">VirtualBox</a>. Install and start playing.</p>
<p>The Posix subsystem in Windows is not only incomplete, but also slower in many cases than the "native" windows functions for the same thing. This is true for I/O for example.</p>
3,827
<p>I have a build script and as part of that script it copies a jar file to a directory, for ease lets call it the utils jar. the utils jar is built by another build script sitting in another directory. What im trying to do have my build script run the utils build script so that I can ensure the utils jar is up to date.</p> <p>So I know I need to import the utils build file.</p> <pre><code>&lt;import file="../utils/build/build.xml" /&gt; </code></pre> <p>Which doesn't work because the import task, unlike almost every other ant taks, doesn't run from basedir, it runs from the pwd. So to get around that I have this little ditty, which does successfully import the build file</p> <pre><code> &lt;property name="baseDirUpOne" location=".." /&gt; &lt;import file="${baseDirUpOne}/utils/build/build.xml" /&gt; </code></pre> <p>So now that ive solved my import problem I need to call the task, well that should be easy right:</p> <pre><code>&lt;antcall target="utils.package" /&gt; </code></pre> <p><em>note that in the above, utils is the project name of ../utils/build/build.xml</em></p> <p>the problem I'm now running into is that ant call doesn't execute in ../utils/build so what I need, and cant find, is a runat property or something similar, essentially:</p> <pre><code>&lt;antcall target="utils.package" runat="../utils/build" /&gt; </code></pre> <p>The reason I need this is that in my utils build file the step to select which code to copy to the jar is based on relative paths so as to avoid hardcoding paths in my ant file. Any ideas? </p>
<p>I've got something similar set up: I have a main Ant build.xml which calls a separate build.xml that takes care of building my tests. This is how I do it:</p> <pre><code>&lt;target name="build-tests"&gt; &lt;subant target="build"&gt; &lt;fileset dir="${test.home}" includes="build.xml"/&gt; &lt;/subant&gt; &lt;/target&gt; </code></pre> <p>The trick is to use <a href="http://ant.apache.org/manual/Tasks/subant.html" rel="noreferrer"><code>subant</code></a> instead of <code>antcall</code>. You don't have to import the other build file.</p>
<p>You can pass params down to antcall using nested in the antcall block. So, you can pass the properties down that way (probably even basedir since properties are immutable). </p>
3,028
<p>I have a fairly standards compliant XHTML+CSS site that looks great on all browsers on PC and Mac. The other day I saw it on FF3 on Linux and the letter spacing was slightly larger, throwing everything out of whack and causing unwanted wrapping and clipping of text. The CSS in question has</p> <pre><code>font-size: 11px; font-family: Arial, Helvetica, sans-serif; </code></pre> <p>I know it's going with the generic sans-serif, whatever that maps to. If I add the following, the text scrunches up enough to be close to what I get on the other platforms:</p> <pre><code>letter-spacing: -1.5px; </code></pre> <p>but this would involve some nasty server-side OS sniffing. If there's a pure CSS solution to this I'd love to hear it.</p> <p>The system in question is Ubuntu 7.04 but that is irrelevant as I'm looking to fix it for at least the majority of, if not all, Linux users. Of course asking the user to install a font is not an option!</p>
<p>A List Apart has a pretty <a href="http://www.alistapart.com/articles/howtosizetextincss" rel="nofollow noreferrer">comprehensive article on sizing fonts in CSS</a>. Their conclusion is to use "<code>ems</code>" to size text, since it generally gives the most consistent sizing across browsers. They make no direct mention of different OSes, but you should try using ems. It might solve your problem.</p>
<p>I find the easiest way to solve font sizing problems between browsers is to simply leave room for error. Make divs slightly larger or fonts slightly smaller so that platform variation doesn't change wrapping or clipping considerably.</p>
6,977
<p>If you are printing an object that has a base (A statue or trophy, for example), and presuming that you have already optimized every other setting: which shape of base would give you the best and most consistent bed adhesion when using PLA on the widest range of printers (For example, if you're putting it up on a site for anybody to download)?</p> <p>For example:</p> <ol> <li><p>A square base that is thin at the edges and thick in the middle, and slopes upwards in the center, like a pyramid.</p> </li> <li><p>A circular base that is thin at the edges and thick in the middle, like a dome</p> </li> <li><p>A flat thick square.</p> </li> <li><p>A flat thick circle</p> </li> </ol> <p>Is a shape with corners better, or a shape with no corners like a disc or a fried egg?</p> <p>Do sloping sides make a difference, or general thickness?</p>
<p>From the excellent Thingiverse link, <a href="https://www.thingiverse.com/thing:4967931" rel="nofollow noreferrer">Customizable QR Keyring or Tag</a> by <a href="https://www.thingiverse.com/outwardb/designs" rel="nofollow noreferrer"><em>OutwardB</em></a> - which was provided in the (now deleted) <a href="https://3dprinting.stackexchange.com/a/18296/4762">link-only answer</a>:</p> <blockquote> <ol> <li><h3>Create the QR code</h3> <ul> <li><p>Go to <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a></p> </li> <li><p><strong>Only change the Content settings</strong></p> <p>DO NOT change the color, logo or design settings</p> </li> <li><p>Click <strong>Create QR Code</strong></p> </li> <li><p>Click <strong>Download PNG</strong> and wait for the file to download</p> </li> </ul> </li> <li><h3>Convert to SVG</h3> <ul> <li>Go to <a href="https://convertio.co/png-svg/" rel="nofollow noreferrer">PNG to SVG Converter</a> and convert the PNG image you just downloaded to a .SVG file</li> </ul> </li> <li><h3>Customise in OpenSCAD</h3> <p>You will need <a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a> from the <a href="https://www.thingiverse.com/thing:4967931/files" rel="nofollow noreferrer">files repository on Thingverse</a></p> <ol> <li><p>Download OpenSCAD from here and install it - <a href="https://openscad.org/downloads.html" rel="nofollow noreferrer">https://openscad.org/downloads.html</a></p> </li> <li><p>Put the downloaded SVG file in the same folder as the .SCAD file from this page</p> </li> <li><p>Double-click the .SCAD file to open it</p> </li> <li><p>Click <strong>Window</strong>, then untick <strong>Hide Customizer</strong></p> <p><em>Optional</em>: Click <strong>Window</strong>, then tick <strong>Hide Editor</strong></p> </li> <li><p>Enter the SVG file name in the basic settings tab (or rename the file to qr-code.svg before opening OpenSCAD)</p> </li> <li><p>Customize the settings. After changing a setting, you may need to click outside the text box to apply the change</p> </li> <li><p>Click <strong>Design</strong> &gt; <strong>Render</strong> and wait for the design to render</p> </li> <li><p>Click <strong>File</strong> &gt; <strong>Export</strong> &gt; <strong>Export to STL</strong></p> </li> <li><p>Save the file</p> </li> </ol> <p><a href="https://i.stack.imgur.com/VyzXZ.gif" rel="nofollow noreferrer" title="QR Customisation - optional"><img src="https://i.stack.imgur.com/VyzXZ.gif" alt="QR Customisation - optional" title="QR Customisation - optional" /></a></p> </li> </ol> <h3>Notes</h3> <ul> <li><strong>Raised</strong> and <strong>Cut-Out</strong> types are for changing filament at layer height</li> <li><strong>Multi-color</strong> and <strong>Code</strong> are to be used together for inlay/multi-color printers</li> <li>You can also set <em>Base Height</em> or <em>Code Height</em> to 0 and export each part on it's own</li> <li>If you want to print a <strong>double sided tag</strong>, you can set <em>Base Height</em> to 0 and export the second side. Then just flip this over in the slicer</li> <li>The text options are a okay for basic text, but if you want to use another program to add some, you can add extra height to the top/bottom of the card under <strong>Extra Size Setting</strong></li> </ul> <h3>Advanced Notes</h3> <ul> <li>There is some logic in the script that stop you from making the size too small if you have Line Size set, you can set Line Size to 0 or half your line size value if you really want to override this.</li> <li>You can change the Customize Design settings before generating the QR Code (on <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a>), but you'll need to set Line Size to 0 and there are no promises that it'll print well</li> <li>If you want to use a different site to create the QR code, resize the image to 1147x1147 pixels before converting it to an SVG. Or if the QR code in the image doesn't have a border, resize it to 1000x1000 px.</li> <li>If you want to use a different source for the SVG file, there are instructions for working out the size in the code (<a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a>) at line 215. You'll need to export it as a STL and measure it outside of OpenSCAD, then enter the values into the script.</li> </ul> </blockquote> <p>The linked to Thingiverse page also has some extra steps for adding an icon:</p> <blockquote> <h3>Add an icon</h3> <p>You can import another SVG file as a logo or use logo fonts.</p> <p>The below example uses an <a href="https://iconmonstr.com/?s=wifi" rel="nofollow noreferrer">wifi SVG file</a> from IconMonstr</p> <ul> <li>Download the wifi SVG file</li> <li>Place it in the same folder as the .SCAD file</li> <li>In the customizer: <ul> <li>Add some extra space to the top or bottom of the card under <strong>Extra Size Settings</strong></li> <li>Go to SVG Logo Settings</li> <li>Tick <strong>enable svg logo</strong></li> <li>Enter the filename under <strong>svg logo name</strong></li> <li>Set the <strong>svg y nudge</strong> position and <strong>svg logo scale</strong></li> </ul> </li> </ul> <p><a href="https://i.stack.imgur.com/A2xCK.png" rel="nofollow noreferrer" title="Adding Wi-Fi logo"><img src="https://i.stack.imgur.com/A2xCK.png" alt="Adding Wi-Fi logo" title="Adding Wi-Fi logo" /></a></p> </blockquote>
<p>From the excellent Thingiverse link, <a href="https://www.thingiverse.com/thing:4967931" rel="nofollow noreferrer">Customizable QR Keyring or Tag</a> by <a href="https://www.thingiverse.com/outwardb/designs" rel="nofollow noreferrer"><em>OutwardB</em></a> - which was provided in the (now deleted) <a href="https://3dprinting.stackexchange.com/a/18296/4762">link-only answer</a>:</p> <blockquote> <ol> <li><h3>Create the QR code</h3> <ul> <li><p>Go to <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a></p> </li> <li><p><strong>Only change the Content settings</strong></p> <p>DO NOT change the color, logo or design settings</p> </li> <li><p>Click <strong>Create QR Code</strong></p> </li> <li><p>Click <strong>Download PNG</strong> and wait for the file to download</p> </li> </ul> </li> <li><h3>Convert to SVG</h3> <ul> <li>Go to <a href="https://convertio.co/png-svg/" rel="nofollow noreferrer">PNG to SVG Converter</a> and convert the PNG image you just downloaded to a .SVG file</li> </ul> </li> <li><h3>Customise in OpenSCAD</h3> <p>You will need <a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a> from the <a href="https://www.thingiverse.com/thing:4967931/files" rel="nofollow noreferrer">files repository on Thingverse</a></p> <ol> <li><p>Download OpenSCAD from here and install it - <a href="https://openscad.org/downloads.html" rel="nofollow noreferrer">https://openscad.org/downloads.html</a></p> </li> <li><p>Put the downloaded SVG file in the same folder as the .SCAD file from this page</p> </li> <li><p>Double-click the .SCAD file to open it</p> </li> <li><p>Click <strong>Window</strong>, then untick <strong>Hide Customizer</strong></p> <p><em>Optional</em>: Click <strong>Window</strong>, then tick <strong>Hide Editor</strong></p> </li> <li><p>Enter the SVG file name in the basic settings tab (or rename the file to qr-code.svg before opening OpenSCAD)</p> </li> <li><p>Customize the settings. After changing a setting, you may need to click outside the text box to apply the change</p> </li> <li><p>Click <strong>Design</strong> &gt; <strong>Render</strong> and wait for the design to render</p> </li> <li><p>Click <strong>File</strong> &gt; <strong>Export</strong> &gt; <strong>Export to STL</strong></p> </li> <li><p>Save the file</p> </li> </ol> <p><a href="https://i.stack.imgur.com/VyzXZ.gif" rel="nofollow noreferrer" title="QR Customisation - optional"><img src="https://i.stack.imgur.com/VyzXZ.gif" alt="QR Customisation - optional" title="QR Customisation - optional" /></a></p> </li> </ol> <h3>Notes</h3> <ul> <li><strong>Raised</strong> and <strong>Cut-Out</strong> types are for changing filament at layer height</li> <li><strong>Multi-color</strong> and <strong>Code</strong> are to be used together for inlay/multi-color printers</li> <li>You can also set <em>Base Height</em> or <em>Code Height</em> to 0 and export each part on it's own</li> <li>If you want to print a <strong>double sided tag</strong>, you can set <em>Base Height</em> to 0 and export the second side. Then just flip this over in the slicer</li> <li>The text options are a okay for basic text, but if you want to use another program to add some, you can add extra height to the top/bottom of the card under <strong>Extra Size Setting</strong></li> </ul> <h3>Advanced Notes</h3> <ul> <li>There is some logic in the script that stop you from making the size too small if you have Line Size set, you can set Line Size to 0 or half your line size value if you really want to override this.</li> <li>You can change the Customize Design settings before generating the QR Code (on <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a>), but you'll need to set Line Size to 0 and there are no promises that it'll print well</li> <li>If you want to use a different site to create the QR code, resize the image to 1147x1147 pixels before converting it to an SVG. Or if the QR code in the image doesn't have a border, resize it to 1000x1000 px.</li> <li>If you want to use a different source for the SVG file, there are instructions for working out the size in the code (<a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a>) at line 215. You'll need to export it as a STL and measure it outside of OpenSCAD, then enter the values into the script.</li> </ul> </blockquote> <p>The linked to Thingiverse page also has some extra steps for adding an icon:</p> <blockquote> <h3>Add an icon</h3> <p>You can import another SVG file as a logo or use logo fonts.</p> <p>The below example uses an <a href="https://iconmonstr.com/?s=wifi" rel="nofollow noreferrer">wifi SVG file</a> from IconMonstr</p> <ul> <li>Download the wifi SVG file</li> <li>Place it in the same folder as the .SCAD file</li> <li>In the customizer: <ul> <li>Add some extra space to the top or bottom of the card under <strong>Extra Size Settings</strong></li> <li>Go to SVG Logo Settings</li> <li>Tick <strong>enable svg logo</strong></li> <li>Enter the filename under <strong>svg logo name</strong></li> <li>Set the <strong>svg y nudge</strong> position and <strong>svg logo scale</strong></li> </ul> </li> </ul> <p><a href="https://i.stack.imgur.com/A2xCK.png" rel="nofollow noreferrer" title="Adding Wi-Fi logo"><img src="https://i.stack.imgur.com/A2xCK.png" alt="Adding Wi-Fi logo" title="Adding Wi-Fi logo" /></a></p> </blockquote>
2,046
<p>I've just started writing unit tests for a legacy code module with large physical dependencies using the #include directive. I've been dealing with them a few ways that felt overly tedious (providing empty headers to break long #include dependency lists, and using #define to prevent classes from being compiled) and was looking for some better strategies for handling these problems.</p> <p>I've been frequently running into the problem of duplicating almost every header file with a blank version in order to separate the class I'm testing in it's entirety, and then writing substantial stub/mock/fake code for objects that will need to be replaced since they're now undefined.</p> <p>Anyone know some better practices?</p>
<p>The depression in the responses is overwhelming... But don't fear, we've got <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="noreferrer" rel="nofollow noreferrer">the holy book to exorcise the demons of legacy C++ code</a>. Seriously just buy the book if you are in line for more than a week of jousting with legacy C++ code.</p> <p>Turn to page 127: <strong>The case of the horrible include dependencies.</strong> (Now I am not even within miles of Michael Feathers but here as-short-as-I-could-manage answer..)</p> <p><strong>Problem</strong>: In C++ if a classA needs to know about ClassB, Class B's declaration is straight-lifted / textually included in the ClassA's source file. And since we programmers love to take it to the wrong extreme, a file can recursively include a zillion others transitively. Builds take years.. but hey atleast it builds.. we can wait. </p> <p>Now to say 'instantiating ClassA under a test harness is difficult' is an understatement. (Quoting MF's example - Scheduler is our poster problem child with deps galore.)</p> <pre><code>#include "TestHarness.h" #include "Scheduler.h" TEST(create, Scheduler) // your fave C++ test framework macro { Scheduler scheduler("fred"); } </code></pre> <p>This will bring out the includes dragon with a flurry of build errors.<br> <strong>Blow#1 Patience-n-Persistence</strong>: Take on each include one at a time and decide if we really need that dependency. Let's assume SchedulerDisplay is one of them, whose displayEntry method is called in Scheduler's ctor.<br> <strong>Blow#2 Fake-it-till-you-make-it</strong> (Thanks RonJ):</p> <pre><code>#include "TestHarness.h" #include "Scheduler.h" void SchedulerDisplay::displayEntry(const string&amp; entryDescription) {} TEST(create, Scheduler) { Scheduler scheduler("fred"); } </code></pre> <p>And pop goes the dependency and all its transitive includes. You can also reuse the Fake methods by encapsulating it in a Fakes.h file to be included in your test files.<br> <strong>Blow#3 Practice</strong>: It may not be always that simple.. but you get the idea. After the first few duels, the process of breaking deps will get easy-n-mechanical</p> <p><strong>Caveats</strong> (Did I mention there are caveats? :) </p> <ul> <li>We need a separate build for test cases in this file ; we can have only 1 definition for the SchedulerDisplay::displayEntry method in a program. So create a separate program for scheduler tests.</li> <li>We aren't breaking any dependencies in the program, so we are not making the code cleaner.</li> <li>You need to maintain those fakes as long as we need the tests.</li> <li>Your sense of aesthetics may be offended for a while.. just bite your lip and 'bear with us for a better tomorrow' </li> </ul> <p>Use this technique for a very huge class with severe dependency issues. Don't use often or lightly.. <strong>Use this as a starting point for deeper refactorings.</strong> Over time this testing program can be taken behind the barn as you extract more classes (WITH their own tests).</p> <p>For more.. please do read the book. Invaluable. Fight on bro!</p>
<p>If you keep writing stubs/mock/fake codes you risk doing unit testing on a class that has different behavior then when compiled on the main project.</p> <p>But if those includes are there and have no added behavior then it's Ok.</p> <p>I'd try not changing anything on the includes while doing the unit testing so you're sure (as far you can be on legacy code :) ) that you testing the real code.</p>
9,080
<p>I would like to turn the HTML generated by my CFM page into a PDF, and have the user prompted with the standard "Save As" prompt when navigating to my page.</p>
<p>You should use the cfdocument tag (with format="PDF") to generate the PDF by placing it around the page you are generating. You'll want to specify a filename attribute, otherwise the document will just stream right to your browser.</p> <p>After you have saved the content as a PDF, use cfheader and cfcontent in combination to output the PDF as an attachment ("Save As") and add the file to the response stream. I also added deletefile="Yes" on the cfcontent tag to keep the file system clean of the files.</p> <pre><code>&lt;cfdocument format="PDF" filename="file.pdf" overwrite="Yes"&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Hello World&lt;/title&gt; &lt;/head&gt; &lt;body&gt; Hello World &lt;/body&gt; &lt;/html&gt; &lt;/cfdocument&gt; &lt;cfheader name="Content-Disposition" value="attachment;filename=file.pdf"&gt; &lt;cfcontent type="application/octet-stream" file="#expandPath('.')#\file.pdf" deletefile="Yes"&gt; </code></pre> <p>As an aside: I'm just using file.pdf for the filename in the example below, but you might want to use some random or session generated string for the filename to avoid problems resulting from race conditions.</p>
<p>I'm not that familiar with ColdFusion, but what you need to do is set the Content-Type of the page when the user requests it to be application/octet-stream. This will prompt them for a download every time. </p> <p>Hope this helps!</p>
9,969
<p>Any one know decent way to reference a SQLite database using the above mentioned tools? I tried using ODBC (the SQLite driver) but while the connection is good, I get no data returned. Like I can't see any tables in Data Connection (VS 2008). Is there a better way?</p> <p><em>Edit: corrected typos</em></p>
<p>Joel Lucsy: That implementation of SQLite is a mixed-mode assembly which is not supported by Silverlight. Only a pure managed implementation would work under the Silverlight CLR.</p>
<p>You should give <a href="http://siaqodb.com/" rel="nofollow">Siaqodb</a> a try. I haven't tested it but they mention that is works with Silverlight OOB apps and even give you a tutorial <a href="http://siaqodb.com/?p=174" rel="nofollow">here</a>.<br> It's commercial software, but a 30 day trial is available.</p>
2,570
<p>I'm trying to read binary data using C#. I have all the information about the layout of the data in the files I want to read. I'm able to read the data "chunk by chunk", i.e. getting the first 40 bytes of data converting it to a string, get the next 40 bytes.</p> <p>Since there are at least three slightly different version of the data, I would like to read the data directly into a struct. It just feels so much more right than by reading it "line by line".</p> <p><strong>I have tried the following approach but to no avail:</strong></p> <pre><code>StructType aStruct; int count = Marshal.SizeOf(typeof(StructType)); byte[] readBuffer = new byte[count]; BinaryReader reader = new BinaryReader(stream); readBuffer = reader.ReadBytes(count); GCHandle handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned); aStruct = (StructType) Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(StructType)); handle.Free(); </code></pre> <p>The stream is an opened FileStream from which I have began to read from. I get an <code>AccessViolationExceptio</code>n when using <code>Marshal.PtrToStructure</code>.</p> <p>The stream contains more information than I'm trying to read since I'm not interested in data at the end of the file.</p> <p><strong>The struct is defined like:</strong></p> <pre><code>[StructLayout(LayoutKind.Explicit)] struct StructType { [FieldOffset(0)] public string FileDate; [FieldOffset(8)] public string FileTime; [FieldOffset(16)] public int Id1; [FieldOffset(20)] public string Id2; } </code></pre> <p>The examples code is changed from original to make this question shorter.</p> <p>How would I read binary data from a file into a struct?</p>
<p>The problem is the <strong>string</strong>s in your struct. I found that marshaling types like byte/short/int is not a problem; but when you need to marshal into a complex type such as a string, you need your struct to explicitly mimic an unmanaged type. You can do this with the MarshalAs attrib.</p> <p>For your example, the following should work:</p> <pre><code>[StructLayout(LayoutKind.Explicit)] struct StructType { [FieldOffset(0)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] public string FileDate; [FieldOffset(8)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] public string FileTime; [FieldOffset(16)] public int Id1; [FieldOffset(20)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 66)] //Or however long Id2 is. public string Id2; } </code></pre>
<p>Try this:</p> <pre><code>using (FileStream stream = new FileStream(fileName, FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); StructType aStruct = (StructType)formatter.Deserialize(filestream); } </code></pre>
2,452
<p>From my understanding, the power of heater must higher than heat dissipate to ambient air so the bed can heat up. The reason why a bed heats up too slowly is due to its heat capacity compared to heater power.</p> <p>As the heater is a resistive load, I think we can put higher voltage to get more heating power.</p> <p>The PCB heater has two parts: copper and laminate. The reason of failure is that the copper can come off the board due to high temperatures. In this case we can control temperature with firmware. The questions are:</p> <ol> <li>Will this method work?</li> <li>What can go wrong or what is the risk of this method?</li> </ol>
<p>Yes, this method will work. Some (LED) power supplies have a small potentiometer that you can use to slightly adjust the voltage. On a 12 V printer, adjusting the supply from 12 V to 14 V will give a 36% increase in power.</p> <p>Obviously there is a limit to how much you can increase the voltage. The voltage itself is unlikely to be the limiting factor, but there is a limit to how much heat the bed can dissipate.</p> <blockquote> <p>The PCB heater have 2-part copper and laminate. the reason of failire is the copper go off the board due to high temperature. In this case we can control temperature with firmware.</p> </blockquote> <p>This is true, but you have to consider that firmware is not infallible. If you increase the voltage (and thus wattage) of the bed a lot, you risk creating a dangerous situation if something fails. Ideally, you should choose the wattage of the bed such that it does not create a dangerous situation even if it is left on permanently by accident. In extreme cases (e.g. 220V to a nominally 12V heated bed) damage will be almost instantaneous before the firmware can intervene.</p> <p>You also have to consider that increasing the voltage also increases the current. The wires need to be thick enough to handle the additional current. You also have to pay special attention to the MOSFET that is used to switch the bed; it also needs to be able to handle the current (and voltage, though this is usually less of a problem). Usually the integrated MOSFETs on 3D printer control boards can only handle about ~10 A which is what the bed might normally draw. Also pay attention to fuses and to screw terminal connections. They might not be able to handle the increased current either.</p>
<h1>Not necessarily</h1> <p><strong>Potential differential U</strong>, aka <em>Voltage</em> of a part, is not to be ignored: a 24 V part needs only 24 V, not 36 V. A 12 V heartbeat is only safe for 12 V. There is a little tolerance for those measurements, but rule of thumb is about 10-15% of the rated voltage, so a 12 V bed should not be operated at more than 13.8 V for an extended period.</p> <p>What actually facilitates heating is the <strong>Current I</strong> aka <em>Amperage</em> going through an item, as the formula for the Work P<sub>h</sub> (dissipated in the shape of heat) of the electric resistance R is <span class="math-container">$P_h=R I^2$</span>.</p> <p>As long as you stay below or at the maximum <strong>rated Power P<sub>r</sub></strong> or <em>Wattage</em> of the heating pad <span class="math-container">$P_r=U I$</span>, you can increase the Current up to the limit of <span class="math-container">$\frac {P_r} U=I$</span>. On the bench, with a regulated power supply, we can use that to get a perfect, maximum output as we want it. But the printer isn't a bench with an expensive PSU, we get only something akin to 12 V out of it, so... what to do?</p> <h2>DON'T route in extra Power!</h2> <p>Yea, in DC circuits we can just add batteries behind one another to get twice the Voltage and push a circuit. Or we can put them in parallel, to sum up the current. But that doesn't work just as straightforward in AC circuits (phase shift between parts has to be taken into account). And routing in an extra pair of wires providing 12 V into an already 12 V part would get us something in the order of 24 V and fry the part. You'd accomplish nothing more than turn your heated bed into a fire hazard or a hunk of scrap!</p> <p>So straight routing in another 12 V on top of what is rated? <strong>NOPE!</strong></p> <h2>Unhooking from the same PSU?</h2> <p>Some printers unhook the bed from the board's PSU, running a (differently) regulated power source. In the best case, it's set up to a Voltage/Current pair that maximizes the bed's heating. In such a setup, the whole heating power runs through a MOSFET that acts as a switch: A signal comes from the board to the MOSFET to allow current to flow. No signal on the Gate of the MOSFET leads to no current reaching the bed and no heating.</p> <p>However, that is a complicated setup - yet one of the only ways how a &quot;mains voltage bed heater&quot; can be done with a board that runs on 5 V. You <em>also</em> will have to route the high power through a properly rated set of wires and connectors. These thicker wires will need proper strain relief as they need larger bending radii than what is installed before. In other words: <strong>you need to know what you do!</strong></p> <h2>Finetuning the power supply to the bed!</h2> <p>In many printers, there's also a less invasive method to finetune the power curve of a bed. usually, there is a Potentiometer that is used to tune the output of the heating wires. Altering the potentiometer's setting with a screwdriver results in the output voltage shifting. <span class="math-container">$U=R I$</span> does not change when flipping to AC but U and I became wave functions instead of constants. However, R of a long wire (such as a bed) does depend only on the frequency of the signal and not on either the current nor the driving potential, we can assume R to be constant. So, we know we want to maximize I². So what can we do easily?</p> <p>A 24 V heatbed has something in the order of 2 Ω and accompanied mainboard in my Ender3 is - according to the labeling - good for about 13 A on the bed output, while a typical 12 V bed runs in the order of 1.2 Ω while such boards typically are limited to 10-11 A. <span class="math-container">$U= RI$</span> to the resuce and... Voila: For the 11 A/1.2 Ω case we can tune the potentiometer to get just a smidge below 13.2 V - just at the 10 % point, for the 13 A/2 Ω case is <em>technically</em> safe at 26 V - and still well within the 10% rule of thumb. However, if you have a 1.2 Ω bed and your borard only allows to draw 10 A, then you are limited to 12 V.</p>
1,824
<p>I have done a bit of research into this and it seems that the only way to sort a data bound combo box is to sort the data source itself (a DataTable in a DataSet in this case). </p> <p>If that is the case then the question becomes what is the best way to sort a DataTable?</p> <p>The combo box bindings are set in the designer initialize using</p> <p><pre><code>myCombo.DataSource = this.typedDataSet; myCombo.DataMember = "Table1"; myCombo.DisplayMember = "ColumnB"; myCombo.ValueMember = "ColumnA";</pre></code></p> <p>I have tried setting <pre><code>this.typedDataSet.Table1.DefaultView.Sort = "ColumnB DESC";</pre></code> But that makes no difference, I have tried setting this in the control constructor, before and after a typedDataSet.Merge call.</p>
<p>If you're using a DataTable, you can use the (DataTable.DefaultView) <a href="http://msdn.microsoft.com/en-us/library/system.data.dataview.sort.aspx" rel="nofollow noreferrer">DataView.Sort</a> property. For greater flexibility you can use the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx" rel="nofollow noreferrer">BindingSource</a> component. BindingSource will be the DataSource of your combobox. Then you can change your data source from a DataTable to List without changing the DataSource of the combobox.</p> <blockquote> <p>The BindingSource component serves many purposes. First, it simplifies binding controls on a form to data by providing currency management, change notification, and other services between Windows Forms controls and data sources.</p> </blockquote>
<p>Does the data need to be in a DataTable? Using a SortedList and binding that to a combo box would be a simpler way.</p> <p>If you need to use a DataTable you can use the Select method to retrieve a DataView and pass in a sort parameter.</p> <pre><code>DataView dv = myDataTable.Select("filter expression", "sort"); </code></pre>
4,947
<p>What's the proper way to convert from a scientific notation string such as "1.234567E-06" to a floating point variable using C#?</p>
<pre><code>Double.Parse("1.234567E-06", System.Globalization.NumberStyles.Float); </code></pre>
<p>Also consider using</p> <pre><code>Double.TryParse("1.234567E-06", System.Globalization.NumberStyles.Float, out MyFloat); </code></pre> <p>This will ensure that <code>MyFloat</code> is set to value 0 if, for whatever reason, the conversion could not be performed. Or you could wrap the <code>Double.Parse()</code> example in a <code>Try..Catch</code> block and set <code>MyFloat</code> to a value of your choosing when an exception is detected.</p>
9,022
<p>I want to use the MultipleLookupField control in a web page that will run in the context of SharePoint. I was wondering if anyone would help me with an example, which shows step by step how to use the control two display two SPField Collections.</p>
<p>I'm not entirely sure I understand your question, especially the bit about displaying two SPField collections. Sorry if this turns out to be the answer to a completely different question!</p> <p>Anyway here's a quick demo walkthrough of using the MultipleLookupField in a web part.</p> <p>Create a team site. Add a few tasks to the task list. Also put a document in the Shared Documents library. Create a new column in the Shared Documents library; call it "Related", have it be a Lookup into the Title field of the Tasks list, and allow multiple values.</p> <p>Now create a web part, do all the usual boilerplate and then add this:</p> <pre><code>Label l; MultipleLookupField mlf; protected override void CreateChildControls() { base.CreateChildControls(); SPList list = SPContext.Current.Web.Lists["Shared Documents"]; if (list != null &amp;&amp; list.Items.Count &gt; 0) { LiteralControl lit = new LiteralControl("Associate tasks to " + list.Items[0].Name); this.Controls.Add(lit); mlf = new MultipleLookupField(); mlf.ControlMode = SPControlMode.Edit; mlf.FieldName = "Related"; mlf.ItemId = list.Items[0].ID; mlf.ListId = list.ID; mlf.ID = "Related"; this.Controls.Add(mlf); Button b = new Button(); b.Text = "Change"; b.Click += new EventHandler(bClick); this.Controls.Add(b); l = new Label(); this.Controls.Add(l); } } void bClick(object sender, EventArgs e) { l.Text = ""; foreach (SPFieldLookupValue val in (SPFieldLookupValueCollection)mlf.Value) { l.Text += val.LookupValue.ToString() + " "; } SPListItem listitem = mlf.List.Items[0]; listitem["Related"] = mlf.Value; listitem.Update(); mlf.Value = listitem["Related"]; } protected override void OnInit(EventArgs e) { base.OnInit(e); EnsureChildControls(); } </code></pre> <p>Granted, this is borderline ridiculous -- everything is hard-coded, there is no error-handling at all, and it serves no useful purpose -- but it's only meant as a quick demo. Now build and deploy this web part and add an instance of it to your team site's homepage; it should allow you to get and set the tasks which are associated with the first document in the library.</p> <p>The strange bit towards the end of the button Click handler, where we read a value from mlf.Value and then write it back again, appears to be required if you want the UI to stay in sync with the actual list values. Try omitting the last line of bClick to see what I mean. This has been driving me nuts for the last hour or so, and I'm hoping another commenter can come up with a better approach...</p>
<p>Hm. Works fine on mine, so let's see if we can work out how your setup is different...</p> <p>It looks as though it's having trouble populating the control; my first guess would be that this is because the code makes so many assumptions about the lists it's talking to. Can you check that you've got a plain vanilla Team site, with (assume these names are case-sensitive): </p> <ol> <li>A list called Tasks, with several items in it</li> <li>A library called Shared Documents with at least one document</li> <li>A column called Related in the Shared Documents library</li> <li>The Related column is a Lookup field into the Title column of Tasks, and allows multiple values.</li> <li>The first document in Shared Documents has a value for Related</li> </ol> <p>Then add the webpart. Fingers crossed...</p>
6,107
<p>Is anyone successfully using the latest 64-bit Ganymede release of Eclipse on Windows XP or Vista 64-bit?</p> <p>Currently I run the normal Eclipse 3.4 distribution on a 32bit JDK and launch &amp; compile my apps with a 64bit JDK. Our previous experience has been that the 64bit Eclipse distro is unstable for us, so I'm curious if anyone is using it successfully.</p> <p>We are using JDK 1.6.0_05.</p>
<p>I'm using Eclipse with a 64bit VM. However I have to use Java 1.5, because with Java 1.6, even 1.6.0_10ea, Eclipse crashed when changing the .classpath-file. On Linux I had the same problems and could only get the 64bit Eclipse to work with 64bit Java 1.5.</p> <p>The problem seems to be with the just in time compilation, since with vmparam -Xint eclipse works -- but this is not a sollution, because it's slow then.</p> <p><strong>Edit:</strong></p> <p>With 1.6.0_11 it seems to work. </p> <p>1.6_10 final might work as well as mentioned in the comment, but I've not tested that.</p>
<p>I've been successfully using it on Vista x64 for some light Java work. Nothing too involved and no extra plugins, but basic Java coding has been working without any issues. I'm using the 3.4M7 build but it looks like the <a href="http://download.eclipse.org/eclipse/downloads/drops/R-3.4-200806172000/index.php" rel="nofollow noreferrer">3.4 stable build</a> supports Vista x64 now.</p>
2,804
<p>I know it is a good idea to store configuration data in app.config (e.g. database connection strings) instead of hardcoing it, even if I am writing an application just for myself. But is there a way to update the configuration data stored in app.config from the program that is using it?</p>
<p>If you use the Settings for the project, you can mark each setting as either application or user.</p> <p>If they're set as user, they will be stored per-user and when you call the Save method it will be updated in the config for that user.</p> <p>Code project has a really detailed <a href="http://www.codeproject.com/KB/dotnet/user_settings.aspx" rel="nofollow noreferrer">article</a> on saving all types of settings.</p>
<p>app.config isn't what you want to use for user-tweakable data, as it'll be stored somewhere in Program Files (which the user shouldn't have write permissions to). Instead, settings marked with <code>a UserScopedSettingAttribute</code> will end up in a user-scoped .config file somewhere in %LocalAppData%.</p> <p>I found the best way to learn this stuff was to mess with the Visual Studio "Settings" tab (on your project's property pages), then look at the code that it generates and look in %LocalAppData% to see the file that it generates.</p>
5,698
<p>My work has a financial application, written in <code>VB.NET</code> with <code>SQL</code>, that several users can be working on at the same time.</p> <p>At some point, one user might decide to Post the batch of entries that they (and possibly other people) are currently working on.</p> <p>Obviously, I no longer want any other users to <strong>add</strong>, <strong>edit</strong>, or <strong>delete</strong> entries in that batch <strong>after</strong> the <strong>Post process</strong> has been initiated.</p> <p>I have already seen that I can lock <strong>all</strong> data by opening the SQL transaction the moment the Post process starts, but the process can be fairly lengthy and I would prefer not to have the Transaction open for the several minutes it might take to complete the function.</p> <p>Is there a way to lock just the records that I know need to be operated on from VB.NET code?</p>
<p>If you are using Oracle you would <strong>Select for update</strong> on the rows you are locking.</p> <p>here is an example</p> <pre><code>SELECT address1 , city, country FROM location FOR UPDATE; </code></pre>
<p>add </p> <pre><code>with (rowlock) </code></pre> <p>to your SQL query</p> <p><a href="http://www.sql-server-performance.com/articles/per/lock_contention_nolock_rowlock_p1.aspx" rel="nofollow noreferrer">SQL Server Performance article</a></p> <p><strong>EDIT:</strong> ok, I misunderstood the question. What you want is transaction isolation. +1 to Joel :) </p>
6,808
<p>Ok so I am trying to print a new fusion 360 file that I converted into an STL and then into gcode using cura and I got the gcode loaded onto the SD card and mounted into my Monoprice 3D printer, Maker Select 3D Printer v2, and tried to do a print. Now here is the strange part. When I choose "print file" and then select a gcode to print it takes me back to the main screen and from there the 3D printers screen displays "Printing...0%" for a few seconds. After this it just goes back to displaying "Stepper Disabled." And if it is not stepper disabled it is just a blank screen. I tried to mount and print multiple gcodes just to make sure that it was not the softwares fault and low and behold I was running into the same issue. </p> <p>Now before using today all of the gcode was printing just fine, however for some reason today it decided to give me this issue. </p>
<p>Wash-away filament used for support in PLA printing is typically PVA, which is completely water soluble and may serve your purpose. It is easily 3D printed as the primary filament and attaches well to the build plate.</p> <p>Many 3D printer filament suppliers will carry this type of support material. It is important to keep it in a sealed bag with desiccant as it will absorb moisture from the air, rendering it useless for printing.</p> <p>One such resource is <a href="https://www.matterhackers.com/store/l/175mm-pva-filament-half-kg/sk/M4MJTECR" rel="nofollow noreferrer">MatterHackers</a> which prices a half-kilogram at US$45. The link provides suitably appropriate information:</p> <blockquote> <p>PVA (Polyvinyl Alcohol) is a water-soluble material that is often used as a support material, but can also be used to print independently. PVA supports are useful for complex designs where removing support material manually is difficult or impossible, but leaving the part in a water bath overnight will completely dissolve this material.</p> </blockquote> <p><a href="https://i.stack.imgur.com/2ytSy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2ytSy.png" alt="PVA filament"></a></p>
<p>ABS dissolves in acetone. Indeed actone can be used to clean up 3D prints, see <a href="https://3dprinting.stackexchange.com/questions/4235/whats-smoother-acetone-treated-pla-or-abs/">What&#39;s smoother? Acetone treated PLA or ABS</a>. PLA maybe not somuch as ABS, see the same post.</p> <p>PLA dissolves in any chlorinated or fluorinated solvent, such as THF or Chloroform - both of which are significantly more hazardous than acetone.</p> <p>Hence, as always <strong>take care</strong> when using solvents, see <a href="https://3dprinting.stackexchange.com/questions/81/safety-precautions-when-using-acetone/278#278">Safety precautions when using acetone</a></p> <p>Also, as filaments are often not pure ABS or PLA, due to additives and dyes, etc., then the solvent may not dissolve the 3D printed part <em>completely</em>, and you may be left with a deformed, rubbery residue.</p>
911
<p>Whenever I try putting the filament through the nozzle it does not go through. I have searched everywhere online and have found nothing.</p>
<p>Many printers have a problem with inserting filament into the extruder. Cutting it at an angle is a huge help. It is also very possible that you have a cog or a bad extruder nozzle. </p> <p>This link could be of some help: <a href="https://www.thingiverse.com/groups/prusa-i3/topic:7469" rel="nofollow noreferrer">Extruder is not feeding</a>.</p>
<p>My first step would be to cut the filament at a bit of an angle. This will help the filament enter the extruder correctly. </p> <p>If you're still having trouble, you may have a clogged nozzle. This article by Lifewire -<a href="https://www.lifewire.com/3d-printer-extruder-nozzle-clogged-2289" rel="nofollow noreferrer">3D Printer Extruder Nozzle Clogged? Here Is How To Unclog It</a> has some good info.</p> <p>I've also heard stories about the Bowden Tube (the PTFE tube that guides the filament from the extruder to the hotend) becoming warped or melted in cases where the printer's temperature control went awry. This is rare as PTFE doesn't melt until 320°C. </p>
570
<p>Typically in Arduinos, most of the 5&nbsp;V outputs that have a limited amount of current (40&nbsp;mA). </p> <p>Are there any 3D printer boards, or is there even a more usual spot, where you can get a 5&nbsp;V output that isn't capped by the microcontroller?</p> <p>I know that USB 2.0 is (typically) limited to 500&nbsp;mA especally when connected to a laptop. Just wondering if there was a way to for e.g. get a 200&nbsp;mA output from one of the 5&nbsp;V pins, or more if there is a stronger power supply connected to the USB port. </p>
<p>Any pin that is labeled as "5&nbsp;V" can supply the full amount of current. Looking at, for example, the <a href="http://domoticx.com/wp-content/uploads/2016/05/Arduino-MEGA-pinout.jpg" rel="nofollow noreferrer">Arduino MEGA pinout</a>, we can see several pins labeled in red with "5&nbsp;V". These are the pins you can use. Most 3D printer boards will expose the 5&nbsp;V pins at several points. For example, the endstop connectors often have a 5&nbsp;V pin that can be used.</p> <p>The pins that are limited to 40&nbsp;mA that you are thinking of are the digital pins, i.e. the pins that can be switched on/off by the microcontroller. These are actually more limited than this, and while in some cases drawing 40&nbsp;mA from them may be possible, it is not a good idea.</p>
<p>Any 5&nbsp;V "output" on those main boards would be used to power a USB host. This is because the electronics actually runs on 3.3 volts. It would be better to splice the input power (the 12 to 24&nbsp;V) and use a buck converter to get down to your required 5&nbsp;V. Select the right one, and you can have all the current you need. </p>
1,671
<p>I've created a little enclosure for a project in sketchup <a href="https://i.stack.imgur.com/m8AB9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8AB9.png" alt="enter image description here" /></a></p> <p>I then exported the .STL</p> <p>When I open it in Creality slicer 4.8 or Cura 5.0 It looks like this <a href="https://i.stack.imgur.com/uD4eb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uD4eb.png" alt="enter image description here" /></a></p> <p>I thought that the red was &quot;overhang that needs support&quot; (but can also mean a shell?)</p> <p>Hoever, that's not the irritating part. That would be the grey in the middle where the &quot;hole&quot; should be.</p> <p>When I slice it, it looks like this: <a href="https://i.stack.imgur.com/ew0yy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ew0yy.png" alt="enter image description here" /></a></p> <p>I didn't notice this before I started printing and 4 hours into the print I noticed that it was just completely ignoring the window and was considering it as a part of the base.</p> <p>Why is it doing this and how can I fix it?</p> <p>I've tried editing the original sketchup model a number of times, but I keep getting the same result.</p> <p>I read the question and answer at <a href="https://3dprinting.stackexchange.com/questions/5068/empty-space-in-model-is-getting-filled">Empty space in model is getting filled</a> but I'm not 100% sure that this is the solution I'm looking for.</p> <p>The slicer, knows enough to see that the hole should be there, as it is rendering in a shaded area. It feels like there is a setting or some such that is &quot;print the shaded area&quot; with a checkbox (on or off) - and if that setting is there, someone please tell me where to find it!</p> <p>I've also tried importing the STL into other programs (like fusion 360) and RE-exporting the STL, but the issue persists.</p> <hr /> <p><em>Please note that <a href="https://3dprinting.stackexchange.com/questions/13352/sketchup-designed-block-with-hole-printed-solid-in-cura">this question</a> seems to be similar to mine, however, there isn't an accepted answer. The one provided below is actually a much better answer.</em></p>
<p>PLA doesn't need a raft.</p> <p>Try printing without a raft. If you print with a raft because of adhesion problems, solve those first. A raft is only needed for filaments that shrink a lot and/or are printing at very high temperatures.</p> <p>If you want a raft, check the distance between raft and print object and know that a raft never gives a smooth bottom. This is because in order to prevent fusion of the print object to the raft a distance between the raft and the print object is accounted for. A property that controls the distance between the raft and the print object is called <code>Raft Air Gap</code> in Ultimaker Cura. Default for my setup this is 0.3 mm which I find rather large.</p> <p>For example (not raft, but support with a solid top layer, which is quite similar to a raft), I have used support structures with a roof to support large flat overhanging areas that where printed at 0.2 mm distance, this gave relatively good surface quality and barely no fusion to the print.</p>
<p>In Cura, you can indeed set the height of the first layer separate from the subsequent layers. So if the first layer is printing nicely, that's a good sign. That's usually the place prints fail. There are a few settings, but here are a few things to just double check:</p> <ul> <li>Is your nozzle set to the right size</li> <li>Is your raft layer height and regular layer height wildly different? Try setting them to the same, or if same, try making them different. There may be a 'raft top thickness' that's wrong for the nozzle size, (try 0.2 for a 0.4 mm nozzle)</li> <li>Layer height of your regular layers should be no greater than 80% of the nozzle width</li> <li>Print cooling (on), but initial fan speed (0)</li> <li>Supports: try printing with, or without. Look at Enable Support Interface (or disable it)</li> <li>Try just disabling your raft and see if it gets past the danger point. that will indicate if there's something misaligned with your Z.</li> <li>Check your axis rollers too! from this question, <a href="https://3dprinting.stackexchange.com/q/8022/4762">First 3 mm prints poorly, then fine after that</a></li> </ul>
2,177
<p>What's the most efficient way to convert the output of this function from a varbinary() to a a varchar()?</p>
<p>How about this:</p> <pre><code>master.sys.fn_varbintohexstr(@binvalue) </code></pre>
<p>CONVERT(varchar, @binary)</p>
9,909
<p>I'd like to mirror a triangular prism I made. However, whenever I select it I am only able to select the faces or sides.</p> <p>Is there a way to select the whole 3D object to move or mirror it?</p>
<p>Yes, there is a "select" tool in the toolbar next to "make". You can use select filters to select components, bodies and faces.</p>
<p>Selecting the body in the browser will select the entire body. Clicking on the body in the viewer will only get you faces or edges. </p> <p>A long click (click and hold) on the model will give you options on what to select. You can choose a face or body under "Depth" or choose a body or feature under "Parents." </p>
815
<p>I'm a 3D printing newbie, and I bought some Hatchbox PLA to start with since it is recommended by the community it seems. </p> <p>Is there really a steep quality drop off if you go for brands that are 50% less than Hatchbox? What does that quality drop off look like?</p>
<p>In addition to @TecTec3's answer:</p> <h3>Parameters that define filament quality:</h3> <ul> <li>Diameter variance: If there is too much fluctuation in diameter, the filament might get stuck.</li> <li>Material Quality: I had really expensive filament that was brittle and did tend to snap when it was extruded. Other filament just didn't melt but started burning up and regulary clogging my extruder.</li> </ul> <h3>My opinion:</h3> <p>I'd say you shouldn't go with too cheap filament and stick with one that works out best for you. If you have issues try another brand. It's impossible to tell quality just from the price.</p>
<p>There is no massive difference in print quality of PLA filaments unless you start going under 10 dollars US for a 1 kilo spool. The filament that I use is yoyi PLA that can be found on Amazon for about 20 bucks, this filament works really nice with my printer and it is fairly cheap. Just make sure you never use the hobby king brand PLS as the quality on that truly is horrendous.</p>
695
<p>We've been trying to alter a lot of columns from nullable to not nullable, which involves dropping all the associated objects, making the change, and recreating the associated objects.</p> <p>We've been using SQL Compare to generate the scripts, but I noticed that SQL Compare doesn't script statistic objects. Does this mean its ok to drop them and the database will work as well as it did before without them, or have Red Gate missed a trick?</p>
<p>It is considered best practice to auto create and auto update statistics. Sql Server will create them if it needs them. You will often see the tuning wizard generate lots of these, and you will also see people advise that you update statistics as a part of your maintenance plan, but this is not necessary and might actually make things worse, just so long as auto create and auto update are enabled.</p>
<p>Statistics are too data-specific to be tooled. It would be potentially very inefficient to blindly re-create them on a data set.</p>
4,078
<p>I have an L6 phone from motorola, a usb cable to connect it to my computer, and the Tools for Phones software so I can do things like upload my own custom ringtones or download pictures from the phone's camera.</p> <p>I have some ideas for programs I'd like to run on the phone, and it supports java, but I don't see anything in the software that I have for uploading them. Even if they did, I wouldn't know where to get started.</p> <p>Does anyone have any info on how to get started building apps for this or similar phones?</p>
<p>I've never used Morotolla's SDK but from my limited work in JME the real hook in the 3rd party tools are the emulators. Setting up a JME dev environment quickly is something that Sun got surprisingly right. Just get NetBeans with the JME pack and there is a regular emulator right in the IDE, and then you can hook in other proprietary emulators such as those from Motorolla.</p> <p>Not sure what kind of apps you are looking to do, but if you're interested in games I thought <a href="https://rads.stackoverflow.com/amzn/click/com/0672326655" rel="nofollow noreferrer" rel="nofollow noreferrer">Beginning Mobile Phone Game Programming</a> was a great starting point: </p>
<p>Yeah, the act of asking the question pointed me in the direction of an answer, and I found this:<br> <a href="https://developer.motorola.com/docstools/motodevstudio/" rel="nofollow noreferrer">https://developer.motorola.com/docstools/motodevstudio/</a><br> I could still use some pointers from someone of what to expect if anyone has done this before.</p>
7,595
<p>I am trying to apply styles to HTML tags dynamically by reading in the value of certain HTML attributes and applying a class name based on their values. For instance, if I have:</p> <pre><code>&lt;p height="30"&gt; </code></pre> <p>I want to apply a <code>class="h30"</code> to that paragraph so that I can style it in my style sheet. I can't find any information on getting the value of an attribute that is not an <code>id</code> or <code>class</code>. Help?</p>
<p>I would highly recommend using something like jquery where adding classes is trivial:</p> <pre><code>$("#someId").addClass("newClass"); </code></pre> <p>so in your case:</p> <pre><code>$("p[height='30']").addClass("h30"); </code></pre> <p>so this selects all paragraph tags where the height attribute is 30 and adds the class h30 to it.</p>
<p>Attributes are just properties (usually). So just try:</p> <pre><code>for (e in ...) { if (e.height == 30) { e.className = "h30"; } } </code></pre> <p>Or use something like jquery to simplify this kind of stuff.</p>
7,693
<p>Since debate without meaningful terms is <a href="https://stackoverflow.com/questions/24270/whats-the-point-of-oop">meaningless</a>, I figured I would point at the elephant in the room and ask: What exactly makes a language "object-oriented"? I'm not looking for a textbook answer here, but one based on your experiences with OO languages that work well in your domain, whatever it may be.</p> <p>A related question that might help to answer first is: What is the archetype of object-oriented languages and why?</p>
<p><a href="http://C2.Com/cgi/wiki?DefinitionsForOo" rel="noreferrer" title="Definitions for OO on Ward&#39;s WikiWikiWeb">Definitions for Object-Orientation</a> are of course a <a href="http://C2.Com/cgi/wiki?OoBestFeatures" rel="noreferrer" title="OO Best Features on Ward&#39;s WikiWikiWeb">huge can of worms</a>, but here are my 2 cents:</p> <p>To me, Object-Orientation is all about objects that collaborate by sending messages. That is, to me, the single most important trait of an object-oriented language.</p> <p>If I had to put up an ordered list of all the features that an object-oriented language must have, it would look like this:</p> <ol> <li><a href="http://C2.com/cgi/wiki?MessagePassing" rel="noreferrer" title="Message Passing on Ward&#39;s WikiWikiWeb">Objects sending messages to other objects</a></li> <li>Everything is an Object</li> <li><a href="http://C2.Com/cgi/wiki?LateBinding" rel="noreferrer" title="Late Binding on Ward&#39;s WikiWikiWeb">Late Binding</a></li> <li><a href="http://C2.Com/cgi/wiki?PolyMorphism" rel="noreferrer" title="Polymorphism on Ward&#39;s WikiWikiWeb">Subtype Polymorphism</a></li> <li>Inheritance or something similarly expressive, like <a href="http://C2.Com/cgi/wiki?DelegationInheritance" rel="noreferrer" title="Delegation Inheritance on Ward&#39;s WikiWikiWeb">Delegation</a></li> <li><a href="http://C2.com/cgi/wiki?EncapsulationDefinition" rel="noreferrer" title="Encapsulation Definition on Ward&#39;s WikiWikiWeb">Encapsulation</a></li> <li><a href="http://C2.com/cgi/wiki?InformationHiding" rel="noreferrer" title="Information Hiding on Ward&#39;s WikiWikiWeb">Information Hiding</a></li> <li>Abstraction</li> </ol> <p>Obviously, this list is very controversial, since it excludes a great variety of languages that are widely regarded as object-oriented, such as <a href="http://Java.Com/" rel="noreferrer" title="Java Programming Language">Java</a>, <a href="http://MSDN.Microsoft.Com/vcsharp/" rel="noreferrer" title="C# Programming Language">C#</a> and <a href="http://Open-Std.Org/jtc1/sc22/wg21/" rel="noreferrer" title="C++ Programming Language">C++</a>, all of which violate points 1, 2 and 3. However, there is no doubt that those languages allow for object-oriented programming (but so does <a href="http://Open-Std.Org/jtc1/sc22/wg14/" rel="noreferrer" title="C Programming Language">C</a>) and even facilitate it (which C doesn't). So, I have come to call languages that satisfy those requirements "purely object-oriented".</p> <p>As archetypical object-oriented languages I would name <a href="http://Research.Sun.Com/self/" rel="noreferrer" title="Self Homepage at Sun Research">Self</a> and <a href="http://NewspeakLanguage.Org/" rel="noreferrer" title="Newspeak Programming Language">Newspeak</a>.</p> <p>Both satisfy the above-mentioned requirements. Both are inspired by and successors to <a href="http://Smalltalk.Org/" rel="noreferrer" title="Smalltalk Programming Language">Smalltalk</a>, and both actually manage to be "more OO" in some sense. The things that I like about Self and Newspeak are that both take the message sending paradigm to the extreme (Newspeak even more so than Self).</p> <p>In Newspeak, <em>everything</em> is a message send. There are no instance variables, no fields, no attributes, no constants, no class names. They are all emulated by using getters and setters.</p> <p>In Self, there are <em>no classes</em>, only objects. This emphasizes, what OO is <em>really</em> about: objects, not classes.</p>
<p><strong>Archetype</strong></p> <p>The ability to express real-world scenarios in code.</p> <pre><code>foreach(House house in location.Houses) { foreach(Deliverable mail in new Mailbag(new Deliverable[] { GetLetters(), GetPackages(), GetAdvertisingJunk() }) { if(mail.AddressedTo(house)) { house.Deliver(mail); } } } </code></pre> <p>-</p> <pre><code>foreach(Deliverable myMail in GetMail()) { IReadable readable = myMail as IReadable; if ( readable != null ) { Console.WriteLine(readable.Text); } } </code></pre> <p><strong>Why?</strong></p> <p>To help us understand this more easily. It makes better sense in our heads and if implemented correctly makes the code more efficient, re-usable and reduces repetition.</p> <p>To achieve this you need:</p> <ul> <li><strong>Pointers/References</strong> to ensure that this == this and this != that.</li> <li><strong>Classes</strong> to point to (e.g. Arm) that store data (int hairyness) and operations (Throw(IThrowable))</li> <li><strong>Polymorphism (Inheritance and/or Interfaces)</strong> to treat specific objects in a generic fashion so you can read books as well as graffiti on the wall (both implement IReadable)</li> <li><strong>Encapsulation</strong> because an apple doesn't expose an Atoms[] property</li> </ul>
4,876
<p>I have a ASP.Net website that is failing on AJAX postbacks (both with ASP.Net AJAX and a 3rd part control) in IE. FireFox works fine. If I install the website on another machine without .Net 3.5 SP1, it works as expected.</p> <p>When it fails, Fiddler shows that I'm getting a 405 "Method Not Allowed". The form seems to be posting to pages other than page I'm viewing.</p> <p>The form's action is "#" for the page on the broken website (with SP1). The form's action is "Default.aspx" for the same page on a website without SP1.</p> <p>Any ideas?</p>
<p>This appears to be correct for your <em>nested</em> Foo tags:</p> <pre><code>&lt;NewDataSet&gt; &lt;Foo&gt; &lt;!-- Foo-Id: 0 --&gt; &lt;Bar&gt;abcd&lt;/Bar&gt; &lt;Foo&gt;efg&lt;/Foo&gt; &lt;!-- Foo-Id: 1, Parent-Id: 0 --&gt; &lt;/Foo&gt; &lt;Foo&gt; &lt;!-- Foo-Id: 2 --&gt; &lt;Bar&gt;hijk&lt;/Bar&gt; &lt;Foo&gt;lmn&lt;/Foo&gt; &lt;!-- Foo-Id: 3, Parent-Id: 2 --&gt; &lt;/Foo&gt; &lt;/NewDataSet&gt; </code></pre> <p>So this correctly becomes 4 records in your result, with a parent-child key of "Foo-Id-0"</p> <p>Try:</p> <pre><code>&lt;NewDataSet&gt; &lt;Rec&gt; &lt;!-- Rec-Id: 0 --&gt; &lt;Bar&gt;abcd&lt;/Bar&gt; &lt;Foo&gt;efg&lt;/Foo&gt; &lt;/Rec&gt; &lt;Rec&gt; &lt;!-- Rec-Id: 1 --&gt; &lt;Bar&gt;hijk&lt;/Bar&gt; &lt;Foo&gt;lmn&lt;/Foo&gt; &lt;/Rec&gt; &lt;/NewDataSet&gt; </code></pre> <p>Which should result in:</p> <pre><code>Bar Foo Rec-Id abcd efg 0 hijk lmn 1 </code></pre>
<p>These are my observations rather than a full answer:</p> <p>My guess (without trying to re-produce it myself) is that a couple of things may be happening as the DataSet tries to 'flatten' a hierarchical structure to a relational data structure.</p> <p>1) thinking about the data from a relational database perspective; there is no obvious primary key field for identifying each of the Foo elements in the collection so the DataSet has automatically used the ordinal position in the file as an auto-generated field called Foo-Id.</p> <p>2) There are actually two elements called 'Foo' so that probably explains the generation of a strange name for the column 'Foo-Id-0' (it has auto-generated a unique name for the column - I guess you could think of this as a fault-tolerant behaviour in the DataSet).</p>
7,494
<p>I'm really beginning to understand what people mean when they say that C++'s error messages are pretty terrible in regards to templates. I've seen horrendously long errors for things as simple as a function not matching its prototype.</p> <p>Are there any tricks to deciphering these errors?</p> <p>EDIT: I'm using both gcc and MSVC. They both seem to be pretty terrible.</p>
<p>You can try the following tool to make things more sane:</p> <p><a href="http://www.bdsoft.com/tools/stlfilt.html" rel="noreferrer">http://www.bdsoft.com/tools/stlfilt.html</a></p>
<p>Some compilers give better messages than others. What compiler are you using? Having said that, they are all pretty bad. C++0X will fix most of this problem (see <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Concepts" rel="nofollow noreferrer">concepts</a>), but the standard won't be released until 2009, and broad support will probably be even later than that :-(</p>
7,033
<p>I'm writing C# code that uses the windows IP Helper API. One of the functions I'm trying to call is "<a href="http://msdn.microsoft.com/en-us/library/aa365920(VS.85).aspx" rel="nofollow noreferrer">GetBestInterface</a>" that takes a 'uint' representation of an IP. What I need is to parse a textual representation of the IP to create the 'uint' representation.</p> <p>I've found some examples via Google, like <a href="http://www.justin-cook.com/wp/2006/11/28/convert-an-ip-address-to-ip-number-with-php-asp-c-and-vbnet/" rel="nofollow noreferrer">this one</a> or <a href="http://www.codeguru.com/csharp/.net/net_general/internet/article.php/c10651" rel="nofollow noreferrer">this one</a>, but I'm pretty sure there should be a standard way to achieve this with .NET. Only problem is, I can't find this standard way. IPAddress.Parse seems to be in the right direction, but it doesn't supply any way of getting a 'uint' representation...</p> <p>There is also a way of doing this using IP Helper, using the <a href="http://msdn.microsoft.com/en-us/library/bb408412(VS.85).aspx" rel="nofollow noreferrer">ParseNetworkString</a>, but again, I'd rather use .NET - I believe the less I rely on pInvoke the better.</p> <p>So, anyone knows of a standard way to do this in .NET?</p>
<p>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.net.ipaddress.getaddressbytes.aspx" rel="noreferrer">says</a> that IPAddress.Address property (which returns numeric representation of IP address) is obsolete and you should use <a href="http://msdn.microsoft.com/en-us/library/system.net.ipaddress.getaddressbytes.aspx" rel="noreferrer">GetAddressBytes</a> method.</p> <p>You can convert IP address to numeric value using following code:</p> <pre><code>var ipAddress = IPAddress.Parse("some.ip.address"); var ipBytes = ipAddress.GetAddressBytes(); var ip = (uint)ipBytes [3] &lt;&lt; 24; ip += (uint)ipBytes [2] &lt;&lt; 16; ip += (uint)ipBytes [1] &lt;&lt;8; ip += (uint)ipBytes [0]; </code></pre> <p><strong>EDIT:</strong><br> As other commenters noticed above-mentioned code is for IPv4 addresses only. IPv6 address is 128 bits long so it's impossible to convert it to 'uint' as question's author wanted.</p>
<p>I have never found a clean solution (i.e.: a class / method in the .NET Framework) for this problem. I guess it just isn't available except the solutions / examples you provided or Aku's example. :(</p>
5,742
<p>I printed <a href="https://www.thingiverse.com/thing:53451" rel="nofollow noreferrer">Planetary Gears</a> and the top looks great<a href="https://i.stack.imgur.com/Oq5DB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Oq5DB.jpg" alt="top"></a> but the bottom doesn't<a href="https://i.stack.imgur.com/MKMDQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MKMDQ.jpg" alt="bottom"></a></p> <p>I am printing on a TronXY X3 (Prusa i3 metal frame clone) using eSun PLA+ and sliced using Cura 2.4. I print on glass and do manual leveling (sheet of paper to set gap).</p> <p>What could be causing this?</p> <p>It almost looks like a raft; but, I selected to print with a Brim not a Raft.</p> <p>I have seen this on some other prints so I suspect it is a slicer setting. Note: Bed adhesion seemed great. First adhered well and part popped off with very little effort.</p>
<p><strong>Your nozzle is too far from your bed.</strong> The first layer isn't squished down sufficiently, resulting in these gaps. If your first layer looks like this, you should cancel your print and adjust the bed. Alternatively, you can adjust the initial height of the Z-axis in G-code (for instance, <code>G0 Z-0.1</code> followed by <code>G92 Z0</code>, which should be appended to your start G-code).</p> <p>You can also try increasing the first layer height or the first layer extrusion multiplier. If you increase the first layer height, you will probably still have to adjust the bed slightly to bring the nozzle closer, but the thicker your first layer the larger the window where you get a good first layer.</p> <p>Increasing the extrusion multiplier will effectively stretch the first layer to be thicker (and thus the model will come out slightly too high) and thus isn't necessarily a good idea, though some people find that a slight increase (to for instance, 110%) makes the first layer slightly more forgiving (but this also increases adherence, making parts harder to remove - there is a very fine line between getting good first layers and having your prints stuck permanently to the bed).</p>
<p><strong>@TomvanderZanden was correct</strong></p> <p><strong>My nozzle was too far from your bed</strong> (sort of)</p> <p>Since my printer is manually leveled I have to use a sheet of paper to check each leveling point. This means the nozzle is about 0.1mm off the bed at home. In Cura, I had <code>Initial Layer Height=0.3mm</code> BUT this is supposed to be 0.3mm above the bed and my home will be already 0.1mm the bed; so, I really needed <code>Initial Layer Height=0.2mm</code>!</p> <p>After doing that, the first layer laid down really nicely and all the lines got properly smooshed together. <a href="https://i.stack.imgur.com/98POk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/98POk.jpg" alt="enter image description here"></a></p>
634
<p>Ran into an “Out of Stack Space” error trying to serialize an ASP.Net AJAX Array object. </p> <p>Here is the scenario with simplified code:</p> <ol> <li><p><code>Default.aspx</code></p></li> <li><p><code>MainScript.js</code></p> <pre><code>function getObject(){ return new Array(); } function function1(obj){ var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); alert(s); } function function2(){ var obj=getObject(); var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); alert(s); } </code></pre></li> <li><p><code>Content.aspx</code></p></li> <li><p><code>ContentScript.js</code></p> <pre><code>function serializeObject(){ var obj=window.top.getObject(); window.top.function1(obj); // &lt;– This works fine obj=new Array(); window.top.function1(obj); // &lt;– this causes an Out of Stack Space error } </code></pre></li> </ol> <p>The code for the sample pages and JavaScript is <a href="http://braincells2pixels.wordpress.com/2008/02/14/aspnet-ajax-javascript-serialization-error/" rel="nofollow noreferrer">here</a>.</p> <p>Posting the code for the aspx pages here posed a problem. So please check the above link to see the code for the aspx pages.</p> <p>A web page (default.aspx) with an IFrame on that hosts a content page (content.aspx). </p> <p>Clicking the “Serialize Object” button calls the JavaScript function serializeObject(). The serialization works fine for Array objects created in the top window (outside the frame). However if the array object is created in the IFrame, serialization bombs with an out of stack space error. I stepped through ASP.Net AJAX JS files and what I discovered is, the process goes into an endless loop trying to figure out the type of the array object. Endless call to Number.IsInstanceOf and pretty soon you get an out of stack error.</p> <p>Any ideas?</p>
<p>This problem happens because Sys.Serialization.JavaScriptSerializer can't serialize objects from others frames, but only those objects which where instantiated in the current window (which calls serialize() method). The only workaround which is known for me it's making clone of the object from other frame before calling serialize() method.</p> <p>Example of the clone() methode you can find here (comments in Russian): <a href="http://snowcore.net/clone-javascript-object" rel="nofollow noreferrer">link text</a></p>
<p>I have no way of testing your code right now, but it looks like a bug in JavaScriptSerializer.serialize to me. My guess is that it tries to do some kind of type checking on the array via the CLR and that it doesn't handle an empty array properly. </p> <p>Have you tried to add an item of a serializable type to the array in your code? If so, what happens?</p>
8,102
<p>I'm unsure whether the following code would ensure all conditions given in Comparator's Javadoc. </p> <pre><code>class TotalOrder&lt;T&gt; implements Comparator&lt;T&gt; { public boolean compare(T o1, T o2) { if (o1 == o2 || equal(o1, o2)) return 0; int h1 = System.identityHashCode(o1); int h2 = System.identityHashCode(o2); if (h1 != h2) { return h1 &lt; h2 ? -1 : 1; } // equals returned false but identity hash code was same, assume o1 == o2 return 0; } boolean equal(Object o1, Object o2) { return o1 == null ? o2 == null : o1.equals(o2); } } </code></pre> <p>Will the code above impose a total ordering on all instances of any class, even if that class does not implement Comparable?</p>
<blockquote> <p>Hey, look at what I found!</p> <p><a href="http://gafter.blogspot.com/2007/03/compact-object-comparator.html" rel="nofollow noreferrer">http://gafter.blogspot.com/2007/03/compact-object-comparator.html</a></p> </blockquote> <p>Oh yes, I forgot about the IdentityHashMap (Java 6 and above only). Just have to pay attention at releasing your comparator. </p>
<p>I'm not really sure about the <code>System.identityHashCode(Object)</code>. That's pretty much what the <strong>==</strong> is used for. You might rather want to use the <code>Object.hashCode()</code> - it's more in parallel with <code>Object.equals(Object)</code>.</p>
4,797
<p>I'm reading lines of input on a TCP socket, similar to this:</p> <pre><code>class Bla def getcmd @sock.gets unless @sock.closed? end def start srv = TCPServer.new(5000) @sock = srv.accept while ! @sock.closed? ans = getcmd end end end </code></pre> <p>If the endpoint terminates the connection while getline() is running then gets() hangs. </p> <p>How can I work around this? Is it necessary to do non-blocking or timed I/O?</p>
<p>You can use select to see whether you can safely gets from the socket, see following implementation of a TCPServer using this technique.</p> <pre><code>require 'socket' host, port = 'localhost', 7000 TCPServer.open(host, port) do |server| while client = server.accept readfds = true got = nil begin readfds, writefds, exceptfds = select([client], nil, nil, 0.1) p :r =&gt; readfds, :w =&gt; writefds, :e =&gt; exceptfds if readfds got = client.gets p got end end while got end end </code></pre> <p>And here a client that tries to break the server:</p> <pre><code>require 'socket' host, port = 'localhost', 7000 TCPSocket.open(host, port) do |socket| socket.puts "Hey there" socket.write 'he' socket.flush socket.close end </code></pre>
<p>If you believe the <a href="http://www.ruby-doc.org/stdlib/libdoc/socket/rdoc/index.html" rel="nofollow noreferrer">rdoc</a> for ruby sockets, they don't implement <code>gets</code>. This leads me to believe gets is being provided by a higher level of abstraction (maybe the IO libraries?) and probably isn't aware of socket-specific things like 'connection closed.'</p> <p>Try using <a href="http://www.ruby-doc.org/stdlib/libdoc/socket/rdoc/classes/Socket.html#M004238" rel="nofollow noreferrer"><code>recvfrom</code></a> instead of <code>gets</code></p>
8,690
<p>It'd be really nice to target my Windows Forms app to the .NET 3.5 SP1 <em>client</em> framework. But, right now I'm using the <code>HttpUtility.HtmlDecode</code> and <code>HttpUtility.UrlDecode</code> functions, and the MSDN documentation doesn't point to any alternatives inside of, say, System.Net or something.</p> <p>So, short from reflectoring the source code and copying it into my assembly---which I don't think would be worth it---are there alternatives inside of the .NET 3.5 SP1 client framework that you know of, to replace this functionality? It seems a bit strange that they'd restrict these useful functions to server-only code.</p>
<p>Found today from <a href="http://10rem.net/blog/2010/04/07/encoding-decoding-uris-and-html-in-the-net-4-client-profile?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+PeteBrown-ASPNET+%28Pete+Brown%27s+Blog+%3A+ASP.NET%29" rel="noreferrer">this here little site</a> that HtmlEncode/Decode can be done using System.Net library in C# 4.0 Client Profile:</p> <pre><code>Uri.EscapeDataString(...) WebUtility.HtmlEncode(...) </code></pre> <p>Edit: I re-read that the question applied for the 3.5 Client Framework but maybe this can be useful those who have updated 4.0..</p>
<p>Two main ways :</p> <ol> <li>Deploy using the full .NET Framework</li> <li>Write your own / 3rd party lib for these functionalities</li> </ol>
5,697
<p>Is there a way to select a parent element based on the class of a child element in the class? The example that is relevant to me relating to HTML output by a nice menu plugin for <a href="http://drupal.org" rel="noreferrer">http://drupal.org</a>. The output renders like this: </p> <pre><code>&lt;ul class="menu"&gt; &lt;li&gt; &lt;a class="active"&gt;Active Page&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a&gt;Some Other Page&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>My question is whether or not it is possible to apply a style to the list item that contains the anchor with the active class on it. Obviously, I'd prefer that the list item be marked as active, but I don't have control of the code that gets produced. I could perform this sort of thing using javascript (JQuery springs to mind), but I was wondering if there is a way to do this using CSS selectors.</p> <p>Just to be clear, I want to apply a style to the list item, not the anchor.</p>
<p>Unfortunately, there's no way to do that with CSS.</p> <p>It's not very difficult with JavaScript though:</p> <pre><code>// JavaScript code: document.getElementsByClassName("active")[0].parentNode; // jQuery code: $('.active').parent().get(0); // This would be the &lt;a&gt;'s parent &lt;li&gt;. </code></pre>
<p>Another thought occurred to me just now that could be a pure CSS solution. Display your active class as an absolutely positioned block and set its style to cover up the parent li.</p> <pre><code>a.active { position:absolute; display:block; width:100%; height:100%; top:0em; left:0em; background-color: whatever; border: whatever; } /* will also need to make sure the parent li is a positioned element so... */ ul.menu li { position:relative; } </code></pre> <p>For those of you who want to use javascript without jquery...</p> <p>Selecting the parent is trivial. You need a <code>getElementsByClass</code> function of some sort, unless you can get your drupal plugin to assign the active item an ID instead of Class. The function I provided I grabbed from some other genius on SO. It works well, just keep in mind when you're debugging that the function will always return an array of nodes, not just a single node.</p> <pre><code>active_li = getElementsByClass("active","a"); active_li[0].parentNode.style.whatever="whatever"; function getElementsByClass(node,searchClass,tag) { var classElements = new Array(); var els = node.getElementsByTagName(tag); // use "*" for all elements var elsLen = els.length; var pattern = new RegExp("\\b"+searchClass+"\\b"); for (i = 0, j = 0; i &lt; elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } </code></pre>
6,680
<p>I'd love to know if there is such a thing as a Gecko.NET ;) I mean, just like we can embed a WebView and that is an "instance" of IE7 inside any Windows Forms application (and tell it to <code>navigateto(fancy_url);</code>). I'd love to use Firefox or WebKit. </p> <p>Anybody tried this?</p> <p><strong>UPDATE</strong>: Please bear in mind that although it is possible to embed Gecko using the mentioned controls, it is still impossible to <strong>print</strong> while using Gecko.</p> <p><strong>UPDATE March 2010</strong>: It’s still not possible to print natively using GeckoFX, however a couple of methods exist that <em>may</em> be enough, depending upon what you’re trying to do. See: <a href="http://geckofx.org/viewtopic.php?id=796" rel="noreferrer">http://geckofx.org/viewtopic.php?id=796</a> for more information.</p> <p><strong>UPDATE October 2013</strong>: I am no longer doing Windows development so I have no interest in this, but seems like the development of Gecko can be found here: <a href="https://bitbucket.org/geckofx" rel="noreferrer">https://bitbucket.org/geckofx</a> and it seems to be recently updated. Leaving this here for future Windows devs ;)</p> <p><strong>UPDATE January 2017</strong>: I have gotten an email from a company called <a href="http://www.teamdev.com" rel="noreferrer">TeamDev</a>. They created a Chromium-based .NET browser component called "DotNetBrowser" which can be used to display modern web pages in Windows Forms applications. </p> <p>To quote the email directly:</p> <blockquote> <p>Here are some details about the component, which might be helpful:</p> </blockquote> <ol> <li>DotNetBrowser is based on Chromium, thus supporting HTML5, CSS3, JS and the latest web standards. The underlying Chromium version of the library is regularly updated.</li> <li>The component is suitable for WPF as well as Windows Forms desktop applications, and works both for C# and VB.NET.</li> <li>The library is licensed commercially, however free licences are provided for Open Source and academic projects.</li> </ol> <p><strong>Disclaimer:</strong> <em>I have not used this DotNetBrowser for I no longer do Windows Development but may be worth checking if you're looking for a solution to this.</em></p>
<p><a href="http://code.google.com/p/geckofx/" rel="noreferrer">http://code.google.com/p/geckofx/</a></p> <p>This is a nice .NET-wrapped version of Gecko</p>
<p>Additionally, if you find yourself using Gtk instead of Windows.Forms, there is a tarball of webkit-sharp available that allows for easy embedding of WebViews into Gtk# applications.</p>
4,574
<p>Our application is interfacing with a lot of web services these days. We have our own package that someone wrote a few years back using UTL_HTTP and it generally works, but needs some hard-coding of the SOAP envelope to work with certain systems. I would like to make it more generic, but lack experience to know how many scenarios I would have to deal with. The variations are in what namespaces need to be declared and the format of the elements. We have to handle both simple calls with a few parameters and those that pass a large amount of data in an encoded string.</p> <p>I know that 10g has UTL_DBWS, but there are not a huge number of use-cases on-line. Is it stable and flexible enough for general use? <a href="http://stanford.edu/dept/itss/docs/oracle/10g/java.101/b12021/callouts.htm" rel="nofollow noreferrer">Documentation</a></p>
<p>I have used <code>UTL_HTTP</code> which is simple and works. If you face a challenge with your own package, you can probably find a solution in one of the many wrapper packages around UTL_HTTP on the net (Google "consuming web services from pl/sql", leading you to e.g. <a href="http://www.oracle-base.com/articles/9i/ConsumingWebServices9i.php" rel="noreferrer">http://www.oracle-base.com/articles/9i/ConsumingWebServices9i.php</a>) </p> <p>The reason nobody is using <code>UTL_DBWS</code> is that it is not functional in a default installed database. You need to load a ton of Java classes into the database, but the standard instructions seem to be defective - the process spews Java errors right and left and ultimately fails. It seems very few people have been willing to take the time to track down the package dependencies in order to make this approach work.</p>
<p>Check out this <a href="https://stackoverflow.com/questions/33449/can-you-call-a-webservice-from-tsql-code">older post</a>. I have to agree with that post's #1 answer; it's hard to imagine a scenario where this could be a good design.</p> <p>Can't you write a service, or standalone application, which would talk to a table in your database? Then you could implement whatever you want as a trigger on that table.</p>
5,835
<p>As I build *nix piped commands I find that I want to see the output of one stage to verify correctness before building the next stage but I don't want to re-run each stage. Does anyone know of a program that will help with that? It would keep the output of the last stage automatically to use for any new stages. I usually do this by sending the result of each command to a temporary file (i.e. tee or run each command one at a time) but it would be nice for a program to handle this.</p> <p>I envision something like a tabbed interface where each tab is labeled with each pipe command and selecting a tab shows the output (at least a hundred lines) of applying that command to to the previous result.</p>
<p>Use 'tee' to copy the intermediate results out to some file as well as pass them on to the next stage of the pipe, like so:</p> <pre><code>cat /var/log/syslog | tee /tmp/syslog.out | grep something | tee /tmp/grep.out | sed 's/foo/bar/g' | tee /tmp/sed.out | cat &gt;&gt;/var/log/syslog.cleaned </code></pre>
<p><code>tee</code>(1) is your friend. It sends its input to both the specified file and stdout. </p> <p>Stick it between your pipes. For example:</p> <pre><code>ls | tee /tmp/out1 | sort | tee /tmp/out2 | sed 's/foo/bar/g' </code></pre>
8,921
<p>Problem: I have an address field from an Access database which has been converted to SQL Server 2005. This field has everything all in one field. I need to parse out the address's individual sections into their appropriate fields in a normalized table. I need to do this for approximately 4,000 records, and it needs to be repeatable.</p> <p>Assumptions:</p> <ol> <li><p>Assume an address in the US (for now)</p> </li> <li><p>assume that the input string will sometimes contain an addressee (the person being addressed) and/or a second street address (i.e. Suite B)</p> </li> <li><p>states may be abbreviated</p> </li> <li><p>zip code could be standard 5 digits or zip+4</p> </li> <li><p>there are typos in some instances</p> </li> </ol> <p>UPDATE: In response to the questions posed, standards were not universally followed; I need need to store the individual values, not just geocode and errors means typo (corrected above)</p> <p>Sample Data:</p> <ul> <li><p>A. P. Croll &amp; Son 2299 Lewes-Georgetown Hwy, Georgetown, DE 19947</p> </li> <li><p>11522 Shawnee Road, Greenwood DE 19950</p> </li> <li><p>144 Kings Highway, S.W. Dover, DE 19901</p> </li> <li><p>Intergrated Const. Services 2 Penns Way Suite 405 New Castle, DE 19720</p> </li> <li><p>Humes Realty 33 Bridle Ridge Court, Lewes, DE 19958</p> </li> <li><p>Nichols Excavation 2742 Pulaski Hwy Newark, DE 19711</p> </li> <li><p>2284 Bryn Zion Road, Smyrna, DE 19904</p> </li> <li><p>VEI Dover Crossroads, LLC 1500 Serpentine Road, Suite 100 Baltimore MD 21</p> </li> <li><p>580 North Dupont Highway Dover, DE 19901</p> </li> <li><p>P.O. Box 778 Dover, DE 19903</p> </li> </ul>
<p>I've done a lot of work on this kind of parsing. Because there are errors you won't get 100% accuracy, but there are a few things you can do to get most of the way there, and then do a visual BS test. Here's the general way to go about it. It's not code, because it's pretty academic to write it, there's no weirdness, just lots of string handling.</p> <p>(Now that you've posted some sample data, I've made some minor changes)</p> <ol> <li>Work backward. Start from the zip code, which will be near the end, and in one of two known formats: XXXXX or XXXXX-XXXX. If this doesn't appear, you can assume you're in the city, state portion, below.</li> <li>The next thing, before the zip, is going to be the state, and it'll be either in a two-letter format, or as words. You know what these will be, too -- there's only 50 of them. Also, you could soundex the words to help compensate for spelling errors.</li> <li>before that is the city, and it's <em>probably</em> on the same line as the state. You could use a <a href="http://zipinfo.com" rel="noreferrer">zip-code database</a> to check the city and state based on the zip, or at least use it as a BS detector.</li> <li>The street address will generally be one or two lines. The second line will generally be the suite number if there is one, but it could also be a PO box.</li> <li>It's going to be near-impossible to detect a name on the first or second line, though if it's not prefixed with a number (or if it's prefixed with an "attn:" or "attention to:" it could give you a hint as to whether it's a name or an address line.</li> </ol> <p>I hope this helps somewhat.</p>
<p>There are data services that given a zip code will give you list of street names in that zip code.</p> <p>Use a regex to extract Zip or City State - find the correct one or if a error get both. pull the list of streets from a <a href="http://www.melissadata.com/lookups/zipstreet.asp" rel="nofollow noreferrer">data source</a> Correct the city and state, and then street address. Once you get a valid Address line 1, city, state, and zip you can then make assumptions on address line 2..3</p>
3,712
<p>I need to display profiling information pulled from a deeply embedded CPU, presenting it in a way which other developers on my team will be able to act upon. The profiling data is a snapshot of a cycle counter at the entry and exit of every function, so we have a call graph annotated with sub-microsecond timing accuracy. I'd prefer not to just dump out function names and timing like gprof, I'm looking for something easier to understand and act upon.</p> <p>Has anyone worked with a particularly good profiling tool (on any platform), which made it easy to identify areas of the code to drill into? I'm looking for an inspirational example to follow for how to display the call graph, but if there is good tool with an input format I can massage my data to I'll use it. I could use Windows, Linux, or MacOS X to run the visualization tool.</p> <p>A profiling article on <A HREF="http://www.ibm.com/developerworks/library/l-graphvis/" rel="noreferrer">IBM DeveloperWorks</A> led me to <A HREF="http://www.graphviz.org/" rel="noreferrer">GraphViz</A>, with a <A HREF="http://www.graphviz.org/Gallery/directed/profile.html" rel="noreferrer">profiling</A> example on their site. Barring another suggestion here, I'll use GraphViz and mimic their profiling example.</p>
<p>Another neat tool to visualize profiling data is the <a href="http://code.google.com/p/jrfonseca/wiki/Gprof2Dot" rel="nofollow noreferrer">gprof2dot.py python script</a>. It can be used to visualize several different formats: "This is a Python script to convert the output from prof, gprof, oprofile, Shark, AQtime, and python profilers into a dot graph." This is what the output look like:</p> <p><a href="https://i.stack.imgur.com/KGYNv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KGYNv.png" alt=""></a><br> <sub>(source: <a href="http://jrfonseca.googlecode.com/svn/wiki/gprof2dot_small.png" rel="nofollow noreferrer">googlecode.com</a>)</sub> </p>
<p>I've written a browser-based visualization tool, <a href="https://pypi.python.org/pypi/ProfileEye/" rel="nofollow">profile_eye</a>, which operates on the output of <a href="https://github.com/jrfonseca/gprof2dot" rel="nofollow">gprof2dot</a>.</p> <p>gprof2dot is great at grokking many profiling-tool outputs, and does a great job at graph-element placement. The final rendering is a static graphic, which is often very cluttered. </p> <p>Using <a href="http://d3js.org/" rel="nofollow">d3.js</a> it's possible to remove much of that clutter, through relative fading of unfocused elements, tooltips, and a <a href="http://bost.ocks.org/mike/fisheye/" rel="nofollow">fisheye distortion</a>. </p> <p>For comparison, see <a href="http://pythonhosted.org//ProfileEye/gprof.html" rel="nofollow">profile_eye's visualization</a> of the <a href="https://github.com/jrfonseca/gprof2dot" rel="nofollow">canonical example used by gprof2dot</a>. </p>
7,865
<p>Does anyone have any recommendations for implementations of ActiveRecord in PHP? I've been using <a href="http://31tools.com/cbl_activerecord/" rel="nofollow noreferrer">CBL ActiveRecord</a>, but I was wondering if there were any viable alternatives.</p>
<p>I realize this is old, but there is an absolutely fabulous PHP Activecord library called, appropriately, PHP Activerecord. I've used it for several months and it blows away the other libraries.</p> <p>Check it out:</p> <p><a href="http://www.phpactiverecord.org/">http://www.phpactiverecord.org/</a></p>
<p>Whilst not strictly ActiveRecord, <a href="http://framework.zend.com/manual/en/zend.db.table.html" rel="nofollow noreferrer">Zend_Db_Table</a> is pretty good.</p>
5,883
<p>I am trying to be a "good" programmer and have unit tests for my ColdFusion application but haven't been able to find a code coverage tool that can tie into the test that I'm using. For those of you who do unit tests on your ColdFusion code, how have you approached this problem?</p>
<p><a href="http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:53046" rel="nofollow noreferrer">Many</a> <a href="http://www.pbell.com/index.cfm/2006/10/20/What-is-Code-Coverage-Analysis--and-why-should-you-care" rel="nofollow noreferrer">have</a> <a href="http://coolskool.blog-city.com/what_coldfusion_tools_do_you_want.htm" rel="nofollow noreferrer">asked</a>, but to date there remains no ColdFusion code coverage tool.</p> <p>The latest ColdFusion features .NET integration in addition to J2EE integration, so if you require code coverage metrics (ie, customer requirements) then (aside from choosing something other than ColdFusion) you might define what parts need such coverage and break them out into .NET or J2EE objects which you can profile with readily available tools.</p> <p>Alternately, you can do some analysis yourself - use a parser to insert <a href="http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&amp;file=00001221.htm" rel="nofollow noreferrer">cftrace</a> tags after every control statement and then parse the results.</p> <p>Lastly, ColdFusion does have some <a href="http://www.bennadel.com/blog/116-Finding-Template-Execution-Stack-in-ColdFusion.htm" rel="nofollow noreferrer">basic stack trace</a> ability - I don't know if it goes deeper than that, but it's worth exploring to see what you can parse from that.</p> <p>I hope this helps!</p> <p>-Adam Davis</p>
<p><a href="http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:53046" rel="nofollow noreferrer">Many</a> <a href="http://www.pbell.com/index.cfm/2006/10/20/What-is-Code-Coverage-Analysis--and-why-should-you-care" rel="nofollow noreferrer">have</a> <a href="http://coolskool.blog-city.com/what_coldfusion_tools_do_you_want.htm" rel="nofollow noreferrer">asked</a>, but to date there remains no ColdFusion code coverage tool.</p> <p>The latest ColdFusion features .NET integration in addition to J2EE integration, so if you require code coverage metrics (ie, customer requirements) then (aside from choosing something other than ColdFusion) you might define what parts need such coverage and break them out into .NET or J2EE objects which you can profile with readily available tools.</p> <p>Alternately, you can do some analysis yourself - use a parser to insert <a href="http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&amp;file=00001221.htm" rel="nofollow noreferrer">cftrace</a> tags after every control statement and then parse the results.</p> <p>Lastly, ColdFusion does have some <a href="http://www.bennadel.com/blog/116-Finding-Template-Execution-Stack-in-ColdFusion.htm" rel="nofollow noreferrer">basic stack trace</a> ability - I don't know if it goes deeper than that, but it's worth exploring to see what you can parse from that.</p> <p>I hope this helps!</p> <p>-Adam Davis</p>
5,049
<p>I am a member of all the roles (Browser, Content Manager, My Reports, Publisher, Report Builder). If I login with a Local Administrator account, I can see and use it fine. Any ideas?</p>
<p>The first thing I would check is to make sure that your normal login is mapped to a role with the correct system-level permissions. The item-level role definitions don't make a difference for the "Report Builder" button.</p> <p>From the browser-based report manager interface:</p> <ul> <li>Click "site settings"</li> <li>In the Security section, click "Configure system-level role definitions"</li> <li>Click the Role that you want to have this ability (e.g. "System Administrator" and "System User" are the default roles, but I believe that you can create your own if you want to).</li> <li>Make sure that the "Execute Report Definitions" task is checked/selected. This is the permission that controls whether or not the "Report Builder" button is displayed.</li> <li>Click "OK" and then return to the "Site Settings" page.</li> <li>In the Security section, click "Configure site-wide security"</li> <li>Click "New Role Assignment" and then map your login (or an AD group to which your login belongs might be even better) to the system-level role you edited in the previous steps.</li> </ul> <p>The forms are pretty straightforward, and I'd guess that your login just isn't mapped to the proper system-level role since you can see the button with the local administrator login. If that doesn't work, you might check your IIS security settings for the report service to make sure that they're configured to use windows authentication (assuming that's what you're using in the first place).</p>
<p>Tried to do as was stated in the answer above. But didn't find "Configure system-level role definitions" as mentioned in the second bullet. Perhaps the interface has changed a little in the past 5 years.</p> <p>Assuming you already have a browser window open where you see the report manager without the [Report Builder] button, I refer to this as the 1st browser window.</p> <p>Like Matt said, you need to start a 2nd browser window as Administrator, go to the report manager again and click on [Site Settings].</p> <p>After that, you click on [Security] and then on [New Role Assignment], type your username in the following page along with a check in [System User] Role. </p> <p>When this was done, the [Report Builder] button occurred again in my 1st browser window (after refresh of course).</p>
6,154
<p><strong>Edit:</strong> This question was written in 2008, which was like 3 internet ages ago. If this question is still relevant to your environment, please accept my condolences. Everyone else should convert into a format <a href="https://videojs.com/html5-video-support/" rel="noreferrer">supported by your browsers</a> (That would be H.264 if Internet Explorer is needed, and probably AV1, VP8/VP9 if not) and use the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video" rel="noreferrer"><code>&lt;video&gt;</code> element</a>.</p> <hr /> <p>We are using <a href="http://en.wikipedia.org/wiki/Windows_Media_Video" rel="noreferrer">WMV</a> videos on an internal site, and we are embedding them into web sites. This works quite well on Internet Explorer, but not on Firefox. I've found ways to make it work in Firefox, but then it stops working in Internet Explorer.</p> <p>We do not want to use Silverlight just yet, especially since we cannot be sure that all clients will be running Windows XP with Windows Media Player installed.</p> <p>Is there some sort of Universal Code that embeds WMP into both Internet Explorer and Firefox, or do we need to implement some user-agent-detection and deliver different HTML for different browsers?</p>
<p>The following works for me in Firefox and Internet Explorer:</p> <pre class="lang-html prettyprint-override"><code>&lt;object id="mediaplayer" classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701" standby="loading microsoft windows media player components..." type="application/x-oleobject" width="320" height="310"&gt; &lt;param name="filename" value="./test.wmv"&gt; &lt;param name="animationatstart" value="true"&gt; &lt;param name="transparentatstart" value="true"&gt; &lt;param name="autostart" value="true"&gt; &lt;param name="showcontrols" value="true"&gt; &lt;param name="ShowStatusBar" value="true"&gt; &lt;param name="windowlessvideo" value="true"&gt; &lt;embed src="./test.wmv" autostart="true" showcontrols="true" showstatusbar="1" bgcolor="white" width="320" height="310"&gt; &lt;/object&gt; </code></pre>
<p>December 2020 :</p> <ul> <li>We have now Firefox 83.0 and Chrome 87.0</li> <li>Internet Explorer is dead, it has been replaced by the new Chromium-based Edge 87.0</li> <li>Silverlight is dead</li> <li>Windows XP is dead</li> <li>WMV is not a standard : <a href="https://www.w3schools.com/html/html_media.asp" rel="nofollow noreferrer">https://www.w3schools.com/html/html_media.asp</a></li> </ul> <p>To answer the question :</p> <ul> <li>You have to convert your WMV file to another format : MP4, WebM or Ogg video.</li> <li>Then embed it in your page with <a href="https://www.w3schools.com/html/html5_video.asp" rel="nofollow noreferrer">the HTML 5 <code>&lt;video&gt;</code> element</a>.</li> </ul> <p>I think this question should be closed.</p>
2,263
<p>I would like to compare the contents of a couple of collections in my Equals method. I have a Dictionary and an IList. Is there a built-in method to do this?</p> <p>Edited: I want to compare two Dictionaries and two ILists, so I think what equality means is clear - if the two dictionaries contain the same keys mapped to the same values, then they're equal.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb342073.aspx" rel="noreferrer"><code>Enumerable.SequenceEqual</code></a></p> <blockquote> <p>Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer(T).</p> </blockquote> <p>You can't directly compare the list &amp; the dictionary, but you could compare the list of values from the Dictionary with the list</p>
<p>No, because the framework doesn't know how to compare the contents of your lists.</p> <p>Have a look at this:</p> <p><a href="http://blogs.msdn.com/abhinaba/archive/2005/10/11/479537.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/abhinaba/archive/2005/10/11/479537.aspx</a></p>
6,507
<pre><code>#include &lt;stdio.h&gt; int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\n", sizeof(num), num, normalInt); return 0; } </code></pre> <p>Output:</p> <pre><code>My number is 8 bytes wide and its value is 285212672l. A normal number is 0. </code></pre> <p>I assume this unexpected result is from printing the <code>unsigned long long int</code>. How do you <code>printf()</code> an <code>unsigned long long int</code>?</p>
<p>Use the ll (el-el) long-long modifier with the u (unsigned) conversion. (Works in windows, GNU).</p> <pre><code>printf("%llu", 285212672); </code></pre>
<p>Well, one way is to compile it as x64 with VS2008</p> <p>This runs as you would expect:</p> <pre><code>int normalInt = 5; unsigned long long int num=285212672; printf( "My number is %d bytes wide and its value is %ul. A normal number is %d \n", sizeof(num), num, normalInt); </code></pre> <p>For 32 bit code, we need to use the correct __int64 format specifier %I64u. So it becomes. </p> <pre><code>int normalInt = 5; unsigned __int64 num=285212672; printf( "My number is %d bytes wide and its value is %I64u. A normal number is %d", sizeof(num), num, normalInt); </code></pre> <p>This code works for both 32 and 64 bit VS compiler.</p>
2,499
<p>Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level?</p> <p>For information on queries to index a field, check out <a href="https://stackoverflow.com/questions/1156/">How do I index a database column</a>.</p>
<p><strong>Why is it needed?</strong></p> <p>When data is stored on disk-based storage devices, it is stored as blocks of data. These blocks are accessed in their entirety, making them the atomic disk access operation. Disk blocks are structured in much the same way as linked lists; both contain a section for data, a pointer to the location of the next node (or block), and both need not be stored contiguously.</p> <p>Due to the fact that a number of records can only be sorted on one field, we can state that searching on a field that isn’t sorted requires a Linear Search which requires <code>(N+1)/2</code> block accesses (on average), where <code>N</code> is the number of blocks that the table spans. If that field is a non-key field (i.e. doesn’t contain unique entries) then the entire tablespace must be searched at <code>N</code> block accesses.</p> <p>Whereas with a sorted field, a Binary Search may be used, which has <code>log2 N</code> block accesses. Also since the data is sorted given a non-key field, the rest of the table doesn’t need to be searched for duplicate values, once a higher value is found. Thus the performance increase is substantial.</p> <p><strong>What is indexing?</strong></p> <p>Indexing is a way of sorting a number of records on multiple fields. Creating an index on a field in a table creates another data structure which holds the field value, and a pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.</p> <p>The downside to indexing is that these indices require additional space on the disk since the indices are stored together in a table using the MyISAM engine, this file can quickly reach the size limits of the underlying file system if many fields within the same table are indexed.</p> <p><strong>How does it work?</strong></p> <p>Firstly, let’s outline a sample database table schema;</p> <pre> Field name Data type Size on disk id (Primary key) Unsigned INT 4 bytes firstName Char(50) 50 bytes lastName Char(50) 50 bytes emailAddress Char(100) 100 bytes </pre> <p><strong>Note</strong>: char was used in place of varchar to allow for an accurate size on disk value. This sample database contains five million rows and is unindexed. The performance of several queries will now be analyzed. These are a query using the <em>id</em> (a sorted key field) and one using the <em>firstName</em> (a non-key unsorted field).</p> <p><em><strong>Example 1</strong></em> - <em>sorted vs unsorted fields</em></p> <p>Given our sample database of <code>r = 5,000,000</code> records of a fixed size giving a record length of <code>R = 204</code> bytes and they are stored in a table using the MyISAM engine which is using the default block size <code>B = 1,024</code> bytes. The blocking factor of the table would be <code>bfr = (B/R) = 1024/204 = 5</code> records per disk block. The total number of blocks required to hold the table is <code>N = (r/bfr) = 5000000/5 = 1,000,000</code> blocks.</p> <p>A linear search on the id field would require an average of <code>N/2 = 500,000</code> block accesses to find a value, given that the id field is a key field. But since the id field is also sorted, a binary search can be conducted requiring an average of <code>log2 1000000 = 19.93 = 20</code> block accesses. Instantly we can see this is a drastic improvement.</p> <p>Now the <em>firstName</em> field is neither sorted nor a key field, so a binary search is impossible, nor are the values unique, and thus the table will require searching to the end for an exact <code>N = 1,000,000</code> block accesses. It is this situation that indexing aims to correct.</p> <p>Given that an index record contains only the indexed field and a pointer to the original record, it stands to reason that it will be smaller than the multi-field record that it points to. So the index itself requires fewer disk blocks than the original table, which therefore requires fewer block accesses to iterate through. The schema for an index on the <em>firstName</em> field is outlined below;</p> <pre> Field name Data type Size on disk firstName Char(50) 50 bytes (record pointer) Special 4 bytes </pre> <p><strong>Note</strong>: Pointers in MySQL are 2, 3, 4 or 5 bytes in length depending on the size of the table.</p> <p><em><strong>Example 2</strong></em> - <em>indexing</em></p> <p>Given our sample database of <code>r = 5,000,000</code> records with an index record length of <code>R = 54</code> bytes and using the default block size <code>B = 1,024</code> bytes. The blocking factor of the index would be <code>bfr = (B/R) = 1024/54 = 18</code> records per disk block. The total number of blocks required to hold the index is <code>N = (r/bfr) = 5000000/18 = 277,778</code> blocks.</p> <p>Now a search using the <em>firstName</em> field can utilize the index to increase performance. This allows for a binary search of the index with an average of <code>log2 277778 = 18.08 = 19</code> block accesses. To find the address of the actual record, which requires a further block access to read, bringing the total to <code>19 + 1 = 20</code> block accesses, a far cry from the 1,000,000 block accesses required to find a <em>firstName</em> match in the non-indexed table.</p> <p><strong>When should it be used?</strong></p> <p>Given that creating an index requires additional disk space (277,778 blocks extra from the above example, a ~28% increase), and that too many indices can cause issues arising from the file systems size limits, careful thought must be used to select the correct fields to index.</p> <p>Since indices are only used to speed up the searching for a matching field within the records, it stands to reason that indexing fields used only for output would be simply a waste of disk space and processing time when doing an insert or delete operation, and thus should be avoided. Also given the nature of a binary search, the cardinality or uniqueness of the data is important. Indexing on a field with a cardinality of 2 would split the data in half, whereas a cardinality of 1,000 would return approximately 1,000 records. With such a low cardinality the effectiveness is reduced to a linear sort, and the query optimizer will avoid using the index if the cardinality is less than 30% of the record number, effectively making the index a waste of space.</p>
<p>Just think of Database Index as Index of a book.</p> <p>If you have a book about dogs and you want to find an information about let's say, German Shepherds, you could of course flip through all the pages of the book and find what you are looking for - but this of course is time consuming and not very fast. </p> <p>Another option is that, you could just go to the Index section of the book and then find what you are looking for by using the Name of the entity you are looking ( in this instance, German Shepherds) and also looking at the page number to quickly find what you are looking for. </p> <p>In Database, the page number is referred to as a pointer which directs the database to the address on the disk where entity is located. Using the same German Shepherd analogy, we could have something like this (“German Shepherd”, 0x77129) where <code>0x77129</code> is the address on the disk where the row data for German Shepherd is stored. </p> <p>In short, an index is a data structure that stores the values for a specific column in a table so as to speed up query search.</p>
2,354
<p>I had a new Extruder tip on my Ender 3 3D printer. the tip looked like the left tip in the below image. After I have been using it for about 5 months, the tip got dull/flat, like the tip on the right in the below image.</p> <p>The only filament I have used is a spool of PLA (from hatchbox) and a spool of PETG (from sain-smart)</p> <h2>About the Filament</h2> <p>From the time that I replaced the tip, to now, i have only used my 1 spool of <a href="https://rads.stackoverflow.com/amzn/click/com/B00J0ECR5I" rel="nofollow noreferrer" rel="nofollow noreferrer">PLA filament</a>.</p> <p>I don't believe it has any carbon-fiber in it, the only other things I can think of, are that the filament has a tough time sticking to the bed, so I have to print pretty close to the bed.</p> <p><strong>Image of my 3D prints using my PLA filament</strong> <a href="https://i.stack.imgur.com/ntcad.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntcad.jpg" alt="enter image description here" /></a></p> <p><strong>Image of my PLA filament</strong> <a href="https://i.stack.imgur.com/O3PGS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O3PGS.jpg" alt="enter image description here" /></a></p> <hr /> <p>I don't 3D print a terribly large amount, Is it normal to have to be replacing the pen this often?</p> <p>How do I prevent my extruder tip from getting dull so soon? Is there a way to prevent the pen tip from getting dull at all?</p> <p><strong>Actual Images:</strong> (Sorry for all the edits, I’m trying to add the images on my phone and it’s not working) <img src="https://i.stack.imgur.com/lP0Vu.jpg" alt="enter image description here" /></p> <p><img src="https://i.stack.imgur.com/pboTZ.jpg" alt="enter image description here" /></p>
<p>Playing around with the nozzle height will help: back it off until just before you have first layer adhesion issues. Don't jam the filament into the bed as you might for ABS. This helps with small prints. However, my experience has been that if you have a large enough continuous contact area (i.e. more than a few square inches) with the print bed, there will be problems getting the print off. So I still use painters tape (in case I have to rip the print off with force) and glue sticks (so that I don't often need to) on my aluminum print bed as I've found that makes it much easier to deal with without damaging either the bed or the print.</p> <p>You can also try dialing back the heated bed temperature a bit (I think I've got mine set to 70-75c for PETG) but that also doesn't eliminate the issue with larger prints. Also, if I lowered it too much I had problems with first layer adhesion on any size print.</p> <p>I also have a glass plate that I use for ABS, which I don't use with PETG. I've read too many accounts of it sticking too well to glass as well (to the point of the plate being destroyed) and didn't want to try using the amount of force on it that I sometimes have to when removing a PETG print. I also considered trying BuildTak but read accounts of similar issues with it and PETG. So I stayed with what's been working for me: tape and glue sticks.</p>
<p>Correctly level your bed. Seriously, that's the answer. PETG does stick well, but it only gets difficult to remove if you're smashing the first layer against the bed with a nozzle that's way too close. With the bed leveled properly - using feeler gauges or test prints and a sub-0.1-mm-precision caliper - I have no trouble taking PETG prints off a buildtak-clone bed. Glass should be easier.</p> <p>If you already have PETG stuck to a build surface you care about and don't want to risk destroying it, try heat, or alternating heat and cold.</p>
1,778
<p>Here is a scenario: Let's say I have site with two controllers responsible for displaying different type of content - Pages and Articles. I need to embed Partial View into my masterpage that will list pages and articles filtered with some criteria, and be displayed on each page. I cannot set Model on my masterpage (am I right?). How do I solve this task using Html.RenderPartial?</p> <p>[EDIT] Yes, I'd probably create separate partial views for listing articles and pages, but still, there is a barrier that I cannot and shouldn't set model on masterpage. I need somehow to say "here are the pages" as an argument to my renderpartial, and also for articles. Entire concept of renderpartial with data from database in masterpages is a bit blurry to me.</p>
<p>How about creating an HtmlHelper extension method that allows you to call a partial view result on the an action on the controller.</p> <p>Something like</p> <pre><code> public static void RenderPartialAction&lt;TController&gt;(this HtmlHelper helper, Func&lt;TController, PartialViewResult&gt; actionToRender) where TController : Controller, new() { var arg = new TController {ControllerContext = helper.ViewContext.Controller.ControllerContext}; actionToRender(arg).ExecuteResult(arg.ControllerContext); } </code></pre> <p>you could then use this in your master page like</p> <pre><code>&lt;% Html.RenderPartialAction((HomeController x) =&gt; x.RenderPartial()) %&gt; </code></pre> <p>and in your controller the appropriate method</p> <pre><code>public PartialViewResult RenderPartial() { return PartialView("~/Path/or/View",_homeService.GetModel()) } </code></pre> <p>Well that is my 2 cents anyway</p>
<p>The ViewData Model property should only be used for the content that you're viewing/editing on the main section of the UI.</p> <p>Other parts of the view may need some data present in ViewData, so just add those to the dictionary.</p> <p>I'd just pass data from the dictionary like this: ViewData["articles"] to the partial. (or ViewData.Get() from MvcContrib).</p> <p>You might also look at the recently implemented SubController pattern implemented in <a href="http://mvccontrib.org" rel="nofollow noreferrer">MvcContrib</a>.</p>
7,125
<p>I just installed my (v3) BLTouch with a vanilla version of Marlin (1.1.9) on my Ender 3 and everything seems to work fine (including auto home) except the probing. It repeatedly does the first three probes (successfully) but then tries the fourth and fails. Even when disabling the axis movement (X/Y stepper motors) the issue persists, which would indicate that it is not a bad connection or physical location dependent. Any ideas on how to troubleshoot?</p> <p>On second thoughts, it seems that it now fails inconsistently, so it is probably a wiring issue, although there is still the issue of it not retracting before printing and not leveling well when it does (although those issues would be more appropriate for a separate question), among other things.</p> <p>&lt;Edit: Resolved, I both replaced the BLTouch and updated my firmware, but I believe it was the latter that fixed it.&gt;</p>
<p>Is your BL Touch a v3 (likely if you've only just purchased it)? If so, make sure you're using the bugfix version of Marlin 1.1.9, which supposedly fixes the compatibility issues. I say supposedly because there's also a capacitor on the mainboard that can be removed to fix the issue, and once I removed it (and commented out the specific v3 bits in the firmware) the BLTouch performed noticeably better than when relying on the bugfix firmware alone.</p> <p><a href="https://www.youtube.com/channel/UCbgBDBrwsikmtoLqtpc59Bw" rel="nofollow noreferrer">Teaching Tech on YouTube</a> has a few BLtouch Ender 3 videos, covering the changes for configuring the bugfix firmware and the removal of the capacitor.</p>
<p>I've been through the <a href="/q/6959">same sort of issues</a> and eventually found that it was attributed by the cable and connector. Re-check or re-wire the sensor, this helped me out.</p>
1,371
<p>I have a Delphi 7 application that has two views of a document (e.g. a WYSIWYG HTML edit might have a WYSIWYG view and a source view - not my real application). They can be opened in separate windows, or docked into tabs in the main window.</p> <p>If I open a modal dialog from one of the separate forms, the main form is brought to the front, and is shown as the selected window in the windows taskbar. Say the main form is the WYSIWYG view, and the source view is poped out. You go to a particular point in the source view and insert an image tag. A dialog appears to allow you to select and enter the properties you want for the image. If the WYSIWYG view and the source view overlap, the WYSIWYG view will be brought to the front and the source view is hidden. Once the dialog is dismissed, the source view comes back into sight.</p> <p>I've tried setting the owner and the ParentWindow properties to the form it is related to:</p> <blockquote><code>dialog := TDialogForm.Create( parentForm );<br> dialog.ParentWindow := parentForm.Handle; </code></blockquote> <p>How can I fix this problem? What else should I be trying?</p> <p>Given that people seem to be stumbling on my example, perhaps I can try with a better example: a text editor that allows you to have more than one file open at the same time. The files you have open are either in tabs (like in the Delphi IDE) or in its own window. Suppose the user brings up the spell check dialog or the find dialog. What happens, is that if the file is being editing in its own window, that window is sent to below the main form in the z-order when the modal dialog is shown; once the dialog is closed, it is returned to its original z-order.</p> <p><b>Note</b>: If you are using Delphi 7 and looking for a solution to this problem, see my answer lower down on the page to see what I ended up doing.</p>
<p>I'd use this code... (Basically what Lars said)</p> <pre><code>dialog := TDialogForm.Create( parentForm ); dialog.PopupParent := parentForm; dialog.PopupMode := pmExplicit; dialog.ShowModal(); </code></pre>
<p>First of all, I am not completely sure I follow, you might need to provide some additional details to help us understand what is happening and what the problem is. I guess I am not sure I understand exactly what you're trying to accomplish and what the problem is.</p> <p>Second, you shouldn't need to set the dialog's parent since that is essentially what is happening with the call to Create (passing the parent). The dialogs you're describing sound like they could use some "re-thinking" a bit to be honest. Is this dialog to enter the properties of the image a child of the source window, or the WYSIWYG window?</p>
4,186
<p>I am a developer. An architect on good days. Somehow I find myself also being the DBA for my small company. My background is fair in the DB arts but I have never been a full fledged DBA. My question is what do I have to do to ensure a realiable and reasonably functional database environment with as little actual effort as possible?</p> <p>I am sure that I need to make sure that backups are being performed and that is being done. That is an easy one. What else should I be doing on a consistant basis? </p>
<p>Who else is involved in the database? Are you the only person making schema changes (creating new objects, releasing new stored procedures, permissioning new users)? </p> <ul> <li>Make sure that the number of users doing anything that could impact performance is reduced to as close to zero as possible, ideally including you. </li> <li>Make sure that you're testing your backups - ideally run a DEV box that is recreating the production environment periodically, 1. a DEV box is a good idea, 2. a backup is only useful if you can restore from it. </li> <li>Create groups for the various apps that connect to your database, so when a new user comes along you don't guess what permissions they need, just add them to the group, meanwhile permission the database objects to only the groups that need them </li> <li>Use indices, primary keys, foreign keys, constraints, stats and whatever other tools your database supports. Normalise. </li> <li>Optimise the most common code against your box - bad stored procedures/data access code will kill you. </li> </ul>
<p>I would suggest:</p> <ul> <li>A script to quickly restore the latest backup of a database, in case it gets corrupted</li> <li>What kind of backups are you doing? Full backups each day, or incremental every hour, etc?</li> <li>Some scripts to create new users and grant them basic access.</li> </ul> <p>However, the number one suggestion is to limit as much as possible the power other users have, this will greatly reduce the chance of stuff getting badly messed up. Servers that have everyone as an sa tend to get screwed up quicker than servers that are locked down.</p>
5,582
<p>If I have a Resource bundle property file:</p> <p>A.properties:</p> <pre><code>thekey={0} This is a test </code></pre> <p>And then I have java code that loads the resource bundle:</p> <pre><code>ResourceBundle labels = ResourceBundle.getBundle("A", currentLocale); labels.getString("thekey"); </code></pre> <p>How can I replace the {0} text with some value</p> <pre><code>labels.getString("thekey", "Yes!!!"); </code></pre> <p>Such that the output comes out as:</p> <pre><code>Yes!!! This is a test. </code></pre> <p>There are no methods that are part of Resource Bundle to do this. Also, I am in Struts, is there some way to use MessageProperties to do the replacement.</p>
<p>The class you're looking for is java.text.MessageFormat; specifically, calling</p> <pre><code>MessageFormat.format("{0} This {1} a test", new Object[] {"Yes!!!", "is"}); </code></pre> <p>or</p> <pre><code>MessageFormat.format("{0} This {1} a test", "Yes!!!", "is"); </code></pre> <p>will return</p> <pre><code>"Yes!!! This is a test" </code></pre> <p>[Unfortunately, I can't help with the Struts connection, although <a href="http://www.jguru.com/faq/view.jsp?EID=915891" rel="noreferrer">this</a> looks relevant.]</p>
<p>There is the class <a href="http://struts.apache.org/1.2.7/api/org/apache/struts/util/MessageResources.html" rel="nofollow noreferrer">org.apache.struts.util.MessageResources</a> with various methods getMessage, some of them take arguments to insert to the actual message.</p> <p>Eg.:</p> <pre><code>messageResources.getMessage("thekey", "Yes!!!"); </code></pre>
9,354
<p>I have a foxpro app, that contains hard coded path for icons and bitmaps. That's how foxpro does it and there is no way around it. And this works fine, except that when a removable drive has been used but is not connected, and when is connected windows assigns the same letter as hard coded path, when opening any form that contains such path, the following error message apears (<strong>FROM WINDOWS</strong>, not fox):</p> <p>Windows-No disk Exception Processing Message c0000012 Parameters .....</p> <p>Any help please Nelson Marmol</p>
<p>Nelson:</p> <p>"That's how foxpro does it and there is no way around it"?</p> <p>I'm using FOX since FoxPro 2.5 to Visual FoxPro 9, and you are NEVER forced in any way to hard-code a path, you can use SET PATH TO (sYourPath), you can embed the icons and bitmaps in your EXE / APP file and therefore there's no need of including this resources externally.</p> <p>You say that you have a "Foxpro App": which version? Old MS-DOS FoxPro o Visual FoxPro? If you're using VFP 8+, you can use SYS(2450, 1):</p> <pre><code>Specifies how an application searches for data and resources such as functions, procedures, executable files, and so on. You can use SYS(2450) to specify that Visual FoxPro searches within an application for a specific procedure or user-defined function (UDF) before it searches along the SET DEFAULT and SET PATH locations. Setting SYS(2450) can help improve performance for applications that run on a local or wide area network. SYS(2450 [, 0 | 1 ]) Parameters 0 Search along path and default locations before searching in the application. (Default) 1 Search within the application for the specified procedure or UDF before searching the path and default locations. </code></pre> <p>One quick workaround could be assign another letter to your USB via the Disk Manager.</p>
<p>I agree with @PabloG - it's been over a decade since I worked with FoxPro (Dos &amp; Windows) but even back in FPW2.6 you could determine where your app was running 'from', set absolute or relative search paths and even bundle your resources straight into the "compiled" (heh) exe. All of our resources lived in a specific subfolder within the app folder, the database files in another subfolder also below the app folder. We used relative paths for everything as I recall.</p> <p>Can you give us a bit more information about the problem?</p> <p>If you think it would be helpful I could try and dig out some of our FPW2.6 code where we're doing this kind of thing. :-)</p>
8,037
<p>Specifically this is regarding when using a client session cookie to identify a session on the server.</p> <p>Is the best answer to use SSL/HTTPS encryption for the entire web site, and you have the best guarantee that no man in the middle attacks will be able to sniff an existing client session cookie?</p> <p>And perhaps second best to use some sort of encryption on the session value itself that is stored in your session cookie?</p> <p>If a malicious user has physical access to a machine, they can still look at the filesystem to retrieve a valid session cookie and use that to hijack a session?</p>
<p>Encrypting the session value will have zero effect. The session cookie is already an arbitrary value, encrypting it will just generate another arbitrary value that can be sniffed.</p> <p>The only real solution is HTTPS. If you don't want to do SSL on your whole site (maybe you have performance concerns), you might be able to get away with only SSL protecting the sensitive areas. To do that, first make sure your login page is HTTPS. When a user logs in, set a secure cookie (meaning the browser will only transmit it over an SSL link) in addition to the regular session cookie. Then, when a user visits one of your "sensitive" areas, redirect them to HTTPS, and check for the presence of that secure cookie. A real user will have it, a session hijacker will not.</p> <p><strong>EDIT</strong>: This answer was originally written in 2008. It's 2016 now, and there's no reason not to have SSL across your entire site. No more plaintext HTTP!</p>
<p>Protect by:</p> <pre><code>$ip=$_SERVER['REMOTE_ADDER']; $_SESSEION['ip']=$ip; </code></pre>
4,290
<p>I want to be able to control my FLSUN QQ over Wi-Fi and don't have OctoPrint or a Raspberry Pi to run it on.</p>
<p>Assuming you use Ultimaker Cura to slice, there is a MKS plugin that allows connecting to the MKS WiFi module that comes with the QQ. Just follow these steps:</p> <p><strong>Install the MKS WiFi Plugin</strong></p> <ol> <li>Open Cura</li> <li>Click "Marketplace" in top right</li> <li>Select "Plugins"</li> <li>Scroll down to find the "MKS WiFi Plugin"</li> <li>Click on the plugin.</li> <li>Click "Install"</li> <li>Restart Cura (quit and reopen)</li> </ol> <p><strong>Configure WiFi</strong> </p> <ol> <li>Turn on your QQ</li> <li>Tap Settings</li> <li>Tap WiFi</li> <li>Enable WiFi</li> <li>Note the IP address and network name</li> <li>Connect your computer to the printers network</li> <li>Open your browser</li> <li>type the IP address of your printer into the address bar</li> <li>hit enter</li> <li>Scroll down to "WIFI Configuration"</li> <li>Select STA</li> <li>Enter your home network SSID into the field labeled "WIFI"</li> <li>Enter the password into the field labeled "KEY"</li> <li>Click configure and reboot</li> </ol> <p><strong>Setup your printer in Cura</strong></p> <ol> <li>Open Cura</li> <li>Open settings > Printer > Manage Printers...</li> <li>Click "MKS Wifi"</li> <li>Click "Add"</li> <li>Enter the new IP address of your printer (can be found by opening WiFi settings on the printer)</li> <li>Click Ok 7, Click connect.</li> </ol> <p>Now you should be connected to your printer. After slicing you should have the option to "Print over FLSUN..." In the Monitor interface you should have some other options such as sending commands to the printer, and printing any files already on the SD card, as well as uploading gcode files to the SD card. </p> <p>Happy Printing</p>
<p>As the auto-install from the Marketplace described in <a href="https://3dprinting.stackexchange.com/a/13753">this answer</a> wasn't working , I did have to manually install the MKS WiFi plugin on my Mac (M1 MBPro). To do this I just:</p> <ol> <li>Downloaded the GitHub files (from the plugin webpage, linked in the Marketplace)</li> <li>Right-clicked the Cura icon in the Applications folder, to show package contents</li> <li>I then went into the macOS folder and followed the plugin link</li> <li>Copy the downloaded GitHub files</li> <li>Restart Cura</li> </ol> <p>I then just followed the printer setup advice in Cura from <a href="https://3dprinting.stackexchange.com/a/13753">this answer</a>.</p> <p>No more messing around with SD cards :)</p>
1,675
<p>By "generate", I mean auto-generation of the code necessary for a particular selected (set of) variable(s).</p> <p>But any more explicit explication or comment on good practice is welcome.</p>
<p>Rather than using <kbd>Ctrl</kbd> + <kbd>K</kbd>, <kbd>X</kbd> you can also just type <code>prop</code> and then hit <kbd>Tab</kbd> twice.</p>
<p>You just simply press <kbd>Alt</kbd> + <kbd>Ins</kbd> in Android Studio. </p> <p>After declaring variables, you will get the getters and setters in the generated code.</p>
2,514
<p>What is the best way to handle user account management in a system, without having your employees who have access to a database, to have access to the accounts.</p> <p>Examples:</p> <ol> <li><p>Storing username/password in the database. This is a bad idea because anyone that has access to a database can see the username and password. And hence use it.</p></li> <li><p>Storing username/password hash. This is a better method, but the account can be accessed by replacing the password hash in the database with the hash of another account that you know the auth info for. Then after access is granted reverting it back in the database. </p></li> </ol> <p>How does windows/*nix handle this?</p>
<blockquote> <p>This is a better method, but the account can be accessed by replacing the password hash in the database with the hash of another account that you know the auth info for.</p> </blockquote> <p>There's really no way around this. Anyone who as write access to the password file has complete control of the computer. </p>
<p>You could store the <em>salt</em> for the hashed password in another table, of course each user would have their own salt. You could then limit access to that table.</p>
8,574
<p>I've been trying to print anything for the past few days. Every time I go to print something the printer stops pushing plastic out and usually the motor makes a knocking sound.</p> <p>My original thought was that my E-steps were off (because they were) but I solved that and I still have a problem. Then I noticed that I was struggling with getting the PLA filament to feed into the nozzle. I assumed it was a clogged nozzle and possibly heat creep (because I was a dummy and used my old, bowden retraction settings on my new, direct extruder). I cleared out the clog and I'm able to feed plastic through after disengaging the idler arm. Though, I do struggle getting the filament into the nozzle. Maybe it's due to the Hemera's tight tolerances or due to a misalignment in the hot end, I'm not sure yet. Once I do get the plastic in, it quickly and easily pushes through and spits out of the nozzle so I think that my nozzle isn't clogged. I did do a cold pull the other day. </p> <p>But I've noticed that my extruder is making a knocking sound, as if someone was gently rapping on my chamber door. I also see that the gears move one step back and forth. It looks to me that the motor is stuck or frozen. I'm pretty sure that it's not skipping steps. The sound happens at varying heights and not just the first layer. The first time I noticed it, it was printing the cabin of Benchy. Z > 1 mm when I finally decided to ask this question. The sound is kind of loud, but that's most likely the resonance in the machine than a symptom, stating it nonetheless. </p> <h2>My setup:</h2> <ul> <li><strong>Printer:</strong> Creality CR-10S </li> <li><strong>Extruder:</strong> E3D Hemera </li> <li><strong>Nozzle temp:</strong> 205-220&nbsp;°C</li> <li><strong>Retraction:</strong> Initially 5&nbsp;mm at 40&nbsp;mm/s, then 0.3&nbsp;mm, then most recently none </li> <li><strong>Motor Vref:</strong> just north of 800&nbsp;mA. (I've read somewhere that the Hemera motor wants 800&nbsp;to 1000&nbsp;mA) </li> </ul> <p>I'm just not sure what could be wrong here. I feel like I checked all the steps and I'm just missing something. </p>
<p>A knocking or clicking sound does not imply you <strong>have a problem</strong>, it implies that you <strong>could have a problem</strong>; it can be the characteristic of the extruder. </p> <hr> <p><em>My own designed 2.85&nbsp;mm filament, 1:4 speed reducing <a href="https://www.thingiverse.com/thing:2897762" rel="nofollow noreferrer">belt driven extruders</a> make clicking sounds while extruding (independent of the layer height), I have verified that no steps are lost and the printer extrudes exactly the requested amount of filament (2.85&nbsp;mm filament requires a lot more pressure for the same nozzle size, the noise is coming from inside of the metal Bulldog housing, not the stepper adjacent, it is not stepper nor filament skipping noise).</em> </p> <hr> <p>A clicking sound in combination with gears losing position as you describe (or filament skipping back) does mean that the pressure in the nozzle is too big for the extruder to push it through. If the gears loose position, this means that the stepper is not powerful enough to push it through, this means that more current or a more powerful stepper is required (the latter option is due to the design of the extruder not possible). If the filament skips back while the gears are in place the tension/grip to the filament needs to be increased. </p> <p>In troubleshooting this problem it is best to increase the current to the stepper close to the upper side of the specifications of the stepper and see if the knocking sounds disappear. This should not be a problem for such a priced and tested extruder system, i.e. considering the reputation and quality of E3D this extruder must work out of the box unless you have received damaged components.</p>
<p>I had a bad connection at my motor that was causing the problem. I soldered direct to the motor and no more problems.</p>
1,559