instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>Is there an easy way to return data to web service clients in JSON using Rails?</p>
<p>Rails resource gives a RESTful interface for your model. Let's see.</p> <h1>Model</h1> <pre><code>class Contact &lt; ActiveRecord::Base ... end </code></pre> <h1>Routes</h1> <pre><code>map.resources :contacts </code></pre> <h1>Controller</h1> <pre><code>class ContactsController &lt; ApplicationController ... def show @contact = Contact.find(params[:id] respond_to do |format| format.html format.xml {render :xml =&gt; @contact} format.js {render :json =&gt; @contact.json} end end ... end </code></pre> <p>So this gives you an API interfaces without the need to define special methods to get the type of respond required</p> <p>Eg.</p> <pre><code>/contacts/1 # Responds with regular html page /contacts/1.xml # Responds with xml output of Contact.find(1) and its attributes /contacts/1.js # Responds with json output of Contact.find(1) and its attributes </code></pre>
<p>ActiveRecord also provides methods to interact with JSON. To create JSON out of an AR object, just call object.to_json. TO create an AR object out of JSON you should be able to create a new AR object and then call object.from_json.. as far as I understood, but this did not work for me.</p>
8,200
<p>How does Z offset (<code>M851</code>) work with an auto leveling sensor? Does it add the Z offset to the offset of the <code>G29</code> mesh? or the <code>G29</code> value replaces the <code>M851</code>?</p> <p>My printer is an Anet A8 with Marlin firmware, I was having issues with the autoleveling sensor and reset the Z offset to 0 and let <code>G29</code> get the mesh offsets and its working good now.</p> <p>I was looking through Marlin G-code page but couldn't figure out how <code>G29</code> affects <code>M851</code> or vice-versa.</p> <p>My setup with level issues:</p> <pre><code>M851 Z0 G28 M211 S0 ;turned endstops off and got a paper to find the zoffset M851 Z-0.59 M500 M211 S1 </code></pre> <p>And <code>G29</code> before printing.</p>
<p><code>G28</code> instructs the printer to home itself to the X an Y endstops and the Z sensor determines the homing of the Z axis; i.e. when the sensor triggers, this is not necessarily (and most commonly) not the position where the nozzle is at Z=0.</p> <p><code>G29</code> determines the shape of the bed by probing the bed. This will set the shape of the bed with respect to the sensor trigger point as described earlier. The Z-offset (set by <code>M851 Z-x.xx</code> is needed to set the offset between the nozzle and the sensor trigger point (to the bed).</p> <p>The sequence to determine the offset is:</p> <pre><code>M851 Z0; // Set the Z offset to zero height G28; // Home Z in the middle of the bed G1 Z0; // This will move the head to zero height; M211 S0; // This will disable the end stops so that you // will be able to proceed lower than Z=0 </code></pre> <p>Now adjust Z height to fit a piece of paper and note the negative Z height (either through the LCD or through an application or <a href="/q/10573">console/terminal</a> over USB)</p> <p><em>Please remember, that a sensor doesn't level your bed, is compensates for the shape, the user should always tram (level) the bed as good as possible with respect to the nozzle print head movement plane! This implies that the user should tram the complete bed as good as the skills allow, all corners, like you would do with a normal Z endstop switch.</em></p> <pre><code>M851 Z-1.23; // Define the Z offset M500; // Store the settings M211 S1; // Enable the end stops again </code></pre> <p>Please note that -1.23 is a fictive value that should be replaced by your own value.</p> <p>To explicitly answer the raised question, the <code>G29</code> probes the bed by scanning the surface geometry and the <code>M851</code> adds an offset for the sensor trigger to the nozzle (at the center). The offset is required to let the firmware know where the nozzle is with respect to the trigger point. The offset therefor lowers the scanned <code>G29</code> surface, no replacement is taking place. The sketches below illustrate this:</p> <p><a href="https://i.stack.imgur.com/wdto7.png" rel="nofollow noreferrer" title="BLTouch or 3DTouch sensor Z-offset definition"><img src="https://i.stack.imgur.com/wdto7.png" alt="BLTouch or 3DTouch sensor Z-offset definition" title="BLTouch or 3DTouch sensor Z-offset definition" /></a></p> <p><a href="https://i.stack.imgur.com/2sGwU.png" rel="nofollow noreferrer" title="Inductive/capacitive proximity sensor Z-offset definition"><img src="https://i.stack.imgur.com/2sGwU.png" alt="Inductive/capacitive proximity sensor Z-offset definition" title="Inductive/capacitive proximity sensor Z-offset definition" /></a></p> <p><em>note that the bottom line of the &quot;M851 Z offset&quot; denotes the <code>G29</code> scanned surface</em></p>
<p>You must use the sequence </p> <pre><code>G28 G29 </code></pre> <p>If you do <code>G28</code> after <code>G29</code> it will reset bed leveling. I guess you don't want that.</p> <p>On my printer deployed z-probe falls 2.3&nbsp;mm lower than nozzle. In printer settings I've therefore stored static Z-offset of -2.3&nbsp;mm, so after <code>G28</code> and <code>G29</code> I can be sure that when ever I tell Z-axis to lower to zero, it can go down -12.3&nbsp;mm, coming to stop at around 0.1&nbsp;mm above the bed surface (so just a single sheet of paper fits between the nozzle and the bed).</p> <p>That said, I'm not worrying about sending the Z-offset via print commands, as restart restores the aforementioned -2.3&nbsp;mm offset.</p>
882
<p>I've found out how to convert errors into exceptions, and I display them nicely if they aren't caught, but I don't know how to log them in a useful way. Simply writing them to a file won't be useful, will it? And would you risk accessing a database, when you don't know what caused the exception yet?</p>
<p>You could use <a href="http://www.php.net/manual/en/function.set-error-handler.php" rel="noreferrer">set_error_handler</a> to set a custom exception to log your errors. I'd personally consider storing them in the database as the default Exception handler's backtrace can provide information on what caused it - this of course won't be possible if the database handler triggered the exception however.</p> <p>You could also use <a href="http://www.php.net/manual/en/function.error-log.php" rel="noreferrer">error_log</a> to log your errors. It has a choice of message destinations including:</p> <blockquote> <p>Quoted from <a href="http://www.php.net/manual/en/function.error-log.php" rel="noreferrer">error_log</a></p> <ol> <li>PHP's system logger, using the Operating System's system logging mechanism or a file, depending on what the error_log configuration directive is set to. This is the default option.</li> <li>Sent by email to the address in the destination parameter. This is the only message type where the fourth parameter, extra_headers is used.</li> <li>Appended to the file destination . A newline is not automatically added to the end of the message string.</li> </ol> </blockquote> <p><em>Edit: Does markdown have a noparse tag for underscores?</em></p>
<p>I think it depends a lot of where your error occured. If the DB is down logging it to the DB is no good idea ;)</p> <p>I use the <a href="http://php.net/syslog" rel="nofollow noreferrer">syslog()</a> function for logging the error, but I have no problems writing it to a file when I'm on a system which has no syslog-support. You can easily set up your system to send you an email or a jabber message using for example <a href="http://www.logwatch.org/" rel="nofollow noreferrer">logwatch</a> or <a href="http://www.johnandcailin.com/blog/john/how-setup-real-time-email-notification-critical-syslog-events" rel="nofollow noreferrer">the standard syslogd</a>.</p>
4,069
<p>In my base page I need to remove an item from the query string and redirect. I can't use<br/></p> <pre><code>Request.QueryString.Remove("foo") </code></pre> <p>because the collection is read-only. Is there any way to get the query string (except for that one item) without iterating through the collection and re-building it?</p>
<p>You'd have to reconstruct the url and then redirect. Something like this:</p> <pre><code>string url = Request.RawUrl; NameValueCollection params = Request.QueryString; for (int i=0; i&lt;params.Count; i++) { if (params[i].GetKey(i).ToLower() == "foo") { url += string.Concat((i==0 ? "?" : "&amp;"), params[i].GetKey(i), "=", params.Get(i)); } } Response.Redirect(url); </code></pre> <p>Anyway, I didn't test that or anything, but it should work (or at least get you in thye right direction)</p>
<p>Can you clone the collection and then redirect to the page with the cloned (and modified) collection?</p> <p>I know it's not much better than iterating...</p>
7,520
<p>I'm considering using Flash but I'm pretty addicted to autocomplete and Step-at-a-time debugging.</p>
<p>By using Eclipse with the ActionScript plugin you get full code hinting in the same format that you do with intellisense. </p> <p>Or you can use <a href="http://www.flashdevelop.org/community/" rel="nofollow noreferrer">FlashDevelop</a> that has both intellisense and can <a href="http://www.flashdevelop.org/community/viewtopic.php?p=6105" rel="nofollow noreferrer">debug (trace) your code</a>.</p>
<p>If you mean ActionScript I once heard that <a href="http://www.primalscript.com/" rel="nofollow noreferrer">PrimalScript</a> will do Intellisense. Never tested it though. As for debugging, MAYBE, <a href="http://www.primalscope.com/" rel="nofollow noreferrer">PrimalScope</a> will have that too. I'd recommend you try before you buy, though. (They both have trials.)</p>
7,168
<p>We need a 3D printer, that can print with plastic suitable for medical applications. We have about $5000 for the printer. What printers can we choose? I am not a specialist in 3D printing, so please answer in detail. </p> <p>We need to print breathing tubes with cuffs. The tubes should be flexible, but rigid enough in order not to collapse. The cuff material should be thin and collapsible, but very strong. Breathing tubes are inserted through the mouth and stay in contact with mucous membrane for many hours.</p>
<p>I am not an expert but I think you will find that because 3D printers use a layer by layer construction method, and the boundary between the layers creates grooves along the surface or leaves a rough texture on the surface. That the textured surface left by 3D printer construction would trap microbes and make 3D printed objects not suitable for medical applications where you need the product to be sterile. </p> <p>It might be possible to treat the printed object or post process it. By vapor smoothing or painting/coating, but I doing think this would work for flexible materials. </p> <p>If you are considering 3D printing because of the ability to customize the design, then I would suggest considering combining 3D printing with molding or casting. You could then use a cheap 3D printer to create the mold and use a flexible resin to create the object you want. </p> <p>I have heard of SLA 3D printing being used to create molds for casting fake teeth. There 3D printing is used to create a custom shape and the print is used to make a mold and the final product is cast using the mold to get the quality and finish needed.</p> <p>And I have head of FDM printing being used in used in remote areas to print clamps for umbilical cords. But I believe this was because not no other option was available. </p>
<p>Find another medical facility that is doing it, and ask what equipment and filament they use. They may also have a source for medical related models.</p> <p>I would expect medical stuff to be regulated by the FDA, so there are probably limitations on what you can get.</p>
731
<p>On one of the nozzles on my printer, the filament comes out at a 45 degree angle. It seems that this causes problems with adhesion to the bed and overall quality.</p> <ul> <li>What caused this problem? </li> <li>How do I fix it? </li> <li>How do I prevent it from happening in the future?</li> </ul>
<p>I've personally had this happen when I had a minor clog in my nozzle. </p> <p>My first steps to fix this would be:</p> <ol> <li>Make sure the exterior of your nozzle is clean. I've had bits of plastic pull at the extruding filament and change it's direction.</li> <li>Attempt a "cold pull" or "<a href="http://support.3dverkstan.se/article/10-the">atomic pull</a>". On my Replicator 2 I do this by removing the extruder motor, heating up the hot end, manually pushing a length of filament through the nozzle, letting it cool slightly and tugging the filament (and hopefully the clog) out of the nozzle.</li> </ol>
<p>You very likely have partial clog in your hotend (the side which is clogged is the angle the extruding filament bends to) or have some plastic somehow stuck on the nozzle surface which the extruding plastic almost sticks to, like two droplets of water merging into one.</p> <p>If its the latter, clean the hotend. It's easier to remove the plastic on it while its hot and soft, but don't burn yourself.</p> <p>If it's a clog, that's more complicated. First, you can make sure if it is indeed a clog or not by extruding into the air and measuring the wire with a caliper. If it's thinner than it should be and your slicer settings are fine, then its a clog.</p> <p>Ways to get rid of clog:</p> <p>1) Replace the nozzle with a new one.</p> <p>2) Break the clog with a sharp wire.</p> <p>3) Take the hotend off and clean the nozzle with acetone ("acetone bath").</p> <p>4) Blow torch on a removed nozzle. Dangerous thing to do for some but it works. If you're not confident or experienced to do this and the previous two solutions don't help, then go with option 1.</p>
165
<p>I don't ever recall coming across anything for C that's as extensive as C++'s Boost library.</p>
<p>You can have a look at glib. It provides quite a few interesting things like containers, unicode support, threading...</p> <p>Have a look at <a href="http://library.gnome.org/devel/glib/stable/" rel="noreferrer">its documentation</a> </p>
<p>ACE (Adaptive Communication Environment) is sometimes mentioned. It's not quite an apples-to-apples comparison. Boost provides more "basic building blocks" whereas ACE provides more of an tightly integrated framework geared towards telco products. I have used both extensively and I find Boost vastly superior. One big advantage of Boost is that many of its features will show up in the STL extensions for the upcoming C++0x standard (see, for example, <a href="http://en.wikipedia.org/wiki/Technical_Report_1" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Technical_Report_1</a>).</p>
7,569
<p>Does anyone use <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a> to deploy PHP applications, and if so how do you use it? We currently have a hand-written "setup" script that we run whenever we deploy a new instance of our project. We just check out from SVN and run it. It sets some basic configuration variables, installs or reloads the database, and generates a v-host for the site instance.</p> <p>I have often thought that maybe we should be using <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a>. I haven't used ant much, so I don't have a real sense of what <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a> is supposed to do other than script the copying of files from one place to another much as our setup script does. What are some more advanced uses that you can give examples of to help me understand why we would or would not want to integrate <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a> into our process?</p>
<p>From Federico Cargnelutti's <a href="http://phpimpact.wordpress.com/2007/06/30/phing-php-project-build-system-based-on-apache-ant/" rel="noreferrer">blog post</a>:</p> <blockquote> <p>Features include file transformations (e.g. token replacement, XSLT transformation, Smarty template transformations), file system operations, interactive build support, SQL execution, CVS operations, tools for creating PEAR packages, and much more.</p> </blockquote> <p>Of course you could write custom scripts for all of the above. However, using a specialized build tool like Phing gives you a number of benefits. You'll be using a proven framework so instead of having to worry about setting up "infrastructure" you can focus on the code you need to write. Using Phing will also make it easier for when new members join your team, they'll be able to understand what is going on if they've used Phing (or Ant, which is what Phing is based on) before.</p>
<p>I don't see any compelling reason to go with phing. I mean, should PHP programmers attempt a rewrite of Eclipse "just because" it might somehow be easier to write Eclipse plugins in PHP? I don't think so.</p> <p>Ant has better documentation, including some nice o'reilly books, and it's well-established in the Java universe, so you avoid the problems of (1) "we haven't copied feature X to phing yet" and (2) the risk of the phing project going dead. <a href="http://nohn.net/blog/view/id/cruisecontrol_ant_and_phpunit" rel="nofollow noreferrer">Here's</a> an article on configuring PHPUnit to work with ant and cruisecontrol: not that hard. And you get eclipse integration for free.</p> <p>Good luck!</p>
5,725
<p>I'm working on an ASP.NET website which targets desktop browsers. We want to enable an optional mobile view (e.g. <a href="http://m.sample.com" rel="nofollow noreferrer">http://m.sample.com</a>) which will offer a few simple pages which will be mostly text. There will be not need for AJAX or even Javascript, and there's no user input - it's really just tables of text with a few links to navigate between the pages.</p> <p>What's the best way to set this up so it will work on Blackberry, Windows Mobile, and iPhone?</p> <p>Should I be looking at <a href="http://www.asp.net/mobile/" rel="nofollow noreferrer">ASP.NET Mobile</a> support, or just rolling my own pages?</p> <p><strong>UPDATE</strong>: This was for m.microsoftpdc.com. We went with the /Mobile subfolder approach, and used <a href="http://www.hanselman.com/blog/MakeYourWebsiteMobileAndIPhoneFriendlyAddHomeScreenIPhoneIconsAndAdjustTheViewPort.aspx" rel="nofollow noreferrer">Scott Hanselman's iPhone tips for viewport and other stuff</a>.</p>
<p>I have done this in the past and the way I did it is by separating the pages by creating a directory for Desktop and creating a directory for Mobile. This gives you better separation of the views, since in reality they are a lot different. In ASP.NET Forms I used the <a href="http://msdn.microsoft.com/en-us/magazine/cc188690.aspx" rel="nofollow noreferrer">Model View Presenter</a> pattern a lot since it went with the way ASP.NET Forms functioned the best. That way I could reuse some code between the two views. Then in your index.aspx page for the site, you just parse the user-agent string of the request to figure out the browser and redirect accordingly. So, for example a person with an iphone comes to your site, you parse the <a href="http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/chapter_3_section_3.html" rel="nofollow noreferrer">user-agent string</a> and figure out it is an iphone. Then you redirect to m.sample.com which is pointing to Mobile/Index.aspx page. Otherwise you redirect to Desktop/Index.aspx.</p> <p>I did the parsing of the user-agent string at the page level, but of course you could do this kind of logic in the HttpModule or HttpHandler level also.</p> <h2>Edit</h2> <p>I just rolled my own pages since we weren't targeting phones that have WML support. That would be the only reason in my opinion to use the ASP.NET Mobile support, is if you want to support WML enabled phones also.</p>
<p>I know from personal experience there really isn't much you need to do for the iPhone. I usually rather just browse your regular site with my iPhone. </p> <p>Just my two cents though.</p>
8,400
<p>We have a SQL server database. To manipulate the data non-programmatically, I can use SQL Server Management Studio by right-clicking a table and selecting "Open Table". However this is slow for very large tables and sorting and filtering is cumbersome.</p> <p>Typically what we have done until now is to create an Access database containing linked tables which point to the SQL Server tables and views. Opening a large table is much faster this way, and Access has easy-to-use right-click filtering and sorting.</p> <p>However, since Access 2007, sorting in particular has been quite slow when working with large tables. The Access database can also inadvertently lock the database tables, blocking other processes that may need to access the data. Creating the Access database in the first place, and updating it when new tables are added to SQL Server, is also tedious.</p> <p>Is there a better way to work with the data that offers the usability of Access without its drawbacks?</p>
<p>Joel Coehoorn's answer is of course correct, that if the data is critical or there are naive users using the data, then a application front end should be developed. That being said, I have cases where a wise user (ok, me) user needs to just get in there and poke around. </p> <p>Instead of directly looking at the tables, use MS Access but use queries to narrow down what you're looking at both column wise and row wise. That will improve the speed. Then edit the query properties and make sure that the query is No Locks. That should eliminate any blocking behavior. You may want to limit the number of rows returned which again will improve the speed. You can still edit the data in the query as you look at it.</p> <p>Depending on what you're looking at, it may also be useful to set up database Views in the SQL Server to do some of the heavy lifting on the server rather than on the client.</p>
<p>Editing raw data is a dangerous no-no. Better to identify the situations where you find yourself doing that and put together an application interface to act as an intermediary that can prevent you from doing stupid things like breaking a foreign key.</p>
6,156
<p>I decided to make a system for a client using <a href="https://web.archive.org/web/20080517021542/http://www.castleproject.org/activerecord/index.html" rel="nofollow noreferrer">Castle ActiveRecord</a>, everything went well until I found that the transactions do not work, for instance;</p> <pre><code> TransactionScope t = new TransactionScope(); try { member.Save(); //This is just to see transaction working throw new Exception("Exception"); foreach (qfh.Beneficiary b1 in l) { b1.Create(); } } catch (Exception ex) { t.VoteRollBack(); MessageBox.Show(ex.Message); } finally { t.Dispose(); } </code></pre> <p>But it doesn't work, I throw an Exception just to try the transaction rolls back, but for my surprise I see that the first [Save] records into the database. What is happening?</p> <p>I'm new on Castle and NHibernate, firstly I saw it very attractive and I decided to go on with it and MySQL (I've never worked with this DB), I tried ActiveWriter and it seemed very promising but after a long and effortly week I see this issue and now I feel like I'm stuck and like I've wasted my time. It is supposed to be easy but right now I'm feeling a frustated cause I cannot find enough information to make this workout, can you help me?</p>
<p>Ben's got it. That doc is a little confusing. Refer to the last block <a href="https://web.archive.org/web/20080417014143/http://www.castleproject.org/ActiveRecord/documentation/v1rc1/usersguide/scopes.html" rel="nofollow noreferrer">on the page</a>, "Nested transactions". </p>
<p>I finally fixed, it happened that I was doing wrong, I overrode the Save method of the Member class and made sessionScope inside and inside of it a transaction scope, so when a involved all of that in a transaction scope it saved in the database, so when I threw the exception everything was already saved, I think that's it.</p> <p>All in all, thanks for the help.</p>
5,968
<p>I wrote a script to export twitter friends as foaf rdf description. Now I'm looking for a tool to visualize the friend networks. I tried <a href="http://foafscape.berlios.de/" rel="nofollow noreferrer">http://foafscape.berlios.de/</a> but for 300+ Nodes it is really slow and does a bad job on auto formatting.</p> <p>Any hints for good graph visualization tools? It's ok if they do not support foaf directly, but they should be able to use images for graph nodes and be able to display large graphs. Linux support would be nice.</p> <p>Oh, and I'm searching for an interactive tool where I can move nodes by hand.</p> <p><strong>Update:</strong> Thanks for your input. I know graphviz and for static images it is really great. But for large datasets I need to be able to select nodes and highlight all neighbours. </p> <ul> <li><strong>Prefuse</strong> looks great: <a href="http://prefuse.org/gallery/graphview/" rel="nofollow noreferrer">http://prefuse.org/gallery/graphview/</a></li> <li>trough prefuse I found <strong>vizster</strong>, which is exactly what I search (just need to find some sourcecode) <a href="http://jheer.org/vizster/" rel="nofollow noreferrer">http://jheer.org/vizster/</a></li> </ul>
<p>perhaps the <a href="http://prefuse.org/" rel="noreferrer">prefuse</a> visualization toolkit might help you. It's based on Java and has many sample apps including a <a href="http://prefuse.org/gallery/graphview/" rel="noreferrer">graph viewer</a>.</p>
<p>If you're using Java, you could use <a href="http://www.jgraph.com/" rel="nofollow noreferrer">JGraph</a>.</p>
9,979
<p>From question <em><a href="https://stackoverflow.com/questions/71323/how-to-replace-a-character-for-a-newline-in-vim">How to replace a character for a newline in Vim?</a></em>. You have to use \r when replacing text for a newline, like this</p> <pre><code>:%s/%/\r/g </code></pre> <p>But when replacing end of lines and newlines for a character, you can do it like:</p> <pre><code>:%s/\n/%/g </code></pre> <p>What section of the manual documents these behaviors, and what's the reasoning behind them?</p>
<p>From <a href="http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cr" rel="noreferrer">vim docs on patterns</a>:</p> <blockquote> <p><code>\r</code> matches &lt;CR&gt;</p> <p><code>\n</code> matches an end-of-line - When matching in a string instead of buffer text a literal newline character is matched.</p> </blockquote>
<p>First of all, open <a href="http://vimdoc.sourceforge.net/htmldoc/change.html#:s" rel="noreferrer"><code>:h :s</code></a> to see the section "4.2 Substitute" of documentation on "Change". Here's what the command accepts:</p> <pre><code>:[range]s[ubstitute]/{pattern}/{string}/[flags] [count] </code></pre> <p>Notice the description about <code>pattern</code> and <code>string</code></p> <blockquote> <p>For the <code>{pattern}</code> see <a href="http://vimdoc.sourceforge.net/htmldoc/pattern.html#pattern" rel="noreferrer"><code>|pattern|</code></a>. <br> <code>{string}</code> can be a literal string, or something <br> special; see <a href="http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-special" rel="noreferrer"><code>|sub-replace-special|</code></a>.</p> </blockquote> <p>So now you know that the search pattern and replacement patterns follow different rules. If you follow the link to <code>|pattern|</code>, it takes you to the section that explains the whole regexp patterns used in Vim.</p> <p>Meanwhile, <code>|sub-replace-special|</code> takes you to the subsection of "4.2 Substitute", which contains the patterns for substitution, among which is <code>\r</code> for line break/split.</p> <p>(The shortcut to this part of manual is <a href="http://vimdoc.sourceforge.net/htmldoc/change.html#:s%25" rel="noreferrer"><code>:h :s%</code></a>)</p>
9,690
<p>I have a number of fairly large printed pieces. The parts, when assembled, form a very large sword. (The model is this: <a href="https://www.thingiverse.com/thing:4178060" rel="nofollow noreferrer">https://www.thingiverse.com/thing:4178060</a>, and is not mine.) It is about 7' from tip to pommel, and individual pieces are fairly large. The pieces are already printed, so advice to modify the model geometry to add reinforcements at this point is moot.</p> <p>I have printed the pieces in PLA. I'm not asking for glue recommendations, necessarily, but rather something that could help with adhesion in addition to the glue. I'm concerned that after gluing them together, they won't support their own weight very well. I'm not worried about swinging it, just holding it and hanging it on a wall.</p> <p>If I was very clever, I would have modified the files to add a through-hole that I would've put a pipe through or something, but I didn't think that far ahead. I could drill holes in the printed pieces, but I don't have a good way to make sure they line up.</p> <p>So, what is the best way to add some kind of support to help keep the parts from falling apart? Is there some trick I could use to figure out how to line up drill holes?</p>
<p><strong>Previous answer assuming not yet printed</strong>:</p> <p>If you want to drill holes, print smaller guide holes to guide the drill bit. The best glue depends on the material. Printing structures like dovetails makes the connection less dependent on the strength of the glue.</p> <p><strong>Answer with the parts already printed</strong>:</p> <p>The best way to align drilled holes is probably to glue the pieces together first, then drill the holes. Otherwise, you need a method to clamp the pieces together or do precision drilling.</p>
<p>A stronger joint than glue can be had by welding, albeit uglier and best used in hidden areas. One way to weld is with friction, using a Dremel to spin a piece of filament so fast it heats up and melts with the two plastic pieces you are joining. You tack the pieces together with a couple spot welds, then move along the joint slowly, melting a bead of plastic that is melted into both sides. Like metal welding, penetration is key to strength. You need a straight piece of filament (heat gun works, and rolling it on a flat surface while it is soft), and 3mm is a better size than 1.75mm, if available. It also helps if the joint is a little “V” shaped, so you melt plastic in the crack between the two pieces. Search “filament friction welding” for articles.</p> <p>You can also weld with some filament and a chisel tip soldering iron with variable temperature (lower the temperature to a little above the filament’s printing temp). Melt the filament into the crack between the parts. Do something to get rid of the fumes if using ABS, etc.</p> <p>Both work, friction welding might get more penetration into the parts being joined, thus a stronger joint, but they are both a sturdy way to do a butt joint between two printed parts, that would be weak if glued.</p> <p>The friction welding can also be used to “rivet” overlapping parts, if you dive in and melt the spinning rod through the two parts, then stop the motor and hold it in place while it cools, then snip the end of the rivet off flush.</p>
1,783
<p>Is it possible to 3D print an axial turbine 2 - 4 inches (50 - 100 mm) in radius, capable withstanding temperatures about 800 - 1000°C and rotation speeds of 100 - 120 x 10<sup>3</sup> rpm?</p> <p>How expensive is that? Is it cheaper to mill such a turbine from a whole piece of alloy?</p> <p>What technologies and materials should be used?</p> <p>Are Inconel alloys suitable for 3D printing?</p> <p>Are there any titanium alloys suitable for this task? I've read titanium is rarely used in rapidly rotating parts due to its ability to ignite if mechanical failure occurs and rotating blades touch the casing. Do titanium alloys still have this drawback? </p> <p>Is it possible to make disk of titanium and blades of Inconel, and have them welded (considering heat expansion)?</p> <p>How blades or blisks can be ceramically coated?</p> <p>Thank you!</p>
<p>You ask some very interesting questions! Firstly, when researching topics such as this, you will have far more luck using 'additive manufacturing' as a search term rather than '3D printing'. In the professional industrial environment, '3D printing' is not a term that is really used to describe the manufacturing you are talking about.</p> <p>Selective laser melting is the additive manufacturing process most suited to metallic aerospace parts. Inconel alloys can be processed (e.g. IN718 being one of the easiest) along with titanium (almost exclusively Ti6Al4V). As for manufacturing turbine blades and similar parts, you might find this interesting: <a href="https://www.siemens.com/innovation/en/home/pictures-of-the-future/industry-and-automation/additive-manufacturing-3d-printed-gas-turbine-blades.html" rel="nofollow noreferrer">Additive Manufacturing - Breakthrough with 3D printed Gas Turbine Blades</a>.</p> <p>Titanium is not typically used in high-temperature sections of gas turbines, but will be used in larger, cooler components such as fan blades, where it's strength to weigh ratio is a benefit (less mass to rotate = better fuel efficiency).</p> <p>Coating of high-temperature nickel superalloy components is usually performed with electron beam physical vapor deposition (EBPVD) or thermal spray such as high-velocity oxy-fuel (HVOF); each process has certain characteristics that dictate when/where is it used. </p> <p>This is only really a surface depth answer to your questions, but it would be impossible to answer fully here!</p> <p>(My experience: PhD student using selective laser melting with aerospace alloys)</p>
<p>Some companies are already on the move with this idea. I think I remember hearing that <a href="http://optics.org/news/6/4/7" rel="nofollow noreferrer">Pratt and Whitney</a> and Boeing are 3D printing some of the smaller air foils.</p> <p>The advantages being that they can achieve manufacturing of more complex, more efficient parts without the hassle of quality control, expensive fixturing/maintenance, and less hands on their proprietary parts and processes.</p> <p>Most often, a metal alloy part is "printed" using SLA or SLS (commonly), but it's more or less just bonded. Bonding is either done via laser sintering or some form of epoxy for these types of printing processes. The part is pretty much useless for aerospace purposes at this point because you can just break it apart with your hands, as it is very brittle.</p> <p>Once the metal is bonded in the desired shape, it goes in a furnace to either solidify the sintered material or the epoxy is replaced with another metal such as bronze or nickel. Also during this operation, the part is heat treated to receive the desired material structure. The changes to the material during this process can help set its strength and heat resistance.</p> <p>A quick Google search on "<a href="https://www.google.com/#q=inconel+3d+printing" rel="nofollow noreferrer">Inconel 3D Printing</a>" yields a couple companies that can 3D print "exotic" metals such as titanium and inconel. Chances are if a 3D printer can process inconel, it can print most other aerospace materials.</p> <p>3D printing exotic materials, at this point, is really just gluing sand and baking it in the oven.</p>
439
<p>The Entity Framework does not support the <code>Expression.Invoke</code> operator. You receive the following exception when trying to use it:</p> <blockquote> <p>"The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.</p> </blockquote> <p>Has anyone got a workaround for this missing functionality? I would like to use the PredicateBuilder detailed <a href="http://www.albahari.com/nutshell/predicatebuilder.html" rel="noreferrer">here</a> in an Entity Framework context.</p> <p><strong>Edit 1</strong> @marxidad - I like your suggestion, however it does baffle me somewhat. Can you give some further advice on your proposed solution?</p> <p><strong>Edit 2</strong> @marxidad - Thanks for the clarification.</p>
<p><a href="http://www.albahari.com/nutshell/predicatebuilder.aspx" rel="noreferrer">PredicateBuilder</a> and <a href="http://www.albahari.com/nutshell/linqkit.aspx" rel="noreferrer">LINQKit</a> now support Entity Framework.</p> <p>Sorry, guys, for not doing this earlier!</p>
<p>The Entity framework converts LINQ expressions into Entity Command trees and within that only its canonical functions are supported. You'd have to use the command trees with canonical functions to do something like PredicateBuilder.</p>
3,172
<p>I'd like to print a cylinder, 50 mm diameter, 200 mm long, with 1.5 mm diameter holes tightly fit like this:</p> <p><a href="https://i.stack.imgur.com/i11dN.png" rel="nofollow noreferrer" title="3D rendering of a cylinder with holes"><img src="https://i.stack.imgur.com/i11dN.png" alt="3D rendering of a cylinder with holes" title="3D rendering of a cylinder with holes" /></a></p> <p>The holes go all the way through from top to bottom.</p> <p>I am using a Prusa i3 MK3S. With 0.1 mm detail and 20 % infill, printing one cylinder is going to take 5 days and 5 hours. I need at least five cylinders.</p> <ul> <li>Is the above setting appropriate for this job?</li> <li>Is there any way I can reduce the printing time?</li> </ul>
<h1>That's a hell of a print!</h1> <p>You are printing a model that has a highly complex structure there, with about 650ish holes, assuming there is space for about 2 perimeters between each hole.</p> <p><a href="https://i.stack.imgur.com/gcrSm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gcrSm.png" alt="imitated design of a cylinder with ca 650 thin holes" /></a></p> <p>Taking my standard 0.3 mm layer height and 0.4 mm nozzle using a 0.45 mm wide line, I sliced a 10mm high slice of the model for a first estimate of the expected print time - and came out with 2:21 hours. That means the expected print time with 0.3 mm layer height is in the area of 47 hours - or just about 2 days.</p> <p>As a result, 5 days and 5 hours are in the order I'd expect from a 0.1 mm layer height print for the same nozzle, in fact, your settings seem to have a faster print speed than I do work with.</p> <p>In general, don't think this model is good for FDM Printing at all, due to many non-fully formed lines inside the model (yellow) and the red perimeters being a very dense pattern.</p> <p><a href="https://i.stack.imgur.com/l0oH6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l0oH6.png" alt="Sliced crossection: in yellow: many extra thin lines!" /></a></p> <h2>Solutions?</h2> <h3>print faster</h3> <p>You might get a faster speed with a high flow solution, for example, using a long melt zone (volcano-style) or an even higher flow core-heating 3DSolex nozzle. The latter originally only comes in 0.6 mm and up, also mandating fewer holes, but in late 2021 CHT Nozles in 0.4 mm came to the market. This could drop print time some, but it'd still be a several days print job.</p> <h3>reduced pattern</h3> <p>Besides increasing layer height to drop printing time by the same factor, reducing the number of holes and as a result, spacing them further apart not only can increase the print speed but also make the print form more reliable.</p> <p>Another alternative would be to alter the pattern from a circle to a hexagonal pattern: by using hexagons, the resulting pattern does not contain thin walls and might print much faster - depending on hole size, you might experience a drop by a factor of 2!</p> <p><a href="https://i.stack.imgur.com/Bk583.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bk583.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/Jjr3P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jjr3P.png" alt="enter image description here" /></a></p> <h3>Printed differently</h3> <p>Going from FDM printing to a system such as SLS might be faster and more reliable while SLA/DLP would make this print not only fast and reliable but also trivial - if one can get a 200 mm high SLA/DLP printer, all three models should be able to be printed in one go at the same time!</p>
<p>Holes, circles, and curves are slow to print, and get slower as the number of wall segments increase.</p> <p>Ideally you'd use square holes, but hexagonal-sided ones would be a fair compromise too.</p> <p>Your slicer should be able to give a breakdown on the times for each kind of line in the part. Check and see how much of the time is spent on &quot;moves&quot;.</p> <p>Is there a reason for using all these little holes? Fewer, larger holes will provide better airflow and require less printing, up to the ultimate of one single large hole, where you're essentially printing a pipe/tube.</p> <p>Do you need the holes to go right-through? Printing a big &quot;cup&quot; with holes across the floor, and separately a &quot;lid&quot; then gluing them together would be quicker and you have one large hole in the middle. If this idea works, you might prefer to just buy plastic pipe of a suitable size, and print only endcaps.</p> <p>Additionally, if you're printing 5 cylinders because you need a metre total length, then printing two endcaps for a 1 metre piece of plastic PVC pipe should take a couple of hours at most. And it will save you a lot of filament.</p>
2,077
<p>Does a caching-nameserver usually cache the negative DNS response SERVFAIL? </p> <p>EDIT: To clarify the question, I can see the caching nameserver caching negative responses NXDOMAIN, NODATA. But it does not do this for SERVFAIL responses. Is this intentional?</p>
<p>SERVFAIL is covered by §7.1 of RFC2308:</p> <blockquote> <p>Server failures fall into two major classes. The first is where a server can determine that it has been misconfigured for a zone. This may be where it has been listed as a server, but not configured to be a server for the zone, or where it has been configured to be a server for the zone, but cannot obtain the zone data for some reason. This can occur either because the zone file does not exist or contains errors, or because another server from which the zone should have been available either did not respond or was unable or unwilling to supply the zone.</p> <p>The second class is where the server needs to obtain an answer from elsewhere, but is unable to do so, due to network failures, other servers that don't reply, or return server failure errors, or similar.</p> <p>In either case a resolver MAY cache a server failure response. If it does so it MUST NOT cache it for longer than five (5) minutes, and it MUST be cached against the specific query tuple &lt;query name, type, class, server IP address&gt;.</p> </blockquote> <p>So basically, it's dependent on the implementation of your name server.</p>
<p>One of the timeout fields in the SOA is a "negative timeout". It is usually set to a short time, such as 30 or 60 seconds. So, yes, but for a shorter time than a "positive" response.</p>
9,908
<p>I am building a site that uses a simple AJAX Servlet to talk JMS (ActiveMQ) and when a message arrives from the topic to update the site.</p> <p>I have Javascript that creates an XMLHttpRequest for data. The Servlet processes the Get Request and sends back JSON. However I have no idea how to connect my Servlet into my ActiveMQ Message Broker. It just sends back dummy data right now.</p> <p>I am thinking the Servelt should implement the messagelistener. Then onMessage send data to the JavaScript page. But I'm not sure how to do this.</p>
<p>The problem with having a servlet implement MessageListener is that servlets are synchronous and MessageListeners are asynchronous. Instead you should create some other object to act as the MessageListener and update some state somewhere (possibly a database or a JMX MBean or a Stateful Session EJB) when messages come in. Then the servlet can query that state to see if there's data to report back to the client, and your web page can periodically ping the servlet to ask for fresh data.</p>
<p>You probably need to get a JMS connection from JNDI, like this:</p> <pre><code>Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); props.setProperty(Context.PROVIDER_URL, "tcp://hostname:61616"); javax.naming.Context ctx = new InitialContext(props); // lookup the connection factory javax.jms.TopicConnectionFactory factory = (javax.jms.TopicConnectionFactory)ctx.lookup("ConnectionFactory"); // create a new TopicConnection for pub/sub messaging javax.jms.TopicConnection conn = factory.getTopicConnection(); // lookup an existing topic javax.jms.Topic mytopic = (javax.jms.Topic)ctx.lookup("MyTopic"); // create a new TopicSession for the client javax.jms.TopicSession session = conn.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE); // create a new subscriber to receive messages javax.jms.TopicSubscriber subscriber = session.createSubscriber(mytopic); </code></pre>
9,049
<p>I am getting a <code>NoClassDefFoundError</code> when I run my Java application. What is typically the cause of this?</p>
<p>While it's possible that this is due to a classpath mismatch between compile-time and run-time, it's not necessarily true.</p> <p>It is important to keep two or three different exceptions straight in our head in this case:</p> <ol> <li><p><strong><code>java.lang.ClassNotFoundException</code></strong> This exception indicates that the class was not found on the classpath. This indicates that we were trying to load the class definition, and the class did not exist on the classpath.</p></li> <li><p><strong><code>java.lang.NoClassDefFoundError</code></strong> This exception indicates that the JVM looked in its internal class definition data structure for the definition of a class and did not find it. This is different than saying that it could not be loaded from the classpath. Usually this indicates that we previously attempted to load a class from the classpath, but it failed for some reason - now we're trying to use the class again (and thus need to load it, since it failed last time), but we're not even going to try to load it, because we failed loading it earlier (and reasonably suspect that we would fail again). The earlier failure could be a ClassNotFoundException or an ExceptionInInitializerError (indicating a failure in the static initialization block) or any number of other problems. The point is, a NoClassDefFoundError is not necessarily a classpath problem.</p></li> </ol>
<p>I got this message after removing two files from the SRC library, and when I brought them back I kept seeing this error message.</p> <p>My solution was: Restart Eclipse. Since then I haven't seen this message again :-)</p>
5,466
<p>We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slowing down this process. That being said, one issue we are running into is that after we push out an update with new JavaScript files, the client browsers still use the cached version of the file and they do not see the update. Obviously, on a support call, we can simply inform them to do a <kbd>ctrl</kbd><kbd>F5</kbd> refresh to ensure that they get the up-to-date files from the server, but it would be preferable to handle this before that time.</p> <p>Our current thought is to simply attach a version number onto the name of the JavaScript files and then when changes are made, increment the version on the script and update all references. This definitely gets the job done, but updating the references on each release could get cumbersome.</p> <p>As I'm sure we're not the first ones to deal with this, I figured I would throw it out to the community. How are you ensuring clients update their cache when you update your code? If you're using the method described above, are you using a process that simplifies the change?</p>
<p>As far as I know a common solution is to add a <code>?&lt;version&gt;</code> to the script's src link.</p> <p>For instance:</p> <pre><code>&lt;script type="text/javascript" src="myfile.js?1500"&gt;&lt;/script&gt; </code></pre> <hr> <blockquote> <p>I assume at this point that there isn't a better way than find-replace to increment these "version numbers" in all of the script tags?</p> </blockquote> <p>You might have a version control system do that for you? Most version control systems have a way to automatically inject the revision number on check-in for instance.</p> <p>It would look something like this:</p> <pre><code>&lt;script type="text/javascript" src="myfile.js?$$REVISION$$"&gt;&lt;/script&gt; </code></pre> <hr> <p>Of course, there are always better solutions like <a href="http://blog.greenfelt.net/2009/09/01/caching-javascript-safely/" rel="noreferrer">this one</a>.</p>
<p>A simple trick that works fine for me to prevent conflicts between older and newer javascript files. That means: If there is a conflict and some error occurs, the user will be prompted to press Ctrl-F5.</p> <p>At the top of the page add something like</p> <pre><code>&lt;h1 id=&quot;welcome&quot;&gt; Welcome to this page &lt;span style=&quot;color:red&quot;&gt;... press Ctrl-F5&lt;/span&gt;&lt;/h1&gt; </code></pre> <p>looking like</p> <p><a href="https://i.stack.imgur.com/yiqlQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yiqlQ.png" alt="enter image description here" /></a></p> <p>Let this line of javascript be the last to be executed when loading the page:</p> <pre><code>document.getElementById(&quot;welcome&quot;).innerHTML = &quot;Welcome to this page&quot; </code></pre> <p>In case that no error occurs the welcome greeting above will hardly be visible and almost immediately be replaced by</p> <p><a href="https://i.stack.imgur.com/IVakd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IVakd.png" alt="enter image description here" /></a></p>
5,235
<p>We need to move off traditional FTP for security purposes (it transmits it's passwords unencrypted). I am hearing SSH touted as the obvious alternative. However I have been driving FTP from an ASP.NET program interface to automate my web-site development, which is now quite a highly web-enabled process. </p> <p>Can anyone recommend a secure way to transfer files around which has a program interface that I can drive from ASP.NET?</p>
<p>the question has three subquestions:</p> <p>1) choosing the secure transfer protocol</p> <p>The secure version of old FTP exists - it's called FTP/SSL (plain old FTP over SSL encrypted channel). Maybe you can still use your old deployment infrastructure - just check whether it supports the FTPS or FTP/SSL.</p> <p>You can check details about FTP, FTP/SSL and SFTP differences at <a href="http://www.rebex.net/secure-ftp.net/" rel="nofollow noreferrer">http://www.rebex.net/secure-ftp.net/</a> page.</p> <p>2) SFTP or FTP/SSL server for Windows</p> <p>When you choose whether to use SFTP or FTPS you have to deploy the proper server. For FTP/SSL we use the Gene6 (<a href="http://www.g6ftpserver.com/" rel="nofollow noreferrer">http://www.g6ftpserver.com/</a>) on several servers without problems. There is plenty of FTP/SSL Windows servers so use whatever you want. The situation is a bit more complicated with SFTP server for Windows - there is only a few working implementations. The Bitvise WinHTTPD looks quite promising (<a href="http://www.bitvise.com/winsshd" rel="nofollow noreferrer">http://www.bitvise.com/winsshd</a>).</p> <p>3) Internet File Transfer Component for ASP.NET</p> <p>Last part of the solution is secure file transfer from asp.net. There is several components on the market. I would recommend the <a href="http://www.rebex.net/file-transfer-pack/" rel="nofollow noreferrer">Rebex File Transfer Pack</a> - it supports both FTP (and FTP/SSL) and SFTP (SSH File Transfer).</p> <p>Following code shows how to upload a file to the server via SFTP. The code is taken from our <a href="http://www.rebex.net/sftp.net/tutorial-sftp.aspx#upload-download" rel="nofollow noreferrer">Rebex SFTP tutorial page</a>.</p> <pre><code>// create client, connect and log in Sftp client = new Sftp(); client.Connect(hostname); client.Login(username, password); // upload the 'test.zip' file to the current directory at the server client.PutFile(@"c:\data\test.zip", "test.zip"); // upload the 'index.html' file to the specified directory at the server client.PutFile(@"c:\data\index.html", "/wwwroot/index.html"); // download the 'test.zip' file from the current directory at the server client.GetFile("test.zip", @"c:\data\test.zip"); // download the 'index.html' file from the specified directory at the server client.GetFile("/wwwroot/index.html", @"c:\data\index.html"); // upload a text using a MemoryStream string message = "Hello from Rebex SFTP for .NET!"; byte[] data = System.Text.Encoding.Default.GetBytes(message); System.IO.MemoryStream ms = new System.IO.MemoryStream(data); client.PutFile(ms, "message.txt"); </code></pre> <p>Martin</p>
<p>G'day,</p> <p>You might like to look at <a href="http://www.proftpd.org/" rel="nofollow noreferrer">ProFPD</a>.</p> <p>Heavily customisable. Based on Apache module structure.</p> <p>From their web site:</p> <blockquote> <p>ProFTPD grew out of the desire to have a secure and configurable FTP server, and out of a significant admiration of the Apache web server.</p> </blockquote> <p>We use our adapted version for large scale transfer of web content. Typically 300,000 updates per day.</p> <p>HTH</p> <p>cheers,</p> <p>Rob</p>
6,012
<p>What are some effective strategies for preventing the use of my proprietary images?</p> <p>I'm talking about saving them, direct linking to them etc...</p> <p>Presently I have a watermark on the image, but I'd rather not.</p> <p>.NET platform preferred, but if there's a strategy that's on another platform that integrates with my existing application that'd be a bonus.</p>
<p>It's not possible to make it "impossible" to download. When a user visits your site you're sending them the pictures. The user will have a copy of that image in the browsers cache and he'd be able to access it even after he leaves the site ( depending on the browser, of course ). Your only real option is to watermark them :O</p>
<p>Anything you send to the client is, like, on the client. Not much you can do about it besides making somewhere between "sorta hard" and "quite hard" to save the image.</p>
4,159
<p>I have a Prusa i3 printer with mk8 extruder. I am using PETG with (200-240/75-85) degrees recommended temp on it's box. but when I do printing i hear some knocking sound that means there is a problem in extrusion. last time I did increase my temp up to 270 degrees!! maybe this sound solved! but it damaged my extruder's screw's inner Teflon and I forced to change it! </p> <p>Now I have a new nozzle and extruder's screw, but again I can hear this sound during the printing! I thought maybe it's because of very close distance between the nozzle and the bed, but when I increase the distance, the filament starts to warping!</p> <p>My nozzle is new and it can't be for clogging. so I decreased the print speed from it's default 60mm(in Cura software) to 50, but didn't solve this sound. Also when I use pronterface and do extrusion manually, it works nice with 200 degrees! but I can hear the sound in 190 degrees. But when I do printing I hear the sound even in 200 degrees! Is this mean I must increase the temperature for printing? how much?</p> <p>By knocking sound I mean the sound you can hear when you have a clogged nozzle and the extruder's stepper motor can't push the filament into it and rotates with knocking sound!</p>
<p>This is the throat block for direct drive extrusion, Anet8 is a cheap clone of Prusa printers, so it's easy to find parts for Anet printers. </p> <p>This is one extruder kit that may help your needs, <a href="https://es.aliexpress.com/store/product/1Set-3D-Printer-makerbot-MK8-Extruder-Aluminum-extrusion-Frame-Block-DIY-Kit-for-Reprap-i3/1962255_32715673423.html?spm=a219c.search0104.3.269.W5yIqd&amp;ws_ab_test=searchweb0_0,searchweb201602_2_10152_10065_10151_10344_10068_10345_10342_10343_10173_10340_10341_10541_10562_10084_10083_10307_10060_10155_5680016_10154_10056_10055_10539_10537_10312_10059_10313_10314_10534_10533_100031_10103_10073_10102_10557_10142_10107,searchweb201603_25,ppcSwitch_5&amp;btsid=79693e48-00b7-4029-908d-314b37935569&amp;algo_expid=64c2aa2b-e9de-4722-8ecb-0ba5542f5a86-34&amp;algo_pvid=64c2aa2b-e9de-4722-8ecb-0ba5542f5a86" rel="nofollow noreferrer">1 Unidades Impresora 3D makerbot MK8 Extrusora De extrusión de Aluminio Bloque de DIY Kit para Reprap i3</a>. This is a link for Aliexpress - of course there are other dealers.</p>
<p>Like @ZuOverture said the name of this component is the filament drive. Most of the manufactures sell the whole extrusion device already assembled, to avoid mismatches between the components of the extrusion device. If your device is somehow damaged, and without possibilities to be used in the printer the easiest solution would be to buy a new extrusion device. If financially is unfeasible for you, you may have the option to generate the 3D model of this piece and share the file to someone who could print this component for you. </p>
741
<p>I have a data structure that represents a directed graph, and I want to render that dynamically on an HTML page. These graphs will usually be just a few nodes, maybe ten at the very upper end, so my guess is that performance isn't going to be a big deal. Ideally, I'd like to be able to hook it in with jQuery so that users can tweak the layout manually by dragging the nodes around.</p> <p>Note: I'm not looking for a charting library.</p>
<p>I've just put together what you may be looking for: <a href="http://www.graphdracula.net" rel="noreferrer">http://www.graphdracula.net</a></p> <p>It's JavaScript with directed graph layouting, SVG and you can even drag the nodes around. Still needs some tweaking, but is totally usable. You create nodes and edges easily with JavaScript code like this:</p> <pre><code>var g = new Graph(); g.addEdge(&quot;strawberry&quot;, &quot;cherry&quot;); g.addEdge(&quot;cherry&quot;, &quot;apple&quot;); g.addEdge(&quot;id34&quot;, &quot;cherry&quot;); </code></pre> <p>I used the previously mentioned Raphael JS library (the graffle example) plus some code for a force based graph layout algorithm I found on the net (everything open source, MIT license). If you have any remarks or need a certain feature, I may implement it, just ask!</p> <hr /> <p>You may want to have a look at other projects, too! Below are two meta-comparisons:</p> <ul> <li><p><a href="http://socialcompare.com/en/comparison/javascript-graphs-and-charts-libraries" rel="noreferrer">SocialCompare</a> has an extensive list of libraries, and the &quot;Node / edge graph&quot; line will filter for graph visualization ones.</p> </li> <li><p>DataVisualization.ch has evaluated many libraries, including node/graph ones. Unfortunately there's no direct link so you'll have to filter for &quot;graph&quot;:<a href="http://selection.datavisualization.ch/" rel="noreferrer"><img src="https://i.stack.imgur.com/o4lwD.jpg" alt="Selection DataVisualization.ch" /></a></p> </li> </ul> <p>Here's a list of similar projects (some have been already mentioned here):</p> <h3>Pure JavaScript Libraries</h3> <ul> <li><p><a href="http://visjs.org/#gallery" rel="noreferrer">vis.js</a> supports many types of network/edge graphs, plus timelines and 2D/3D charts. Auto-layout, auto-clustering, springy physics engine, mobile-friendly, keyboard navigation, hierarchical layout, animation etc. <a href="https://github.com/almende/vis" rel="noreferrer">MIT licensed</a> and developed by a Dutch firm specializing in research on self-organizing networks.</p> </li> <li><p><a href="http://js.cytoscape.org" rel="noreferrer">Cytoscape.js</a> - interactive graph analysis and visualization with mobile support, following jQuery conventions. Funded via NIH grants and developed by by <a href="https://stackoverflow.com/users/947225/maxkfranz">@maxkfranz</a> (see <a href="https://stackoverflow.com/a/10319429/1269037">his answer below</a>) with help from several universities and other organizations.</p> </li> <li><p><a href="http://thejit.org/demos.html" rel="noreferrer">The JavaScript InfoVis Toolkit</a> - Jit, an interactive, multi-purpose graph drawing and layout framework. See for example the <a href="http://philogb.github.io/jit/static/v20/Docs/files/Visualizations/Hypertree-js.html" rel="noreferrer">Hyperbolic Tree</a>. Built by Twitter dataviz architect <a href="http://www.sencha.com/conference/session/sencha-charting-visualization" rel="noreferrer">Nicolas Garcia Belmonte</a> and <a href="http://philogb.github.io/infovis/" rel="noreferrer">bought by Sencha</a> in 2010.</p> </li> <li><p><a href="http://d3js.org/" rel="noreferrer">D3.js</a> Powerful multi-purpose JS visualization library, the successor of Protovis. See the <a href="http://bl.ocks.org/mbostock/4062045" rel="noreferrer">force-directed graph</a> example, and other graph examples in the <a href="https://github.com/mbostock/d3/wiki/Gallery" rel="noreferrer">gallery</a>.</p> </li> <li><p><a href="https://plot.ly./" rel="noreferrer">Plotly's</a> JS visualization library uses D3.js with JS, Python, R, and MATLAB bindings. See a nexworkx example in IPython <a href="https://plot.ly/ipython-notebooks/network-graphs/" rel="noreferrer">here</a>, human interaction example <a href="https://plot.ly/ipython-notebooks/bioinformatics/#In-%5B54%5D" rel="noreferrer">here</a>, and <a href="https://github.com/plotly/Embed-API" rel="noreferrer">JS Embed API</a>.</p> </li> <li><p><a href="http://sigmajs.org/" rel="noreferrer">sigma.js</a> Lightweight but powerful library for drawing graphs</p> </li> <li><p><a href="http://jsplumbtoolkit.com/" rel="noreferrer">jsPlumb</a> jQuery plug-in for creating interactive connected graphs</p> </li> <li><p><a href="http://getspringy.com/" rel="noreferrer">Springy</a> - a force-directed graph layout algorithm</p> </li> <li><p><a href="http://js-graph-it.sourceforge.net/" rel="noreferrer">JS Graph It</a> - drag'n'drop boxes connected by straight lines. Minimal auto-layout of the lines.</p> </li> <li><p><a href="http://raphaeljs.com/graffle.html" rel="noreferrer">RaphaelJS's Graffle</a> - interactive graph example of a generic multi-purpose vector drawing library. RaphaelJS can't layout nodes automatically; you'll need another library for that.</p> </li> <li><p><a href="http://www.jointjs.com/demos" rel="noreferrer">JointJS Core</a> - David Durman's MPL-licensed open source diagramming library. It can be used to create either static diagrams or fully interactive diagramming tools and application builders. Works in browsers supporting SVG. Layout algorithms not-included in the core package</p> </li> <li><p><a href="https://github.com/jgraph/mxgraph" rel="noreferrer">mxGraph</a> Previously commercial HTML 5 diagramming library, now available under Apache v2.0. mxGraph is the base library used in <a href="https://www.draw.io?splash=0" rel="noreferrer">draw.io</a>.</p> </li> </ul> <h3>Commercial libraries</h3> <ul> <li><p><a href="http://gojs.net/latest/index.html" rel="noreferrer">GoJS</a> Interactive graph drawing and layout library</p> </li> <li><p><a href="http://www.yworks.com/yfileshtml" rel="noreferrer">yFiles for HTML</a> Commercial graph drawing and layout library</p> </li> <li><p><a href="http://keylines.com/" rel="noreferrer">KeyLines</a> Commercial JS network visualization toolkit</p> </li> <li><p><a href="https://zoomcharts.com" rel="noreferrer">ZoomCharts</a> Commercial multi-purpose visualization library</p> </li> <li><p><a href="https://www.syncfusion.com/javascript-ui-controls/diagram" rel="noreferrer">Syncfusion JavaScript Diagram</a> Commercial diagram library for drawing and visualization.</p> </li> </ul> <h3>Abandoned libraries</h3> <ul> <li><p><a href="http://cytoscapeweb.cytoscape.org/" rel="noreferrer">Cytoscape Web</a> Embeddable JS Network viewer (no new features planned; succeeded by Cytoscape.js)</p> </li> <li><p><a href="http://code.google.com/p/canviz/" rel="noreferrer">Canviz</a> JS <strong>renderer</strong> for Graphviz graphs. <a href="https://code.google.com/p/canviz/source/list" rel="noreferrer">Abandoned</a> in Sep 2013.</p> </li> <li><p><a href="http://arborjs.org/" rel="noreferrer">arbor.js</a> Sophisticated graphing with nice physics and eye-candy. Abandoned in May 2012. Several <a href="https://github.com/samizdatco/arbor/issues/56#issuecomment-62842532" rel="noreferrer">semi-maintained</a> forks exist.</p> </li> <li><p><a href="http://github.com/jackrusher/jssvggraph" rel="noreferrer">jssvggraph</a> &quot;The simplest possible force directed graph layout algorithm implemented as a Javascript library that uses SVG objects&quot;. Abandoned in 2012.</p> </li> <li><p><a href="https://code.google.com/p/jsdot/" rel="noreferrer">jsdot</a> Client side graph drawing application. <a href="https://code.google.com/p/jsdot/source/list" rel="noreferrer">Abandoned in 2011</a>.</p> </li> <li><p><a href="http://vis.stanford.edu/protovis/ex/force.html" rel="noreferrer">Protovis</a> Graphical Toolkit for Visualization (JavaScript). Replaced by d3.</p> </li> <li><p><a href="http://labs.unwieldy.net/moowheel/" rel="noreferrer">Moo Wheel</a> Interactive JS representation for connections and relations (2008)</p> </li> <li><p><a href="http://www.jsviz.org/" rel="noreferrer">JSViz</a> 2007-era graph visualization script</p> </li> <li><p><a href="https://github.com/cpettitt/dagre" rel="noreferrer">dagre</a> Graph layout for JavaScript</p> </li> </ul> <h3>Non-Javascript Libraries</h3> <ul> <li><p><a href="http://www.graphviz.org/" rel="noreferrer">Graphviz</a> Sophisticated graph visualization language</p> <ul> <li>Graphviz has been compiled to Javascript using Emscripten <a href="https://github.com/mdaines/viz.js/" rel="noreferrer">here</a> with an <a href="http://mdaines.github.io/viz.js/" rel="noreferrer">online interactive demo here</a></li> </ul> </li> <li><p><a href="http://flare.prefuse.org/" rel="noreferrer">Flare</a> Beautiful and powerful Flash based graph drawing</p> </li> <li><p><a href="http://nodebox.net/code/index.php/Graph" rel="noreferrer">NodeBox</a> Python Graph Visualization</p> </li> <li><p><a href="http://processingjs.org/" rel="noreferrer">Processing.js</a> Javascript port of the Processing library by John Resig</p> </li> </ul>
<p>As guruz mentioned, the <a href="http://philogb.github.io/jit/" rel="nofollow noreferrer">JIT</a> has several lovely graph/tree layouts, including quite appealing RGraph and HyperTree visualizations.</p> <p>Also, I've just put up a super simple SVG-based <a href="http://github.com/jackrusher/jssvggraph" rel="nofollow noreferrer">implementation at github</a> (no dependencies, ~125 LOC) that should work well enough for small graphs displayed in modern browsers.</p>
2,869
<p>I have just upgraded my board to TH3D's <a href="https://www.th3dstudio.com/product/ezboard-lite/" rel="nofollow noreferrer">EZBoard Lite</a> with their <a href="https://www.th3dstudio.com/knowledgebase/ezboard-installation-guide/" rel="nofollow noreferrer">Unified Firmware (U2.R1.15)</a> and whilst dialling in all the setting I have found that using the BlTouch each time to be frustrating because of the time it takes to complete the Auto Bed Leveling, however, I cannot find the settings to increase the speed as shown in <a href="https://youtu.be/BV11-VOQjMc?t=134" rel="nofollow noreferrer">Teaching Tech's video</a>:</p> <pre><code>#define DEFAULT_MAX_FEEDRATE { 500, 500, 5, 25 } </code></pre> <p>is changed to</p> <pre><code>#define DEFAULT_MAX_FEEDRATE { 500, 500, 20, 25 } </code></pre> <p>and</p> <pre><code>#define BLTOUCH_DELAY 375 // (ms) Enable and increase if needed </code></pre> <p>is changed to</p> <pre><code>#define BLTOUCH_DELAY 100 // (ms) Enable and increase if needed </code></pre> <p>and</p> <pre><code>// X and Y axis travel speed (mm/m) between probes #define XY_PROBE_SPEED 8000 </code></pre> <p>is changed to</p> <pre><code>// X and Y axis travel speed (mm/m) between probes #define XY_PROBE_SPEED 10000 </code></pre> <p>I am not quite sure which parts to change as the two builds are organised and worded differently.</p> <p>In the online firmware configurator, it does list an option to speed up the probing of their own EZABL but says not to do so for the BLTouch in the <a href="https://ezfirmware.th3dstudio.com/editor/" rel="nofollow noreferrer">manual configuration editor</a></p> <pre><code>// Super fast probing - VERY EXPERIMENTAL AND ONLY TESTED WITH EZABL PRO SENSORS // Do NOT use with EZABL_FASTPROBE (comment out above) or BL Touch Sensors //#define EZABL_SUPERFASTPROBE </code></pre> <p>Would enabling this be the same as making the changes listed in Teaching Tech's video?</p> <p>Any help you can offer will be greatly appreciated.</p>
<p>There are multiple ways to achieve this:</p> <h2>In G-code</h2> <p>You don't necessarily need to do that in firmware, TH3D is based on Marlin firmware and is just a monolithic implementation for most popular printers and boards that helps novice users to easily configure their printer, but in the meantime it hides other options from plain sight.</p> <p>Being a derivative fro Marlin firmware, the bed leveling speed in between probes can also be easily set in G-code. G-code <a href="https://reprap.org/wiki/G-code#G29:_Detailed_Z-Probe" rel="nofollow noreferrer"><code>G29</code></a> has a speed parameter:</p> <p><code>S</code> : <em>Set the XY travel speed between probe points (in units/min)</em></p> <p>From below (TH3D firmware) can be seen that a value of 12000 mm/min will speed up and is generally safe to use.</p> <h2>In Marlin firmware</h2> <p>In Marlin firmware, the speed setting in between probes is found in <a href="https://github.com/MarlinFirmware/Marlin/blob/2.0.x/Marlin/Configuration.h" rel="nofollow noreferrer">Configuration.h</a>:</p> <pre><code>// X and Y axis travel speed (mm/min) between probes #define XY_PROBE_SPEED 8000 </code></pre> <h2>In TH3D firmware</h2> <p>In TH3D firmware this speed is buried in the <a href="https://github.com/houseofbugs/TH3D-Unified-U1.R2/blob/master/TH3DUF_R2/Configuration_backend.h" rel="nofollow noreferrer">Configuration_backend.h</a>:</p> <pre><code> #if ENABLED(PROBING_MOTORS_OFF) #define XY_PROBE_SPEED 8000 #else #if ENABLED(SLOWER_PROBE_MOVES) || ENABLED(TH3D_EZ300) || ENABLED(TIM_AM8) #define XY_PROBE_SPEED 8000 #else #if ENABLED(EZABL_SUPERFASTPROBE) #define XY_PROBE_SPEED 16000 #else #define XY_PROBE_SPEED 12000 #endif #endif #endif </code></pre> <p>The speed is depending on setting of the <code>PROBING_MOTORS_OFF</code> in <a href="https://github.com/houseofbugs/TH3D-Unified-U1.R2/blob/master/TH3DUF_R2/Configuration.h" rel="nofollow noreferrer">Configuration.h</a>:</p> <pre><code>// This will disable the XYE motors during probing. Can be useful if you have stepper motors causing interference issues with the EZABL sensor. #define PROBING_MOTORS_OFF </code></pre> <p>or depending on the speed settings for specific setting/sensors <code>(ENABLED(SLOWER_PROBE_MOVES) || ENABLED(TH3D_EZ300) || ENABLED(TIM_AM8)</code>:</p> <pre><code>// If you have issues with your machine running the faster probe setting disable the #define EZABL_FASTPROBE below. // DO NOTE: Most machines will work with the fast probe enabled. Use M48 to verify accuracy. #define EZABL_FASTPROBE // Superfast probing - Only works with the EZABL Pro Sensors // DO NOTE: Not all machines will work with the fast probe enabled. Use M48 to verify accuracy and make sure the Z isn't binding with the high speeds. //#define EZABL_SUPERFASTPROBE </code></pre> <p>Basically, if you have not defined one of the following: <code>PROBING_MOTORS_OFF</code>, <code>SLOWER_PROBE_MOVES</code>, <code>TH3D_EZ300</code> or <code>TIM_AM8</code>, the <code>XY_PROBE_SPEED </code> will default to a value of 4000 (depending of the definition of <code>HOMING_FEEDRATE_XY</code>) since the constant is not defined, see <a href="https://github.com/houseofbugs/TH3D-Unified-U1.R2/blob/master/TH3DUF_R2/Conditionals_post.h" rel="nofollow noreferrer">Conditionals_post.h)</a>:</p> <pre><code> #ifndef XY_PROBE_SPEED #ifdef HOMING_FEEDRATE_XY #define XY_PROBE_SPEED HOMING_FEEDRATE_XY #else #define XY_PROBE_SPEED 4000 #endif #endif </code></pre> <p>In Marlin you would simply change the value of the travel between probing speed whilst in TH3D you need to sort out if one of all those conditions are met. For advanced users with a slightly different printer setup, the TH3D software might be less optimal. Do note that forks of the Marlin firmware that are heavily modified always (like TH3D) lack behind the original sources; you are dependent on the implementation schedule of the fork maintainer. But, for people that have not modified their printer, have a limited knowledge of software (C/C++ development) and firmware flashing, or their modification falls in the supported options of TH3D, the monolithic TH3D might be very helpful!</p> <p>Most probably, your setting is overruled later.</p>
<p>I dont know if you managed to solve this but if not I was facing the same issue and managed to do it just by searching all sketches for those parameters in Arduino IDE. They are not all in configuration.h like shown in the Teaching Tech video. Most of them are in configuration_backend.h and some in conditionals_LCD.h I used the values suggested in TT's video and it has speeded up levelling vastly.</p> <p>p.s. I am using the most recent version of the TH3D unified firmware on a Creality CR-10 mini</p>
1,546
<p><a href="https://stackoverflow.com/questions/180/function-for-creating-color-wheels">Original Question</a></p> <p>I am looking for a function that attempts to quantify how "distant" (or distinct) two colors are. This question is really in two parts: </p> <ol> <li>What color space best represents human vision?</li> <li>What distance metric in that space best represents human vision (euclidean?)</li> </ol>
<p>Convert to La*b* (aka just plain "Lab", and you'll also see reference to "CIELAB"). A good quick measaure of color difference is </p> <blockquote> <p>(L1-L2)^2 + (a1-a2)^2 + (b1-b2)^2</p> </blockquote> <p>Color scientists have other more refined measures, which may not be worth the bother, depending on accuracy needed for what you're doing.</p> <p>The <code>a</code> and <code>b</code> values represent opposing colors in a way similar to how cones work, and may be negative or positive. Neutral colors - white, grays are <code>a=0</code>,<code>b=0</code>. The <code>L</code> is brightness defined in a particular way, from zero (pure darkness) up to whatever. </p> <p>Crude explanation :>> Given a color, our eyes distinguish between two broad ranges of wavelength - blue vs longer wavelengths. and then, thanks to a more recent genetic mutation, the longer wavelength cones bifurcated into two, distinguishing for us red vs. green. </p> <p>By the way, it'll be great for your career to rise above your color caveman collegues who know of only "RGB" or "CMYK" which are great for devices but suck for serious perception work. I've worked for imaging scientists who didn't know a thing about this stuff!</p> <p>For more fun reading on color difference theory, try:</p> <ul> <li><a href="http://white.stanford.edu/~brian/scielab/introduction.html" rel="noreferrer">http://white.stanford.edu/~brian/scielab/introduction.html</a> and info </li> <li>and links on color theory in general, websurf starting with <a href="http://www.efg2.com/Lab/Library/Color/" rel="noreferrer">http://www.efg2.com/Lab/Library/Color/</a> and </li> <li><a href="http://www.poynton.com/Poynton-color.html" rel="noreferrer">http://www.poynton.com/Poynton-color.html</a> </li> </ul> <p>More detail on Lab at <a href="http://en.kioskea.net/video/cie-lab.php3" rel="noreferrer">http://en.kioskea.net/video/cie-lab.php3</a> I can't at this time find a non-ugly page that actually had the conversion formulas but I'm sure someone will edit this answer to include one.</p>
<p>The easiest <em>distance</em> would of course be to just consider the colors as 3d vectors originating from the same origin, and taking the distance between their end points.</p> <p>If you need to consider such factors that green is more prominent in judging intensity, you can weigh the values.</p> <p><a href="http://www.imagemagick.org/Usage/color/#grayscale" rel="nofollow noreferrer">ImageMagic</a> provides the following scales: </p> <ul> <li>red: 0.3</li> <li>green: 0.6</li> <li>blue: 0.1</li> </ul> <p>Of course, values like this would only be meaningful in relation to other values for other colors, not as something that would be meaningful to humans, so all you could use the values for would be similiarity ordering.</p>
2,372
<p><a href="https://3dprinting.stackexchange.com/questions/871/is-22-guage-stranded-hookup-wire-the-correct-wire-to-connect-the-switching-power">I'm still looking at wires</a> for my Prusa i3, to go between the power supply and <a href="http://reprap.org/wiki/RAMPS_1.4" rel="nofollow noreferrer">RAMPS 1.4</a>, and <a href="http://rads.stackoverflow.com/amzn/click/B007KG0ZYI" rel="nofollow noreferrer">the power supply</a> and the <a href="http://reprap.org/wiki/PCB_Heatbed#MK2.2C_MK2a" rel="nofollow noreferrer">MK2a Heatbed</a>. </p> <p>I also recently found a <a href="http://www.harborfreight.com/400-ft-wire-storehouse-61527.html" rel="nofollow noreferrer">400 ft. Wire Storehouse</a> that I bought from Harbor Freight which has wire sizes in it from AWG 10 through AWG 22 (and additionally speaker wire, Zip Cord and Bell).</p> <p>I also bought some reading material, I picked up <a href="http://rads.stackoverflow.com/amzn/click/097929455X" rel="nofollow noreferrer">Wiring Simplified 44th edition</a>, and in it on page 28, Table 4-1, there is a table with information about the <a href="https://en.wikipedia.org/wiki/Ampacity" rel="nofollow noreferrer">Ampacity</a> of copper wires including their maximum temp (C), and maximum carrying current (Amps) based on their insulation types.</p> <p>Unfortunately, the <a href="http://www.harborfreight.com/400-ft-wire-storehouse-61527.html" rel="nofollow noreferrer">400 ft. Wire Storehouse</a> does not provide any information in regards to the insulation type or quality and this makes it difficult for one to choose the correct wire based on the specification in the table. </p> <p>Given that the thing only cost $30 for 400 Ft. of wire, it would lead me to believe that the cheapest grade of insulation was used; as I understand it, the TW type wire. </p> <p>I also read a forum somewhere in which people were complaining about the cheapness of the wire in this kit, stating that one ought to wear gloves when working with it as there is probably lead in the insulation as well as the wire.</p> <p>The largest copper wire I have found in the table that I have (AWG 10) says that it is rated at 30 AMP regardless of which type of insulation it has, should I be using the speakerwire instead? That isn't listed in the table. Also it should be noted that though the ratings for the <a href="https://en.wikipedia.org/wiki/Ampacity" rel="nofollow noreferrer">Ampacity</a> are 30 AMPs, the max temperatures are different; with the TW being at 60 C. </p> <p>As far as I can tell if I use the AWG 10 (TW?) to connect everything it won't matter, but I just thought I'd check here to be sure first since my power supply is rated at 30 AMPs and that's probably the same as the wire....</p>
<p><strong>THHN</strong> wire is thermoplastic high heat-resistant nylon coated wire.<br> <strong>THWN</strong> is thermoplastic heat- and moisture-resistant nylon coated wire.</p> <p><strong>"T"</strong> stands for thermoplastic insulation covering the wire itself.<br> <strong>"H"</strong> stands for a heat resistance of the insulation max 167°F.<br> <strong>"HH"</strong> stands for a heat resistance, but increased max 194°F.<br> <strong>"W"</strong> is for moisture resistant.<br> <strong>"N"</strong> is for a nylon coating make the insulation oil and gas resistant.</p> <p>In my opinion the Wire Storehouse is good for simple stuff, but I would not use it for something I consider important. It's quality is poor on the insulation rating and the number of strands is low. Higher strands number allows for more flexible wire.</p> <p>If you get high end audiophile type speaker wire it could be considered as you can find high strand number with good quality insulation properties in heavier gauges. </p> <p>Or your local auto parts store will carry 8 and 6 gauge wire with better insulation properties. </p>
<h2>No &quot;mystery meat&quot; wire in AC electrical</h2> <p>That kit is random Chinese &quot;no-name&quot; hookup wire and cannot be used for AC power. It's fine for low voltage hobbyist tinkering, which is what it's sold for. If it was better than that, <em>they'd say</em>.</p> <p><strong>But who knows?</strong> Maybe the boat didn't arrive and they needed some 12 AWG to finish some kits, so they ran to the electrical supply and bought bona-fide Southwire THHN. If so, the wire would be <a href="https://diy.stackexchange.com/questions/78847/how-do-i-read-the-markings-printed-on-the-outside-of-electric-wires">labeled</a> &quot;UL Listed&quot; and &quot;<a href="https://www.wireandcableyourway.com/blog/what-is-the-difference-between-thhn-vs-thwn-wire/" rel="nofollow noreferrer">THHN/THWN-2</a>&quot;. Then you can use it for AC power.</p> <p>Without &quot;UL Listed&quot; or &quot;UR Recognized&quot; or other mark from a credible NRTL, any other labeling is lies. <em>CE is not an NRTL</em>.</p> <h2>Proper THHN/THWN-2 is available locally, dirt cheap.</h2> <p><em>Competent</em> hardware stores and lumberyards will cheerfully sell it by the foot. So like 6 feet for a dollar-ish.</p> <p>(However they are often not located in strip malls, so some may need to rethink their shopping mindset if they want value).</p> <p>Any good tinkerer/hacker ought to know the location of every good family-owned hardware store, real lumberyard, and electrical supply houses, bonus points for HVAC supply.</p> <h2>TW, THW and THWN-2 are NOT &quot;good, better, best&quot;.</h2> <p>More like the Ford Edsel, Thunderbird and Escape: &quot;obsolete, obsolete, and currently sold product&quot;.</p> <p>Why not keep making TW, THW and THWN? No money savings there. It would cost more to keep 4 separate production lines than to just make everything <a href="https://www.wireandcableyourway.com/blog/what-is-the-difference-between-thhn-vs-thwn-wire/" rel="nofollow noreferrer"><em>dual-rated</em> THHN/THWN-2</a>. So that's what they do.</p> <blockquote> <p>it would lead me to believe that the cheapest grade of insulation was used; as I understand it, the TW type wire.</p> </blockquote> <p>No, wiring doesn't work that way. You can't even assume it's a &quot;T&quot; family - there are also <a href="https://www.multicominc.com/training/technical-resources/thhn-vs-xhhw-difference/" rel="nofollow noreferrer">XHHW</a> and <a href="https://www.multicominc.com/training/technical-resources/rhh-rhw-2-use-2-and-rhh-building-wire-explained/" rel="nofollow noreferrer">RHH/RHW</a> and the &quot;S&quot; family cordage, just in NEC Chapter 3 wiring methods. And many other families <strong>not approved</strong> for AC power.</p> <blockquote> <p>Unfortunately, the 400 ft. Wire Storehouse does not provide any information in regards to the insulation type or quality and this makes it difficult for one to choose the correct wire based on the specification in the table.</p> </blockquote> <p>Doesn't matter what the ad copy says, it matters what the markings on the wire say. <strong>Wire that is <a href="https://diy.stackexchange.com/questions/78847/how-do-i-read-the-markings-printed-on-the-outside-of-electric-wires">unmarked</a> is <em>literally nothing</em></strong>.</p> <p>Wire manufacturers know this. Chinese wire manufacturers don't care. But that Harbor Freight pack never claimed to be anything else, did it?</p>
254
<p>Can anyone tell me if there is a way with generics to limit a generic type argument <code>T</code> to only:</p> <ul> <li><code>Int16</code></li> <li><code>Int32</code></li> <li><code>Int64</code></li> <li><code>UInt16</code></li> <li><code>UInt32</code></li> <li><code>UInt64</code></li> </ul> <p>I'm aware of the <code>where</code> keyword, but can't find an interface for <strong>only</strong> these types,</p> <p>Something like:</p> <pre><code>static bool IntegerFunction&lt;T&gt;(T value) where T : INumeric </code></pre>
<p>There's no constraint for this. It's a real issue for anyone wanting to use generics for numeric calculations.</p> <p>I'd go further and say we need</p> <pre><code>static bool GenericFunction&lt;T&gt;(T value) where T : operators( +, -, /, * ) </code></pre> <p>Or even</p> <pre><code>static bool GenericFunction&lt;T&gt;(T value) where T : Add, Subtract </code></pre> <p>Unfortunately you only have interfaces, base classes and the keywords <code>struct</code> (must be value-type), <code>class</code> (must be reference type) and <code>new()</code> (must have default constructor)</p> <p>You could wrap the number in something else (similar to <code>INullable&lt;T&gt;</code>) like <a href="http://www.codeproject.com/KB/cs/genericnumerics.aspx" rel="noreferrer">here on codeproject</a>.</p> <hr> <p>You could apply the restriction at runtime (by reflecting for the operators or checking for types) but that does lose the advantage of having the generic in the first place.</p>
<p>If all you want is use <strong>one numeric type</strong>, you could consider creating something similar to an alias in C++ with <code>using</code>.</p> <p>So instead of having the very generic</p> <pre><code>T ComputeSomething&lt;T&gt;(T value1, T value2) where T : INumeric { ... } </code></pre> <p>you could have</p> <pre><code>using MyNumType = System.Double; T ComputeSomething&lt;MyNumType&gt;(MyNumType value1, MyNumType value2) { ... } </code></pre> <p>That might allow you to easily go from <code>double</code> to <code>int</code> or others if needed, but you wouldn't be able to use <code>ComputeSomething</code> with <code>double</code> and <code>int</code> in the same program.</p> <p>But why not replace all <code>double</code> to <code>int</code> then? Because your method may want to use a <code>double</code> whether the input is <code>double</code> or <code>int</code>. The alias allows you to know exactly which variable uses the <em>dynamic</em> type.</p>
5,265
<p>Help! I am using jQuery to make an AJAX call to fill in a drop-down dynamically given the user's previous input (from another drop-down, that is filled server-side). In all other browsers aside from Firefox (IE6/7, Opera, Safari), my append call actually appends the information below my existing option - "Select An ". But in Firefox, it automatically selects the last item given to the select control, regardless of whether I specify the JQuery action to .append or to replace (.html()). </p> <pre><code>&lt;select name="Products" id="Products" onchange="getHeadings(this.value);"&gt; &lt;option value=""&gt;Select Product&lt;/option&gt; &lt;/select&gt; function getProducts(Category) { $.ajax({ type: "GET", url: "getInfo.cfm", data: "Action=getProducts&amp;Category=" + Category, success: function(result){ $("#Products").html(result); } }); }; </code></pre> <p>Any thoughts? I have tried in the past to also transmit another blank first option, and then trigger a JavaScript option to re-select the first index, but this triggers the onChange event in my code, rather annoying for the user.</p> <hr> <p>Update:</p> <p>Here's an example of what the script would return</p> <pre><code>&lt;option value="3"&gt;Option 1&lt;/option&gt; &lt;option value="4"&gt;Option 2&lt;/option&gt; &lt;option value="6"&gt;Option 3&lt;/option&gt; </code></pre> <p>Optionally, if using the .html() method instead of the .append(), I would put another</p> <pre><code>&lt;option value=""&gt;Select a Product&lt;/option&gt; </code></pre> <p>at the top of the result.</p> <hr> <p>@Darryl Hein</p> <p>Here's an example of what the script would return</p> <pre><code>&lt;option value="3"&gt;Option 1&lt;/option&gt; &lt;option value="4"&gt;Option 2&lt;/option&gt; &lt;option value="6"&gt;Option 3&lt;/option&gt; </code></pre> <p>Optionally, if using the .html() method instead of the .append(), I would put another</p> <pre><code>&lt;option value=""&gt;Select a Product&lt;/option&gt; </code></pre> <p>at the top of the result.</p>
<p>Can you just change your success function to reset the selected item to the first option?</p> <pre><code>$("#Products").append(result).selectedIndex = 0; </code></pre> <p>or to set it to the previous selection?</p> <pre><code>var tmpIdx = $("#Products").selectedIndex; $("#Products").append(result).selectedIndex = tmpIdx; </code></pre> <p>If the onChange event should not fire then you can always set a flag to indicate that the form is updating and change events can check for that flag and exit if it is set.</p>
<p>I just did the following and it worked fine:</p> <pre><code>&lt;select name="Products" id="Products"&gt; &lt;option value=""&gt;Select Product&lt;/option&gt; &lt;/select&gt; &lt;script type="text/javascript"&gt; $('#Products').append('&lt;option value="1"&gt;test 1&lt;/option&gt;&lt;option value="3"&gt;test 3&lt;/option&gt;&lt;option value="3"&gt;test 3&lt;/option&gt;'); &lt;/script&gt; </code></pre> <p>What is your script returning?</p>
8,171
<p>I'm using a few (2 or 3) master pages in my ASP.NET MVC application and they must each display bits of information from the database. Such as a list of sponsors, current fundings status etc.</p> <p>So my question was, where should I put these master-page database calling code?</p> <p>Normally, these should goes into its own controller class right? But then that'd mean I'd have to wire them up manually (e.g. passing ViewDatas) since it is out of the normal routing framework provided by the MVC framework.</p> <p>Is there a way to this cleanly without wiring ViewData passing/Action calls to master pages manually or subclassing the frameworks'?</p> <p>The amount of documentation is very low... and I'm very new to all this including the concepts of MVC itself so please share your tips/techniques on this.</p>
<p>One way to do this is to put in the masterpage view the hook for the ViewData and then you define a BaseController : Controller (or multiple base classes) where you do all the db calls you need.</p> <p>What you wanna do is quite the same thing described in <a href="http://weblogs.asp.net/stephenwalther/archive/2008/08/12/asp-net-mvc-tip-31-passing-data-to-master-pages-and-user-controls.aspx" rel="nofollow noreferrer">this</a> articles.</p> <p>I hope this helps!</p> <p>Regards</p>
<p>If you don't mind strongly typed view data, you can put all the master page data in a common base class for viewData. You can set this data in the base class's constructor. All your views requiring additional data will then need strongly typed viewdata that inherits from this base class.</p> <p>To allow a call to View() in your controllers without any explicit viewdata you can override View in your ControllerBase:</p> <pre><code>protected override ViewResult View(string viewName, string masterName, object model) { if (model == null) { model = new ViewDataBase(); } return base.View(viewName, masterName, model); } </code></pre>
8,541
<p>We have an error that we can't seem to find and don't have the need/resources to try and track it down. What we do need to do is just keep the freaking "Please tell Microsoft about this problem" dialog boxes from cluttering up the server.</p> <p>It is from an MS-Access error (we think) but I can't find where Access is installed (I don't think it is); there is no MS Office directory on any of the drives.</p> <p>If we could just stop the dialog boxes from appearing that would be great.</p> <p>Thanks.</p> <p>Spec: Window Server 2003 sp2</p>
<p>From <a href="http://www.codeproject.com/KB/exception/UnhandledExceptionClass.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/exception/UnhandledExceptionClass.aspx</a>:</p> <blockquote> <p>If you also want to disable the Windows “Send Error Report” dialog on your computer, right-click on the “My Computer” icon, select “Properties”, switch to the “Advanced” tab, and click on the “Error Reporting” button. In the Options dialog, select the “Disable error reporting” radio button:<br> <img src="https://i.stack.imgur.com/1bjZg.png"></p> </blockquote> <p>Compare also <a href="http://www.codeproject.com/KB/exception/ExceptionHandling.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/exception/ExceptionHandling.aspx</a> for general .NET Exception Handling sanity.</p>
<p>When working in .net, you can catch all unhandled exceptions (which is what causes this message). But I'm not aware of a way to do the same in Access.</p> <p><a href="http://devcity.net/Articles/60/1/unhandled_exceptions.aspx" rel="nofollow noreferrer">http://devcity.net/Articles/60/1/unhandled_exceptions.aspx</a></p>
7,866
<p>Imagine the scene, you're updating some legacy Sybase code and come across a cursor. The stored procedure builds up a result set in a #temporary table which is all ready to be returned except that one of columns isn't terribly human readable, it's an alphanumeric code.</p> <p>What we need to do, is figure out the possible distinct values of this code, call another stored procedure to cross reference these discrete values and then update the result set with the newly deciphered values:</p> <pre><code>declare c_lookup_codes for select distinct lookup_code from #workinprogress while(1=1) begin fetch c_lookup_codes into @lookup_code if @@sqlstatus&lt;&gt;0 begin break end exec proc_code_xref @lookup_code @xref_code OUTPUT update #workinprogress set xref = @xref_code where lookup_code = @lookup_code end </code></pre> <p>Now then, whilst this may give some folks palpitations, it does work. My question is, how best would one avoid this kind of thing?</p> <p>_NB: for the purposes of this example you can also imagine that the result set is in the region of 500k rows and that there are 100 distinct values of look_up_code and finally, that it is not possible to have a table with the xref values in as the logic in proc_code_xref is too arcane._</p>
<p>You have to have a XRef table if you want to take out the cursor. Assuming you know the 100 distinct lookup values (and that they're static) it's simple to generate one by calling proc_code_xref 100 times and inserting the results into a table</p>
<p>They say, that if you must use cursor, then, you must have done something wrong ;-) here's solution without cursor:</p> <pre><code>declare @lookup_code char(8) select distinct lookup_code into #lookup_codes from #workinprogress while 1=1 begin select @lookup_code = lookup_code from #lookup_codes if @@rowcount = 0 break exec proc_code_xref @lookup_code @xref_code OUTPUT delete #lookup_codes where lookup_code = @lookup_code end </code></pre>
3,538
<p>So I recently installed a genuine E3D V6 (direct) on my AM8 (Anet a8 with upgraded frame). I have already been able to fix most of the print quality problems. But the last one is a hard one for me. </p> <p>It prints super fine up until a certain height. Then the extruder starts slipping and starts making weird noises like its clogged but I will be able to push through filament properly after cancelling the print. I thought it was heat creep but when touching the spiral heat break it is just a tad warm. I can comfortably put my finger on it and keep it there. </p> <p>I also tried two different brands of filament and it seems to happen roughly at the same spot. </p> <p>I tried PID tuning (the temps are literally perfect and super straight with no fluctuations), I tried cleaning the extruder gear and checked if it was worn or anything. Then I tightened everything on the extruder, making sure everything was nice and snug. </p> <p>I am not exactly a newbie when it comes to fixing my own printer and troubleshooting the problems but this one I have never seen or had before. </p> <p>Do you guys have any tips for me to point me in the right direction?</p> <p>Running Marlin 1.1.8. I have a BLTouch on it and an AnyCubic UltraBase. </p>
<p>I used a different heat break with a PFTE lining inside. After that it ran smoothly. </p> <p>Probably what was happening was that my filament was getting too hot and started to stick on the full metal heat break. </p>
<p>I have had some similar problems as you describe with my custom build CoreXY printer. I used an all-metal heat break for my 2.85 mm diameter filament. The heat break clogged up. I found that the inner diameter of the heatbreak, although specifically designed for 3 mm filament, narrowed down having a ledge inside. I replaced the heat break with a spare with a teflon tube inside, and never had any problems again.</p> <p>Since then I scoured the internet to find some proper all metal heat breaks and order a few that do not seem to have that deficiency. I have not tried these (while hot, but when cold the filament also moves better through it and does not get stuck on a ledge like the first one), but will when I print POM and <a href="https://colorfabb.com/pa-cf-low-warp-679" rel="nofollow noreferrer">ColorFabb PA-CF Low Warp</a> with my soon to arrive Olsson Ruby nozzle.</p>
901
<blockquote> <p>Note that this question continues from <a href="https://stackoverflow.com/questions/15414/">Is it possible to coax Visual Studio 2008 into using italics for comments?</a></p> </blockquote> <p>If the long question title got you, here's the problem:</p> <blockquote> <p>How to convert the style property of the Consolas Italic font to Bold without actually modifying any of its actual glyphs? That is, we want the font to be still the same (i.e., Italic) we merely want the OS to believe that it's now a Bold font.</p> </blockquote> <p>Please just don't mention the name of a tool (Ex: fontforge), but describe the steps to achieve this or point to such a description.</p>
<p>Alright, I've successfully used FontForge to create a copy of Consolas (although this should work with any font) with the bold style actually being italics.</p> <p>These are the steps that I followed:</p> <ul> <li>Install <a href="http://fontforge.sourceforge.net/" rel="noreferrer">FontForge</a>. It's a lot easier to do this on linux than on windows/cygwin. I used a Ubuntu VM ("sudo apt-get install fontforge").</li> <li>Open Consola.ttf (the "normal" style font) in FontForge.</li> <li>Select Element -> Font Info.</li> <li>Change the Fontname, Family Name, and Name for Humans, all to the same thing. I used 'ConsolasVS'.</li> <li>Click Ok. Click 'Yes' to let FontForge generate a new GUID for the font.</li> <li>Select File -> Generate Fonts. Make sure you've got "TrueType" selected. Uncheck "Validate before saving". Click Save.</li> <li>Now open Consolai.ttf (the italic style font) in FontForge.</li> <li>Go back to Element -> Font Info.</li> <li>Change the Font names as before, and where it currently says "Italic", change that to "Bold".</li> <li>Go to the OS/2 tab, change the font weight to "700 Bold".</li> <li>Go to the Mac tab, change the style set to Bold.</li> <li>Click Ok. Allow a new GUID to be generated again.</li> <li>File -> Generate Fonts, as before.</li> </ul> <p>Copy your two new ttf files into your \Windows\FONTS\ folder.</p> <p>You can now have nice italic comments with Consolas in VS2008. Hooray!</p>
<p>I did the italics-as-bold trick on Consolas back in July 2007 and posted a <a href="http://damieng.com/blog/2007/07/11/italic-syntax-highlighting-in-visual-studio-2005" rel="nofollow noreferrer">screenshot of it on my blog</a>.</p> <p>I used FontLab which does a great job but a custom tool to copy and set the header would be the best bet as you can't modify and redistribute Consolas and FontLab costs $699.</p> <p>If you want to go down the FontLab route the open up the regular and italic versions and go into the File &gt; Font Info... menu option and use the Names and Copyright section.</p> <p>In there set them both fonts Family Name to a new name then flip the checkboxes on the italic version to indicate bold instead of italic and select Normal from the Weight list box and Italic in the Style Name list box.</p> <p>Save and install :)</p>
3,814
<p>I cannot figure out how to change the title bar icon (the icon in the furthest top left corner of the application) in Adobe AIR. It is currently displaying the default 'Adobe AIR' red icon. </p> <p>I have been able to change it in the system tray, however.</p>
<p>Does the following help?</p> <p><a href="http://groups.google.com/group/chennai-flex-user-group/browse_thread/thread/cffb9ab56450c28e" rel="nofollow noreferrer">http://groups.google.com/group/chennai-flex-user-group/browse_thread/thread/cffb9ab56450c28e</a></p>
<p>The first link shows how to change the Taskbar Icon, the second shows the application icon I believe used on the desktop. I am going to recompile and install the application and see if it works.</p> <p>Edit: Yea, the one that changes the Desktop Icon also changes the Title Bar icon. It's in the app.xml file.</p>
3,892
<p>Is there any way in the Servlet API to access properties specified in web.xml (such as initialization parameters) from within a Bean or Factory class that is not associated at all with the web container?</p> <p>For example, I'm writing a Factory class, and I'd like to include some logic within the Factory to check a hierarchy of files and configuration locations to see which if any are available to determine which implementation class to instantiate - for example, </p> <ol> <li>a properties file in the classpath,</li> <li>a web.xml parameter, </li> <li>a system property, or </li> <li>some default logic if nothing else is available. </li> </ol> <p>I'd like to be able to do this without injecting any reference to <code>ServletConfig</code> or anything similiar to my Factory - the code should be able to run ok outside of a Servlet Container.</p> <p>This might sound a little bit uncommon, but I'd like for this component I'm working on to be able to be packaged with one of our webapps, and also be versatile enough to be packaged with some of our command-line tools without requiring a new properties file just for my component - so I was hoping to piggyback on top of other configuration files such as web.xml.</p> <p>If I recall correctly, .NET has something like <code>Request.GetCurrentRequest()</code> to get a reference to the currently executing <code>Request</code> - but since this is a Java app I'm looking for something simliar that could be used to gain access to <code>ServletConfig</code>.</p>
<p>One way you could do this is:</p> <pre><code>public class FactoryInitialisingServletContextListener implements ServletContextListener { public void contextDestroyed(ServletContextEvent event) { } public void contextInitialized(ServletContextEvent event) { Properties properties = new Properties(); ServletContext servletContext = event.getServletContext(); Enumeration&lt;?&gt; keys = servletContext.getInitParameterNames(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = servletContext.getInitParameter(key); properties.setProperty(key, value); } Factory.setServletContextProperties(properties); } } public class Factory { static Properties _servletContextProperties = new Properties(); public static void setServletContextProperties(Properties servletContextProperties) { _servletContextProperties = servletContextProperties; } } </code></pre> <p>And then have the following in your web.xml</p> <pre><code>&lt;listener&gt; &lt;listener-class&gt;com.acme.FactoryInitialisingServletContextListener&lt;listener-class&gt; &lt;/listener&gt; </code></pre> <p>If your application is running in a web container, then the listener will be invoked by the container once the context has been created. In which case, the _servletContextProperties will be replaced with any context-params specified in the web.xml.</p> <p>If your application is running outside a web container, then _servletContextProperties will be empty.</p>
<p>I think that you will have to add an associated bootstrap class which takes a reference to a ServletConfig (or ServletContext) and transcribes those values to the Factory class. At least this way you can package it separately.</p> <p>@toolkit : Excellent, most humbled - This is something that I have been trying to do for a while</p>
6,302
<p>Whilst analysing some legacy code with FXCop, it occurred to me is it really that bad to catch a general exception error within a try block or should you be looking for a specific exception. Thoughts on a postcard please.</p>
<p>Obviously this is one of those questions where the only real answer is "it depends."</p> <p>The main thing it depends on is where your are catching the exception. In general libraries should be more conservative with catching exceptions whereas at the top level of your program (e.g. in your main method or in the top of the action method in a controller, etc) you can be more liberal with what you catch.</p> <p>The reason for this is that e.g. you don't want to catch all exceptions in a library because you may mask problems that have nothing to do with your library, like "OutOfMemoryException" which you really would prefer bubbles up so that the user can be notified, etc. On the other hand, if you are talking about catching exceptions inside your main() method which catches the exception, displays it and then exits... well, it's probably safe to catch just about any exception here.</p> <p>The most important rule about catching all exceptions is that you should never just swallow all exceptions silently... e.g. something like this in Java:</p> <pre><code>try { something(); } catch (Exception ex) {} </code></pre> <p>or this in Python:</p> <pre><code>try: something() except: pass </code></pre> <p>Because these can be some of the hardest issues to track down.</p> <p>A good rule of thumb is that you should only catch exceptions that you can properly deal with yourself. If you cannot handle the exception completely then you should let it bubble up to someone who can.</p>
<p>For my IabManager class, which I used with in-app billing (from the TrivialDrive example online), I noticed sometimes I'd deal with a lot of exceptions. It got to the point where it was unpredictable.</p> <p>I realized that, as long as I ceased the attempt at trying to consume an in-app product after one exception happens, which is where most of the exceptions would happen (in consume, as opposed to buy), I would be safe.</p> <p>I just changed all the exceptions to a general exception, and now I don't have to worry about any other random, unpredictable exceptions being thrown.</p> <p>Before:</p> <pre><code> catch (final RemoteException exc) { exc.printStackTrace(); } catch (final IntentSender.SendIntentException exc) { exc.printStackTrace(); } catch (final IabHelper.IabAsyncInProgressException exc) { exc.printStackTrace(); } catch (final NullPointerException exc) { exc.printStackTrace(); } catch (final IllegalStateException exc) { exc.printStackTrace(); } </code></pre> <p>After:</p> <pre><code> catch (final Exception exc) { exc.printStackTrace(); } </code></pre>
4,195
<p>What are the methods to auto eject parts (into a collection area/box/basket) in order for the 3D printer to continue printing?</p> <p>For some reason this feature isn't common (yet?). Is there a hidden reason why?</p> <p>Will using the print head to ram the part off the build plate into a basket nearby cause the print head to misalign (if using belts).</p> <p>I am planning to use a Cartesian XY-Head type (like CoreXY) printer, where the build plate moves along the Z axis and XY axes are on the ceiling of the printer using belts to move the print head.</p>
<p>While the "best" method is probably unanswerable since it would be based on very specific requirements and subject to change as soon as a better method were devised, here are some feasible methods to auto-eject 3d printed parts.</p> <p>Some of these are methods that I've considered for my personal use, others have been mentioned by others and added for helpful reference. Some have been done, others have not (I think), but all of them are feasible.</p> <p><strong>Scrolling Conveyor-type Bed:</strong></p> <ul> <li>In this concept, parts become dislodged from the print surface as it is deformed around a roller in the process of scrolling to the next position. Scrolling bed designs must make allowances to prevent parts from lifting up the bed material which becomes an issue especially with warp-prone materials. Note: This is the basis of the <a href="http://www.thingiverse.com/thing:4056" rel="noreferrer">Automated Build Platform</a> (ABP) originally designed (as far as I can tell) by Charles Pax and later covered in several patents by Makerbot Industries.</li> </ul> <p><strong>Deforming Bed:</strong></p> <ul> <li>In this concept, the bed is mechanically deformed when the part removal temperature has been reached. This deformation dislodges the part which can then be easily swept off of the bed by an arm or similar mechanism. (As far as I know, this concept has not yet been demonstrated.)</li> </ul> <p><strong>Articulated Segmented Bed:</strong></p> <ul> <li>In this concept, the bed is comprised of several strips. Slightly lowering a portion (let's say half) of the strips would separate them from the part, then slightly raising that portion would separate the part from the remaining strips. (As far as I know, this concept has not yet been demonstrated.)</li> </ul> <p><strong>Eject and Replace Bed:</strong></p> <ul> <li>This method ejects the entire bed surface along with the finished parts and then receives a fresh print surface for the next print. This method would likely still require intervention to remove parts from used print surfaces and then return them to the clean stack. (As far as I know, this concept has not yet been demonstrated.)</li> </ul> <p><strong>Plow:</strong></p> <ul> <li>This method mentioned by Fred_dot_u and AllanL uses a specially designed plow arm to sweep parts off the bed between prints. This method has been effectively demonstrated in <a href="https://www.youtube.com/watch?v=x-5-a2NN2Vk" rel="noreferrer">this video</a> by New Valance Robotics Corporation that was mentioned by AllanL (thanks!).</li> </ul> <p><strong>Issues using print head to eject parts:</strong> While this method has been tried, and demonstrated (see below), it has some challenges/drawbacks.</p> <ul> <li><p>Typical FDM/FFF 3d printers are not designed to apply significant force behind print head movements. While a printer designed specifically for this purpose could be built, using a typical printer in this way is extremely likely to cause the stepper motors to loose steps and result in loss of position accuracy unless parts separate very easily. (however, position could easily be regained by zeroing via limit switches between prints.) </p></li> <li><p>In addition to skipping steps, mechanical issues such as ratcheting/skipping belts or unwanted frame movement could result from even moderately stuck prints.</p></li> </ul> <p><strong>Examples of pushing or ramming parts off of bed:</strong> While using various parts of the printer to push parts off of the bed may not be an ideal solution, it may be an adequate solution for specific circumstances. Here are a few demonstrations of the "ramming" method.</p> <ul> <li><p>Ramming parts off with frame and moving bed <a href="https://www.youtube.com/watch?v=gnme8Tx00bg" rel="noreferrer">like this.</a></p></li> <li><p>Ramming part with robust print head <a href="https://www.youtube.com/watch?v=-LcDqVwJYvo" rel="noreferrer">like this.</a></p></li> <li><p>Ramming easy to remove part with print head <a href="https://www.youtube.com/watch?v=1jgEx-ICjwA" rel="noreferrer">like this.</a></p></li> </ul> <p>Interesting question. I hope this helps!</p>
<p>Here's a wild idea. Since you're planning to have a bed which only moves in the Z-axis, build a roller system which feeds a thin, flexible layer of some material (unobtanium, I fear) to cover the build plate. The feed rollers have a weak spring to provide some tension to keep this layer flat but not overly stretched while building the part. When the part is done, lower the bed to zero while allowing the roller to retract excess parts of the sheet (rollers on both sides of the build plate will have to do this). At zero, lock down the rollers and move the bed to some negative Z position, causing the overlay sheet to pop free of the bed and ideally pop the printed parts loose as well. <a href="https://i.stack.imgur.com/XRhXu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XRhXu.jpg" alt="demo concept"></a></p> <p>Hey, it "could" work!</p>
406
<p>I just assembled Ender 3 and noticed that the X-axis movement doesn't correspond to the commands. When I make it move 1 mm with the encoder it moves 16 mm. Everything is in the &quot;out of the box&quot; configuration.</p> <p>The current steps/mm for the X-axis read (from the display) 80 steps/mm.</p> <p>Am I supposed to manually fix this with steps per mm setting or could it be another problem. Other axes seem to work fine. I also double checked and everything should be built correctly.</p>
<p>Direct Drive v.s. Bowden has no relation to the maximum print temperature. What determines the maximum print temperature is the design of the hotend itself. There are &quot;all-metal&quot; designs, where the PTFE tube (Bowden or not) stops in the cold zone and the heatbreak and all other components that get hot are fully made of metal. Other hotend designs have the PTFE tube run all the way down into the hot zone and this limits the maximum printing temperature. It has nothing to do with whether the hotend is Bowden or not.</p>
<p>Bowden tubes extending to the nozzle to make a seal will damage the Teflon (PTFE) tube if exceeding 250°C for an extended time. An all-metal hotend for a Bowden would have either the nozzle sealed against the heatbreak or an integrated nozzle and heatbreak. Then the Bowden tube would attach with a minimum gape with either the heatbreak or heatsink.</p> <p>Note: The heater block needs to be at the maximum operating temperature When making a seal between the nozzle and heatbreak.</p>
1,960
<p>Consider the class below that represents a Broker:</p> <pre><code>public class Broker { public string Name = string.Empty; public int Weight = 0; public Broker(string n, int w) { this.Name = n; this.Weight = w; } } </code></pre> <p>I'd like to randomly select a Broker from an array, taking into account their weights.</p> <p>What do you think of the code below?</p> <pre><code>class Program { private static Random _rnd = new Random(); public static Broker GetBroker(List&lt;Broker&gt; brokers, int totalWeight) { // totalWeight is the sum of all brokers' weight int randomNumber = _rnd.Next(0, totalWeight); Broker selectedBroker = null; foreach (Broker broker in brokers) { if (randomNumber &lt;= broker.Weight) { selectedBroker = broker; break; } randomNumber = randomNumber - broker.Weight; } return selectedBroker; } static void Main(string[] args) { List&lt;Broker&gt; brokers = new List&lt;Broker&gt;(); brokers.Add(new Broker("A", 10)); brokers.Add(new Broker("B", 20)); brokers.Add(new Broker("C", 20)); brokers.Add(new Broker("D", 10)); // total the weigth int totalWeight = 0; foreach (Broker broker in brokers) { totalWeight += broker.Weight; } while (true) { Dictionary&lt;string, int&gt; result = new Dictionary&lt;string, int&gt;(); Broker selectedBroker = null; for (int i = 0; i &lt; 1000; i++) { selectedBroker = GetBroker(brokers, totalWeight); if (selectedBroker != null) { if (result.ContainsKey(selectedBroker.Name)) { result[selectedBroker.Name] = result[selectedBroker.Name] + 1; } else { result.Add(selectedBroker.Name, 1); } } } Console.WriteLine("A\t\t" + result["A"]); Console.WriteLine("B\t\t" + result["B"]); Console.WriteLine("C\t\t" + result["C"]); Console.WriteLine("D\t\t" + result["D"]); result.Clear(); Console.WriteLine(); Console.ReadLine(); } } } </code></pre> <p>I'm not so confident. When I run this, Broker A always gets more hits than Broker D, and they have the same weight.</p> <p>Is there a more accurate algorithm?</p> <p>Thanks!</p>
<p>Your algorithm is nearly correct. However, the test should be <code>&lt;</code> instead of <code>&lt;=</code>:</p> <pre><code>if (randomNumber &lt; broker.Weight) </code></pre> <p>This is because 0 is inclusive in the random number while <code>totalWeight</code> is exclusive. In other words, a broker with weight 0 would still have a small chance of being selected – not at all what you want. This accounts for broker A having more hits than broker D.</p> <p>Other than that, your algorithm is fine and in fact the canonical way of solving this problem.</p>
<p>I've come up with a generic version of this solution:</p> <pre><code>public static class WeightedEx { /// &lt;summary&gt; /// Select an item from the given sequence according to their respective weights. /// &lt;/summary&gt; /// &lt;typeparam name="TItem"&gt;Type of item item in the given sequence.&lt;/typeparam&gt; /// &lt;param name="a_source"&gt;Given sequence of weighted items.&lt;/param&gt; /// &lt;returns&gt;Randomly picked item.&lt;/returns&gt; public static TItem PickWeighted&lt;TItem&gt;(this IEnumerable&lt;TItem&gt; a_source) where TItem : IWeighted { if (!a_source.Any()) return default(TItem); var source= a_source.OrderBy(i =&gt; i.Weight); double dTotalWeight = source.Sum(i =&gt; i.Weight); Random rand = new Random(); while (true) { double dRandom = rand.NextDouble() * dTotalWeight; foreach (var item in source) { if (dRandom &lt; item.Weight) return item; dRandom -= item.Weight; } } } } /// &lt;summary&gt; /// IWeighted: Implementation of an item that is weighted. /// &lt;/summary&gt; public interface IWeighted { double Weight { get; } } </code></pre>
8,074
<p>I'm just curious if any project exists that attempts to group all (or most) of PHP's built-in functions into a more object-oriented class hierarchy. For example, grouping all the string functions into a single String class, etc.</p> <p>I realize this won't actually solve any problems (unless the modifications took place at the PHP source code level), since all the built-in functions would still be accessible in the global namespace, but it would certainly make usability much easier.</p>
<p>I think something like this is intergral for PHP to move forward. Being mainly a .Net programmer, I find PHP painful to work in with it's 1 million and 1 global functions. It's nice that PHP 5.3 has namespaces, but it doesn't help things much when their own libraries aren't even object oriented, let alone employ namespaces. I don't mind PHP as a language so much, but their API is terribly disorganized, and it probably needs a complete overhaul. Kind of like what VB went through when it became VB.Net.</p>
<p>I don't agree. Object Oriented Programming is not inherently better than procedural programming. I believe that you should not use OO unless you need polymorphic behavior (inheritance, overriding methods, etc). Using objects as simple containers for code is not worth the overhead. This is <em>particularly</em> true of strings because their used so much (e.g. as array keys). Every application can usually benifit from some polymorphic features but usually at a high level. Would you ever want to extend a String class?</p> <p>Also, a little history is necessary to understand PHP's odd function naming. PHP is grounded around The Standard C Library and POSIX standard and uses many of the same function names (strstr, getcwd, ldap_open, etc). This is actually a good thing because it minimizes the amount of language binding code, ensures that a full well thought out set of features (just about anything you can do in C you can do in PHP) and these system libraries are highly optimized (e.g. strchr is usually inlined which makes it about 10x faster).</p>
8,710
<p>I like to study languages outside my comfort zone, but I've had a hard time finding a place to start for functional languages. I heard a lot of good things about <a href="https://rads.stackoverflow.com/amzn/click/com/0070004846" rel="noreferrer" rel="nofollow noreferrer">Structure and Interpretations of Computer Programs</a>, but when I tried to read through it a couple of years ago it just seemed to whiz over my head. I do way better with books than web sites, but when I visit the local book store the books on LISP look kind of scary.</p> <p>So what's a good starting point? My goal is to be able to use a functional programming language to solve simple problems in 6 months or so, and the ability to move to more advanced topics, recognize when a functional language is the right tool for the job, and use the language to solve more problems over the course of 2-3 years. I like books that are heavy on examples but also include challenges to work through. Does such a thing exist for functional languages?</p>
<p><a href="http://www.ccs.neu.edu/home/matthias/BTLS/" rel="noreferrer">The Little Schemer</a> teaches recursion really well, and it's fun and simple to read. </p> <p>I also liked <a href="http://www.scheme.com/tspl3/" rel="noreferrer">The Scheme Programming Language</a> for a broader introduction into the language. </p>
<p>I have heard good things about <a href="https://rads.stackoverflow.com/amzn/click/com/0201342758" rel="nofollow noreferrer" rel="nofollow noreferrer">Haskell Functional Programming</a>, but I also found this <a href="http://www.amazon.com/LISP-Functional-Programming-Books/lm/36GEU8N3B2JPW" rel="nofollow noreferrer">list</a> of functional programming books at amazon that might be helpful to you.</p>
4,313
<p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p> <p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
<p>As Google Web Toolkit is a <a href="http://code.google.com/support/bin/answer.py?answer=54830&amp;topic=10208" rel="nofollow noreferrer">subset of Java</a> it works best when you Java at the backend too. Since Google App Engine is currently <a href="http://code.google.com/appengine/kb/general.html#language" rel="nofollow noreferrer">Python only</a> I think you'd have to do a lot of messing about to get your server and client to talk nicely to each other.</p> <p>jQuery seems to be the most popular JavaScript library option in the <a href="http://www.djangosnippets.org/tags/ajax/?page=1" rel="nofollow noreferrer">AJAX Tag at DjangoSnippets.com</a>.</p> <p><strong>Edit:</strong> The above is only true of Google App Engine applications written in Python. As Google App Engine now supports Java, GWT could now be a good choice for writing an AJAX front end. <a href="http://code.google.com/webtoolkit/doc/latest/tutorial/appengine.html" rel="nofollow noreferrer">Google even have a tutorial showing you how to do it.</a></p>
<p>If you want to be able to invoke method calls from JavaScript to Python, <a href="http://json-rpc.org/wiki/python-json-rpc" rel="nofollow noreferrer">JSON-RPC</a> works well with Google App Engine. See Google's article, "<a href="http://code.google.com/appengine/articles/rpc.html" rel="nofollow noreferrer">Using AJAX to Enable Client RPC Requests</a>", for details.</p>
7,757
<p>I know I should use different nozzles for filaments that use vastly different temperatures but what about filament types that use similar temperatures?</p> <p>For example, PLA and PLA composites like ColorFabb Woodfill filament. Should I use a separate nozzle for that?</p>
<p>There is absolutely no reason to use different nozzles, <em>not even if filaments do require different temperatures</em>.</p> <p>The only exception is when printing abrasive filaments (such as glow-in-the-dark and carbon-fiber) in which case you should use an abrasion-resistant, stainless steel nozzle. This nozzle can also be used to to print "regular" filaments but a regular brass nozzle has slightly more favorable properties if you do not require abrasion resistance.</p>
<p>It depends on the size of the nozzle you are using. If you are using a small nozzle, e.g. 0.2&nbsp;mm, normally, you should increase the nozzle diameter (filament manufacturers often refer to about 0.5&nbsp;mm nozzle diameters). Wood/cork, or whatever particle filled filament requires a somewhat larger diameter to prevent clogging.</p> <hr> <p>In addition to <a href="/a/2824/">Tom's answer</a>, note that there are stainless steel nozzles and hardened steel nozzles. The latter is harder than the prior and should be used for abrasive filaments, like filament filled with metal particles or some sort of abrasive fibres like glass or carbon fibre. Note that the addition of fibres or particles may require you to increase the nozzle diameter as fibres or particles may cause clogging. A last nozzle discussed is the nozzle with an embedded industrial Ruby, a design of Anders Olsson, a research engineer at Uppsala University, more information is found on the <a href="https://olssonruby.com/anders-olsson-olsson-ruby/" rel="nofollow noreferrer">Olsson Ruby website</a>.</p> <p>From the Olsson Ruby website, the following interesting image is shown, comparing the wear resistance of the various nozzle materials up to 0.5&nbsp;mm <em>(from left to right; brass, stainless steel and hardened steel by printing respectively 0.3&nbsp;kg, 1.0&nbsp;kg and 4&nbsp;kg of carbon fibre filled filament)</em>:</p> <p><a href="https://i.stack.imgur.com/f7ckg.png" rel="nofollow noreferrer" title="Nozzle material wear resistance compared"><img src="https://i.stack.imgur.com/f7ckg.png" alt="Nozzle material wear resistance compared" title="Nozzle material wear resistance compared"></a></p>
390
<p>Is there a way to tell MS SQL that a query is not too important and that it can (and should) take its time?</p> <p>Likewise is there a way to tell MS SQL that it should give higher priority to a query?</p>
<p>Not in versions below SQL 2008. In SQL Server 2008 there's the resource governor. Using that you can assign logins to groups based on properties of the login (login name, application name, etc). The groups can then be assigned to resource pools and limitations or restrictions i.t.o. resources can be applied to those resource pools</p>
<p>I'm not sure if this is what you're asking, but I had a situation where a single UI click added 10,000 records to an email queue (lots of data in the body). The email went out over the next several days so it didn't need to be a high priority, in fact it would bog the server every time it happened.</p> <p>I split the procedure into 10,000 individual calls, ran the process on the UI in a different thread (set to low priority) and set it to sleep for a second after running the procedure. It took a while, but I had very granular control over exactly what it was doing.</p> <p>btw, this was NOT spam, so don't flame me thinking it was.</p>
8,594
<p>What options exist for accessing different databases from C++? Put differently, what alternatives are there to ADO? What are the pros and cons?</p>
<ol> <li><a href="http://msdn.microsoft.com/en-us/library/ms710252.aspx" rel="nofollow noreferrer">Microsoft ODBC</a>.</li> <li>The MFC ODBC classes such as <a href="http://msdn.microsoft.com/en-us/library/2dhc1abk.aspx" rel="nofollow noreferrer">CDatabase</a>.</li> <li><a href="http://msdn.microsoft.com/en-us/library/ms722784.aspx" rel="nofollow noreferrer">OleDB</a> (via COM).</li> <li>And you can always go through the per-RDBMS native libraries (for example, the <a href="http://msdn.microsoft.com/en-us/library/ms722784.aspx" rel="nofollow noreferrer">SQL Server native library</a>)</li> <li><a href="http://msdn.microsoft.com/en-us/library/aa163992.aspx" rel="nofollow noreferrer">DAO</a> (don't).</li> <li>3rd party ORM providers.</li> </ol> <p>I would recommend going through ODBC or OleDB by default. Native libraries really restrict you, DAO is no fun, there aren't a lot of great 3rd-party ORM for C++/Windows.</p>
<p>One thing - if speed is important and your code doesn't need to be portable, then it may be worth it to use the native libraries. </p> <p>I don't know much about SQL Server, but I do know that the Oracle OCI calls are faster than using ODBC. But, they tie you to Oracle's version of SQL. It would make sense for SQL Server to be the same way. </p>
7,277
<p>I'm trying to use Visual Studio 2008's extensibility to write an addin that will create a project folder with various messages in it after parsing an interface. I'm having trouble at the step of creating/adding the folder, however. I've tried using </p> <pre><code>ProjectItem folder = item.ProjectItem.Collection.AddFolder(newDirectoryName, string.Empty); </code></pre> <p>(item is my target file next to which I'm creating a folder with the same name but "Messages" appended to it) but it chokes when a folder already exists (no big surprise).</p> <p>I tried deleting it if it already exists, such as: </p> <pre><code>DirectoryInfo dirInfo = new DirectoryInfo(newDirectoryParent + newDirectoryName); if (dirInfo.Exists) { dirInfo.Delete(true); } ProjectItem folder = item.ProjectItem.Collection.AddFolder(newDirectoryName, string.Empty); </code></pre> <p>I can SEE that the folder gets deleted when in debug, but it still seems to think the folder is still there and dies on a folder already exists exception. </p> <p>Any ideas??? </p> <p>Thanks. </p> <p>AK </p> <p>.... Perhaps the answer would lie in programmatically refreshing the project after the delete? How might this be done?</p>
<p>Yup, that was it...</p> <pre><code>DirectoryInfo dirInfo = new DirectoryInfo(newDirectoryParent + newDirectoryName); if (dirInfo.Exists) { dirInfo.Delete(true); item.DTE.ExecuteCommand("View.Refresh", string.Empty); } ProjectItem folder = item.ProjectItem.Collection.AddFolder(newDirectoryName, string.Empty); </code></pre> <p>If there's a more elegant way of doing this, it would be much appreciated...</p> <p>Thanks.</p>
<p>here's an idea i thought of because i've been using NAnt for so long and thought it might work. </p> <p>Open the .csproj file in a text editor and add the directory as such:</p> <pre><code>&lt;ItemGroup&gt; &lt;compile include="\path\rootFolderToInclude\**\*.cs" /&gt; &lt;/ItemGroup&gt; </code></pre> <p>if an "ItemGroup" already esists, that's fine. Just add it into an existing one. Visual studio won't really know how to edit this entry, but it will scan the whole directory.</p> <p>edit to whatever you'd like. </p>
8,991
<p>I would like to quickly send email from the command line. I realize there are probably a number of different ways to do this.</p> <p>I'm looking for a simple way to do this from a linux terminal (likely a bash shell but anything should do) and an alternative way to do this on Windows. I want to be able to whip up an email right on the command line or have the flexibility to pipe the message into the command line program. How would you go about doing this? If you have small scripts that would be fine as well.</p>
<pre><code>$ echo "This is the email body" | mail -s "This is the subject" me@email.com </code></pre> <p>Alternatively:</p> <pre><code>$ cat | mail -s "A few lines off the top of my head" me@here.com This is where my multiline message would go ^D </code></pre> <p>^D - means press <kbd>ctrl</kbd>+<kbd>d</kbd></p>
<p>If you want to invoke an email program, then see this article:</p> <p><a href="https://stackoverflow.com/questions/17373/how-do-i-open-the-default-mail-program-with-a-subject-and-body-in-a-cross-platf">How do I open the default mail program with a Subject and Body in a cross-platform way?</a></p>
5,708
<p>I'm looking for a way to get the size of an instance of a reference type. sizeof is only for value types. Is this possible?</p>
<p>You need <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.sizeof.aspx" rel="noreferrer">Marshal.SizeOf</a></p> <p><strong>Edit:</strong> This <em>is</em> for unsafe code, but then, so is sizeof().</p>
<p>Beware that Marshal.SizeOf is for unsafe code...</p> <p>I don't think it's possible for managed code though, maybe you can explain your problem, there may be another way to solve it</p>
4,614
<p>I am considering creating my own website using Java and am trying to decide what framework to use. However, doing a quick search for Java frameworks returns more than 50 to choose from!</p> <p>My website is just going to be for my own enjoyment of building it in the beginning, but if it becomes popular, it would be good for it to have some scalability, or to at least be able to redesign for that.</p> <p>What are the main differences between the more popular frameworks? Are there instances where one significantly outperforms the others? For example, high-traffic enterprise applications versus low-traffic small applications. I'm also wondering if some are much easier to learn and use than others.</p> <p>Is there anyone who has experience with some of these frameworks and can make a recommendation? Does the sheer number of choices just serve as an early warning to avoid Java-based web development where possible?</p>
<p>I've used <a href="http://tapestry.apache.org/tapestry3/" rel="noreferrer">Tapestry 3</a>, <a href="http://wicket.apache.org/" rel="noreferrer">Wicket</a>, <a href="http://echo.nextapp.com/site/" rel="noreferrer">Echo</a>, and <a href="http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html" rel="noreferrer">JSF</a> fairly extensively. I'd really recommend you look those over and pick the one that appears the easiest for you, and to most closely fit the way you prefer to work.</p> <p>Of them, the most comfortable for me to work with was <a href="http://wicket.apache.org/" rel="noreferrer">Wicket</a>, due to the lightweight nature of component building and simplicity of page templating. That goes doubly so if you are using your own db code instead of Hibernate or some other framework (I was never completely happy with Wicket Hibernate or Spring Integration).</p> <p><a href="http://echo.nextapp.com/site/" rel="noreferrer">Echo</a> is great if you don't mind writing all of your layout in Java. I know that is different now, but I still think that product serves a fairly narrow niche. They change the development model with every major release as well it seems.</p> <p><a href="http://tapestry.apache.org/tapestry3/" rel="noreferrer">Tapestry</a> is a great product, but it is obviously very different from the others in terms of development model as it is led mainly by one dude. Howard Lewis Ship is no doubt quite smart, but I am disappointed with their decision to basically forget backwards compatibility with each release. Again, though, for your needs this may not matter, and I've always found the Tapestry products pleasurable to work against.</p> <p><a href="http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html" rel="noreferrer">JSF</a> has been out for years, and still feels like something that a <a href="http://struts.apache.org/" rel="noreferrer">Struts</a> guy built to fix all of the problems of Struts. Without really understanding all of the problems with Struts. It still has an unfinished feel to it, although the product is obviously very flexible. I use it and have some fondness for it, with great hopes for its future. I think the next release (2.0) to be delivered in JEE6 will really bring it into its own, with a new template syntax (similar to Facelets) and a simplified component model (custom components in only 1 file... finally).</p> <p>And, of course, there are a million smaller frameworks and tools that get their own following (<a href="http://velocity.apache.org/" rel="noreferrer">Velocity</a> for basic needs, raw <a href="http://en.wikipedia.org/wiki/JavaServer_Pages" rel="noreferrer">JSPs</a>, Struts, etc). I generally prefer component oriented frameworks myself, though. </p> <p>In the end, I'd recommend just taking a look at Tapestry, Wicket, and JSF and just picking the one that feels the best to you. You'll probably find one that just fits the way you like to work very quickly.</p>
<p>Can't believe no one has mentioned GWT</p>
4,423
<p>I'm looking for a way to delete a file which is locked by another process using C#. I suspect the method must be able to find which process is locking the file (perhaps by tracking the handles, although I'm not sure how to do this in C#) then close that process before being able to complete the file delete using <code>File.Delete()</code>.</p>
<p>Killing other processes is not a healthy thing to do. If your scenario involves something like uninstallation, you could use the <a href="https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa" rel="nofollow noreferrer"><strong><code>MoveFileEx</code></strong> API function</a> to mark the file for deletion upon next reboot.</p> <p>If it appears that you really need to delete a file in use by another process, I'd recommend re-considering the actual problem before considering any solutions.</p>
<p>Oh, one big hack I employed years ago, is that Windows won't let you <em>delete</em> files, but it does let you <em>move</em> them.</p> <p>Pseudo-sort-of-code:</p> <pre><code>mv %WINDIR%\System32\mfc42.dll %WINDIR\System32\mfc42.dll.old Install new mfc42.dll Tell user to save work and restart applications </code></pre> <p>When the applications restarted (note we didn't need to reboot the machine), they loaded the new <code>mfc42.dll</code>, and all was well. That, coupled with <code>PendingFileOperations</code> to delete the old one the next time the whole system restarted, worked pretty well.</p>
2,345
<p>I am attempting to update a project from ASP.NET MVC Preview 3 to Preview 5 and it seems that Controller.ReadFromRequest(string key) has been removed from the Controller class. Does anyone know of any alternatives to retrieving information based on an identifier from a form?</p>
<p>Looks like they've added controller.UpdateModel to address this issue, signature is:</p> <pre><code>UpdateModel(object model, string[] keys) </code></pre> <p>I haven't upgraded my app personally, so I'm not sure of the actual usage. I'll be interested to find out about this myself, as I'm using <code>controller.ReadFromRequest</code> as well.</p>
<p>could you redo that link in something like tinyurl.com?</p> <p>I need this info too but can get that mega-link to work.</p>
5,670
<p>is there an alternative for <code>mysql_insert_id()</code> php function for PostgreSQL? Most of the frameworks are solving the problem partially by finding the current value of the sequence used in the ID. However, there are times that the primary key is not a serial column....</p>
<p>From the PostgreSQL point of view, in pseudo-code:</p> <pre><code> * $insert_id = INSERT...RETURNING foo_id;-- only works for PostgreSQL &gt;= 8.2. * INSERT...; $insert_id = SELECT lastval(); -- works for PostgreSQL &gt;= 8.1 * $insert_id = SELECT nextval('foo_seq'); INSERT INTO table (foo...) values ($insert_id...) for older PostgreSQL (and newer PostgreSQL) </code></pre> <p><code>pg_last_oid()</code> only works where you have OIDs. OIDs have been off by default since PostgreSQL 8.1.</p> <p>So, depending on which PostgreSQL version you have, you should pick one of the above method. Ideally, of course, use a database abstraction library which abstracts away the above. Otherwise, in low level code, it looks like:</p> <h1>Method one: INSERT... RETURNING</h1> <pre><code>// yes, we're not using pg_insert() $result = pg_query($db, "INSERT INTO foo (bar) VALUES (123) RETURNING foo_id"); $insert_row = pg_fetch_row($result); $insert_id = $insert_row[0]; </code></pre> <h1>Method two: INSERT; lastval()</h1> <pre><code>$result = pg_execute($db, "INSERT INTO foo (bar) values (123);"); $insert_query = pg_query("SELECT lastval();"); $insert_row = pg_fetch_row($insert_query); $insert_id = $insert_row[0]; </code></pre> <h1>Method three: nextval(); INSERT</h1> <pre><code>$insert_query = pg_query($db, "SELECT nextval('foo_seq');"); $insert_row = pg_fetch_row($insert_query); $insert_id = $insert_row[0]; $result = pg_execute($db, "INSERT INTO foo (foo_id, bar) VALUES ($insert_id, 123);"); </code></pre> <p>The safest bet would be the third method, but it's unwieldy. The cleanest is the first, but you'd need to run a recent PostgreSQL. Most db abstraction libraries don't yet use the first method though.</p>
<p>Check out the <a href="http://www.postgresql.org/docs/current/interactive/sql-insert.html" rel="nofollow noreferrer">RETURNING optional clause</a> for an INSERT statement. (Link to official PostgreSQL documentation)</p> <p>But basically, you do:</p> <pre><code>INSERT INTO table (col1, col2) VALUES (1, 2) RETURNING pkey_col </code></pre> <p>and the INSERT statement itself returns the id (or whatever expression you specify) of the affected row.</p>
7,980
<p>When printing objects higher than approximately 8-10&nbsp;cm, sometimes nozzle hits the printed model and knocks over it. After 7-8 hours of printing that's really annoying. I'm using Creality Ender 3 Pro with Ultimaker Cura. How can I avoid this problem?</p> <p>As a note; it happens with thick, wide models without support structure too. I'm using Ender 3 Pro's stock magnetic bed.</p> <p>Here are some photos of printed model.</p> <p><a href="https://i.stack.imgur.com/0hIqg.jpg" rel="nofollow noreferrer" title="Failed print - photo#1"><img src="https://i.stack.imgur.com/0hIqg.jpg" alt="Failed print - photo#1" title="Failed print - photo#1"></a></p> <p><a href="https://i.stack.imgur.com/HNiG4.jpg" rel="nofollow noreferrer" title="Failed print - photo#2"><img src="https://i.stack.imgur.com/HNiG4.jpg" alt="Failed print - photo#2" title="Failed print - photo#2"></a></p> <p><a href="https://i.stack.imgur.com/Y841k.jpg" rel="nofollow noreferrer" title="Failed print - photo#3"><img src="https://i.stack.imgur.com/Y841k.jpg" alt="Failed print - photo#3" title="Failed print - photo#3"></a></p> <p>I use Esun PLA+, the part was on baseplate without any loss of contact. It was like one layer missed its coordinates and then all corrupted.</p> <p>I think it's not related with bed adhesion because for example for this model, it didn't knock over the model.</p> <p>There is no roof for the model, I think it doesn't need any support structure. <a href="https://cdn.thingiverse.com/renders/35/b4/84/0c/45/74441e4966d7cc6caac1adbd2795375f_preview_featured.jpg" rel="nofollow noreferrer">Here</a> you can see the expected finished one: </p> <p><a href="https://i.stack.imgur.com/U1nzR.jpg" rel="nofollow noreferrer" title="Expected finished print"><img src="https://i.stack.imgur.com/U1nzR.jpg" alt="Expected finished print" title="Expected finished print"></a></p>
<p>It seems the problem was because of Z-axis leveling (level of the X-axis), I found out that the right side was more than 3-4&nbsp;mm below the left side when the Z-axis height exceeds around 8-10&nbsp;cm. Below 8-10&nbsp;cm, the two sides were even. I calibrated the X-axis by turning the eccentric nuts of the wheels and tighten them. I will try printing soon with some test objects.</p>
<p>There are options in Cura to avoid that the extruder hovers over printed parts when traveling. There is also an option to lift Z axis while traveling. Those options are hidden by default. You can only enable them in advanced settings mode.</p>
1,360
<p>What was the motivation for having the <code>reintroduce</code> keyword in Delphi?</p> <p>If you have a child class that contains a function with the same name as a virtual function in the parent class and it is not declared with the override modifier then it is a compile error. Adding the reintroduce modifier in such situations fixes the error, but I have never grasped the reasoning for the compile error.</p>
<p>If you declare a method in a descendant class that has the same name as a method in an ancestor class then you are hiding that ancestor method — meaning if you have an instance of that descendant class (that is referenced as that class) then you will not get the behavior of the ancestor. When the ancestor's method is virtual or dynamic, the compiler will give you a warning.</p> <p>Now you have one of two choices to suppress that warning message:</p> <ol> <li>Adding the keyword <strong>reintroduce</strong> just tells the compiler you know you are hiding that method and it suppresses the warning. You can still use the <strong>inherited</strong> keyword within your implementation of that descended method to call the ancestor method.</li> <li>If the ancestor's method was <strong>virtual</strong> or <strong>dynamic</strong> then you can use <strong>override</strong>. It has the added behavior that if this descendant object is accessed through an expression of the ancestor type, then the call to that method will still be to the descendant method (which then may optionally call the ancestor through <strong>inherited</strong>).</li> </ol> <p>So difference between <strong>override</strong> and <strong>reintroduce</strong> is in polymorphism. With <strong>reintroduce</strong>, if you cast the descendant object as the parent type, then call that method you will get the ancestor method, but if you access it the descendant type then you will get the behavior of the descendant. With <strong>override</strong> you always get the descendant. If the ancestor method was neither <strong>virtual</strong> nor <strong>dynamic</strong>, then <strong>reintroduce</strong> does not apply because that behavior is implicit. (Actually you could use a class helper, but we won't go there now.)</p> <p>In spite of what Malach said, you <em>can still call <strong>inherited</em></strong> in a reintroduced method, even if the parent was neither <strong>virtual</strong> nor <strong>dynamic</strong>.</p> <p>Essentially reintroduce is just like <strong>override</strong>, but it works with non-<strong>dynamic</strong> and non-<strong>virtual</strong> methods, and it <em>does not replace</em> the behavior if the object instance is accessed via an expression of the ancestor type.</p> <p><strong><em>Further Explanation:</em></strong></p> <p><strong>Reintroduce</strong> is a way of communicating intent to the compiler that you did not make an error. We override a method in an ancestor with the <strong>override</strong> keyword, but it requires that the ancestor method be <strong>virtual</strong> or <strong>dynamic</strong>, and that you want the behavior to change when the object is accessed as the ancestor class. Now enter <strong>reintroduce</strong>. It lets you tell the compiler that you did not accidentally create a method with the same name as a virtual or dynamic ancestor method (which would be annoying if the compiler didn't warn you about). </p>
<p><strong>reintroduce</strong> allows you to declare a method with the same name as the ancestor, but with different parameters. It has nothing to do with bugs or mistakes!!!</p> <p>For example, I often use it for constructors...</p> <pre><code>constructor Create (AOwner : TComponent; AParent : TComponent); reintroduce; </code></pre> <p>This allows me to create the internal classes in a cleaner fashion for complex controls such as toolbars or calendars. I normally have more parameters than that. Sometimes it is <strong>almost impossible</strong> or <strong>very messy</strong> to create a class without passing some parameters.</p> <p>For visual controls, Application.Processmessages can get called after Create, which can be too late to use these parameters.</p> <pre><code>constructor TClassname.Create (AOwner : TComponent; AParent : TComponent); begin inherited Create (AOwner); Parent := AParent; .. end; </code></pre>
7,736
<p>Our company has multiple domains set up with one website hosted on each of the domains. At this time, each domain has its own authentication which is done via cookies. </p> <p>When someone logged on to one domain needs to access anything from the other, the user needs to log in again using different credentials on the other website, located on the other domain. </p> <p>I was thinking of moving towards single sign on (SSO), so that this hassle can be eliminated. I would appreciate any ideas on how this could be achieved, as I do not have any experience in this regard.</p> <p>Thanks.</p> <p><strong>Edit:</strong> The websites are mix of internet (external) and intranet (internal-used within the company) sites.</p>
<p>The SSO solution that I've implemented here works as follows:</p> <ol> <li>There is a master domain, <code>login.mydomain.example</code> with the script <code>master_login.php</code> that manages the logins.</li> <li>Each client domain has the script <code>client_login.php</code></li> <li>All the domains have a shared user session database.</li> <li>When the client domain requires the user to be logged in, it redirects to the master domain (<code>login.mydomain.example/master_login.php</code>). If the user has not signed in to the master it requests authentication from the user (ie. display login page). After the user is authenticated it creates a session in a database. If the user is already authenticated it looks up their session id in the database.</li> <li>The master domain returns to the client domain (<code>client.mydomain.example/client_login.php</code>) passing the session id.</li> <li>The client domain creates a cookie storing the session id from the master. The client can find out the logged in user by querying the shared database using the session id.</li> </ol> <p>Notes:</p> <ul> <li>The session id is a unique global identifier generated with algorithm from RFC 4122</li> <li>The <code>master_login.php</code> will only redirect to domains in its whitelist</li> <li>The master and clients can be in different top level domains. Eg. <code>client1.abc.example</code>, <code>client2.xyz.example</code>, <code>login.mydomain.example</code></li> </ul>
<p>If you use Active Directory you could have each app use AD for authentication, login could then be seamless. </p> <p>Otherwise, if the applications can talk to each other behind the scenes, you could use sessionids and have one app handling id generation serving all of your other applications.</p>
6,628
<p>I've been trying to figure out a regex to allow me to search for a particular string while automatically skipping comments. Anyone have an RE like this or know of one? It doesn't even need to be sophisticated enough to skip <code>#if 0</code> blocks; I just want it to skip over <code>//</code> and <code>/*</code> blocks. The converse, that is only search inside comment blocks, would be very useful too. </p> <p>Environment: VS 2003</p>
<p>This is a harder problem than it might at first appear, since you need to consider comment tokens inside strings, comment tokens that are themselves commented out etc.</p> <p>I wrote a string and comment parser for C#, let me see if I can dig out something that will help... I'll update if I find anything.</p> <p>EDIT: ... ok, so I found my old 'codemasker' project. Turns out that I did this in stages, not with a single regex. Basically I inch through a source file looking for start tokens, when I find one I then look for an end-token and mask everything in between. This takes into account the context of the start token... if you find a token for "string start" then you can safely ignore comment tokens until you find the end of the string, and vice versa. Once the code is masked (I used guids as masks, and a hashtable to keep track) then you can safely do your search and replace, then finally restore the masked code.</p> <p>Hope that helps.</p>
<p>I would make a copy and strip out the comments first, then search the string the regular way.</p>
7,764
<p>I've started printing PETG recently and I'm happy with results so far, awesome strength and good looking (except for stringing). But I've noticed that PETG prints better with more distance nozzle-plate than usual, and under-extrusion make parts looking better than both normal/over-extrusion.</p> <ul> <li>What distance nozzle-plate is optimal for PETG? (i.e. the distance between nozzle and build plate during calibration)</li> <li>What extrusion percentage is optimal for PETG?</li> </ul>
<p>Here is the mental framework that I use to reason about PETG: In a nutshell you want to <strong>avoid nozzle contact</strong>.</p> <p>Unlike most other plastics, PETG sticks to hot brass really well and every time the nozzle moves through material it will pick up some of it. Material around the the nozzle then sticks to a random place creating a blob. It can also cook, turn transparent brown and drop into the print. Investing in a plated nozzle or silicone socks helps but doesn't eliminate the problem completely.</p> <p>Now to the questions.</p> <h3>1) Nozzle Distance</h3> <p>Distance to the plate has to be such that the plastic is laid down precisely without the nozzle dragging through the material (remember, avoid nozzle contact). Precise lines require the build plate to be level and the flow perfectly calibrated. If nozzle is too low and/or the layer is over-extruded then PETG will stick to the nozzle and rip the lines off the plate again. Inspecting the first layer is required for best results. I like to print a layer test pattern <strong>after</strong> the flow has been calibrated and tweak Z offset in 0.02mm increments until it's perfect.</p> <p>With many other plastics it's ok to have a large amount of "squish" in the first layer as it helps to work around minor leveling issues. This is where the cookie-cutter recommendation to raise the nozzle when printing with PETG is coming from.</p> <h3>2) Extrusion percentage</h3> <p>Flow has to be near <strong>perfect</strong>. Down to one percent perfect. Even a slightest over extrusion and some of the excess material will end up on the nozzle when it makes the next pass. Under extrusion isn't great either as this can lead to holes and affect overhangs where thinner strands of a previous pass may not be enough for the next line to stick to.</p> <p>There are two critical parameters: diameter of the filament and extrusion multiplier. This is how to determine the settings:</p> <ol> <li>Measure filament diameter. I use an average of ten measurements over about a meter (yard) of filament taken in multiple orientations.</li> <li>Calibrate the extrusion multiplier using a <a href="https://help.prusa3d.com/article/d9j1xdg7vj-extrusion-multiplier-calibration" rel="nofollow noreferrer">method described in Prusa manual</a>: I print a 40x40x40 cube in vase mode with extrusion multiplier set to 1 and fixed extrusion width (e.g. 0.45mm), measure the wall thickness in three spots on every side, average the results and compute the correction factor.</li> </ol> <p>I perform flow calibration for every new roll of filament.</p>
<p>On my Ender 3 Pro's I have found the following works well (also remember settings can be effected by different brand/quality of filament):</p> <ul> <li>Bed to nozzle 0.2-0.3 mm,</li> <li>Multiplier 100 %,</li> <li>Nozzle ~230 °C/bed 70 °C,</li> <li>Speed 50 mm/s.</li> <li>Cooling off first few layers but from there cooling and retraction is part specific.</li> </ul> <p>If you use retraction, it may help to slow it down to 25 mm/s and adjust retract distance if your using Bowden tube or direct drive. Last, a must have, a can of hair spray, works great and less expensive than the glues.</p>
1,195
<p>I am planning on buying a cheap 3D printer to get into 3D printing, but the printer I'm planning to buy only takes 1.75 mm filament, I was wondering if it might be possible to change the hotend of that printer or something to take in 3.0 mm filament, the reason I want to use 3.0 mm filament is because it is cheaper than 1.75 mm filament.</p>
<p>First it really depends on your printer / extruder. That said generally 1.75 mm is cheaper and much more common.</p> <p>If one were to change the hotend, likely you will need to replace most or all of the hot end. In the case of my personal hot ends, when I did this conversion I had to replace both the tube and the PETF lined mouth. I did not have to replace the tip, core, or the thermsister.</p> <p>My advice is to pick a different printer. You see 3 mm on older extruders like J Head direct gear from around 2012-2013 and Bowden style (like the Ultimaker) use 3 mm (actually 2.85 mm).</p> <p>Possible yes, advised, no.</p>
<p>I had my printer Anycubic-Chiron converted from 1.75 mm filament to 3.00 mm, as it is big enough to handle bigger filament and the printer itself came with two sizes of the heatsink - the other fit to 3.00 mm filament.</p> <p>In addition, I changed my extruder to a &quot;Bulldog&quot; extruder kit for 1.75 and 3 mm filament plus the PTFE tube and had to change the metal tube (heat break) between the heatsink and the hotend.</p> <p>However, the conversion failed, the filament gets stuck on multiple points. I found many blogs describing this similar issue. The only possible solution is to increase the heat up to 270 °C at which my printer also fails. As the thickness of 3.00 mm filament prevents the heat to reach the middle of it. That's why it spools on the beginning only of printing then stop. There is no way to continue.</p> <p>So, the problem is with the hotend, being mostly designed to suit 1.75 mm filament, not the printer itself.</p>
461
<p>Is there any way to have a binary compiled from an ActionScript 3 project print stuff to <em>stdout</em> when executed?</p> <p>From what I've gathered, people have been going around this limitation by writing hacks that rely on local socket connections and AIR apps that write to files in the local filesystem, but that's pretty much it -- it's obviously not possible with the Flash Player and AIR runtimes from Adobe.</p> <p>Is there any project (e.g. based on the Tamarin code) that is attempting to implement something that would provide this kind of functionality?</p>
<p>With AIR on Linux, it is easy to write to stdout, since the process can see its own file descriptors as files in /dev.</p> <p>For stdout, open <code>/dev/fd/1</code> or <code>/dev/stdout</code> as a <code>FileStream</code>, then write to that.</p> <p>Example:</p> <pre><code>var stdout : FileStream = new FileStream(); stdout.open(new File("/dev/fd/1"), FileMode.WRITE); stdout.writeUTFBytes("test\n"); stdout.close(); </code></pre> <p><strong>Note:</strong> See <a href="https://stackoverflow.com/questions/5552277/when-to-use-writeutf-and-writeutfbytes-in-bytearray-of-as3">this answer</a> for the difference between <code>writeUTF()</code> and <code>writeUTFBytes()</code> - the latter will avoid garbled output on stdout.</p>
<p>If you are using a debug Flash Player, you can have the Flash Player log trace messages to a file on your system.</p> <p>If you want real time messages, then you could tail the file.</p> <p>More info:</p> <p><a href="http://blog.flexexamples.com/2007/08/26/debugging-flex-applications-with-mmcfg-and-flashlogtxt/" rel="nofollow noreferrer">http://blog.flexexamples.com/2007/08/26/debugging-flex-applications-with-mmcfg-and-flashlogtxt/</a></p> <p>mike chambers</p> <p>mesh@adobe.com</p>
5,958
<p>I have a web application that should behave differently for internal users than external ones. The web application is available over the Internet, and therefore obviously to the internal users as well.</p> <p>All the users are anonymous, not authenticated, but the page should render differently for internal users than external. What I'm doing in my code is use <code>Request.UserHostName</code> and then <code>Dns.GetHostEntry</code>. The result is then compared to a setting in my <code>web.config</code> (that holds something like <code>*.mydomain.local</code>) . If the comparison gives a positive result then I render the HTML that the internal user should see otherwise I render the HTML the external user should see.</p> <p>However, my problem is that I don't always get the expected value from <code>Request.UserHostName</code>. on the development site I get the <code>IP-number</code> (?) of the machine running the browser but on the customer site I don't get the <code>IP-number</code> of the user machine, I get some other <code>IP-number</code>. The browsers don't have any proxies set or anything like that.</p> <p>Should I be using something else than <code>Request.UserHostName</code>?</p>
<p>I recommend using IP addresses as well. I'm dealing with this exact same situation setting up an authentication system right now as well and the conditions described by Epso and Robin M are exactly what is happening. External users coming to the site give me their actual IP address while all internal users provide the IP of the gateway machine(router) on to the private subnet the webservers sit on.</p> <p>To deal with it I just check for that one IP. If I get the IP of the gateway, I provide the internal access. If I get anything else they get the external one which requires additional authentication in my case. In yours, it would just mean a different interface.</p>
<p>There might be a firewall that is doing some sort of NAT, to enable inside clients to use the external dns-name to reach the server.</p> <p>Is the IP-number you get on customer site the same at the external customer-server ip? In that case you can hard code for that one IP-address. All internal computers behind that firewall will appear to have to same ip-address and you can classify them as "internal".</p>
6,748
<p>Here is a quick test program:</p> <pre><code> public static void main( String[] args ) { Date date = Calendar.getInstance().getTime(); System.out.println("Months:"); printDate( "MMMM", "en", date ); printDate( "MMMM", "es", date ); printDate( "MMMM", "fr", date ); printDate( "MMMM", "de", date ); System.out.println("Days:"); printDate( "EEEE", "en", date ); printDate( "EEEE", "es", date ); printDate( "EEEE", "fr", date ); printDate( "EEEE", "de", date ); } public static void printDate( String format, String locale, Date date ) { System.out.println( locale + ": " + (new SimpleDateFormat( format, new Locale( locale ) )).format( date ) ); } </code></pre> <p>The output is:</p> <p><code> Months: en: September es: septiembre fr: septembre de: September Days: en: Monday es: lunes fr: lundi de: Montag</code></p> <p>How can I control the capitalization of the names. For some reason the Spanish and French always seem to return names that start with a lowercase letter.</p>
<p>Not all languages share english capitalization rules. I guess you'd need to alter the data used by the API, but your non-english clients might not appreciate it...</p> <p><a href="http://french.about.com/library/writing/bl-capitalization.htm" rel="noreferrer">about.com on french capitalization</a></p>
<p>I'm having a problem now where a sentence begins with "dimanche 07 mars", which wouldn't matter if it were not at the beginning of a sentence. I guess this cannot be changed, unless I do manual string manipulation on the first character of the string.</p>
9,228
<p>Why does my 3&nbsp;mm PLA filament always snap near the spool some time (usually a few hours) after a print has finished?</p> <p>I have had it snap mid print but this is quite rare.</p> <p>I have 3 rolls of 3&nbsp;mm PLA filament from Velleman and 3DPrima. They all exhibit this behavior. They are between 2 and 3 years old. Each roll is stored in a foil bag with some desiccant, although this was not the case in the first year. The temperature in the room ranges between 14&nbsp;°C and 18&nbsp;°C in winter and rarely up to 30&nbsp;°C in summer. Current relative humidity is 49&nbsp;%. In summer I think I have seen it as high as 70&nbsp;%. I baked one spool in the oven at about 50&nbsp;°C for a few hours but this does not seam to have helped. When I remove the loose end of filament from the extruder after it has broken, some length of it seams to snap easily and some of it will just bend.</p> <p>The printer has a direct extruder so there is no bowden tube.</p>
<p>PLA seems to become brittle with age. Micro-fractures develop on the surface, and they will grow if filament is taken off the spool and held straight. This behaviour does not seem to be linked to moisture content. The best course of action is probably to use PLA quickly. Don't give it time to age.</p>
<p>PLA snapping is pretty universal. The best countermeasure is to always remove the filament from the printer after a print and place it in a low-humidity chamber. Other answers speak of moisture-induced micro-cracks, for which I have no evidence for or against.</p> <p>This has occurred for me when I've been lazy about putting filament away after a print.</p> <p>I've seen it with several brands of PLA, perhaps more often with filament with a glassy surface finish.</p> <p>My filament is 1.75&nbsp;mm. 3&nbsp;mm filament may be more susceptible because of higher stresses on the surface for the same radius bend, or straightening from the same radius spool.</p>
1,541
<p>E3D mentions on their <a href="http://wiki.e3d-online.com/wiki/E3D-v6_Assembly#Usage_Guidance" rel="nofollow noreferrer">own wiki</a>:</p> <blockquote> <p>Excessively long retractions will cause issues by dragging soft filament into cold areas. [...] for bowden systems you might want to go up to 2&nbsp;mm. Retraction beyond 2&nbsp;mm is likely to cause issues.</p> </blockquote> <p>I have retraction set to the recommended maximum of 2&nbsp;mm, but I still get a lot of stringing and blobs. My printer is set up with a relatively long Bowden tube (500-600&nbsp;mm). I wonder if I need to push my retraction setting slightly beyond 2&nbsp;mm to take up some of the slack. Is the 2&nbsp;mm a conservative rating (I guess they don't want dissatisfied customers with clogging problems) or is it really the maximum? Is there anything else I can do to improve retraction performance? (I already have a small coasting distance of 0.1&nbsp;mm set.)</p>
<p>Yes, you can increase retraction past E3D's max 2&nbsp;mm recommendation to compensate for Bowden tube stretch and slop. The reason for the recommendation is that jams will occur with most all-metal hot ends if you pull molten filament up into the cold zone. Any molten filament that enters the cold zone rapidly cools and hardens and sticks to the walls, very often forming a jam. </p> <p>So, the requirement is to keep your retraction distance <em>at the extruder</em> less than 2&nbsp;mm. Additional retraction travel that is absorbed by the Bowden tube and not seen at the extruder is fine. I personally run 2.5&nbsp;mm retraction on an E3Dv6 Bowden system without any issues. </p>
<p>In addition to the already excellent answers above, I want to mention that maybe a change in hotend temperature (lower) can also help reducing ooze/stringing. That is, if not other parameters prevent that.</p>
238
<p>I recently found out carbon fiber and glow in the dark PLA can damage the printer nozzle, now I'm suspicious of all the "exotic" filaments.</p> <p>So, does wood filament cause damage to the nozzle? (under normal use, or at least what someone who only used PLA/ABS before would consider normal use)</p> <p>Let's assume a normal quality brass nozzle - not some cheap stuff that didn't even came in the correct size to begin with and not some premium reinforeced nozzle - and reasonable quality filament.</p>
<p>If you haven't been to their site before, you should check out the forums on 3DHubs. There's a lot of how-to's. A quick Google search yields <a href="https://www.3dhubs.com/talk/thread/accelerated-nozzle-wear" rel="noreferrer">this</a> link to a similar question.</p> <p>The key thing to note is that in all technicalities, any material you run through the nozzle is going to cause <em>some</em> sort of wear on your nozzle. <strong>How quickly</strong> depends on the material or composition.</p> <p>The answer to the question linked above relates it spot on to sandpaper. If you have sandpaper made out of metal (ie stainless pla), it will scratch your skin fairly easily. If you have sandpaper made out of tree bark (ie laywood pla), it probably won't scratch your skin as bad, but it'll still scratch. And just for poops and giggles, lets say you have sandpaper made out of pla; it'll take a while, but you could eventually make your skin raw if you rub the plastic against your arm long enough.</p> <p>It is typically recommended to use one nozzle for each material type as to avoid cross-contamination of materials in your printing. With this idea in mind, if you are using many types of materials, you can also minimize failed prints due to clogging and other "damaged nozzle" type troubles.</p>
<p>If you haven't been to their site before, you should check out the forums on 3DHubs. There's a lot of how-to's. A quick Google search yields <a href="https://www.3dhubs.com/talk/thread/accelerated-nozzle-wear" rel="noreferrer">this</a> link to a similar question.</p> <p>The key thing to note is that in all technicalities, any material you run through the nozzle is going to cause <em>some</em> sort of wear on your nozzle. <strong>How quickly</strong> depends on the material or composition.</p> <p>The answer to the question linked above relates it spot on to sandpaper. If you have sandpaper made out of metal (ie stainless pla), it will scratch your skin fairly easily. If you have sandpaper made out of tree bark (ie laywood pla), it probably won't scratch your skin as bad, but it'll still scratch. And just for poops and giggles, lets say you have sandpaper made out of pla; it'll take a while, but you could eventually make your skin raw if you rub the plastic against your arm long enough.</p> <p>It is typically recommended to use one nozzle for each material type as to avoid cross-contamination of materials in your printing. With this idea in mind, if you are using many types of materials, you can also minimize failed prints due to clogging and other "damaged nozzle" type troubles.</p>
175
<p>I'm doing a fair bit of work in Ruby recently, and using</p> <pre><code> ruby script/console </code></pre> <p>Is absolutely critical. However, I'm really disappointed with the default Windows console in Vista, especially in that there's a really annoying bug where moving the cursor back when at the bottom of the screen irregularly causes it to jump back. Anyone have a decent console app they use in Windows?</p>
<p>I use <a href="http://sourceforge.net/projects/console/" rel="nofollow noreferrer">Console2</a>.</p> <p>I like the tabbed interface and that copy works properly if text breaks at the end of a line.</p>
<p><a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" rel="nofollow noreferrer">Powershell</a></p> <blockquote> <p>Windows PowerShell is Microsoft's task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems.</p> </blockquote>
6,246
<p>I want to delete foo() if foo() isn't called from anywhere.</p>
<p><a href="http://www.mono-project.com/Gendarme" rel="nofollow noreferrer">Gendarme</a> will detect private methods with no upstream callers. It is available cross platform, and the latest version handles "<a href="http://www.mono-project.com/Gendarme.Rules.Performance" rel="nofollow noreferrer">AvoidUncalledPrivateCodeRule</a>".</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx" rel="nofollow noreferrer" title="FxCop">FxCop</a> will detect public/protected methods with no upstream callers. However, FxCop does not detect all methods without upstream callers, as it is meant to check in the case that your code is part of a Library, so public members are left out. <a href="https://stackoverflow.com/questions/71518/is-there-a-custom-fxcop-rule-that-will-detect-unused-public-methods#71929">You can use NDepend to do a search for public members with no upstream callers, which I detail here in this other StackOverflow answer</a>.</p> <p><em>(edit: added information about Gendarme which actually does what the questioner asked)</em></p>
<p><a href="http://www.jetbrains.com/resharper/" rel="nofollow noreferrer">Resharper</a> does this, and not just with methods. It also does it with using statements, variables etcetera.</p>
9,132
<p>Short version: I want to trigger the Form_Load() event without making the form visible. This doesn't work because Show() ignores the current value of the Visible property:</p> <pre><code>tasksForm.Visible = false; tasksForm.Show(); </code></pre> <p>Long version: I have a WinForms application with two forms: main and tasks. The main form is always displayed. The user can either click a button to open the tasks form, or click some buttons that just run a task directly without opening the tasks form.</p> <p>When a user asks to run a task directly, I'd like to just call some public methods on the tasks form without showing it. Unfortunately, the task logic depends on stuff that happens in the Form_Load() event. The only way I can find to trigger Form_Load() is to call Show(). The best I've been able to do is to show the form in the minimized state:</p> <pre><code>tasksForm.WindowState = FormWindowState.Minimized; tasksForm.Show(); </code></pre> <p>I suppose the cleanest solution would be to pull the tasks logic out of the tasks form and into a controller class. Then I can use that class from the main form and from the tasks form, and only load the tasks form when I need it visible for the user. However, if it's an easy thing to load the form without displaying it, that would be a smaller change.</p>
<p>I totally agree with Rich B, you need to look at where you are placing your application logic rather than trying to cludge the WinForms mechanisms. All of those operations and data that your Tasks form is exposing should really be in a separate class say some kind of Application Controller or something held by your main form and then used by your tasks form to read and display data when needed but doesn't need a form to be instantiated to exist. </p> <p>It probably seems a pain to rework it, but you'll be improving the structure of the app and making it more maintainable etc.</p>
<p>If you make the method public, then you could access it directly.... however, there could be some unexpected side effects when you call it. But making it public and calling it directly will not draw the screen or open the form.</p>
9,249
<p>I want to put songs on a web page and have a little play button, like you can see on Last.fm or Pandora. There can be multiple songs listed on the site, and if you start playing a different song with one already playing, it will pause the first track and begin playing the one you just clicked on. I think they use Flash for this, and I could probably implement it in a few hours, but is there already code I could use for this? Maybe just a flash swf file that you stick hidden on a web page with a basic Javascript API that I can use to stream mp3 files?</p> <p>Also, what about WMA or AAC files? Is there a universal solution that will play these 3 file types?</p> <hr> <p><a href="http://musicplayer.sourceforge.net/" rel="nofollow noreferrer">http://musicplayer.sourceforge.net/</a></p>
<p>There are <strong>many</strong> flash mp3 players that you can use that do this. Usually, you just have to edit a text file to point at the mp3s you want to have available.</p> <p>Here is the first one that showed up on a google search for <code>flash mp3 player</code>: <a href="http://www.flashmp3player.org/demo.html" rel="nofollow noreferrer">http://www.flashmp3player.org/demo.html</a></p>
<p>This is fairly simple if you want to embed the WMP you can use all the controls via JavaScript. There is a great MSDN section on it but I cant seem to find it now.<br /><br />Edit: I found <a href="http://msdn.microsoft.com/en-us/library/ms909930.aspx" rel="nofollow noreferrer">this</a> on MSDN it contains the properties that an embeded WMP will accept then all you have to do is call the methods via javascript.</p> <pre><code>&lt;OBJECT id="VIDEO" width="320" height="240" style="position:absolute; left:0;top:0;" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject"&gt; &lt;PARAM NAME="URL" VALUE="your file or url"&gt; &lt;PARAM NAME="SendPlayStateChangeEvents" VALUE="True"&gt; &lt;PARAM NAME="AutoStart" VALUE="True"&gt; &lt;PARAM name="uiMode" value="none"&gt; &lt;PARAM name="PlayCount" value="9999"&gt; &lt;/OBJECT&gt; </code></pre> <p>Then for the javascript</p> <pre><code>&lt;script type="javascript"&gt; obj = document.getElementById("VIDEO"); //Where video is the id of the object above. obj.URL="filename"; //You can use this to both start and change the current file. obj.controls.stop(); //Will stop obj.controls.Pause(); //Pause &lt;/script&gt; </code></pre> <p>Somewhere around here I have code to even control the volume.<br /> A while ago I built a custom (looking) player for a client purely in HTML and JavaScript.</p>
7,059
<p>I have something like this:</p> <pre> barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation( barProgress.Value, dNextProgressValue, new Duration(TimeSpan.FromSeconds(dDuration))); </pre> <p>Now, how would you stop that animation (the <code>DoubleAnimation</code>)? The reason I want to do this, is because I would like to start new animations (this seems to work, but it's hard to tell) and eventually stop the last animation...</p>
<p>To stop it, call <code>BeginAnimation</code> again with the second argument set to <code>null</code>.</p>
<p>You can use this code:</p> <pre><code>[StoryBoardName].Remove([StoryBoardOwnerControl]); </code></pre>
4,066
<p>When writing code do you consciously program defensively to ensure high program quality and to avoid the possibility of your code being exploited maliciously, e.g. through buffer overflow exploits or code injection ?</p> <p>What's the "minimum" level of quality you'll always apply to your code ?</p>
<p>In my line of work, our code has to be top quality.<br> So, we focus on two main things:</p> <ol> <li>Testing</li> <li>Code reviews</li> </ol> <p>Those bring home the money.</p>
<p>I always work to prevent things like injection attacks. However, when you work on an internal intranet site, most of the security features feel like wasted effort. I still do them, maybe just not as well.</p>
2,854
<p>The page <em><a href="http://www.codinghorror.com/blog/archives/001167.html" rel="noreferrer">Protecting Your Cookies: HttpOnly</a></em> explains why making HttpOnly cookies is a good idea.</p> <p>How do I set this property in Ruby on Rails?</p>
<p>Set the 'http_only' option in the hash used to set a cookie</p> <p>e.g. <pre>cookies["user_name"] = { :value => "david", :httponly => true }</pre></p> <p>or, in Rails 2:</p> <p>e.g. <pre>cookies["user_name"] = { :value => "david", :http_only => true }</pre></p>
<p>I also wrote a patch that is included in Rails 2.2, which defaults the CookieStore session to be http_only. </p> <p>Unfortunately session cookies are still by default regular cookies.</p>
9,788
<p>What is the best way for me to determine a controller variable's value during execution?</p> <p>For example, is there a way I can insert a break in the code, and cause the value of the variable to be output to the screen (or the log)?</p>
<p>Yes. The easiest way is to raise the value as a string. Like so: <code>raise @foo.to_s</code></p> <p>Or, you can install the debugger (<code>gem install ruby-debug</code>), and then start the development server with the <code>--debugger</code> flag. Then, in your code, call the <code>debugger</code> instruction.</p> <p>Inside the debugger prompt, you have many commands, including <code>p</code> to print the value of a variable.</p> <p><strong>Update:</strong> here's <a href="http://bashdb.sourceforge.net/ruby-debug.html" rel="noreferrer">a bit more about ruby-debug</a>.</p>
<p>Raising an exception is the fastest way if you just need to look at a value, but it's worth the time to learn how to use the debugger properly. It's rare that you would only need to just see the value of a variable, you are likely trying to find a bug in your code, and that's what a debugger is for.</p> <p>Sending the info to the development log is slower than either of the other two options here so far if you learn how to use the debugger (who wants to read through log files). Use the logger for production, you are going to want to see what the value was when somebody calls you up and says everything is broken.</p>
8,570
<p>In Cura, when you enable "Print support structure", is there a way to see what it will look like?</p>
<p>Select the View Modes Button in the upper right hand corner, and select Layers.</p> <p><a href="https://i.stack.imgur.com/grPQi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/grPQi.png" alt="Cura"></a></p>
<p>Cura generates support based on the outlines of the layers which will be printed, rather based on the triangles of the 3D model. It is therefore not possible to show the generated support in the solid view.</p> <p>You can view the support in the layer view however. In Cura 2 that's on the left bottom of the screen.</p> <p><a href="https://i.imgur.com/2rkCslJ.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/2rkCslJ.png" alt="Cura"></a></p> <p>Support is classified as a helper part in the legend of the layer view.</p>
205
<p>I am using Forms authentication in my asp.net (3.5) application. I am also using roles to define what user can access which subdirectories of the app. Thus, the pertinent sections of my web.config file look like this:</p> <pre><code>&lt;system.web&gt; &lt;authentication mode="Forms"&gt; &lt;forms loginUrl="Default.aspx" path="/" protection="All" timeout="360" name="MyAppName" cookieless="UseCookies" /&gt; &lt;/authentication&gt; &lt;authorization &gt; &lt;allow users="*"/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;location path="Admin"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles="Admin"/&gt; &lt;deny users="*"/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; </code></pre> <p>Based on what I have read, this should ensure that the only users able to access the Admin directory will be users who have been Authenticated and assigned the Admin role.</p> <p>User authentication, saving the authentication ticket, and other related issues all work fine. If I remove the tags from the web.config file, everything works fine. The problem comes when I try to enforce that only users with the Admin role should be able to access the Admin directory.</p> <p>Based on this <a href="http://support.microsoft.com/kb/311495" rel="nofollow noreferrer">MS KB article</a> along with other webpages giving the same information, I have added the following code to my Global.asax file:</p> <pre><code>protected void Application_AuthenticateRequest(Object sender, EventArgs e) { if (HttpContext.Current.User != null) { if (Request.IsAuthenticated == true) { // Debug#1 FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Context.Request.Cookies[FormsAuthentication.FormsCookieName].Value); // In this case, ticket.UserData = "Admin" string[] roles = new string[1] { ticket.UserData }; FormsIdentity id = new FormsIdentity(ticket); Context.User = new System.Security.Principal.GenericPrincipal(id, roles); // Debug#2 } } } </code></pre> <p>However, when I try to log in, I am unable to access the Admin folder (get redirected to login page). </p> <p>Trying to debug the issue, if I step through a request, if I execute Context.User.IsInRole("Admin") at the line marked Debug#1 above, it returns a false. If I execute the same statement at line Debug#2, it equals true. So at least as far as Global.asax is concerned, the Role is being assigned properly.</p> <p>After Global.asax, execution jumps right to the Login page (since the lack of role causes the page load in the admin folder to be rejected). However, when I execute the same statement on the first line of Page_Load of the login, it returns false. So somewhere after Application_AuthenticateRequest in Global.asax and the initial load of the WebForm in the restricted directory, the role information is being lost, causing authentication to fail (note: in Page_Load, the proper Authentication ticket is still assigned to Context.User.Id - only the role is being lost).</p> <p>What am I doing wrong, and how can I get it to work properly?</p> <hr> <p><strong>Update: I entered the <a href="https://stackoverflow.com/questions/56271/contextuser-losing-roles-after-being-assigned-in-globalasaxapplicationauthentic#57040">solution below</a></strong></p>
<p><strong>Here was the problem and solution</strong>: </p> <p>Earlier in development I had gone to the Website menu and clicked on Asp.net configuration. This resulted in the following line being added to the web.config: </p> <pre><code>&lt;system.web&gt; &lt;roleManager enabled="true" /&gt; &lt;/system.web&gt; </code></pre> <p>From that point on, the app was assuming that I was doing roles through the Asp.net site manager, and not through FormsAuthentication roles. Thus the repeated failures, despite the fact that the actual authentication and roles logic was set up correctly.</p> <p>After this line was removed from web.config everything worked perfectly.</p>
<p>this is just a random shot, but are you getting blocked because of the order of authorization for Admin? Maybe you should try switching your deny all and your all Admin.</p> <p>Just in case it's getting overwritten by the deny.</p> <p>(I had code samples in here but they weren't showing up.</p>
8,016
<p>I've created a webservice and when I want to use its methods I instantiate it in the a procedure, call the method, and I finally I dispose it, however I think also it could be okay to instantiate the webservice in the "private void Main_Load(object sender, EventArgs e)" event.</p> <p>The thing is that if I do it the first way I have to instantiate the webservice every time I need one of its methods but in the other way I have to keep a webservice connected all the time when I use it in a form for example. </p> <p>I would like to know which of these practices are better or if there's a much better way to do it</p> <p><strong>Strategy 1</strong></p> <pre><code>private void btnRead_Click(object sender, EventArgs e) { try { //Show clock this.picResult.Image = new Bitmap(pathWait); Application.DoEvents(); //Connect to webservice svc = new ForPocketPC.ServiceForPocketPC(); svc.Credentials = new System.Net.NetworkCredential(Settings.UserName, Settings.Password); svc.AllowAutoRedirect = false; svc.UserAgent = Settings.UserAgent; svc.PreAuthenticate = true; svc.Url = Settings.Url; svc.Timeout = System.Threading.Timeout.Infinite; svc.CallMethod(); ... } catch (Exception ex) { ShowError(ex); } finally { if (svc != null) svc.Dispose(); } } </code></pre> <p><strong>Strategy 2</strong></p> <pre><code>private myWebservice svc; private void Main_Load(object sender, EventArgs e) { //Connect to webservice svc = new ForPocketPC.ServiceForPocketPC(); svc.Credentials = new System.Net.NetworkCredential(Settings.UserName, Settings.Password); svc.AllowAutoRedirect = false; svc.UserAgent = Settings.UserAgent; svc.PreAuthenticate = true; svc.Url = Settings.Url; svc.Timeout = System.Threading.Timeout.Infinite; } private void btnRead_Click(object sender, EventArgs e) { try { //Show clock this.picResult.Image = new Bitmap(pathWait); Application.DoEvents(); svc.CallMethod(); ... } catch (Exception ex) { ShowError(ex); } } private void Main_Closing(object sender, CancelEventArgs e) { svc.Dispose(); } </code></pre>
<p>It depends on how often you are going to be calling the web service. If you're going to be calling it almost constantly, it would probably be better to use method #2. However, if it's not going to be getting called quite so often, you are better off using method #1, and only instantiating it when you need it.</p>
<p>Right now I made a solution for a mobile device and it turns to be used on irregular times, it could be used in 10 minutes, 1 hour, 4 hours its very variable, it seems that the better aproach is the first strategy.</p> <p>Last year we went on a project where we used webservices, the fact is that we instantiated our webservices at the Sub New() procedure and it run it very well, however, sometimes some users claimed at us that they woke up from their chairs and when they returned and tried to continue on the application they received a timeout error message and they had to re-login again.</p> <p>We thougth that maybe that was Ok because maybe the users went out for a very long time out of their seats, but once in a presentation of the application with the CEOs it happened exactly the same scenario and personally I didn't like that behaviour and that's why the question.</p> <p>Thanks for the answer.</p>
3,416
<p>I have an Ender 5 printer, which is a frame-based printer with no enclosure. However, I want to print ABS. Some experiments with a massive cardboard box have shown me I need an enclosure.</p> <p>Because the printer has a box frame, fitting some perspex sheets will be easy. The bit that won't be easy is the top - the filament tube projects fairly high.</p> <p>Will I need to cover the top for ABS though? I read somewhere that drafts are a killer for ABS, which perspex around the sides should prevent. I guess most of the heat from the heat bed will be lost out of the top, so will this be a problem for layer adhesion?</p>
<p>Sides without a top will help.</p> <p>Sides with a top will help more.</p> <p>Do you need either? That depends. How warm, how dry, how drafty is your printing room?</p>
<p>If ambient temp gets under 70°F, layer adhesion becomes a real problem. I have found that enclosing the space and adding heat makes the printing more reliable.</p> <p>This answer is based on a few years of solely printing ABS. I've got my printer on a tool cart and the spool holder is above on a post. The first time winter ruined a print, I threw a pallet covering plastic bag over all of it and put a small, low powered, forced air heater more or less pointing at the printing area. It wasn't air tight, but I made effort to close it up pretty well.</p> <p>The current location of the 3D printer is on the bottom tier of the cart with a temperature controlled heater pointing at it. I opened up a large amazon box and set it against the cart, forming walls on 3 sides. There is poor sealing but the print quality stayed good.</p> <p>Oh and obviously it is very dangerous and have burned down my workplace and home several times, so don't do it.</p>
1,583
<p>I know I can call the GetVersionEx Win32 API function to retrieve Windows version. In most cases returned value reflects the version of my Windows, but sometimes that is not so.</p> <p>If a user runs my application under the compatibility layer, then GetVersionEx won't be reporting the real version but the version enforced by the compatibility layer. For example, if I'm running Vista and execute my program in "Windows NT 4" compatibility mode, GetVersionEx won't return version 6.0 but 4.0.</p> <p>Is there a way to bypass this behaviour and get true Windows version?</p>
<p>The best approach I know is to check if specific API is exported from some DLL. Each new Windows version adds new functions and by checking the existance of those functions one can tell which OS the application is running on. For example, Vista exports <a href="http://msdn.microsoft.com/en-us/library/ms724451(VS.85).aspx" rel="noreferrer">GetLocaleInfoEx</a> from kernel32.dll while previous Windowses didn't.</p> <p>To cut the long story short, here is one such list containing only exports from kernel32.dll.</p> <pre> > *function: implemented in* > GetLocaleInfoEx: Vista > GetLargePageMinimum: Vista, Server 2003 GetDLLDirectory: Vista, Server 2003, XP SP1 GetNativeSystemInfo: Vista, Server 2003, XP SP1, XP ReplaceFile: Vista, Server 2003, XP SP1, XP, 2000 OpenThread: Vista, Server 2003, XP SP1, XP, 2000, ME GetThreadPriorityBoost: Vista, Server 2003, XP SP1, XP, 2000, NT 4 IsDebuggerPresent: Vista, Server 2003, XP SP1, XP, 2000, ME, NT 4, 98 GetDiskFreeSpaceEx: Vista, Server 2003, XP SP1, XP, 2000, ME, NT 4, 98, 95 OSR2 ConnectNamedPipe: Vista, Server 2003, XP SP1, XP, 2000, NT 4, NT 3 Beep: Vista, Server 2003, XP SP1, XP, 2000, ME, 98, 95 OSR2, 95 </pre> <p>Writing the function to determine the real OS version is simple; just proceed from newest OS to oldest and use <a href="http://msdn.microsoft.com/en-us/library/ms683212.aspx" rel="noreferrer">GetProcAddress</a> to check exported APIs. Implementing this in any language should be trivial.</p> <p>The following code in Delphi was extracted from the free <a href="http://gp.17slon.com/gp/dsiwin32.htm" rel="noreferrer">DSiWin32</a> library):</p> <pre><code>TDSiWindowsVersion = (wvUnknown, wvWin31, wvWin95, wvWin95OSR2, wvWin98, wvWin98SE, wvWinME, wvWin9x, wvWinNT3, wvWinNT4, wvWin2000, wvWinXP, wvWinNT, wvWinServer2003, wvWinVista); function DSiGetWindowsVersion: TDSiWindowsVersion; var versionInfo: TOSVersionInfo; begin versionInfo.dwOSVersionInfoSize := SizeOf(versionInfo); GetVersionEx(versionInfo); Result := wvUnknown; case versionInfo.dwPlatformID of VER_PLATFORM_WIN32s: Result := wvWin31; VER_PLATFORM_WIN32_WINDOWS: case versionInfo.dwMinorVersion of 0: if Trim(versionInfo.szCSDVersion[1]) = 'B' then Result := wvWin95OSR2 else Result := wvWin95; 10: if Trim(versionInfo.szCSDVersion[1]) = 'A' then Result := wvWin98SE else Result := wvWin98; 90: if (versionInfo.dwBuildNumber = 73010104) then Result := wvWinME; else Result := wvWin9x; end; //case versionInfo.dwMinorVersion VER_PLATFORM_WIN32_NT: case versionInfo.dwMajorVersion of 3: Result := wvWinNT3; 4: Result := wvWinNT4; 5: case versionInfo.dwMinorVersion of 0: Result := wvWin2000; 1: Result := wvWinXP; 2: Result := wvWinServer2003; else Result := wvWinNT end; //case versionInfo.dwMinorVersion 6: Result := wvWinVista; end; //case versionInfo.dwMajorVersion end; //versionInfo.dwPlatformID end; { DSiGetWindowsVersion } function DSiGetTrueWindowsVersion: TDSiWindowsVersion; function ExportsAPI(module: HMODULE; const apiName: string): boolean; begin Result := GetProcAddress(module, PChar(apiName)) &lt;&gt; nil; end; { ExportsAPI } var hKernel32: HMODULE; begin { DSiGetTrueWindowsVersion } hKernel32 := GetModuleHandle('kernel32'); Win32Check(hKernel32 &lt;&gt; 0); if ExportsAPI(hKernel32, 'GetLocaleInfoEx') then Result := wvWinVista else if ExportsAPI(hKernel32, 'GetLargePageMinimum') then Result := wvWinServer2003 else if ExportsAPI(hKernel32, 'GetNativeSystemInfo') then Result := wvWinXP else if ExportsAPI(hKernel32, 'ReplaceFile') then Result := wvWin2000 else if ExportsAPI(hKernel32, 'OpenThread') then Result := wvWinME else if ExportsAPI(hKernel32, 'GetThreadPriorityBoost') then Result := wvWinNT4 else if ExportsAPI(hKernel32, 'IsDebuggerPresent') then //is also in NT4! Result := wvWin98 else if ExportsAPI(hKernel32, 'GetDiskFreeSpaceEx') then //is also in NT4! Result := wvWin95OSR2 else if ExportsAPI(hKernel32, 'ConnectNamedPipe') then Result := wvWinNT3 else if ExportsAPI(hKernel32, 'Beep') then Result := wvWin95 else // we have no idea Result := DSiGetWindowsVersion; end; { DSiGetTrueWindowsVersion } </code></pre> <p>--- updated 2009-10-09</p> <p>It turns out that it gets very hard to do an "undocumented" OS detection on Vista SP1 and higher. A look at the <a href="http://msdn.microsoft.com/en-us/library/aa383687(VS.85).aspx" rel="noreferrer">API changes</a> shows that all Windows 2008 functions are also implemented in Vista SP1 and that all Windows 7 functions are also implemented in Windows 2008 R2. Too bad :(</p> <p>--- end of update</p> <p>FWIW, this is a problem I encountered in practice. We (the company I work for) have a program that was not really Vista-ready when Vista was released (and some weeks after that ...). It was not working under the compatibility layer either. (Some DirectX problems. Don't ask.)</p> <p>We didn't want too-smart-for-their-own-good users to run this app on Vista at all - compatibility mode or not - so I had to find a solution (a guy smarter than me pointed me into right direction; the stuff above is not my brainchild). Now I'm posting it for your pleasure and to help all poor souls that will have to solve this problem in the future. Google, please index this article!</p> <p>If you have a better solution (or an upgrade and/or fix for mine), please post an answer here ...</p>
<p><strong>Note:</strong> Gabr is asking about an approach that can bypass the limitations of <code>GetVersionEx</code>. JCL code uses GetVersionEx, and is thus subject to compatibility layer. This information is for people who don't need to bypass the compatibility layer, only.</p> <p>Using the Jedi JCL, you can add unit JclSysInfo, and call function <code>GetWindowsVersion</code>. It returns an enumerated type TWindowsVersion.</p> <p>Currently JCL contains all shipped windows versions, and gets changed each time Microsoft ships a new version of Windows in a box:</p> <pre><code> TWindowsVersion = (wvUnknown, wvWin95, wvWin95OSR2, wvWin98, wvWin98SE, wvWinME, wvWinNT31, wvWinNT35, wvWinNT351, wvWinNT4, wvWin2000, wvWinXP, wvWin2003, wvWinXP64, wvWin2003R2, wvWinVista, wvWinServer2008, wvWin7, wvWinServer2008R2); </code></pre> <p>If you want to know if you're running 64-bit windows 7 instead of 32-bit, then call <code>JclSysInfo.IsWindows64</code>.</p> <p>Note that JCL allso handles Editions, like Pro, Ultimate, etc. For that call GetWindowsEdition, and it returns one of these:</p> <pre><code>TWindowsEdition = (weUnknown, weWinXPHome, weWinXPPro, weWinXPHomeN, weWinXPProN, weWinXPHomeK, weWinXPProK, weWinXPHomeKN, weWinXPProKN, weWinXPStarter, weWinXPMediaCenter, weWinXPTablet, weWinVistaStarter, weWinVistaHomeBasic, weWinVistaHomeBasicN, weWinVistaHomePremium, weWinVistaBusiness, weWinVistaBusinessN, weWinVistaEnterprise, weWinVistaUltimate, weWin7Starter, weWin7HomeBasic, weWin7HomePremium, weWin7Professional, weWin7Enterprise, weWin7Ultimate); </code></pre> <p>For historical interest, you can check the NT-level edition too with the NtProductType function, it returns:</p> <pre><code> TNtProductType =       (ptUnknown, ptWorkStation, ptServer, ptAdvancedServer,        ptPersonal, ptProfessional, ptDatacenterServer, ptEnterprise, ptWebEdition); </code></pre> <p>Note that "N editions" are detected above. That's an EU (Europe) version of Windows, created due to EU anti-trust regulations. That's a pretty fine gradation of detection inside the JCL.</p> <p>Here's a sample function that will help you detect Vista, and do something special when on Vista.</p> <pre><code>function IsSupported:Boolean; begin case GetWindowsVersion of wvVista: result := false; else result := true; end; end; </code></pre> <p>Note that if you want to do "greater than" checking, then you should just use other techniques. Also note that version checking can often be a source of future breakage. I have usually chosen to warn users and continue, so that my binary code doesn't become the actual source of breakage in the future.</p> <p>Recently I tried to install an app, and the installer checked my drive free space, and would not install, because I had more than 2 gigabytes of free space. The 32 bit integer signed value in the installer became negative, breaking the installer. I had to install it into a VM to get it to work. Adding "smart code" often makes your app "stupider". Be wary.</p> <p>Incidentally, I found that from the command line, you can run WMIC.exe, and type <code>path Win32_OperatingSystem</code> (The "Select * from Win32_OperatingSystem" didn't work for me). In future perhaps JCL could be extended to use the WMI information.</p>
8,131
<p>I have a seemingly unique problem. I'm trying to design models that print with single extrusion walls and are not closed volumes. For example, a topographical map model printed on an edge. It has height and width, but no depth. I want the model to print with a single, non-closed extrusion per layer. Printing back and forth as it moves up the model.</p> <p>When slicers cut up a model, historically each plane must result in a closed shape. The slicer then determines the tool path to create that shape. But what if, instead of a closed shape, the slice results in lines. No area or volume, just lines. Couldn't the slicer then create a tool path at each line?</p> <p>Is there anything like this available anywhere?</p> <p>Also, to be clear, I've been doing this 3D printing thing for a long time and know pretty well how slicers work and their resulting models. I've also been 3D modelling for a long time.</p> <p>The simplest solution I can think of would be to modify a slicer or find a plugin or something that already does what I'm looking for. The second possible solution would be to find 3D software that can &quot;extrude&quot; an arbitrarily complex surface in such a way that normal slicing software with the &quot;detect thin walls&quot; setting enabled would result in a single extrusion resulting in the desired outer surface. I haven't found either in my searching.</p> <p>The solution should work with nearly any extrusion width or any nozzle. You have a 0.4mm nozzle, you can print the part with wall widths anywhere from ~0.4mm wide to around 1mm. Your choice when slicing. If you have a 1mm wide nozzle, you could print the part with much thicker walls. It would be configurable in the slicer because the model only defines the surfaces, no volume data.</p> <p>Like I said, this is a seemingly unique problem.</p>
<p>Use Cura to slice and check out the &quot;Surface Mode&quot; option (might be hidden by default; if so, search for and unhide it). Also known as <code>magic_mesh_surface_mode</code>. The &quot;Surface&quot; choice sounds close to what you want and might suffice.</p>
<p>If you are designing a model that has single extrusion walls, you are constructing a design which has volume. A single extrusion wall will be dependent on the nozzle diameter and extrusion multiplier. For the sake of discussion, consider the theoretical nozzle 0.4 mm with a true 0.4 mm extrusion and a 0.2 mm layer thickness.</p> <p>Your design should reflect this fact. You can/should design your non-dimensional lines to be 0.4 mm wide and 0.2 mm thick in whatever manner you use to create models.</p> <p>Slicer settings can be adjusted to permit single extrusion walls. A common example is vase mode, in which the printer is directed to construct a single extrusion wall in a specified pattern, usually with an appropriately thick base.</p> <p>The caveat in this case is that the model file was created to match these requirements. It will be represented as a solid with a thickness to the wall appropriate to the nozzle size.</p> <p>If you create test models representing a small sample of your overall project and slice them with your preferred slicer, you can examine the resulting g-code, or use the preview feature common in slicers to determine if your objective is accomplished.</p> <p>In summary, every 3D printed model has all three dimensions. This cannot be avoided, other than in a virtual/simulated environment.</p>
2,020
<p>I've created a ListBox to display items in groups, where the groups are wrapped right to left when they can no longer fit within the height of the ListBox's panel. So, the groups would appear similar to this in the listbox, where each group's height is arbitrary (group 1, for instance, is twice as tall as group 2):</p> <pre><code>[ 1 ][ 3 ][ 5 ] [ ][ 4 ][ 6 ] [ 2 ][ ] </code></pre> <p>The following XAML works correctly in that it performs the wrapping, and allows the horizontal scroll bar to appear when the items run off the right side of the ListBox.</p> <pre><code>&lt;ListBox&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;StackPanel Orientation="Vertical"/&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBox.GroupStyle&gt; &lt;ItemsPanelTemplate&gt; &lt;WrapPanel Orientation="Vertical" Height="{Binding Path=ActualHeight, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ScrollContentPresenter}}}"/&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.GroupStyle&gt; &lt;/ListBox&gt; </code></pre> <p>The problem occurs when a group of items is longer than the height of the WrapPanel. Instead of allowing the vertical scroll bar to appear to view the cutoff item group, the items in that group are simply clipped. I'm assuming that this is a side effect of the Height binding in the WrapPanel - the scrollbar thinks it does not have to enabled.</p> <p>Is there any way to enable the scrollbar, or another way around this issue that I'm not seeing?</p>
<p>By setting the Height property on the WrapPanel to the height of the ScrollContentPresenter, it will never scroll vertically. However, if you remove that Binding, it will never wrap, since in the layout pass, it has infinite height to layout in. </p> <p>I would suggest creating your own panel class to get the behavior you want. Have a separate dependency property that you can bind the desired height to, so you can use that to calculate the target height in the measure and arrange steps. If any one child is taller than the desired height, use that child's height as the target height to calculate the wrapping.</p> <p>Here is an example panel to do this:</p> <pre><code>public class SmartWrapPanel : WrapPanel { /// &lt;summary&gt; /// Identifies the DesiredHeight dependency property /// &lt;/summary&gt; public static readonly DependencyProperty DesiredHeightProperty = DependencyProperty.Register( "DesiredHeight", typeof(double), typeof(SmartWrapPanel), new FrameworkPropertyMetadata(Double.NaN, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); /// &lt;summary&gt; /// Gets or sets the height to attempt to be. If any child is taller than this, will use the child's height. /// &lt;/summary&gt; public double DesiredHeight { get { return (double)GetValue(DesiredHeightProperty); } set { SetValue(DesiredHeightProperty, value); } } protected override Size MeasureOverride(Size constraint) { Size ret = base.MeasureOverride(constraint); double h = ret.Height; if (!Double.IsNaN(DesiredHeight)) { h = DesiredHeight; foreach (UIElement child in Children) { if (child.DesiredSize.Height &gt; h) h = child.DesiredSize.Height; } } return new Size(ret.Width, h); } protected override System.Windows.Size ArrangeOverride(Size finalSize) { double h = finalSize.Height; if (!Double.IsNaN(DesiredHeight)) { h = DesiredHeight; foreach (UIElement child in Children) { if (child.DesiredSize.Height &gt; h) h = child.DesiredSize.Height; } } return base.ArrangeOverride(new Size(finalSize.Width, h)); } } </code></pre>
<p>I would think that you are correct that it has to do with the binding. What happens when you remove the binding? With the binding are you trying to fill up at least the entire height of the list box? If so, consider binding to MinHeight instead, or try using the <code>VerticalAlignment</code> property.</p>
9,987
<p>I search about that topic, but all what I found, was the mechanical part of the 3d printer. But I didn't find, how to program it using arduino.</p> <p>I want to make a cartesian 3d printer. I don't have a printer yet, but I will buy all the components that I need actually.</p> <p>I know, how to control stepper motors, but I don't know, how I can program it in order to make the shape that I want.</p> <p>This is my question: what I need to learn in order to let this 3d printer make this shapes?</p>
<p>Yes. Look up Arduino Ramps 1.4</p> <p><a href="http://reprap.org/wiki/RAMPS_1.4" rel="noreferrer">http://reprap.org/wiki/RAMPS_1.4</a></p> <p>Following the programing is all done for you in the firmware. That said you can edit it. Just open the firmware files -- it is compiled when you upload them. Generally however one usually sticks to the preferences header alone..</p> <p><a href="http://reprap.org/wiki/List_of_Firmware" rel="noreferrer">http://reprap.org/wiki/List_of_Firmware</a></p> <p>Over all you are trying to reinvent the wheel. When I started 5-6 years ago it was barely a thing. Now you buy a proven kit and get to the printing. That said if you are truly interested in designing check out. </p> <p><a href="https://www.facebook.com/groups/cncbuilddesign/" rel="noreferrer">https://www.facebook.com/groups/cncbuilddesign/</a></p> <p>If you want help on picking a kit. Or what I really think you are looking for. A good place to start. This is one of the larger 3d printing groups. Full disclosure I run this one, but at 6k members I don't recruit. </p> <p><a href="https://www.facebook.com/groups/3DPrinterHobbyists/" rel="noreferrer">https://www.facebook.com/groups/3DPrinterHobbyists/</a></p> <p>I got my start in reprap IRC</p> <p><a href="http://reprap.org/wiki/IRC" rel="noreferrer">http://reprap.org/wiki/IRC</a></p> <p>Be aware there are trolls that now camp the IRC looking to sell you a printer. I would not engage with them, their printers are usually overpriced and sub par. </p> <p>Best of luck.</p> <p>Most of all I think you need to know it's Reprap all the way. Reprap forums, Reprap printers, Reprap kits, Reprap community. All the commercial printers started off the reprap project. Even if you buy a makerbot (don't) it's Reprap in it's roots.</p> <p><a href="https://vimeo.com/5202148" rel="noreferrer">https://vimeo.com/5202148</a></p>
<p>While Star Wind's answer is best as far as addressing what was not asked, but was probably the intent of the question, for educational purposes:</p> <p>To control the printer you need an microcontroller (most popular are Arduino) which will interface with the motor drivers. Microcontrollers cannot output the current needed to control the motors, so motor drivers (such as this <a href="https://www.pololu.com/product/1182" rel="noreferrer">https://www.pololu.com/product/1182</a> ) are easy ways to control a stepper motor with higher current (and usually voltage). You can build your own if you are particularlly adventurous, they are essentially two H-bridge circuits.</p> <p>The Arduino programming environment has a library for controlling stepper motors through a driver built in, you just tell it which pin to send the pulses to, and how fast, and a separate pin tells it to spin clockwise or counterclockwise. </p> <p>For a 3D printer you need at least four motors working in unison, one for the X, Y, Z axis, and one for the extruder (E axis). </p> <p>The existing programs that 3D printers use (Marlin, Sprinter, Teacup, etc) are all doing these simple steps at their core, but have implemented libraries of G-code that the printer uses to make control the stepper motors in unison to make the correct shape. Slicing programs such as Cura or Slic3r take in the 3D model and output the Gcode that the microcontroller is programmed to understand. </p>
330
<p>Is there a simple way to format numbers in a Winforms 1.1 datagrid? The Format property of the DataGridTextBoxColumn seems to be completely ignored. I know there is a <a href="http://support.microsoft.com/kb/318581" rel="nofollow noreferrer">solution</a> that involves subclassing a Column control, and it's fairly simple, but was hoping there might be some trick to making the Format property just work.</p>
<p>My personal opinion is that a datagridcolumnstyle is the way to go. Without seeing the code that you have, I can't say for certain why your formatting isn't taking hold when no style is defined - but mixing in formatting with data calculations and other parts of the code can get very messy very quickly.</p> <p>Creating a new column style class is very clean, and if you have to use the same formatting again in another datagrid, it's as easy as pie to reuse it.</p> <p>Here's the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridcolumnstyle.aspx" rel="nofollow noreferrer">Microsoft Documentation</a> that may get you started in the right direction.</p>
<p>I did subclass and it was easy and did work. I still don't like it so much. I was already subclassing column styles for other reasons. I'd rather handle all databinding myself, where I can more easily change it and test it. This whole mixing of the UI with the data is old school, and not in a good way.</p> <p>Thanks very much for your answers, it's good to have second opinions.</p> <p>Mike</p>
5,467
<p>Does anyone know of any good library that abstracts the problem of path manipulation in a nice way? I'd like to be able to combine and parse paths with arbitrary separators ('/' or ':' for example) without reinventing the wheel.</p> <p>It's a shame that <code>System.IO.Path</code> isn't more reusable.</p> <p>Thanks</p>
<p>System.IO.Path.Combine will work great for many different types of paths:</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx</a></p> <p>System.IO.Path.Combine uses the current platform standard separators to combine paths. That means on Windows it uses "\" and on unix/linux (mono) it uses "/". Can you give some samples of what paths you are trying to combine and on what platform?</p>
<p>You're describing regular expressions! Use that as the underpinning for what you need to do. </p>
7,529
<p>The <code>System.Windows.Threading.DispatcherObject</code> class (which <code>DependencyObject</code> is based on) contains a useful function, called <code>CheckAccess()</code>, that determines whether or not the code is running on the UI thread.</p> <p>When I wanted to use it yesterday, I was puzzled to find out that Intellisense didn't show the function (nor <code>VerifyAccess()</code>, which throws an exception when not on the UI thread), even though the MSDN library lists it. I decided to investigate the class using Reflector. It seems that the function in question has an <code>EditorBrowsable(EditorBrowsableState.Never)</code> attribute attached to it. The <code>Dispatcher</code> class, which is used by <code>DispatcherObject</code>, has the same attribute attached to <code>CheckAccess()</code> and <code>VerifyAccess()</code>:</p> <pre><code>public abstract class DispatcherObject { // ... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); // ... [EditorBrowsable(EditorBrowsableState.Advanced)] public Dispatcher Dispatcher { get; } } public sealed class Dispatcher { // ... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); // ... } </code></pre> <p>I don't believe that the application of that attribute is random (or a joke), so my question is: why is it there? Should those methods not be called directly? Then why aren't they <code>protected</code> (or <code>internal</code>, like some of the most useful methods in the WPF)?</p>
<p>A Microsoft employee <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bd0e6f6c-cadd-48f1-8e1a-163c2f17e4ca/" rel="noreferrer">recently stated</a> CheckAccess is used only for "advanced scenarios", so they hid it from Intellisense.</p> <blockquote> <p>"CheckAccess and VerifyAccess have always been marked to be not visible, maybe IntelliSense wasn't respecting it. You can use Reflector to confirm. The idea here is that CheckAccess and VerifyAccess are advances scenarios, that normal developers don't need.</p> <p>However, I do think that EditorBrowsableState.Advanced would have been a more appropriate level."</p> </blockquote> <p>There's a Microsoft Connect case for this shortcoming. <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=367777" rel="noreferrer">Vote for it</a> if it's important to you.</p>
<p>I can't find any documentation that says you shouldn't use those methods directly, but I haven't looked very long.</p> <p>Also you refer to the EditorVisibleAttribute, which doesn't exist. According to Reflector it's the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx" rel="nofollow noreferrer">EditorBrowsableAttribute</a>.</p> <p>Reflector disassembly:</p> <pre><code>[EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess() { //CODE } </code></pre>
3,813
<p>I'm working on a project using 3D printed parts, everything is working very nicely except for one part that needs a 3 mm x 1.2 mm diameter rod. I can print with PLA/PLA+ but such a thin object doesn't seem viable for 3D printing. Is it still possible or am I better off using a 1.2 mm metal dowel?</p> <p>The bigger part (5 mm x 7 mm diameter) near the back isn't an issue, it's the small rod that I can't seem to print correctly</p> <p><a href="https://i.stack.imgur.com/JGkft.png" rel="nofollow noreferrer" title="Part"><img src="https://i.stack.imgur.com/JGkft.png" alt="Part" title="Part" /></a></p>
<p>It would be impossible to print this standing with the rod straight up, and even if you got it to print the part would be very weak due to the thin cross-section of the rod aligning with the layers.</p> <p>The only way to print this part and get a usable result is to print it in the orientation shown in the picture, with the rod part being horizontal. Because the layers will now have a much larger cross-sectional area, this not only makes the print much stronger but also prevents issues with the plastic not cooling off sufficiently between layers. Though this will still be a tricky print, because now you'll need lots of support material.</p> <p>Using a metal rod is probably the better option. Another option is printing the rod lying flat on the bed, and gluing it in place later. This would avoid the issue with support material.</p>
<p>If you insist on printing it entirely, I would suggest cutting the model in two halves through the centerline, printing them flat and gluing both parts together after printing. This will make sure the axial direction of the rod is in the XY plane, and doesn't require support.</p> <p>However, the beauty of 3D printing is that it can be easily combined with other materials and techniques. In this case, you are far better off by printing the big cylinder with a hole in it and glueing a metal rod in. It is less trouble, stronger and possibly more functional since it will have a much better surface finish.</p>
2,098
<p>It is difficult to describe with words what's happening, so take a look at the picture. Somehow PrusaSlicer decides to move and print in the air (blue line), where instead it can continue going from outwards to inward. I understand it wants to print first the outer layer but in this case it is obvious it will not hold that layer.</p> <p>The final position is shown in the second image.</p> <p><a href="https://i.stack.imgur.com/iB1fc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iB1fc.jpg" alt="prusa slicer" /></a></p> <p>The final step of that layer: <a href="https://i.stack.imgur.com/PCetc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PCetc.jpg" alt="enter image description here" /></a></p> <p>Any idea how to configure PrusaSlicer to avoid this situation?</p>
<p>The inability to do this is not fundamental, but it's currently a limitation in slicing software, and not likely to change soon.</p> <p>You can see from <a href="https://www.youtube.com/watch?v=c9b7Ey4LyCs" rel="nofollow noreferrer">this demo</a> that the kind of printing you want is possible. However, it's currently only being done with software to assist in hand-crafting gcode to make the printer do what you want it to do. The hard part is making the slicer automatically figure out that that's what it's supposed to do.</p> <p>For your needs, just printing from outer loop inward here is not going to suffice. There needs to be overlap, computation to compensate for the fact that extrusion lines will not squeeze out to their nominal width because there's nothing below them to extrude against, and using the overlap in the XY direction to achieve that instead. This is all new stuff slicers have just not been programmed to do.</p> <p>So for now, you need supports. If you're willing to use Cura, Conical Supports or Tree Supports will let you support this with less waste material and make removal easier. Alternatively you could design your own support into the model and put it just under the hole in the middle, letting the flat part bridge. Or you could make a <em>sacrificial bridge layer</em> so that the first layer is solid bridge all the way across, and cut/drill it out after the print is done.</p>
<blockquote> <p>How to configure PrusaSlicer to prevent printing in the air</p> </blockquote> <p>You need either support or change the print orientation.</p> <p>You cannot print into the air, you can however print lines on top of a prior layer with a certain overlap, or bridge a certain gap. E.g. (screw) holes are often covered with 2 layers over the screw hole so that you use bridging to print (the cutout shows that the hole has a bottom):</p> <p><a href="https://i.stack.imgur.com/nPEbf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nPEbf.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/iVQ5a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iVQ5a.png" alt="enter image description here" /></a></p> <p>After printing you need to punch through the layers to open the hole.</p> <p>Starting and stopping extruding in thin air will result in deposition of the extruded material on the location the nozzle crosses a prior layer (often seen when support structure pillars have fallen over).</p> <p>What is used frequently together with support in Ultimaker Cura is the option called <code>Enable support roof</code>, this will create a dense top layer on top of the support interface which allows for pretty good bottom surface of the overhang.</p> <p>This e.g. results in the following slice:</p> <p><a href="https://i.stack.imgur.com/QolNr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QolNr.png" alt="enter image description here" /></a></p> <p>When applied to a recently printed flanged tube you see that the bottom surface is pretty good (note the concentric lined top surface, first image shows the product with support, second image, on the left a view of the bottom above support layer and right the support with roof layer):</p> <p><a href="https://i.stack.imgur.com/cZVtw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cZVtw.jpg" alt="enter image description here" /></a><a href="https://i.stack.imgur.com/3LmGO.jpg" rel="nofollow noreferrer" title="on the left a view of the bottom above support layer and right the support with roof layer"><img src="https://i.stack.imgur.com/3LmGO.jpg" alt="enter image description here" title="on the left a view of the bottom above support layer and right the support with roof layer" /></a></p> <blockquote> <p>How to configure PrusaSlicer to prevent printing in the air</p> </blockquote> <p>In PrusaSlicer you should be able to something pretty similar with <code>Interface pattern spacing</code> set to zero:</p> <p><a href="https://i.stack.imgur.com/jbHQr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jbHQr.png" alt="enter image description here" /></a></p>
2,202
<p>How do you page through a collection in LINQ given that you have a <code>startIndex</code> and a <code>count</code>?</p>
<p>A few months back I wrote a blog post about Fluent Interfaces and LINQ which used an Extension Method on <code>IQueryable&lt;T&gt;</code> and another class to provide the following natural way of paginating a LINQ collection.</p> <pre><code>var query = from i in ideas select i; var pagedCollection = query.InPagesOf(10); var pageOfIdeas = pagedCollection.Page(2); </code></pre> <p>You can get the code from the MSDN Code Gallery Page: <a href="http://code.msdn.microsoft.com/productschallenge" rel="noreferrer">Pipelines, Filters, Fluent API and LINQ to SQL</a>.</p>
<p>This question is somewhat old, but I wanted to post my paging algorithm that shows the whole procedure (including user interaction).</p> <pre><code>const int pageSize = 10; const int count = 100; const int startIndex = 20; int took = 0; bool getNextPage; var page = ideas.Skip(startIndex); do { Console.WriteLine("Page {0}:", (took / pageSize) + 1); foreach (var idea in page.Take(pageSize)) { Console.WriteLine(idea); } took += pageSize; if (took &lt; count) { Console.WriteLine("Next page (y/n)?"); char answer = Console.ReadLine().FirstOrDefault(); getNextPage = default(char) != answer &amp;&amp; 'y' == char.ToLowerInvariant(answer); if (getNextPage) { page = page.Skip(pageSize); } } } while (getNextPage &amp;&amp; took &lt; count); </code></pre> <p>However, if you are after performance, and in production code, we're all after performance, you shouldn't use LINQ's paging as shown above, but rather the underlying <code>IEnumerator</code> to implement paging yourself. As a matter of fact, it is as simple as the LINQ-algorithm shown above, but more performant:</p> <pre><code>const int pageSize = 10; const int count = 100; const int startIndex = 20; int took = 0; bool getNextPage = true; using (var page = ideas.Skip(startIndex).GetEnumerator()) { do { Console.WriteLine("Page {0}:", (took / pageSize) + 1); int currentPageItemNo = 0; while (currentPageItemNo++ &lt; pageSize &amp;&amp; page.MoveNext()) { var idea = page.Current; Console.WriteLine(idea); } took += pageSize; if (took &lt; count) { Console.WriteLine("Next page (y/n)?"); char answer = Console.ReadLine().FirstOrDefault(); getNextPage = default(char) != answer &amp;&amp; 'y' == char.ToLowerInvariant(answer); } } while (getNextPage &amp;&amp; took &lt; count); } </code></pre> <p>Explanation: The downside of using <code>Skip()</code> for multiple times in a "cascading manner" is, that it will not really store the "pointer" of the iteration, where it was last skipped. - Instead the original sequence will be front-loaded with skip calls, which will lead to "consuming" the already "consumed" pages over and over again. - You can prove that yourself, when you create the sequence <code>ideas</code> so that it yields side effects. -> Even if you have skipped 10-20 and 20-30 and want to process 40+, you'll see all side effects of 10-30 being executed again, before you start iterating 40+. The variant using <code>IEnumerable</code>'s interface directly, will instead remember the position of the end of the last logical page, so no explicit skipping is needed and side effects won't be repeated.</p>
2,247
<p>What is the easiest way to create and verify PGP/GPG signatures from within a Python application? </p> <p>I can call pgp or gpg using subprocess and parse the output, but I was looking for a way that didn't require an external program to be installed (my application is cross-platform mac/windows/unix).</p>
<p>I think <a href="http://www.gnupg.org/related_software/gpgme/" rel="nofollow noreferrer">GPGME</a> and the <a href="http://pyme.sourceforge.net/" rel="nofollow noreferrer">PyMe Python wrapper</a> should do what you need.</p>
<p>In addition to PyMe, consider <a href="http://code.google.com/p/python-gnupg/" rel="nofollow">python-gnupg</a> and the <a href="http://py-gnupg.sourceforge.net/" rel="nofollow">gnupginterface</a>.</p>
6,113
<p>I am printing a mechanical part for my printer. </p> <p>It's a new mount for my extruders and I have been attempting to use BVOH as a support filament so that when my print is done it will cut down on the need to finish the part and possible mistakes. </p> <p>My problem is I can get the BVOH to adhere to the bed with no problem and no warping of any kind, but I can't get the ASA to adhere to the BVOH supports. I run the BVOH at 220&nbsp;&deg;C and the ASA at 250&nbsp;&deg;C with my fan at 10&nbsp;% and I am using a Flashforge Creator Pro printer which is mostly enclosed. </p> <p>Does anyone know of a way to get the ASA to adhere to the BVOH?</p>
<p>Can you tell by looking at the de-adhesion what isn't sticking? </p> <p>It may be that printing the ASA at higher temperature is melting the BVOH enough that it doesn't stick, being molten. If so, then it may be possible to print the first layer of ASA at a cooler temperature, slower if necessary to still succeed at extrusion, with fans blowing. Then, print the next layer of ASA at a higher temperature, also with fans flowing.</p> <p>A test might be to print the BVOH, then a layer of ASA, and stop. Let it cool and test the adhesion. If it sticks under these conditions, then a better command of the temperature profile may offer a way forward.</p>
<p>Here's how I got it to work. I set the heat bed to 110°C and disabled the underlayer of the raft layer. I set the BVOH and the ASA to 235°C after the 4th layer I set the heatbed to 90°C and after the 6th layer I set the bed down to 60°C so that the BVOH hardened and adhered to the bed making sure that nothing curled or moved. After the print finished it took 24 hours for my BVOH to fully dissolve but thats probably because I set my support to 100% infill. Either way I got a perfect ASA extruder mount</p>
1,306
<p>I'm building a 40x40x40cm corexy and I am quite impatient so I want the heated to reach the target temperature as fast as possible, so I ordered a <a href="https://www.aliexpress.com/item/400X400mm-1200W-220V-w-NTC-100K-Thermistor-Keenovo-Silicone-Heater-Pad-for-Huge-Mega-Cube-3D/32550597606.html?spm=a2g0s.9042311.0.0.Io1mMV" rel="noreferrer">Keenovo silicone heater</a> It is a 220VAC 1200Watt bed, so I really want to make sure that it is safe to use. I also bought a <a href="http://www.crydom.com/en/products/catalog/series-1-240-ac-panel-mount.pdf" rel="noreferrer">Crydom D2450</a> SSR.</p> <p>Could someone tell me if the wiring in the diagram I made below is safe?</p> <p>Do I need to put a fuse or some other kind of safety?</p> <p><a href="https://i.stack.imgur.com/dd7TA.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/dd7TA.jpg" alt="wiring"></a></p>
<p>I had a similar issue building my Prusa i3 Mk2s clone. I was constantly hooking &amp; unhooking my Arduino from my PC while the printer was plugged into the mains. At some point it had enough &amp; it released some &quot;magic smoke&quot;. Later on I found out this was the power regulator on the Arduino.</p> <p>You shouldn't <strong>need</strong> to plug in the USB and the external power to the Arduino at the same time, but if you did, it is smart enough to only use one.</p> <p>That being said, by default the RAMPS passes 12V straight to the Arduino in order to power it (the Vin pin).</p>
<p>The answer is, yes you can, but you need to follow guidelines.</p> <p>Reversing +/- or otherwise incorrectly connecting power can destroy your electronics and cause fire hazard.</p> <hr /> <p>From <a href="http://reprap.org/wiki/RAMPS_1.4" rel="nofollow noreferrer">RepRap wiki - RAMPS 1.4</a></p> <blockquote> <p>Maximum Input Voltage Power Supply without diode There are three limiting factors to the maximum voltage that you can put into the RAMPS:</p> <p>The Arduino Mega maximum input voltage Filtering capacitor maximum voltages PTC fuse maximum voltages First, the 1N4004 diode connects the RAMPS input voltage to the Arduino Mega which has a recommended maximum input voltage of 12 volts. If your board does not have this diode soldered in (or if you cut it), you will need to power the Mega through the USB connector or through a separate 5v line, but this allows a higher RAMPS voltage.</p> <p>Second, most boards use 25v or 35v aluminum electrolytic capactors (C2, C3, C4, C6, C7, C9, and C10). To be safe, you should only go to half of your rated maximum voltage -- thus if your board has 35v capacitors (code VZA) then you should use a maximum input of 17.5v. The absolute maximum voltage is determined by the pololu servo drivers, which themselves are limited to 35V.</p> <p>Third, the MF-R500 (5A) PTC fuse is rated to 30V and the MF-R1100 (11A) PTC fuse is rated to 16V. They will need to be replaced with real fuses.</p> <p>Power Supply with diode If your board has a 1N4004 diode soldered in, do not apply more than 12 V to it. Original flavor Arduino Mega are rated to 12 V input. While Arduino Mega 2560 can take 20 V, it is not recommended.</p> </blockquote>
872
<p>Can people point me to resources on lexing, parsing and tokenising with Python?</p> <p>I'm doing a little hacking on an open source project (<a href="http://www.hotwire-shell.org/" rel="noreferrer">hotwire</a>) and wanted to do a few changes to the code that <a href="http://code.google.com/p/hotwire-shell/source/browse/trunk/hotwire/externals/shlex.py" rel="noreferrer">lexes</a>, <a href="http://code.google.com/p/hotwire-shell/source/browse/trunk/hotwire/command.py" rel="noreferrer">parses and tokenises</a> the commands entered into it. As it is real working code it is fairly complex and a bit hard to work out.</p> <p>I haven't worked on code to lex/parse/tokenise before, so I was thinking one approach would be to work through a tutorial or two on this aspect. I would hope to learn enough to navigate around the code I actually want to alter. Is there anything suitable out there? (Ideally it could be done in an afternoon without having to buy and read the dragon book first ...)</p> <p><strong>Edit:</strong> (7 Oct 2008) None of the below answers quite give what I want. With them I could generate parsers from scratch, but I want to learn how to write my own basic parser from scratch, not using lex and yacc or similar tools. Having done that I can then understand the existing code better. </p> <p>So could someone point me to a tutorial where I can build a basic parser from scratch, using just python?</p>
<p>I'm a happy user of <a href="http://www.dabeaz.com/ply/" rel="noreferrer">PLY</a>. It is a pure-Python implementation of Lex &amp; Yacc, with lots of small niceties that make it quite Pythonic and easy to use. Since Lex &amp; Yacc are the most popular lexing &amp; parsing tools and are used for the most projects, PLY has the advantage of standing on giants' shoulders. A lot of knowledge exists online on Lex &amp; Yacc, and you can freely apply it to PLY.</p> <p>PLY also has a good <a href="http://www.dabeaz.com/ply/ply.html" rel="noreferrer">documentation page</a> with some simple examples to get you started. </p> <p>For a listing of lots of Python parsing tools, see <a href="http://nedbatchelder.com/text/python-parsers.html" rel="noreferrer">this</a>.</p>
<p>I suggest <a href="http://www.canonware.com/Parsing/" rel="nofollow noreferrer">http://www.canonware.com/Parsing/</a>, since it is pure python and you don't need to learn a grammar, but it isn't widely used, and has comparatively little documentation. The heavyweight is ANTLR and PyParsing. ANTLR can generate java and C++ parsers too, and AST walkers but you will have to learn what amounts to a new language.</p>
5,756
<p>In an embedded application (written in C, on a 32-bit processor) with hard real-time constraints, the execution time of critical code (specially interrupts) needs to be constant.</p> <p>How do you insure that time variability is not introduced <strong>in the execution</strong> of the code, specifically due to the processor's caches (be it L1, L2 or L3)?</p> <p>Note that we are concerned with cache behavior due to the <strong>huge</strong> effect it has on execution speed (sometimes more than 100:1 vs. accessing RAM). Variability introduced due to specific processor architecture are nowhere near the magnitude of cache.</p>
<p>If you can get your hands on the hardware, or work with someone who can, you can turn off the cache. Some CPUs have a pin that, if wired to ground instead of power (or maybe the other way), will disable all internal caches. That will give predictability but not speed!</p> <p>Failing that, maybe in certain places in the software code could be written to deliberately fill the cache with junk, so whatever happens next can be guaranteed to be a cache miss. Done right, that can give predictability, and perhaps could be done only in certain places so speed may be better than totally disabling caches.</p> <p>Finally, if speed does matter - carefully design the software and data as if in the old day of programming for an ancient 8-bit CPU - keep it small enough for it all to fit in L1 cache. I'm always amazed at how on-board caches these days are bigger than all of RAM on a minicomputer back in (mumble-decade). But this will be hard work and takes cleverness. Good luck!</p>
<p>Understand your worst case runtime for complex operations and use timers.</p>
9,450
<p>I recently decided to upgrade to auto bed-leveling using an inductive proximity sensor and an aluminum build plate on my Prusa i3. I also wanted to try to secure the build plate using neodymium magnets at 4 points, with the magnets being secured with bolts to the Y-carriage, and steel washers glued to the bottom of the aluminum build plate (since aluminum is not magnetic).</p> <p>I would like to know if anybody has attempted this, and what the results were, as well as any issues incurred. My primary concern is a possible interference between the small magnetic field that is created by the magnet, and the sensor when probing the plate. I fear this question may sound a little open-ended, but I would just like to know if this could work. Please feel free to ask any follow up questions to details I may have missed. Thank you.</p> <p>P.S. I would also like to note, in case there is any relevance, I do not plan on using a heated build plate, since I have a heated build chamber.</p>
<p>Good question. The magnets from the build plate will almost certainly interfere with your inductive sensor, the movement from the carriage will induce a current in the inductor as it approaches the magnet and may cause it to trigger. If you're looking for a mag build, I'd suggest looking at: <a href="http://www.3dprintermods.com/prestashop/index.php?id_product=9&amp;controller=product" rel="nofollow">http://www.3dprintermods.com/prestashop/index.php?id_product=9&amp;controller=product</a></p> <p>I'm just about to get into auto-leveling myself, with this particular build there are a few ways to get around the issue. If you plot your auto level to occur as far from the magnets as possible (x,y location wise), then you might be ok. Otherwise you might consider investigating optical and touch probes.</p>
<p>You might use the magnets themselves or additional ones on top for the leveling process, as partly discussed in this thread:<br> <a href="http://forums.reprap.org/read.php?1,479795" rel="nofollow">http://forums.reprap.org/read.php?1,479795</a></p> <p>A mechanical or piezo switch might also solve the issue for you with a lot less guesswork and trouble.</p>
282
<p>I'm looking for an existing library to summarize or paraphrase content (I'm aiming at blog posts) - any experience with existing natural language processing libraries?</p> <p>I'm open to a variety of languages, so I'm more interested in the abilities &amp; accuracy.</p>
<p>I think he wants to generate blog posts by automatically paraphrasing whatever was it the blogs this system is monitoring.</p> <p>This would be really interesting if you could combine 2 to 10 blog posts that are similar, but from different sources and then do a paraphrased "real" summary automatically (the size of 1 blog post).</p> <p>It could also be great for Homeworks. Unfortunately it's not that easy to do.</p> <p>The only way I could see is to be able to decompose every sentence into "meaning", and then randomly change the sentence structure and some words retaining the meaning.</p> <p>These sentences mean the same:</p> <ul> <li>I hate this guy, he is so dumb.</li> <li>This guy is stupid, I hate him.</li> <li>I despise this dumb guy.</li> <li>He is dumb, I hate him.</li> </ul> <p>It would be nontrivial to write a program to transform one of these sentences to the others, and these are simple sentences, real sentences from blogs are much more complicated.</p>
<p>Your getting into really far out AI type domain. I have done extensive work in text transformation into machine knowledge mainly using Attempto Controlled English (see: <a href="http://attempto.ifi.uzh.ch/site/" rel="nofollow noreferrer">http://attempto.ifi.uzh.ch/site/</a>), it is a natural language (english) that is completely computer processable into several different ontologies, such as OWLDL.</p> <p>Seems like that would we way overkill though...</p> <p>Is there a reason for not just taking the first few sentences of your blog post and then appending an ellipse for your summary?</p>
4,497
<p>I am trying to program a small server+client in Javascript on Firefox, using XPCOM.</p> <p>To get the HTTP message in Javascript, I am using the nsIScriptableInputStream interface. This f**ing component through the read() method randomly cut the message and I cannot make it reliable.</p> <p>Is anybody know a solution to get reliably the information? (I already tried a binary stream, same failure.)</p> <p>J.</p>
<p>I had the same problem with unreliability... I ended up using XMLHTTPRequest, which when used from the XPCOM component can do cross site requests. The second part of the <a href="http://developer.mozilla.org/en/XMLHttpRequest" rel="nofollow noreferrer">docs</a> detail how to instantiate the XPCOM version.</p> <p>If you're looking to serve HTTP request I'd take a look at the <a href="https://addons.mozilla.org/en-US/firefox/addon/3002" rel="nofollow noreferrer">POW</a> source code and the use of <a href="http://www.xulplanet.com/tutorials/mozsdk/serverpush.php" rel="nofollow noreferrer">server sockets</a>, which implements a basic HTTP server in JavaScript. Also check out <a href="http://mxr.mozilla.org/mozilla/source/netwerk/test/httpserver/httpd.js" rel="nofollow noreferrer">httpd.js</a></p>
<p>If you control the protocol (that is, both the client and server) I would highly recommend using Javascript/JSON for your server-to-client messages. The client can open a stream either via dynamically adding a &lt;script&gt; tag to the DOM. The server can then send a stream of Javascript commands like:</p> <pre><code>receiveMsg({type:"text", content:"this is my message"}); </code></pre> <p>Then the client just needs to define a receiveMsg function. This allows you to rely on fast browser code to parse the message and determine where the end of each message is, at which point it will call your handler for you.</p> <p>Even if you're working with an existing HTTP protocol and can't use JSON, is there some reason you can't use XMLHttpRequest? I would expect it to be more stable than some poorly documented Firefox-specific XPCOM interface.</p> <p>--Chouser</p>
9,857
<p>Let's say that there is a solution that contains two projects (Project1 and Project2).</p> <p>Project1 is set as a StartUp Project (its name is displayed in a bold font). I double-click some file in Project2 to open it. The file opens, but something else happens too - Project2 gets set as a StartUp Project.</p> <p>I tried to find an option in configuration to change it, but I found none.</p> <p>Can this feature (though it's more like a bug to me) be disabled?</p>
<p>The way to select a startup project is described in <a href="http://blogs.msdn.com/saraford/default.aspx" rel="noreferrer">Sara Ford's blog "Visual Studio Tip of the Day</a>" (highly recommended). She has a post there about <a href="http://blogs.msdn.com/saraford/archive/2008/07/29/did-you-know-how-to-select-the-startup-project-269.aspx" rel="noreferrer">setting up StartUp projects</a>. Essentially there are 2 ways, the easiest one being right-clicking on the desired project, and choosing "Set As StartUp Project". That prevents other projects from becoming the StartUp project, even if you click on one their files. </p>
<p>I ran into a bug where the project in bold would not be the startup project despite it being selected in the solution properties as the "single startup project".</p> <p>One work around for this bug was un-checking deploy, from the Configuration Manager, for the non-bold project that was being incorrectly used as the startup project. The configuration manager is found by right clicking the solution in the Solution Explorer.</p>
2,645
<p>This is a follow on question to "<a href="https://stackoverflow.com/questions/33778/how-do-i-delete-1-file-from-a-revision-in-svn">How do I delete 1 file from a revision in SVN?</a>" but because it probably has a very different answer and I believe that others would benefit from knowing the answer. (I don't know the answer yet.)</p> <p>The previous question was answered and I discovered that it is not possible to remove a revision from SVN. The second best solution was to remove the file from SVN, commit and then add the file back and commit again.</p> <p>I now want to make sure that the original file's revision history has gone. So I am hoping that the answer to the question "<strong>How can I find the revision history of the file that was deleted and then resubmitted to SVN?</strong>" is that you can't.</p>
<p>With a simple </p> <pre><code>svn log -v [folder] </code></pre> <p>you can browse quickly the adding and deletion.</p> <pre><code>------------------------------------------------------------------------ r14 | kame | 2008-08-29 04:23:43 +0200 (ven., 29 aoû2008) | 1 line Chemins modifié : A /a.txt Readded a ------------------------------------------------------------------------ r13 | kame | 2008-08-29 04:23:24 +0200 (ven., 29 aoû2008) | 1 line Chemins modifié : D /a.txt Delete a ------------------------------------------------------------------------ r12 | kame | 2008-08-29 04:23:06 +0200 (ven., 29 aoû2008) | 1 line Chemins modifié : A /a.txt </code></pre> <p>svn log won't show the file, svn diff will pretend that the old revision does not exist, but a svn checkout targeting the old revision will happily give you the old file.</p>
<p>I would have said you can't - you have created a new file and thus revision tree in the eyes of SVN.</p> <p>It may be possible to recover the old tree independently (not sure if you managed an actual delete or just SVN Delete) but there is no link between the old revision tree and the new one.</p>
5,394
<p>My application dynamically loads assemblies at runtime from specific subfolders. These assemblies are compiled with dependencies to other assemblies. The runtime trys to load these from the application directory. But I want to put them into the modules directory.</p> <p>Is there a way to tell the runtime that the dlls are in a seperate subfolder?</p>
<p>One nice approach I've used lately is to add an event handler for the AppDomain's AssemblyResolve event.</p> <pre><code>AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler); </code></pre> <p>Then in the event handler method you can load the assembly that was attempted to be resolved using one of the Assembly.Load, Assembly.LoadFrom overrides and return it from the method.</p> <p>EDIT:</p> <p>Based on your additional information I think using the technique above, specifically resolving the references to an assembly yourself is the only real approach that is going to work without restructuring your app. What it gives you is that the location of each and every assembly that the CLR fails to resolve can be determined and loaded by your code at runtime... I've used this in similar situations for both pluggable architectures and for an assembly reference integrity scanning tool.</p>
<p>You can use the <code>&lt;codeBase&gt;</code> element found in the application configuration file. More information on "<a href="http://msdn.microsoft.com/en-us/library/15hyw9x3.aspx" rel="nofollow noreferrer">Locating the Assembly through Codebases or Probing</a>".</p> <blockquote> <p>Well, the loaded assembly doesn't have an application configuration file.</p> </blockquote> <p>Well if you know the specific folders at runtime you can use <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfrom.aspx" rel="nofollow noreferrer">Assembly.LoadFrom</a>. </p>
4,205