instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I'm writing a simple app that's going to have a tiny form sitting in one corner of the screen, updating itself.</p> <p>I'd really love for that form to be transparent and to have the transparency be user-configurable.</p> <p>Is there any easy way to achieve this?</p>
<p>You could try using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.opacity.aspx" rel="nofollow noreferrer">Opacity</a> property of the Form. Here's the relevant snippet from the MSDN page:</p> <pre><code>private Sub CreateMyOpaqueForm() ' Create a new form. Dim form2 As New Form() ' Set the text displayed in the caption. form2.Text = "My Form" ' Set the opacity to 75%. form2.Opacity = 0.75 ' Size the form to be 300 pixels in height and width. form2.Size = New Size(300, 300) ' Display the form in the center of the screen. form2.StartPosition = FormStartPosition.CenterScreen ' Display the form as a modal dialog box. form2.ShowDialog() End Sub </code></pre>
<p>You can set the <code>Form.Opacity</code> property. It should do what you want.</p>
5,716
<p>I like a bit of TiVo hacking in spare time - TiVo uses a Linux variant and <a href="http://wiki.tcl.tk/299" rel="nofollow noreferrer">TCL</a>. I'd like to write TCL scripts on my Windows laptop, test them and then FTP them over to my TiVo.</p> <p>Can I have a recommendation for a TCL debugging environment for Windows, please?</p>
<p>Komodo from Activestate is a good IDE for Windows/Linux. There is a trial version - I am not sure if there is a free version after trial though.</p>
<p>ActiveState has a Tcl development kit (not free, but cheap) that I've used in the past. It even worked with our embedded tcl interpreter.</p> <p><a href="http://www.activestate.com/tcl_dev_kit/" rel="nofollow noreferrer">http://www.activestate.com/tcl_dev_kit/</a></p>
3,895
<p>Would like to hear from people about their experience with java clustering (ie. implementing HA solutions). aka . terracotta, JGroups etc. It doesn't have to be web apps. Experience writing custom stand alone servers would be great also.</p> <p><strong>UPDATE</strong> : I will be a bit more specific -> not that interested in Web App clustering (unless it can be pulled out and run standalone). I know it works. But we need a bit more than just session clustering. Examining solutions in terms of ease of programming, supported topologies (ie. single data center versus over the WAN ), number of supported nodes. Issues faced, workarounds. At the moment I am doing some POC (Proof of concept) work on Terracotta and JGroups to see if its worth the effort for our app (which is stand alone, outside of a web container). ­­­­­­­­­­­­­­­­­­­­</p>
<p><a href="http://docs.jboss.org/jbossas/jboss4guide/r4/html/cluster.chapt.html" rel="nofollow noreferrer">Jboss clustering</a> was very easy to get up and running. </p> <p>It seems to work well for us.</p>
<p>JBossCache is a standalone open source project that JbossClustering makes use of in the Application Server.</p> <p>Our company made use of it in our own custom network server, its working well so far in development, though yet to be deployed. </p> <p>Its a pretty simple API, and it comes in two flavors, a flat cache, or a "POJO Cache" that uses insturmentation to keep State across servers. Basically, updates to fields are propgated across the network using JGroups.</p>
5,032
<p>I am wanting to use ActiveScaffold to create <em>assignment</em> records for several <em>students</em> in a single step. The records will all contain identical data, with the exception of the student_id.</p> <p>I was able to override the default form and replace the dropdown box for selecting the student name with a multi-select box - which is what I want. That change however, was only cosmetic, as the underlying code only grabs the first selected name from that box, and creates a single record.</p> <p>Can somebody suggest a good way to accomplish this in a way that doesn't require my deciphering and rewriting too much of the underlying ActiveScaffold code?</p> <hr> <p>Update: I still haven't found a good answer to this problem.</p>
<p>I suppose you have defined your multi-select box adding :multiple => true to html parameters of select_tag. Then, in the controller, you need to access the list of names selected, what you can do like this:</p> <pre><code>params[:students].collect{|student| insert_student(student, params[:assignment_id]) } </code></pre> <p>With collect applied to an array or enum you can loop through each item of that array, and then do what you need with each student (in the example, to call a function for insert the students). Collect returns an array with the results of doing the code inside.</p>
<p>if your assingnments have <code>has_many :students</code> or <code>has_and_belongs_to_many :students</code>, then you can change the id of the multi-select box to assignment_student_ids[], and it should work.</p>
8,479
<p>I haven't seen any questions relating to GNU autoconf/automake builds, but I'm hoping at least some of you out there are familiar with it. Here goes:</p> <p>I have a project (I'll call it myproject) that includes another project (vendor). The vendor project is a standalone project maintained by someone else. Including a project like this is fairly <a href="http://www.gnu.org/software/autoconf/manual/autoconf.html#Subdirectories" rel="nofollow noreferrer">straightforward</a>, but in this case there is a tiny snag: each project generates its own <code>config.h</code> file, each of which defines standard macros such as PACKAGE, VERSION, etc. This means that, during the build, when vendor is being built, I get lots of errors like this:</p> <pre><code>... warning: "VERSION" redefined ... warning: this is the location of the previous definition ... warning: "PACKAGE" redefined ... warning: this is the location of the previous definition </code></pre> <p>These are just warnings, for the time being at least, but I would like to get rid of them. The only relevant information I've been able to turn up with a Google search is <a href="http://sourceware.org/ml/automake/2004-03/msg00130.html" rel="nofollow noreferrer">this</a> thread on the automake mailing list, which isn't a whole lot of help. Does anybody else have any better ideas?</p>
<p>Some notes:</p> <ul> <li>you didn't mention how <code>config.h</code> was included - with quotes or angle brackets. See <a href="https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename">this other question</a> for more information on the difference. In short, <code>config.h</code> is typically included with quotes, not angle brackets, and this should make the preprocessor prefer the <code>config.h</code> from the project's own directory (which is usually what you want)</li> <li>You say that a subproject should be including the enclosing project's <code>config.h</code> Normally this is not at all what you want. The subproject is standalone, and its PACKAGE and VERSION should be the one of that subproject, not yours. If you include libxml in your xmlreader project for example, you would still want the libxml code to be compiled with PACKAGE libxml and VERSION (whatever the libxml version is).</li> <li>It is usually a big mistake to have <code>config.h</code> be included from public headers. <code>config.h</code> is always private to your project or the subproject, and should only be included from .c files. So, if your vendor's documentation says to include their "vendor.h" and that public header includes <code>config.h</code> somehow, then that is a no-no. Similarly, if your project is a library, don't include <code>config.h</code> anywhere from your publically installed headers.</li> </ul>
<p>It turns out there was a very simple solution in my case. The vendor project gathers several header files into one monolithic header file, which is then <code>#include</code>d by the vendor sources. But the make rule that builds the monolithic header accidentally included the generated <code>config.h</code>. The presence of the PACKAGE, VERSION, etc. config variables in the monolithic header is what was causing the redefinition warnings. It turns out that the vendor's <code>config.h</code> was irrelevant, because "config.h" always resolved to <code>$(top_builddir)/config.h</code>.</p> <p>I believe this is the way it's supposed to work. By default a subproject should be including the enclosing project's <code>config.h</code> instead of its own, unless the subproject explicitly includes its own, or manipulates the INCLUDE path so that its own directory comes before <code>$(top_builddir)</code>, or otherwise manipulates the header files as in my case.</p>
2,897
<p>I remember first learning about vectors in the STL and after some time, I wanted to use a vector of bools for one of my projects. After seeing some strange behavior and doing some research, I learned that <a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=98" rel="noreferrer">a vector of bools is not really a vector of bools</a>.</p> <p>Are there any other common pitfalls to avoid in C++?</p>
<p>A short list might be:</p> <ul> <li>Avoid memory leaks through use shared pointers to manage memory allocation and cleanup</li> <li>Use the <a href="https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="noreferrer">Resource Acquisition Is Initialization</a> (RAII) idiom to manage resource cleanup - especially in the presence of exceptions</li> <li>Avoid calling virtual functions in constructors</li> <li>Employ minimalist coding techniques where possible - for example, declaring variables only when needed, scoping variables, and early-out design where possible. </li> <li>Truly understand the exception handling in your code - both with regard to exceptions you throw, as well as ones thrown by classes you may be using indirectly. This is especially important in the presence of templates.</li> </ul> <p>RAII, shared pointers and minimalist coding are of course not specific to C++, but they help avoid problems that do frequently crop up when developing in the language. </p> <p>Some excellent books on this subject are:</p> <ul> <li>Effective C++ - Scott Meyers</li> <li>More Effective C++ - Scott Meyers</li> <li>C++ Coding Standards - Sutter &amp; Alexandrescu</li> <li>C++ FAQs - Cline</li> </ul> <p>Reading these books has helped me more than anything else to avoid the kind of pitfalls you are asking about.</p>
<pre><code>#include &lt;boost/shared_ptr.hpp&gt; class A { public: void nuke() { boost::shared_ptr&lt;A&gt; (this); } }; int main(int argc, char** argv) { A a; a.nuke(); return(0); } </code></pre>
5,029
<p>I want to move various parts of my app into simple scripts, to allow people that do not have a strong knowledge of c++ to be able to edit and implement various features.</p> <p>Because it's a real time app, I need to have some kind of multitasking for these scripts. Ideally I want it so that the c++ app calls a script function which then continues running (under the c++ thread) until either a pause point (Wait(x)), or it returns. In the case of it waiting the state needs to be saved ready for the script to be restarted the next time the app loops after the duration has expired.</p> <p>The scripts also need to be able to call c++ class methods, ideally using the c++ classes rather than plain wrapper functions around c++ classes.</p> <p>I don't want to spend a massive amount of time implementing this, so using an existing scripting language is preferred to writing my own. I heard that Python and Lua can be integrated into a c++ app, but I do not know how to do this to achieve my goals.</p> <ul> <li>The scripts must be able to call c++ functions</li> <li>The scripts must be able to "pause" when certain functions are called (eg. Wait), and be restarted again by the c++ thread</li> <li>Needs to be fast -- this is for a real time app and there could potentially be a lot of scripts running.</li> </ul> <p>I can probably roll the multitasking code fairly easily, provided the scripts can be saved and restarted (possibly by a different thread to the original).</p>
<p>You can use either Lua or Python. Lua is more "lightweight" than python. It's got a smaller memory footprint than python does and in our experience was easier to integrate (people's mileage on this point might vary). It can support a bunch of scripts running simultaneously. Lua, at least, supports stopping/starting threads in the manner you desire.</p> <p>Boost.python is nice, but in my (limited) experience, it was difficult for us to get compiling for our different environments and was pretty heavyweight. It has (in my opinion) the disadvantage of requiring Boost. For some, that might not be a problem, but if you don't need Boost (or are not using it), you are introducing a ton of code to get Boost.python working. YMMV.</p> <p>We have built Lua into apps on multiple platforms (win32, Xbox360 and PS3). I believe that it will work on x64. The suggestion to use Luabind is good. We wound up writing our own interface between the two and while not too complicated, having that glue code will save you a lot of time and perhaps aggravation.</p> <p>With either solution though, debugging can be a pain. We currently have no good solution for debugging Lua scripts that are embedded into our app. Since we haven't used python in our apps I can't speak to what tools might be available there, but a couple of years ago the landscape was roughly the same -- poor debugging. Having scripting to extend functionality is nice, but bugs in the scripts can cause problems and might be difficult to locate.</p> <p>The Lua code itself is kind of messy to work with if you need to make changes there. We have seen bugs in the Lua codebase itself that were hard to track down. I suspect that Boost::Python might have similar problems.</p> <p>And with any scripting language, it's not necessarily a solution for "non-programmers" to extend functionality. It might seem like it, but you will likely wind up spending a fair amount of time either debugging scripts or even perhaps Lua.</p> <p>That all said, we've been very happy with Lua and have shipped it in two games. We currently have no plans to move away from the language. All in all, we've found it better than other alternatives that were available a couple of years ago. Python (and IronPython) are other choices, but based on experience, they seem more heavy handed than Lua. I'd love to hear about other experiences there though.</p>
<p>You can also embed C/C++ scripts using <a href="http://softintegration.com/" rel="nofollow noreferrer">Ch</a>. I've been using it for a game project I'm working on, and it does well. Nice blend of power and adaptability.</p>
8,923
<p>Are there any open source (or I guess commercial) packages that you can plug into your site for monitoring purposes? I'd like something that we can hook up to our ASP.NET site and use to provide reporting on things like:</p> <ul> <li>performance over time</li> <li>current load</li> <li>page traffic</li> <li>SQL performance</li> <li>PU time monitoring </li> </ul> <p>Ideally in c# :)</p> <p>With some sexy graphs.</p> <p><strong>Edit</strong>: I'd also be happy with a package that I can feed statistics and views of data to, and it would analyse trends, spot abnormal behaviour (e.g. "no one has logged in for the last hour. is this Ok?", "high traffic levels detected", "low number of API calls detected") and generally be very useful indeed. Does such a thing exist?</p> <p>At my last office we had a big screen which showed us loads and loads of performance counters over a couple of time ranges, and we could spot weird stuff happening, but the data was not stored and there was no way to report on it. Its a package for doing this that I'm after.</p>
<p>It should be noted that google analytics is not an accurate representation of web site usage. This is because the web beacon (web bug) used on the page does not always load for these reasons:</p> <ol> <li>Google analytics servers are called by millions of pages every second and can not always process the requests in a timely fashion.</li> <li>Users often browse away from a page before the full page has loaded and thus there is not enough time to load Googles web beacon to record a hit.</li> <li>Google analytics require javascript to be installed which can be disabled.</li> <li>Quite a few (but not substantial amount) of people block google-analytics.com from their browsers, myself included.</li> </ol> <p>The physical log files are the best 'real' representation of site usage as they record every request. Alternatively there are far better 'professional' packages, of which Omniture is my favourite, which have much better response times, alternative methods for recording actions and more functionality.</p>
<p><a href="http://google.com/analytics" rel="nofollow noreferrer">Google Analytics</a> is free (up to 50,000 hits per month I think) and is easy to setup with just a little javascript snippet to insert into your header or footer and has great detailed reports, with some very nice graphs.</p>
3,869
<p>Anyone know if it's possible to databind the ScaleX and ScaleY of a render transform in Silverlight 2 Beta 2? Binding transforms is possible in WPF - But I'm getting an error when setting up my binding in Silverlight through XAML. Perhaps it's possible to do it through code?</p> <pre><code>&lt;Image Height="60" HorizontalAlignment="Right" Margin="0,122,11,0" VerticalAlignment="Top" Width="60" Source="Images/Fish128x128.png" Stretch="Fill" RenderTransformOrigin="0.5,0.5" x:Name="fishImage"&gt; &lt;Image.RenderTransform&gt; &lt;TransformGroup&gt; &lt;ScaleTransform ScaleX="1" ScaleY="1"/&gt; &lt;SkewTransform/&gt; &lt;RotateTransform/&gt; &lt;TranslateTransform/&gt; &lt;/TransformGroup&gt; &lt;/Image.RenderTransform&gt; &lt;/Image&gt; </code></pre> <p>I want to bind the ScaleX and ScaleY of the ScaleTransform element.</p> <p>I'm getting a runtime error when I try to bind against a double property on my data context: </p> <pre><code>Message="AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 1570 Position: 108]" </code></pre> <p>My binding looks like this:</p> <pre><code>&lt;ScaleTransform ScaleX="{Binding Path=SelectedDive.Visibility}" ScaleY="{Binding Path=SelectedDive.Visibility}"/&gt; </code></pre> <p>I have triple verified that the binding path is correct - I'm binding a slidebar against the same value and that works just fine...</p> <p>Visibility is of type double and is a number between 0.0 and 30.0. I have a value converter that scales that number down to 0.5 and 1 - I want to scale the size of the fish depending on the clarity of the water. So I don't think it's a problem with the type I'm binding against...</p>
<p>ScaleTransform doesn't have a data context so most likely the binding is looking for SelectedDive.Visibility off it's self and not finding it. There is much in Silverlight xaml and databinding that is different from WPF... </p> <p>Anyway to solve this you will want to set up the binding in code**, or manually listen for the PropertyChanged event of your data object and set the Scale in code behind.</p> <p>I would choose the latter if you wanted to do an animation/storyboard for the scale change.</p> <p>** i need to check but you may not be able to bind to it. as i recall if the RenderTransform is not part of an animation it gets turned into a matrix transform and all bets are off. </p>
<p>Ah I think I see your problem. You're attempting to bind a property of type Visibility (SelectedDive.Visibility) to a property of type Double (ScaleTransform.ScaleX). WPF/Silverlight can't convert between those two types.</p> <p>What are you trying to accomplish? Maybe I can help you with the XAML. What is "SelectedDive" and what do you want to happen when its Visibility changes?</p>
4,697
<p>I am receiving SOAP requests from a client that uses the Axis 1.4 libraries. The requests have the following form:</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;soapenv:Body&gt; &lt;PlaceOrderRequest xmlns="http://example.com/schema/order/request"&gt; &lt;order&gt; &lt;ns1:requestParameter xmlns:ns1="http://example.com/schema/common/request"&gt; &lt;ns1:orderingSystemWithDomain&gt; &lt;ns1:orderingSystem&gt;Internet&lt;/ns1:orderingSystem&gt; &lt;ns1:domainSign&gt;2&lt;/ns1:domainSign&gt; &lt;/ns1:orderingSystemWithDomain&gt; &lt;/ns1:requestParameter&gt; &lt;ns2:directDeliveryAddress ns2:addressType="0" ns2:index="1" xmlns:ns2="http://example.com/schema/order/request"&gt; &lt;ns3:address xmlns:ns3="http://example.com/schema/common/request"&gt; &lt;ns4:zipcode xmlns:ns4="http://example.com/schema/common"&gt;12345&lt;/ns4:zipcode&gt; &lt;ns5:city xmlns:ns5="http://example.com/schema/common"&gt;City&lt;/ns5:city&gt; &lt;ns6:street xmlns:ns6="http://example.com/schema/common"&gt;Street&lt;/ns6:street&gt; &lt;ns7:houseNum xmlns:ns7="http://example.com/schema/common"&gt;1&lt;/ns7:houseNum&gt; &lt;ns8:country xmlns:ns8="http://example.com/schema/common"&gt;XX&lt;/ns8:country&gt; &lt;/ns3:address&gt; [...] </code></pre> <p>As you can see, several prefixes are defined for the same namespace, e.g. the namespace <a href="http://example.com/schema/common" rel="noreferrer">http://example.com/schema/common</a> has the prefixes ns4, ns5, ns6, ns7 and ns8. Some long requests define several hundred prefixes for the same namespace.</p> <p>This causes a problem with the <a href="http://saxon.sourceforge.net/" rel="noreferrer">Saxon</a> XSLT processor, that I use to transform the requests. Saxon limits the the number of different prefixes for the same namespace to 255 and throws an exception when you define more prefixes.</p> <p>Can Axis 1.4 be configured to define smarter prefixes, so that there is only one prefix for each namespace?</p>
<p>I have the same issue. For the moment, I've worked around it by writing a BasicHandler extension, and then walking the SOAPPart myself and moving the namespace reference up to a parent node. I don't <em>like</em> this solution, but it does seem to work.</p> <p>I really hope somebody comes along and tells us what we have to do.</p> <p><strong><em>EDIT</em></strong></p> <p>This is way too complicated, and like I said, I don't like it at all, but here we go. I actually broke the functionality into a few classes (This wasn't the only manipulation that we needed to do in that project, so there were other implementations) I really hope that somebody can fix this soon. This uses dom4j to process the XML passing through the SOAP process, so you'll need dom4j to make it work.</p> <pre><code>public class XMLManipulationHandler extends BasicHandler { private static Log log = LogFactory.getLog(XMLManipulationHandler.class); private static List processingHandlers; public static void setProcessingHandlers(List handlers) { processingHandlers = handlers; } protected Document process(Document doc) { if (processingHandlers == null) { processingHandlers = new ArrayList(); processingHandlers.add(new EmptyProcessingHandler()); } log.trace(processingHandlers); treeWalk(doc.getRootElement()); return doc; } protected void treeWalk(Element element) { for (int i = 0, size = element.nodeCount(); i &lt; size; i++) { Node node = element.node(i); for (int handlerIndex = 0; handlerIndex &lt; processingHandlers.size(); handlerIndex++) { ProcessingHandler handler = (ProcessingHandler) processingHandlers.get(handlerIndex); handler.process(node); } if (node instanceof Element) { treeWalk((Element) node); } } } public void invoke(MessageContext context) throws AxisFault { if (!context.getPastPivot()) { SOAPMessage message = context.getMessage(); SOAPPart soapPart = message.getSOAPPart(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { message.writeTo(baos); baos.flush(); baos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); SAXReader saxReader = new SAXReader(); Document doc = saxReader.read(bais); doc = process(doc); DocumentSource ds = new DocumentSource(doc); soapPart.setContent(ds); message.saveChanges(); } catch (Exception e) { throw new AxisFault("Error Caught processing document in XMLManipulationHandler", e); } } } } </code></pre> <pre><code>public interface ProcessingHandler { public Node process(Node node); } </code></pre> <pre><code>public class NamespaceRemovalHandler implements ProcessingHandler { private static Log log = LogFactory.getLog(NamespaceRemovalHandler.class); private Namespace namespace; private String targetElement; private Set ignoreElements; public NamespaceRemovalHandler() { ignoreElements = new HashSet(); } public Node process(Node node) { if (node instanceof Element) { Element element = (Element) node; if (element.isRootElement()) { // Evidently, we never actually see the root node when we're called from // SOAP... } else { if (element.getName().equals(targetElement)) { log.trace("Found the target Element. Adding requested namespace"); Namespace already = element.getNamespaceForURI(namespace.getURI()); if (already == null) { element.add(namespace); } } else if (!ignoreElements.contains(element.getName())) { Namespace target = element.getNamespaceForURI(namespace.getURI()); if (target != null) { element.remove(target); element.setQName(new QName(element.getName(), namespace)); } } Attribute type = element.attribute("type"); if (type != null) { log.trace("Replacing type information: " + type.getText()); String typeText = type.getText(); typeText = typeText.replaceAll("ns[0-9]+", namespace.getPrefix()); type.setText(typeText); } } } return node; } public Namespace getNamespace() { return namespace; } public void setNamespace(Namespace namespace) { this.namespace = namespace; } /** * @return the targetElement */ public String getTargetElement() { return targetElement; } /** * @param targetElement the targetElement to set */ public void setTargetElement(String targetElement) { this.targetElement = targetElement; } /** * @return the ignoreElements */ public Set getIgnoreElements() { return ignoreElements; } /** * @param ignoreElements the ignoreElements to set */ public void setIgnoreElements(Set ignoreElements) { this.ignoreElements = ignoreElements; } public void addIgnoreElement(String element) { this.ignoreElements.add(element); } } </code></pre> <p>No warranty, etc, etc.</p>
<p>Alter your client's wsdd to set <code>enableNamespacePrefixOptimization</code> to <code>true</code></p> <pre><code>&lt;globalConfiguration &gt; &lt;parameter name="enableNamespacePrefixOptimization" value="true"/&gt; </code></pre>
8,791
<p>Most people with a degree in CS will certainly know what <a href="http://www.nist.gov/dads/HTML/bigOnotation.html" rel="noreferrer">Big O stands for</a>. It helps us to measure how well an algorithm scales. </p> <p>But I'm curious, how do <em>you</em> calculate or approximate the complexity of your algorithms?</p>
<p>I'll do my best to explain it here on simple terms, but be warned that this topic takes my students a couple of months to finally grasp. You can find more information on the Chapter 2 of the <a href="https://rads.stackoverflow.com/amzn/click/com/0321370139" rel="noreferrer" rel="nofollow noreferrer">Data Structures and Algorithms in Java</a> book.</p> <hr> <p>There is no <a href="http://en.wikipedia.org/wiki/Halting_problem" rel="noreferrer">mechanical procedure</a> that can be used to get the BigOh.</p> <p>As a "cookbook", to obtain the <a href="http://en.wikipedia.org/wiki/Big_Oh_notation" rel="noreferrer">BigOh</a> from a piece of code you first need to realize that you are creating a math formula to count how many steps of computations get executed given an input of some size.</p> <p>The purpose is simple: to compare algorithms from a theoretical point of view, without the need to execute the code. The lesser the number of steps, the faster the algorithm.</p> <p>For example, let's say you have this piece of code:</p> <pre><code>int sum(int* data, int N) { int result = 0; // 1 for (int i = 0; i &lt; N; i++) { // 2 result += data[i]; // 3 } return result; // 4 } </code></pre> <p>This function returns the sum of all the elements of the array, and we want to create a formula to count the <a href="http://en.wikipedia.org/wiki/Computational_complexity_theory" rel="noreferrer">computational complexity</a> of that function:</p> <pre><code>Number_Of_Steps = f(N) </code></pre> <p>So we have <code>f(N)</code>, a function to count the number of computational steps. The input of the function is the size of the structure to process. It means that this function is called such as:</p> <pre><code>Number_Of_Steps = f(data.length) </code></pre> <p>The parameter <code>N</code> takes the <code>data.length</code> value. Now we need the actual definition of the function <code>f()</code>. This is done from the source code, in which each interesting line is numbered from 1 to 4.</p> <p>There are many ways to calculate the BigOh. From this point forward we are going to assume that every sentence that doesn't depend on the size of the input data takes a constant <code>C</code> number computational steps.</p> <p>We are going to add the individual number of steps of the function, and neither the local variable declaration nor the return statement depends on the size of the <code>data</code> array.</p> <p>That means that lines 1 and 4 takes C amount of steps each, and the function is somewhat like this:</p> <pre><code>f(N) = C + ??? + C </code></pre> <p>The next part is to define the value of the <code>for</code> statement. Remember that we are counting the number of computational steps, meaning that the body of the <code>for</code> statement gets executed <code>N</code> times. That's the same as adding <code>C</code>, <code>N</code> times:</p> <pre><code>f(N) = C + (C + C + ... + C) + C = C + N * C + C </code></pre> <p>There is no mechanical rule to count how many times the body of the <code>for</code> gets executed, you need to count it by looking at what does the code do. To simplify the calculations, we are ignoring the variable initialization, condition and increment parts of the <code>for</code> statement.</p> <p>To get the actual BigOh we need the <a href="http://en.wikipedia.org/wiki/Asymptotic_analysis" rel="noreferrer">Asymptotic analysis</a> of the function. This is roughly done like this:</p> <ol> <li>Take away all the constants <code>C</code>.</li> <li>From <code>f()</code> get the <a href="http://en.wikipedia.org/wiki/Polynomial" rel="noreferrer">polynomium</a> in its <code>standard form</code>.</li> <li>Divide the terms of the polynomium and sort them by the rate of growth.</li> <li>Keep the one that grows bigger when <code>N</code> approaches <code>infinity</code>.</li> </ol> <p>Our <code>f()</code> has two terms:</p> <pre><code>f(N) = 2 * C * N ^ 0 + 1 * C * N ^ 1 </code></pre> <p>Taking away all the <code>C</code> constants and redundant parts:</p> <pre><code>f(N) = 1 + N ^ 1 </code></pre> <p>Since the last term is the one which grows bigger when <code>f()</code> approaches infinity (think on <a href="http://en.wikipedia.org/wiki/Limit_%28mathematics%29" rel="noreferrer">limits</a>) this is the BigOh argument, and the <code>sum()</code> function has a BigOh of:</p> <pre><code>O(N) </code></pre> <hr> <p>There are a few tricks to solve some tricky ones: use <a href="http://en.wikipedia.org/wiki/Summation" rel="noreferrer">summations</a> whenever you can.</p> <p>As an example, this code can be easily solved using summations:</p> <pre><code>for (i = 0; i &lt; 2*n; i += 2) { // 1 for (j=n; j &gt; i; j--) { // 2 foo(); // 3 } } </code></pre> <p>The first thing you needed to be asked is the order of execution of <code>foo()</code>. While the usual is to be <code>O(1)</code>, you need to ask your professors about it. <code>O(1)</code> means (almost, mostly) constant <code>C</code>, independent of the size <code>N</code>.</p> <p>The <code>for</code> statement on the sentence number one is tricky. While the index ends at <code>2 * N</code>, the increment is done by two. That means that the first <code>for</code> gets executed only <code>N</code> steps, and we need to divide the count by two.</p> <pre><code>f(N) = Summation(i from 1 to 2 * N / 2)( ... ) = = Summation(i from 1 to N)( ... ) </code></pre> <p>The sentence number <em>two</em> is even trickier since it depends on the value of <code>i</code>. Take a look: the index i takes the values: 0, 2, 4, 6, 8, ..., 2 * N, and the second <code>for</code> get executed: N times the first one, N - 2 the second, N - 4 the third... up to the N / 2 stage, on which the second <code>for</code> never gets executed.</p> <p>On formula, that means:</p> <pre><code>f(N) = Summation(i from 1 to N)( Summation(j = ???)( ) ) </code></pre> <p>Again, we are counting <strong>the number of steps</strong>. And by definition, every summation should always start at one, and end at a number bigger-or-equal than one.</p> <pre><code>f(N) = Summation(i from 1 to N)( Summation(j = 1 to (N - (i - 1) * 2)( C ) ) </code></pre> <p>(We are assuming that <code>foo()</code> is <code>O(1)</code> and takes <code>C</code> steps.)</p> <p>We have a problem here: when <code>i</code> takes the value <code>N / 2 + 1</code> upwards, the inner Summation ends at a negative number! That's impossible and wrong. We need to split the summation in two, being the pivotal point the moment <code>i</code> takes <code>N / 2 + 1</code>.</p> <pre><code>f(N) = Summation(i from 1 to N / 2)( Summation(j = 1 to (N - (i - 1) * 2)) * ( C ) ) + Summation(i from 1 to N / 2) * ( C ) </code></pre> <p>Since the pivotal moment <code>i &gt; N / 2</code>, the inner <code>for</code> won't get executed, and we are assuming a constant C execution complexity on its body.</p> <p>Now the summations can be simplified using some identity rules:</p> <ol> <li>Summation(w from 1 to N)( C ) = N * C</li> <li>Summation(w from 1 to N)( A (+/-) B ) = Summation(w from 1 to N)( A ) (+/-) Summation(w from 1 to N)( B )</li> <li>Summation(w from 1 to N)( w * C ) = C * Summation(w from 1 to N)( w ) (C is a constant, independent of <code>w</code>)</li> <li>Summation(w from 1 to N)( w ) = (N * (N + 1)) / 2</li> </ol> <p>Applying some algebra:</p> <pre><code>f(N) = Summation(i from 1 to N / 2)( (N - (i - 1) * 2) * ( C ) ) + (N / 2)( C ) f(N) = C * Summation(i from 1 to N / 2)( (N - (i - 1) * 2)) + (N / 2)( C ) f(N) = C * (Summation(i from 1 to N / 2)( N ) - Summation(i from 1 to N / 2)( (i - 1) * 2)) + (N / 2)( C ) f(N) = C * (( N ^ 2 / 2 ) - 2 * Summation(i from 1 to N / 2)( i - 1 )) + (N / 2)( C ) =&gt; Summation(i from 1 to N / 2)( i - 1 ) = Summation(i from 1 to N / 2 - 1)( i ) f(N) = C * (( N ^ 2 / 2 ) - 2 * Summation(i from 1 to N / 2 - 1)( i )) + (N / 2)( C ) f(N) = C * (( N ^ 2 / 2 ) - 2 * ( (N / 2 - 1) * (N / 2 - 1 + 1) / 2) ) + (N / 2)( C ) =&gt; (N / 2 - 1) * (N / 2 - 1 + 1) / 2 = (N / 2 - 1) * (N / 2) / 2 = ((N ^ 2 / 4) - (N / 2)) / 2 = (N ^ 2 / 8) - (N / 4) f(N) = C * (( N ^ 2 / 2 ) - 2 * ( (N ^ 2 / 8) - (N / 4) )) + (N / 2)( C ) f(N) = C * (( N ^ 2 / 2 ) - ( (N ^ 2 / 4) - (N / 2) )) + (N / 2)( C ) f(N) = C * (( N ^ 2 / 2 ) - (N ^ 2 / 4) + (N / 2)) + (N / 2)( C ) f(N) = C * ( N ^ 2 / 4 ) + C * (N / 2) + C * (N / 2) f(N) = C * ( N ^ 2 / 4 ) + 2 * C * (N / 2) f(N) = C * ( N ^ 2 / 4 ) + C * N f(N) = C * 1/4 * N ^ 2 + C * N </code></pre> <p>And the BigOh is:</p> <pre><code>O(N²) </code></pre>
<p>In addition to using the master method (or one of its specializations), I test my algorithms experimentally. This can't <em>prove</em> that any particular complexity class is achieved, but it can provide reassurance that the mathematical analysis is appropriate. To help with this reassurance, I use code coverage tools in conjunction with my experiments, to ensure that I'm exercising all the cases.</p> <p>As a very simple example say you wanted to do a sanity check on the speed of the .NET framework's list sort. You could write something like the following, then analyze the results in Excel to make sure they did not exceed an n*log(n) curve.</p> <p>In this example I measure the number of comparisons, but it's also prudent to examine the actual time required for each sample size. However then you must be even more careful that you are just measuring the algorithm and not including artifacts from your test infrastructure.</p> <pre><code>int nCmp = 0; System.Random rnd = new System.Random(); // measure the time required to sort a list of n integers void DoTest(int n) { List&lt;int&gt; lst = new List&lt;int&gt;(n); for( int i=0; i&lt;n; i++ ) lst[i] = rnd.Next(0,1000); // as we sort, keep track of the number of comparisons performed! nCmp = 0; lst.Sort( delegate( int a, int b ) { nCmp++; return (a&lt;b)?-1:((a&gt;b)?1:0)); } System.Console.Writeline( "{0},{1}", n, nCmp ); } // Perform measurement for a variety of sample sizes. // It would be prudent to check multiple random samples of each size, but this is OK for a quick sanity check for( int n = 0; n&lt;1000; n++ ) DoTest(n); </code></pre>
2,543
<p>I have a project where I would like to generate a report export in MS Word format. The report will include images/graphs, tables, and text. What is the best way to do this? Third party tools? What are your experiences?</p>
<p>The answer is going to depend slightly upon if the application is running on a server or if it is running on the client machine. If you are running on a server then you are going to want to use one of the XML based office generation formats as there are know issues when <a href="http://support.microsoft.com/kb/257757" rel="noreferrer">using Office Automation on a server</a>.</p> <p>However, if you are working on the client machine then you have a choice of either <a href="http://msdn.microsoft.com/en-us/office/default.aspx" rel="noreferrer">using Office Automation</a> or using the Office Open XML format (see links below), which is supported by Microsoft Office 2000 and up either natively or through service packs. One draw back to this though is that you might not be able to embed some kinds of graphs or images that you wish to show. </p> <p>The best way to go about things will all depend sightly upon how much time you have to invest in development. If you go the route of Office Automation there are quite a few good tutorials out there that can be found via Google and is fairly simple to learn. However, the Open Office XML format is fairly new so you might find the learning curve to be a bit higher.</p> <p>Office Open XML Iinformation</p> <ul> <li>Office Open XML - <a href="http://en.wikipedia.org/wiki/Office_Open_XML" rel="noreferrer">http://en.wikipedia.org/wiki/Office_Open_XML</a></li> <li>OpenXML Developer - <a href="http://openxmldeveloper.org/default.aspx" rel="noreferrer">http://openxmldeveloper.org/default.aspx</a></li> <li>Introducing the Office (2007) Open XML File Formats - <a href="http://msdn.microsoft.com/en-us/library/aa338205.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa338205.aspx</a></li> </ul>
<p>Another alternative is <a href="https://www.windwardstudios.com/programming-languages/csharp" rel="nofollow noreferrer">Windward Docgen</a> (disclaimer - I'm the founder). With Windward you design the template in Word, including images, tables, graphs, gauges, and anything else you want. You can set tags where data from an XML or SQL datasource is inserted (including functionality like forEach loops, import, etc). And then generate the report to DOCX, PDF, HTML, etc.</p>
3,160
<p>The design for the website I am working on calls for a custom image on lists instead of a bullet. Using the image is fine, but I have been having difficulties ensuring that it is centered against the text of the list item across all browsers. Does anyone know of a standard solution for this?</p>
<p>If you are referring to using a custom image bullet for your list this is the code you'll want to use, it will be vertically centered. I'm assuming here that the bullet image is 12px by 12px.</p> <pre class="lang-css prettyprint-override"><code>ul li { background: transparent url(/link/to/custom/bullet.gif) no-repeat 0 50%; padding-left: 18px; } </code></pre> <p>The only problem with this is that sometimes on long multi-line list items it looks odd. In that case it might be best to assign the background position to a slight indent from the top and the left (i.e. no-repeat 0 7px). </p> <p>cheers, Bruce</p>
<p>Have you tried adding the following code in your CSS file?</p> <pre class="lang-css prettyprint-override"><code>li { background-image: URL('custom.png'); background-repeat: no-repeat; background-position: center; } </code></pre>
8,985
<p><a href="https://3dprinting.stackexchange.com/questions/973/which-properties-of-real-organs-do-3d-printed-organs-have">A recent question</a> regarding bio-printing has been put on hold and I'd like to discuss the validity of the question here in the 3D Printing community.</p> <p>I personally feel that the question fits within the scope of the community as it specifically requests details on the process of 3D printing.</p> <p><strong>Valid Questions:</strong></p> <blockquote> <p>Also can someone explain how human cells can be printed?</p> <p>Would this involve some kind of cell-plastic filament?</p> </blockquote> <p><strong>Borderline Question:</strong></p> <blockquote> <p>How would the cells survive, etc. Where would you get these cells from and how would you be able to go from using a 3D printer to layer these cells together to then forming an organ out of that?</p> </blockquote> <p>I don't see how this can be much different than:</p> <blockquote> <p>Also can someone explain how <em>{stainless steel}</em> can be printed?</p> <p>Would this involve some kind of <em>{granular steel}</em>?</p> </blockquote> <p>For the borderline question:</p> <blockquote> <p>How would the <em>{stainless steel bond}</em>, etc. [How] would you get these {granules of stainless steel} from and how would you be able to go from using a 3D printer to layer these <em>{granules}</em> together to then forming <em>{a solid part}</em>?</p> </blockquote>
<p>It seems like a great subject to incorporate, since bioprinting is 1) pretty neat and 2) an important application for 3D printing in general... but I sort of suspect none of our active users have the necessary expertise at the moment. It's a highly specialized field. We don't want the question to sit for an extended period with (at best) 1-2 mediocre answers, do we? That seems to be what happens to this sort of question at the site's current activity level. </p>
<p>It seems like a great subject to incorporate, since bioprinting is 1) pretty neat and 2) an important application for 3D printing in general... but I sort of suspect none of our active users have the necessary expertise at the moment. It's a highly specialized field. We don't want the question to sit for an extended period with (at best) 1-2 mediocre answers, do we? That seems to be what happens to this sort of question at the site's current activity level. </p>
24
<p>I've been looking for a decent guide to Haskell for some time, but haven't been able to find one that seems interesting enough to read through and/or makes sense.</p> <p>I've had prior exposure to Haskell a few years back, but I can't remember much about it. I remember the "Aha!"-feeling was incredible when I finally got it, and it was actually fun to play with, so I'm looking to rediscover the lost art of Haskell.</p> <p>I'm familiar with Ruby and its functional programming tricks, so I think I'm not completely in the dark. Any links?</p>
<p>Some good places to start are:</p> <ul> <li><a href="http://www.cs.auckland.ac.nz/references/haskell/haskell-intro-html/intro.html" rel="noreferrer">The Gentle Introduction To Haskell</a></li> <li><a href="http://www.cs.kent.ac.uk/people/staff/sjt/Haskell_craft/probSolving.html" rel="noreferrer">Problem Solving in Haskell</a></li> <li><a href="http://www.happylearnhaskelltutorial.com" rel="noreferrer">Happy Learn Haskell Tutorial</a></li> </ul> <p>Other resources:<br></p> <ul> <li>Interesting blog entry on a <a href="http://web.archive.org/web/20100416040111/http://www.alpheccar.org/en/posts/show/67" rel="noreferrer">Study plan for Haskell</a> via the Wayback Machine</li> <li><a href="http://www.haskell.org/" rel="noreferrer">HaskellWiki</a></li> <li><a href="http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=F620BE1F358D8EC82AE93B19C543CE3B?doi=10.1.1.13.5249&amp;rep=rep1&amp;type=pdf" rel="noreferrer">Generic Haskell User Guide (PDF)</a></li> </ul>
<p>This is where I started. <a href="http://www.haskell.org/haskellwiki/Category:Tutorials" rel="nofollow noreferrer">haskell.org</a></p>
3,760
<p>I'm faced with writing a framework to simplify working with a large and complex object library (<a href="http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/ao_start.htm" rel="noreferrer">ArcObjects</a>). What guidelines would you suggest for creating a framework of this kind? Are static methods preferred? How do you handle things like logging? How do you future proof your framework code from changes that a vendor might introduce?</p> <p>I think of all of the various wrappers and helpers I've seen for NHibernate, log4net, and code I've read from projects like NLog and <a href="http://code.google.com/p/nettopologysuite/" rel="noreferrer" title="NetTopologySuite">NetTopologySuite</a> and I see so many good approaches, but honestly I'm at a loss where to start.</p> <p>BTW - I'm working in C# 3.5 but it's more about recommended approach rather than language.</p>
<p>Brad Abrams' <a href="https://rads.stackoverflow.com/amzn/click/com/0321246756" rel="noreferrer" rel="nofollow noreferrer">Framework Design Guidelines</a> book is all about this. Might be worth a look.</p>
<p>I think that you're consistent is more important than what conventions you go with. As far as future-proofing yourself, that's a matter of the code that you're making a framework for. It's a lot easier to build on a brick house than a sand one.</p>
4,905
<p>There are a few ways to get class-like behavior in javascript, the most common seem to be prototype based like this:</p> <pre><code>function Vector(x, y, x) { this.x = x; this.y = y; this.z = z; return this; } Vector.prototype.length = function () { return Math.sqrt(this.x * this.x ... ); } </code></pre> <p>and closure based approaches similar to</p> <pre><code>function Vector(x, y, z) { this.length = function() { return Math.sqrt(x * x + ...); } } </code></pre> <p>For various reasons the latter is faster, but I've seen (and I frequently do write) the prototype version and was curious as to what other people do.</p>
<p>Assigning functions to the prototype is better (for public methods) because all instances of the class will share the same copy of the method. If you assign the function inside the constructor as in the second example, every time you create a new instance, the constructor creates a new copy of the length function and assigns it to just that one instance.</p> <p>However this latter technique is useful if you <em>want</em> each copy to have it's own copy, the main use of that being to do private/privileges methods which have access to private variables declared inside the constructor and inherited via the closure mechanism.</p> <p>Douglas Crockford has a good <a href="http://javascript.crockford.com/private.html" rel="noreferrer">summary</a>.</p>
<p>I'm a big fan of using <a href="http://ejohn.org/blog/simple-javascript-inheritance/" rel="nofollow noreferrer">John Resig's library</a> for this. Lightweight, straight-forward, and you already know how to use it if you're familiar with the 'usual' object-oriented style.</p>
2,823
<p>I am trying to print a model I designed in Blender on Shapeways.</p> <p>The object has a hole in it:</p> <p><a href="https://i.stack.imgur.com/iCaGP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iCaGP.png" alt="enter image description here"></a></p> <p>But when I upload it to Shapeways as a STL file, fixed the sizes, but the hole is filled up in the preview window for the object in Shapeways:</p> <p><a href="https://i.stack.imgur.com/6P9iO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6P9iO.png" alt="enter image description here"></a></p> <p>What could cause this? Will the model print properly?</p> <p>(I cannot share the model here).</p>
<p>Double-check that your model is solid (i.e. watertight). Holes in the mesh, or (as other's mentioned in the comments) or problems with thickness can cause those issues. You can use <a href="https://netfabb.azurewebsites.net/" rel="nofollow">Netfabb's Cloud Services</a>, or download the free version of their app. There are other model repair services, too.</p>
<p>Just like the other already have mentioned, most likely your model has 3D printing errors. Either way, I would run it through a repairing service just to make sure it's free of 3D printing errors. I repair my models using this free automatic tool <a href="https://makeprintable.com/" rel="nofollow">https://makeprintable.com/</a> </p>
378
<p>I work for a .NET/MSSQL shop that has trouble supporting customers running Novell, partially because we don't have Novell (or the money for it) and partially because we have no one with Novell experience. This question could easily be expanded to "How can we improve our support of technology X when we don't have technology X?" Obviously, I expect someone to say "it is easy to acquire the technology or someone with that kind of experience," but keep in mind I'm just a developer, not the development manager or someone with power over the purse strings. I looked for a Novell server virtual appliance (though I'm not sure "Novell server" is what I should be looking for) but didn't find much on VMware's website.</p>
<p>There is a <a href="https://secure-www.novell.com/center/regadmin/jsps/eval_app.jsp?buildid=GsODlkBPM2g~" rel="nofollow noreferrer">60 day evaluation trial of Open Enterprise Server 2</a> available (requires free registration). If you install it in a VM, there's nothing stopping you from reinstalling it after 60 days (well except licence).</p> <p>But you will need someone good with Linux to handle this (and preferably good with this precise technology). In a MS shop this might be a problem.</p> <p>The easiest solution would be to outsource this - have some external techs test your software for compatibility. If you find out you are paying too much - hire someone who knows this software stack.</p> <p>You can't support something if you don't test against it. And you can't test against something you don't know.</p>
<p>There used to be some relatively cheap developers network which we used to belong to before the Novell questions all whithered and died away (famous last words, now I bet we will get one tomorrow), there is never any substitute for having the software / hardware, the only alternative is to write a test program and get your user to run it. I am intrigued though as to what problem you are getting, the main ones we got were file locks with Jet databases. </p>
5,893
<p>Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page?</p>
<p>Here is the php code for the same:</p> <pre><code>function time_since($since) { $chunks = array( array(60 * 60 * 24 * 365 , 'year'), array(60 * 60 * 24 * 30 , 'month'), array(60 * 60 * 24 * 7, 'week'), array(60 * 60 * 24 , 'day'), array(60 * 60 , 'hour'), array(60 , 'minute'), array(1 , 'second') ); for ($i = 0, $j = count($chunks); $i &lt; $j; $i++) { $seconds = $chunks[$i][0]; $name = $chunks[$i][1]; if (($count = floor($since / $seconds)) != 0) { break; } } $print = ($count == 1) ? '1 '.$name : "$count {$name}s"; return $print; } </code></pre> <p>The function takes the number of seconds as input and outputs text such as:</p> <ul> <li>10 seconds</li> <li>1 minute</li> </ul> <p>etc</p>
<p>PHP's <code>\DateTime::diff</code> returns a <a href="http://nl3.php.net/dateInterval" rel="noreferrer"><code>\DateInterval</code></a> object on which you can get the minutes by the public <code>i</code> property.</p>
3,923
<p>Is there a method of accessing an Exchange server that does not have <code>IMAP</code> or <code>POP3</code> enabled without Outlook?</p> <p>It does not appear that Outlook Express supports Exchange (only <code>IMAP and POP3</code>).</p>
<p>The only way I can think of is if the Exchange server has Outlook Web Access (OWA) turned on. You can test this by trying the server name in your browser like so: <a href="http://server/exchange" rel="nofollow noreferrer">http://server/exchange</a>.</p> <p>If you mean programmatically then the recommended way is to use <a href="http://www.codeproject.com/KB/vb/AccRemoteExchange.aspx?fid=132800&amp;df=90&amp;mpp=25&amp;noise=3&amp;sort=Position&amp;view=Quick&amp;fr=26" rel="nofollow noreferrer">WebDAV</a> (which is what OWA uses).</p> <p>@Jon I think the method you linked to uses IMAP.</p> <p>Edit: @Pat: SimpleMAPI is the protocol that allows applications such as Word etc to talk to your email client, not your email client to the server - ExtendedMAPI is needed for that, which Thunderbird doesn't support.</p>
<p>You can use <a href="http://www.mozilla.com/en-US/thunderbird/" rel="nofollow noreferrer">Thunderbird</a> to <a href="http://www.downloadsquad.com/2007/03/30/howto-thunderbird-and-ms-exchange-server/" rel="nofollow noreferrer">access Exchange e-mail and contact lists</a>.</p> <p>Edit - Oops, this uses IMAP, didn't answer the question.</p>
3,914
<p>I have read a lot that LISP can redefine syntax on the fly, presumably with macros. I am curious how far does this actually go? Can you redefine the language structure so much that it borderline becomes a compiler for another language? For example, could you change the functional nature of LISP into a more object oriented syntax and semantics, maybe say having syntax closer to something like Ruby?</p> <p>Especially, is it possible to get rid of the parenthesis hell using macros? I have learned enough (Emacs-)LISP to customize Emacs with my own micro-features, but I am very curious how far macros can go in customizing the language.</p>
<p>That's a really good question.</p> <p>I think it's nuanced but definitely answerable:</p> <p>Macros are not stuck in s-expressions. See the LOOP macro for a very complex language written using keywords (symbols). So, while you may start and end the loop with parentheses, inside it has its own syntax.</p> <p>Example:</p> <pre><code>(loop for x from 0 below 100 when (even x) collect x) </code></pre> <p>That being said, most simple macros just use s-expressions. And you'd be "stuck" using them.</p> <p>But s-expressions, like Sergio has answered, start to feel right. The syntax gets out of the way and you start coding in the syntax tree.</p> <p>As for reader macros, yes, you could conceivably write something like this:</p> <pre><code>#R{ ruby.code.goes.here } </code></pre> <p>But you'd need to write your own Ruby syntax parser.</p> <p>You can also mimic some of the Ruby constructs, like blocks, with macros that compile to the existing Lisp constructs.</p> <pre><code>#B(some lisp (code goes here)) </code></pre> <p>would translate to</p> <pre><code>(lambda () (some lisp (code goes here))) </code></pre> <p>See <a href="http://rottcodd.wordpress.com/2007/11/29/lambda-shortcut/" rel="noreferrer">this page</a> for how to do it.</p>
<p>@sparkes</p> <p>Sometimes LISP is the clear language choice, namely Emacs extensions. I'm sure I could use Ruby to extend Emacs if I wanted to, but Emacs was designed to be extended with LISP, so it seems to make sense to use it in that situation.</p>
2,420
<p>I use more than one machine for development in VS 2008. Is there a tool to automatically synchronize the snippets between the machines? Same concept of synchronizing browsers' bookmark.</p>
<p>If you have Vista and the LiveMesh client installed try <a href="http://weblogs.asp.net/lduveau/archive/2008/06/30/sync-your-visual-studio-settings-with-live-mesh.aspx" rel="nofollow noreferrer">this suggestion</a></p> <p>Hope this helps.</p>
<p>Assuming you already know what files you need/want sync'd then some additional options to Mesh would be to tool-out. Maybe look at SyncToy or SyncBack to keeps these collection of files centralized - then have all your machines pull from the central data store.</p> <p>There is also <a href="https://sync.live.com/" rel="nofollow noreferrer">Live Sync</a> (formery FolderShare) which works over the internet.</p>
8,726
<p>I have a Monoprice Maker Select Plus, currently using Ultimaker Cura 3.6.0 with the default settings for a Wanhao Duplicator i3 Plus. Right now when a print finishes, the bed retreats towards the back of the machine. I'd rather present the bed forward for easier part removal.</p> <p>Here is my ending G-Code:</p> <pre> M104 S0 ;extruder heater off G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way M84 ;steppers off G90 ;absolute positioning </pre> <p>It looks like I need to change that <code>G28</code> line third from the bottom, but I'm not sure what to change it to. I've not yet done any g-code manipulation of my own. I don't know what units it's using, and it looks like it still has relative positioning, so even then I don't know it's a good idea to just set it for the max size of the bed. </p> <p>So how can I change this code to move the bed as I want?</p>
<p>Note that <a href="https://reprap.org/wiki/G-code#G28:_Move_to_Origin_.28Home.29" rel="nofollow noreferrer">this reference</a> states that:</p> <blockquote> <p>Because the behavior of <code>G28</code> is unspecified, it is recommended <strong>not</strong> to automatically include <code>G28</code> in your <strong>ending GCode</strong>. On a Cartesian this will result in damaging the printed object. If you need to move the carriage at the completion of a print, use <code>G0</code> or <code>G1</code>.</p> </blockquote> <p>So you need to use a <a href="https://reprap.org/wiki/G-code#G0_.26_G1:_Move" rel="nofollow noreferrer"><code>G0</code> or <code>G1</code></a> move.</p> <p>When using Ultimaker Cura (like many other slicers), there is built in functionality known as <a href="https://github.com/Ultimaker/Cura/issues/1131" rel="nofollow noreferrer">keywords</a> with a complete list found <a href="https://github.com/Ultimaker/Cura/blob/master/resources/definitions/fdmprinter.def.json" rel="nofollow noreferrer">here</a>.</p> <p>The keyword <code>machine_depth</code> is the one that is of use to you, embed this in your end G-code in between curly brackets and it will expand to the bed size of your machine (replacing <code>G28 X0 Y0</code>):</p> <p><code>G1 X0 Y{machine_depth}</code></p> <p>For me this compiles to (e.g. for my coreXY printer):</p> <p><code>G1 X0 Y300</code></p> <p>To set the speed, just add the following command prior to the one above:</p> <p><code>G1 F2500</code></p> <p>Adding this line before the actual move ensures that the speed is constant, if <code>F2500</code> would have been included in the move command (like <code>G1 X0 Y{machine_depth} F2500</code>), this defines the end speed, it would start moving at the last speed value prior to the move.</p> <p>This results in adding the following lines in your endscript:</p> <pre> G1 F2500 G1 X0 Y{machine_depth} </pre>
<p>You're correct that the G28 line should be changed. What I would do is the following:</p> <pre><code>M104 S0 ;extruder heater off G91 ;relative positioning G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure G1 Z+0.5 E-5 X-20 Y-20 F{travel_speed} ;move Z up a bit and retract filament even more G28 X0 ;move X to min endstop, so the head is out of the way G90 ;absolute positioning G1 Y200 ;Move bed forward M84 ;steppers off </code></pre> <p>This way your X axis still gets homed after the Z bumps up and before Y moves to present the print.</p> <p>G28 is the command to home the print head. Your current settings homes the X and Y axes. G1 is a linear movement. One caveat to this change in G-Code is that there needs to be a home command at the start of your prints since you're not homing afterwards anymore. (I believe most slicers default to a G28 at the start AND end of prints so it's not a major concern, but one to be wary of now just in case.)</p>
1,210
<p>Was looking to get peoples thoughts on keeping a Lucene index up to date as changes are made to the domain model objects of an application. </p> <p>The application in question is a Java/J2EE based web app that uses Hibernate. The way I currently have things working is that the Hibernate mapped model objects all implement a common "Indexable" interface that can return a set of key/value pairs that are recorded in Lucene. Whenever a CRUD operation is performed involving such an object I send it via JMS queue into a message driven bean that records in Lucene the primary key of the object and the key/value pairs returned from the index( ) method of the Indexable object that was provided. </p> <p>My main worries about this scheme is if the MDB gets behind and can't keep up with the indexing operations that are coming in or if some sort of error/exception stops an object from being index. The result is an out-of-date index for either a sort, or long, period of time. </p> <p>Basically I was just wondering what kind of strategies others had come up with for this sort of thing. Not necessarily looking for one correct answer but am imagining a list of "whiteboard" sort of ideas to get my brain thinking about alternatives.</p>
<p>Change the message: just provide the primary key and the current date, not the key/value pairs. Your mdb fetches the entity by primary key and calls index(). After indexing you set a value "updated" in your index to the message date. You update your index only if the message date is after the "updated" field of the index. This way you can't get behind because you always fetch the current key/value pairs first.</p> <p>As an alternative: have a look at <a href="http://www.compass-project.org" rel="nofollow noreferrer">http://www.compass-project.org</a>.</p>
<p>The accepted answer is 8 years old now and very out of date.</p> <p>The Compass Project is not maintained anymore since a long time, as its main developer moved on to create the excellent Elasticsearch.</p> <p>The modern answer to this is to use <a href="http://hibernate.org/search/" rel="nofollow noreferrer">Hibernate Search</a>, which incidentally can map to either a Lucene index directly or through Elasticsearch.</p>
5,905
<p>I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually when a user tries to access a resource without proper authorization I want them to be redirected to a login page. FormsAuth does this for me easy enough.</p> <p>Problem: Now I have an action being accessed by a console app. Whats the quickest way to have this action respond w/ status 401 instead of redirecting the request to the login page? </p> <p>I want the console app to be able to react to this 401 StatusCode instead of it being transparent. I'd also like to keep the default, redirect unauthorized requests to login page behavior.</p> <p>Note: As a test I added this to my global.asax and it didn't bypass forms auth:</p> <pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e) { HttpContext.Current.SkipAuthorization = true; } </code></pre> <hr> <p>@Dale and Andy</p> <p>I'm using the AuthorizeAttributeFilter provided in MVC preview 4. This is returning an HttpUnauthorizedResult. This result is correctly setting the statusCode to 401. The problem, as i understand it, is that asp.net is intercepting the response (since its taged as a 401) and redirecting to the login page instead of just letting it go through. I want to bypass this interception for certain urls.</p>
<p>Ok, I worked around this. I made a custom ActionResult (HttpForbiddenResult) and custom ActionFilter (NoFallBackAuthorize).</p> <p>To avoid redirection, HttpForbiddenResult marks responses with status code 403. FormsAuthentication doesn't catch responses with this code so the login redirection is effectively skipped. The NoFallBackAuthorize filter checks to see if the user is authorized much like the, included, Authorize filter. It differs in that it returns HttpForbiddenResult when access is denied. </p> <p>The HttpForbiddenResult is pretty trivial:</p> <pre> public class HttpForbiddenResult : ActionResult { public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } context.HttpContext.Response.StatusCode = 0x193; // 403 } } </pre> <p>It doesn't appear to be possible to skip the login page redirection in the FormsAuthenticationModule.</p>
<p>I did some googling and this is what I came up with:</p> <pre><code> HttpContext.Current.Response.StatusCode = 401; </code></pre> <p>Not sure if it works or not, I haven't tested it. Either way, it's worth a try, right? :)</p>
5,578
<p>I'm looking for a way to visually mark or tag a window (any OS) so that it stands out.</p> <p>A while back, I accidentally replaced a live production database containing thousands of records with an empty dev version, simply because the two instances of Enterprise Manager looked identical to one another. I'd like to avoid that in the future!</p>
<p>None that I'm aware of, but perhaps a <a href="http://en.wikipedia.org/wiki/Virtual_desktop" rel="nofollow noreferrer">virtual desktop</a> system for your OS of choice would help keep the separation a little better for you.</p>
<p>Since you didn't restrict your question, I'll answer with my solution to this type of problem. I often am logged into multiple different machines with <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/" rel="nofollow noreferrer">PuTTY</a> as different users (including as <code>root</code>). If I have a window that I want to distinguish from the others, for example when I need to make sure I know I am typing commands as root, I change the background of the window to a different colour. A window that is mostly red really stands out as being something extraordinary.</p>
5,447
<p>A couple of days ago I got my first 3D printer: Creality 3D Ender 3 Pro. I finished assembling it last night. I booted it up, but ran into problems (which I guess is not a common thing for a beginner in 3D printing). After booting and running the motors, it seemed that the lead screw got stuck about halfway down the Z-axis. I heard a rattling sound. So I turned the 3D-printer off. I disassembled the lead screw and applied some Lithium lubricant on it. But the problem persisted. Looking more closely at it, I noticed some notches on the lead screw:</p> <p>I tried to spin the Creality Z-axis stepper motor, and it felt smooth and did not have any resistance. The bolts on the rod holder were slighly loose so that the lead screw had a bit of play inside.</p> <p>Im wondering if the lead screw may have been defect during manufacturing process? Are lead screws supposed to have notches like these, or are these manufacturing defects? Here's two photos of the lead screw:</p> <p><img src="https://i.stack.imgur.com/WufoV.jpg" width="320"><img src="https://i.stack.imgur.com/mzN12.jpg" width="320"></p> <p>Im guessing the notches are too deep for the z-axis to actually work the way it is supposed to.</p>
<p>The threads of the screw are very damaged, this causes your brass nut to be damaged as well.</p> <p>This is hardly accountable by misusage, this is a production or handling error in the factory.</p> <p>You need to contact the vendor for a new screw and new threaded brass nut.</p> <p>Although the nut is softer and may run in on the damaged threads, there will always be a rough part of the screw, so it will always affect print quality, please replace the damaged parts.</p>
<p>Both of the above answers are likely correct <strong>but also,</strong> I own an Ender 3 and it's kinda/sorta tricky to get it set up right. I had a similar problem and I was certain it was the lead screw -- and mine indeed does not have the marks that yours has -- but in the end the issue was that I had assembled the printer ever-so-slightly out of true, and I had to do a lot of adjusting and wobbling to get things lined up right. So just be prepared for that.</p> <p>Yes I think the rod is damaged and send back for a replacement, but when it comes back be sure and triple-check that everything is adjusted properly following videos like <a href="https://www.youtube.com/watch?v=dQ0q9zLygTY" rel="nofollow noreferrer">this</a>. You might also need to spend a little bit more money to replace some of the stock parts to really get it dialed in but once you do you won't be disappointed!</p>
2,183
<p>I've been hearing about triggers, and I have a few questions.<br /> What are triggers?<br /> How do I set them up?<br /> Are there any precautions, aside from typical SQL stuff, that should be taken?</p>
<p>Triggers allow you to perform a function in the database as certain events happen (eg, an insert into a table). </p> <p>I can't comment on mysql specifically.</p> <p>Precaution: Triggers can be very alluring, when you first start using them they seem like a magic bullet to all kinds of problems. But, they make "magic" stuff happen, if you don't know the database inside out, it can seem like really strange things happen (such as inserts into other tables, input data changing, etc). Before implementing things as a trigger I'd seriously consider instead enforcing the use of an API around the schema (preferably in the database, but outside if you can't).</p> <p>Some things I'd still use triggers for</p> <ul> <li>Keeping track of "date_created" and "date_last_edited" fields</li> <li>Inserting "ID"'s (in oracle, where there is no auto id field)</li> <li>Keeping change history</li> </ul> <p>Things you wouldn't want to use triggers for</p> <ul> <li>business rules/logic</li> <li>anything which connects outside of the database (eg a webservice call)</li> <li>Access control</li> <li>Anything which isn't transactional ( anything you do in the trigger MUST be able to rollback with the transaction )</li> </ul>
<p>A trigger is a named database object that is associated with a table and that is activated when a particular event occurs for the table.<br /> <br />To create a trigger:<br /></p> <pre><code>CREATE TRIGGER triggerName [BEFORE|AFTER] [INSERT|UPDATE|DELETE|REPLACE] ON tableName FOR EACH ROW SET stuffToDoHERE; </code></pre> <p><br />Even though I answered this part the other question still stands.</p>
6,961
<p>I have a really bent heatbed PCB, the middle is elevated about 3 mm with respect to all edges.</p> <p>I have found this thread <a href="http://midibox.org/forums/topic/17599-warped-pcbs/" rel="noreferrer">Warped PCBs</a>, where a heating method is applied by baking a PCB in the oven, as described here: <a href="http://www.circuitrework.com/guides/3-2.shtml" rel="noreferrer">3.2 Bow and Twist Repair</a>.</p> <p>Can this help straightening out a Prusa heatbed PCB? If so, can I apply the heat by the heatbed itself, or do I need to utilize an oven? Will the pressure from the strongly clamped glass plate be enough or will the glass break at these temperatures (given that the heatbed can reach them).</p>
<p>Baking PCB in an oven is not a good idea, I would say. I know PCBs are resistive to the heat (especially heatbeds) but, still, it sounds odd. But the real question is how baking would help. Let's leave it.</p> <p>If your heatbed is such bent you can do few things depending on your situation/environment.</p> <p>You can:</p> <ol> <li>Add two glass plates (at the bottom and at the top) and clip them all together;</li> <li>Support your HB with flat aluminium or even wood;</li> <li>Add an aluminium frame, or;</li> <li>If you use glass plate, clip the HB to the glass using stronger (wider) clips.</li> </ol> <p>Ad#1 the thermistor can even stay sandwiched between the PCB and the bottom glass plate.</p> <p>Ad#2 If your HB is bent up in the middle, you can use the middle thermistor hole. Drill it a bit with fi8mm drill (but not too much, I would say halfway through) and use a cone head screw to screw it flat on to the aluminium/wood support. Of course you will have to install a thermistor into the new place.</p> <p>The simplest, and less destructive, solution is #1 and I would recommend that.</p>
<p>Easiest way would be to place a glass sheet on top of the bed and run a calibration... Although, that way you may lose a few millimeters of print height.</p>
255
<p>When I defragment my XP machine I notice that there is a block of "Unmovable Files". Is there a file attribute I can use to make my own files unmovable?</p> <p>Just to clarify, I want a way to programmatically tell Windows that a file that I create should be unmovable. Is this possible, and if so, how can I do it?</p> <p>Thanks,</p> <p>Terry </p>
<p>A lot of system files cannot be moved after the system boots, such as the page file and registry database files.</p> <p><a href="http://technet.microsoft.com/en-us/sysinternals/bb897426.aspx" rel="noreferrer">This utility</a> runs before Windows boots to defragment those files. I have it set to run at every boot, and it works well for me on several machines.</p> <p>Note that the very first time you boot up with this utility set to run, it may take several minutes to defrag. After that first run though, it finishes in just 3 or 4 seconds.</p> <p><em>Edit0: To respond to your clarification- that link says windows has marked the page file and registry files as open for exclusive access. So you should be able to do the same thing with the <a href="http://msdn.microsoft.com/en-us/library/aa365202(VS.85).aspx" rel="noreferrer">LockFile</a> API Call. However, that's not an attribute of the file itself. You'd have to actually run some background program that locks the file for exclusive access.</em></p>
<p>I assume you're using the defragger that comes with Windows. Some commercial ones like DiskKeeper can move some of these files (usually system files). You can try their trial versions.</p>
7,543
<p>I use OctoPrint on an Ubuntu system with a M3D printer.</p> <p>Midway through a recent print, the filament just stopped extruding although the motor-functions of the printer were proceeding fine. Since then, every print I attempt has trouble extruding proper amounts of filament. It's always not enough. The output is stringy and not cohesive.</p> <p>I'm thinking there may simply be a clog in the extruder and wondering the safest way to remove it.</p> <p>The weird thing, though, is that when I use manual control and extrude at, say, 220C, the filament comes out fine.</p> <p>You can see the raft definitely isn't printing right. Way too little output:</p> <p><a href="https://i.stack.imgur.com/M4Ih4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M4Ih4.png" alt="enter image description here"></a></p>
<p>Depends on the glue and on your tolerance for messy undersides on your prints. It's fairly common for some of the glue to come off with the print. Or you may have marks from scrapers or rafts. Do you want to touch up that spot and have some artifacts on the bottom of the next print, or clean and redo the bed to get everything flat?</p> <p>Gluestick is pretty easy to wash and reapply. It can also be freshened up with a gentle spray of water, smeared flat, and redried, or more gluestick added on top. It will really come down to your preferred workflow. </p>
<p>As noted in the answer to the other question you asked, the Flux Delta steel plate bed will handle multiple layers of glue. The determining factor regarding this particular printer and specific glue is how many ripples, bumps and/or lines you are willing to tolerate on the first layer of your prints. </p> <p>You'll notice that a print made with a couple layers of glue, freshly applied, will have a relatively smooth surface. Peel off the model, apply glue over the now-cleared areas, and you've created a slightly-less-than-smooth surface for your next model.</p> <p>I've found that I can apply six to ten layers before the ripples become objectionable.</p>
312
<p>I'm on .NET 2.0, running under Medium Trust (so <a href="http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx" rel="nofollow noreferrer">TimeZoneInfo</a> and the Registry are not allowed options). I'm asking the user for two dates and a time zone, and would really love to be able to automatically determine whether I need to adjust the time zone for DST. </p> <p>This probably isn't even a valid scenario unless I have some <em>very</em> robust support, a la <a href="http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx" rel="nofollow noreferrer">TimeZoneInfo</a>, to differentiate between all of the different varieties of Time Zones in the first place.</p>
<p>In .NET 2.0 you have to code this yourself. It involves researching daylight savings time laws in various regions and building that into your own data structures. The problem is somewhat simplified if you only care about a subset of time zones, for example just in the USA, but if you need all global time zones, you have a lot of work to do, and then the code has to be updated every few years when the laws change. Even the new time zone objects in the latest version of .NET will require windows updates to keep them correct as laws change.</p> <p>Look <a href="http://aa.usno.navy.mil/faq/docs/daylight_time.php" rel="nofollow noreferrer">here</a>, <a href="http://en.wikipedia.org/wiki/Daylight_saving_time" rel="nofollow noreferrer">here</a>, and <a href="http://www.timeanddate.com/time/aboutdst.html" rel="nofollow noreferrer">here</a> for more info.</p>
<p>Well, since <code>TimeZoneInfo</code> is excluded, you're probably not going to find a solution in the framework itself (but don't quote me on that).</p> <p>In which case, have you considered reflectoring the <code>TimeZoneInfo</code> class and using what you find there?</p>
6,657
<p>I am completely on board with the ideas behind TDD, Refactoring and Patterns however it does seem like there is a huge gaping whole in these ideas, mainly that they are great for dev teams of 1, but when you start refactoring code that 10 people are working on you start getting merge conflicts all over the place and most diff/merge software can't tell that you refactored a function into its own class.</p> <p>How do you clean up your code, by refactoring, without causing major headaches for everyone on your team?</p>
<p>Small changes committed often.</p> <p>As for your example, you would start by creating the class, committing that change. Then adding a similar function in the class as the old one and commit that change. Then change all the references from the old function to the new class function, commit that. Then remove the old function and commit that change.</p> <p>Of course, no one said it was going to be easy.</p>
<p>Communication.</p> <p>Tools can't solve this for you, unless the specific tool is your email or IM client.</p> <p>It's the same as if you were making any other major change in a shared project -- you need to be able to tell your coworkers/collaborators "hey, hands off for a couple of hours, I have a big change to the FooBar module coming in".</p> <p>Alternately, if you're going to be making a change so major that it has the potential to cause huge merge conflicts with the work of 10 other people, run the change by them beforehand. Have a code review. Ask for architectural input. Then, when you're as close to consensus as you're likely to get, take that virtual lock on the section of the repository you need, check in your changes, and send out an all-clear.</p> <p>It's not a perfect solution, but it's as close as you'll get. Lots of source control systems support explicit locks on sections of the source base, but I've never really seen those lead to good results in these areas. It's a social problem, and you only really need to resort to technical solutions if you can't trust the people you're working with.</p>
9,395
<p>How do I select all records that contain "LCS" within the title column in sql.</p>
<pre><code>SELECT * FROM TABLE WHERE TABLE.TITLE LIKE '%LCS%'; </code></pre> <p>% is the wild card matcher.</p>
<p>Look into the LIKE clause</p>
4,251
<p>I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. The technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple templating engine, like StringTemplate, or even XSLT outputting HTML would be fine. The problem I'm having is finding a free way to print this kind of output from a service. Since it <em>seems</em> that it will work, I'm working on a prototype using Microsoft's RDLC, populating a local report and then rendering it as an image to a memory stream, which I will then print. Issues with that are:</p> <ul> <li>Multi-page printing will be a big headache.</li> <li>Still have to use PrintDocument to print the memory stream, which is unsupported in a Windows Service (though it may work - haven't gotten that far with the prototype yet)</li> <li>If the data coming across changes, I have to change the dataset and the class that the data is being deserialized into. bad bad bad.</li> </ul> <p>Has anyone had to do anything remotely like this? Any advice? I already posted a question about printing HTML without user input, and after wasting about 3 days on that, I have come to the conclusion that it cannot be done, at least not with any freely available tool.</p> <p>All help is appreciated.</p> <p>EDIT: We are on version 2.0 of the .NET framework.</p>
<p>Trust me, you will spend more money trying to search/develop a solution for this as compared to buying a third party component. Do not reinvent the wheel and go for the paid solution.</p> <p>Printing is a complex problem and I would love to see the day when better framework support is added for this.</p>
<p>I think we are going to go the third party route. I like the XSL -> HTML -> PDF -> Printer flow... Winnovative's <a href="http://www.winnovative-software.com/" rel="nofollow noreferrer">HTML to PDF</a> looks good for the first part, but I'm running into a block finding a good PDF printing solution... any suggestions? Ideally the license would be on a developer basis, not on a deployed runtime basis.</p>
2,953
<p>To illustrate, assume that I have two tables as follows:</p> <pre><code>VehicleID Name 1 Chuck 2 Larry LocationID VehicleID City 1 1 New York 2 1 Seattle 3 1 Vancouver 4 2 Los Angeles 5 2 Houston </code></pre> <p>I want to write a query to return the following results:</p> <pre><code>VehicleID Name Locations 1 Chuck New York, Seattle, Vancouver 2 Larry Los Angeles, Houston </code></pre> <p>I know that this can be done using server side cursors, ie:</p> <pre><code>DECLARE @VehicleID int DECLARE @VehicleName varchar(100) DECLARE @LocationCity varchar(100) DECLARE @Locations varchar(4000) DECLARE @Results TABLE ( VehicleID int Name varchar(100) Locations varchar(4000) ) DECLARE VehiclesCursor CURSOR FOR SELECT [VehicleID] , [Name] FROM [Vehicles] OPEN VehiclesCursor FETCH NEXT FROM VehiclesCursor INTO @VehicleID , @VehicleName WHILE @@FETCH_STATUS = 0 BEGIN SET @Locations = '' DECLARE LocationsCursor CURSOR FOR SELECT [City] FROM [Locations] WHERE [VehicleID] = @VehicleID OPEN LocationsCursor FETCH NEXT FROM LocationsCursor INTO @LocationCity WHILE @@FETCH_STATUS = 0 BEGIN SET @Locations = @Locations + @LocationCity FETCH NEXT FROM LocationsCursor INTO @LocationCity END CLOSE LocationsCursor DEALLOCATE LocationsCursor INSERT INTO @Results (VehicleID, Name, Locations) SELECT @VehicleID, @Name, @Locations END CLOSE VehiclesCursor DEALLOCATE VehiclesCursor SELECT * FROM @Results </code></pre> <p>However, as you can see, this requires a great deal of code. What I would like is a generic function that would allow me to do something like this:</p> <pre><code>SELECT VehicleID , Name , JOIN(SELECT City FROM Locations WHERE VehicleID = Vehicles.VehicleID, ', ') AS Locations FROM Vehicles </code></pre> <p>Is this possible? Or something similar?</p>
<p>If you're using SQL Server 2005, you could use the FOR XML PATH command.</p> <pre><code>SELECT [VehicleID] , [Name] , (STUFF((SELECT CAST(', ' + [City] AS VARCHAR(MAX)) FROM [Location] WHERE (VehicleID = Vehicle.VehicleID) FOR XML PATH ('')), 1, 2, '')) AS Locations FROM [Vehicle] </code></pre> <p>It's a lot easier than using a cursor, and seems to work fairly well.</p> <p><strong>Update</strong></p> <p>For anyone still using this method with newer versions of SQL Server, there is another way of doing it which is a bit easier and more performant using the <a href="https://learn.microsoft.com/en-us/sql/t-sql/functions/string-agg-transact-sql?view=sql-server-ver15" rel="noreferrer"><code>STRING_AGG</code></a> method that has been available since SQL Server 2017.</p> <pre><code>SELECT [VehicleID] ,[Name] ,(SELECT STRING_AGG([City], ', ') FROM [Location] WHERE VehicleID = V.VehicleID) AS Locations FROM [Vehicle] V </code></pre> <p>This also allows a different separator to be specified as the second parameter, providing a little more flexibility over the former method.</p>
<p>If you're running SQL Server 2005, you can write a <a href="https://learn.microsoft.com/en-us/sql/relational-databases/clr-integration-database-objects-user-defined-functions/clr-user-defined-aggregates" rel="nofollow noreferrer">custom CLR aggregate function</a> to handle this.</p> <p>C# version:</p> <pre><code>using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using System.Text; using Microsoft.SqlServer.Server; [Serializable] [Microsoft.SqlServer.Server.SqlUserDefinedAggregate(Format.UserDefined,MaxByteSize=8000)] public class CSV:IBinarySerialize { private StringBuilder Result; public void Init() { this.Result = new StringBuilder(); } public void Accumulate(SqlString Value) { if (Value.IsNull) return; this.Result.Append(Value.Value).Append(","); } public void Merge(CSV Group) { this.Result.Append(Group.Result); } public SqlString Terminate() { return new SqlString(this.Result.ToString()); } public void Read(System.IO.BinaryReader r) { this.Result = new StringBuilder(r.ReadString()); } public void Write(System.IO.BinaryWriter w) { w.Write(this.Result.ToString()); } } </code></pre>
2,858
<p>I have two machines, speed and mass. speed has a fast Internet connection and is running a crawler which downloads a lot of files to disk. mass has a lot of disk space. I want to move the files from speed to mass after they're done downloading. Ideally, I'd just run:</p> <pre><code>$ rsync --remove-source-files speed:/var/crawldir . </code></pre> <p>but I worry that rsync will unlink a source file that hasn't finished downloading yet. (I looked at the source code and I didn't see anything protecting against this.) Any suggestions?</p>
<p>How much control do you have over the download process? If you roll your own, you can have the file being downloaded go to a temp directory or have a temporary name until it's finished downloading, and then mv it to the correct name when it's done. If you're using third party software, then you don't have as much control, but you still might be able to do the temp directory thing.</p>
<p>Rsync can exclude files matching certain patters. Even if you can't modify it to make it download files to a temporary directory, maybe it has a convention of naming the files differently during download (for example: <code>foo.downloading</code> while downloading for a file named <code>foo</code>) and you can use this property to exclude files which are still being downloaded from being copied.</p>
7,094
<p>The short version of my question is:</p> <blockquote> <p><em>Are 3D printed parts made of ABS likely to survive for <strong>one year</strong> in an incubator at <strong>80℃</strong>?</em></p> </blockquote> <p>Please read on for more details.</p> <p>I am printing some parts that will be used inside an incubator in a lab. They are likely to be used at 80℃ for at least a year, possibly even at higher temperatures than that. (But most likely under 100℃.)</p> <p>We're currently using ABS for these parts. My question is whether 3D printed ABS will degrade under those conditions. (For example: will it become soft and slump; will it discolour; will it become brittle?) The parts clip together to form quite a big object, which is basically a rack holding a lot of glass vials, so it's important that it stays rigid.</p> <p>I did find some papers on thermal degradation of ABS (for example <a href="http://www.sciencedirect.com/science/article/pii/S0141391002000459" rel="noreferrer">this one</a> looks quite comprehensive) but I don't have the experience to interpret them in terms of how my parts will behave practically. I'm also not sure if being 3D printed will make a difference.</p> <p>If ABS is not suitable for this kind of application, are there other plastics that are? We're using the Zortrax M200, so our choices are the plastics listed <a href="https://zortrax.com/materials/zortrax-m-series/" rel="noreferrer">here</a>. I note that PCABS is listed as specifically being temperature resistant, so we might go with that - but we'd prefer ABS if it will work, since it comes in white rather than ivory (which is important for our application) and we have plenty of it available.</p> <hr> <p><strong>update:</strong> we decided in the end that using ABS is too risky, so we went with PCABS and we'll just live with the yellowish colour. (We might paint it white.) It's currently in the oven on a test run, and if it doesn't fail in a few weeks we'll take the risk of running the year-long experiment with this material. However, we would still <em>very greatly</em> appreciate advice from anyone who has concrete knowledge or experience of this kind of situation.</p>
<p>To answer your question briefly: <strong>No, ABS will not survive for a duration of at least one year at 80-100°C</strong>.</p> <p><img src="https://i.stack.imgur.com/6X0uY.png" alt="1]"> If you look at the chart above (from Tiganis/Burn), you'll notice, that the blue line (ABS 90°C) is decreasing. I did an eyeball calculation of the graph and arrived at the equation (<code>J</code> for <em>break energy</em>, <code>h</code> for <em>hours</em>):</p> <pre><code>J = -0.002h + 14 </code></pre> <p>Based on that, a break energy of 0 Joule will be reached after <em>7056 hours or 294 days</em>.</p> <p>If you roam around internet forums on 3D printing, you'll find that that value is in the ballpark of people's experiences. I remember one case, where someone put out a piece of ABS in the sun and it broke down after a year.</p> <p>Tiganis; Burn: The Effects of Heat Aging on Acrylonitrile-Butadiene-Styrene (ABS) Blends. In: Lacasse; Vanier (1999): Durability of Building Materials and Components 8, pp. 912-922.</p>
<p>I would recommend <a href="http://taulman3d.com/bluprint-spec.html" rel="nofollow noreferrer">Taulman Bluprint</a>, which has a T<sub>g</sub> of 100&nbsp;°C and prints around 250&nbsp;°C. </p> <p>I got a small sample and it printed well with the recommended settings. I didn't do any thermal testing with my print (I made a knob for a lawn mower with it) but Taulman has a solid reputation for engineered filaments.</p>
753
<p>When a user on our site loses his password and heads off to the Lost Password page we need to give him a new temporary password. I don't really mind how random this is, or if it matches all the "needed" strong password rules, all I want to do is give them a password that they can change later.</p> <p>The application is a Web application written in C#. so I was thinking of being mean and going for the easy route of using part of a Guid. i.e.</p> <pre><code>Guid.NewGuid().ToString("d").Substring(1,8) </code></pre> <p>Suggesstions? thoughts?</p>
<p>There's always <a href="http://msdn.microsoft.com/en-us/library/system.web.security.membership.generatepassword.aspx" rel="noreferrer"><code>System.Web.Security.Membership.GeneratePassword(int length, int numberOfNonAlphanumericCharacters</code>)</a>.</p>
<p>Insert a Timer: timer1, 2 buttons: button1, button2, 1 textBox: textBox1, and a comboBox: comboBox1. Make sure you declare:</p> <pre><code>int count = 0; </code></pre> <hr> <p>Source Code:</p> <pre><code> private void button1_Click(object sender, EventArgs e) { // This clears the textBox, resets the count, and starts the timer count = 0; textBox1.Clear(); timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { // This generates the password, and types it in the textBox count += 1; string possible = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; string psw = ""; Random rnd = new Random { }; psw += possible[rnd.Next(possible.Length)]; textBox1.Text += psw; if (count == (comboBox1.SelectedIndex + 1)) { timer1.Stop(); } } private void Form1_Load(object sender, EventArgs e) { // This adds password lengths to the comboBox to choose from. comboBox1.Items.Add("1"); comboBox1.Items.Add("2"); comboBox1.Items.Add("3"); comboBox1.Items.Add("4"); comboBox1.Items.Add("5"); comboBox1.Items.Add("6"); comboBox1.Items.Add("7"); comboBox1.Items.Add("8"); comboBox1.Items.Add("9"); comboBox1.Items.Add("10"); comboBox1.Items.Add("11"); comboBox1.Items.Add("12"); } private void button2_click(object sender, EventArgs e) { // This encrypts the password tochar = textBox1.Text; textBox1.Clear(); char[] carray = tochar.ToCharArray(); for (int i = 0; i &lt; carray.Length; i++) { int num = Convert.ToInt32(carray[i]) + 10; string cvrt = Convert.ToChar(num).ToString(); textBox1.Text += cvrt; } } </code></pre>
7,869
<p>How do I add an instance method to a class using a metaclass (yes I do need to use a metaclass)? The following kind of works, but the func_name will still be "foo":</p> <pre><code>def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): dict["foobar"] = bar return type(name, bases, dict) class Foo(object): __metaclass__ = MetaFoo &gt;&gt;&gt; f = Foo() &gt;&gt;&gt; f.foobar() bar &gt;&gt;&gt; f.foobar.func_name 'bar' </code></pre> <p>My problem is that some library code actually uses the func_name and later fails to find the 'bar' method of the Foo instance. I could do:</p> <pre><code>dict["foobar"] = types.FunctionType(bar.func_code, {}, "foobar") </code></pre> <p>There is also types.MethodType, but I need an instance that does'nt exist yet to use that. Am I missing someting here?</p>
<p>Try dynamically extending the bases that way you can take advantage of the mro and the methods are actual methods:</p> <pre><code>class Parent(object): def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): return type(name, (Parent,) + bases, dict) class Foo(object): __metaclass__ = MetaFoo if __name__ == "__main__": f = Foo() f.bar() print f.bar.func_name </code></pre>
<p>I think what you want to do is this:</p> <pre><code>&gt;&gt;&gt; class Foo(): ... def __init__(self, x): ... self.x = x ... &gt;&gt;&gt; def bar(self): ... print 'bar:', self.x ... &gt;&gt;&gt; bar.func_name = 'foobar' &gt;&gt;&gt; Foo.foobar = bar &gt;&gt;&gt; f = Foo(12) &gt;&gt;&gt; f.foobar() bar: 12 &gt;&gt;&gt; f.foobar.func_name 'foobar' </code></pre> <p>Now you are free to pass <code>Foo</code>s to a library that expects <code>Foo</code> instances to have a method named <code>foobar</code>.</p> <p>Unfortunately, (1) I don't know how to use metaclasses and (2) I'm not sure I read your question correctly, but I hope this helps. </p> <p>Note that <code>func_name</code> is only assignable in Python 2.4 and higher.</p>
9,111
<p>Heavy emphasis on simple. I've never made an installer and I'd rather not have to learn much. A system that I could hand a pile of files to and it would make some smart guesses about where to put them would be ideal.</p> <p>Go ahead and answer the general question.</p> <p>However In my cases I'm stuck with some extra constraints. The program to be installed is written in VB6 (or is it 5?) and a few previous versions of VB, so it's <em>not</em> going to be updated any time soon. I have a running install and will have a Clean VM to play with So I'll be doing a loop of: run the install, find where it's broken, fix it, add that to the installer, revert the VM, try again. If anyone has a better approach I'm open to suggestions.</p> <p>I <em>MUST</em> get it working on XP and I'd really like to also have something that will work on newer versions of Windows as well.</p>
<p><a href="http://www.jrsoftware.org/" rel="noreferrer">InnoSetup</a> or <a href="http://nsis.sourceforge.net/" rel="noreferrer">NSIS</a>, whichever seems easier to you. <a href="http://www.istool.org" rel="noreferrer">ISTool</a> is a nice GUI tool for InnoSetup which makes creating setup scripts even easier.</p>
<p>My advice is this. Try to keep the installer as simple as possible. Windows Installer is a very complicated piece of software and when things don't work right it can be hard to figure out what's going on. I'm sure we have all experienced the endless loop of Windows Installer trying to repair a file that you no longer have the source .msi file for.</p> <p>Most of the time using Windows Installer is like using a sledge hammer to crack a nut.</p> <p>I use InnoSetup for my own stuff and InstallShield at work (against my will). Start with a simple script based installer and only use Windows Installer if you have a good reason to.</p> <p>Note that support for installing assemblies to the GAC may be missing for some non Windows Installer setup tools (such as InnoSetup).</p>
4,366
<p>I'm trying to generate a sitemap.xml on the fly for a particular asp.net website.</p> <p>I found a couple solutions:<br /></p> <ol> <li><a href="http://sitemap.chinookwebs.com/" rel="nofollow noreferrer">chinookwebs</a></li> <li><a href="http://web.archive.org/web/20080307061444/http://www.cervoproject.info:80/sitemaps.aspx" rel="nofollow noreferrer">cervoproject</a></li> <li><a href="http://www.codeplex.com/Sitemaps" rel="nofollow noreferrer">newtonking</a></li> </ol> <p>Chinookwebs is working great but seems a bit inactive right now and it's impossible to personalize the &quot;priority&quot; and the &quot;changefreq&quot; tags of each and every page, they all inherit the same value from the config file.</p> <p>What solutions do you guys use?</p>
<p>Usually you'll use an <a href="http://www.google.com/search?q=HTTPHandler+ASP.NET&amp;spell=1" rel="noreferrer">HTTP Handler</a> for this. Given a request for...</p> <blockquote> <p><a href="http://www.yoursite.com/sitemap.axd" rel="noreferrer">http://www.yoursite.com/sitemap.axd</a></p> </blockquote> <p>...your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other method is up to the HTTP Handler implementation.</p> <p>Here's roughly what it would look like:</p> <pre><code>void IHttpHandler.ProcessRequest(HttpContext context) { // // Important to return qualified XML (text/xml) for sitemaps // context.Response.ClearHeaders(); context.Response.ClearContent(); context.Response.ContentType = "text/xml"; // // Create an XML writer // XmlTextWriter writer = new XmlTextWriter(context.Response.Output); writer.WriteStartDocument(); writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); // // Now add entries for individual pages.. // writer.WriteStartElement("url"); writer.WriteElementString("loc", "http://www.codingthewheel.com"); // use W3 date format.. writer.WriteElementString("lastmod", postDate.ToString("yyyy-MM-dd")); writer.WriteElementString("changefreq", "daily"); writer.WriteElementString("priority", "1.0"); writer.WriteEndElement(); // // Close everything out and go home. // result.WriteEndElement(); result.WriteEndDocument(); writer.Flush(); } </code></pre> <p>This code can be improved but that's the basic idea.</p>
<p>Custom handler to generate the sitemap. </p>
3,076
<p>We're thinking of buying a PETG-powered printer. When researching printers available on the market, there are machines with a 100 microns. I was wondering if there are machines with a 50 microns or close to 50 micros? Otherwise, why not?</p>
<blockquote> <p>I was wondering the other day why don't all three motors move at the same time?</p> </blockquote> <p>That is perfectly possible for most printers (with limitations, &quot;3D Printing&quot; with all steppers being used is called &quot;non-planar&quot; printing), but there are some major cons you need to deal with. First, there are not that many software suites that slice objects perfectly well like the &quot;normal&quot; per &quot;fixed/variable layer height&quot; slicing as the slicers are under developed. Second, it requires a specific tall and slender nozzle/print head, else the height of printing is very limited. Last, besides generally not being useful for rectangular prints (except for 90° overhanging structures<sup>1)</sup>), this method is only/best suitable for curved objects as the top layer will follow the contours of the object.</p> <blockquote> <p>It makes sense if a 3D printer really does print with all three motors moving.</p> </blockquote> <p>No, it does not make sense, the essentials of 3D printing it that it produces a 3D object, not that all stepper motors should be running simultaneously.</p> <blockquote> <p>Won't it also be more efficient if they do 3D print in all axes?</p> </blockquote> <p>Not necessarily, there are limitations to non-planar printing like geometry and print quality, but, you could (in some cases) print with less support material.</p> <hr /> <p><sup>1)</sup> : From <a href="https://xyzdims.com/2021/03/03/3d-printing-90-overhangs-without-support-structure-with-non-planar-slicing-on-3-axis-printer/" rel="nofollow noreferrer">Rene K. Mueller, published March 3, 2021, https://xyzdims.com</a>: <a href="https://i.stack.imgur.com/eaJm0.png" rel="nofollow noreferrer" title="Non-planar slicing for printing 90° overhangs are tilted sliced"><img src="https://i.stack.imgur.com/eaJm0.png" alt="Non-planar slicing for printing 90° overhangs are tilted sliced" title="Non-planar slicing for printing 90° overhangs are tilted sliced" /></a> <a href="https://i.stack.imgur.com/Liiiw.png" rel="nofollow noreferrer" title="Non-planar slicing for printing 90° overhangs are conically sliced"><img src="https://i.stack.imgur.com/Liiiw.png" alt="Non-planar slicing for printing 90° overhangs are conically sliced" title="Non-planar slicing for printing 90° overhangs are conically sliced" /></a></p> <p><em>Note that these are <strong>demonstration</strong> pieces, normally you would rotate the print for 90° and print it sliced normal (planar).</em></p>
<p>The Z axis moves between each layer so you are indeed printing in the 3rd dimension. There are some techniques that move all three axis at the same time.</p>
1,925
<p>I've got a Windows DLL that I wrote, written in C/C++ (all exported functions are 'C'). The DLL works fine for me in VC++. I've given the DLL to another company who do all their development in VB. They seem to be having a problem linking to the functions. I haven't used VB in ten years and I don't even have it installed. What could be the problem?</p> <p>I've declared all my public functions as follows:</p> <pre><code>#define MYDCC_API __declspec(dllexport) MYDCCL_API unsigned long MYDCC_GetVer( void); . . . </code></pre> <p>Any ideas?</p> <hr> <p>Finally got back to this today and have it working. The answers put me on the right track but I found this most helpful:</p> <p><a href="http://www.codeproject.com/KB/DLL/XDllPt2.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/DLL/XDllPt2.aspx</a></p> <p>Also, I had a few problems passing strings to the DLL functions, I found this helpful:</p> <p><a href="http://www.flipcode.com/archives/Interfacing_Visual_Basic_And_C.shtml" rel="nofollow noreferrer">http://www.flipcode.com/archives/Interfacing_Visual_Basic_And_C.shtml</a></p> <hr>
<p>By using <code>__declspec</code> for export, the function name will get exported <em>mangled</em>, i.e. contain type information to help the C++ compiler resolve overloads.</p> <p>VB6 cannot handle mangled names. As a workaround, you have to de-mangle the names. The easiest solution is to link the DLL file using an <a href="http://msdn.microsoft.com/en-us/library/d91k01sh%28VS.80%29.aspx" rel="nofollow noreferrer">export definition</a> file in VC++. The export definition file is very simple and just contains the name of the DLL and a list of exported functions:</p> <pre><code>LIBRARY mylibname EXPORTS myfirstfunction secondfunction </code></pre> <p>Additionally, you have to specify the <code>stdcall</code> calling convention because that's the only calling convention VB6 can handle. There's a project using assembly injection to handle C calls but I guess you don't want to use this difficult and error-prone method.</p>
<p>A VB6 DLL is always a COM dll. I shall describe an example in as few words as possible. Suppose you have a ActiveX DLL project in VB6 with a class called CTest which contains a method as shown below</p> <p>Public Function vbConcat(ByVal a As String, ByVal b As String) As String vbConcat = a &amp; b End Function</p> <p>and you have set the project name as VBTestLib in VB6 project properties and you have compiled the project as F:\proj\VB6\ActiveXDLL\VBTestDLL.dll</p> <p>You need to register the dll using the Windows command regsvr32 F:\proj\VB6\ActiveXDLL\VBTestDLL.dll</p> <p>now your C++ code :</p> <p>#import "F:\proj\VB6\ActiveXDLL\VBTestDLL.dll" using namespace VBTestLib;</p> <p>void CDialogTestDlg::OnButton1() {</p> <pre><code> HRESULT hresult; CLSID clsid; _CTest *t; // a pointer to the CTest object _bstr_t bstrA = L"hello"; _bstr_t bstrB = L" world"; _bstr_t bstrR; ::CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("VBTestLib.CTest"), &amp;clsid); hresult= CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER, __uuidof(_CTest),(LPVOID*) &amp;t); if(hresult == S_OK) { bstrR = t-&gt;vbConcat(bstrA , bstrB); AfxMessageBox((char*)bstrR); } </code></pre> <p>}</p> <p>That's all there is to it, to get started off. </p>
6,052
<p>2 days into a 5-day build, I came home from work and found the build ruined because the build plate had slipped.</p> <p>I'm using a Raise 3D N2 Plus printer, with the standard glass build plate that comes with it, attached via 4 clips: two stationary ones at the back, and two standard binder clips at the front, which shipped with the printer, which hold the glass build plate plate to the heated surface beneath.</p> <p>The left-side clip had come off of the heated surface, remaining clipped to the top and bottom of the glass plate, and the whole thing slipped an inch or so. I immediately canceled the build, and I can start another one, but before I do I'd like to know how this happened and what I can do to prevent it from happening again.</p> <p>What typically causes the plate clips to come free? Is there anything I can do about it? Will adding more clips around the edges help? I'd really prefer not to ruin more builds if I can help it...</p>
<p>Your nozzle may have caught up with the print somehow pushing the binder clip off by moving the glass slate. </p> <p>Apparently this is a more <a href="https://www.3dhubs.com/talk/thread/raise3d-n2-plus-glass-bed-not-secure" rel="nofollow noreferrer">common</a> problem. Try adding more binder clips, this has been reported to help preventing shifting.</p> <p>Maybe with some ingenuity you could develop your own fastening system depending on the bed. Alternatively, you could make the underside of the glass a little sticky so that it does not move easily (a little PVA based glue maybe or hairspray, I've done that with my mouse mat with 3DLAC :) which is now not slipping from the desk).</p>
<p>Your nozzle may have caught up with the print somehow pushing the binder clip off by moving the glass slate. </p> <p>Apparently this is a more <a href="https://www.3dhubs.com/talk/thread/raise3d-n2-plus-glass-bed-not-secure" rel="nofollow noreferrer">common</a> problem. Try adding more binder clips, this has been reported to help preventing shifting.</p> <p>Maybe with some ingenuity you could develop your own fastening system depending on the bed. Alternatively, you could make the underside of the glass a little sticky so that it does not move easily (a little PVA based glue maybe or hairspray, I've done that with my mouse mat with 3DLAC :) which is now not slipping from the desk).</p>
923
<p>I'm using a custom-built inhouse application that generates a standard set of reports on a weekly basis. I have no access to the source code of the application, and everyone tells me there is no documentation available for the Oracle database schema. (Aargh!)</p> <p>I've been asked to define the specs for a variant of an existing report (e.g., apply additional filters to constrain the data set, and modify the layout slightly). This sounds simple enough in principle, but is difficult without any existing documentation. </p> <p>It's my understanding that the logs can't help me because the report only queries the database; it does not actually insert, delete, or update database values, so there is nothing to log (is this correct?).</p> <p>So my question is this: is there a tool or utility (Oracle or otherwise) that I can use to see the actual SQL statement that is being executed while the report generation job is still running? I figure, if I can see what tables are actually being accessed to produce the existing report, I'll have a very good starting point for exploring the schema and determining the correct SQL to use for my own report.</p>
<p>On the data dictionary side there are a lot of tools you can use to such as <a href="http://schemaspy.sourceforge.net/" rel="noreferrer">Schema Spy</a></p> <p>To look at what queries are running look at views sys.v_$sql and sys.v_$sqltext. You will also need access to sys.all_users</p> <p>One thing to note that queries that use parameters will show up once with entries like </p> <pre><code>and TABLETYPE=’:b16’ </code></pre> <p>while others that dont will show up multiple times such as:</p> <pre><code>and TABLETYPE=’MT’ </code></pre> <p>An example of these tables in action is the following SQL to find the top 20 diskread hogs. You could change this by removing the <strong>WHERE rownum &lt;= 20</strong> and maybe add <strong>ORDER BY module</strong>. You often find the module will give you a bog clue as to what software is running the query (eg: "TOAD 9.0.1.8", "JDBC Thin Client", "runcbl@somebox (TNS V1-V3)" etc)</p> <pre><code>SELECT module, sql_text, username, disk_reads_per_exec, buffer_gets, disk_reads, parse_calls, sorts, executions, rows_processed, hit_ratio, first_load_time, sharable_mem, persistent_mem, runtime_mem, cpu_time, elapsed_time, address, hash_value FROM (SELECT module, sql_text , u.username , round((s.disk_reads/decode(s.executions,0,1, s.executions)),2) disk_reads_per_exec, s.disk_reads , s.buffer_gets , s.parse_calls , s.sorts , s.executions , s.rows_processed , 100 - round(100 * s.disk_reads/greatest(s.buffer_gets,1),2) hit_ratio, s.first_load_time , sharable_mem , persistent_mem , runtime_mem, cpu_time, elapsed_time, address, hash_value FROM sys.v_$sql s, sys.all_users u WHERE s.parsing_user_id=u.user_id and UPPER(u.username) not in ('SYS','SYSTEM') ORDER BY 4 desc) WHERE rownum &lt;= 20; </code></pre> <p>Note that if the query is long .. you will have to query v_$sqltext. This stores the whole query. You will have to look up the ADDRESS and HASH_VALUE and pick up all the pieces. Eg:</p> <pre><code>SELECT * FROM sys.v_$sqltext WHERE address = 'C0000000372B3C28' and hash_value = '1272580459' ORDER BY address, hash_value, command_type, piece ; </code></pre>
<p>I had (have) a similar problem in a Java application. I wrote a JDBC driver wrapper around the Oracle driver so all output is sent to a log file. </p>
7,974
<p>My understanding is that <a href="http://www.wxwidgets.org" rel="noreferrer">wxWidgets</a> is for a number of programming languages (C++, Python, Perl, and C#/.NET) but that does not include C. Is there a similar framework for the C programming language, or is this not something that C is used for?</p>
<p>You can try <a href="http://www.gtk.org/" rel="nofollow noreferrer">GTK+</a>. I believe wxWidgets implementation for linux is written in GTK+.</p>
<p>Obviously No, Because it has predefined classes but if you insist you can try GTK which is for C.</p>
4,968
<p>One of those classic programming interview questions...</p> <p>You are given two marbles, and told that they will break when dropped from some certain height (and presumably suffer no damage if dropped from below that height). You’re then taken to a 100 story building (presumably higher than the certain height), and asked to find the highest floor your can drop a marble from without breaking it as efficiently as possible.</p> <p>Extra info</p> <ul> <li>You must find the correct floor (not a possible range)</li> <li>The marbles are both guaranteed to break at the same floor</li> <li>Assume it takes zero time for you to change floors - only the number of marble drops counts</li> <li>Assume the correct floor is randomly distributed in the building</li> </ul>
<p>The interesting thing here is how you can do it in the least amount of drops possible. Going to the 50th floor and dropping the first would be disastrous if the breaking floor is the 49th, resulting in us having to do 50 drops. We should drop the first marble at floor n, where n is the max amount of drops required. If the marble breaks at floor n, we may have to make n-1 drops after that. If the marble doesn't break we go up to floor 2n-1 and if it breaks here we have to drop the second marble n-2 times in the worst case. We continue like this up to the 100th floor and try to break it at 3n-2, 4n-3....<br> and n+(n-1)+(n-2)+...1 &lt;=100<br> <strong>n=14 Is the maximum drops required</strong></p>
<p>First thing I would do is use the dead simple algorithm that starts at floor 1 drops the marble one floor at a time until it reaches 100 or the marble breaks.</p> <p>Then I'd ask why should I spend time optimizing it until somone can show that it will be a problem. Too many times people get all hung up on finding the perfect complicated algorithm when a much simpler one will solve the problem. In other words don't optimize things until it's needed. </p> <p>This might be trick question to see if you are one of those people who can make a mountain out of a mole hill.</p>
2,826
<p>Other than the most obvious issue with the filament kinking in the tube, what other issues could arise when trying to print flexibles (<em>i.e. TPU/TPE, Nylon, etc.</em>) with a Bowden style extruder setup? </p> <p>Can the kinking issue be alleviated by a well-constrained filament path (<em>proper ID</em>) in a properly sized Bowden tube?</p>
<p>As a user of an UM3E, which uses Bowden tubes and has TPU as an available material, I can tell you that the kinking issues can be alleviated or downright avoided. </p> <p>I've printed quite a few things with the Ultimaker-brand TPU 95, and never had problems with kinking in the tube. </p> <p>Ultimaker uses 2.85 mm filament, with Bowden tubes adapted for those and a rear motor, i.e. the motor is on the back on the printer and not right on top of the print head.</p> <p>I personally wouldn't consider Nylon as one of the really flexible material, but that's my opinion. Never had kinking in the Bowden tube with Nylon either in my UM3E.</p>
<p>To also validate the first answer, I have been printing with TPU95A for a number of years and it has been one of the most reliable materials to use. The strength of the product alongside the flex makes it a test and production based outcome with fewer issues. My printer for the most part of this experience was the Ultimaker 2+ that has a similar set up to the UM3 with a more traditional hot end.</p> <p>Cautions: Some older material profiles have the heatbed at 60c. I have always had better outcomes from room temp (no heat on the bed). </p>
1,057
<ul> <li>Printer: Kobra Max</li> <li>Nozzle: 0.4 mm</li> <li>Material: PLA</li> <li>Slicer :Cura</li> </ul> <p>I have printed 1 model 3 times with different settings (different temperatures and different bed temperatures).</p> <ul> <li>Try 1: 190 °C / 50 °C</li> <li>Try 2: 210 °C / 70 °C</li> <li>Try 3: 230 °C / 50 °C</li> </ul> <p>All 3 models show a seam.</p> <p>How / where do I best hide this seam?</p> <p><a href="https://i.stack.imgur.com/zmV36.jpg" rel="nofollow noreferrer" title="Photo of three printed models with the same printing error"><img src="https://i.stack.imgur.com/zmV36.jpg" alt="Photo of three printed models with the same printing error" title="Photo of three printed models with the same printing error" /></a></p> <p>These are some screenshots of the model in Fusion 360:</p> <p><a href="https://i.stack.imgur.com/x8b7D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x8b7D.png" alt="enter image description here" /></a></p>
<p>There are a bunch of possible causes for the seam. But the main one is retraction.</p> <p>In Cura the main setting affecting this is under '<strong>Travel</strong>'.</p> <p>In the '<strong>Travel</strong>' settings is '<strong>Enable retraction</strong>', and '<strong>Retract at layer change</strong>'.</p> <p>Retraction pulls the filament up and it doesn't make such a noticeable seam.</p>
<p>Hiding the seam isn't really possible when the object is rotationally symmetric. The closest you can get is hiding it &quot;statistically&quot; by distributing the seam randomly so it's fractionally-bad everywhere rather than fully-bad in one place. Depending on your needs, this might be good, or it might be awful. If you're hoping to clean up the seam in postprocessing, it's probably awful since there's not just one isolated point that needs fixing with a razor blade or something, but the whole print surface.</p> <p>One thing you can try, though, is turning on <em>wipe</em>. In Cura this is &quot;Outer Wall Wipe Distance&quot;. Setting it to 1-2 mm can go a long way to concealing the seam, especially if it's not bulging from ooze, which yours doesn't seem to be. Combined with random distribution, this might come out looking pretty good for your particular need.</p> <p>In general, how to deal with seams depends on whether the problem is cosmetic or functional. I'm assuming in your case it's cosmetic, but if it is functional (affecting fit of mechanical parts together, making a printed gear rotationally asymmetric, etc.) then one trick you can do is make an artificial <em>cut</em> into the surface at an arbitrary point and selecting to put the seam on the sharpest corner. This can help ensure the entire print fits inside the intended print volume, and is only missing a small amount of material on a scale smaller than the functional scale of the print.</p>
2,214
<p>I know you can put &lt;% if %> statements in the ItemTemplate to hide controls but the column is still there. You cannot put &lt;% %> statements into the LayoutTemplate which is where the column headings are declared, hence the problem. Does anyone know of a better way?</p>
<p>Here's another solution that I just did, seeing that I understand what you want to do:</p> <p><strong>Here's your ASCX / ASPX</strong></p> <pre><code> &lt;asp:ListView ID="ListView1" runat="server" DataSourceID="MyDataSource" ItemPlaceholderID="itemPlaceHolder" OnDataBound="ListView1_DataBound"&gt; &lt;LayoutTemplate&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;td&gt;Name&lt;/td&gt; &lt;td&gt;Age&lt;/td&gt; &lt;td runat="server" id="tdIsSuperCool"&gt;IsSuperCool&lt;/td&gt; &lt;/tr&gt; &lt;asp:PlaceHolder ID="itemPlaceHolder" runat="server" /&gt; &lt;/table&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td&gt;&lt;%# Eval("Name") %&gt;&lt;/td&gt; &lt;td&gt;&lt;%# Eval("Age") %&gt;&lt;/td&gt; &lt;td runat="server" id="myCol" visible='&lt;%# (bool)Eval("IsSuperCool") %&gt;'&gt;true&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:ListView&gt; &lt;asp:ObjectDataSource ID="MyDataSource" runat="server" DataObjectTypeName="BusinessLogicLayer.Thing" SelectMethod="SelectThings" TypeName="BusinessLogicLayer.MyObjectDataSource" /&gt; </code></pre> <p><strong>Here's the code behind</strong></p> <pre><code>/// &lt;summary&gt; /// Handles the DataBound event of the ListView1 control. /// &lt;/summary&gt; /// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt; /// &lt;param name="e"&gt;The &lt;see cref="System.EventArgs"/&gt; instance containing the event data.&lt;/param&gt; protected void ListView1_DataBound(object sender, EventArgs e) { ListView1.FindControl("tdIsSuperCool").Visible = false; } </code></pre> <p>Do whatever you want in the databound. Because the column is now runat server, and you're handling the DataBound of the control, when you do ListView1.FindControl("tdIsSuperCool") you're in the Layout template so that works like a champ.</p> <p>Put whatever business logic that you want to control the visibility of the td and you're good.</p>
<p>You can always set the column width to 0 (zero) if you don't find a better way.</p>
9,622
<p>I have a web application running on a Gentoo-based LAMP stack. My customers buy the software as a service and I host everything. However, there is some demand for on-site deployment inside the clients' own networks.</p> <p>Currently, because I host the system, there is no built-in license management in the app. I bill based on user accounts and data capacity (it's a processing and analysis app for metering data) and I just set up whatever the client pays for and the client can't setup those things himself. Even without on-site installation, that should be changed for better scalability anyway.</p> <p>I am looking for a license managment framework and/or typical approaches that you have implemented yourselves or have seen to work well elsewhere. My requirements are:</p> <ul> <li>"safe enough" rather than "military grade"</li> <li>very much non-obtrusive</li> <li>prevent the owner of a license from running the system in multiple plants when he has only licensed one</li> <li>make the number of user accounts and the data capacity both reasonably tamper-proof and easy to up- / downgrade</li> <li>work without an Internet connection (having a completely self-contained system would be the main point of opting for the on-site solution), though it might be acceptable if there has to be a temporary connection during installation</li> </ul> <p>For some of the on-site scenarios, there would be a requirement for some particular OS, typically some version of Windows Server, but various Linux distros are getting more popular as well, especially in the public sector.</p> <p>From a user's point of view, I am quite satisfied with the license management in FogBugz, it seems Joel Spolsky is satisfied with it from a vendor's point of view, and it is cross-platform, so it would make a great reference of what I'm aiming at.</p>
<p>Don't. Every hour that you spend writing a license key system is an hour that you are not spending fixing bugs or adding features. By writing a license management system, you are spending resources in order to reduce the value of your product!</p> <p>Copyright your code, have a lawyer and be ready to prosecute anyone who violates your copyright, and call it a day.</p>
<p>I am sure you can get to the serial number of the cpu on most os's; you could use that, after all if they transplant the cpu its safe to assume that the old machine would no longer be in use?</p> <p>Secondly a web service could be used to find out the current data capacity and what the client has paid for.</p>
7,437
<p>I'm trying to rebuild an old metronome application that was originally written using <code>MFC</code> in C++ to be written in <code>.NET</code> using <code>C#</code>. One of the issues I'm running into is playing the midi files that are used to represent the metronome "clicks".</p> <p>I've found a few articles online about playing <code>MIDI</code> in .NET, but most of them seem to rely on custom libraries that someone has cobbled together and made available. I'm not averse to using these, but I'd rather understand for myself how this is being done, since it seems like it <em>should</em> be a mostly trivial exercise.</p> <p>So, am I missing something? Or is it just difficult to use MIDI inside of a .NET application?</p>
<p>I think you'll need to p/invoke out to the windows api to be able to play midi files from .net.</p> <p>This codeproject article does a good job on explaining how to do this: <a href="http://www.codeproject.com/KB/audio-video/vbnetSoundClass.aspx" rel="nofollow noreferrer">vb.net article to play midi files</a></p> <p>To rewrite this is c# you'd need the following import statement for mciSendString:</p> <pre><code>[DllImport("winmm.dll")] static extern Int32 mciSendString(String command, StringBuilder buffer, Int32 bufferSize, IntPtr hwndCallback); </code></pre> <p>Hope this helps - good luck!</p>
<p>System.Media.<strong>SoundPlayer</strong> is a good, simple way of playing WAV files. WAV files have some advantages over MIDI, one of them being that you can control precisely what each instrument sounds like (rather than relying on the computer's built-in synthesizer).</p>
3,027
<p>When using Groovy <code>MarkupBuilder</code>, I have places where I need to output text into the document, or call a function which outputs text into the document. Currently, I'm using the undefined tag <em>"text"</em> to do the output. Is there a better way to write this code?</p> <pre><code>li { text("${type.getAlias()} blah blah ") function1(type.getXYZ()) if (type instanceof Class1) { text(" implements ") ft.getList().each { if (it == '') return text(it) if (!function2(type, it)) text(", ") } } } </code></pre>
<p>Actually, the recommended way now is to use <code>mkp.yield</code>, e.g.,</p> <pre><code>src.p { mkp.yield 'Some element that has a ' strong 'child element' mkp.yield ' which seems pretty basic.' } </code></pre> <p>to produce</p> <pre><code>&lt;p&gt;Some element that has a &lt;strong&gt;child element&lt;/strong&gt; which seems pretty basic.&lt;/p&gt; </code></pre>
<p>Include a method:</p> <pre><code>void text(n){ builder.yield n } </code></pre> <p>Most likely you (I) copied this code from somewhere that had a text method, but you didn't also copy the text method. Since MarkupBuilder accepts any name for the name of a tag and browsers ignore unknown markup, it just happened to work.</p>
4,314
<p>I'm looking for the best JavaScript editor available as an Eclipse plugin. I've been using Spket which is good. But, is there more better one?</p>
<p><a href="http://amateras.sourceforge.jp/cgi-bin/fswiki_en/wiki.cgi?page=EclipseHTMLEditor" rel="nofollow noreferrer">Eclipse HTML Editor Plugin</a></p> <p>I too have struggled with this totally obvious question. It seemed crazy that this wasn't an extremely easy-to-find feature with all the web development happening in Eclipse these days.</p> <p>I was very turned off by Aptana because of how bloated it is, and the fact that it starts up a local web server (by default on port 8000) everytime you start Eclipse and <a href="http://forums.aptana.com/viewtopic.php?t=5269" rel="nofollow noreferrer">you can't disable this functionality</a>. Adobe's port of JSEclipse is now a 400Mb plugin, which is equally insane.</p> <p>However, I just found a super-lightweight JavaScript editor called <a href="http://amateras.sourceforge.jp/cgi-bin/fswiki_en/wiki.cgi?page=EclipseHTMLEditor" rel="nofollow noreferrer">Eclipse HTML Editor Plugin</a>, made by Amateras, which was exactly what I was looking for.</p>
<p>Oracle Workshop for WebLogic (formally BEA Workshop) has excellent support for JavaScript and for visually editing HTMLs. It support many servers, not only WebLogic, including Tomcat, JBoss, Resin, Jetty, and WebSphere. </p> <p>It recently became free, check out <a href="http://blog.zvikico.com/2008/08/the-best-jspstrutsjsf-development-tool-is-now-free.html" rel="nofollow noreferrer">my post</a> about it. Given that it was an expensive product not long ago, I guess it's worth checking out.</p>
4,433
<p>How do you store file permissions in a repository? A few files need to be read-only to stop a third party program from trashing it but after checking out of the repository they are set to read-write.</p> <p>I looked on google and found a <a href="http://mamchenkov.net/wordpress/2005/04/27/subversion-and-file-permissions/" rel="noreferrer">blog post from 2005</a> that states that Subversion doesn't store file-permissions. There are patches and hook-scripts listed (only one url still exists). Three years later does Subversion still not store file permissions and are hooks the only way to go about this? (I've never done hooks and rather use something that is native to Subversion.)</p>
<p>One possible solution would be to write a script that you check in with the rest of your code and which is run as the first step of your build process.</p> <p>This script runs through your copy of the codebase and sets read permissions on certain files.</p> <p>Ideally the script would read the list of files from a simple input file. This would make it easy to maintain and easy for other developers to understand which files get marked as read-only.</p>
<p>Consider using <a href="http://svnbook.red-bean.com/nightly/en/svn.advanced.locking.html" rel="nofollow noreferrer"><code>svn lock</code></a> to disallow others from writing to the file.</p>
8,005
<p>Is it possible to embed an inline search box into a web page which provides similar functionality to the <a href="http://www.ie7pro.com/inline-search.html" rel="noreferrer">IE7Pro Inline Search</a> or similar plugins for Firefox/Safari?</p>
<p>If I understand your schema and question correctly, how about something like this:</p> <pre><code>select student_name, score from students join (select student_answers.student_id, count(*) as score from student_answers, answer_key group by student_id where student_answers.question_id = answer_key.question_id and student_answers.answer = answer_key.answer) as student_scores on students.student_id = student_scores.student_id where score &gt;= 7 order by score, student_name </code></pre> <p>That should select the students with a score of 7 or more, for example. Just adjust the where clause for your purposes.</p>
<p>The architecture you are talking about could become very cumbersome in the long run, and if you need to change the questions it means more changes to the UDF you are using.</p> <p>I would think you could probably do your analysis in code without necessarily de-normalizing your database. De-normalization could also lend to inflexibility, or at least added expense to update, down the road.</p>
4,244
<p>I'm working on a project where I'm coding in C in a UNIX environment. I've been using the lint tool to check my source code. Lint has been around a long time (since 1979), can anyone suggest a more recent code analysis tool I could use ? Preferably a tool that is free.</p>
<p>Don't overlook the compiler itself. Read the compiler's documentation and find all the warnings and errors it can provide, and then enable as many as make sense for you.</p> <p>Also make sure to tell your compiler to treat warnings like errors so you're forced to fix them right away (<code>-Werror</code> on gcc). By the way, don't be fooled <code>-Wall</code> on gcc does <em>not</em> enable all warnings.</p> <p>You may want to check <a href="http://valgrind.org" rel="nofollow noreferrer"><code>valgrind</code></a> (free!) — it &quot;automatically detect[s] many memory management and threading bugs, and profile[s] your programs in detail.&quot; It isn't a static checker, but it's a great tool!</p>
<p>There is a "-Weffc++" option for gcc which according to the Mac OS X man page will:</p> <blockquote> <p>Warn about violations of the following style guidelines from Scott Meyers' Effective C++ book:</p> </blockquote> <p><strong><em>[snip]</em></strong></p> <p>I know you asked about C, but this is the closest I know of..</p>
2,502
<p>Say I have a list as follows:</p> <ul> <li>item1</li> <li>item2</li> <li>item3</li> </ul> <p>Is there a CSS selector that will allow me to directly select the last item of a list? In this case item 3.</p> <p>Cheers!</p>
<p>Not that i'm aware of. The traditional solution is to tag the first &amp; last items with class="first" &amp; class="last" so you can identify them.</p> <p>The CSS psudo-class <a href="http://www.w3.org/TR/CSS2/selector.html#first-child" rel="noreferrer">first-child</a> will get you the first item but not all browsers support it. CSS3 will have <a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#last-child-pseudo" rel="noreferrer">last-child too</a> (this is currently supported by Firefox, Safari but not IE 6/7/beta 8)</p>
<p>The answer for this question should be updated! IE9 + Firefox (for a while back) + Chrome, Safari all support: <code>last-of-type</code> or <code>last-child</code> </p>
7,411
<p>When I load my iPhone app it always loads a black screen first then pops up the main window. This happens even with a simple empty app with a single window loaded. </p> <p>I've noticed that when loading, most apps zoom in on the main window (or scale it to fit the screen, however you want to think about it) and then load the content of the screen, with no black screen (see the Contacts app for an example).</p> <p>How do I achieve this effect?</p>
<p>Add a Default.png to your project. This should be the image you want shown instead of the black launch screen.</p>
<p>You can also take a screenshot of your app as an aid to creating the Default.png - while holding the Home button, press and release the Lock Sleep/Wake button. The screenshot can be find in your Camery Roll library in the Photos app and can be synced back to your desktop.</p>
8,888
<p>As an electrician newbie I have a question..</p> <h2>Short question</h2> <p>My power plug is attached to the wall outlet and three wires are at the end of it.. the blue, the brown and the green/yellow oen.</p> <p>How to determine which is the live, zero and ground wire WITHOUT depending on the colouring? I want to know this to always be able to check the wiring, if I don't trust it.</p> <p>Also, I have these sub questions that follow from my situation:</p> <ul> <li>Why does the test screwdriver lit up when connected to the apparant zero line?</li> <li>How can I determine the live/zero line using a multimeter</li> </ul> <h2>Situation</h2> <p>My tools:</p> <ul> <li>a test screw driver</li> <li>a multimeter</li> <li>the ANET A6 manual</li> </ul> <p>In the manual it states that</p> <ul> <li>brown is the live wire</li> <li>blue is the zero wire</li> <li>green/yellow is the ground wire</li> </ul> <p>I know that in some countries this colour coding is the standard and can be trusted. I just want to be able to check it.</p> <p>So, my first hypothesis would be.. if I put the test screw driver on the live (brown) wire, lay my thumb on the end, the internal bulb would glow. This did not happen. It did happen when I put it on the zero (blue) wire. So I am a bit confused by this.</p> <p>My second trick was using the multimeter. Using the positive and negative probes to determine the polarity and therefore decide how the current was flowing. But there was no sign of polarity... duh.. because I was of course on AC, which is always Alternating.. hence no sign information from a multimeter. So, how CAN I use a multimeter to determine the live/zero line? Maybe measure the current from live/zero to ground? Is that a safe option?</p> <p>PS: my first post on this forum.. so please correct me where needed</p>
<p>As it is alternating current, why are you interested to know which is which? (I'm referring to the blue and the brown wire, the green/yellow has an obvious purpose) </p> <p>E.g. a <a href="https://en.wikipedia.org/wiki/AC_power_plugs_and_sockets" rel="nofollow noreferrer">CEE 7/4 plug</a> can be flipped around in the CEE 7/3 socket. When you flip the plug (180&deg;), the brown and the blue switch places, it is all depending on how the electrician in your home attached the brown and blue wires in the socket and depends on the socket and plug you use.</p> <p>The only benefit would be that when you cut the power with a relay, you may want to have the power on the side of the relay, not the printer; but again, that does not matter when you flip the plug 180&deg;. Note that some plugs inhibit rotation, so it also depends on the plug and socket you use and where you are located.</p>
<p>As it is alternating current, why are you interested to know which is which? (I'm referring to the blue and the brown wire, the green/yellow has an obvious purpose) </p> <p>E.g. a <a href="https://en.wikipedia.org/wiki/AC_power_plugs_and_sockets" rel="nofollow noreferrer">CEE 7/4 plug</a> can be flipped around in the CEE 7/3 socket. When you flip the plug (180&deg;), the brown and the blue switch places, it is all depending on how the electrician in your home attached the brown and blue wires in the socket and depends on the socket and plug you use.</p> <p>The only benefit would be that when you cut the power with a relay, you may want to have the power on the side of the relay, not the printer; but again, that does not matter when you flip the plug 180&deg;. Note that some plugs inhibit rotation, so it also depends on the plug and socket you use and where you are located.</p>
1,243
<p>I had a working solution using ASP.NET MVC Preview 3 (was upgraded from a Preview 2 solution) that uses an untyped ViewMasterPage like so:</p> <pre><code>public partial class Home : ViewMasterPage </code></pre> <p>On Home.Master there is a display statement like this:</p> <pre><code>&lt;%= ((GenericViewData)ViewData["Generic"]).Skin %&gt; </code></pre> <p>However, a developer on the team just changed the assembly references to Preview 4.</p> <p>Following this, the code will no longer populate ViewData with indexed values like the above.</p> <p>Instead, ViewData["Generic"] is null.</p> <p>As per <a href="https://stackoverflow.com/questions/18787/aspnet-mvc-user-control-viewdata">this question</a>, ViewData.Eval("Generic") works, and ViewData.Model is also populated correctly.</p> <p>However, the reason this solution isn't using typed pages etc. is because it is kind of a legacy solution. As such, it is impractical to go through this fairly large solution and update all .aspx pages (especially as the compiler doesn't detect this sort of stuff).</p> <p>I have tried reverting the assemblies by removing the reference and then adding a reference to the Preview 3 assembly in the 'bin' folder of the project. This did not change anything. I have even tried reverting the Project file to an earlier version and that still did not seem to fix the problem.</p> <p>I have other solutions using the same technique that continue to work.</p> <p>Is there anything you can suggest as to why this has suddenly stopped working and how I might go about fixing it (any hint in the right direction would be appreciated)?</p>
<p>We made that change because we wanted a bit of symmetry with the [] indexer. The Eval() method uses reflection and looks into the model to retrieve values. The indexer only looks at items directly added to the dictionary.</p>
<p>I've decided to replace all instances of ViewData["blah"] with ViewData.Eval("blah"). However, I'd like to know the cause of this change if possible because:</p> <ol> <li>If it happens on my other projects it'd be nice to be able to fix.</li> <li>It would be nice to leave the deployed working code and not overwrite with these changes.</li> <li>It would be nice to know that nothing else has changed that I haven't noticed.</li> </ol>
8,712
<p>How would I remove the border from an iframe embedded in my web app? An example of the iframe is:</p> <pre><code>&lt;iframe src="myURL" width="300" height="300"&gt;Browser not compatible.&lt;/iframe&gt; </code></pre> <p>I would like the transition from the content on my page to the contents of the iframe to be seamless, assuming the background colors are consistent. The target browser is IE6 only and unfortunately solutions for others will not help.</p>
<p>Add the <code>frameBorder</code> attribute (note the <strong>capital ‘B’</strong>).</p> <p>So it would look like:</p> <pre><code>&lt;iframe src="myURL" width="300" height="300" frameBorder="0"&gt;Browser not compatible.&lt;/iframe&gt; </code></pre>
<pre><code>iframe src="XXXXXXXXXXXXXXX" marginwidth="0" marginheight="0" width="xxx" height="xxx" </code></pre> <p>Works with Firefox ;)</p>
9,073
<p>Why do elements with the CSS <code>position: fixed</code> applied to them cause Firefox to eat 100% CPU when scrolling the page they are in? And are there any workarounds?</p> <p>I've noticed this behavior on a few sites, for example the notification bar at the top of the page on StackOverflow. I'm using Linux in case that matters.</p>
<p>This is <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=201307" rel="nofollow noreferrer">bug #201307</a>.</p>
<p>Are you sure that there's a direct link here? Have you created a static HTML page with fixed elements to verify your theory? Given how widely these CSS properties are used, I'd think someone else would have noticed it by now, whatever browser/OS you're running.</p>
9,313
<p>I had an idea for a client-side language other than JavaScript, and I'd like to look into developing a Firefox plugin that would treat includes of this new language in a page, like &lt;script type="newscript" src="path/script.ns" />, just as if it were a natively supported language. The plugin would do all of the language parsing and ideally be able to perform every operation on the browser and the html and css within the web page just as JavaScript can.</p> <p>I've done a bunch of Googling and have found some articles on writing basic Firefox plugins, but nothing as complicated as this.</p> <p>Is this even possible?</p>
<p><a href="https://stackoverflow.com/questions/69982/writing-a-firefox-plugin-for-parsing-a-custom-client-side-language#70239">@Nathan de Vries</a>: no, actually, NPAPI plugins you suggested don't let one implement support for <code>&lt;script type=...&gt;</code>.</p> <p>OP: this is not easy, but look for PyDOM and PyXPCOM - language bindings for Python. The former does exactly what you asked for - for Python, but I'm unsure about its current status. In any case, it's very likely that you need to create your own build of Firefox to support additional script types.</p>
<p>Do you really want to tie your pages to your own custom scripting language? Or are you just looking to write your client-side code in something that's not javascript? If the latter try <a href="http://milescript.org/" rel="nofollow noreferrer">MileScript</a>, <a href="http://haxe.org/" rel="nofollow noreferrer">Haxe</a>, or <a href="http://code.google.com/webtoolkit/" rel="nofollow noreferrer">Google Web Toolkit</a></p>
9,541
<p>Plastic is used in 3D FDM/FFF printing partly because it had a wide temperature range for its glass state - where it can be flowed with some force, but won't flow due only to gravity.</p> <p>Most metals have a very narrow, or non-existant, glass state. They transition from solid to liquid with almost no flowable-but-not-liquid state.</p> <p>Are there any metals or alloys that display a glass transition state?</p>
<p>A few things are required for effective extrusion-style 3d printing materials:</p> <ul> <li>It must stay where placed by the nozzle long enough to harden (or, alternately for pastes and such, have a shear-thinning or thixotropic viscous profile so it will not flow under its own weight). </li> <li>If using a filament extruder, it must have a wide range of viscosity that varies gradually over a considerable temperature range. This is necessary to develop the proper "cap zone" semi-melt shearing behavior that allows the incoming filament to act like a piston and generate pressure upstream of the nozzle. Pellet extruders have a similar requirement but related to screw/wall shearing rather than filament/wall shearing. If using neither filament nor pellets, such as clay printers, the material must be pumpable by a positive-displacement pump. (It is possible to pump molten metal, but the cost is quite high.)</li> <li>It must form some kind of bond with previously-deposited solid material, without needing to be in a state that will rapidly flow and lose shape.</li> <li>It must have some combination of low shrinkage, the ability to creep at the printer's ambient temp, and/or low stiffness that allows consecutive layers to be stacked without an unacceptable amount of warping. </li> </ul> <p>Liquid metals tend to have a conflict between "Staying where you put it" and "bonding with the previous layer." In order for deposited metal to fully bond, the interface material needs to reach the melting point so a true fusion weld occurs. And in order to supply enough heat to remelt the interface without an additional heat source like an arc, the deposited molten metal needs to be very hot. So it will tend to run while it cools. High density and high heat capacity makes it run fast and cool slowly. </p> <p>Pretty much every DIY metal 3d print (such as made by wire-feed MIG welders) ends up looking something like this:</p> <p><a href="https://i.stack.imgur.com/FTyNd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FTyNd.png" alt="enter image description here"></a> <a href="https://3dprint.com/29944/diy-metal-printing-garage/" rel="nofollow noreferrer">https://3dprint.com/29944/diy-metal-printing-garage/</a></p> <p>In comparison, polymers have long molecular chains that allow them to "diffusion weld" and adhere WITHOUT fully remelting the interface. Molten liquid plastic will stick to solid plastic quite effectively. The interface only needs to get hot enough for appreciable diffusion to intertwine the molecular chains. This will occur between the glass point and melting point, without true fusion occurring. So you can print molten plastic at a temperature where it will stay in place long enough to harden, and still get good bonding.</p> <p>Metals also tend to be very stiff, which encourages warping. It is difficult to build a heated environment of sufficient temperature to properly stress-relieve the thermal contraction stress as the print progresses, whereas with plastic a heated build plate and warm enclosure can permit warping stresses to start relaxing as the print progresses. </p> <p><strong>It is possible to "FDM-style" 3d print filament/wire made of metal alloys that have a wide range between solidus and liquidus.</strong> It has <a href="https://www.adafruit.com/adablog/wp-content/uploads/2013/11/MetalPrinting.jpg" rel="nofollow noreferrer">been done using solder</a> and <a href="http://blog.reprap.org/2011/06/new-approach-to-printing-metals.html" rel="nofollow noreferrer">similar alloys</a>. However, between the warping stresses, poor layer bonding from inadequate interface re-melting, and use of soft low-melting alloys, <strong>the resulting printed parts will usually end up being weaker than if they had simply been printed in a strong plastic.</strong> For example, PEEK is nearly as strong as aluminum, and carbon fiber or fiberglass composite plastics can exceed metals on various performance metrics. So what's the point of printing with weak, brittle metal alloys?</p> <p>Over the years, lots of people have tried FDM-style metal printing, but no one has found it worthwhile to pursue in the long run. More typical DIY metal printing approaches like 3D MIG welding following by cleanup machining will produce better results.</p>
<p>I spent some time looking at making an FDM machine that would print bronze filament. An alloy commonly made into wire had a difference between the solidus and liquidus temperature of only 50 degrees C. I determined that one could make a conventional hot end, electrically heated, made of either molybdenum or tungsten.</p> <p>I did not determine how the bronze would behave in the 50 degree solid-to-liquid zone. I was more concerned about the solubility of the nozzle material in copper, for which I could find very little published data.</p> <p>From my experience welding, and from printing plastics with FDM, there could be a problem with layer adhesion. To really bond, the cooled material needs to be melted by the material being deposited in the next layer. This is complicated by the temperature of the cooled material, the thermal conductivity of the material, and the propensity of the material to form oxides. These could be mitigated by heating the object in an inert atmosphere.</p> <p>So, to answer the question, I would suggest looking at bronze alloys because they melt at moderate temperatures, and are less prone to oxidation than aluminum alloys.</p>
85
<p>This is my first time asking for some help on here and I have Googled, but only found a few reference to this issue. I know I am doing something dumb but I have no clue what it is. </p> <p>I get an unknown motherboard error every time I try to setup my MKS GEN L. At first I found that in the <code>boards.h</code> file there was no reference to this board and the <code>pins.h</code> file was not there either. I have added both of these in and still nothing. I have checked the <code>configuration.h</code> and as far as I can tell I cannot find the error. </p> <p>I have tried this in 1.1.9 and 2.x of marlin and get the same error.</p> <p>The message is:</p> <pre> Arduino: 1.8.9 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)" In file included from sketch\MarlinConfig.h:33:0, from C:\Users\name\OneDrive\Desktop\Ender 5 1.1.61 version (1)\Ender 5 1.1.61 version\Marlin\Marlin.ino:31: pins.h:235:4: error: #error "Unknown MOTHERBOARD value set in Configuration.h" #error "Unknown MOTHERBOARD value set in Configuration.h" ^~~~~ In file included from sketch\MarlinConfig.h:39:0, from C:\Users\jcgra\OneDrive\Desktop\Ender 5 1.1.61 version (1)\Ender 5 1.1.61 version\Marlin\Marlin.ino:31: SanityCheck.h:311:6: error: #error "BABYSTEP_ZPROBE_OFFSET requires a probe." #error "BABYSTEP_ZPROBE_OFFSET requires a probe." ^~~~~ SanityCheck.h:624:8: error: #error "Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN requires the Z_MIN_PIN to be defined." #error "Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN requires the Z_MIN_PIN to be defined." ^~~~~ SanityCheck.h:909:4: error: #error "HEATER_0_PIN not defined for this board." #error "HEATER_0_PIN not defined for this board." ^~~~~ exit status 1 #error "Unknown MOTHERBOARD value set in Configuration.h" This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. </pre> <p>My config file is as follows <a href="https://gist.github.com/cripto101/9e9e36f509352ab19033beb189e166d7" rel="nofollow noreferrer">Config.h</a>.</p> <p>Please let me know if there is anything else you might need to help with this matter and thank you for your time and attention.</p>
<p>The MKS GEN L board was added in Marlin release 1.1.7 .</p> <p>According to the configuration file you've linked and <a href="https://github.com/MarlinFirmware/Marlin/releases" rel="nofollow noreferrer">previous Marlin releases</a>, your copy of Marlin is release 1.1.6. While all Marlin releases before 1.1.7 had "010100" as "CONFIGURATION_H_VERSION", earlier versions had less features than listed in your configuration file.</p> <p>In Marlin 2.0.x, the MKS GEN L is <a href="https://github.com/MarlinFirmware/Marlin/blob/2.0.1/Marlin/src/core/boards.h#L66" rel="nofollow noreferrer">also</a> <a href="https://github.com/MarlinFirmware/Marlin/blob/2.0.1/Marlin/src/pins/ramps/pins_MKS_GEN_L.h" rel="nofollow noreferrer">available</a>.</p> <p>Since you said it was also unavailable in 2.0.x, please provide a copy of your entire 2.0.x setup.</p>
<p>As explained in the <a href="/a/11866/">answer by @towe</a>, you are using an older version of the configuration file, it appears that you aren't using the latest sources from the 1.1.x and the 2.0.x trees.</p> <p>In addition to the answer, the MKS GEN L is basically a RAMPS board with RAMPS pin layout except for a few pins. The board is defined in both <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/pins_MKS_GEN_L.h" rel="nofollow noreferrer">1.1.9</a> and <a href="https://github.com/MarlinFirmware/Marlin/blob/2.0.x/Marlin/src/pins/ramps/pins_MKS_GEN_L.h" rel="nofollow noreferrer">2.0.x</a> (if you scroll down you see that it includes the pin definition for a RAMPS layout: #include "pins_RAMPS.h"). This being said, you could get it to work in pre 1.1.7 release of Marlin if you must. Choosing a RAMPS board for <code>MOTHERBOARD</code> constant and overriding/defining <code>MOSFET_D_PIN</code> to 7, <code>X_CS_PIN</code> to 59 and <code>X_CS_PIN</code> to 63 will make the firmware work. But, it is advised to get the latest version, even Marlin 2.0.x will run fine on Arduino Mega 2560 based boards.</p>
1,569
<p>I previously asked about Version Cue 3 vs Subversion. I think this is a better question and someone suggested <a href="http://www.gridironsoftware.com/Flow/" rel="noreferrer">http://www.gridironsoftware.com/Flow/</a> I hope this question will allow others to join in and suggest other tools or give specific recommendation to using Version Que versus other tools.</p>
<p>Take a look at <a href="http://joshcarter.com/productivity/svn_hg_git_for_home_directory" rel="nofollow noreferrer">this article</a> comparing Subversion, Mercurial, Git and Bazaar for managing the files in a home directory, including image files and large Photoshop files that are being edited and versioned.</p> <p>EDIT: The link is dead and I can't find the article, however the information in the article is now severely outdated anyway. Today I would strongly recommend using Git-LFS (Large File System), with the file locking mechanism that was added in 2017, I believe. This is the solution I currently use, as it solves both the problem of needed to lock binary files, and avoids the inefficiencies of git when it comes to storing large files - which was one of the main points of that article.</p>
<p>Take a look at Perforce (<a href="http://www.perforce.com" rel="nofollow noreferrer">www.perforce.com</a>), particularly if you are managing these files in the context of development projects. It is a code-oriented system, but it supports binary files well and has a Photoshop plugin. P4 isn't free, but it is worth every penny if you need professional-grade SCM - it is solid, fast, flexible and easy to use. (I am a very satisfied customer.)</p>
5,688
<p>We have an ASP.NET application running at a customer site that uses ActiveDirectory for user login via the ActiveDirectoryMembershipProvider. Their primary domain controller that we were pointing to went down this morning, and in getting everything set back up the client was wondering if we could have a redundant connection to two domain controllers; i.e. specifying a primary and a backup AD server. A Google search proved fruitless - does anyone know if this can be done?</p>
<p>If ActiveDirectory couldn't handle multiple domain controllers then it wouldn't be a very good technology.</p> <p>You just need to make sure in your Membership configuration you are pointing to the 'Domain' rather than the 'Server' and then add two or more controllers to your domain.</p> <p>Generally if you are referring to the domain as "LDAP://server/DC=domain,DC=com" then you should be able to remove the "server" part and refer simply to "LDAP://DC=domain,DC=com"</p> <p>The following code project gives a long list of things you can do in Active Directory from C#: <a href="http://www.codeproject.com/KB/system/everythingInAD.aspx#7" rel="nofollow noreferrer">http://www.codeproject.com/KB/system/everythingInAD.aspx#7</a></p>
<p>It can be done, it will just take some work.</p> <p>You will need to create a class that inherits off of the ActiveDirectoryMemberhsipProvider and use it has your provider instead. That way you can maintain most of the functionality. Then setup a way to specify two connectionStringName properties, one for primary and one for secondary. You will also need to create the code to read the information from the config since you are changing it. Then just override the methods where you need to catch when the primary is down and switch to the secondary. This will be the most reusable way of doing it.</p> <p>There's probably other ways of doing it, but it will probably be hacky and not very reusable. Like testing the connection before each request and then setting the connectionstring that way.</p> <p>Based on the <a href="http://msdn.microsoft.com/en-us/library/system.web.security.activedirectorymembershipprovider.aspx" rel="nofollow noreferrer">MSDN documentation</a> on the class, this will probably be the only way to do it. They don't provide the functionality internal.</p>
7,797
<p>I'm generating some xml files that needs to conform to an xsd file that was given to me. How should I verify they conform?</p>
<p>The Java runtime library supports validation. Last time I checked this was the Apache Xerces parser under the covers. You should probably use a <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/Validator.html" rel="noreferrer">javax.xml.validation.Validator</a>.</p> <pre><code>import javax.xml.XMLConstants; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.*; import java.net.URL; import org.xml.sax.SAXException; //import java.io.File; // if you use File import java.io.IOException; ... URL schemaFile = new URL("http://host:port/filename.xsd"); // webapp example xsd: // URL schemaFile = new URL("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"); // local file example: // File schemaFile = new File("/location/to/localfile.xsd"); // etc. Source xmlFile = new StreamSource(new File("web.xml")); SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); try { Schema schema = schemaFactory.newSchema(schemaFile); Validator validator = schema.newValidator(); validator.validate(xmlFile); System.out.println(xmlFile.getSystemId() + " is valid"); } catch (SAXException e) { System.out.println(xmlFile.getSystemId() + " is NOT valid reason:" + e); } catch (IOException e) {} </code></pre> <p>The schema factory constant is the string <code>http://www.w3.org/2001/XMLSchema</code> which defines XSDs. The above code validates a WAR deployment descriptor against the URL <code>http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd</code> but you could just as easily validate against a local file.</p> <p>You should not use the DOMParser to validate a document (unless your goal is to create a document object model anyway). This will start creating DOM objects as it parses the document - wasteful if you aren't going to use them.</p>
<p>I had to validate an XML against XSD just one time, so I tried XMLFox. I found it to be very confusing and weird. The help instructions didn't seem to match the interface.</p> <p>I ended up using LiquidXML Studio 2008 (v6) which was much easier to use and more immediately familiar (the UI is very similar to Visual Basic 2008 Express, which I use frequently). The drawback: the validation capability is not in the free version, so I had to use the 30 day trial.</p>
3,656
<p>I have three tables: page, attachment, page-attachment</p> <p>I have data like this:</p> <pre><code>page ID NAME 1 first page 2 second page 3 third page 4 fourth page attachment ID NAME 1 foo.word 2 test.xsl 3 mm.ppt page-attachment ID PAGE-ID ATTACHMENT-ID 1 2 1 2 2 2 3 3 3 </code></pre> <p>I would like to get the number of attachments per page <strong>also when that number is 0</strong>. I have tried with: </p> <pre><code>select page.name, count(page-attachment.id) as attachmentsnumber from page inner join page-attachment on page.id=page-id group by page.id </code></pre> <p>I am getting this output: </p> <pre><code>NAME ATTACHMENTSNUMBER second page 2 third page 1 </code></pre> <p>I would like to get this output:</p> <pre><code>NAME ATTACHMENTSNUMBER first page 0 second page 2 third page 1 fourth page 0 </code></pre> <p>How do I get the 0 part?</p>
<p>Change your "inner join" to a "left outer join", which means "get me all the rows on the left of the join, even if there isn't a matching row on the right."</p> <pre><code>select page.name, count(page-attachment.id) as attachmentsnumber from page left outer join page-attachment on page.id=page-id group by page.name </code></pre>
<p>Use this:</p> <pre><code>SELECT p.name,( SELECT COUNT(*) FROM [page-attachment] pa WHERE pa.[PAGE-ID] = p.id) as attachmentsnumber FROM page p </code></pre>
5,737
<p>What is the purpose of annotations in Java? I have this fuzzy idea of them as somewhere in between a comment and actual code. Do they affect the program at run time?</p> <p>What are their typical usages?</p> <p>Are they unique to Java? Is there a C++ equivalent?</p>
<p>Annotations are primarily used by code that is inspecting other code. They are often used for modifying (i.e. decorating or wrapping) existing classes at run-time to change their behavior. Frameworks such as <a href="http://www.junit.org/" rel="noreferrer">JUnit</a> and <a href="http://www.hibernate.org/" rel="noreferrer">Hibernate</a> use annotations to minimize the amount of code you need to write yourself to use the frameworks.</p> <p>Oracle has <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/language/annotations.html" rel="noreferrer">a good explanation of the concept and its meaning in Java</a> on their site.</p>
<p><a href="https://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why">When do you use Java&#39;s @Override annotation and why?</a> The link refers to a question on when one should use the override annotation(@override).. This might help understand the concept of annotation better.Check out.</p>
4,396
<p>In slicer G-code is it possible to set the probe Z offset for the first layer only?</p> <p>For my stock E3 plate I find -4.125 mm best however for glass I need to go to -4.175 mm for the first layer to get better adhesion. So it's a manual process every time. Any way to tell the slicer do the first layer at -4.175 mm and next ones at -4.125 mm?</p>
<p>I don't understand the reasoning behind a first layer having a different offset from the following layers, but, You can manually add a re-definition of the current height after the first layer, suppose your first layer is 0.2 mm, you just need to tell the printer to move to a slightly higher next layer to redefine this as a different Z-offset.</p> <ul> <li>From a G-code file find the start of the second layer:<br><code>G0 F600 X141.541 Y109.467 Z0.37</code></li> <li>Modify this to:<br><code>G0 F600 X141.541 Y109.467 Z0.42</code></li> <li>Now insert the following command:<br><code>G92 X0.37</code></li> </ul> <p>Now it is like you have changed the Z-offset.</p> <p>The reason for not using <code>M206</code> is that is applied onto current offsets, if you accidentally save setting to memory after printing, it stores this offset. You can use <code>M206</code>, but use it carefully. A re-definition of the Z level is never stored, the next <code>G28</code> erases the effect, so does repowering the motors.</p>
<p>Trying to change the Z level (NOT the offset) during a print isn't a good idea UNLESS you know that all future moves will be &quot;relative&quot;.</p> <p>The <code>M206</code> (if you use Marlin) is the right way to set it! Depending on the slicer, just create TWO &quot;different&quot; printer definitions and add them to the startup G-codes.</p> <p>If you don't save it, a reset will return the z-offset to the &quot;saved&quot; value. Or consider resetting to a &quot;standard&quot; value in the ending G-code.</p> <p>Also, consider using &quot;baby-stepping&quot; (if you can), and manually adjusting things at the start of a print with a different surface.</p>
1,910
<p>I have a tree encoded in a MySQL database as edges:</p> <pre><code>CREATE TABLE items ( num INT, tot INT, PRIMARY KEY (num) ); CREATE TABLE tree ( orig INT, term INT FOREIGN KEY (orig,term) REFERENCES items (num,num) ) </code></pre> <p>For each leaf in the tree, <code>items.tot</code> is set by someone. For interior nodes, <code>items.tot</code> needs to be the sum of it's children. Running the following query repeatedly would generate the desired result.</p> <pre><code>UPDATE items SET tot = ( SELECT SUM(b.tot) FROM tree JOIN items AS b ON tree.term = b.num WHERE tree.orig=items.num) WHERE EXISTS (SELECT * FROM tree WHERE orig=items.num) </code></pre> <p>(note this actually doesn't work but that's beside the point)</p> <p>Assume that the database exists and the invariant are already satisfied. </p> <p>The question is:</p> <blockquote> <p><strong>What is the most practical way to update the DB while maintaining this requirement? Updates may move nodes around or alter the value of <code>tot</code> on leaf nodes. It can be assumed that leaf nodes will stay as leaf nodes, interior nodes will stay as interior nodes and the whole thing will remain as a proper tree.</strong></p> </blockquote> <p>Some thoughts I have had:</p> <ul> <li>Full Invalidation, after any update, recompute everything (Um... No)</li> <li>Set a trigger on the items table to update the parent of any row that is updated <ul> <li>This would be recursive (updates trigger updates, trigger updates, ...)</li> <li>Doesn't work, MySQL can't update the table that kicked off the trigger</li> </ul></li> <li>Set a trigger to schedule an update of the parent of any row that is updated <ul> <li>This would be iterative (get an item from the schedule, processing it schedules more items)</li> <li>What kicks this off? Trust client code to get it right?</li> <li>An advantage is that if the updates are ordered correctly fewer sums need to be computer. But that ordering is a complication in and of it's own.</li> </ul></li> </ul> <p>An ideal solution would generalize to other "aggregating invariants"</p> <p>FWIW I know this is "a bit overboard", but I'm doing this for fun (Fun: verb, Finding the impossible by doing it. :-)</p>
<p>You sound as if you're looking for three major things: code templates, refactoring tools, and auto-completion.</p> <p>The good news is that Xcode 3 and later come with superb auto-completion and template support. By default, you have to explicitly request completion by hitting the escape key. (This actually works in all <code>NSTextView</code>s; try it!) If you want to have the completions appear automatically, you can go to <strong>Preferences</strong> -> <strong>Code Sense</strong> and set the pop-up to appear automatically after a few seconds. You should find good completions for C and Objective-C code, and pretty good completions for C++.</p> <p>Xcode also has a solid template/skeleton system that you can use. You can see what templates are available by default by going to Edit -> Insert Text Macro. Of course, you don't want to insert text macros with the mouse; that defeats the point. Instead, you have two options:</p> <ol> <li>Back in <strong>Preferences</strong>,go to <strong>Key Bindings</strong>, and then, under <strong>Menu Key Bindings</strong>, assign a specific shortcut to macros you use often. I personally don't bother doing this, but I know plenty of great Mac devs who do</li> <li><p>Use the <code>CompletionPrefix</code>. By default, nearly all of the templates have a special prefix that, if you type and then hit the escape key, will result in the template being inserted. You can use Control-/ to move between the completion fields.</p> <p>You can see <a href="http://crookedspin.com/2005/06/10/xcode-macros/" rel="noreferrer">a full list of Xcode's default macros and their associated <code>CompletionPrefix</code>es</a> at <a href="http://crookedspin.com" rel="noreferrer">Crooked Spin</a>.</p> <p>You can also add your own macros, or modify the defaults. To do so, edit the file <code>/Developer/Library/Xcode/Specifications/{C,HTML}.xctxtmacro</code>. The syntax should be self-explanatory, if not terribly friendly.</p></li> </ol> <p>Unfortunately, if you're addicted to R#, you will be disappointed by your refactoring options. Basic refactoring is provided within Xcode through the context menu or by hitting Shift-Apple-J. From there, you can extract and rename methods, promote and demote them through the class hierarchy, and a few other common operations. Unfortunately, neither Xcode nor any third-party utilities offer anything approaching Resharper, so on that front, you're currently out of luck. Thankfully, Apple has already demonstrated versions of Xcode in the works that have vastly improved refactoring capabilities, so hopefully you won't have to wait too long before the situation starts to improve.</p>
<p>I found some xtmacro files in Xcode.app package: <strong>/Developer/Applications/Xcode.app/Contents/PlugIns/TextMacros.xctxtmacro/Contents/Resources</strong></p> <p>Installed Xcode ver. 3.2.5.</p>
4,080
<p>One of the guys I work with needs a custom control that would work like a multiline ddl since such a thing does not exist as far as we have been able to discover</p> <p>does anyone have any ideas or have created such a thing before<br> we have a couple ideas but they involve to much database usage </p> <p>We prefer that it be FREE!!!</p>
<p>From <a href="http://bytes.com/forum/thread16212.html" rel="noreferrer">this thread</a>, there are different ways to do this:</p> <pre><code>double r = 5.1234; System.out.println(r); // r is 5.1234 int decimalPlaces = 2; BigDecimal bd = new BigDecimal(r); // setScale is immutable bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); r = bd.doubleValue(); System.out.println(r); // r is 5.12 </code></pre> <hr> <pre><code>f = (float) (Math.round(n*100.0f)/100.0f); </code></pre> <hr> <pre><code>DecimalFormat df2 = new DecimalFormat( "#,###,###,##0.00" ); double dd = 100.2397; double dd2dec = new Double(df2.format(dd)).doubleValue(); // The value of dd2dec will be 100.24 </code></pre> <p>The <a href="http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html" rel="noreferrer">DecimalFormat()</a> seems to be the most dynamic way to do it, and it is also very easy to understand when reading others code.</p>
<p>There are two approaches in the standard library. One is to use java.text.DecimalFormat. The other more cryptic methods (String.format, PrintStream.printf, etc) based around java.util.Formatter should keep C programmers happy(ish).</p>
7,333
<p>I always tend to forget these built-in <strong>Symfony</strong> functions for making links.</p>
<p>If your goal is to have user-friendly URLs throughout your application, use the following approach:</p> <p>1) Create a routing rule for your module/action in the application's routing.yml file. The following example is a routing rule for an action that shows the most recent questions in an application, defaulting to page 1 (using a pager):</p> <pre><code>recent_questions: url: questions/recent/:page param: { module: questions, action: recent, page: 1 } </code></pre> <p>2) Once the routing rule is set, use the <code>url_for()</code> helper in your template to format outgoing URLs.</p> <pre><code>&lt;a href="&lt;?php echo url_for('questions/recent?page=1') ?&gt;"&gt;Recent Questions&lt;/a&gt; </code></pre> <p>In this example, the following URL will be constructed: <code>http://myapp/questions/recent/1.html</code>.</p> <p>3) Incoming URLs (requests) will be analyzed by the routing system, and if a pattern match is found in the routing rule configuration, the named wildcards (ie. the <code>:/page</code> portion of the URL) will become request parameters.</p> <p>You can also use the <code>link_to()</code> helper to output a URL without using the HTML <code>&lt;a&gt;</code> tag.</p>
<p>In addition, if you actually want a query string with that url, you use this: </p> <pre><code>link_to('My link name', 'yourmodule/youraction?key=value&amp;key2=value',array('query_string'=&gt;'page=2')); </code></pre> <p>Otherwise, it's going to try to route it as part of the url and likely break your action.</p>
5,465
<p>I am wanting to buy a 3D printer to add to my shop.</p> <p>I am an engineer and enjoy making/building things so the kit idea sounds fun and economical.</p> <p>I see Tronxy has two different styles for their larger printers:</p> <ul> <li>P802 (reprap frame) style</li> <li>X3 (metal frame) style.</li> </ul> <p>As far as I can see, both printers have the same basic resolution, accuracy, and material specs.</p> <ol> <li>What are the advantages/disadvantages/differences between the P802 and X3? </li> <li>How important is auto-leveling?</li> </ol>
<p>You can not tell this by looking at the STL file alone, because how much material will be used depends on the print settings (obviously, printing at 100% infill will consume much more material than 10%).</p> <p>The best way to check the material usage is to load the model into a slicer and slice it using your preferred settings. Most slicers will report the projected material usage, often in grams but sometimes in meters of filament (but the two figures are easily converted between each other if you know the density and diameter of your material).</p> <p>Here is an example in the Cura slicer:</p> <p><a href="https://i.stack.imgur.com/e23iM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/e23iM.png" alt="Cura print statistics"></a></p> <p>Simplify3D (after you click "prepare to print!") also shows you the projected print time and material usage and even the cost of the material (if you have previously entered the material cost per kilogram):</p> <p><a href="https://i.stack.imgur.com/pjcxO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pjcxO.png" alt="Simplify3D print statistics"></a></p>
<p>This is a link I found that analyzes your G-code ( filament usage, time, etc.): <a href="http://gcode.ws/" rel="nofollow noreferrer">gCodeViewer</a></p> <p>From the description (emphasis is mine):</p> <blockquote> <ul> <li>Analyze GCode <ul> <li>Print time, <strong><em>amount of plastic used</em></strong>, layer height, etc. for whole file and for single layer</li> </ul></li> </ul> </blockquote> <p>Here is a screenshot:</p> <blockquote> <p><a href="https://i.stack.imgur.com/pDsuL.png" rel="nofollow noreferrer" title="Screenshot"><img src="https://i.stack.imgur.com/pDsuL.png" alt="Screenshot" title="Screenshot"></a></p> </blockquote>
549
<p>Anybody have a script or alias to find untracked (really: unadded) files in a Perforce tree?</p> <p>EDIT: I updated the accepted answer on this one since it looks like P4V added support for this in the January 2009 release.</p>
<p><strong>EDIT:</strong> Please use <code>p4 status</code> now. There is no need for jumping through hoops anymore. See @ColonelPanic's <a href="https://stackoverflow.com/a/13864328/39648">answer</a>.</p> <p>In the Jan 2009 version of P4V, you can right-click on any folder in your workspace tree and click "reconcile offline work..." </p> <p>This will do a little processing then bring up a split-tree view of files that are not checked out but have differences from the depot version, or not checked in at all. There may even be a few other categories it brings up. </p> <p>You can right-click on files in this view and check them out, add them, or even revert them.</p> <p>It's a very handy tool that's saved my ass a few times.</p> <p>EDIT: ah the question asked about scripts specifically, but I'll leave this answer here just in case.</p>
<p>In P4V, under the "View" menu item choose "Files in Folder" which brings up a new tab in the right pane. To the far right of the tabs there is a little icon that brings up a window called "Files in Folder" with 2 icons. Select the left icon that looks like a funnel and you will see several options. Choose "Show items not in Depot" and all the files in the folder will show up. Then just right-click on the file you want to add and choose "Mark for Add...". You can verify it is there in the "Pending" tab. Just submit as normal (Ctrl+S).</p>
3,067
<p>I'm interested in learning some (ideally) database agnostic ways of selecting the <em>n</em>th row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: </p> <ul> <li>SQL Server</li> <li>MySQL</li> <li>PostgreSQL</li> <li>SQLite</li> <li>Oracle</li> </ul> <p>I am currently doing something like the following in SQL Server 2005, but I'd be interested in seeing other's more agnostic approaches:</p> <pre><code>WITH Ordered AS ( SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS RowNumber, OrderID, OrderDate FROM Orders) SELECT * FROM Ordered WHERE RowNumber = 1000000 </code></pre> <p>Credit for the above SQL: <a href="https://web.archive.org/web/20101103031717/http://weblogs.asp.net/Firoz/archive/2005/06/12/411949.aspx" rel="noreferrer">Firoz Ansari's Weblog</a></p> <p><strong>Update:</strong> See <a href="https://stackoverflow.com/questions/16568/how-to-select-the-nth-row-in-a-sql-database-table#42765">Troels Arvin's answer</a> regarding the SQL standard. <em>Troels, have you got any links we can cite?</em></p>
<p>There are ways of doing this in optional parts of the standard, but a lot of databases support their own way of doing it.</p> <p>A really good site that talks about this and other things is <a href="http://troels.arvin.dk/db/rdbms/#select-limit" rel="noreferrer">http://troels.arvin.dk/db/rdbms/#select-limit</a>.</p> <p>Basically, PostgreSQL and MySQL supports the non-standard:</p> <pre><code>SELECT... LIMIT y OFFSET x </code></pre> <p>Oracle, DB2 and MSSQL supports the standard windowing functions:</p> <pre><code>SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY key ASC) AS rownumber, columns FROM tablename ) AS foo WHERE rownumber &lt;= n </code></pre> <p>(which I just copied from the site linked above since I never use those DBs)</p> <p><em>Update:</em> As of PostgreSQL 8.4 the standard windowing functions are supported, so expect the second example to work for PostgreSQL as well.</p> <p><em>Update:</em> SQLite added window functions support in version 3.25.0 on 2018-09-15 so both forms also work in SQLite.</p>
<p>unbelievable that you can find a SQL engine executing this one ...</p> <pre><code>WITH sentence AS (SELECT stuff, row = ROW_NUMBER() OVER (ORDER BY Id) FROM SentenceType ) SELECT sen.stuff FROM sentence sen WHERE sen.row = (ABS(CHECKSUM(NEWID())) % 100) + 1 </code></pre>
3,730
<p>The manual page for <code>XML::Parser::Style::Objects</code> is horrible. A simple hello world style program would really be helpful.</p> <p>I really wanted to do something like this: (not real code of course)</p> <pre><code>use XML::Parser; my $p = XML::Parser-&gt;new(Style =&gt; 'Objects', Pkg =&gt; 'MyNode'); my $tree = $p-&gt;parsefile('foo.xml'); $tree-&gt;doSomething(); MyNode::doSomething() { my $self = shift; print "This is a normal node"; for $kid ($self-&gt;Kids) { $kid-&gt;doSomething(); } } MyNode::special::doSomething() { my $self = shift; print "This is a special node"; } </code></pre>
<p>When ever I need to do something similar, usually I end up using <a href="http://search.cpan.org/~ebohlman/XML-Parser-EasyTree-0.01/EasyTree.pm" rel="nofollow noreferrer">XML::Parser::EasyTree </a> it has better documentation and is simpler to use.</p> <p>I highly recommend it.</p>
<p>When ever I need to do something similar, usually I end up using <a href="http://search.cpan.org/~ebohlman/XML-Parser-EasyTree-0.01/EasyTree.pm" rel="nofollow noreferrer">XML::Parser::EasyTree </a> it has better documentation and is simpler to use.</p> <p>I highly recommend it.</p>
5,528
<p>Does anyone know of any free tools that can assist in converting an <code>SQL2005</code> database back to <code>SQL2000</code> format? I know that you can script all the objects and then do a dump of the data, but this is a lot of work to do manually.</p>
<p>Reviewing some other related questions I just found Microsoft's <a href="http://www.codeplex.com/sqlhost/Wiki/View.aspx?title=Database%20Publishing%20Wizard" rel="nofollow noreferrer">Database Publishing Wizard</a>. It does most of what I need, although I have used nVarChar(max) in a couple of places and it simply fails to handle those cases and bombs out without generating anything.</p>
<p>Have you considered using DTS to transfer the data across? It should be independant of the version.</p>
6,457
<p>I have heard umpteen times that we 'should not mix business logic with other code' or statements like that. I think every single code I write (processing steps I mean) consists of logic that is related to the business requirements..</p> <p>Can anyone tell me what exactly consists of business logic? How can it be distinguished from other code? Is there some simple test to determine what is business logic and what is not?</p>
<p>Simply define what you are doing in plain English. When you are saying things businesswise, like "make those suffer", "steal that money", "destroy this portion of earth" you are talking about business layer. To make it clear, things that get you excited go here.</p> <p>When you are saying "show this here", "do not show that", "make it more beautiful" you are talking about the presentation layer. These are the things that get your designers excited.</p> <p>When you are saying things like "save this", "get this from database", "update", "delete", etc. you are talking about the data layer. These are the things that tell you what to keep forever at all costs.</p>
<p>For me, " <em>business logic</em> " makes up all the entities that represent data applicable to the problem domain, as well as the logic that decides on "what do do with the data"..</p> <p>So it should really consist of "data transport" (not access) and "data manipulation".. Actually data access (stuff hitting the DB) should be in a different layer, as should presentation code.</p>
6,034
<p>I'm trying to solve <a href="http://uva.onlinejudge.org/external/1/100.pdf" rel="noreferrer">the 3n+1 problem</a> and I have a <code>for</code> loop that looks like this: </p> <pre><code>for(int i = low; i &lt;= high; ++i) { res = runalg(i); if (res &gt; highestres) { highestres = res; } } </code></pre> <p>Unfortunately I'm getting this error when I try to compile with GCC:</p> <blockquote> <p>3np1.c:15: error: 'for' loop initial declaration used outside C99 mode</p> </blockquote> <p>I don't know what C99 mode is. Any ideas?</p>
<p>I'd try to declare <code>i</code> outside of the loop!</p> <p>Good luck on solving 3n+1 :-)</p> <p>Here's an example: </p> <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt; int main() { int i; /* for loop execution */ for (i = 10; i &lt; 20; i++) { printf("i: %d\n", i); } return 0; } </code></pre> <p>Read more on for loops in C <a href="https://www.tutorialspoint.com/cprogramming/c_for_loop.htm" rel="noreferrer">here</a>.</p>
<p>For Qt-creator: just add next lines to *.pro file...</p> <pre><code>QMAKE_CFLAGS_DEBUG = \ -std=gnu99 QMAKE_CFLAGS_RELEASE = \ -std=gnu99 </code></pre>
4,451
<p>My i3 MK3 is printing very well for solid parts of an object, but it messes up with infill.</p> <p><a href="https://i.stack.imgur.com/dc5BL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dc5BL.jpg" alt="Infill rough"></a></p> <p>As you can see in the image, the infill is broken into pieces and bends to that the surface becomes rough and the nozzle touches it next time it moves there, which probably does not make things better.</p> <p>I've read the <a href="https://www.prusaprinters.org/7-problems-affecting-quality-of-3d-prints" rel="nofollow noreferrer">Prusa problem page</a>, where they suggest three solutions:</p> <ul> <li>change infill type</li> <li>flexible filament (I'm using PETG, so this does not apply)</li> <li>lower printing speed</li> </ul> <p>I'm printing with 20% infill and I believe that this worked before at the same speed, so I'm tempted to say that both remaining options are options, but it should work without them.</p> <p>It also seems to me as if the infill is thinner that ordinary walls. Is the extrusion speed lower in case of infill? Is there a way of changing the extrusion speed for infill?</p> <p>Side note: my printer always tells me to upgrade to the latest firmware 3.5.1. Since I have just received the printer back from a warranty repair after the last firmware upgrade, I don't want to upgrade the firmware. Could the issue be related to firmware?</p> <p>Infos requested from comments:</p> <p>I'm basically using the Slic3r default settings for PETG. The only thing I adjusted is the temperature, since I'm using HDGlass PETG and there was a recommended temperature written on the spool. Relevant settings seem to be</p> <ul> <li>Filament settings <ul> <li>fan speed min 30 % max 50 %</li> <li>bridges fan speed 50 %</li> <li>enable fan below 20 s</li> <li>slow down below 20 s</li> <li>min print speed 15 mm/s</li> </ul></li> <li>Speed settings <ul> <li>Perimenters 45 mm/s</li> <li>Small perimeters 25 mm/s</li> <li>External perimeters 35 mm/s</li> <li>Infill 200 mm/s</li> <li>Solid infill 200 mm/s </li> <li>Top solid infill 50 mm/s</li> </ul></li> </ul>
<p>From your comments can be read that you print infill at 200&nbsp;mm/s. </p> <p>Know that 200&nbsp;mm/s is ridiculously fast (like high travelling speed), close to the limits of printing on certain machines (<a href="/a/8108">for an AtMega</a>)! It is hard for the filament to keep up at this speed. A value of 60&nbsp;mm/s would be a good value to start experimenting. Your infill is not rough, it just failed printing. I have printed kilometers of PETG, normal print speeds for my PETG are recommended at 30-50&nbsp;mm/s by my manufacturer; I get good results at 50-60&nbsp;mm/s. On my Ultimaker 3, 70&nbsp;mm/s is also feasible.</p> <hr> <p><em>Note that the filament you use seems to have rather <a href="https://www.formfutura.com/shop/product/hdglass-clear-238" rel="nofollow noreferrer">low printing temperatures</a> (195-225&nbsp;&deg;C) as opposed to the PETG filament (co-polymer) I'm used to. The manufacturer does not specify advised print speeds (other than "high", but what defines "high"?), but <a href="https://mevade.wordpress.com/2015/08/22/1-75mm-hdglass/" rel="nofollow noreferrer">this user posted</a> some of his print settings for this material. The overall speed of 60&nbsp;mm/s seems to support lower than 200&nbsp;mm/s print speeds.</em></p>
<p>I have dealt with this on infill as well on multiple MK3s.</p> <p>However, it was not the speed itself, but the hot end having difficulty extruding enough to keep up with the infill. </p> <p>Some things to try:</p> <ul> <li>Raise hot end temperature 5 degrees (melt filament faster)</li> <li>Lower infill speed, it will not affect your overall print time very much (surprisingly)</li> <li>A combination of the two above.</li> </ul> <p>Good luck!</p>
1,217
<p>What are the most common 3D printing file formats, and which one is more effective or used more than others?</p>
<h1>3D-Model Exchange Files</h1> <p>The <a href="https://all3dp.com/3d-file-format-3d-files-3d-printer-3d-cad-vrml-stl-obj/" rel="nofollow noreferrer">most common file formats</a> to exchange models for 3D printing are STL, OBJ, FBX, COLLADA, 3DS, IGES, STEP, and VRML/X3D.</p> <p>Of these, STL, OBJ, AMF, and 3MF are the most popular formats according to <a href="https://all3dp.com/3d-printing-file-formats/" rel="nofollow noreferrer">All3DP</a>. Pointing out which is the best is a subjective interpretation and not fit for SE sites. However, for many of the model sharing sites, like e.g. Thingiverse.com, many people share the STL file format.</p> <ul> <li>STL file format is short for “stereolithography” and is a 3D rendering that is containing a single color.</li> <li>OBJ file format, this format stores information about your 3D model. It encodes surface geometry of your 3D model and is also able to store color and even texture information.</li> <li>AMF file format stands for Additive Manufacturing File Format, this is a relative new format for 3D printing based on an XML open standard. Like OBJ it can store color information. When compressed, the size can be reduced significantly to about half the size of STL files.</li> <li>3MF file format stands for 3D Manufacturing Format. It is also a relatively new file format that aims to be a new standard for additive manufacturing. According to the 3MF consortium, it allows higher inter-operability between 3D modeling software and other applications, services, platforms, and printers.</li> </ul> <h1>Actual Printing Files</h1> <p>In the end, all these formats store the models of your products which eventually need to be <em>transformed into 3D printer understandable instructions</em>. These instructions are called <a href="https://reprap.org/wiki/G-code" rel="nofollow noreferrer">G-code commands</a>.</p> <p>Lately I also noted that Ultimaker Cura stores sliced models in GZ file format for my Ultimaker 3 Extended, which is a compressed archive from the GZIP compression utility containing the actual G-code file.</p>
<p><a href="https://en.wikipedia.org/wiki/STL_(file_format)" rel="nofollow noreferrer">STL</a> is the standard for pretty much everything out there.</p> <p>EDIT: This is for models to be sliced and printed. Gcode is what would actually be executed, after slicing, to create the print.</p>
1,085
<p>C# and Java allow almost any character in class names, method names, local variables, etc.. Is it bad practice to use non-ASCII characters, testing the boundaries of poor editors and analysis tools and making it difficult for some people to read, or is American arrogance the only argument against?</p>
<p>I would stick to english, simply because you usually never know who is working on that code, and because some third-party tools used in the build/testing/bugtracking progress may have problems. Typing äöüß on a Non-German Keyboard is simply a PITA, and I simply believe that anyone involved in software development should speak english, but maybe that's just my arrogance as a non-native-english speaker.</p> <p>What you call "American arrogance" is not whether or not your program uses international variable names, it's when your program thinks "Währung" and "Wahrung" are the same words.</p>
<p>There is another hazzard to using non-ASCII characters, though it will probably only bite in obscure cases. The allowed characters are <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8" rel="nofollow">defined</a> in terms of the methods <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isJavaIdentifierStart%28int%29" rel="nofollow">Character.isJavaIdentifierStart(int)</a> and <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isJavaIdentifierPart%28int%29" rel="nofollow">Character.isJavaIdentifierPart(int)</a>, which are defined in terms of Unicode. However, the exact version of Unicode used depends on the version Java platform, as specified in the documentation for <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html" rel="nofollow">java.lang.Character</a>.</p> <p>Since character properties change slightly from one Unicode version to the next, it's possible (but probably very unlikely) you could have identifiers that are valid in one version of Java, but not in the next.</p>
8,683
<p>Given a specific <code>DateTime</code> value, how do I display relative time, like:</p> <ul> <li><code>2 hours ago</code></li> <li><code>3 days ago</code></li> <li><code>a month ago</code></li> </ul>
<p>Jeff, <a href="https://stackoverflow.com/questions/11/how-do-i-calculate-relative-time/12#12">your code</a> is nice but could be clearer with constants (as suggested in Code Complete).</p> <pre class="lang-csharp prettyprint-override"><code>const int SECOND = 1; const int MINUTE = 60 * SECOND; const int HOUR = 60 * MINUTE; const int DAY = 24 * HOUR; const int MONTH = 30 * DAY; var ts = new TimeSpan(DateTime.UtcNow.Ticks - yourDate.Ticks); double delta = Math.Abs(ts.TotalSeconds); if (delta &lt; 1 * MINUTE) return ts.Seconds == 1 ? "one second ago" : ts.Seconds + " seconds ago"; if (delta &lt; 2 * MINUTE) return "a minute ago"; if (delta &lt; 45 * MINUTE) return ts.Minutes + " minutes ago"; if (delta &lt; 90 * MINUTE) return "an hour ago"; if (delta &lt; 24 * HOUR) return ts.Hours + " hours ago"; if (delta &lt; 48 * HOUR) return "yesterday"; if (delta &lt; 30 * DAY) return ts.Days + " days ago"; if (delta &lt; 12 * MONTH) { int months = Convert.ToInt32(Math.Floor((double)ts.Days / 30)); return months &lt;= 1 ? "one month ago" : months + " months ago"; } else { int years = Convert.ToInt32(Math.Floor((double)ts.Days / 365)); return years &lt;= 1 ? "one year ago" : years + " years ago"; } </code></pre>
<p>My way is much more simpler. You can tweak with the return strings as you want</p> <pre><code> public static string TimeLeft(DateTime utcDate) { TimeSpan timeLeft = DateTime.UtcNow - utcDate; string timeLeftString = ""; if (timeLeft.Days &gt; 0) { timeLeftString += timeLeft.Days == 1 ? timeLeft.Days + " day" : timeLeft.Days + " days"; } else if (timeLeft.Hours &gt; 0) { timeLeftString += timeLeft.Hours == 1 ? timeLeft.Hours + " hour" : timeLeft.Hours + " hours"; } else { timeLeftString += timeLeft.Minutes == 1 ? timeLeft.Minutes+" minute" : timeLeft.Minutes + " minutes"; } return timeLeftString; } </code></pre>
2,233
<p>How do I create a new webpage in the Documentum front end Webtop? </p>
<p>Why WebTop? You should use Web Publisher which is built on WebTop with the specific purpose of managing web content. Is this an OOTB installation? Web Publisher / WebTop requires significant amount of customization in order to start being useful. Do you have templates defined? If so, then just go to File New and select your template. </p> <p><a href="http://www.dmdeveloper.com/" rel="nofollow noreferrer">http://www.dmdeveloper.com/</a> Is a good site with some very good how-to's.</p>
<p>Why WebTop? You should use Web Publisher which is built on WebTop with the specific purpose of managing web content. Is this an OOTB installation? Web Publisher / WebTop requires significant amount of customization in order to start being useful. Do you have templates defined? If so, then just go to File New and select your template. </p> <p><a href="http://www.dmdeveloper.com/" rel="nofollow noreferrer">http://www.dmdeveloper.com/</a> Is a good site with some very good how-to's.</p>
6,119
<p>Assuming a Cartesian printer with a belt and smooth rod design in which one axis moves another (i.e. the X-axis rails 'sit' on the Y-axis rails), what are the main considerations in sizing the rods and belts? For example, given a base design using 8 mm diameter rods and 6 mm belts (assume these are the limiting factors of the printer and that the frame, etc. can handle whatever you throw at it), what is roughly the maximum load, print speed and build size that this should be expected to support? If you were to increase the rod diameters to 10 mm or even 12 mm on one or both axes (assume the steppers could handle the increased load), what would the increased rigidity buy you in terms of maximum speed and/or build size and would 6 mm belts still be appropriate? Ballpark calculations or rules of thumb are fine as I understand the variables are likely not trivial and am looking more for a rough range of guidance to understand the trade-offs involved.</p>
<p>8 mm rods and 6 mm GT2 belts are generally accepted as a good tradeoff between price and performance, an exact calculation is possible but might not be very relevant if another part is flexing. Also, generally speaking, the smaller the part the sooner it will wear out of specification. Thus your service interval might be higher compared to an over-engineered printer.</p> <p>In short, it depends on what your goal is, if you desire low maintenance and accurate machine, you might be better off with heavier gauge parts. Obviously, this will also affect the speed of printing. A 6 mm GT2 belt might have a higher stretch factor compared to a 10 mm belt, but can be mitigated by adjusting the acceleration. In addition, a 10 mm belt has a larger pulley reducing the number of steps per mm, lowering precision. As such you might be better of using two 6 mm belts.</p> <p>Increased rod size for the print bed will not affect printing speed much but might help with accuracy since the bending modulus is lower. Play around with the calculators below to get an idea of the force your beam will have to withstand. That said, there are a lot of other factors that will flex under load, for example, the bed leveling springs. You can replace them with solid spacers, but that might warp the bed when it heats up.</p> <p><a href="https://www.engineering.com/calculators/beams.htm" rel="nofollow noreferrer">https://www.engineering.com/calculators/beams.htm</a></p> <p><a href="https://www.omnicalculator.com/physics/acceleration" rel="nofollow noreferrer">https://www.omnicalculator.com/physics/acceleration</a></p> <p>To conclude, I would use the calculators to figure out if the 8 mm rods are within tolerance for the intended speeds and load, but don't forget to look at the overall picture. The quality of parts you choose is one such thing.</p>
<p>The 3D printing revolution started out with the idea/community project to build self-replicating machines:</p> <blockquote> <p>RepRap was the first of the low-cost 3D printers, and the RepRap Project started the open-source 3D printer revolution. It has become the most widely-used 3D printer among the global members of the Maker Community. <em>(From RepRap.org)</em></p> </blockquote> <p>The main aspects for this project was to build self-replicating machines from cheap and &quot;simple&quot; available materials and making them freely available for the benefit of everyone. The rod solution is a simple and affordable solution for linear motion with fair tolerances.</p> <p>As far as the rigidity of the X carriage, rods aren't the best solution, increasing rod diameter will surely increase the stiffness, but it will be smaller than a design that uses a (quality) linear rail, these are much stiffer. Note that instead of steel, carbon rods can be used, these are stiff and light and reduce the weight of the carriage, allowing for higher acceleration and speed. The solution of using rods is mainly based on availability and being a cheap solution.</p> <p>Do note that rods flex much more than linear rails, even when you increase the diameter, this will limit the length of the X-axis.</p> <p><a href="https://m.all3dp.com/2/linear-rail-3d-printer-really-better-or-just-a-hype/" rel="nofollow noreferrer">From all3Dp</a>:</p> <blockquote> <p>Any decent rail will have far less give. In terms of 3D printing, this leads to greatly reduced backlash and ringing artifacts, yielding cleaner print surfaces and edges.</p> </blockquote> <p>Belts allow the rotational motion to be transferred into a linear motion. Belt width depends on the force (carriage weight) you need to move. Same as for rods, an increased height will allow for a larger load to be driven/moved, but for a fixed load, the increasing height allows for less stretch and thus less printing defects. Note the different <a href="https://3dprinting.stackexchange.com/a/6714">types of belts</a> are available, all having their own stiffness and load bearing capacity.</p>
1,771
<p>Are there any tools available that will calculate code metrics (for example number of code lines, cyclomatic complexity, coupling, cohesion) for your project and over time produce a graph showing the trends? </p>
<p>On my latest project I used <a href="http://www.campwoodsw.com/sourcemonitor.html" rel="noreferrer">SourceMonitor</a>. It's a nice free tool for code metrics analysis.<br> Here is an excerpt from SourceMonitor official site:</p> <blockquote> <ul> <li>Collects metrics in a fast, single pass through source files.</li> <li>Measures metrics for source code written in C++, C, C#, VB.NET, Java, Delphi, Visual Basic (VB6) or HTML.</li> <li>Includes method and function level metrics for C++, C, C#, VB.NET, Java, and Delphi.</li> <li><strong>Saves metrics in checkpoints for comparison during software development projects.</strong></li> <li>Displays and prints metrics in tables and charts.</li> <li>Operates within a standard Windows GUI or inside your scripts using XML command files.</li> <li>Exports metrics to XML or CSV (comma-separated-value) files for further processing with other tools.</li> </ul> </blockquote> <p>For .NET beside <a href="http://www.ndepend.com" rel="noreferrer">NDepend</a> which is simply the best tool, I can recommend <a href="http://www.1bot.com/index.html" rel="noreferrer">vil</a>.</p> <p>Following tools can perform trend analysis:</p> <ul> <li><a href="http://www.castsoftware.com/Product/Application-Intelligence-Platform.aspx" rel="noreferrer">CAST</a></li> <li><a href="http://www.klocwork.com/products/insight.asp" rel="noreferrer">Klocwork Insight</a></li> </ul>
<p>On the PHP front, I believe for example <a href="http://phpundercontrol.org" rel="nofollow noreferrer">phpUnderControl</a> includes metrics through <a href="http://www.phpunit.de/" rel="nofollow noreferrer">phpUnit</a> (if I am not mistaken).</p> <p>Keep in mind that metrics are often flawed. For example, a coder who's working on trivial problems will produce more code and there for look better on your graphs, than a coder who's cracking the complex issues.</p>
8,525
<p>My model layers are printing much as I expect but the parts when removed from the plate are very soft and flexible and fail to harden any further in sunlight or UV lamplight. A tall or slender part will bend and distort under its own weight while printing. I am using LCD-T resin, I have increased time and reduced thicknesses and am now using 0.04&nbsp;mm layers at 20&nbsp;s and 255 brightness with no improvement. Can anyone suggest what I need to change?</p>
<p>I could finally solve the issue. Calling <code>openscad</code> from command line with parameters does NOT work with the AppImage I used. It works fine with a "standard" installation, though.</p> <p>Thanks for your support.</p>
<p>You can specify variable values from command line using:</p> <pre> openscad ...\ ... \ [ -D var=val [..] ] \ ... \ ... \ filename </pre> <p>See the <a href="https://en.m.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment" rel="nofollow noreferrer">OpenSCAD Manual</a>.</p>
1,228
<p>Why does the use of temp tables with a SELECT statement improve the logical I/O count? Wouldn't it increase the amount of hits to a database instead of decreasing it. Is this because the 'problem' is broken down into sections? I'd like to know what's going on behind the scenes.</p>
<p>There's no general answer. It depends on how the temp table is being used.</p> <p>The temp table may reduce IO by caching rows created after a complex filter/join that are used multiple times later in the batch. This way, the DB can avoid hitting the base tables multiple times when only a subset of the records are needed.</p> <p>The temp table may increase IO by storing records that are never used later in the query, or by taking up a lot of space in the engine's cache that could have been better used by other data.</p> <p>Creating a temp table to use all of its contents once is slower than including the temp's query in the main query because the query optimizer can't see past the temp table and it forces a (probably) unnecessary <a href="http://msdn.microsoft.com/en-us/library/ms181032.aspx" rel="nofollow noreferrer">spool</a> of the data instead of allowing it to stream from the source tables.</p>
<p>AFAIK, at least with mysql, tmp tables are kept in RAM, making SELECTs much faster than anything that hits the HD</p>
9,822
<p>Right now I have an <a href="http://en.wikipedia.org/wiki/SQL_Server_Integration_Services" rel="nofollow noreferrer">SSIS</a> package that runs every morning and gives me a report on the number of packages that failed or succeeded from the day before. The information for these packages is contained partly within the <code>sysjobs</code> table (a system table) within the <code>msdb</code> database (a system database) in <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005" rel="nofollow noreferrer">SQL Server 2005</a>.</p> <p>When trying to move the package to a C# executable (mostly to gain better formatting over the email that gets sent out), I wasn't able to find a way to create a dbml file that allowed me to access these tables through <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" rel="nofollow noreferrer">LINQ</a>. I tried to look for any properties that would make these tables visible, but I haven't had much luck.</p> <p>Is this possible with <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_SQL_.28formerly_called_DLINQ.29" rel="nofollow noreferrer">LINQ&nbsp;to&nbsp;SQL</a>?</p>
<p>If you're in Server Explorer, you can make them visible this way:</p> <ul> <li>Create a connection to the server you want.</li> <li>Right-click the server and choose Change View > Object Type.</li> <li>You should now see System Tables and User Tables. You should see sysjobs there, and you can easily drag it onto a .dbml surface.</li> </ul>
<p>It may not be available in the designer, but why not just add it to the DBML file itself?</p>
7,786
<p>I have a ComboBox that I bind to a standard HTTPService, I would like to add an event listener so that I can run some code after the ComboBox is populated from the data provider.</p> <p>How can I do this?</p>
<p>Flex doesn't have a specific data-binding events in the way that say ASP .Net does. You have to watch for the dataProvider property like John says in the first answer, but not simply to the combobox or its dataProvider property. Let's say you have a setup like this:</p> <pre><code>&lt;!-- Assume you have extracted an XMLList out of the result and attached it to the collection --&gt; &lt;mx:HttpService id="svc" result="col.source = event.result.Project"/&gt; &lt;mx:XMLListCollection id="col"/&gt; &lt;mx:ComboBox id="cbProject" dataProvider="{col}"/&gt; </code></pre> <p>Now if you set a changewatcher like this:</p> <pre><code>// Strategy 1 ChangeWatcher.watch(cbProject, "dataProvider", handler) ; </code></pre> <p>your handler will <em>not</em> get triggered when the data comes back. Why? Because the <em>dataProvider</em> itself didn't change - its underlying collection did. To trigger that, you have to do this:</p> <pre><code>// Strategy 2 ChangeWatcher.watch(cbProject, ["dataProvider", "source"], handler) ; </code></pre> <p>Now, when your collection has updated, your handler will get triggered. If you want to make it work using Strategy 1, <em>don't</em> set your dataProvider in MXML. Rather, handle the <em>collectionChange</em> event of your XMLListCollection and in AS, over-write the dataProvider of the ComboBox.</p> <p>Are these exactly the same as a databound event? No, but I've used them and never had an issue. If you want to be <em>absolutely</em> sure your data <em>has</em> bound, just put a changeWatcher on the selectedItem property of your combobox and do your processing there. Just be prepared to have that event trigger multiple times and handle that appropriately.</p>
<p>You can use <code>BindingUtils</code> to get notified when the <code>dataProvider</code> property of the combo box changes:</p> <pre><code>BindingUtils.bindSetter(comboBoxDataProviderChanged, comboBox, "dataProvider"); </code></pre> <p><code>BindingUtils</code> lives in the <code>mx.binding.utils</code> package.</p> <p>I have a longer description of how to work with <code>BindingUtils</code> here: <a href="https://stackoverflow.com/questions/14247/flex-does-painless-programmatic-data-binding-exist#14261">Does painless programmatic data binding exist?</a></p>
4,605
<p>Has anyone ever set up Cruise Control to build an OS X Cocoa/Objective-C project?</p> <p>If so, is there a preferred flavor of CruiseControl (CruiseControl.rb or just regular CruiseControl) that would be easier to do this with. </p> <p>I currently have a Ruby rake file that has steps for doing building and running tests, and wanted to automate this process after doing a checkin. </p> <p>Also, does CruiseControl have support for git? I couldn't find anything on the website for this.</p>
<p>Yes, you just run xcode builds via the command line (xcodebuild) which makes it simple to target from CC via an ant <code>&lt;exec&gt;</code>. I've been using just regular CC, not the ruby version and it works fine. Here's a barebones example:</p> <pre><code>&lt;project name="cocoathing" default="build"&gt; &lt;target name="build"&gt; &lt;exec executable="xcodebuild" dir="CocoaThing" failonerror="true"&gt; &lt;arg line="-target CocoaThing -buildstyle Deployment build" /&gt; &lt;/exec&gt; &lt;/target&gt; &lt;/project&gt; </code></pre> <p><a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html" rel="nofollow noreferrer">More info on xcodebuild</a></p> <p>And there does appear to be a standard git object <a href="http://cruisecontrol.sourceforge.net/main/api/net/sourceforge/cruisecontrol/sourcecontrols/Git.html" rel="nofollow noreferrer">here</a>, but I don't use git so I can't tell you much more than that!</p>
<p>Yes, CruiseControl has a <a href="http://cruisecontrol.sourceforge.net/main/configxml.html#git" rel="nofollow noreferrer">support for git</a>.</p>
5,048
<p>One of my co-workers checked in a some files in SVN and one of the files has a password in it. The password has been removed from the file and a new version checked in but the password is obviously still in the repository if we look at the revision history and go to that revision. (We're using TortoiseSVN as the client.)</p> <p>So how do I securely delete that single file from the repository in SVN?</p>
<p><a href="http://subversion.apache.org/faq.html#removal" rel="nofollow noreferrer">link to subversion FAQ entry on this</a></p>
<p>I'm not sure. You could always create a new file and copy the latest revision into that, wiping out prior revision history. </p>
5,387
<p>On my Ender 3 v2 printer I recently and consistently get some knocking. This happens in only two scenarios.</p> <p>First, it now occurs all the time when printing the initial test strip gets near the top (high Y value), and knocks several times.</p> <p>Secondly, it occurs if the model (sliced with Cura) has a high Y value (eg: if the model occupies most of the bed). (If there is room and I move the model - in Cura - closer to the front there is no knocking.) On the first 10 (or so) layers the printer sometimes knocks when a high Y value is reached and the entire model is thereafter shifted to the front by a few millimeters.</p> <p>There is a third scenario. At the end of a print the print head is in the middle of the bed and moves up 20 mm then travels directly to the top left corner. At this corner there are 4 or 5 &quot;knocks&quot; (and the nozzle is 20 mm above the bed).</p> <p>Any suggestions to diagnose/fix this problem will be much appreciated.</p>
<p>Embarassingly, I discovered that the cable to the heatbed was sometimes caught between the on/off switch and the adjacent power plug. So, for high Y values the cable was very tight and the bed could not be moved. Presumably the &quot;knocking&quot; came from the Y-axis motor. The problem was fixed by attaching this cable to the adjacent hotend/X axis motor cable.</p> <p>Hopefully this will be helpful to others who have a similar problem. Please add a comment if you experienced this.</p>
<p>Your bed has become unleveled or skewed in Y direction.</p> <p>When the nozzle is closer to the bed the extruder has to push harder to get the same filament flow through a smaller space, the stresses the extruder to a point that the stepper skips or grinds the filament. This is generally described as a knocking sound.</p> <p>You need to find out why the bed is higher at the upper end of the Y range and fix this. Otherwise your bed has become warped and may need to be replaced. There are alternatives in using a sensor (e.g. a BLTouch) to sense the shape of the print surface, it will then automatically adjust for the shape during the first 10 mm (default value) of your print product. Installing a sensor requires new or alternative firmware.</p>
2,186
<p>I'm using an Xml field in my Sql Server database table. I'm trying to search a word using the XQuery <strong>contains</strong> method but it seems to search <strong>only</strong> in case sensitive mode. The lower method isn't implemented on Sql Server XQuery implementation also. ¿Is there a simple solution to this problem?</p>
<p>If you're using SQL Server 2005, I'm afraid you're out of luck.</p> <p>If you're using SQL Server 2008, you can use the upper-case function like this :</p> <pre><code>DECLARE @x xml = N'abcDEF!@4'; SELECT @x.value('fn:upper-case(/text()[1])', 'nvarchar(10)'); </code></pre> <p>Here's a link on MSDN for the upper-case syntax and a couple search examples :</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc645590.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc645590.aspx</a></p>
<p><em><a href="http://www.google.ru/search?complete=1&amp;hl=en&amp;newwindow=1&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;hs=MdF&amp;q=Sql+Server+contains+function+xquery+case-insensitive&amp;btnG=%CF%EE%E8%F1%EA&amp;lr=&amp;aq=f&amp;oq=" rel="nofollow noreferrer">First</a></em> link from google points to MSDN page:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms178026.aspx" rel="nofollow noreferrer">contains Function (XQuery)</a></p> <blockquote> <p>In order to get case-insensitive comparisons, the <a href="http://msdn.microsoft.com/en-us/library/cc645590.aspx" rel="nofollow noreferrer">upper-case</a> or lower-case functions can be used.</p> </blockquote>
9,742
<p>I've seen news of <a href="http://github.com/jeresig/sizzle/tree/master" rel="noreferrer">John Resig's fast new selector engine named Sizzle</a> pop up in quite a few places, but I don't know what a selector engine is, nor have any of the articles given an explanation of what it is. I know Resig is the creator of jQuery, and that Sizzle is something in Javascript, but beyond that I don't know what it is. So, what is a selector engine?</p> <p>Thanks!</p>
<p>A selector engine is used to query a page's DOM for particular elements, based on some sort of query (usually CSS syntax or similar). </p> <p>For example, this jQuery:</p> <pre><code>$('div') </code></pre> <p>Would search for and return all of the &lt;div&gt; elements on the page. It uses jQuery's selector engine to do that.</p> <p>Optimizing the selector engine is a big deal because almost every operation you perform with these frameworks is based on some sort of DOM query.</p>
<p>A selector engine is used to find elements in a document, in the same way as CSS stylesheets does. Currently only Safari has the built-in querySelectorAll function which does just that. With other browser you have to use external JavaScript implementations as <a href="http://llamalab.com/js/selector/" rel="nofollow noreferrer">LlamaLab Selector</a> or Sizzle instead. </p>
4,596