instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I posted the code below to the Sun developers forum since I thought it was erroring (the true error was before this code was even hit). One of the responses I got said it would not work and to throw it away. But it is actually working. It might not be the best code (I am new to Java) but is there something inherently "wrong" with it? </p> <p>=============</p> <p>CODE: <pre></p> <code>private static void ImportFromCsvToAccessTable(String mdbFilePath, String accessTableName , String csvDirPath , String csvFileName ) throws ClassNotFoundException, SQLException { Connection msConn = getDestinationConnection(mdbFilePath); try{ String strSQL = "SELECT * INTO " + accessTableName + " FROM [Text;HDR=YES;DATABASE=" + csvDirPath + ";].[" + csvFileName + "]"; PreparedStatement selectPrepSt = msConn.prepareStatement(strSQL ); boolean result = selectPrepSt.execute(); System.out.println( "result = " + result ); } catch(Exception e) { System.out.println(e); } finally { msConn.close(); } } </code></pre>
<p>The literal answer is no - there is never anything "inherently wrong" with code, it's a matter of whether it meets the requirements - which may or may not include being maintainable, secure, robust or fast.</p> <p>The code you are running is actually a JET query purely within Access - the Java code is doing nothing except telling Access to run the query.</p> <p>On the one hand, if it ain't broke don't fix it. On the other hand, there's a good chance it will break in the near future so you could try fixing it in advance.</p> <p>The two likely reasons it might break are:</p> <ol> <li>SQL injection risk. Depending on where csvDirPath and csvFileName come from (e.g. csvFileName might come from the name of the file uploaded by a user?), and on how clever the Access JDBC driver is, you could be open to someone breaking or deleting your data by inserting a semicolon (or some brackets to make a subquery) and some additional SQL commands into the query.</li> <li>You are relying on the columns of the CSV file being compatible with the columns of the Access table. If you have unchecked CSV being uploaded, or if the CSV generator has a particular way of handling nulls, or if you one day get an unusual date or number format, you may get an error on inserting into the Access table.</li> </ol> <p>Having said all that, we are all about pragmatism here. If the above code is from a utility class which you are going to use by hand a few times a week/month/year/ever, then it isn't really a problem.</p> <p>If it is a class which forms part of a web application, then the 'official' Java way to do it would be to read records out of the CSV file (either using a CSV parser or a CSV/text JDBC driver), get the columns out of the recordset, do some validation or sanity checking on them, and then use a new PreparedStatement to insert them into the Access database. Much more trouble but much more robust.</p> <p>You can probably find a combination of tools (e.g. object-relational layers or other data access tools) which will do a lot of that for you, but setting up the tools is going to be as much hassle as writing the code. Then again, you'll learn a lot from either one.</p>
<p>Question to Joshua McKinnon:</p> <p>Can you provide a citation about MS's plans to never introduce 64-bit ODBC drivers for Jet? This sounds reasonable, so I'm not doubting you at all, I would just like to know if you have a source for it that you can point to.</p> <p>Surely MS <em>is</em> providing access to Jet on 64-bit systems through OLEDB, though, right? That doesn't help with JDBC, but certainly provides a method to use Jet data (they have to provide something, since Jet 4 is part of the OS, as it is used as the data store for Active Directory, and has been used thus since Windows 2000).</p>
5,056
<p>With Ender 3 is there a way to configure printer extruder to go all way up when the printing finishes?</p> <p>Or even with the Ultimaker Cura software?</p> <p>I want this, because i'm going to put a switch on the top of the printer that will switch it off when the printer finishes (if i can make the arm with the extruder go all the way up when printing finishes.)</p> <p>How can this be done?</p>
<p>The most safe way to move the printer up to the maximum print height is to use a concept known as "<strong>keywords</strong>" (sort of constants that are filled by the correct value when slicing) in Ultimaker Cura, certainly if you have multiple printers with different print area sizes.</p> <p>To use these keywords, just add these in between curly braces and insert them into your slicer "End G-code" script. These keywords will be substituted with actual numbers from the printer settings or slicing configuration parameters. In this case we need to use the maximum print height which is specified by the keyword <code>machine_height</code>. This keyword takes its value from the printer settings, set for the printer in the graphical user interface of the printer settings, see image below (this is a configuration of an Ultimaker 3 Extended, it also shows the <strong>Start G-code</strong> and <strong>End G-code</strong> which you can tweak yourself, as seen by the additional G-code line <code>G0 F10000 Z{machine_height}</code> that has been added for this demonstration).</p> <p><a href="https://i.stack.imgur.com/Np6Gy.png" rel="nofollow noreferrer" title="Printer settings, configuration of an Ultimaker 3 Extended"><img src="https://i.stack.imgur.com/Np6Gy.png" alt="Printer settings, configuration of an Ultimaker 3 Extended" title="Printer settings, configuration of an Ultimaker 3 Extended"></a></p> <p>E.g. similar to <a href="/a/10627">this answer</a>, you could solve this with a keyword. Now when you slice for a certain printer (e.g. with the printer settings of the image above), the correct value will be filled in automatically when slicing the print object as can be seen from this snippet of G-code:</p> <pre> ... G91 ;Relative movement G0 F15000 X8.0 Z0.5 E-4.5 ;Wiping+material retraction G0 F10000 Z1.5 E4.5 ;Compensation for the retraction G90 ;Disable relative movement G0 F10000 Z300 ; &lt;------------ note to see {machine_height} be resolved to 300 mm ... </pre> <hr> <p><em>This is specifically for Ultimaker Cura. Do note that e.g. Slic3r even takes the keyword concept further by allowing arithmetic and logic, similar as you could do in programming languages!</em></p>
<p>If you use OctoPrint, there is a plugin that will allow you to take action on certain events, such as print completion. The action that it can take would allow you to turn of a TP-link smart plug; which would turn off the printer. You could then use the phone app to turn it back on.</p>
1,415
<p>I have this clogging problem on my 3D printer that I am having a really hard time to solve. I am a hobbiest so in no way am I a professional with regards to 3D printers. I also know that this is a popular issue and I have tried a lot of the proposed solutions (going through a lot of PLA filament and failed prints) to no avail. I will try to describe the problem and what I have tried to solve it.</p> <p>First the issue:<a href="https://i.stack.imgur.com/OremM.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/OremM.jpg" alt="Removed hortend to show the clog"></a></p> <p>This shows how the filament clogs. The next image shows the assembled printer head for reference.: <a href="https://i.stack.imgur.com/AhioD.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/AhioD.jpg" alt="Assembled printer head"></a></p> <p>This is how the print looks when it fails:<a href="https://i.stack.imgur.com/ZcvdG.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ZcvdG.jpg" alt="Failed print"></a></p> <p>I have tried the following: - Adjusting the temperate between 190 up to 220 for the PLA filament. Everything trying a print with it. - Doing a thorough cleaning of the nozzle (Acetone soak, wire brush, guitar string etc.) - Checking the Teflon pipe inside the tube if it is clear and ensuring that the edges allow the filament to pass through. - Check if the cooling fans work well to ensure cooling of the whole assembly (they work, they aren't jammed etc.) - Dissambling the printer head and putting it back together.</p> <p>I have printed with the printer before without a problem. I printed PETG a few times to get that working and the results were decent. When I returned to PLA this issue started and no matter what I change on the profile it won't work. I have tried adjusting feedrate, flow rate, retraction amount and speed, temperature, fan speeds to name but a few things.</p> <p>I have a Cura profile I can upload if that will help. Any advise would be much appreciated. I have been struggling with this for a while now and really need some options.</p>
<h2>A Scriptable Process for Generating Multi-Material STL Files:</h2> <p>I am now using interactive CAD software to define the more complex features of the object I am printing (in the current case, clock faces), and then using OpenSCAD to do the boolean volume operations. </p> <p>To print the composite object, I need three STL files, one for each material I am using. The three parts are the clock body, the translucent optics to conduct the LED lights, and the clock numbers. </p> <p>I need:</p> <ul> <li>one STL for the body minus the LED optics and minus the numbers.</li> <li>one STL for the numbers minus the LED optics, and</li> <li>one STL for the LED optics.</li> </ul> <p>The CAD package supports the operations, but every time I change anything, I have to jump through several hoops to combine the three parts, manually and recreate the three objects. </p> <p>I had used OpenSCAD to make the optics and the numbers, and they were never in the same coordinate system as the clock body from the interactive CAD package.</p> <p>So, I scripted it and used OpenSCAD to read the clock body STL and being it into OpenScad. I transformed it into the common coordinate system. I then did, one by one, based on a command-line parameter, the boolean operations, rendered the result, and exported the resulting STL file.</p> <p>When I read the three files into PrusaSlicer, the lined up perfectly and everything worked simply, without and precision hand-eye coordination, and with no drama.</p> <p>Scripts and command lines work for repeatability far better than squint, drag, and guess.</p>
<p>You do not necessarily need a specific design tool, you can use any tool you want to create your multiple material product. It is the slicer software that manages the materials by assigning the correct extruder. E.g. Cura is able to join 2 STL files that fit together and assign each part a specific extruder and thus material. Please read more <a href="https://ultimaker.com/en/blog/34012-get-started-with-cura-printing-with-two-colors" rel="nofollow noreferrer">here for instructions</a></p>
861
<p>I'm thinking in particular of how to display pagination controls, when using a language such as C# or Java.</p> <p>If I have <em>x</em> items which I want to display in chunks of <em>y</em> per page, how many pages will be needed?</p>
<p>Found an elegant solution:</p> <pre><code>int pageCount = (records + recordsPerPage - 1) / recordsPerPage; </code></pre> <p>Source: <a href="http://www.cs.nott.ac.uk/~rcb/G51MPC/slides/NumberLogic.pdf" rel="noreferrer">Number Conversion, Roland Backhouse, 2001</a></p>
<p>You'll want to do floating point division, and then use the ceiling function, to round up the value to the next integer.</p>
3,854
<p>I really feel that I should learn <a href="http://en.wikipedia.org/wiki/Lisp_(programming_language)" rel="noreferrer">Lisp</a> and there are plenty of good resources out there to help me do it.</p> <p>I'm not put off by the complicated syntax, but where in "traditional commercial programming" would I find places it would make sense to use it instead of a procedural language.</p> <p>Is there a commercial killer-app out there that's been written in Lisp ?</p>
<p>One of the main uses for Lisp is in Artificial Intelligence. A friend of mine at college took a graduate AI course and for his main project he wrote a "<a href="http://en.wikipedia.org/wiki/Lights_Out_(video_game)" rel="noreferrer">Lights Out</a>" solver in Lisp. Multiple versions of his program utilized slightly different AI routines and testing on 40 or so computers yielded some pretty neat results (I wish it was online somewhere for me to link to, but I don't think it is).</p> <p>Two semesters ago I used Scheme (a language based on Lisp) to write an interactive program that simulated Abbott and Costello's "Who's on First" routine. Input from the user was matched against some pretty complicated data structures (resembling maps in other languages, but much more flexible) to choose what an appropriate response would be. I also wrote a routine to solve a 3x3 <a href="http://en.wikipedia.org/wiki/Sliding_puzzle" rel="noreferrer">slide puzzle</a> (an algorithm which could easily be extended to larger slide puzzles).</p> <p>In summary, learning Lisp (or Scheme) may not yield many practical applications beyond AI but it is an extremely valuable learning experience, as many others have stated. Programming in a functional language like Lisp will also help you think recursively (if you've had trouble with recursion in other languages, this could be a great help).</p>
<p>Syntax is irrelevant, readability is not!</p>
2,673
<p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p> <pre><code>Shoes.app do t = para "Not clicked!" button "The Label" do alert "You clicked the button!" # when clicked, make an alert t.replace "Clicked!" # ..and replace the label's text end end </code></pre> <p>This made me think - how would I design a similarly nice-to-use GUI framework in Python? One that doesn't have the usual tyings of basically being wrappers to a C* library (In the case of GTK, Tk, wx, QT etc etc)</p> <p>Shoes takes things from web devlopment (like <code>#f0c2f0</code> style colour notation, CSS layout techniques, like <code>:margin =&gt; 10</code>), and from ruby (extensively using blocks in sensible ways)</p> <p>Python's lack of "rubyish blocks" makes a (metaphorically)-direct port impossible:</p> <pre><code>def Shoeless(Shoes.app): self.t = para("Not clicked!") def on_click_func(self): alert("You clicked the button!") self.t.replace("clicked!") b = button("The label", click=self.on_click_func) </code></pre> <p>No where near as clean, and wouldn't be <em>nearly</em> as flexible, and I'm not even sure if it would be implementable.</p> <p>Using decorators seems like an interesting way to map blocks of code to a specific action:</p> <pre><code>class BaseControl: def __init__(self): self.func = None def clicked(self, func): self.func = func def __call__(self): if self.func is not None: self.func() class Button(BaseControl): pass class Label(BaseControl): pass # The actual applications code (that the end-user would write) class MyApp: ok = Button() la = Label() @ok.clicked def clickeryHappened(): print "OK Clicked!" if __name__ == '__main__': a = MyApp() a.ok() # trigger the clicked action </code></pre> <p>Basically the decorator function stores the function, then when the action occurred (say, a click) the appropriate function would be executed.</p> <p>The scope of various stuff (say, the <code>la</code> label in the above example) could be rather complicated, but it seems doable in a fairly neat manner..</p>
<p>You could actually pull this off, but it would require using metaclasses, which are <em>deep</em> magic (there be dragons). If you want an intro to metaclasses, there's a series of <a href="http://www.ibm.com/developerworks/linux/library/l-pymeta.html" rel="nofollow noreferrer">articles from IBM</a> which manage to introduce the ideas without melting your brain.</p> <p>The source code from an ORM like SQLObject might help, too, since it uses this same kind of declarative syntax.</p>
<p>Declarative is not necessarily more (or less) pythonic than functional IMHO. I think a layered approach would be the best (from buttom up):</p> <ol> <li>A native layer that accepts and returns python data types.</li> <li>A functional dynamic layer.</li> <li>One or more declarative/object-oriented layers.</li> </ol> <p>Similar to <a href="http://elixir.ematia.de/trac/wiki" rel="nofollow noreferrer">Elixir</a> + <a href="http://www.sqlalchemy.org/" rel="nofollow noreferrer">SQLAlchemy</a>.</p>
8,314
<p>I'm wondering how to use a VideoDisplay object (defined in MXML) to display video streamed from FMS via a NetStream.</p> <p>The <a href="http://livedocs.adobe.com/flex/3/langref/mx/controls/VideoDisplay.html" rel="noreferrer">Flex3 docs</a> suggest this is possible:</p> <blockquote> <p>The Video Display ... supports progressive download over HTTP, streaming from the Flash Media Server, and streaming from a Camera object.</p> </blockquote> <p>However, later in the docs all I can see is an attachCamera() method. There doesn't appear to be an attachStream() method like the old Video object has.</p> <p>It looks like you can play a fixed file served over HTML by using the source property, but I don't see anything about how to attach a NetStream.</p> <p>The old <a href="http://livedocs.adobe.com/flex/3/langref/flash/media/Video.html" rel="noreferrer">Video</a> object still seems to exist, though it's not based on UIComponent and doesn't appear to be usable in MXML.</p> <p>I found <a href="http://blog.flexexamples.com/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/" rel="noreferrer">this blog post</a> that shows how to do it with a regular Video object, but I'd much prefer to use VideoDisplay (or something else that can be put directly in the MXML).</p>
<p>Unfortunately you can attachNetStream() only on Video object. So you are doomed to use em if you want to get data from FMS.</p> <p>By the way attachCamera() method <strong>publishes</strong> local camera video to the server so be careful ;)</p>
<p>it works.</p> <p>mx:VideoDisplay live="true" autoPlay="true" source="rtmp://server.com/appname/streamname" /></p> <p>that will give you live video through a videodisplay... problem is it won't use an existing netconnection object, it creates it's own... which is what I'm trying to find a work around for.</p>
6,377
<p>I have a dual-extruder printer with a separate heating element for each head, thus able to combine materials in a single print job even if they don't share a single temperature range.</p> <p>Now the question: When (outside of using expensive dedicated support material or doing multicolor prints for aesthetic reasons) is this actually useful?</p> <p>Of common printable filaments (PLA, PETG, TPU, ABS, nylon):</p> <ul> <li>Do some of these materials work well (which is to say, substantially better than just doing a single-material print with same-material supports) as breakaway supports for others?</li> <li>Can some of these materials be dissolved in household solvents that don't harm others?</li> <li>Do some of these materials adhere to each other strongly enough (and have sufficiently similar profiles in how they shrink on cooling) to reliably generate finished pieces comprising of both? (Especially relevant for anything+TPU, where one might want to generate a design with some soft or rubbery components).</li> </ul>
<p>The answers are </p> <ol> <li><p>yes</p></li> <li><p>yes</p></li> <li><p>probably</p></li> </ol> <p>Which is to say, if you only want to use MaterialNumberTwo for disposable supports, then you should be fine. Presumably the slicer software is material-aware and adjusts the feed so the layer heights are the same for both materials. <strong>BUT</strong>be careful that the support material isn't higher-temp than the object material, or supports which start from the object rather than the bed may cause local melting or distortion when the first layer is deposited on the cooler-melt material. </p> <p>But if you want to try to intertwine two materials for the final product, then certainly bonding will be a major risk, as will shrinkage during cooling (not to mention the risk of melting the lower-temp material while depositing the higher-temp material on top of it!). If at all possible I'd recommend printing such parts separately and fitting them together post-print. </p>
<p>I have printed ABS on top of PLA and it has bonded well. It was simple, then "campaign"-style buttons with Prusament Galaxy Black on the bottom and HatchBox white ABS on top. There was no tendency to warp, as I would expect if the ABS were shrinking more than the PLA.</p> <p>I expected this to not work, but I needed white on black and these were the filaments I had.</p>
1,439
<p>How do you automatically set the focus to a textbox when a web page loads?</p> <p>Is there an HTML tag to do it or does it have to be done via Javascript?</p>
<p>If you're using jquery:</p> <pre><code>$(function() { $("#Box1").focus(); }); </code></pre> <p>or prototype:</p> <pre><code>Event.observe(window, 'load', function() { $("Box1").focus(); }); </code></pre> <p>or plain javascript:</p> <pre><code>window.onload = function() { document.getElementById("Box1").focus(); }; </code></pre> <p>though keep in mind that this will replace other on load handlers, so look up addLoadEvent() in google for a safe way to append onload handlers rather than replacing.</p>
<p>Use the below code. For me it is working</p> <pre><code>jQuery("[id$='hfSpecialty_ids']").focus() </code></pre>
6,784
<p>I'd like a dead simple explanation of policy injection for less-informed co-workers. Where is a good resource for this? I learned about policy injection from the entlib help files, which I'm sure aren't the best option.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/cc309370.aspx" rel="nofollow noreferrer">The MSDN documentation for Policy Injection</a> has a pretty clear explanation:</p> <blockquote> <p>Applications include a mix of business logic and crosscutting concerns, and the two are typically intermingled—which can make the code harder to read and maintain. Each task or feature of an application is referred to as a "concern." Concerns that implement the features of an object within the application, such as the business logic, are core concerns. Crosscutting concerns are the necessary tasks, features, or processes that are common across different objects—for example, logging, authorization, validation, and instrumentation. The purpose of the Policy Injection Application Block is to separate the core concerns and crosscutting concerns.</p> </blockquote> <p>Simply put, the PI block lets developers define a set of policies that specify the behavior of objects in the system. So your core business logic, such as the code that calculates profit per unit in a fiscal year (one concern), is separated from the logging of that execution of logic (another, but more often used, concern). </p> <p>The same documentation says that the PI block is <em>not</em> AOP because:</p> <ul> <li>It uses interception to enable only pre-processing handlers and post-processing handlers. </li> <li>It does not insert code into methods. </li> <li>It does not provide interception for class constructors. </li> </ul> <p>So trying to look at PI from an AOP perspective can muddy the waters a bit.</p>
<p>What the EntLib calls Policy Injection, is really Aspect Oriented Programming. I wrote a post <a href="http://iridescence.no/post/Aspect-Oriented-Programming-A-Primer.aspx" rel="nofollow noreferrer">introducing the concepts of AOP on my blog</a> a while back, maybe it'll be helpful.</p>
9,917
<p>Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes I need to scroll around in order to get the syntax highlighting adjusted, as sometimes it mysteriously drops all highlighting.</p> <p>Are there any work-arounds or ways to fix this? I'm using vim 7.1.</p>
<p>You might like to try this <a href="http://www.vim.org/scripts/script.php?script_id=1491" rel="noreferrer">improved Javascript syntax highlighter</a> rather than the one that ships with VIMRUNTIME.</p>
<p>For a quick and dirty fix, sometimes I just scroll up and down and the highlighting readjusts. <kbd>Ctrl</kbd>+<kbd>L</kbd> for a screen redraw can also fix it.</p>
8,326
<p>What is the best Image Manager to integrate in TinyMce editor apart the official Moxiecode commercial ones?</p> <p>I'm looking to integrate a light texteditor in an asp.net mvc application and I choosed the Tinymce solution (and not the classic FCKEditor as this seems more lightweight and more jquery friendly).</p> <p>Sadly TinyMce doesn't come with the Image Manager or Document Manager integrated like FCKeditor but you must buy them as plugins form Moxiecode.</p> <p>I've looked other plugins but till now I've not find any decend and light solution that works with asp.net mvc framework. </p> <p>Any suggestions?</p>
<p>There are a couple of open source plugins on SourceForge,</p> <p><a href="http://sourceforge.net/tracker/?group_id=103281&amp;atid=738747" rel="noreferrer">http://sourceforge.net/tracker/?group_id=103281&amp;atid=738747</a> (search for image)</p> <p>The plugin architecture is easy to understand if you know Javascript. If you have the time you could roll out your own.</p>
<p>Carlton : Alfresco seems to be a Java based solution. Ta: I've looked into the plugin folders but none was really good for asp.net mvc. What I'm now testing is a mix between Tiny with the image uploader of FCKEditor: this is the pho version but I think it is pretty easy to convert to .net [Tinyfck][1]</p> <p>[1]: this: <a href="http://p4a2.crealabsfoundation.org/tinyfck" rel="nofollow noreferrer">http://p4a2.crealabsfoundation.org/tinyfck</a></p>
4,003
<p>Do we want to add a BLOG to this site? Blogs are another way of communicating things that don't fit the Q&amp;A model.</p> <p>Here is a good description of <a href="https://stackoverflow.blog/2011/06/23/blog-overflow/">what a Blog is and how you can start one</a>.</p> <p>This post on the SuperUser Blog asking for <a href="http://blog.superuser.com/2012/02/09/are-you-interested-in-writing-for-our-blog/" rel="nofollow noreferrer">help with their Blog</a> is helpful too.</p>
<p>The description of blogs you've cited is 6 years old. Unfortunately, <a href="https://meta.stackexchange.com/questions/291741/we-will-no-longer-be-hosting-blog-overflow">blogs have since been discontinued</a>.</p> <p>It is no longer possible to start a new blog.</p>
<p>+1 - As it seems a good idea. Not sure what would go in it though - do you have any concrete examples of blog ideas? </p> <p>I already have a (messy) <a href="https://gr33nonline.wordpress.com/" rel="nofollow noreferrer">blog</a>, and I am not sure if I could also write a blog on here too. I wonder what the score is regarding duplicating personal blogs on to SE blogs? </p> <hr> <h3>Content</h3> <p>An SE 3D print blog could be a good idea for <strong><em>Build Logs</em></strong>, for example, maybe. Or maybe a page that links to other people's superlative build logs, <a href="https://miscsolutions.wordpress.com/" rel="nofollow noreferrer">David Crocker's blogs</a> come to mind.</p> <p>Is the blog (unlike the SE Q&amp;A site) allowed to contain <strong><em>links to cheap items/suppliers</em></strong>? Apparently, reviews are allowed, from <a href="https://stackoverflow.blog/2011/06/23/blog-overflow/">Blog Overflow</a>:</p> <blockquote> <p><strong>Review a product</strong>. Reviews don’t fit the Q&amp;A nature of the sites, but these rules don’t apply on the blog! Between a review written by a random person on the internet and a review written by a user on the site who consistently gets a lot of upvotes, which review would you trust more?</p> </blockquote> <p>This closed question would have fitted into a blog nicely: <a href="https://3dprinting.stackexchange.com/questions/4279/what-is-3d-printing">What Is 3D Printing?</a></p> <hr> <h3>Concerns</h3> <p>So, yes, I think it would be worth starting one up and seeing how it goes... although I would be a little concerned about the regularity of posts: </p> <blockquote> <p><strong>Plan a schedule</strong>. Given the results of steps #2 and #3, think about a rough idea of a schedule for the blog. Will there be one post a week, posted Mondays? Will there be posts on Tuesdays and posts on Fridays? You don’t need to be pushing out posts daily, but you should post at least once a week.</p> </blockquote> <p><em>and</em></p> <blockquote> <p><strong>Pick a posting schedule and stick to it</strong>. It is easier to simply keep up from the get go than catch up if you fall behind. Have a couple draft posts stashed away for a rainy day, ready to go that can be published if there is a lull.</p> </blockquote> <p>Also, who would coordinate it? Are you putting yourself forward?</p> <blockquote> <p><strong>Have someone holding the reins</strong>. This person doesn’t need to be the one writing all the posts, just someone that helps coordinate who is writing what and when it is getting posted.</p> </blockquote> <hr> <p>However, it <em>is</em> a bit of a misfortune that Blog Overflow has a rather unfortunately acronym (as well as sounding like <em>Bog</em> Overflow).</p>
43
<p>I have an Image control with it's source bound to a property on an object(string url to an image). After making a service call, i update the data object with a new URL. The exception is thrown after it leaves my code, after invoking the PropertyChanged event.</p> <p>The data structure and the service logic are all done in a core dll that has no knowledge of the UI. How do I sync up with the UI thread when i cant access a Dispatcher? </p> <p>PS: Accessing Application.Current.RootVisual in order to get at a Dispatcher is not a solution because the root visual is on a different thread(causing the exact exception i need to prevent). </p> <p>PPS: This only is a problem with the image control, binding to any other ui element, the cross thread issue is handled for you.</p>
<pre><code>System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =&gt; {...}); </code></pre> <p>Also look <a href="https://stackoverflow.com/questions/1924408/invalid-cross-thread-access-issue/1925827#1925827">here.</a></p>
<p>The property getter for RootVisual on the Application class has a thread check which causes that exception. I got around this by storing the root visual's dispatcher in my own property in my App.xaml.cs:</p> <pre><code>public static Dispatcher RootVisualDispatcher { get; set; } private void Application_Startup(object sender, StartupEventArgs e) { this.RootVisual = new Page(); RootVisualDispatcher = RootVisual.Dispatcher; } </code></pre> <p>If you then call BeginInvoke on App.RootVisualDispatcher rather than Application.Current.RootVisual.Dispatcher you shouldn't get this exception.</p>
6,915
<p>After trying to avoid JavaScript for years, Iv started using Query for <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">validation</a> in MVC asp.net, as there does not seem to be an official way of doing validation, Iv been surprised how good jQuery is. </p> <p>Firstly is there a way to get intellisense working for jQuery and its validation plugin, so that i don have to learn the api?</p> <p>Secondly how do I create a validation summary for this, it currently appends the error to the right of the text box.:</p> <pre><code>&lt;script type="text/javascript"&gt; $().ready(function() { $("#CreateLog").validate({ rules: { UserName: { required: true, minLength: 2, } }, messages: { UserName: { required: "Please enter a username", minLength: "Your username must consist of at least 2 characters", } } }); }); &lt;/script&gt; &lt;form id="CreateLog" action="Create" method="post" /&gt; &lt;label&gt;UserName&lt;/label&gt;&lt;br /&gt; &lt;%=Html.TextBox("UserName")%&gt; &lt;br /&gt; &lt;div class="error"&gt; &lt;/div&gt; &lt;input type=submit value=Save /&gt; &lt;/form&gt; </code></pre> <p>I tried adding this to the script:</p> <pre><code> errorLabelContainer: $("#CreateLog div.error") </code></pre> <p>and this to the html:</p> <pre><code> &lt;div class="error"&gt; &lt;/div&gt; </code></pre> <p>But this didn't work.</p>
<p>Try specifying both a wrapper and a label container in your options. I also added <code>display:none;</code> to the style of error-container to let jQuery decide when to show it.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$().ready(function() { $("#CreateLog").validate({ errorLabelContainer: $("ul", $('div.error-container')), wrapper: 'li', rules: { UserName: { required: true, minLength: 2, } }, messages: { UserName: { required: "Please enter a username", minLength: "Your username must consist of at least 2 characters" } } }); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div class="error-container"&gt; &lt;ul&gt;&lt;/ul&gt; &lt;/div&gt; &lt;form id="CreateLog" action="Create" method="post" /&gt; &lt;label&gt;UserName&lt;/label&gt;&lt;br /&gt; &lt;%=Html.TextBox("UserName")%&gt; &lt;br /&gt; &lt;input type=submit value=Save /&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>That should work.</p>
<p>regarding intellisense for jquery (and other plugins): in order to have full intellisense in your own script files as well, just include the following line at the top of your .js file once for each file you want intellisensee from:</p> <pre><code>/// &lt;reference path="[insert path to script file here]" /&gt; </code></pre> <p>simple, but very useful =)</p>
8,671
<p>When using 3rd party libraries/components in production projects, are you rigorous about using only released versions of said libraries?</p> <p>When do you consider using a pre-release or beta version of a library (in dev? in production, under certain circumstances)? </p> <p>If you come across a bug or shortcoming of the library and you're already committed to using it, do you apply a patch to the library or create a workaround in your code?</p>
<p>I am a big fan of not coding something when someone else has a version that I could not code in a reasonable amount of time or would require me to become an expert on something that wouldn't matter in the long run. </p> <p>There are several open source components and libraries I have used in our production environment such as Quartz.NET, Log4Net, nLog, SharpFTPLibrary (heavily modified) and more. Quartz.NET was in beta when I first released an application using it into production. It was a very stable beta and I had the source code so I could debug an issue and there were a few. When I encountered a bug or an error I would fix it and post the issue to the bug tracker or author. I feel very comfortable using a beta product if the source is available for me to debug any issues or there is a strong following of developers hammering out any issues.</p>
<ul> <li>Yes. Unless there's a feature we really need in a beta version.</li> <li>There's no point using a beta version in dev if you aren't certain you'll use it in production. That just seems like a wasted exercise</li> <li>I'll use the patch. Why write code for something you've paid for?</li> </ul>
4,271
<p>Does anyone know a tool for Profiling JavaScript in IE?</p> <p>List available:</p> <ul> <li><a href="http://blogs.msdn.com/ie/archive/2008/09/11/introducing-the-ie8-developer-tools-jscript-profiler.aspx" rel="noreferrer">IE8</a> (Internet Explorer 8 only)</li> <li><a href="http://www.whitefrost.com/documents/html/technical/dhtml/jsprof.html" rel="noreferrer">JavaScript Profiler</a></li> <li><a href="http://developer.yahoo.com/yui/profiler/" rel="noreferrer">YUI!</a></li> </ul>
<p>Checkout <a href="http://ejohn.org/blog/deep-tracing-of-internet-explorer/" rel="noreferrer">http://ejohn.org/blog/deep-tracing-of-internet-explorer/</a> the dynaTrace tool shown here is fantastic and works with IE7.</p>
<p>We use Firebugs console.log, console.time and console.timeEnd (I think) a lot.</p> <p>Firebug also has a built in profiler.</p>
4,074
<p>I have a simple web service operation like this one:</p> <pre><code> [WebMethod] public string HelloWorld() { throw new Exception("HelloWorldException"); return "Hello World"; } </code></pre> <p>And then I have a client application that consumes the web service and then calls the operation. Obviously it will throw an exception :-)</p> <pre><code> try { hwservicens.Service1 service1 = new hwservicens.Service1(); service1.HelloWorld(); } catch(Exception e) { Console.WriteLine(e.ToString()); } </code></pre> <p>In my catch-block, what I would like to do is extract the Message of the actual exception to use it in my code. The exception caught is a <code>SoapException</code>, which is fine, but it's <code>Message</code> property is like this...</p> <pre><code>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.Exception: HelloWorldException at WebService1.Service1.HelloWorld() in C:\svnroot\Vordur\WebService1\Service1.asmx.cs:line 27 --- End of inner exception stack trace --- </code></pre> <p>...and the <code>InnerException</code> is <code>null</code>.</p> <p>What I would like to do is extract the <code>Message</code> property of the <code>InnerException</code> (the <code>HelloWorldException</code> text in my sample), can anyone help with that? If you can avoid it, please don't suggest parsing the <code>Message</code> property of the <code>SoapException</code>.</p>
<p>Unfortunately I don't think this is possible.</p> <p>The exception you are raising in your web service code is being encoded into a Soap Fault, which then being passed as a string back to your client code.</p> <p>What you are seeing in the SoapException message is simply the text from the Soap fault, which is not being converted back to an exception, but merely stored as text.</p> <p>If you want to return useful information in error conditions then I recommend returning a custom class from your web service which can have an "Error" property which contains your information.</p> <pre><code>[WebMethod] public ResponseClass HelloWorld() { ResponseClass c = new ResponseClass(); try { throw new Exception("Exception Text"); // The following would be returned on a success c.WasError = false; c.ReturnValue = "Hello World"; } catch(Exception e) { c.WasError = true; c.ErrorMessage = e.Message; return c; } } </code></pre>
<p>I ran into something similar a bit ago and <a href="http://theruntime.com/blogs/jacob/archive/2008/01/28/getting-at-the-details.aspx" rel="nofollow noreferrer">blogged about it</a>. I'm not certain if it is precisely applicable, but might be. The code is simple enough once you realize that you have to go through a MessageFault object. In my case, I knew that the detail contained a GUID I could use to re-query the SOAP service for details. The code looks like this:</p> <pre><code>catch (FaultException soapEx) { MessageFault mf = soapEx.CreateMessageFault(); if (mf.HasDetail) { XmlDictionaryReader reader = mf.GetReaderAtDetailContents(); Guid g = reader.ReadContentAsGuid(); } } </code></pre>
5,201
<p>Can you suggest a tool for testing accessibility and section 508/ADA compliance of a Website with MS Share Point and .Net 2.0 as the underlying platform?</p>
<p>In my experience, testing Sharepoint for accessibility is not worth it. Even if you've used the Accessibility Toolkit for Sharepoint (AKS) with Sharepoint 2007, the end result is far from accessible.</p> <p>The trouble is that accessibility was not, and still is not a big consideration for MS when they made Sharepoint. Everything depends on table layout, and screenreaders are given a nightmare to deal with.</p> <p>There are a few online tools - some will help validate your output, others pretend to test you for accessibility (<a href="http://www.tawdis.net" rel="nofollow noreferrer">TAW</a>). </p> <p>The problem is that many of the guidelines under WCAG are just too arbitrary, and will never be testable by an automated tool. This may change with WCAG 2.</p> <p>Anyway, wish you the best trying to make Sharepoint accessible.</p> <p><strong>EDIT:</strong> As a side not, I can highly recommend the following tools/resources for anyone interested in accessible development:</p> <ul> <li>Chris Pederick's <a href="http://chrispederick.com/work/web-developer/" rel="nofollow noreferrer">Web Accessibility Toolbar</a></li> <li><a href="http://www.accessit.nda.ie/" rel="nofollow noreferrer">NDA's Web Accessibility IT Guidelines</a></li> </ul>
<p>You can try FireEyes(http://www.deque.com/products/worldspace-fireeyes/download-worldspace-fireeyes) . You can run it in firebug and can set up your own set of rules through a dedicated server.</p> <p>FireEyes is an unprecedented, nextgen web accessibility tool that ensures both static and dynamic content within a web portfolio are compliant with standards such as Section 508, WCAG 1.0, and WCAG 2.0. You can use another tool, but it won’t be fully JavaScript aware or handle event-based page content, like FireEyes. Does your site: Use AJAX, JavaScript, Flash, PDFs, or dynamic content? Personalize multiple user roles? Display pages based on user-entered data? Use a content management system, with or without templates? Need to be accessible, secure, and private?</p>
9,654
<h2>The problem</h2> <p>When I print with my mElephant 3D printer from Makeblock, the prints come out with waved walls like in the picture below. I am using PLA filament from <a href="https://makeblock.lt" rel="noreferrer">https://makeblock.lt</a></p> <p><img src="https://makeblock.lt/up/so/3d-waves.jpg" alt="3d-waves"></p> <h2>What I tried</h2> <p>I tried changing temperatures 190-220, tried to change the flow rate. Also checked if the bolts are not lose. Everything seems good.</p> <h2>My printer</h2> <p><img src="https://makeblock.lt/up/so/melephant.jpg" alt="mElephant"></p>
<p>I had the same problem with ABS, but printing different test objects I found out that the distance between the wavy structures depends on the cross sectional area of the object. Printing the testcube in 70.1% (1/sqrt(2) times of the original size) takes half the time per layer and the distance between two grooves doubles. I was printing ABS with 0.1 mm layer height and the simple bang-bang heat bed controller. The temperature is clearly wandering for 4° with a period of aproximately 2.5 minutes, which corresponds to the groove distances. After changing to a PID controller for the heated bed the temperature stayed within 0.1°C and the problem was gone. Several hundredths of a millimeter thermal expansion of the heated bed can have substantial impact at 0.1 mm layer height!</p> <p>You can enable the PID controller for the heated bed in Marlin or Skynet firmware by enabling (removing the <code>//</code>) here:</p> <blockquote> <p><code>//#define PIDTEMPBED</code></p> </blockquote> <p>and disabling (putting <code>//</code> at the beginning of the line) here:</p> <blockquote> <p><code>#define BED_LIMIT_SWITCHING</code></p> </blockquote> <p>in Configuration.h. Calibration of the PID controller can then be done with the GCODE Command: </p> <blockquote> <p>M303 E-1 S90 C8</p> </blockquote> <p>for 90°C. I had to preheat the heated bed before, otherwise the calibration would run into a timeout. The command will return parameters for the PID algorithm. The values can then be applied by the </p> <blockquote> <p>M304 P579.01 I100.87 D586.0</p> </blockquote> <p>GCODE command (here for example values). Everything can then be saved to the EEPROM with </p> <blockquote> <p>M500</p> </blockquote> <p>Bang-Bang controller: <img src="https://i.stack.imgur.com/rQbWH.jpg" alt="Bang-Bang controller"></p> <p>PID controller: <img src="https://i.stack.imgur.com/Ka0AA.jpg" alt="PID controller"></p>
<p>Looks like something is catching on the z axis. A bent peice would likely cause much smaller deformations unless it was very obviously bent. Something could be loose, allowing the vertical play, perhaps the motor mounts.</p> <p>More likely I think is a level-difference between the z-axis worm gears, possibly caused by an obstruction, lack of lubrication, or possibly even the wrong lubrication. That's where I would look. Further, since it's a very consistent pattern, my guess would be your issue can be isolated to the tops and bottoms of the z axis worm gears. Even if it's not the issues I think, the issue most likely located at the top or bottom.</p>
514
<p>I've got a group of inter-related classes that are all overridden together to create a particular implementation. I'm wondering if it is a good idea to enclose the interrelated subclasses in a namespace.</p> <p>For example purposes, consider the following namespaces and classes:</p> <pre><code>namespace Protocol { public abstract class Message { } public abstract class Driver { } } namespace Protocol.Tcp { public class TcpMessage : Message { } public class TcpDriver : Driver { } } namespace Protocol.Ftp { public class FtpMessage : Message { } public class FtpDriver : Driver { } } </code></pre> <p>What is the best way to structure the namespaces? It seems unavoidable to expose the inheritance in the namespace since the base classes don't really belong in either the Protocol.Tcp namespace or the Protocol.Ftp namespace.</p>
<p>I think you are perhaps worrying too much!</p> <p>Does it make sense logically? Do you know where to find your code within the namespaces?</p> <p>I would much rather see a codebase like the above with a small number of classes, relevant to the name with a hierarchy, than one large namespace where everything is interrelated..</p> <p>Remember, namespacing is there for precisely this, to <strong>organise your codebase logically</strong></p> <p>What you have seems logical :)</p> <p>EDIT:</p> <p>As an example:</p> <pre><code>using System.Data; using System.Data.Sql; </code></pre> <p>;)</p>
<p>If this were me, I would define 2 namespaces:</p> <pre><code>Protocol </code></pre> <p>and</p> <pre><code>Protocol.Driver </code></pre> <p>Dividing the namespace like this separates your "library code" vs your "executable / test code." I also create my namespaces to match the directory structure; it will give logic to your programs structure and codefiles. (maybe you already do this...)</p>
3,915
<p>An example of an app that does this is <a href="http://www.humanized.com/enso/" rel="nofollow noreferrer">Enso</a>, it pops up when you press the caps lock.</p>
<p>You can act on global hotkeys by calling the winapi function <a href="https://www.pinvoke.net/default.aspx/user32/RegisterHotKey.html" rel="nofollow noreferrer">RegisterHotKey</a>. Also see <a href="https://www.codeproject.com/Articles/4345/NET-system-wide-hotkey-component" rel="nofollow noreferrer">https://www.codeproject.com/Articles/4345/NET-system-wide-hotkey-component</a> and <a href="https://www.codeproject.com/Articles/3055/System-Hotkey-Component" rel="nofollow noreferrer">https://www.codeproject.com/Articles/3055/System-Hotkey-Component</a> for example. You can not use all key combination as hotkeys. For those that don't work you might try a global keyboard hook (SetWindowsHookEx) </p>
<p>You need to install a hook in user32.dll. Lookup the Win32-API call SetWindowsHookEx. You can call it from C# via the stuff in System.Runtime.InteropServices.</p> <p><a href="https://www.codeproject.com/Articles/14485/Low-level-Windows-API-hooks-from-C-to-stop-unwante" rel="nofollow noreferrer">This article</a> discusses the topic nicely.</p> <p><strong>Edit</strong>: Lars Truijens answer looks like a nicer approach actually.</p>
8,581
<p>Consider these two function definitions:</p> <pre><code>void foo() { } void foo(void) { } </code></pre> <p>Is there any difference between these two? If not, why is the <code>void</code> argument there? Aesthetic reasons?</p>
<p>In <strong>C</strong>: </p> <ul> <li><code>void foo()</code> means "a function <code>foo</code> taking an unspecified number of arguments of unspecified type" </li> <li><code>void foo(void)</code> means "a function <code>foo</code> taking no arguments"</li> </ul> <p>In <strong>C++</strong>: </p> <ul> <li><code>void foo()</code> means "a function <code>foo</code> taking no arguments" </li> <li><code>void foo(void)</code> means "a function <code>foo</code> taking no arguments"</li> </ul> <p>By writing <code>foo(void)</code>, therefore, we achieve the same interpretation across both languages and make our headers multilingual (though we usually need to do some more things to the headers to make them truly cross-language; namely, wrap them in an <code>extern "C"</code> if we're compiling C++).</p>
<p>In C, you use a void in an empty function reference so that the compiler has a prototype, and that prototype has "no arguments". In C++, you don't have to tell the compiler that you have a prototype because you can't leave out the prototype.</p>
7,391
<p>So for my text parsing in C# <a href="https://stackoverflow.com/questions/13963/best-method-of-textfile-parsing-in-c">question</a>, I got directed at YAML. I'm hitting a wall with this library I was recommended, so this is a quickie.</p> <pre><code>heading: name: A name taco: Yes age: 32 heading: name: Another name taco: No age: 27 </code></pre> <p>And so on. Is that valid?</p>
<p>Partially. YAML supports the notion of multiple consecutive "documents". If this is what you are trying to do here, then yes, it is correct - you have two documents (or document fragments). To make it more explicit, you should separate them with three dashes, like this:</p> <pre><code>--- heading: name: A name taco: Yes age: 32 --- heading: name: Another name taco: No age: 27 </code></pre> <p>On the other hand if you wish to make them part of the same document (so that deserializing them would result in a list with two elements), you should write it like the following. Take extra care with the indentation level:</p> <pre><code>- heading: name: A name taco: Yes age: 32 - heading: name: Another name taco: No age: 27 </code></pre> <p>In general YAML is concise and human readable / editable, but not really human writable, so you should always use libraries to generate it. Also, take care that there exists some breaking changes between different versions of YAML, which can bite you if you are using libraries in different languages which conform to different versions of the standard.</p>
<p>Just to make an explicit comment about it: You have a duplicate mapping key issue. A YAML processor will resolve this as a !!map, which prohibits duplicate keys. Not all processors enforce this constraint, though, so you might get an incorrect result if you pass an incorrect YAML stream to a processor.</p>
3,652
<p>I am trying to create a two-piece snap-fit or joint using a 3D printer (Resin). After that, I plan to coat the joint with a conductive spray and create an electrical connection when the two pieces are joined together.</p> <p><strong>Has this been done before? Are certain types of joint mechanism recommended?</strong></p> <p>I will probably use carbon spray because it is cheaper than others. However, after the spray dries it can start to flake and thin, so I might need a couple of rounds of coating or something else. Any tips are appreciated.</p> <p>However, more importantly is the joint mechanism - this is what I had in mind:</p> <p><a href="https://i.stack.imgur.com/6t3Ef.png" rel="nofollow noreferrer" title="Plastic ball joint example"><img src="https://i.stack.imgur.com/6t3Ef.png" alt="Plastic ball joint example" title="Plastic ball joint example" /></a></p> <p>The signal would be a DC current only, in the µA range and the targeted resistance would be less than 20 Ω.</p> <p>Can this work? If not, what are my alternatives?</p>
<p><a href="https://www.instructables.com/Copper-Electroforming-on-3d-Printed-PLAABS-Objects/" rel="nofollow noreferrer">Electroforming</a> is the process of applying a conductive paint to a non-conductive surface. Once dry, the object is subjected to a process similar to electroplating, in that molecules of a conductive, more durable metal are bonded to the conductive paint, which is bonded to the 3D printed part.</p> <p>Typical metals would be nickel, which is quite conductive, as well as copper, known for conductivity. One could be somewhat absurd and perform the same process with silver and gold. The absurdity is related to the expense of those materials.</p> <p>The link covers using copper, but I believe that nickel would be more durable.</p> <p>Your joint selection is more related to the strength of the design and contact surface area and may be better suited for a more detailed separate question.</p> <p><a href="https://i.stack.imgur.com/ypefi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ypefi.png" alt="electroformed 3d printed calibration cube" /></a> As usual, image from linked site.</p>
<p>For your task you basically have several options:</p> <ol> <li><strong>Electroforming</strong> (see @fred_dot_u answer). Pros: high electrical conductivity due to actual metal layer; very low friction between polished metal layers. Cons: the process is quite dirty and requires additional materials and processing, plus some skill to produce results of appropriate quality.</li> <li><strong>Conductive filament</strong> (e.h. <a href="https://www.makerbot.com/3d-printers/materials/method-pla/" rel="nofollow noreferrer">PLA from Makerbot</a>). Pros: direct printing of any form. Cons: high price, probably tricky to print with, high current resistance.</li> <li><strong>Sliding electrical connections</strong> (e.g. as in brushed motors or magnetic USB charging cables). Pros: when properly executed will be very durable and probably could even reuse parts from existing markets (brushed motors use this trick for very long time). Cons: requires additional engineering and redesign of your existing parts.</li> <li><strong>Wireless connection</strong> (e.g. parts use radio/Bluetooth/WiFi for communicating). Pros: independent functionality of each 'limb'. Cons: independent power sources required for each limb; complex communication means.</li> <li><strong>Optical signalling</strong>. Pros: no electrical connections; depending on your use-case might fall in-between <em>wireless connection</em> (without the need of additional power source) and <em>sliding/magnetic connections</em>. Cons: requires skills and tools to work with fiberoptics, which is totally different story.</li> </ol> <p>Depending on your resources, requirements, skills and time you would chose one of above. You may also find some alternative solutions from engineering world.</p>
2,167
<h2>Problem</h2> <p>My CR-10 printer seems to be trying to print the model 4 or 5 layers too low. This means that for the first few layers, the printing nozzle is forced against the bed, preventing extrusion until the print reaches higher layers.</p> <h2>Outcome</h2> <p>This results in the bottom part of the print having the internal structure visible and the printing head deteriorating. I had to remove the old nozzle because it was clogged up with what I believe to be some residue that was picked up during preceding prints.</p> <p><a href="https://i.stack.imgur.com/mUfsT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mUfsT.jpg" alt="A print showing the structure inside the model because of missing layers"></a> <em>note: On this print, the top part is almost-well printed. It cannot be seen in pictures, but I say "almost" because the well-printed part is still much thinner than expected. This is the result of my purposeful mis-leveling the bed so that the part where the printer "homes" is higher than the lower part. I did this to see if there was any obvious bending of the printing bed. Doesn't look like there is.</em></p> <h2>Fix attempts</h2> <ul> <li>I have tried to re-level the bed multiple times, but it doesn't matter as the "too low" effect is independent from the location on the bed.</li> <li>I have tried using the printer's built-in Z-offset but to no avail. This might be due to the fact that I control the print through Ultimaker Cura 4, so I tried looking for the Z-offset property in Ultimaker Cura and even though internet says it exists, I failed to find it.</li> </ul> <h2>History</h2> <p>The printer used to work perfectly well and I do not remember having changed anything before the problem arose. I recently changed the nozzle and made sure to tighten it as high as possible but the Z-offset problem still persists.</p>
<p>Did you verify the Cura z-offset actually changed the corresponding G-Codes? </p> <p>I had the opposite problem on my RF1000. To fix the problem I added the following 2 lines to my start G-Codes:</p> <pre><code>M3001 ; Activate Z-Compensation M206 Z-0.3 ; Set z offset 0.3mm closer to the nozzle </code></pre> <p>The first line was default in some example prints and is (as far as I know) only used by Renkforce printers. The second line moves the nozzle closer to the bed. In your case you'd have to move it further away and would need a positive Z value.</p>
<p>Did you verify the Cura z-offset actually changed the corresponding G-Codes? </p> <p>I had the opposite problem on my RF1000. To fix the problem I added the following 2 lines to my start G-Codes:</p> <pre><code>M3001 ; Activate Z-Compensation M206 Z-0.3 ; Set z offset 0.3mm closer to the nozzle </code></pre> <p>The first line was default in some example prints and is (as far as I know) only used by Renkforce printers. The second line moves the nozzle closer to the bed. In your case you'd have to move it further away and would need a positive Z value.</p>
1,437
<p>How do I determine using TSQL what roles are granted execute permissions on a specific stored procedure? Is there a system stored procedure or a system view I can use?</p>
<p>In 7.0 or 2000, you can modify and use the following code:</p> <pre><code>SELECT convert(varchar(100), 'GRANT ' + CASE WHEN actadd &amp; 32 = 32 THEN 'EXECUTE' ELSE CASE WHEN actadd &amp; 1 = 1 THEN 'SELECT' + CASE WHEN actadd &amp; (8|2|16) &gt; 0 THEN ', ' ELSE '' END ELSE '' END + CASE WHEN actadd &amp; 8 = 8 THEN 'INSERT' + CASE WHEN actadd &amp; (2|16) &gt; 0 THEN ', ' ELSE '' END ELSE '' END + CASE WHEN actadd &amp; 2 = 2 THEN 'UPDATE' + CASE WHEN actadd &amp; (16) &gt; 0 THEN ', ' ELSE '' END ELSE '' END + CASE WHEN actadd &amp; 16 = 16 THEN 'DELETE' ELSE '' END END + ' ON [' + o.name + '] TO [' + u.name + ']') AS '--Permissions--' FROM syspermissions p INNER JOIN sysusers u ON u.uid = p.grantee INNER JOIN sysobjects o ON p.id = o.id WHERE o.type &lt;&gt; 'S' AND o.name NOT LIKE 'dt%' --AND o.name = '&lt;specific procedure/table&gt;' --AND u.name = '&lt;specific user&gt;' ORDER BY u.name, o.name </code></pre>
<p>You can try something like this. Note, I believe 3 is EXECUTE.</p> <pre><code>SELECT grantee_principal.name AS [Grantee], CASE grantee_principal.type WHEN 'R' THEN 3 WHEN 'A' THEN 4 ELSE 2 END - CASE 'database' WHEN 'database' THEN 0 ELSE 2 END AS [GranteeType] FROM sys.all_objects AS sp INNER JOIN sys.database_permissions AS prmssn ON prmssn.major_id=sp.object_id AND prmssn.minor_id=0 AND prmssn.class=1 INNER JOIN sys.database_principals AS grantee_principal ON grantee_principal.principal_id = prmssn.grantee_principal_id WHERE (sp.type = N'P' OR sp.type = N'RF' OR sp.type='PC')and(sp.name=N'myProcedure' and SCHEMA_N </code></pre> <p>I got that example by simply using SQL Profiler while looking at the permissions on a procedure. I hope that helps.</p>
9,283
<p>Is global memory initialized in C++? And if so, how?</p> <p>(Second) clarification:</p> <p>When a program starts up, what is in the memory space which will become global memory, prior to primitives being initialized? I'm trying to understand if it is zeroed out, or garbage for example.</p> <p>The situation is: can a singleton reference be set - via an <code>instance()</code> call, prior to its initialization:</p> <pre><code>MySingleton* MySingleton::_instance = NULL; </code></pre> <p>and get two singleton instances as a result?</p> <p>See my C++ quiz on on multiple instances of a singleton...</p>
<p>Yes global primitives are initialized to NULL.</p> <p>Example:</p> <pre><code>int x; int main(int argc, char**argv) { assert(x == 0); int y; //assert(y == 0); &lt;-- wrong can't assume this. } </code></pre> <p>You cannot make any assumptions about classes, structs, arrays, blocks of memory on the heap...</p> <p>It's safest just to always initialize everything. </p>
<p>Variables declared with static/global scope are always initialized under VC++ at least.</p> <p>Under some circumstances there can actually be a difference in behaviour between:</p> <pre><code>int x = 0; int main() { ... } </code></pre> <p>and</p> <pre><code>int x; int main() { ... } </code></pre> <p>If you are using shared data segments then VC++ at least uses the presence of an explicit initialization along with a <code>#pragma data_seg</code> to determine whether a particular variable should go in the shared data segment or the private data segment for a process.</p> <p>For added fun consider what happens if you have a static C++ object with constructor/destructor declared in a shared data segment. The constructor/destructor is called every time the exe/dll attaches to the data segment which is almost certainly not what you want.</p> <p>More details in this <a href="http://support.microsoft.com/kb/125677" rel="nofollow noreferrer">KB article</a></p>
8,561
<p>I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely. [And no, I didn't just randomize the items until they were sorted]. </p> <p>How might I write an even worse Big-O sort, without just adding extraneous junk that could be pulled out to reduce the time complexity?</p> <p><a href="http://en.wikipedia.org/wiki/Big_O_notation#Orders_of_common_functions" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Big_O_notation</a> has various time complexities sorted in growing order.</p> <p>Edit: I found the code, here is my O(n!) deterministic sort with amusing hack to generate list of all combinations of a list. I have a slightly longer version of get_all_combinations that returns an iterable of combinations, but unfortunately I couldn't make it a single statement. [Hopefully I haven't introduced bugs by fixing typos and removing underscores in the below code]</p> <pre><code>def mysort(somelist): for permutation in get_all_permutations(somelist): if is_sorted(permutation): return permutation def is_sorted(somelist): # note: this could be merged into return... something like return len(foo) &lt;= 1 or reduce(barf) if (len(somelist) &lt;= 1): return True return 1 &gt; reduce(lambda x,y: max(x,y),map(cmp, somelist[:-1], somelist[1:])) def get_all_permutations(lst): return [[itm] + cbo for idx, itm in enumerate(lst) for cbo in get_all_permutations(lst[:idx] + lst[idx+1:])] or [lst] </code></pre>
<p>There's a (proven!) worst sorting algorithm called <a href="http://c2.com/cgi/wiki?SlowSort" rel="noreferrer">slow sort</a> that uses the “multiply and surrender” paradigm and runs in exponential time.</p> <p>While your algorithm is slower, it doesn't progress steadily but instead performs random jumps. Additionally, slow sort's best case is still exponential while yours is constant.</p>
<p>One way that I can think of would be to calculated the post position of each element through a function that vary gradually moved the large elements to the end and the small ones to the beginning. If you used a trig based function, you could make the elements osculate through the list instead of going directly toward their final position. After you've processed each element in the set, then do a full traversal to determine if the array is sorted or not.</p> <p>I'm not positive that this will give you O(n!) but it should still be pretty slow.</p>
4,520
<p>This is an antique problem with VB6 DLL and COM objects but I still face it day to day. What tools or procedures can be used to see which DLL file or version another DLL is referencing?</p> <p>I am referring to compiled DLLs at runtime, not from within VB6 IDE.</p> <p>It's DLL hell.</p>
<p><a href="http://www.dependencywalker.com/" rel="noreferrer">Dependency Walker</a> shows you all the files that a DLL links to (or is trying to link to) and it's free.</p>
<p><a href="http://technet.microsoft.com/en-us/sysinternals/default.aspx" rel="nofollow noreferrer">ProcessExplorer</a> shows you all the DLLs that are currently loaded in a process at a particular moment. This gives you another angle on <a href="http://www.dependencywalker.com/" rel="nofollow noreferrer">Dependency Walker</a> which I believe does a static scan and can miss some DLLs that are dynamically loaded on demand. Raymond says <a href="http://blogs.msdn.com/oldnewthing/archive/2009/07/10/9827869.aspx" rel="nofollow noreferrer">that's unavoidable</a>.</p>
9,490
<p>... say for CentOS?</p>
<p>From what I understand a virtul IP can let you abstract the address from the physical interface(s) the traffic actually goes through. If your server has two network cards it can have a single virtual IP and have the traffic go through either network physical interface. If hardware failure occurs on one of the two network cards, the traffic can keep going with the second one as a backup. I assume that this is more relevant on servers where such parts can be hotswapped.</p>
<p>Check out this article on <a href="http://en.wikipedia.org/wiki/Virtual_IP_address" rel="nofollow noreferrer">Virtual IP address</a>. As indicated it usually floats between machines, and is sometimes used to fail-over a service from one device to another. Are you thinking of a virtual interface instead perhaps?</p> <p>/Allan</p>
9,494
<p>In C++ program, I am trying to #import TLB of .NET out-of-proc server.</p> <p>I get errors like:</p> <blockquote> <p>z:\server.tlh(111) : error C2146: syntax error : missing ';' before identifier 'GetType'</p> <p>z:\server.tlh(111) : error C2501: '_TypePtr' : missing storage-class or type specifiers</p> <p>z:\server.tli(74) : error C2143: syntax error : missing ';' before 'tag::id'</p> <p>z:\server.tli(74) : error C2433: '_TypePtr' : 'inline' not permitted on data declarations</p> <p>z:\server.tli(74) : error C2501: '_TypePtr' : missing storage-class or type specifiers</p> <p>z:\server.tli(74) : fatal error C1004: unexpected end of file found</p> </blockquote> <p>The TLH looks like:</p> <pre><code>_bstr_t GetToString(); VARIANT_BOOL Equals (const _variant_t &amp; obj); long GetHashCode(); _TypePtr GetType(); long Open(); </code></pre> <p>I am not really interested in the having the base object .NET object methods like GetType(), Equals(), etc. But GetType() seems to be causing problems.</p> <p>Some google research indicates I could <code>#import mscorlib.tlb</code> (or put it in path), but I can't get that to compile either.</p> <p>Any tips?</p>
<p>Added no_namespace and raw_interfaces_only to my #import:</p> <pre><code>#import "server.tlb" no_namespace named_guids </code></pre> <p>Also using TLBEXP.EXE instead of REGASM.EXE seems to help this issue.</p>
<p>Also, make sure your C# class doesn't have this attribute:</p> <p>[ClassInterface(ClassInterfaceType.AutoDual)] &lt;-- Seems to cause errors in C++ with _TypePtr</p>
3,382
<p>I'm interested in printing small machine parts (gears, linkages, structural components) so I'm looking for accuracy and mechanical strength over speed and volume.</p> <p>I'm also somewhat concerned about harmful emissions so would like a solution with some sort of filtration, whether it's built into the machine or something added. I'm thinking I will run the machine in an unventilated garage, which is quite warm and humid during the summer in Texas.</p> <p>My price range is \$1500-\$2000 USD. I've looked at several options but I didn't really come across any scenarios like I've described and would like some advice from the experts before committing.</p> <p>Anyone in a similar boat have any suggestions?</p>
<p>Your environmental conditions will preclude finding a machine suitable for your purposes in the budget specified.</p> <p>Humidity is a problem with many material types, especially nylon, but also with PLA and ABS, the more common filaments used in 3D printing.</p> <p>You can likely reject PLA for your mechanical needs, as it is brittle and weak compared to ABS. PLA releases virtually no gases of concern, while some find ABS fumes to be offensive and dangerous. </p> <p>The humidity issue is forefront in your search. You may have to construct within the garage a chamber in which you would operate a portable or window air conditioner unit, to keep the humidity in check. If you can assign a different budget to such a construction, that will leave your printer funding intact and better able to address your goal.</p> <p>Selective Laser Sintering using nylon powder, also susceptible to humidity, which is sintered by a laser, hence the name, making very detailed and strong parts. The process is also self-supporting, allowing for fairly intricate parts. Once the machine is calibrated, the part accuracy can be quite good. Unfortunately, SLS machines are also out of the budget range you've noted.</p> <p>You can use an external service to print the parts you design, at least at first, to get a better indication of how the various materials will work for you. Start with PLA, then move to ABS for a set of test parts, and even perhaps have some printed using SLS.</p> <p>If you find, for example, that ABS will be strong enough, you might find an affordable 3D printer which will generate parts on your budget and timeline. For printing ABS, the warmer temperatures are to your advantage, but the humidity has to be properly addressed in any home/shop/garage installation.</p>
<p>There is more than one question here. Which touches three topics: the choice of appropriate 3D printing technique, the choice of materials, and control of any hazardous, noxious, or annoying out-gassing. </p> <p>It is important to understand the limits of the 3D printing process you will choose. Each process has its own limits on repeatability and resolution of small features, such as gear teeth. A 10 pitch (teeth-per-inch) gear could print acceptably well with a low-cost printer, but the size of a 10-tooth gear would be 1/2" diameter. This could be a small part, or a huge part, depending on the use. To print an 1/8" diameter 10-tooth gear would require a 100 pitch gear likely would not, and would call for an optical process (laser sintering (SLS) or photo-polymerization (like the FormLabs Form 2)) or a dot-jetting process (such as the StrataSys Objet Connex machines). These are not in the budget you've suggested, but are available through service bureaus.</p> <p>Answers here <a href="https://3dprinting.stackexchange.com/questions/3392/how-can-i-print-gears-using-very-high-resolution-material-like-nylon">another community question</a> give some hints for using a plastic-extrusion machine, and information about SLS.</p> <p>Each process has different environmental requirements, and impacts, but first should be to understand the requirements of the parts, based on those choose a process and material, and then mitigate the environmental factors.</p>
674
<p>I want to write C/C++ programs that take input from a MIDI device. </p> <p>The MIDI device connects to my PC using a USB connector. </p> <p>I'm looking for a (C/C++ implemented) library that I can use to read the MIDI signals from the MIDI device through the USB port.</p> <p>I'm happy manipulating the MIDI data once I get it, I just don't want to have to implement the code for its capture.</p> <p>I'm planning on writing my code using the Bloodshed Dev-C++ IDE on Windows XP.</p>
<p><a href="http://portmedia.sourceforge.net/portmidi/" rel="noreferrer">PortMidi</a> is another open source cross-platform MIDI I/O library worth checking out. On the other hand, if you are working on a sysex type of app, then direct Win32 works easily enough.</p> <p>Just came across another open source cross-platform framework that includes MIDI support: <a href="http://www.rawmaterialsoftware.com/juce/" rel="noreferrer">Juce</a>.</p> <p>Also, I should note that there isn't anything special about a USB connected MIDI device. It will still be presented as a MIDI device in Windows and you will use standard MIDI APIs (mmsystem) to communicate with it.</p> <p>[July 2014] I just came across <a href="http://www.music.mcgill.ca/~gary/rtmidi/" rel="noreferrer">RtMidi</a> that looks to be a nice, compact, open source cross-platform C++ library.</p>
<p>Check out the open source project <a href="http://lmms.sourceforge.net/" rel="nofollow noreferrer">LMMS</a>. It's a music studio for Linux that includes the ability to use MIDI keyboards with software instruments. If you dig around in <a href="http://lmms.sourceforge.net/wiki/index.php?title=Accessing_SVN" rel="nofollow noreferrer">source files</a> with 'midi' in the name, you'll probably find what you're looking for.</p>
2,541
<p>I am trying to enable Full-text indexing in SQL Server 2005 Express. I am running this on my laptop with Vista Ultimate.</p> <p>I understand that the standard version of SQL Server Express does not have full-text indexing. I have already downloaded and installed "Microsoft SQL Server 2005 Express Edition with Advanced Services Service Pack 2" (<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5B5528B9-13E1-4DB9-A3FC-82116D598C3D&amp;displaylang=en" rel="noreferrer">download</a>).</p> <p>I have also ensured that both the "SQL Server (instance)" and "SQL Server FullText Search (instance)" services are running on the same account which is "Network Service".</p> <p>I have also selected the option to "Use full-text indexing" in the Database Properties > Files area.</p> <p>I can run the sql query "SELECT fulltextserviceproperty('IsFulltextInstalled');" and return 1.</p> <p>The problem I am having is that when I have my table open in design view and select "Manage FullText Index"; the full-text index window displays the message... </p> <blockquote> <p>"Creation of the full-text index is not available. Check that you have the correct permissions or that full-text catalogs are defined."</p> </blockquote> <p>Any ideas on what to check or where to go next?</p>
<pre><code>sp_fulltext_database 'enable' CREATE FULLTEXT CATALOG [myFullText] WITH ACCENT_SENSITIVITY = ON CREATE FULLTEXT INDEX ON [dbo].[tblName] KEY INDEX [PK_something] ON [myFullText] WITH CHANGE_TRACKING AUTO ALTER FULLTEXT INDEX ON [dbo].[otherTable] ADD ([Text]) ALTER FULLTEXT INDEX ON [dbo].[teyOtherTable] ENABLE </code></pre>
<p>Use sql server management studio.</p> <p>Login as admin to your windows account.</p> <p>Then select database and right click on database in sql server management studio and select Define Full Text Index and you are guided throughout the process by management studio.</p>
2,607
<p>I'm curious to hear the experiences of those who are currently running their SVN server on Windows. </p> <p>Jeff Atwood has a post on <a href="https://blog.codinghorror.com/setting-up-subversion-on-windows/" rel="nofollow noreferrer">how to setup SVN as a Windows service</a>. It's a great first step, but it doesn't touch on other topics, such as:</p> <ul> <li>What to use for a web-based repository browser? <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">WebSVN</a> <em>can</em> work on Windows, but it ain't pretty.</li> <li>How to manage the passwd file?</li> <li>Is it possible to integrate with Active Directory without running Apache?</li> <li>Strategies for backing up the repository.</li> <li>Useful global ignore patterns for Visual Studio development (suggestions <a href="http://blog.jasonhoekstra.com/2008/07/useful-net-subversion-global-ignore.html" rel="nofollow noreferrer">here</a>, <a href="http://www.thushanfernando.com/?p=12" rel="nofollow noreferrer">here</a>, and <a href="http://blog.donnfelker.com/2007/08/10/SubVersionTortoiseSVNGlobalIgnorePattern.aspx" rel="nofollow noreferrer">here</a> for example).</li> </ul> <p>Our company switched from SourceGear Vault to Subversion about one month ago. We've got the basics down pat, but would love to discover people's tips and tricks for running SVN in a MSFT world.</p>
<p>Use <a href="http://www.visualsvn.com/" rel="nofollow noreferrer">VisualSVN Server</a>. It integrates with Windows authentication and it handles all the apache setup. It's as painless as SVN can be on Windows.</p>
<p>I think you are seeing the difference betweeen the svn protocol and hosting the svn protocol on another.<br> Similar performance decreases when using svn+ssh compared to svn. </p> <p>The ease of setup, has made it a no brainer for my team, we just threw it on a vm and ran.</p>
4,414
<p>Should I be able to hand turn the stepper motor for the extruder of an Ender 3?</p> <p>Trying to figure out why the motor isn’t turning on a new to me, never used, but out-of-warranty Ender 3.</p> <p>Swapping controller cables I discovered the extruder port on the motherboard is dead, but even if I put it on the X axis and manually move the axis it makes the sound like it should move, but doesn’t actually move at all.</p> <p>Trying to figure out if it’s seized or something. Doing a resistance test with a multimeter shows a resistance of 4 for either of the two pairs of wires. I am not sure what else to test.</p> <p>I have a hard time believing I need a new control board and a new stepper motor, but maybe two things are broke.</p> <p>Thanks for the help!</p> <hr /> <h2>EDIT - Got the Extruder Working</h2> <p>After the comments here mentioned that &quot;Yes, it should be able to be moved by hand&quot;, curiosity got the better of me and I said, &quot;Well, if its broken, let's see why&quot;.</p> <p>I did the following:</p> <ol> <li>I tried to turn the stepper motor by hand again, just to confirm I wasn't crazy from the day before when I tried it. It wouldn't budge.</li> <li>I removed all four screws on the bottom of the stepper motor and attempted to pry things apart. While fiddling with it, I thought I saw the stepper motor turn.</li> <li>Sure enough, I now tried to spin the stepper motor and it moved relatively easily.</li> <li>I put the 4 screws back in place and validated I could still hand turn the motor. I could in fact do so.</li> <li>I hooked the stepper motor back up to the X axis controller and told it to move, and sure enough now it moves and works!</li> <li>Just as a sanity check, I then hooked it up to the extruder controller and it again wouldn't turn.</li> </ol> <p>I'm going to try what @towe recommended to make sure the controller board is in fact fried, but I <em>think</em> I might JUST have a fried board and not a fried motor.</p>
<p>Yes - you should be able to turn the extruder by hand when it is unplugged and therefore not powered.</p> <p>The V2 comes with a blue plastic knob for this purpose, it may be too small to turn the shaft by hand.</p> <p>When powered and &quot;steppers enabled&quot; the motors need a lot more force to overcome, but even that can be done by hand or a machine crash.</p> <p>If you can't turn the extruder at all, its probably toast. That you've tested other ports on the board is excellent problem solving.</p> <p>Whatever damaged the motor has likely damaged the board too, or vise versa.</p> <p>You likely need both parts replaced to get this printer working again. Could be expensive - you might want to compare cost of parts with cost of a new printer, remembering there may be other non-functional components still undiscovered.</p> <p>Plausibly, with a dead extruder, you could slap a laser on this unit and make it a dedicated burner. The creality laser module is around $50 USD.</p>
<p>Criggie's answer is basically correct, but I disagree with the conclusion that it:</p> <blockquote> <p>Could be expensive - you might want to compare cost of parts with cost of a new printer, remembering there may be other non-functional components still undiscovered.</p> </blockquote> <p>If you want to turn the Ender 3 into a decent printer, the controller board is one of the components you want to replace anyway, since it comes with either (old models) extremely loud and poorly performing A4988 stepper drivers or (newer models) TMC2208 stepper drivers hard-wired in a mode where they don't work well and malfunction if you enable Linear Advance (which is critical to getting decent prints on a bowden extruder system). Good boardsthat are exact fits for the housing and cable connectors, with TMC2209 steppers that lack the above problems, can be had for $35 or so.</p> <p>If the motor is dead, that's a pain but not expensive to replace. Equivalent motors are available for $15 or so all over the place, or you could make the upgrade to a light-weight geared direct drive extruder with pancake stepper instead of the large NEMA 17 (which negates pretty much all of the disadvantages of direct drive and gives you a much better printer than you started with).</p>
2,145
<p>I am currently using Linq to NHibernate (although that is not an issue with regards to this question) to execute queries against my database and I want to be able to test whether the current <code>IQueryable</code> result instance has been executed or not.</p> <p>The debugger knows that my <code>IQueryable</code> has not been <em>'invoked'</em> because it tells me that expanding the Results property will <em>'enumerate'</em> it. Is there a way for me to programmatically identify that as well.</p> <p>I hope that makes sense :)</p>
<p>How about writing an IQueryable wrapper like this:</p> <pre><code>class QueryableWrapper&lt;T&gt; : IQueryable&lt;T&gt; { private IQueryable&lt;T&gt; _InnerQueryable; private bool _HasExecuted; public QueryableWrapper(IQueryable&lt;T&gt; innerQueryable) { _InnerQueryable = innerQueryable; } public bool HasExecuted { get { return _HasExecuted; } } public IEnumerator&lt;T&gt; GetEnumerator() { _HasExecuted = true; return _InnerQueryable.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } public Type ElementType { get { return _InnerQueryable.ElementType; } } public System.Linq.Expressions.Expression Expression { get { return _InnerQueryable.Expression; } } public IQueryProvider Provider { get { return _InnerQueryable.Provider; } } } </code></pre> <p>Then you can use it like this:</p> <pre><code>var query = new QueryableWrapper&lt;string&gt;( from str in myDataSource select str); Debug.WriteLine("HasExecuted: " + query.HasExecuted.ToString()); foreach (string str in query) { Debug.WriteLine(str); } Debug.WriteLine("HasExecuted: " + query.HasExecuted.ToString()); </code></pre> <p>Output is:</p> <p>False<br/> String0<br/> String1<br/> ...<br/> True</p>
<p>I believe you can use <a href="https://learn.microsoft.com/en-us/dotnet/api/system.data.linq.datacontext.log" rel="nofollow noreferrer">DataContext.Log</a> to log everything that is executed.</p>
7,966
<p>Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database. But all the query work is done on the client side, I'd like to move some of this to PHP. </p> <p>What driver and/or connection string is needed to connect to Sql Svr and what is the syntax to use in PHP?</p> <hr> <p>Update: OK so I was definitely trying to avoid using anything to do with copying DLLs etc. I'll look into the <a href="http://www.codeplex.com/SQL2K5PHP" rel="nofollow noreferrer">SQL2K5PHP</a> driver (thanks Vincent). @jcarrascal for the sake of clarity, by "client side" I mean our application is an internal web app that runs as an <a href="http://msdn.microsoft.com/en-us/library/ms536471.aspx" rel="nofollow noreferrer">HTA</a>, with all queries done via javascript calls to an ASP which actually submits the DB request.</p>
<p>You have two options:</p> <p>1) <strong>php_mssql extension</strong> : If you'd like something that has the same API mysql and mysqli has, then use the php_mssql extension. But there is a catch, the bundled ntwdblib.dll file with PHP is not working. You have to find this file from a SQL Server 2000 installation or you can find it on the Internet. This API is supposedly not very reliable but I have been using it without problem for about one year.</p> <p><a href="http://ca.php.net/mssql" rel="noreferrer">http://ca.php.net/mssql</a></p> <p>2) <strong>Microsoft SQL Server 2005 PHP Driver</strong> : If you'd like something more modern but which does not have the same API and is missing some important functions (mssql_num_rows). The big plus is that it is supported by Microsoft and is likely to work with a future version.</p> <p><a href="http://msdn.microsoft.com/en-us/data/cc299381.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/data/cc299381.aspx</a></p>
<p>PHP provides an extension for accessing Microsoft SQL Server databases. To use the SQL Server extension, all that is required is to activate the extension in the PHP configuration file.</p> <p>Details on <a href="http://msdn.microsoft.com/en-us/library/bb264561.aspx" rel="nofollow noreferrer">the MSDN page</a></p>
4,021
<p>I'm parsing text from a file and storing it in a string. The problem is that some of the text in the original files contains <code>ASCII art</code> and whatnot that I would like to preserve. When I print out the string on the <code>HTML page</code>, even if it does have the same formatting and everything since it is in <code>HTML</code>, the spacing and line breaks are not preserved. What is the best way to print out the text in <code>HTML</code> exactly as it was in the original text file?<br> I would like to give an example, but unfortunately, I was not able to get it to display correctly in this markdown editor :P<br> Basically, I would like suggestions on how to display <code>ASCII art in HTML</code>.</p>
<p>use the &lt;pre&gt; tag (pre formatted), that will use a mono spaced font (for your art) and keep all the white space</p> <pre><code>&lt;pre&gt; text goes here and here and here and here Some out here ▄ ▄█▄ █▄ ▄ ▄█▀█▓ ▄▓▀▀█▀ ▀▀▀█▓▀▀ ▀▀ ▄█▀█▓▀▀▀▀▀▓▄▀██▀▀ ██ ██ ▀██▄▄ ▄█ ▀ ░▒ ░▒ ██ ██ ▄█▄ █▀ ██ █▓▄▀██ ▄ ▀█▌▓█ ▒▓ ▒▓ █▓▄▀██ ▓█ ▀▄ █▓ █▒ █▓ ██▄▓▀ ▀█▄▄█▄▓█ ▓█ █▒ █▓ ▒█ ▓█▄ ▒ ▀▒ ▀ ▀ █▀ ▀▒ ▀ █▀ ░ &lt;/pre&gt; </code></pre> <p>You might have to convert any &lt;'s to &amp;lt; 's</p>
<p>just echo the necessary special characters (\s, \n, or \r ) along with your string in your PHP code.</p> <pre><code>&lt;?php echo ("hello world \n") ?&gt; </code></pre>
5,727
<p>Is there a public/government web service that I can call to find out what the national holidays are for a given year? (For the US and/or any country in the world.)</p> <p>Edit: Does anybody have a set of formulas to calculate US holidays? (C# would be my language of choice if there is a choice.)</p>
<p>There's a web service at <a href="http://www.holidaywebservice.com" rel="noreferrer">http://www.holidaywebservice.com</a> which will provide dates of holidays for the USA, Republic of Ireland, England and Scotland. They also sell a DLL and source code.</p> <p>As for details of algorithms, you could do worse than check out the excellent <a href="https://rads.stackoverflow.com/amzn/click/com/0521702380" rel="noreferrer" rel="nofollow noreferrer">Calendrical Calculations</a> book (third edition), which is a really fascinating read for all matters calendrical, and includes sample LISP code for their calendar algorithms.</p>
<p>Some parsing may be required, and it's not 100% complete, but you can use <a href="http://en.wikipedia.org/wiki/List_of_holidays_by_country" rel="nofollow noreferrer">wikipedia</a>.</p>
8,469
<p>I am pondering about buying a Creality Ender-3, and I am honestly confused about some reviews. Some claim it is running 24 V, one did claim it was 12 V, most don't mention it. Since I know about some issues with the clamps, if I get myself an Ender-3, I want to replace the hotend with a proper one from day one. So knowing its voltage is needed to order the right parts.</p>
<p>Bearing in mind that the specifications on Amazon's page are sometimes not 100% (even though they are <em>in this case</em>), it is always best to check on the manufacturer's website.</p> <p>From Creality3D's own website, <a href="https://www.creality3dofficial.com/" rel="nofollow noreferrer">Creality3D.shop</a>, on the Creality3D Ender-3 product page, <a href="https://www.creality3dofficial.com/products/official-creality-ender-3-3d-printer" rel="nofollow noreferrer">Creality3D Ender-3 3D Printer Economic Ender DIY KITS</a>, the specifications are given as (emphasis is mine):</p> <blockquote> <p>##ender-3 Machine Parameter:</p> <ul> <li>Modeling Technology:FDM (Fused Deposition Modeling)</li> <li>Printing Size:220<em>220</em>250mm</li> <li>Machine Size:440<em>410</em>465mm</li> <li>Package weight:8kg Max</li> <li>Traveling Speed:180mm/s</li> <li>Filament:1.75mm PLA,TPU,ABS</li> <li><strong>Input:AC 100-265V 50-60Hz</strong></li> <li><em><strong>Output:DC 24V 15A 360W</strong></em></li> <li>Layer Thickness:0.1-0.4mm</li> <li>Nozzle diameter:0.4mm</li> <li>Precision:±0.1mm</li> <li>File Format:STL,OBJ,G-Code</li> <li>Working Mode:Online or SD offline</li> <li>Max Nozzle Temperature:255℃</li> <li>Max Hot bed Temperature:110℃</li> </ul> </blockquote>
<p>After checking the amazon listings of the ender-3, they contain more information than the gearbest listing: indeed it is a <strong>24V</strong> machine.</p> <blockquote> <p>Product description</p> <p>[...]</p> <p><strong>Output: DC 24 V 15 A 360 W</strong></p> <p>[...]</p> </blockquote>
956
<p>You find plenty of tutorials on menu bars in HTML, but for this specific (though IMHO generic) case, I haven't found any decent solution:</p> <pre><code># THE MENU ITEMS SHOULD BE JUSTIFIED JUST AS PLAIN TEXT WOULD BE # # ^ ^ # </code></pre> <ul> <li>There's an varying number of text-only menu items and the page layout is fluid.</li> <li>The first menu item should be left-aligned, the last menu item should be right-aligned.</li> <li>The remaining items should be spread optimally on the menu bar.</li> <li>The number is varying,so there's no chance to pre-calculate the optimal widths.</li> </ul> <p>Note that a TABLE won't work here as well:</p> <ul> <li>If you center all TDs, the first and the last item aren’t aligned correctly.</li> <li>If you left-align and right-align the first resp. the last items, the spacing will be sub-optimal.</li> </ul> <p>Isn’t it strange that there is no obvious way to implement this in a clean way by using HTML and CSS?</p>
<p>The simplest thing to do is to is to force the line to break by inserting an element at the end of the line that will occupy more than the left available space and then hiding it. I've accomplished this quite easily with a simple <code>span</code> element like so:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>#menu { text-align: justify; } #menu * { display: inline; } #menu li { display: inline-block; } #menu span { display: inline-block; position: relative; width: 100%; height: 0; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="menu"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Menu item 2&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;span&gt;&lt;/span&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>All the junk inside the <code>#menu span</code> selector is (as far as I've found) required to please most browsers. It should force the width of the <code>span</code> element to 100%, which should cause a line break since it is considered an inline element due to the <code>display: inline-block</code> rule. <code>inline-block</code> also makes the <code>span</code> possible to block-level style rules like <code>width</code> which causes the element to not fit in line with the menu and thus the menu to line-break.</p> <p>You of course need to adjust the width of the <code>span</code> to your use case and design, but I hope you get the general idea and can adapt it.</p>
<p>I know the original question specified HTML + CSS, but it didn't specifically say <em>no javascript</em> ;)</p> <p>Trying to keep the css and markup as clean as possible, and as semantically meaningful as possible to (using a UL for the menu) I came up with this suggestion. Probably not ideal, but it may be a good starting point:</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Kind-of-justified horizontal menu&lt;/title&gt; &lt;style type="text/css"&gt; ul { list-style: none; margin: 0; padding: 0; width: 100%; } ul li { display: block; float: left; text-align: center; } &lt;/style&gt; &lt;script type="text/javascript"&gt; setMenu = function() { var items = document.getElementById("nav").getElementsByTagName("li"); var newwidth = 100 / items.length; for(var i = 0; i &lt; items.length; i++) { items[i].style.width = newwidth + "%"; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;ul id="nav"&gt; &lt;li&gt;&lt;a href="#"&gt;first item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;item&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;last item&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;script type="text/javascript"&gt; setMenu(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
7,214
<p>I came across a printed <a href="http://www.eiffel.com/general/column/2008/02.html" rel="nofollow noreferrer">article by Bertrand Meyer</a> where he states that tests can be generated from specifications. My development team does nothing like this, but it sounds like a good technique to consider. How are you generating tests from specifications? How would you describe the success your having in discovering program faults via this method?</p>
<p>This might be a reference to <a href="http://rspec.info/" rel="nofollow noreferrer">RSpec</a>, which is a really clever way of developing tests as a series of requirements. I'm still getting used to it, but it's been very handy in both defining what I need to do and then ensuring I do it.</p>
<p>I would say it depends on your specs. I have yet to work anywhere where the specs were good enough to create full unit tests from specifications - the level of detail just wasn't there. My managers always told us that if we specified to that level they could just ship the specs off to India and get it coded on the cheap ;)</p>
4,877
<p>Just received my new Ender 3 v2. When using the Auto Home feature, the Y-axis motor drives the bed as far back as possible then the motor grinds for about 10-15 seconds. The Y-axis limit switch is not being depressed and the limit stop is about .5 inches away from the switch. The control unit locks at this point and must be power cycled to regain control. If I manually depress the limit switch then it appears to act normally.</p> <p>Clearly either the limit switch is way out of adjustment or the bed is not positioned properly. Can this be fixed or should I send it back as defective?</p>
<p>You could still get heat creep with a Bowden tube. It has different characteristics. Instead of jamming up in the direct drive, the filament can melt too far upwards into the heat break where it can refreeze and jam. The characteristic, if you can pull out the filament, is widened filament extending into the heat break.</p> <p>See <a href="https://3dprinting.stackexchange.com/questions/15732/air-printing-jamming-midway-through-raft-creation/15738#15738">Air printing/jamming midway through raft creation</a></p> <p>and</p> <p><a href="https://3dprinting.stackexchange.com/questions/15629/understanding-all-the-ways-to-avoid-heat-creep">What are ways to avoid heat creep?</a></p> <p>Adding fans to an enclosure improves the temperature control in the enclosure.</p>
<p><em>Answer created from octopus8's comments. If octopus8 wants to post their own answer, this wiki answer can be deleted.</em></p> <hr /> <p>185 °C is quite ok for several PLAs I have when printing slow.</p> <p>Honestly, I couldn't believe that the heat can go up the heatsink and Bowden tube to make extruder frame hot. So maybe your extruder's stepper motor is just getting hot heats up all metal elements (or a combination of both)? Did you replace only frame or also the stepper motor? Maybe the voltage is too high? I think voltages might be not calibrated well in factory, because my Z stepper in Ender 3 V2 also is getting really hot since I bought the printer (so far I added radiator, but I plan to regulate this voltage).</p> <blockquote> <p>The new tension arm is a bit tighter than I had it set on my old, but I can't imagine it's making enough resistance to overwork the motor without seeing other issues first.</p> </blockquote> <p>I agree with your judgement. Regarding the voltage: first I am not sure if my copy of v4.2.2 mainboard <a href="https://www.reddit.com/r/ender3/comments/ibqo8s/" rel="nofollow noreferrer">has TMC2208 stepper drivers, or some older HR4988</a>. I would need to determine that first, then find a valid formula for Vref. Actual voltage is tuned using potentiometer next to corner of stepper's small radiator. You can <a href="https://marlin.crc.id.au/faq/Ender%203%20V2/#vref" rel="nofollow noreferrer">see here an example of this process</a>. One problem is that Ender 3 V2 has the mainboard accessible from the bottom, so I would need something like garage pit to operate...</p> <p>As you can see, it is important to not touch the screwdriver's metal bar, and anyhow include your body's capacity to this circuit, or you may break things. There are also ceramic screwdrivers - but I already bought two and still my best option is sculpted from 3mm filament. Plastic or ceramic tool will need you to measure voltage separately from turning potentiometer. So the idea of connecting voltmeter to small metal screwdriver is very handy, but you have to be careful to touch only plastic parts.</p>
1,888
<p>Does anyone have any tips or gotcha moments to look out for when trying to migrate MySQL tables from the the default case-insenstive swedish or ascii charsets to utf-8? Some of the projects that I'm involved in are striving for better internationalization and the database is going to be a significant part of this change.</p> <p>Before we look to alter the database, we are going to convert each site to use UTF-8 character encoding (from least critical to most) to help ensure all input/output is using the same character set.</p> <p>Thanks for any help</p>
<p>Some hints:</p> <ul> <li>Your <code>CHAR</code> and <code>VARCHAR</code> columns will use up to 3 times more disk space. (You probably won't get much disk space grow for Swedish words.)</li> <li>Use <code>SET NAMES utf8</code> before reading or writing to the database. If you don't this then you will get partially garbled characters.</li> </ul>
<blockquote> <p>Your <code>CHAR</code> and <code>VARCHAR</code> columns will use up to 3 times more disk space.</p> </blockquote> <p>Only if they're stuffed full of latin-1 with ordinals > 128. Otherwise, the increased space use of UTF-8 is minimal.</p>
6,919
<p>I'm currently working on a web application which has a page which displays a single chart (a .png image). On another part of this page there are a set of links which, when clicked, the entire page reloads and looks exactly the same as before except for the chart in the middle of the page.</p> <p>What I want to do is when a link is clicked on a page just the chart on the page is changed. This will speed things up tremendously as the page is roughly 100kb large, and don't really want to reload the entire page just to display this. </p> <p>I've been doing this via JavaScript, which works so far, using the following code</p> <pre><code>document.getElementById('chart').src = '/charts/10.png'; </code></pre> <p>The problem is that when the user clicks on the link, it may take a couple of seconds before the chart changes. This makes the user think that their click hasn't done anything, or that the system is slow to respond.</p> <p>What I want to happen is display a spinner / throbber / status indicator, in place of where the image is while it is loading, so when the user clicks the link they know at least the system has taken their input and is doing something about it. </p> <p>I've tried a few suggestions, even using a psudo time out to show a spinner, and then flick back to the image. </p> <p>A good suggestion I've had is to use the following</p> <pre><code>&lt;img src="/charts/10.png" lowsrc="/spinner.gif"/&gt; </code></pre> <p>Which would be ideal, except the spinner is significantly smaller than the chart which is being displayed.</p> <p>Any other ideas?</p>
<p>I've used something like this to preload an image and then automatically call back to my javascript when the image is finished loading. You want to check complete before you setup the callback because the image may already be cached and it may not call your callback.</p> <pre><code>function PreloadImage(imgSrc, callback){ var objImagePreloader = new Image(); objImagePreloader.src = imgSrc; if(objImagePreloader.complete){ callback(); objImagePreloader.onload=function(){}; } else{ objImagePreloader.onload = function() { callback(); // clear onLoad, IE behaves irratically with animated gifs otherwise objImagePreloader.onload=function(){}; } } } </code></pre>
<p>@iAn's solution looks good to me. The only thing I'd change is instead of using setTimeout, I'd try and hook into the images 'Load' event. This way, if the image takes longer than 3 seconds to download, you'll still get the spinner.</p> <p>On the other hand, if it takes less time to download, you'll get the spinner for less than 3 seconds.</p>
7,441
<p>I heard Joel and Jeff talking about <a href="http://www.mikeindustries.com/blog/sifr/" rel="nofollow noreferrer">sIFR</a> in one of the <a href="https://stackoverflow.fogbugz.com/default.asp?W12621" rel="nofollow noreferrer">early podcasts</a>. I've been using it on <a href="http://www.american-data.com" rel="nofollow noreferrer">www.american-data.com</a> and <a href="http://www.chartright.us" rel="nofollow noreferrer">www.chartright.us</a> with some fairly mixed results. </p> <p>Yesterday I was informed that the first line of text on my website appeared upside down in Internet Explorer 6 without flash player. I'm pretty sure that assessment was wrong, owing to no flash player = no sIFR. But I'm getting some odd behavior on my pages, at least in IE 6, 7 and 8. I only really wanted to use sIFR because my fonts looked crummy on my computer in Firefox. </p> <p>My question is: if you use sIFR, when do you use sIFR? In which cases do you disable sIFR? When is it better to just use the browser font?</p>
<p>You use sIFR moderately, say for headlines. Try not to use it for links, because links in Flash don't work as well as normal HTML links. It also makes little sense to use sIFR only for text that never changes, an image would work a lot better.</p> <p>I haven't heard about the upside-down problem in a few years now, but in any case, that's an issue with IE 6 and (an old?) Flash player. In any case, it always makes sense to test thoroughly.</p> <p>Also, did you look into <a href="http://novemberborn.net/sifr3" rel="nofollow noreferrer">sIFR 3</a> lately? It's much improved over v2.</p>
<p>I had plenty of headaches after implementing <a href="http://www.mikeindustries.com/blog/sifr/" rel="nofollow noreferrer">sIFR</a> on my last website project. Most of the problems were to do with browser inconsistencies like you are describing. Text would appear in odd places, not wrap properly or just not display the way I wanted it to. I found that, as per usual, firefox was displaying nicely while I had to implement several different css hacks in order to get the same code to display properly in IE7 and IE6.</p> <p>I say stick to standard browser fonts if you can, but if the project / client requires you to use it then make sure you test it thoroughly in all browsers and with various flash blockers etc.</p>
3,853
<p>I have a class in system-C with some data members as such: </p> <pre><code>long double x[8]; </code></pre> <p>I'm initializing it in the construction like this:</p> <pre><code>for (i = 0; i &lt; 8; ++i) { x[i] = 0; } </code></pre> <p>But the first time I use it in my code I have garbage there.</p> <p>Because of the way the system is built I can't connect a debugger easily. Are there any methods to set a data breakpoint in the code so that it tells me where in the code the variables were actually changed, but without hooking up a debugger?</p> <p>Edit: @Prakash: Actually, this is a typo in the <em>question</em>, but not in my code... Thanks!</p>
<p>The trick is to combine a <code>UNION</code> with a literal string to determine the type of 'object' returned. In most (?) cases, UNION ALL will be more efficient, and should be used unless duplicates are required in the sub-queries. The following pattern should suffice:</p> <pre><code> SELECT "group" type, name FROM groups WHERE name LIKE "%$text%" UNION ALL SELECT "user" type, name FROM users WHERE name LIKE "%$text%" </code></pre> <p><strong>NOTE</strong>: I've added the answer myself, because I came across this problem yesterday, couldn't find a good solution, and used this method. If someone has a better approach, please feel free to add it.</p>
<p>If you use "UNION ALL" then the db doesn't try to remove duplicates - you won't have duplicates between the two queries anyway (since the first column is different), so UNION ALL will be faster.<br> (I assume that you don't have duplicates inside each query that you want to remove)</p>
8,024
<p>I'm new to 3D printing and I was wondering about the risks of leaving my printer to print overnight? I'm aware that if something goes wrong I'll wake up to spaghetti for breakfast but what are the other things like having the nozzle and bed heated that long? And, when it's done it just sits there on so what could that do to the screen? What if the printer runs into some physical problem and damages itself and/or the print? I'm not looking for answers to these questions specifically just feedback on what I should do when printing overnight.</p>
<p>Presuming that you're talking about an 8 hour period, your printer should be designed to run for 8 hours continuous anyway, so nothing will happen regarding the bed or screen that wouldn't happen with a normal print.</p> <p>If the first few layers stick to the bed, it's likely that you're print will at least be partially completed. So even over night it won't be a full 8 hours of printing while failed. Maybe half that period.</p> <p>If the problem is bed adhesion, or anything that doesn't effect the filament being supplied to the nozzle, then your only problem will be wasted filament and disposing of the spaghetti. No harm will come to your printer.</p> <p>If the problem is a break in the filament or filament runout, or a blocked nozzle then you could have damage to the head of the nozzle from printing dry. If you're printing with PLA this isn't really something that you need to worry about too much as you can run a printer dry for several hours without any problems.</p> <p>If you're printing with ABS or something that needs a hotter head then you could cause damage to it if it's allowed to run dry for an entire night. But again this isn't really something that you need to worry about unless it's running dry for 4 or 6 hours.</p> <p>Simply checking in on it once in the night should be enough to prevent any problems.</p>
<p>There are software solutions like &quot;Spaghetti Detective&quot; (recently renamed to &quot;Obico&quot;) which can watch your print via a camera, and potentially stop the job if it looks bad.</p> <p>Most of the time my print failures come early, in the form of poor bed adhesion - watch the job start for a while before leaving it.</p> <p>I can also remote-check my cameras and stop the job if required, but that requires me to look.</p> <p>The second most common failure is lifting from the base at any time in the print, so you have to keep an eye on it.</p> <p>Filament feed issues are probably third on the common list of causes for problems, including running out.</p> <p>I also have occasional issues where my Pi running Octoprint just looses connection to the printer, and it freezes in place with the bed/nozzle heaters on. This is just a waste of power, so a future plan is to wire the printer through a relay allowing me to power it on/off from octoprint's web page.</p> <p>My longest print was ~30 hours - you have to learn to not touch it unless there's a good reason.</p> <p>Finally, try and maintain the environmental conditions to be fairly constant. I have an enclosure even when printing plain PLA, becuase my printer's location is in a garage, and opening the main door allows the air temp to drop quickly. This would upset a running print until I surrounded it.</p> <p>You can also make sure there's a smoke or heat detector in the room where the printer is, for added peace of mind.</p>
2,156
<p>I find myself doing this sort of thing all the time. I've been considering writing a macro/function to make this sort of thing easier, but it occurs to me that I'm probably reinventing the wheel.</p> <p>Is there an existing function that will let me accomplish this same sort of thing more succinctly?</p> <pre><code>(defun remove-low-words (word-list) "Return a list with words of insufficient score removed." (let ((result nil)) (dolist (word word-list) (when (good-enough-score-p word) (push word result))) result)) </code></pre>
<p>There are several built-in ways of doing this. One way would be:</p> <pre><code>(remove-if-not 'good-enough-score-p word-list) </code></pre> <p>And another:</p> <pre><code>(loop for word in word-list when (good-enough-score-p word) collect word) </code></pre> <p>And yet another:</p> <pre><code>(mapcan (lambda (word) (when (good-enough-score-p word) (list word))) word-list) </code></pre> <p>Etc... There's also <a href="http://series.sourceforge.net/" rel="noreferrer">SERIES</a> and <a href="http://common-lisp.net/project/iterate/" rel="noreferrer">Iterate</a>. The Iterate version is identical to the LOOP version, but the SERIES version is interesting:</p> <pre><code>(collect (choose-if 'good-enough-score-p (scan word-list)))) </code></pre> <p>So, yes, you're very likely to reinvent <em>some</em> wheel. :-)</p>
<p>There are a couple ways you can do this. First, and probably most easily, you can do it recursively.</p> <pre><code>(defun remove-low-words (word-list) (if (good-enough-score-p (car word-list)) (list word (remove-low-words (cdr word-list))) (remove-low-words (cdr word-list)))) </code></pre> <p>You could also do it with <code>mapcar</code> and <code>reduce</code>, where the former can construct you a list with failing elements replaced by <code>nil</code> and the latter can be used to filter out the <code>nil</code>.</p> <p>Either would be a good candidate for a "filter" macro or function that takes a list and returns the list filtered by some predicate.</p>
5,945
<p>I have printed a MPCNC machine. It has a print area of about 30" x 30" and up to 11" tall. (yes, those numbers are correct).</p> <p>I found a perfect piece of glass at a garage sale for $5.00 to use as my print bed. </p> <p>My problem now is how to heat the glass? I was wondering if there is some sort of tape that would perhaps mimic what is on the rear window of a car, but I couldn't find it anywhere.</p> <p>Any ideas or links to something that can get me some progress on my search would be greatly appreciated.</p>
<p>Your best option may be to seek out a silicone rubber heating mat, using those terms for your web search. A quick search on my part shows many resources, some of which are known to the 3d printing manufacturing world, while others are equally suited for that purpose.</p> <p>Don't bond the heater to the glass. You'll need to replace it when it breaks. Consider to use borosilicate glass for better heat tolerance and smaller chance of breakage. A quick search for such a large size pane comes up empty, invalidating that suggestion.</p> <p>I've read of some people using water bed heaters for large area coverage, but they may heat the area unevenly.</p> <p>It could be to your advantage to use multiple heater panels with temperature controls for each one. This would provide more uniform heating although more complex temperature management.</p> <p>I would post links, but there are so many from which to choose.</p>
<p>Maybe you can stick a <a href="https://en.wikipedia.org/wiki/Nichrome" rel="nofollow" title="nichrome">nichrome</a> wire under the glass using a heat resistant tape. You'll have to make the appropriate calcs (or just trial/error) to achieve the desired temperature at a consistent timing.</p>
370
<p>I am trying to run the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;displaylang=en" rel="nofollow noreferrer">VS 2008 SP1 installer</a>, but it says that I need 6,366MB of available space, and my C drive currently only has 2,452MB available. Is there any good way to install that doesn't require so much free space?</p> <p>I have also tried <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=27673c47-b3b5-4c67-bd99-84e525b5ce61&amp;displaylang=en" rel="nofollow noreferrer">downloading the ISO image</a> and mounting that, but it still requires 5,864MB free. Am I missing any obvious command line switches?</p>
<p>Burn it to a DVD and install it from there. Also remove any development software that you don't need from Visual Studio, such as C++, VB.NET, Crystal Reports, etc.</p>
<p>You can have Visual Studio install components onto a separate hard drive from your primary but be warned, you still end up with a lot of data on your primary drive.</p> <p>I tried to install VS 2008 on a machine with 2gb of hard drive space on the primary and a lot of the secondary, you still end up with about 1gb on the primary though.</p> <p>Try methods to clean up your hard drive, run the Disk Cleaner tool (I found 10gb of MS error emails the other day!). Also, try removing features you wont need, MSDN is a huge install but if you're always online google is just a few clicks away, if you aren't doing VB, don't install VB (or C#, or J#, etc).</p> <p>Scott Hanselman has a recent post on freeing up disk space in Vista: <a href="http://www.hanselman.com/blog/GuideToFreeingUpDiskSpaceUnderWindowsVista.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/GuideToFreeingUpDiskSpaceUnderWindowsVista.aspx</a></p>
3,704
<p>I'm looking for ideas on how to draw a skinnable "button" in a game application. If I use a fixed sprite non-vector image for the button background, then I can't size the button easily. If I write code to draw a resizable button (like Windows buttons are drawn), then the programmer has to get involved -- and it makes skinning difficult. Another option is to break the button into 9 smaller images (3x3) and stretch them all -- kindof like rounded corners are done in HTML. </p> <p>Is there another "easier" way? What's the best approach?</p>
<p>If you really want to accomplish this, the way to do it is with texture coordinates. Much like you would make a stretchable button/panel design in HTML with a table, you simply define the UV coordinates for the corners, the top stretchable area, the bottom stretchable area, the side stretchable areas, and then the middle.</p> <p>For an example of this being implemented in an XNA engine (though it's a closed source engine), see this: <a href="http://www.flatredball.com/frb/docs/index.php?title=SpriteFrame_Tutorial" rel="nofollow noreferrer">http://www.flatredball.com/frb/docs/index.php?title=SpriteFrame_Tutorial</a></p>
<p>Yes. I am working on an Editor. It's a XAML-like language (or OpenLaszlo-like, if you prefer) for XNA. So the buttons can be resized by the editor. The buttons might also be resized by a style sheet. </p> <p>I guess you're right that it's likely that the buttons will all be the same size in a real design. But even in a window's app, you sometimes need to make a button wider to accomodate text.</p>
2,867
<p>I've got a rails application where users have to log in. Therefore in order for the application to be usable, there must be one initial user in the system for the first person to log in with (they can then create subsequent users). Up to now I've used a migration to add a special user to the database.</p> <p>After asking <a href="https://stackoverflow.com/questions/62038/rails-model-validators-break-earlier-migrations">this question</a>, it seems that I should be using db:schema:load, rather than running the migrations, to set up fresh databases on new development machines. Unfortunately, this doesn't seem to include the migrations which insert data, only those which set up tables, keys etc.</p> <p>My question is, what's the best way to handle this situation:</p> <ol> <li>Is there a way to get d:s:l to include data-insertion migrations?</li> <li>Should I not be using migrations at all to insert data this way?</li> <li>Should I not be pre-populating the database with data at all? Should I update the application code so that it handles the case where there are no users gracefully, and lets an initial user account be created live from within the application?</li> <li>Any other options? :)</li> </ol>
<p>Try a rake task. For example:</p> <ol> <li>Create the file <strong>/lib/tasks/bootstrap.rake</strong></li> <li>In the file, add a task to create your default user:</li> </ol> <pre><code> namespace :bootstrap do desc "Add the default user" task :default_user => :environment do User.create( :name => 'default', :password => 'password' ) end desc "Create the default comment" task :default_comment => :environment do Comment.create( :title => 'Title', :body => 'First post!' ) end desc "Run all bootstrapping tasks" task :all => [:default_user, :default_comment] end </code></pre> <ol start="3"> <li>Then, when you're setting up your app for the first time, you can do rake db:migrate OR rake db:schema:load, and then do rake bootstrap:all.</li> </ol>
<p>Some of the answers are outdated. Since Rails 2.3.4, there is a simple feature called Seed available in <code>db/seed.rb</code> :</p> <pre><code>#db/seed.rb User.create( :name =&gt; 'default', :password =&gt; 'password' ) Comment.create( :title =&gt; 'Title', :body =&gt; 'First post!' ) </code></pre> <p>It provides a new rake task that you can use after your migrations to load data :</p> <pre><code>rake db:seed </code></pre> <p>Seed.rb is a classic Ruby file, feel free to use any classic datastructure (array, hashes, etc.) and iterators to add your data :</p> <pre><code>["bryan", "bill", "tom"].each do |name| User.create(:name =&gt; name, :password =&gt; "password") end </code></pre> <p>If you want to add data with UTF-8 characters (very common in French, Spanish, German, etc.), don't forget to add at the beginning of the file :</p> <pre><code># ruby encoding: utf-8 </code></pre> <p>This Railscast is a good introduction : <a href="http://railscasts.com/episodes/179-seed-data" rel="nofollow">http://railscasts.com/episodes/179-seed-data</a></p>
8,756
<p>I have a medium sized application that runs as a .net web-service which I do not control, and I want to create a loose pythonic API above it to enable easy scripting.</p> <p>I wanted to know what is the best/most practical solution for using web-services in python.</p> <p>Edit: I need to consume a complex soap WS and I have no control over it.</p>
<p>If I have to expose APIs, I prefer doing it as JSON. Python has excellent support for JSON objects (JSON Objects are infact python dictionaries)</p>
<p>Most of the packages on python that a SOAP service through them can be called works on python 2.x, but had problems on Python 3.x</p> <p>The best fit for python 3.x that I've found is <a href="https://pypi.python.org/pypi/suds-jurko/0.6" rel="nofollow">suds-jurko</a></p>
4,863
<p>I believe this question is asked on every private Beta... what should be the name of our chatroom?</p>
<p><strong>The Hotbed.</strong></p> <p>Colloquially, "hotbed" generally refers to a center of activity. Here, it will have a double meaning (referencing the hot bed of a 3D printer.</p>
<h1>Filibusters!</h1> <p>I've heard that from somewhere. It's a play on the word "filament"</p> <p><sup>Oh, Just as a heads up, I can think of the weirdest names...</sup></p>
12
<p>I have an Ender 3 Pro with upgraded Bowden capricorn tube. The tube will move approximately 1-2&nbsp;mm during normal operation, though it will not come out of the coupler at all. I have read that the movement if unchanging (constant movement of 1-2&nbsp;mm) can be compensated for with settings adjustment to avoid retraction issues such that it will extrude or retract "that much less"... I do not understand how this is possible...</p> <p>Im confused by comments that a slipping Bowden tube on the extruder side <em>only</em>, say by up to 2&nbsp;mm, is "lost retraction"... I have this problem too with the Bowden tube <em>only</em> at the extruder end, not the hotend, and wonder if it is really an issue at all. Here's why...</p> <p>The filament is in direct contact with the gear and wheel of the extruder. <em>If</em> the Bowden tube is <em>only</em> moving in/out of the extruder end of the coupler, there are no "gaps" being created to cause leakage of the filament, etc on the hot end...As the extruder is either pushing or retracting, the filament <em>inside</em> the tube is still moving as much as intended regardless of the amount of play of the Bowden tube... no? therefore, retracting will not be affected at all, nor would the extruding process. Am I wrong and if so, can someone explain to me how this would be?</p> <p>Note, I can see that this movement may cause under-extrusion on the feeding side process, as the machine is expecting say, 0.5&nbsp;mm extrusion, but then has to compensate (unknowingly) for the slipping <em>out</em> tube during the "push", so not enough gets "out", but should not affect the retraction amount as the filament is still being <em>pulled</em> directly from the gears/roller. </p> <p>Am I wrong and if so, can someone explain to me how this would affect the <em>retraction</em> along with the under-extrusion?</p>
<p>The slipping does result in lost retraction distance. It does not result in underextrusion, lost material (except possibly via having insufficient retraction after the reduction), or anything like that.</p> <p>If your retraction is set to 6 mm, but the bowden pulls 2 mm into the coupler when you retract, those first 2 mm of filament motion do not pull the filament out of the hotend at all. The position of the filament relative to the tube (and thus relative to the nozzle) remains constant. After the tube can be pulled back no further into the coupler, the remaining retraction pulls the filament back through the bowden tube, for 4 mm of retraction at the hotend/nozzle.</p> <p>When unretracting, the reverse happens. The first 2 mm of extruder motion push the bowden tube out of the coupler, and don't move the filament relative to the tube (or the hotend). After that the next 4 mm push the filament through the tube and back to the nozzle orifice.</p> <p>The result is the filament ending up back exactly where it started, but having backed out only 4 mm from the nozzle, not the requested 6 mm.</p> <p>These numbers are just examples but probably about right. If you put the plastic clip on the pneumatic coupler, the slipping should stop, but you can also just increase retraction if the amount after the loss to slipping is not sufficient.</p>
<p>This is happening to my E3 pro. When the Bowden tube slips back filament fills up the gap causing a heat creep issue. This of course causes clogged nozzle. If retracting I have had the swollen filament lodge in the tube to the point I had to remove tube and heat high enough with heat gun to soften filament for a reverse pull as there was nothing left on the hotend side to pull.</p> <p>My solution after a week of frustration was to replace the coupling.</p>
1,494
<p>I had the idea of a search engine that would index web items like other search engines do now but would only store the file's title, url and a hash of the contents.</p> <p>This way it would be easy to find items on the web if you already had them and didn't know where they came from or wanted to know all the places that something appeared.</p> <p>More useful for non textual items like images, executables and archives.</p> <p>I was wondering if there is already something similar?</p>
<p>Check out <a href="http://en.wikipedia.org/wiki/Locality_sensitive_hashing" rel="nofollow noreferrer">the wikipedia page on locality sensitive hashing</a>. There's also <a href="http://www.mit.edu/~andoni/LSH/" rel="nofollow noreferrer">a good page hosted by a research on MIT</a>.</p> <p>In general, there are several flavors available: hashes for strings (such as <a href="http://scholar.google.com/scholar?hl=en&amp;lr=&amp;cluster=2077823906332929131" rel="nofollow noreferrer">simhash</a>), sets or 0/1 features (such as <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.43.9451" rel="nofollow noreferrer">min-wise hashes</a>), and for real vectors.</p> <p>The main trick for numerical hashes is basically <a href="http://en.wikipedia.org/wiki/Dimension_reduction" rel="nofollow noreferrer">dimension reduction</a>, so far. For strings, the idea is to come up with a representation that's robust in the face of minor edits.</p> <p>I'm also doing a little research in this field, although I guess stackoverflow might not be the right place for nascent work.</p>
<p>It's not a bad idea. Sometimes I find myself stumbled upon some file trying to figure out where it comes from :) But how are you going to track item's sources? Content can be obtained by various means - web browser, download manager, simply by copying from network share.</p>
7,373
<p>What's the best way to delete all rows from a table in sql but to keep n number of rows on the top? </p>
<pre><code>DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table) </code></pre> <p><strong>Edit:</strong> </p> <p>Chris brings up a good performance hit since the TOP 10 query would be run for each row. If this is a one time thing, then it may not be as big of a deal, but if it is a common thing, then I did look closer at it.</p>
<p>I would solve it using the technique below. The example expect an <em>article</em> table with an <em>id</em> on each row.</p> <pre><code>Delete article where id not in (select top 1000 id from article) </code></pre> <p>Edit: Too slow to answer my own question ...</p>
6,851
<p>In VS .NET, when you are selecting a folder for a project, a dialog that looks like an OpenFileDialog or SaveFileDialog is displayed, but is set up to accept only folders. Ever since I've seen this I've wanted to know how it's done. I am aware of the FolderBrowserDialog, but I've never really liked that dialog. It starts too small and doesn't let me take advantage of being able to type a path.</p> <p>I'm almost certain by now there's not a way to do this from .NET, but I'm just as curious how you do it from unmanaged code as well. Short of completely reimplementing the dialog from scratch, how do you modify the dialog to have this behavior?</p> <p>I'd also like to restate that I am aware of the FolderBrowserDialog but sometimes I don't like to use it, in addition to being genuinely curious how to configure a dialog in this manner. Telling me to just use the FolderBrowserDialog helps me maintain a consistent UI experience but doesn't satisfy my curiosity so it won't count as an answer.</p> <p>It's not a Vista-specific thing either; I've been seeing this dialog since VS .NET 2003, so it is doable in Win2k and WinXP. This is less of a "I want to know the proper way to do this" question and more of a "I have been curious about this since I first wanted to do it in VS 2003" question. I understand that Vista's file dialog has an option to do this, but it's been working in XP so I know they did <em>something</em> to get it to work. Vista-specific answers are not answers, because Vista doesn't exist in the question context.</p> <p><strong>Update: I'm accepting Scott Wisniewski's answer because it comes with a working sample, but I think Serge deserves credit for pointing to the dialog customization (which is admittedly nasty from .NET but it <em>does</em> work) and Mark Ransom for figuring out that MS probably rolled a custom dialog for this task.</strong></p>
<p>I have a dialog that I wrote called an OpenFileOrFolder dialog that allows you to open either a folder or a file.</p> <p>If you set its AcceptFiles value to false, then it operates in only accept folder mode.</p> <p><a href="https://github.com/scottwis/OpenFileOrFolderDialog" rel="noreferrer">You can download the source from GitHub here</a></p>
<p>I know the question was on configuration of <code>OpenFileDialog</code> but seeing that Google brought me here i may as well point out that if you are ONLY looking for folders you should be using a <code>FolderBrowserDialog</code> Instead as answered by another SO question below</p> <p><a href="https://stackoverflow.com/questions/11465237/how-to-specify-path-using-open-file-dialog-in-vb-net">How to specify path using open file dialog in vb.net?</a></p>
5,093
<p>I've been using OpenGL for years, but after trying to use D3D for the first time, I wasted a significant amount of time trying figure out how to make my scene lights stay fixed in the world rather than fixed on my objects.</p> <p>In OpenGL light positions get transformed just like everything else with the MODELVIEW matrix, so to get lights fixed in space, you set up your MODELVIEW the way you want for the lights, and call glLightPosition then set it up for your geometry and make geometry calls. In D3D that doesn't help.</p> <p>(Comment -- I eventually figured out the answer to this one, but I couldn't find anything helpful on the web or in the MSDN. It would have saved me a few hours of head scratching if I could have found this answer then.)</p>
<p>The answer I discovered eventually was that while OpenGL only has its one amalgamated <code>MODELVIEW</code> matrix, in D3D the "world" and "view" transforms are kept separate, and placing lights seems to be the major reason for this. So the answer is you use <code>D3DTS_VIEW</code> to set up matrices that should apply to your lights, and <code>D3DTS_WORLD</code> to set up matrices that apply to the placement of your geometry in the world.</p> <p>So actually the D3D system kinda makes more sense than the OpenGL way. It allows you to specify your light positions whenever and wherever the heck you feel like it once and for all, without having to constantly reposition them so that they get transformed by your current "view" transform. OpenGL has to work that way because it simply doesn't know what you think your "view" is vs your "model". It's all just a modelview to GL.</p> <p>(Comment - apologies if I'm not supposed to answer my own questions here, but this was a real question that I had a few weeks ago and thought it was worth posting here to help others making the shift from OpenGL to D3D. Basic overviews of the D3D lighting and rendering pipeline seem hard to come by.)</p>
<p>For the fixed function pipeline, the lights position and direction are set in world space. The docs for the light structures do tell you that, but I'm not surprised that you missed it in the docs. There's not much information on the fixed function pipeline anymore as the focus has to programmable shaders.</p>
9,724
<p>The company where I work created this application which is core to our business and relies on the web browser to enforce certain "rules" that without them renders the application kinda useless to our customers. Sorry about having to be circumspect, An NDA along with a host of other things prevents me from saying exactly what the application is. Essentially, JavaScript controls certain timed events (that have to be accurate down to at least the second) that make it difficult to control with ajax/postbacks etc. </p> <p>My question is this: how hard is it to convert an ASP.NET application to SilverLight assuming that most of the code is really C# business logic and not asp.net controls? I just got finished listening to Deep Fried bytes and the MS people make it sounds like this really isn't that big of a deal. Is this true for web apps, or mainly Win32 ones? </p> <p>I know the asp.net front end is fundamentally different from SilverLight, but there is a bunch of C# code I would like to not have to rewrite if necessary. The replacement of the javascript code to silverlight I am assuming is trivial (i know bad assumption, but I have to start somewhere) since it deals with timed events, so I am not really concerned with that. I need to come up with a solution on how to mitigate this problem, and I am hoping this is a middle ground between: do nothing and watch us get pounded by our clients, and rewrite the whole application in something more secure than a web page with only front end validation. Has anyone tried to convert ASP.NET code to a SilverLight project? </p>
<p>If the bulk of your application is on the back-end, you should still be able to keep the majority of the code intact and only replace the front-end. However, Silverlight requires an understanding of WPF, which is dramatically different than the HTML/JS that your app currently uses. I'd say if your UI is pretty thin, it should be pretty easy to port to Silverlight, but the more business logic is in the UI, the harder it will be.</p>
<p>How heavily do you use the class libraries, and things that might be considered 'dangerous', like pinvoke, file system access and System.Diagnostics.Process? </p>
9,014
<p>I need to determine if I'm on a particular view. My use case is that I'd like to decorate navigation elements with an "on" class for the current view. Is there a built in way of doing this?</p>
<p>Here what i am using. I think this is actually generated by the MVC project template in VS:</p> <pre><code>public static bool IsCurrentAction(this HtmlHelper helper, string actionName, string controllerName) { string currentControllerName = (string)helper.ViewContext.RouteData.Values["controller"]; string currentActionName = (string)helper.ViewContext.RouteData.Values["action"]; if (currentControllerName.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase) &amp;&amp; currentActionName.Equals(actionName, StringComparison.CurrentCultureIgnoreCase)) return true; return false; } </code></pre>
<p>Here is something a little different, use a FilterAttribute:</p> <pre><code> [NavigationLocationFilter("Products")] public ViewResult List() { return View(); } </code></pre> <p>...</p> <pre><code>public class NavigationLocationFilterAttribute : ActionFilterAttribute { public string CurrentLocation { get; set; } public NavigationLocationFilterAttribute(string currentLocation) { CurrentLocation = currentLocation; } public override void OnActionExecuting(ActionExecutingContext filterContext) { var controller = (Controller)filterContext.Controller; controller.ViewData.Add("NavigationLocation", CurrentLocation); } } </code></pre> <p>...</p> <p>And in the view:</p> <pre><code>&lt;%= ViewData["NavigationLocation"] %&gt; </code></pre>
6,177
<p>In order for my application (.Net 1.1) to use the system configured proxy server (trough a proxy.pac script) I was using an interop calls to WinHTTP function WinHttpGetProxyForUrl, passing the proxy.pac url I got from the registry.</p> <p>Unfortunately, I hit a deployment scenario, where this does not work, as the proxy.pac file is deployed locally on the user's hard drive, and the url is "file://C://xxxx"</p> <p>As clearly stated in the WinHttpGetProxyForUrl docs, it works only with http and https schemes, so it fails with file://</p> <p>I'm considering 2 "ugly" solutions to the problem (the pac file is javascript):</p> <ol> <li><p>Creating a separate JScript.NET project, with a single class with single static method Eval(string), and use it to eval in runtime the function read from the pac file</p></li> <li><p>Building at runtime a JScript.NET assembly and load it.</p></li> </ol> <p>As these solutions are really ugly :), does anybody know a better approach? Is there a Windows function which I can use trough interop?</p> <p>If not, what are you guys thinking about the above 2 solutions - which one would you prefer?</p>
<p>Just a thought: Why not create a micro web server that can serve the local PAC file over a localhost socket. You should use a random URI for the content so that it is difficult to browse this in unexpected ways.</p> <p>You could then pass a URL like <a href="http://localhost:1234/gfdjklskjgfsdjgklsdfklgfsjkl" rel="nofollow noreferrer">http://localhost:1234/gfdjklskjgfsdjgklsdfklgfsjkl</a> to the WinHttpGetProxyForUrl function and allow it to pull the PAC file from your micro server.</p> <p>(hack... hack... hack...)</p>
<p>Can't answer your problem unfortunately (though a few years ago I played with jscript.net and it would only be a few lines to build and run that way)</p> <p>I hit a similar proxy.pac hiccup with a personal work-around-the-office-proxy file a while back - in the end I went with the easiest option and dropped it into its own IIS site, and its been rock solid and works flawlessly with everything on my pc.</p> <p>Sometimes its best to give in and work with what is provided :)</p>
8,959
<p>Linux/Gcc/LD - Toolchain.</p> <p>I would like to remove STL/Boost debug symbols from libraries and executable, for two reasons:</p> <ol> <li>Linking gets very slow for big programs</li> <li>Debugging jumps into stl/boost code, which is annoying</li> </ol> <p>For 1. incremental linking would be a big improvement, but AFAIK ld does not support incremental linking. There is a workaround "pseudo incremental linking" in an 1999 dr.dobb's journal (not in the web any more, but at <a href="http://web.archive.org/web/20000131063231/www.ddj.com/articles/1999/9910/9910d/9910d.htm" rel="nofollow noreferrer">archive.org</a> (the idea is to put everything in a dynamic library and all updated object files in an second one that is loaded first) but this is not really a general solution.</p> <p>For 2. there is a script <a href="http://ubuntuforums.org/showthread.php?p=4368377" rel="nofollow noreferrer">here</a>, but a) it did not work for me (it did not remove symbols), b) it is very slow as it works at the end of the pipe, while it would be more efficient to remove the symbols earlier.</p> <p>Obviously, the other debug symbols should stay in place.</p>
<p>As far as I know there's no real option to do what you want in gcc. The main problem being that all the code you want to strip debug symbols for is defined in headers.</p> <p>Otherwhise it would be possible to build a library separatly, strip that, and link with the stripped version.</p> <p>But only getting debug symbols from certain parts of a compilation unit, while building and linking (for your desired link time speedup) is not possible in gcc as far as I know.</p>
<p>Which compiler are you using? For example, if I understand your question correctly, this is a trivial matter in MS Visual Studio.</p>
9,924
<p>I have a Duplicator i3 mini, which has yet to make it a month without breaking. This time it is extra broken because the filament is not extruding properly. the most successful print I've had yet had about a centimeter before turning into an absolute mess. I have a picture. It was not stringy, and had the exact shape i was trying to print, but was like a frame of a sort. I am printing with matterhackers MH build series PLA, which has worked before this started happening. What should I do? What troubleshooting steps should I take?<a href="https://i.stack.imgur.com/ZZzyt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZZzyt.jpg" alt="It&#39;s a mess"></a></p>
<p>Underextrusion and clogs can also be caused by insufficient temperature in the hot end. You've not reference your temperatures, so consider to use a test model and print at different temperatures. Too low temps can result in the problem you present, while too hot temps will increase stringing and peculiar blobs on the print. </p> <p>If your slicer changes print speed at the layer of destruction, it may also be too fast, which is related to temperatures. Simplify3D allows speed variation as well as temperature variation at selected layers, but it requires deliberate action on the part of the operator.</p>
<p>That looks like underextrusion as a result of a clog. Try cleaning the nozzle or replacing it.</p> <p>See this link for more information about clogged nozzles. <a href="https://3dprinting.stackexchange.com/questions/5191/if-i-have-a-nozzle-clog-can-i-easily-get-rid-of-it-by-simply-replacing-the-nozz">If I have a nozzle clog, can I easily get rid of it by simply replacing the nozzle?</a></p>
1,416
<p>I am overriding a lot of SAP's Portal functionality in my current project. I have to create a custom fixed width framework, custom iView trays, custom KM API functionality, and more.</p> <p>With all of these custom parts, I will not be using a lot of the style functionality implemented by SAP's Theme editor. What I would like to do is create an external CSS, store it outside of the Portal and reference it. Storing externally will allow for easier updates rather than storing the CSS within a portal application. It would also allow for all custom pieces to have their styles in once place.</p> <p>Unfortunately, I've not found a way to gain access to the HEAD portion of the page that allows me to insert an external stylesheet. Portal Applications can do so using the IResource object to gain access to internal references, but not items on another server.</p> <p>I'm looking for any ideas that would allow me to gain this functionality. I have <a href="https://www.sdn.sap.com/irj/sdn/thread?threadID=1046064&amp;tstart=0" rel="nofollow noreferrer">x-posted on SAP's SDN</a>, but I suspect I'll get a better answer here.</p>
<p>I'd consider it dirty hack, but as a non-Portal developer I'd consider using JavaScript to insert a new link element in the head pointing to your new CSS file. Of course you'd have a flash of un-styled content because the script probably won't run until after part of the page has been downloaded and rendered, but it may be an adequate solution.</p>
<p>I hate that I'm answering my own question, but I did find a potential solution that's not documented well and in typical SAP fashion uses deprecated methods. So it might be a slightly less dirty hack than what Eric suggested. I found it through an unrelated SDN forum post.</p> <p>Basically, you dive into the request object and gather the PortalNode. Once you have that, you ask it for a value of a IPortalResponse. This object can be cast to a PortalHtmlResponse. That object has a deprecated method called getHtmlDocument. Using that method, you can use some Html mirror objects to get the head and insert new links.</p> <p>Sample:</p> <pre><code>IPortalNode node = request.getNode().getPortalNode(); IPortalResponse resp = (IPortalResponse) node.getValue(IPortalResponse.class.getName()); if (resp instanceof PortalHtmlResponse) { PortalHtmlResponse htmlResp = (PortalHtmlResponse) resp; HtmlDocument doc = htmlResp.getHtmlDocument(); HtmlHead myHead = doc.getHead(); HtmlLink cssLink = new HtmlLink("http://myserver.com/css/mycss.css"); cssLink.setType("text/css"); cssLink.setRel("stylesheet"); myHead.addElement(cssLink); } </code></pre>
8,781
<p>Rather than rewriting the entire contents of an xml file when a single element is updated, is there a better alternative to updating the file?</p>
<p>I would recommend using VTD-XML <a href="http://vtd-xml.sourceforge.net/" rel="noreferrer">http://vtd-xml.sourceforge.net/</a></p> <p>From their FAQ ( <a href="http://vtd-xml.sourceforge.net/faq.html" rel="noreferrer">http://vtd-xml.sourceforge.net/faq.html</a> ):</p> <blockquote> <p>Why should I use VTD-XML for large XML files?</p> <p>For numerous reasons summarized below:</p> <ul> <li>Performance: The performance of VTD-XML is far better than SAX</li> <li>Ease to use: Random access combined with XPath makes application easy to write</li> <li>Better maintainability: App code is shorter and simpler to understand.</li> <li>Incremental update: Occasional, small changes become very efficient.</li> <li>Indexing: Pre-parsed form of XML will further boost processing performance.</li> <li>Other features: Cut, paste, split and assemble XML documents is only possible with VTD-XML.</li> </ul> <p>In order to take advantage of VTD-XML, we recommended that developers split their ultra large XML documents into smaller, more manageable chucks (&lt;2GB). </p> </blockquote>
<p><strong>Process Large XML Files with XQuery Works with Gigabyte Size XML Files</strong> <a href="http://www.xquery.com" rel="nofollow noreferrer">http://www.xquery.com</a></p> <p>XQuery is a query language that was designed as a native XML query language. Because most types of data can be represented as XML, XQuery can also be used to query other types of data. For example, XQuery can be used to query relational data using an XML view of a relational database. This is important because many Internet applications need to integrate information from multiple sources, including data found in web messages, relational data, and various XML sources. XQuery was specifically designed for this kind of data integration.</p> <p>For example, suppose your company is a financial institution that needs to produce reports of stock holdings for each client. A client requests a report with a Simple Object Access Protocol (SOAP) message, which is represented in XML. In most businesses, the stock holdings data is stored in multiple relational databases, such as Oracle, Microsoft SQL Server, or DB2. XQuery can query both the SOAP message and the relational databases, creating a report in XML.</p> <p>XQuery is based on the structure of XML and leverages that structure to make it possible to perform queries on any type of data that can be represented as XML, including relational data. In addition, XQuery API for Java (XQJ) lets your queries run in any environment that supports the J2EE platform.</p>
8,783
<p>There is a little circuit board, or breadboard or something <a href="http://reprap.org/wiki/Prusa_i3_Rework_Electronics_and_wiring#Wiring" rel="nofollow noreferrer">in the diagram of the wiring for the i3</a>.</p> <p>And it's mentioned that the z-axis motors need to be <a href="http://reprap.org/wiki/Prusa_i3_Rework_Electronics_and_wiring#Motors_wiring" rel="nofollow noreferrer">wired in parallel</a> but beyond that they don't give you much detail about parts or how the wires go in. </p> <p>Can someone provide me with some more detail on this?</p>
<p>In the diagram, they do show the wires connecting together, which is right. You can accomplish that just about any way you like, so long as you pair up the wires correctly from one motor to the other.</p> <p>I'm assuming both "Z" motors are the same type and have the same color-coding for their wires. If not, you'll need to figure out the correspondences first (you may want to post another question if you need a hand with that, since it's pretty specific and generally useful).</p> <p>Many control boards have "headers" sticking up, with 4 bare pins for each motor. Connectors that plug right onto those are readily available, such as at <a href="https://www.sparkfun.com/products/10364" rel="nofollow noreferrer">https://www.sparkfun.com/products/10364</a>.</p> <p>Some ways you can wire the motors in parallel:</p> <ul> <li><p>Some control boards, like my RAMPS 1.4, provide 2 sets of header pins next to the Z stepper driver board. In that case, just put a connector on each motor (if they're not there already), and plug them in next to each other.</p></li> <li><p>If there's just one set of header pins (or one Z-motor socket of some other kind) on your controller, make a "Y-cord" by soldering the wires from one connector (that plugs to the controller) to <em>2</em> 4 pin connectors, one to mate with each motor.</p></li> <li><p>Or you can skip the 2 extra connectors entirely, and just solder the motor wires to the wires from the connector: 2 reds to red, 2 blacks to black, or whatever.</p></li> <li><p>If your controller just has empty holes, either solder in header pins and do as above (preferred, IMHO), or wire directly into the holes, splicing the 2 sets of motor wires if there's only one set of holes.</p></li> </ul> <p>Motor and connector wires are wildly inconsistent, so make sure you get them sorted out right if they aren't already. The first thing is to check continuity: find 2 pairs of wires, which are the ends of two separate coils. If your motors have more than 4 wires it's trickier.</p> <p>With RAMPS (see handy diagram <a href="http://makerdev.com/blog/wp-content/uploads/2014/02/ramps_fanboard_annotations.jpg" rel="nofollow noreferrer">RAMPS 1.4 RepRap Arduino Mega Pololu shield</a>), </p> <p><a href="https://i.stack.imgur.com/A6lsT.jpg" rel="nofollow noreferrer" title="RAMPS 1.4 RepRap Arduino Mega Pololu shield"><img src="https://i.stack.imgur.com/A6lsT.jpg" alt="RAMPS 1.4 RepRap Arduino Mega Pololu shield" title="RAMPS 1.4 RepRap Arduino Mega Pololu shield"></a></p> <p>the 4 pins are commonly labelled (starting from the one nearest the power-supply end of the RAMPS board):</p> <pre><code>2B 2A 1A 1B </code></pre> <p>It means coil 1 and coil 2, each of which has ends A and B. I find this unclear because it could just as well have been numbers for the coils, and letters for the ends (if you wire it that way it won't work). So be sure you have continuity (maybe 15 ohms or so) between the wires you connect to 2B and 2A, and between the wires you connect to 1A and 1B.</p> <p>The <em>really good thing</em> about this pin order is that if a motor is running backwards all you have to do is power off and then turn the plug around. That's one reason I think it's important to keep connectors in there, rather than soldering directly.</p>
<p>For some unknown reason, everywhere everybody is saying that Z stepper motors need to be connected in parallel... And this was always the only obvious way, until recently some people started to connect these motors in series.</p> <p>And I personally started to believe the right way is to connect them in series.</p> <p>All stepstick drivers are some kind of current limiting devices (you could read more about chopper mode). It is all about current. Connecting in series will guarantee that both motors receive the same current in all situations. And as result you could expect the same behaviour from both of them.</p> <p>The bad thing when they are in parallel, is that the motor with the bigger load will get more current and as a result the other one will get less current and could skip steps. Of course, in an ideal situation, this should never happen but don't forget about Murphy's law ("whatever can go wrong, will go wrong").</p> <p>One more thing - why did I change my wiring and connected my Z motors in series: At some moment I found that one Z motor was disconnected but the other one was working and this resulted in a broken printer geometry. When Z motors are in series and if one of them fails or disconnects, the other one will not work either. You will get always synchronous operation from both of them!</p> <p>I made this Z splitter that works fantastic: </p> <p><a href="https://i.stack.imgur.com/WM9F3.jpg" rel="noreferrer" title="Z splitter"><img src="https://i.stack.imgur.com/WM9F3.jpg" alt="Z splitter" title="Z splitter"></a></p>
171
<p>I made a test print for a small gear (~ 1.5 inches in diameter) a few months ago, with a hole through the center. On the first try, the filament (ABS) fused to the print bed, meaning that I had to spend ten minutes scraping off material to loosen it. One solution to this is to use painter's tape spread across the print bed.</p> <p>This yielded a good print during the next run. The problem with this method was that some of the tape subsequently fused to the backside of the gear; it was so tight that I had to discard the prototype. Multiple varieties of tape made no difference.</p> <p>Is there a way to continue using this tape without having it fuse to the filament?</p>
<p>This can highly depend on the slicer you are using. Some software such as Makerware and Slic3r allow you to adjust the settings for the first raft/part layers. I might suggest adjusting this "Z0" point to about 1/4-1/2 of your layer height. Essentially the first layer (or two) will not adhere as well.</p> <p>This is just one suggestion of many solutions. Here are some other variables I could think of off-hand:</p> <ul> <li>Type of build plate tape (ie masking, painters, kapton, etc.)</li> <li>Type of material. I've noticed that PLA is very stubborn if you let the part completely cool after printing and that it's much easier to remove the part from the build plate/raft right after it's complete.</li> <li>Type of build plate. Are you applying too much heat (if you have a heated bp) for the material such as PLA?</li> <li>Try lowering your layer height. This will ensure that each strand does not have too much surface area and therefore less chance that it will create a vacuum affect with the build plate. This can, however, result in a worse surface finish.</li> </ul>
<p>My very first thought was you didn't re-calibrate your Z0 after adding the blue tape. It sounds like the print head was too close to the print bed to begin with, and adding the blue tape just made it that much worse. </p>
104
<p>I've seen examples like this: </p> <pre><code>public class MaxSeconds { public static final int MAX_SECONDS = 25; } </code></pre> <p>and supposed that I could have a Constants class to wrap constants in, declaring them static final. I know practically no Java at all and am wondering if this is the best way to create constants. </p>
<p>That is perfectly acceptable, probably even the standard.</p> <pre><code>(public/private) static final TYPE NAME = VALUE; </code></pre> <p>where <code>TYPE</code> is the type, <code>NAME</code> is the name in all caps with underscores for spaces, and <code>VALUE</code> is the constant value;</p> <p>I highly recommend NOT putting your constants in their own classes or interfaces. </p> <p>As a side note: Variables that are declared final and are mutable can still be changed; however, the variable can never point at a different object.</p> <p>For example:</p> <pre><code>public static final Point ORIGIN = new Point(0,0); public static void main(String[] args){ ORIGIN.x = 3; } </code></pre> <p>That is legal and <code>ORIGIN</code> would then be a point at (3, 0).</p>
<p>I wouldn't call the class the same (aside from casing) as the constant ... I would have at a minimum one class of "Settings", or "Values", or "Constants", where all the constants would live. If I have a large number of them, I'd group them up in logical constant classes (UserSettings, AppSettings, etc.)</p>
9,174
<p>How do I speed up prints for the Monoprice Select IIIP Plus printer?</p> <p>The manual shows [Cura] examples of:</p> <ul> <li>Print speed: 50mm/s</li> <li>Travel Speed: 80mm/s</li> <li>Bottom Layer Speed: 20mm/s</li> <li>Infill Speed: 50mm/s</li> <li>Outer shell speed: 15mm/s</li> <li>Inner shell speed: 30mm/s</li> </ul> <p>However, this doesn’t line up with their advertisements online of a 150mm/s printing speed.</p> <p>Are there better settings to use, especially ones which can speed up printing time? Or are there any other measures which I can take in order to reduce printing time in general? </p>
<p>In my experience a print speed of 50-70mm/s is ideal. Even if you set the speed to 150mm/s the print head still changes directions often and rarely will have enough time to accelerate from 0->150 before changing direction again. </p> <p>Some more effective ways of speeding up prints is to adjust</p> <ul> <li>Layer height</li> <li>Infill percentage (15-25% for regular prints, more if they need to be more sound)</li> <li>Supports</li> <li>Number of shells, etc</li> </ul>
<p>I was using Cura's default settings for a Prusa I3 on my MonoPrice Select V2 (model #13860), and got horrible results frequently. Then I used the settings you list, and got very nice results. Compare the below images for the bottom layer of 4 benchys, with adhesion brim.</p> <p>I'm using PLA, 0.4mm nozzle, 60C for bed, 200C for extruder, 1.75mm filament from Hatchbox.</p> <p><strong>Default Cura Settings</strong> <a href="https://i.stack.imgur.com/akAJu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/akAJu.jpg" alt="Using default Cura settings"></a></p> <p><strong>Listed Settings</strong> <a href="https://i.stack.imgur.com/Zg76A.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zg76A.jpg" alt="Using recommended settings"></a></p> <p><strong>Settings breakdown</strong></p> <pre><code>Setting Cura default Recommended Print Speed 60 50 Outer Wall Speed 30 15 Inner Wall Speed 60 30 Top/Bottom Speed 30 20 Travel Speed 120 80 </code></pre> <p><strong>Symptoms of my printer being told to print too fast:</strong></p> <p>Material would not adhere properly to the print bed, and would start making clumps. These would rest either on the bed, or on the nozzle itself. The ones on the bed would grow taller than layer height, making the next pass of the nozzle bump against it, further depositing material on it. The clumps on the nozzle would drop at other points, leaving stringing filament all over, and further compromising the next pass of the head.</p> <p>This might seem like a bed adhesion problem, but the prints were <em>very</em> well attached to the bed; I had to apply a lot of force to remove a 15*15cm square from the bed.</p> <p>Increasing the hot-end temperature seemed to help; at some point we were printing at 230C, well beyond Hatchbox' extrusion temperature range (range is listed as 180C-210C for this PLA batch).</p> <p>Ultimately, reducing print speed to the settings listed helped us increase print quality back to acceptable levels.</p>
654
<p>Has anyone used ADO.NET Data Services as a data source for Adobe Flex applications? If so, any success stories or tragedies to avoid? If you did use it, how did you handle security?</p>
<p>I use WebORB for .NET to do Flex remoting and then use DLINQ on the server. One tricky thing about using LINQ with WebORB is that WebORB uses Reflection to automatically retrieve all the relationships of the object(s) you return to Flex. This causes severe time penalties as LINQ uses lazy loading to load relationships. To prevent this from happening, I do something like the following:</p> <p>Override your DataContext's constructor and add the following code:</p> <pre><code>this.DeferredLoadingEnabled = false; DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith&lt;Order&gt;(q =&gt; q.Payments); dlo.LoadWith&lt;Order&gt;(q =&gt; q.Customer); this.LoadOptions = dlo; </code></pre> <p>This tells the DataContext to disable deferred loading of relationships and specifically instructs it to load just the relationships you want, without lazy loading. That way, WebORB isn't causing any lazy loading to happen through Reflection and the number of relationships being transferred to Flex is kept at a minimum.</p> <p>Hope this helps you in some way. It's definitely one of those little "gotchas" when working with Flex/WebORB and LINQ.</p>
<p>He Asked about ADO.NET Data Services not web service</p>
6,660
<p>I want to know how to make a mold of a 3D design in .stl format.</p> <p>Suppose I have a 3D partin .stl format (for e.g. a cylinder) and I want to make/design a mold for this object (i.e. the structure through which I could make the cylinder). Is there any way to do so? Are there any tools to do so?</p> <p>My requirement is as follows: I have an .stl file of a design and need to develop the CAD files for its mold. I will then need to 3D print these molds. I would require to add a hole to pour in liquid (resin based) raw material which hardens with time. </p>
<p>You can also bring the model and a big box into slic3r, align and orient them (enclose the model in the box), and do a subtract modifier, leaving a hollow where the two intersected. You probably want to do this twice, for a top mould and a botom mould. I've done this, but I don't see any instructions online for it. :(</p> <p>EDIT: Unfortunately, this would be very tedious. It's much easier to use meshmixer or another publicly available program to subtract one stl from another.</p> <p>In Slic3r, using another stl as a modifier has no effect unless you are also printing that second stl (normally from another head). So you would have to manually remove all the gcode for the second head. Sorry for the bad advice.</p>
<p>In addition to the answer of Davo (which describes a surprising feature of the slicer software I was unaware of), a more generic description would involve the use of a 3D solid model CAD program. You should be aware that a model in STL format is not a solid model, it is a surface model. In order to make a mold you would have to import the STL model into a CAD program (there are a few free ones available like Fusion 360 or FreeCAD or maybe many more that will work also) and make a solid body from the surface model. Next thing is to create a large rectangular block and subtract the positive model from the block. Now a negative lives inside this block so you will need to conveniently cut the block through your negative to create 2 mold parts. Be sure that you divide the block so that you can take out the casting from the mold parts and also add an entry to pour in the liquid casting material and add risers (holes) to de-aerate the cavity. Furthermore, for alignment, you could add pins and holes to the mold parts.</p>
894
<p>I was wondering how as semantic service like Open Calais figures out the names of companies, or people, tech concepts, keywords, etc. from a piece of text. Is it because they have a large database that they match the text against? </p> <p>How would a service like Zemanta know what images to suggest to a piece of text for instance? </p>
<p>I'm not familiar with the specific services listed, but the field of natural language processing has developed a number of techniques that enable this sort of information extraction from general text. As Sean stated, once you have candidate terms, it's not to difficult to search for those terms with some of the other entities in context and then use the results of that search to determine how confident you are that the term extracted is an actual entity of interest.</p> <p><a href="http://opennlp.sourceforge.net/" rel="noreferrer">OpenNLP</a> is a great project if you'd like to play around with natural language processing. The capabilities you've named would probably be best accomplished with Named Entity Recognizers (NER) (algorithms that locate proper nouns, generally, and sometimes dates as well) and/or Word Sense Disambiguation (WSD) (eg: the word 'bank' has different meanings depending on it's context, and that can be very important when extracting information from text. Given the sentences: "the plane banked left", "the snow bank was high", and "they robbed the bank" you can see how dissambiguation can play an important part in language understanding)</p> <p>Techniques generally build on each other, and NER is one of the more complex tasks, so to do NER successfully, you will generally need accurate tokenizers (natural language tokenizers, mind you -- statistical approaches tend to fare the best), string stemmers (algorithms that conflate similar words to common roots: so words like informant and informer are treated equally), sentence detection ('Mr. Jones was tall.' is only one sentence, so you can't just check for punctuation), part-of-speech taggers (POS taggers), and WSD.</p> <p>There is a python port of (parts of) OpenNLP called NLTK (<a href="http://nltk.sourceforge.net" rel="noreferrer">http://nltk.sourceforge.net</a>) but I don't have much experience with it yet. Most of my work has been with the Java and C# ports, which work well. </p> <p>All of these algorithms are language-specific, of course, and they can take significant time to run (although, it is generally faster than reading the material you are processing). Since the state-of-the-art is largely based on statistical techniques, there is also a considerable error rate to take into account. Furthermore, because the error rate impacts all the stages, and something like NER requires numerous stages of processing, (tokenize -> sentence detect -> POS tag -> WSD -> NER) the error rates compound.</p>
<p>Open Calais probably use language parsing technology and language statics to guess which words or phrases are Names, Places, Companies, etc. Then, it is just another step to do some kind of search for those entities and return meta data.</p> <p>Zementa probably does something similar, but matches the phrases against meta-data attached to images in order to acquire related results.</p> <p>It certainly isn't easy.</p>
4,207
<p>I was surprised recently to find that it's possible to have a return statement in a finally block in Java.</p> <p>It seems like lots of people think it's a bad thing to do as described in '<a href="https://web.archive.org/web/20070922061412/http://weblogs.java.net/blog/staufferjames/archive/2007/06/_dont_return_in.html" rel="noreferrer">Don't return in a finally clause</a>'. Scratching a little deeper, I also found '<a href="https://web.archive.org/web/20190528011825/http://www.cs.arizona.edu/projects/sumatra/hallofshame/" rel="noreferrer">Java's return doesn't always</a>' which shows some pretty horrible examples of other types of flow control in finally blocks.</p> <p>So, my question is, can anyone give me an example where a return statement (or other flow control) in a finally block produces better / more readable code?</p>
<p>The examples you provided are reason enough to <i>not</i> use flow-control from finally.</p> <p>Even if there's a contrived example where it's "better," consider the developer who has to maintain your code later and who might not be aware of the subtleties. That poor developer might even be you....</p>
<p>Returning from inside a <code>finally</code> block will cause <code>exceptions</code> to be lost.</p> <p><strong>A return statement inside a finally block will cause any exception that might be thrown in the try or catch block to be discarded.</strong> </p> <p>According to the <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.20.2" rel="nofollow noreferrer"><strong>Java Language Specification:</strong></a></p> <blockquote> <p>If execution of the try block completes abruptly for any other reason R, then the finally block is executed, and then there is a choice:</p> <pre><code> If the finally block completes normally, then the try statement completes abruptly for reason R. If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and reason R is discarded). </code></pre> </blockquote> <p><em>Note: As per <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.17" rel="nofollow noreferrer">JLS 14.17</a> - a return statement always completes abruptly.</em></p>
7,045
<p>I'm working on a C# winforms application (VS.NET 2008, .NET 3.5 sp 1). I have a search field on a form, and rather than have a label next to the search field I'd like to show some grey text in the background of the search field itself ('Search terms', for example). When the user starts entering text in the search field the text should disappear. How can I achieve this?</p>
<p>You will need to use some P/Inovke interop code to do this. Look for the Win32 API <code>SendMessage</code> function and the <code>EM_SETCUEBANNER</code> message.</p>
<p>There is built-in functionality in the text box control -- <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.autocompletemode.aspx" rel="nofollow noreferrer">AutoCompleteMode</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.autocompletesource.aspx" rel="nofollow noreferrer">AutoCompleteSource</a>. They may be worth a try before you go into custom or 3rd party controls.</p>
6,902
<p>I have read through several reviews on Amazon and some books seem outdated. I am currently using MyEclipse 6.5 which is using Eclipse 3.3. I'm interested in hearing from people that have experience learning RCP and what reference material they used to get started.</p>
<p>I've been doing Eclipse RCP development for almost 2 years now. When I first started, I wanted a book for help and many people told me, with Eclipse you're better off using the <a href="http://wiki.eclipse.org/index.php/Rich_Client_Platform" rel="nofollow noreferrer">Eclipsepedia</a> and Google.</p> <p>However, I started with "<a href="https://rads.stackoverflow.com/amzn/click/com/0321305027" rel="nofollow noreferrer" rel="nofollow noreferrer">The Java Developer's Guide to Eclipse</a>" by D'Anjou et al, and I still reference it when I need a better starting point or a good reference. It's probably a little outdated now, but is very thorough and really explains how the Eclipse framework works. Like just about anything, RCP isn't too hard to pick up if you've figured out how the framework supporting it works and you'll get a lot more mileage out of your code.</p>
<p>I read the <a href="https://rads.stackoverflow.com/amzn/click/com/0321334612" rel="nofollow noreferrer" rel="nofollow noreferrer">book</a> suggested by Thomas and it's really worth reading, although not very up-to-date.</p>
2,938
<p>Like many people, I have burnt the pins in the micro-controller connected to the E0 motor - the E0 motor is not working anymore and I need to print tomorrow! I need to control the extruder motor with the working E1 pins. How do I change this in firmware? </p> <p>I tried to change to the pins in `pins_RAMPS.h" but it was a complete fail, the motors that i tried to change didn't move. </p> <p>I have a Arduino Mega + Ramps 1.3 in "Extruder Fan Bed" configuration, I use Repetier-Host as host and Marlin as firmware. </p>
<p>I would change the pin assignments by swapping E0 and E1 in <code>pins_RAMPS.h</code>.</p>
<p>As a quick and dirty solution you may try to enable two extruders in configuration file, re-upload firmware, and then edit your GCODE file to replace all E0 references with E1.</p>
447
<p>I've had to do some introspection in python and it wasn't pretty:</p> <pre><code>name = sys._getframe(1).f_code name = "%s:%d %s()" %(os.path.split(name.co_filename)[1],name.co_firstlineno,name.co_name) </code></pre> <p>To get something like</p> <pre><code>foo.py:22 bar() blah blah </code></pre> <p>In our debugging output.</p> <p>I'd ideally like to prepend anything to stderr with this sort of information -- Is it possible to change the behaviour of print globally within python?</p>
<p>A print statement does its IO through "sys.stdout.write" so you can override sys.stdout if you want to manipulate the print stream.</p>
<p>The python <a href="http://www.python.org/doc/current/lib/module-inspect.html" rel="nofollow noreferrer">inspect</a> module makes this a lot easier and cleaner. </p>
6,288
<p>I recently read a nice <a href="http://macdevelopertips.com/ruby/using-a-string-as-a-file-in-ruby.html" rel="noreferrer">post</a> on using <code>StringIO</code> in Ruby. What the author doesn't mention, though, is that <code>StringIO</code> is just an "I." There's no "O." You <em>can't</em> do this, for example:</p> <pre><code>s = StringIO.new s &lt;&lt; 'foo' s &lt;&lt; 'bar' s.to_s # =&gt; should be "foo\nbar" # =&gt; really is ''` </code></pre> <p>Ruby really needs a StringBuffer just like the one Java has. StringBuffers serve two important purposes. First, they let you test the output half of what Ruby's StringIO does. Second, they are useful for building up long strings from small parts -- something that Joel reminds us over and over again is otherwise very very slow.</p> <p>Is there a good replacement?</p> <p>It's true that Strings in Ruby are mutable, but that doesn't mean we should always rely on that functionality. If <code>stuff</code> is large, the performance and memory requirements of this, for example, is really bad.</p> <pre><code>result = stuff.map(&amp;:to_s).join(' ') </code></pre> <p>The "correct" way to do this in Java is:</p> <pre><code>result = StringBuffer.new("") for(String s : stuff) { result.append(s); } </code></pre> <p>Though my Java is a bit rusty.</p>
<p>I looked at the ruby documentation for <code>StringIO</code>, and it looks like what you want is <a href="http://ruby-doc.org/stdlib/libdoc/stringio/rdoc/classes/StringIO.html#method-i-string" rel="noreferrer"><code>StringIO#string</code></a>, not <code>StringIO#to_s</code></p> <p>Thus, change your code to:</p> <pre><code>s = StringIO.new s &lt;&lt; 'foo' s &lt;&lt; 'bar' s.string </code></pre>
<p>Well, a StringBuffer is not quite as necessary in Ruby, mainly because Strings in Ruby are mutable... thus you can build up a string by modifying the existing string instead of constructing new strings with each concat.</p> <p>As a note, you can also use special string syntax where you can build a string which references other variables within the string, which makes for very readable string construction. Consider:</p> <pre><code>first = "Mike" last = "Stone" name = "#{first} #{last}" </code></pre> <p>These strings can also contain expressions, not just variables... such as:</p> <pre><code>str = "The count will be: #{count + 1}" count = count + 1 </code></pre>
3,156
<p>The system I'm currently working on consists of a controller PC running XP with .Net 2 connected to a set of embedded systems. All these components communicate with each other over an ethernet network. I'm currently using TcpClient.Connect on the XP computer to open a connection to the embedded systems to send TCP/IP messages. </p> <p>I now have to connect the XP computer to an external network to send processing data to, so there are now two network cards on the XP computer. However, the messages sent to the external network mustn't appear on the network connecting the embedded systems together (don't want to consume the bandwidth) and the messages to the embedded systems mustn't appear on the external network.</p> <p>So, the assertion I'm making is that messages sent to a defined IP address are sent out on both network cards when using the TcpClient.Connect method.</p> <p>How do I specify which physical network card messages are sent via, ideally using the .Net networking API. If no such method exists in .Net, then I can always P/Invoke the Win32 API.</p> <p>Skizz</p>
<p>Try using a Socket for your client instead of the TcpClient Class.</p> <p>Then you can use Socket.Bind to target your local network adapter</p> <pre><code> int port = 1234; IPHostEntry entry = Dns.GetHostEntry(Dns.GetHostName()); //find ip address for your adapter here IPAddress localAddress = entry.AddressList.FirstOrDefault(); IPEndPoint localEndPoint = new IPEndPoint(localAddress, port); //use socket instead of a TcpClient Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //binds client to the local end point client.Bind(localEndPoint); </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.bind.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.bind.aspx</a></p>
<p>Basically, once the TcpClient.Connect method has been successful, it will have created a mapping between the physical MAC address of the embedded system and the route it should take to that address (i.e. which network card to use).</p> <p>I don't believe that all messages then sent over the TcpClient connection will be sent out via both network cards.</p> <p>Do you have any data to suggest otherwise, or are you mealy guessing?</p>
7,211
<p>I am using Slic3r to generate the GCode for my Marlin-based printer. For some reason with increasing height my print starts to get messed up. On another part it starts to act like this when there are small parts. Is this related to my Slic3r settings, maybe to much filament being extruded or is this due to something else?</p> <p>Any help is highly appreciated and I can provide more pictures of messed up parts or slic3r config if necessary.</p> <p><a href="https://i.stack.imgur.com/jTyk1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jTyk1.jpg" alt="The filament is completely messed up"></a></p> <p><a href="https://i.stack.imgur.com/J4Thr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J4Thr.jpg" alt="Another picture of the messed up print"></a></p>
<p>To me, this looks like a combination of bad filament, high temperature and/or fast speeds.</p> <ul> <li>Too high extrusion temperature will make difficult to let each layer cool enough before the next layer begins. This is why you see the poor results on the smaller areas of the print in your second photo.</li> <li>If you're using bad filament (out of round, non-virgin, or poorly stored filament) you might see a series of over/under extrusion areas or smoke from moisture in the filament.</li> <li>Slowing down your feed rates can be tricky if your extrusion temps are too high. By slowing down, you're allowing layers to cool down a little bit more and solidify. If your previous layers are still relatively molten, you'll notice that the new layer of filament will adhere to it and potentially drag the previous layers as the nozzle continues to move. You'll see the results of this in the top-arc layers with an uneven curvature.</li> </ul>
<p>This can happen if your filament is having to be pulled off the spool and slipping in the extruder. Check if slippage is happening at the extruder, perhaps see if results change by providing some hand powered help. I have seen this with some glossy PLA I have used.</p>
321
<p>We've got a scenario that requires us to parse lots of e-mail (plain text), each e-mail 'type' is the result of a script being run against various platforms. Some are tab delimited, some are space delimited, some we simply don't know yet.</p> <p>We'll need to support more 'formats' in the future too.</p> <p>Do we go for a solution using:</p> <ul> <li>Regex</li> <li>Simply string searching (using string.IndexOf etc)</li> <li>Lex/ Yacc</li> <li>Other</li> </ul> <p>The overall solution will be developed in C# 2.0 (hopefully 3.5)</p>
<p>Regex.</p> <p>Regex can solve almost everything except for world peace. Well maybe world peace too.</p>
<p>With as little information you provided, i would choose Regex.</p> <p>But what kind of information you want to parse and what you would want to do will change the decision to Lex/Yacc maybe..</p> <p>But it looks like you've already made your mind up with String search :)</p>
8,025
<p>I am new to ActionScript 3 and have run into a problem:</p> <p>Using Flex Builder 3, I have a created a project with a few simple classes. If code in class A instantiates an object of class B (class B is in its own source file) then the code compiles fine, but I get the following run time error:</p> <blockquote> <p>ArgumentError: Error #2012: B class cannot be instantiated.</p> </blockquote> <p>Can someone explain what I'm doing wrong?</p> <p><strong>Update:</strong> Please see my own answer below (I could not vote it to the top since I'm not yet registered).</p>
<p>I finally realized what was wrong: Class B was subclassing from DisplayObject which I now see is an abstract class. Class B did not implement the abstract members, thus the error. I'll probably change class B to subclass from Sprite instead.</p> <p>This seems like a problem that should have been caught by the compiler. Does the fact that it wasn't mean implementation of abstract members can wait until run time? Even if so, it would be nice to at least get a compiler warning.</p> <p>Thanks for everyone's answers, hopefully they will help others who run into error 2012.</p>
<p>It's worth noting that if you're including classes that someone else built, and they used Flash CS3 and you're using Flex, or vice versa, that the core libraries of each are different and some things are not included in both. Check out the two reference docs to be sure:</p> <p>CS3: <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/" rel="nofollow noreferrer">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/</a></p> <p>Flex: <a href="http://livedocs.adobe.com/flex/2/langref/" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/2/langref/</a></p>
9,375
<p>What would be the best way to design a threaded commenting system so that it doesn't hammer the database?</p>
<p><strong>SELECT ... START WITH ... CONNECT BY</strong></p> <p>Oracle has an extension to SELECT that allows easy tree-based retrieval.</p> <p>This query will traverse a table where the nesting relationship is stored in <strong>parent</strong> and <strong>child</strong> columns.</p> <pre><code>select * from my_table start with parent = :TOP_ARTICLE connect by prior child = parent; </code></pre> <p><a href="http://www.adp-gmbh.ch/ora/sql/connect_by.html" rel="nofollow noreferrer">http://www.adp-gmbh.ch/ora/sql/connect_by.html</a></p>
<p>What I normally do in this case is to have a single thread that is responsible for putting the data into the database, and have all auxiliary threads report to that thread, which then queues up the data, and writes it either serially, or in batches (depending on the requirements, and how much database activity I'm willing to put up with).</p>
5,706
<p>Suppose I have:</p> <ol> <li>Toby</li> <li>Tiny</li> <li>Tory</li> <li>Tily</li> </ol> <p>Is there an algorithm that can easily create a list of common characters in the same positions in all these strings? (in this case the common characters are 'T' at position 0 and 'y' at position 3)</p> <p>I tried looking at some of the algorithms used for DNA sequence matching but it seems most of them are just used for finding common substrings regardless of their positions.</p>
<p>Finding a list of characters that are common in ALL strings at a certain position is trivially simple. Just iterate on each string for each character position 1 character position at a time. If any string's character is not the match of it's closest neighbor string's character, then the position does not contain a common character.</p> <p>For any i = 0 to length -1... Once you find Si[x] != Si+1[x] you can skip to the next position x+1.</p> <p>Where Si is the ith string in the list. And [x] is the character at position x.</p>
<p>In lisp:</p> <pre><code>CL-USER&gt; (defun common-chars (&amp;rest strings) (apply #'map 'list #'char= strings)) COMMON-CHARS </code></pre> <p>Just pass in the strings:</p> <pre><code>CL-USER&gt; (common-chars "Toby" "Tiny" "Tory" "Tily") (T NIL NIL T) </code></pre> <p>If you want the characters themselves:</p> <pre><code>CL-USER&gt; (defun common-chars2 (&amp;rest strings) (apply #'map 'list #'(lambda (&amp;rest chars) (when (apply #'char= chars) (first chars))) ; return the char instead of T strings)) COMMON-CHARS2 CL-USER&gt; (common-chars2 "Toby" "Tiny" "Tory" "Tily") (#\T NIL NIL #\y) </code></pre> <p>If you don't care about posiitons, and just want a list of the common characters:</p> <pre><code>CL-USER&gt; (format t "~{~@[~A ~]~}" (common-chars2 "Toby" "Tiny" "Tory" "Tily")) T y NIL </code></pre> <p>I admit this wasn't an algorithm... just a way to do it in lisp using existing functionality</p> <p>If you wanted to do it manually, as has been said, you loop comparing all the characters at a given index to each other. If they all match, save the matching character.</p>
9,422
<p>Is there an easy way to find the storage card's path on a Windows Mobile device when there is a storage card and a bluetooth ftp connection?</p>
<p>Keep in mind that "\Storage Card" is english oriented. A device made for a different region may have a different name. The name of the storage card path on my device varies with how I am using the device. </p> <p>Some time ago in the MSDN forms I responded to a few questions on how to detect the storage cards in the file system and how does one get the storage card's capacity. I wrote the following could are a response to those questions and thought it would be helpful to share. Storage cards show up in the file system as temporary directories. This program examines the objects in the root of the device and any folders that have temp attribute are considered to be a positive match </p> <pre><code>using System; using System.IO; using System.Runtime.InteropServices; namespace StorageCardInfo { class Program { const ulong Megabyte = 1048576; const ulong Gigabyte = 1073741824; [DllImport("CoreDLL")] static extern int GetDiskFreeSpaceEx( string DirectoryName, out ulong lpFreeBytesAvailableToCaller, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes ); static void Main(string[] args) { DirectoryInfo root = new DirectoryInfo("\\"); DirectoryInfo[] directoryList = root.GetDirectories(); ulong FreeBytesAvailable; ulong TotalCapacity; ulong TotalFreeBytes; for (int i = 0; i &lt; directoryList.Length; ++i) { if ((directoryList.Attributes &amp; FileAttributes.Temporary) != 0) { GetDiskFreeSpaceEx(directoryList.FullName, out FreeBytesAvailable, out TotalCapacity, out TotalFreeBytes); Console.Out.WriteLine("Storage card name: {0}", directoryList.FullName); Console.Out.WriteLine("Available Bytes : {0}", FreeBytesAvailable); Console.Out.WriteLine("Total Capacity : {0}", TotalCapacity); Console.Out.WriteLine("Total Free Bytes : {0}", TotalFreeBytes); } } } } </code></pre>
<p>On Windows CE 5 (which is the base for Windows Mobile 6) the storage cards get mounted at the root file system as "Storage Card\", "Storage Card2\", etc.</p> <p>To find out if it's mounted call GetFileAttributes (or the remote version CeGetFileAttributes I believe) passing in the full path ("\Storage Card\"). If it returns INVALID_FILE_ATTRIBUTES then it's not mounted, otherwise check to make sure it's a directory before returning true.</p>
6,149
<p>What is the best way to authorize all users to one single page in a asp.net website.</p> <p>For except the login page and one other page, I deny all users from viewing pages in the website. </p> <p>How do you make this page accessible to all users?</p>
<p>I've been using forms authentication and creating the necessary GenericIdentity and CustomPrincipal objects that allows me to leverage the User.IsInRole type functions you typically only get with Windows authentication.</p> <p>That way in my web.config file, I can do stuff like...</p> <pre><code>&lt;location path="Login.aspx"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow users ="*" /&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; &lt;location path="ManagementFolder"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles ="Administrator, Manager" /&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; </code></pre>
<p>I created a base "page" class that handles that sort of thing. All my pages can then be decorated with the RequiresLogin attribute if a login is required to view them. If the attribute is not present, the page is accessible to all.</p> <p>Example:</p> <pre><code>&lt;RequiresLogin()&gt; _ &lt;RequiresPermission("process")&gt; _ Partial Class DesignReviewEditProgressPage Inherits MyPage 'which inherits System.Web.UI.Page and deal with logins itself ... End Class </code></pre> <p>The MyPage class checks what attributes are being tagged to itself and if RequiresLogin is present, it forwards you to a login page.</p> <p>I believe this could be adapted to fit your own problem.</p>
3,905
<p>my <b>SSRS DataSet</b> returns a field with HTML, e.g.</p> <pre><code>&lt;b&gt;blah blah &lt;/b&gt;&lt;i&gt; blah &lt;/i&gt;. </code></pre> <p>how do i strip all the HTML tags? has to be done with <b>inline</b> VB.NET</p> <p>Changing the data in the table is not an option.</p> <p><strong>Solution found</strong> ... = System.Text.RegularExpressions.Regex.Replace(StringWithHTMLtoStrip, "&lt;[^>]+>","")</p>
<p>Thanx to Daniel, but I needed it to be done inline ... here's the solution:</p> <p><code>= System.Text.RegularExpressions.Regex.Replace(StringWithHTMLtoStrip, "&lt;[^&gt;]+&gt;","")</code></p> <p>Here are the links:</p> <p><a href="http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx" rel="noreferrer">http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx</a><br> <a href="http://msdn.microsoft.com/en-us/library/ms157328.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms157328.aspx</a></p>
<p>If you know the HTML is well-formed enough, you could, if you make sure it has a root node, convert the data in that field into a System.Xml.XmlDocument and then get the InnerText value from it.</p> <p>Again, you will have to make sure the text has a root node, which you can add yourself if needs be, since it will not matter, and make sure the HTML is well formed.</p>
5,533
<p>As the question states, should <a href="https://3dprinting.stackexchange.com/questions/tagged/bed" class="post-tag" title="show questions tagged &#39;bed&#39;" rel="tag">bed</a> and <a href="https://3dprinting.stackexchange.com/questions/tagged/build-plate" class="post-tag" title="show questions tagged &#39;build-plate&#39;" rel="tag">build-plate</a> be merged? Basically, both tags refer to the same part of the printer; <a href="https://3dprinting.stackexchange.com/questions/tagged/bed" class="post-tag" title="show questions tagged &#39;bed&#39;" rel="tag">bed</a> should be a synonym for <a href="https://3dprinting.stackexchange.com/questions/tagged/build-plate" class="post-tag" title="show questions tagged &#39;build-plate&#39;" rel="tag">build-plate</a>.</p>
<p>It should not be about merging of tags, rather we should come up with a proper terminology to identify the correct parts of the &quot;build platform&quot;.</p> <p>Basically, every printer consists of a frame with some sort of guide rails<sup>1</sup> moving a carriage. On this carriage a build surface is attached where the printer prints the print on; it is always the top of the stack. Note that this can be e.g. a moving Y-axis<sup>2</sup> or moving Z-axis carriage<sup>3</sup>. In some cases the carriage is missing and there is just a static mounting, then it's a platform instead<sup>4</sup>. It is basically irrelevant if the build surface is glued to the stack or removeable in some way or another.</p> <p>Between the carriage and the build surface you can have have a stack of multiple elements: a structure or structures, a plate, plates or matts, insulation, etc. This <strong>whole</strong> assembly of elements make up the build platform, an example is shown below.</p> <p><a href="https://i.stack.imgur.com/M3xCs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M3xCs.png" alt="Proposed build platform terminology" /></a></p> <p>Note that the linear support can be mounted in Y or Z direction. To tag the elements that make up the <em>build platform assembly</em>, a proposed solution can consist of the following terms for subassemblies:</p> <ul> <li><a href="https://3dprinting.stackexchange.com/questions/tagged/z-axis" class="post-tag" title="show questions tagged &#39;z-axis&#39;" rel="tag">z-axis</a> or <a href="https://3dprinting.stackexchange.com/questions/tagged/y-axis" class="post-tag" title="show questions tagged &#39;y-axis&#39;" rel="tag">y-axis</a> in combination with <a href="https://3dprinting.stackexchange.com/questions/tagged/carriage" class="post-tag" title="show questions tagged &#39;carriage&#39;" rel="tag">carriage</a>,</li> <li><a href="https://3dprinting.stackexchange.com/questions/tagged/platform" class="post-tag" title="show questions tagged &#39;platform&#39;" rel="tag">platform</a> (to support printers that have a solid platform, e.g. Hyrel/Delta)</li> <li><a href="https://3dprinting.stackexchange.com/questions/tagged/heated-bed" class="post-tag" title="show questions tagged &#39;heated-bed&#39;" rel="tag">heated-bed</a> (aluminium bed or a silicone matt), which can have a</li> <li><a href="https://3dprinting.stackexchange.com/questions/tagged/glass-print-surface" class="post-tag" title="show questions tagged &#39;glass-print-surface&#39;" rel="tag">glass-print-surface</a>, <a href="https://3dprinting.stackexchange.com/questions/tagged/pei-print-surface" class="post-tag" title="show questions tagged &#39;pei-print-surface&#39;" rel="tag">pei-print-surface</a>, <a href="https://3dprinting.stackexchange.com/questions/tagged/buildtak-print-surface" class="post-tag" title="show questions tagged &#39;buildtak-print-surface&#39;" rel="tag">buildtak-print-surface</a>, etc. possibly augmented with the additional tag of <a href="https://3dprinting.stackexchange.com/questions/tagged/removeable-print-surface" class="post-tag" title="show questions tagged &#39;removeable-print-surface&#39;" rel="tag">removeable-print-surface</a> or <a href="https://3dprinting.stackexchange.com/questions/tagged/magnetic-print-surface" class="post-tag" title="show questions tagged &#39;magnetic-print-surface&#39;" rel="tag">magnetic-print-surface</a>.</li> </ul> <h2>Annotations</h2> <ol> <li>The rails often take the shape of rods and bearings, linear rails of V-slot profile.</li> <li>Carthesian Portal or Cantilever printers</li> <li>CoreXY like the Hypercube</li> <li>Delta Printers</li> </ol>
<h1>Edit: I like Trish's suggestion best.</h1> <p>I vote <strong>no</strong>. Our (Hyrel) printers have, on some models, a thick aluminum <a href="https://3dprinting.stackexchange.com/questions/tagged/bed" class="post-tag" title="show questions tagged &#39;bed&#39;" rel="tag">bed</a> that can reach 200C, but we expect users to mount different <a href="https://3dprinting.stackexchange.com/questions/tagged/build-plate" class="post-tag" title="show questions tagged &#39;build-plate&#39;" rel="tag">build-plate</a>s on it, depending on what material they're printing with. These can be coated with PEI, garolite, polycarbonate, or others; or they can be commercial build plates like GeckoTek or Anycubic Ultrabase.</p> <p>You heat the bed. You print on the build plate. In some cases, these may be a single item.</p>
74
<p>Do any editors honer C #line directives with regards to goto line features?</p> <p><em>Context:</em> I'm working on a code generator and need to jump to a line of the output but the line is specified relative to the the #line directives I'm adding. I can drop them but then finding the input line is even a worse pain</p>
<p>If the editor is scriptable it should be possible to write a script to do the navigation. There might even be a Vim or Emacs script that already does something similar.</p> <p>FWIW when I writing a lot of Bison/Flexx I wrote a <a href="http://www.zeusedit.com" rel="nofollow noreferrer">Zeus</a> Lua macro script that attempted to do something similar (i.e. move from input file to the corresponding line of the output file by search for the #line marker).</p> <p>For any one that might be interested <a href="http://www.zeusedit.com/forum/viewtopic.php?p=4065" rel="nofollow noreferrer">here is</a> that particular macro script.</p>
<p><code>#line</code> directives are normally inserted by the precompiler, not into source code, so editors won't usually honor that if the file extension is <code>.c</code>.</p> <p>However, the normal file extension for post-compiled files is <code>.i</code> or <code>.gch</code>, so you might try using that and see what happens.</p>
7,362
<p>In C# is there a shorthand way to write this:</p> <pre><code>public static bool IsAllowed(int userID) { return (userID == Personnel.JohnDoe || userID == Personnel.JaneDoe ...); } </code></pre> <p>Like:</p> <pre><code>public static bool IsAllowed(int userID) { return (userID in Personnel.JohnDoe, Personnel.JaneDoe ...); } </code></pre> <p>I know I could also use switch, but there are probably 50 or so functions like this I have to write (porting a classic ASP site over to ASP.NET) so I'd like to keep them as short as possible.</p>
<p>How about this?</p> <pre><code>public static class Extensions { public static bool In&lt;T&gt;(this T testValue, params T[] values) { return values.Contains(testValue); } } </code></pre> <p>Usage:</p> <pre><code>Personnel userId = Personnel.JohnDoe; if (userId.In(Personnel.JohnDoe, Personnel.JaneDoe)) { // Do something } </code></pre> <p>I can't claim credit for this, but I also can't remember where I saw it. So, credit to you, anonymous Internet stranger.</p>
<p>A nice little trick is to sort of reverse the way you usually use .Contains(), like:-</p> <pre><code>public static bool IsAllowed(int userID) { return new int[] { Personnel.JaneDoe, Personnel.JohnDoe }.Contains(userID); } </code></pre> <p>Where you can put as many entries in the array as you like.</p> <p>If the Personnel.x is an enum you'd have some casting issues with this (and with the original code you posted), and in that case it'd be easier to use:-</p> <pre><code>public static bool IsAllowed(int userID) { return Enum.IsDefined(typeof(Personnel), userID); } </code></pre>
5,293
<p>I am about to purchase a TronXY X3 or P802; but, my PC is running Windows 10.</p> <p>The spec sheet for the printers does not list anything above Windows 7. Is anyone using either of these printers with Windows 10?</p>
<p>Since the printer supports using an SD card, you don't <em>need</em> to connect it directly to a PC. Serial over USB has been broken in the past in various Win10 builds, I've not tried it recently and I've not tried connecting my A8 to my PC recently either.</p> <p>If you need to use USB, and can't make it work with Windows, there is always the option of using a Raspberry Pi single-board computer (which you can then connect to by VNC from your PC). Depending on the software you want to use, this might resolve any remaining issues you have.</p>
<p>For Windows 10 driver, go directly to the Microsoft update catalogue. <a href="https://www.catalog.update.microsoft.com/Search.aspx?q=USB%5CVID_1A86%26PID_7523" rel="nofollow noreferrer">https://www.catalog.update.microsoft.com/Search.aspx?q=USB%5CVID_1A86%26PID_7523</a></p> <p>Download the .cab file, extract the contents. Using Device Manager update the driver for the partially installed device. After the update TronXY-2 now appears as a COM port.</p>
550
<p>I'm setting up a dedicated SQL Server 2005 box on Windows Server 2008 this week, and would like to pare it down to be as barebones as possible while still being fully functional.</p> <p>To that end, the "Server Core" option sounds appealing, but I'm not clear about whether or not I can run SQL Server on that SKU. Several services are addressed on the <a href="http://www.microsoft.com/windowsserver2008/en/us/compare-core-installation.aspx" rel="noreferrer">Microsoft website</a>, but I don't see any indication about SQL Server.</p> <p>Does anyone know definitively?</p>
<p>Not sure how credible <a href="http://www.builderau.com.au/program/windows/soa/Getting-started-with-Windows-Server-2008-Core-edition/0,339024644,339288700,00.htm" rel="noreferrer">this source is</a>, but:</p> <blockquote> <p>The Windows Server 2008 Core edition can:</p> <ul> <li><p>Run the file server role.</p></li> <li><p>Run the Hyper-V virtualization server role.</p></li> <li><p>Run the Directory Services role.</p></li> <li><p>Run the DHCP server role.</p></li> <li><p>Run the IIS Web server role.</p></li> <li><p>Run the DNS server role.</p></li> <li><p>Run Active Directory Lightweight Directory Services.</p></li> <li><p>Run the print server role.</p></li> </ul> <p>The Windows Server 2008 Core edition cannot:</p> <ul> <li><p>Run a SQL Server.</p></li> <li><p>Run an Exchange Server.</p></li> <li><p>Run Internet Explorer.</p></li> <li><p>Run Windows Explorer.</p></li> <li><p>Host a remote desktop session.</p></li> <li><p>Run MMC snap-in consoles locally.</p></li> </ul> </blockquote>
<p>Server Core won't be very useful (to me at least, and I think many others as well) until they get a version of .Net framework on it. Maybe a specialized subset like they have in the Compact Framework on smart phones.</p>
2,379
<p>My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time.</p> <p>However, for reasons I won't go into here it can sometimes be <em>very</em> important that we don't interrupt a Mongrel while it is servicing a request, so I assume a simple process kill isn't the answer.</p> <p>Ideally, I want to send the Mongrel a signal that says "finish whatever you're doing and then quit before accepting any more connections".</p> <p>Is there a standard technique or best practice for this?</p>
<p>I've done a little more investigation into the Mongrel source and it turns out that Mongrel installs a signal handler to catch an standard process kill (TERM) and do a graceful shutdown, so I don't need a special procedure after all.</p> <p>You can see this working from the log output you get when killing a Mongrel while it's processing a request. For example:</p> <pre><code>** TERM signal received. Thu Aug 28 00:52:35 +0000 2008: Reaping 2 threads for slow workers because of 'shutdown' Waiting for 2 requests to finish, could take 60 seconds.Thu Aug 28 00:52:41 +0000 2008: Reaping 2 threads for slow workers because of 'shutdown' Waiting for 2 requests to finish, could take 60 seconds.Thu Aug 28 00:52:43 +0000 2008 (13051) Rendering layoutfalsecontent_typetext/htmlactionindex within layouts/application </code></pre>
<p>Try using:</p> <pre><code>mongrel_cluster_ctl stop </code></pre> <p>You can also use:</p> <pre><code>mongrel_cluster_ctl restart </code></pre>
4,740
<p>Documentation is severely lacking on anything to do with stored procedures in mysql with PHP. I currently have a stored procedure that I call via PHP, how can I get the value of an out parameter?</p>
<p>it looks like it's answered in this post:</p> <p><a href="http://forums.mysql.com/read.php?52,198596,198717#msg-198717" rel="noreferrer">http://forums.mysql.com/read.php?52,198596,198717#msg-198717</a></p> <p>With mysqli PHP API: </p> <p>Assume sproc myproc( IN i int, OUT j int ): </p> <pre><code>$mysqli = new mysqli( "HOST", "USR", "PWD", "DBNAME" ); $ivalue=1; $res = $mysqli-&gt;multi_query( "CALL myproc($ivalue,@x);SELECT @x" ); if( $res ) { $results = 0; do { if ($result = $mysqli-&gt;store_result()) { printf( "&lt;b&gt;Result #%u&lt;/b&gt;:&lt;br/&gt;", ++$results ); while( $row = $result-&gt;fetch_row() ) { foreach( $row as $cell ) echo $cell, "&amp;nbsp;"; } $result-&gt;close(); if( $mysqli-&gt;more_results() ) echo "&lt;br/&gt;"; } } while( $mysqli-&gt;next_result() ); } $mysqli-&gt;close(); </code></pre>
<p>Here's an example of how to do this with mysql, mysqli, and pdo:</p> <p><a href="http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/" rel="noreferrer">http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/</a></p>
7,050
<p>I have a concept that's roughly 18"x30" (about 457x762 mm), and I just realized that the Makerbot and similar printers only allow dimensions around the size of a piece of paper. What are other options? Are there large 3D printers I just don't know about? I looked up TMC injection mold, but couldn't find anything on size (most links go to PDFs with printer images). </p> <p>Is injection even in the same "world" as 3D..? Sorry for confusing the two.</p>
<p>As Trish states, a print service would appear to be your best bet. Building a printer large enough may work out costing more than the print service, especially if it is only for one print of a proof of concept.</p> <p>Anecdotally, I visited a 3D Printing shop in Bangkok, <a href="http://jwh3dprinting.com/english/our-shop/our-shop.html" rel="noreferrer">JWH High tech Garden</a>, that had a <em>huge</em> Delta printer that had, reputably, cost a million baht (~£20000) if my memory serves me correctly, and was capable of producing prints up to 1000 mm x 600 mm (39.37" x 23.62"):</p> <p><a href="https://i.stack.imgur.com/tAN8o.jpg" rel="noreferrer" title="Large Delta printer"><img src="https://i.stack.imgur.com/tAN8o.jpg" alt="Large Delta printer" title="Large Delta printer"></a></p> <p>However, the print service was not cheap at all. In May 2017, I was quoted 68000-100000 baht (~£1360-2000) for some printed parts (the proteins) for a Wilson II 3D printer, which are about only £70 on eBay!</p> <p><a href="https://i.stack.imgur.com/fpqlJ.jpg" rel="noreferrer" title="Wilson II proteins"><img src="https://i.stack.imgur.com/fpqlJ.jpg" alt="Wilson II proteins" title="Wilson II proteins"></a></p> <p>However, it is worth taking into consideration that, at the moment, Thailand is very expensive for 3D printing in general, as it is relatively new there, and so prices for both printers and print services are high.</p>
<h1>Yes<sup>If you have the money</sup></h1> <p>Either read <a href="https://all3dp.com/1/best-large-3d-printer-large-format-scale-3d-printers/#section-best-large-3d-printers-under-1000" rel="nofollow noreferrer">here</a> or look at the ones I plucked out of that list to show you:</p> <p>First of all, 3D printers on FDM basis can become quite large, if you pay extra. And the price goes up really fast as the dimensions grow because the demands on stability grow exponentially.</p> <h1>Larger Printers?</h1> <p>One example of a &quot;scaling&quot; printer family is the CR-10: The baseline CR-10 is about 300x300x400 mm, so about 12x12x16 inch for 400\$. Not enough? 400x400x400 on the CR-10 S4 for ca 760\$. 500x500x500 on the CR-10 S5 for 900\$. That's 20 inch in all directions. But that's still not enough, isn't it? Well, if you need to go larger, you need to go professional...</p> <h1>Going Big!</h1> <p>Well, there are printers like the gCreate gMax 1.5 XT+ (406x406x533 mm) for a mere 3000\$. That's enough, isn't it? Well, we can even go <em>bigger</em>: 610x610x610 mm for a mere 3500\$ on the Modix Big 60.</p> <p>Still not satisfied? Industrial machines can go even larger! A BigRep Studio for the <em>little</em> price of 50000\$ could achieve 500x1000x500 mm.</p> <h1>Even more? Go Parametric!</h1> <p>As amra mentioned, the <a href="https://en.wikipedia.org/wiki/Hangprinter" rel="nofollow noreferrer">Hangpringer</a> project of printers has no &quot;set&quot; build size, but you will have to provide a build platform of fitting size and a room it can work in undisturbed and with filament supply ready... just... bring a ladder? And be wary of people tripping over wires... and somehow find a ginormous, evenly heated bed somewhere...</p> <h1>Ways around</h1> <h2>Assembly</h2> <p>That is a little overkill, isn't it? Well, the first thing you need to remember when 3D printing is: unless you make a functional part that has to have certain dimensions, feel free to scale it down if it is just for visuals. Then, you can assemble prints. Like, take a smaller printer and print the object in halves or quarters. Then glue it back together.</p> <h2>Order</h2> <p>You don't want or can't assemble the part? Well, there are printing services out there that have these larger scale printers I mentioned (or at least similar ones) that offer to make your parts for you and then ship them to you. Usually, that is much more cost effective than buying one of these ginormous printers yourself.</p>
1,054
<p>For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this?</p>
<p><code>ICriteria</code> has a <code>SetFirstResult(int i)</code> method, which indicates the index of the first item that you wish to get (basically the first data row in your page). </p> <p>It also has a <code>SetMaxResults(int i)</code> method, which indicates the number of rows you wish to get (i.e., your page size).</p> <p>For example, this criteria object gets the first 10 results of your data grid:</p> <pre><code>criteria.SetFirstResult(0).SetMaxResults(10); </code></pre>
<p>You don't need to define 2 criterias, you can define one and clone it. To clone nHibernate criteria you can use a simple code:</p> <pre><code>var criteria = ... (your criteria initializations)...; var countCrit = (ICriteria)criteria.Clone(); </code></pre>
7,835