instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I've created a custom list, and made some changes to the way the CQWP renders it on a page by modifying ItemStyle.xsl. However, I'd like to use some custom css classes and therefore I'd like to link to my own custom .css file from the head tag of the pages containing this CQWP.</p> <p>So my question is, where to do put my .css file and how do I link it properly to a page containing the CQWPs. Please have in mind that I'm making a solution that should be deployed on multi sharepoint installations.</p> <p>Thanks.</p>
<p>The microsoft official way is just to copy them into the relevant folders (as seen by downloading their template packs). However, you could also create your own site definition and add the items to the correct libraries and lists in the same way that the master pages are added.</p> <p>If you are going to deploy CSS and Master Pages through features remember you will have to activate your the publishing infrastructure on the site collection and the publishing feature on the site.</p> <p>To deploy a master page/page layout as a feature you should follow the steps at the site below, you can use the "fileurl" element to specify your CSS and place it into the correct folder (style library, for example): <a href="http://www.sharepointnutsandbolts.com/2007/04/deploying-master-pages-and-page-layouts.html" rel="nofollow noreferrer">http://www.sharepointnutsandbolts.com/2007/04/deploying-master-pages-and-page-layouts.html</a></p>
<p>Consider uploading them to "Style Library" in the root of the site collection. <p>If you don't have a "Style Library" at the root, consider making one -- it's just a document library. <p>Make sure the permissions are set correctly so everyone who needs to read it can. <p>You can reference them using "/Style%20Library/my.css" but this won't work on site collections that don't live at the root of the domain.</p>
7,712
<p>Is there a pattern using Linq to dynamically create a filter?</p> <p>I have the need to create custom filtering on a list, in the past I would just dynamically create the SQL...it doesn't seem like this is possible with Linq.</p>
<p>Check out the <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="noreferrer">Dynamic Linq Library</a> from ScottGu's blog:</p> <p>For example, below is a standard type-safe LINQ to SQL VB query that retrieves data from a Northwind database and displays it in a ASP.NET GridView control:</p> <pre><code>Dim Northwind As New NorthwindDataContext Dim query = From q In Northwind.Products Where p.CategoryID = 2 And p.UnitPrice &gt; 3 Order By p.SupplierID Select p Gridview1.DataSource = query GridView1.DataBind() </code></pre> <p>Using the LINQ DynamicQuery library I could re-write the above query expression instead like so</p> <pre><code>Dim Northwind As New NorthwindDataContext Dim query = Northwind.Products .where("CategoryID=2 And UnitPrice&gt;3") . OrderBy("SupplierId") Gridview1.DataSource = query GridView1.DataBind() </code></pre> <p>Notice how the conditional-where clause and sort-orderby clause now take string expressions instead of code expressions. Because they are late-bound strings I can dynamically construct them. For example: I could provide UI to an end-user business analyst using my application that enables them to construct queries on their own (including arbitrary conditional clauses).</p>
<p>something like this?</p> <pre><code>var myList = new List&lt;string&gt; { "a","b","c" }; var items = from item in db.Items where myList.Contains(item.Name) select item; </code></pre> <p>that would create a sql statement like</p> <pre><code>SELECT * FROM Items [t0] where Name IN ('a','b','c') </code></pre>
5,074
<p>I would like to compare two collections (in C#), but I'm not sure of the best way to implement this efficiently.</p> <p>I've read the other thread about <a href="https://stackoverflow.com/questions/43500/is-there-a-built-in-method-to-compare-collections-in-c">Enumerable.SequenceEqual</a>, but it's not exactly what I'm looking for.</p> <p>In my case, two collections would be equal if they both contain the same items (no matter the order).</p> <p>Example:</p> <pre><code>collection1 = {1, 2, 3, 4}; collection2 = {2, 4, 1, 3}; collection1 == collection2; // true </code></pre> <p>What I usually do is to loop through each item of one collection and see if it exists in the other collection, then loop through each item of the other collection and see if it exists in the first collection. (I start by comparing the lengths).</p> <pre><code>if (collection1.Count != collection2.Count) return false; // the collections are not equal foreach (Item item in collection1) { if (!collection2.Contains(item)) return false; // the collections are not equal } foreach (Item item in collection2) { if (!collection1.Contains(item)) return false; // the collections are not equal } return true; // the collections are equal </code></pre> <p>However, this is not entirely correct, and it's probably not the most efficient way to do compare two collections for equality.</p> <p>An example I can think of that would be wrong is:</p> <pre><code>collection1 = {1, 2, 3, 3, 4} collection2 = {1, 2, 2, 3, 4} </code></pre> <p>Which would be equal with my implementation. Should I just count the number of times each item is found and make sure the counts are equal in both collections?</p> <hr> <p>The examples are in some sort of C# (let's call it pseudo-C#), but give your answer in whatever language you wish, it does not matter.</p> <p><strong>Note:</strong> I used integers in the examples for simplicity, but I want to be able to use reference-type objects too (they do not behave correctly as keys because only the reference of the object is compared, not the content).</p>
<p>It turns out Microsoft already has this covered in its testing framework: <a href="http://msdn.microsoft.com/en-us/library/ms243779.aspx" rel="noreferrer">CollectionAssert.AreEquivalent</a></p> <blockquote> <p>Remarks</p> <p>Two collections are equivalent if they have the same elements in the same quantity, but in any order. Elements are equal if their values are equal, not if they refer to the same object.</p> </blockquote> <p>Using reflector, I modified the code behind AreEquivalent() to create a corresponding equality comparer. It is more complete than existing answers, since it takes nulls into account, implements IEqualityComparer and has some efficiency and edge case checks. plus, it's <em>Microsoft</em> :)</p> <pre><code>public class MultiSetComparer&lt;T&gt; : IEqualityComparer&lt;IEnumerable&lt;T&gt;&gt; { private readonly IEqualityComparer&lt;T&gt; m_comparer; public MultiSetComparer(IEqualityComparer&lt;T&gt; comparer = null) { m_comparer = comparer ?? EqualityComparer&lt;T&gt;.Default; } public bool Equals(IEnumerable&lt;T&gt; first, IEnumerable&lt;T&gt; second) { if (first == null) return second == null; if (second == null) return false; if (ReferenceEquals(first, second)) return true; if (first is ICollection&lt;T&gt; firstCollection &amp;&amp; second is ICollection&lt;T&gt; secondCollection) { if (firstCollection.Count != secondCollection.Count) return false; if (firstCollection.Count == 0) return true; } return !HaveMismatchedElement(first, second); } private bool HaveMismatchedElement(IEnumerable&lt;T&gt; first, IEnumerable&lt;T&gt; second) { int firstNullCount; int secondNullCount; var firstElementCounts = GetElementCounts(first, out firstNullCount); var secondElementCounts = GetElementCounts(second, out secondNullCount); if (firstNullCount != secondNullCount || firstElementCounts.Count != secondElementCounts.Count) return true; foreach (var kvp in firstElementCounts) { var firstElementCount = kvp.Value; int secondElementCount; secondElementCounts.TryGetValue(kvp.Key, out secondElementCount); if (firstElementCount != secondElementCount) return true; } return false; } private Dictionary&lt;T, int&gt; GetElementCounts(IEnumerable&lt;T&gt; enumerable, out int nullCount) { var dictionary = new Dictionary&lt;T, int&gt;(m_comparer); nullCount = 0; foreach (T element in enumerable) { if (element == null) { nullCount++; } else { int num; dictionary.TryGetValue(element, out num); num++; dictionary[element] = num; } } return dictionary; } public int GetHashCode(IEnumerable&lt;T&gt; enumerable) { if (enumerable == null) throw new ArgumentNullException(nameof(enumerable)); int hash = 17; foreach (T val in enumerable) hash ^= (val == null ? 42 : m_comparer.GetHashCode(val)); return hash; } } </code></pre> <p>Sample usage:</p> <pre><code>var set = new HashSet&lt;IEnumerable&lt;int&gt;&gt;(new[] {new[]{1,2,3}}, new MultiSetComparer&lt;int&gt;()); Console.WriteLine(set.Contains(new [] {3,2,1})); //true Console.WriteLine(set.Contains(new [] {1, 2, 3, 3})); //false </code></pre> <p>Or if you just want to compare two collections directly:</p> <pre><code>var comp = new MultiSetComparer&lt;string&gt;(); Console.WriteLine(comp.Equals(new[] {&quot;a&quot;,&quot;b&quot;,&quot;c&quot;}, new[] {&quot;a&quot;,&quot;c&quot;,&quot;b&quot;})); //true Console.WriteLine(comp.Equals(new[] {&quot;a&quot;,&quot;b&quot;,&quot;c&quot;}, new[] {&quot;a&quot;,&quot;b&quot;})); //false </code></pre> <p>Finally, you can use your an equality comparer of your choice:</p> <pre><code>var strcomp = new MultiSetComparer&lt;string&gt;(StringComparer.OrdinalIgnoreCase); Console.WriteLine(strcomp.Equals(new[] {&quot;a&quot;, &quot;b&quot;}, new []{&quot;B&quot;, &quot;A&quot;})); //true </code></pre>
<p><a href="https://stackoverflow.com/users/3474/erickson">erickson</a> is almost right: since you want to match on counts of duplicates, you want a <a href="http://commons.apache.org/collections/api-3.1/org/apache/commons/collections/HashBag.html" rel="nofollow noreferrer">Bag</a>. In Java, this looks something like:</p> <pre><code>(new HashBag(collection1)).equals(new HashBag(collection2)) </code></pre> <p>I'm sure C# has a built-in Set implementation. I would use that first; if performance is a problem, you could always use a different Set implementation, but use the same Set interface.</p>
7,273
<p>Watching SO come online has been quite an education for me. I'd like to make a checklist of various vunerabilities and exploits used against web sites, and what programming techniques can be used to defend against them.</p> <ul> <li>What categories of vunerabilities? <ul> <li>crashing site</li> <li>breaking into server</li> <li>breaking into other people's logins</li> <li>spam</li> <li><a href="http://en.wikipedia.org/wiki/Internet_sock_puppet" rel="nofollow noreferrer">sockpuppeting</a>, <a href="http://en.wikipedia.org/wiki/Internet_sock_puppet#Meatpuppet" rel="nofollow noreferrer">meatpuppeting</a></li> <li>etc...</li> </ul></li> <li>What kind of defensive programming techniques?</li> <li>etc...</li> </ul>
<p>From the <a href="http://www.owasp.org/" rel="nofollow noreferrer">Open Web Application Security Project</a>:</p> <ol> <li>The <a href="http://www.owasp.org/images/e/e8/OWASP_Top_10_2007.pdf" rel="nofollow noreferrer">OWASP Top Ten</a> vulnerabilities (pdf)</li> <li>For a more painfully exhaustive list: <a href="http://www.owasp.org/index.php/Category:Vulnerability" rel="nofollow noreferrer">Category:Vulnerability</a></li> </ol> <p>The top ten are:</p> <ol> <li>Cross-site scripting (XSS)</li> <li>Injection flaws (SQL injection, script injection)</li> <li>Malicious file execution</li> <li>Insecure direct object reference</li> <li>Cross-site request forgery (XSRF)</li> <li>Information leakage and improper error handling</li> <li>Broken authentication and session management</li> <li>Insecure cryptographic storage</li> <li>Insecure communications</li> <li>Failure to restrict URL access</li> </ol>
<p>SQL injection</p>
4,864
<p>I want to get whois information of a domain name from my c#/java programs. Is there a simple way to do this? </p>
<p>I found a perfect C# example on dotnet-snippets.com (<em>which doesn't exist anymore</em>). </p> <p>It's 11 lines of code to copy and paste straight into your own application.</p> <pre><code>/// &lt;summary&gt; /// Gets the whois information. /// &lt;/summary&gt; /// &lt;param name="whoisServer"&gt;The whois server.&lt;/param&gt; /// &lt;param name="url"&gt;The URL.&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; private string GetWhoisInformation(string whoisServer, string url) { StringBuilder stringBuilderResult = new StringBuilder(); TcpClient tcpClinetWhois = new TcpClient(whoisServer, 43); NetworkStream networkStreamWhois = tcpClinetWhois.GetStream(); BufferedStream bufferedStreamWhois = new BufferedStream(networkStreamWhois); StreamWriter streamWriter = new StreamWriter(bufferedStreamWhois); streamWriter.WriteLine(url); streamWriter.Flush(); StreamReader streamReaderReceive = new StreamReader(bufferedStreamWhois); while (!streamReaderReceive.EndOfStream) stringBuilderResult.AppendLine(streamReaderReceive.ReadLine()); return stringBuilderResult.ToString(); } </code></pre>
<p>Here's the Java solution, which just opens up a shell and runs <code>whois</code>:</p> <pre><code>import java.io.*; import java.util.*; public class ExecTest2 { public static void main(String[] args) throws IOException { Process result = Runtime.getRuntime().exec("whois stackoverflow.com"); BufferedReader output = new BufferedReader(new InputStreamReader(result.getInputStream())); StringBuffer outputSB = new StringBuffer(40000); String s = null; while ((s = output.readLine()) != null) { outputSB.append(s + "\n"); System.out.println(s); } String whoisStr = output.toString(); } } </code></pre>
7,714
<p>I am planning to upgrade my printer with a second extruder. Since my printer is a Tronxy X8 it's frame is not exactly vibration resistant, so I'd like to keep the print head weight down. At the same time I really don't want a Bowden setup.</p> <p>I came up with the idea of making a dual extruder driven only by a single stepper with a gear shift setup that switches the stepper between the two extruders.</p> <p>The idea seems simple, but googleing didn't turn up anything else.</p> <p>Is there anything I am missing that would would make such a setup unfeasible?</p> <p>Did anyone else build something like that?</p> <p>A clarification, because it came up in an answer:</p> <p>What I imagine is this:</p> <p>One stepper motor is connected to a gear shift system that is either connected to Extruder A or Extruder B, depending on the gear. When shifting it just connects the stepper motor to the other extruder. So it is still similar to a regular direct driven dual extruder system, except that it only uses a single stepper to drive two extruders, each connected to it's own hotend.</p>
<p>That is perfectly viable these days in Marlin firmware, there are options for setting this up using the configuration file, e.g.:</p> <pre><code>// :[0, 1, 2, 3, 4, 5, 6, 7, 8] #define EXTRUDERS 1 ... ... ... // A dual extruder that uses a single stepper motor //#define SWITCHING_EXTRUDER #if ENABLED(SWITCHING_EXTRUDER) #define SWITCHING_EXTRUDER_SERVO_NR 0 #define SWITCHING_EXTRUDER_SERVO_ANGLES { 0, 90 } // Angles for E0, E1[, E2, E3] #if EXTRUDERS &gt; 3 #define SWITCHING_EXTRUDER_E23_SERVO_NR 1 #endif #endif </code></pre>
<p>You'll need a custom firmware.</p> <p>Yur custom firmware will have to react to the &quot;Change extruder&quot; command differently than a normal firmware: instead of just swapping to a different extruder, you'll need to perform some operations to alter the gearing (possibly a solenoid?), and possibly include some kind of &quot;break&quot; to make sure that the filament is not slipping back without the extruder attached. However, there already is a setup that pretty much does this: the Prusa MMU2 uses something similar. The MMU does use a Bowden setup, but you could use Bowden and direct drive in combination, especially if both motors run in sync.</p>
1,806
<p>I cannot generate the upper part of the solid properly which contain a hole (as in the picture). The solid part (bottom section) printed well. </p> <p><a href="https://i.stack.imgur.com/QpBfR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QpBfRm.jpg" alt="enter image description here"></a></p> <p>What should I change to print the part with hole properly?<br> Is it a problem with machine or the design?<br> I am using Hydra 3D printer. </p>
<p>It appears that the upper part of your print contains less plastic than the lower. This would mean that as the printer begins to operate in that area, the previously deposited plastic has less time to cool.</p> <p>The distortions are difficult to see from the distortions of the photograph, but I've experienced similar upper, smaller section failures.</p> <p>You could consider to print more than one copy of the item on the bed, which will require the nozzle to move away from each layer, allowing more cooling time, or add a throw-away model. </p> <p>I've also added an ooze shield using Simplify3D to create a single wall around the part, providing the same cooling time concept.</p> <p>If you try these options and still experience a problem, please consider editing your post with material used (PLA, ABS, PETG, etc) as well as temperatures and speeds used for this print.</p> <p>Your slicer is not likely the problem, but is often useful information. Printer name is sometimes helpful, but I think it's not critical in this circumstance.</p> <p>It's also useful to orient the part in the photograph to match that of the print. It's apparent in this case that the top of the print is to the right and bottom is to the left. If that is not correct, please advise in edit.</p>
<p>This can be a product of poor overhang profiles and bridging. Issues with overhanging features can most easily be fixed by:</p> <ul> <li>applying active cooling (for PLA)</li> <li>slowing down your feedrate on outer shells</li> <li>or adjusting some of the more advanced slicing settings related to bridging/overhanging such as: <ul> <li>anchors</li> <li>widths</li> <li>feedrates</li> <li>active cooling speeds</li> <li>etc.</li> </ul></li> </ul>
655
<p>I'm working on a simple ASP.Net page (handler, actually) where I check the value of the LOGON_USER server variable. This works using Visual Studio's built-in web server and it works in other sites deployed to the live intranet site. But it doesn't work on the IIS instance on my local XP machine. How can I fix it, or what's going on if I can't?</p>
<p>What authentication do you have enabled in IIS? Anonmyous, Basic, Digest, Integrated Windows? Sounds to me like anonymous access is enabled/allowed, and nothing else. This would means that LOGON_USER is not populated. </p> <p>When you access your local IIS, trying using <a href="http://127.0.0.1" rel="nofollow noreferrer">http://127.0.0.1</a> in particular if you use IE. IE will recognize "localhost" as being in your local trusted zone and will automatically pass your XP login credentials through when Integrated Windows auth is enabled.</p>
<p>In addition to Jon's answer, IIRC even if you have Integrated Authentication enabled, if Anonymous Authentication is enabled it will take precedence...</p>
8,473
<p>I'm using the .NET CF 3.5. The type I want to create does not have a default constructor so I want to pass a string to an overloaded constructor. How do I do this?</p> <p>Code:</p> <pre><code>Assembly a = Assembly.LoadFrom("my.dll"); Type t = a.GetType("type info here"); // All ok so far, assembly loads and I can get my type string s = "Pass me to the constructor of Type t"; MyObj o = Activator.CreateInstance(t); // throws MissMethodException </code></pre>
<pre><code>MyObj o = null; Assembly a = Assembly.LoadFrom("my.dll"); Type t = a.GetType("type info here"); ConstructorInfo ctor = t.GetConstructor(new Type[] { typeof(string) }); if(ctor != null) o = ctor.Invoke(new object[] { s }); </code></pre>
<p>See if this works for you (untested):</p> <pre><code>Type t = a.GetType("type info here"); var ctors = t.GetConstructors(); string s = "Pass me to the ctor of t"; MyObj o = ctors[0].Invoke(new[] { s }) as MyObj; </code></pre> <p>If the type has more than one constructor then you may have to do some fancy footwork to find the one that accepts your string parameter.</p> <p>Edit: Just tested the code, and it works.</p> <p>Edit2: <a href="https://stackoverflow.com/questions/29436/compact-framework-how-do-i-dynamically-create-type-with-no-default-constructor#29472">Chris' answer</a> shows the fancy footwork I was talking about! ;-)</p>
4,908
<p>As a long time World of Warcraft player, and a passionate developer I have decided that I would like to combine the two and set about developing some addins. Not only to improve my gameplay experience but as a great opportunity to learn something new.</p> <p>Does anyone have any advice on how to go about starting out?</p> <p>Is there an IDE one can use? How does one go about testing? Are there any ready made libraries available? Or would I get a better learning experience by ignoring the libraries and building from scratch? How do I oneshot Hogger?</p> <p>Would love to hear your advice, experiences and views.</p>
<p><a href="http://www.wowwiki.com/Getting_started_with_writing_addons" rel="noreferrer">This article</a> explains how to start pretty well.</p> <p>Your first bookmark is possibly the US Interface Forum, especially the Stickies for that:</p> <p><a href="http://us.battle.net/wow/en/forum/1011693/" rel="noreferrer">http://us.battle.net/wow/en/forum/1011693/</a></p> <p>Then, grab some simple addons to learn how XML and LUA interacts. The <a href="http://www.wowwiki.com/Category:HOWTOs" rel="noreferrer">WoWWiki HOWTO List</a> is a good point here as well.</p> <p>One important thing to keep in mind: World of Warcraft is available in many languages. If you have a EU Account, you got an excellent testing bed by simply downloading the language Packs for Spanish, German and French. If you're an US Guy, check if you can get the Latin America version. That way, you can test it against another language version.</p> <p>Once you made 1 or 2 really small and simple addons just to learn how to use it, have a look at the various frameworks. <a href="http://www.wowace.com/" rel="noreferrer">WowAce</a> is a popular one, but there are others.</p> <p>Just keep one thing in mind: Making an Addon is work. Maintaining one is even more work. With each new Patch, there may be breaking changes, and the next Addon will surely cause a big Exodus of Addons, just like Patch 2.0.1 did.</p>
<p>Another useful tools you might like is <a href="http://www.codeplex.com/WarcraftAddOnStudio" rel="noreferrer">WarcraftAddOnStudio</a> which lets you make plugins in the visual studio environment.</p>
2,855
<p>How can I create a new database from my C# application?</p> <p>I'm assuming once I create it, I can simply generate a connection string on the fly and connect to it, and the issue all the CREATE TABLE statements.</p>
<p><a href="http://support.microsoft.com/kb/307283" rel="noreferrer">KB307283</a> explains how to create a database using ADO.NET.</p> <p>From the article:</p> <pre><code>String str; SqlConnection myConn = new SqlConnection ("Server=localhost;Integrated security=SSPI;database=master"); str = "CREATE DATABASE MyDatabase ON PRIMARY " + "(NAME = MyDatabase_Data, " + "FILENAME = 'C:\\MyDatabaseData.mdf', " + "SIZE = 2MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " + "LOG ON (NAME = MyDatabase_Log, " + "FILENAME = 'C:\\MyDatabaseLog.ldf', " + "SIZE = 1MB, " + "MAXSIZE = 5MB, " + "FILEGROWTH = 10%)"; SqlCommand myCommand = new SqlCommand(str, myConn); try { myConn.Open(); myCommand.ExecuteNonQuery(); MessageBox.Show("DataBase is Created Successfully", "MyProgram", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (System.Exception ex) { MessageBox.Show(ex.ToString(), "MyProgram", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { if (myConn.State == ConnectionState.Open) { myConn.Close(); } } </code></pre>
<p>CREATE DATABASE works</p>
6,125
<p>Let's say I'm modeling a simple box with a lid. Just as an example, we'll say the <strong>outer</strong> edge along the top of the box is 50 mm x 50 mm. With 3D modeling software, it's easy to build a lid for this box to surround the top with an <strong>inner</strong> edge size of also exactly 50 mm x 50 mm ...but this seems like a bad idea. Surely I'll want some kind of of gap, to ensure an easy on/off. An <em>exact</em> fit seems like it's asking for trouble.</p> <ul> <li>How much gap do we leave for this kind of thing?</li> <li>Is it related to nozzle size?</li> <li>I suppose it also matters how tightly you want to fit, though I expect in cases where a tight fit matters some kind of snap or clip would be used.</li> <li>Are draft prints with larger layer sizes useful for figuring this, or do the rough layers make things seem tighter than they'll be in a final print?</li> </ul>
<p>I use my clearance values according to my rule of thumb: 0.1 mm - to fit with some force, 0.2 mm - just fit edge to edge without force.</p> <p>Examples:</p> <ol> <li><p>3 mm metal cylinder to be pressed into plastic part needs <span class="math-container">$3\ mm+0.1\ mm*2=3.2\ mm$</span> diameter printed hole (clearance from two sides)</p> </li> <li><p>3 mm screw to fit into plastic part needs a hole bigger than <span class="math-container">$3\ mm+0.2\ mm*2=3.4\ mm$</span> that is 3.5 mm will be already good.</p> </li> </ol> <p>This is fully experimental but always worked for me on three different printers and both on PLA and ABS.</p>
<p>Since you said nozzle, I expect you mean FDM 3d printing. Typically you would use one (1) outline of gap between the parts. An outline is usually equal to the size of the nozzle. The corners of a 3d printed square object are rounded. The radius of that rounding would be half your nozzle diameter (i.e. the nozzle's radius). Also if there was any over extrusion occurring on the outline it the two parts would not fit within each other. This is of course assuming that they are being designed to easily come apart. Otherwise you can make them an exact fit if you intend to friction fit them together.</p>
990
<p>I have seen several postings in forums about the power connector on some ender 3's being bad and causing issues or just burning out, potentially causing a fire.</p> <p>How can I tell if I have the bad power connector?</p>
<p>If you can measure the voltage at the main board where the bed power line is attached, or at the last point in the wiring prior to the connector, then measure the voltage at the bed, you can compare the difference to determine if there is loss related to a failing connector.</p> <p>One certain indication of a failing connector is to separate the components of the connector and see corrosion, discoloration or any sign of burning. The Robo3d R1+ used 10 ampere connectors and the bed draws 14 amperes, according to the research I've done. When I discovered that information and separated the connector, it was an easy answer, as one side was scorched and the pins on the other were corroded and discolored.</p> <p>Another method, not for everyone, is to use an IR camera and examine the leads carrying the power to the bed. The failing portion will be absorbing some of the power and heating itself, which will show up as a bright portion in the power path.</p>
<p>Unless the connector has already started failing - by getting warm, creating a voltage drop, eventually melting away -, you will have to remove the shrink tubing near it. Earlier batches had the connection crimped by the supplier of the cables, which is <strong>wrong</strong>. XT60 connectors should always be soldered to.</p>
1,540
<p><a href="https://i.stack.imgur.com/tcLgq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tcLgq.jpg" alt="damage" /></a></p> <p><a href="https://i.stack.imgur.com/Hyr7P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hyr7P.jpg" alt="damage" /></a></p> <p>Just got an Ender 3 a week ago. This is my first 3D printer. On the 5th print the object ended up tearing away the surface of the print bed such that it's no longer usable. Trying to work out if this is something that I did wrong or if this is faulty material or a combination of the two?</p> <p>To set the print head I watched a few tutorials and carefully followed the instructions checking the height with a piece of paper at each corner and in the center and repeated this until it was set.</p> <p>I watched a couple more tutorials on how to remove the pieces from the bed. I have been removing the top sheet from the print bed by detaching the paper clips. Using the supplied putty knife I've worked around the edges tapping gently with a rubber mallet to get the putty knife under the piece and loosen it before it pops off.</p> <p>Afterwards I've used the putty knife to scrape off any other residue to make sure that the surface is smooth.</p> <p>The first 2 prints were with PLA and then the next 3 with PETG. The damage happened when removing a piece printed with PETG.</p> <p>My specific questions: Is my approach to removing a print incorrect? If so, what would the correct approach be? Did this cause the damage?</p>
<h1>Your print surface is destroyed</h1> <p>So, you managed to rip off your print surface in the center. Happened to me too. the corners of my scraper were too sharp, cutting the surface. Another time I did pierce the surface with my nozzle. Damage happens. Replacement surfaces for the Ender3 start at about 5 bucks a piece. So get yourself some spares. <a href="https://3dprinting.stackexchange.com/questions/7960/how-to-clean-up-my-build-plate-for-a-new-build-surface">Clean your bed before applying the new one.</a></p> <h1>Removal process</h1> <p>To properly remove a print from the bed, grab your scraper blade and do the following:</p> <ul> <li>Sharpen the edge only on <strong>one</strong> side.</li> <li>Soften the corners, they should be slightly rouned.</li> </ul> <p>Make sure the scraper is kept sharp.</p> <p>When removing prints, be slow! Push the scraper against the bed with the bevel upwards. Apply careful pressure till the tip moves just a little. Move to a different spot till the blade slips under a little, then work the scraper left and right. You'll hear a sucking sound, that's the print coming free. It gets much easier if you let the bed cool down.</p> <p>For very tall prints with a relatively small area, you might not need the scraper at all.</p> <p>PETG has a tendency to stick too much with glass and fuse with PEI. We don't know if the Build-Tak clone Creality uses contains PEI. I suggest to grab gluestick to add a safety layer for printing PETG.</p>
<p>PETG sticks to the bed much easier than PLA or ABS. I've found it harder to release from the bed. Note this reference indicates PETG can cause bed damage.</p> <p><a href="https://www.matterhackers.com/news/how-to-succeed-when-printing-with-petg-filament#:%7E:text=Other%20Print%20Bed%20Surfaces&amp;text=It%27s%20not%20uncommon%20for%20PETG,permanently%20bonds%20to%20the%20surface" rel="nofollow noreferrer">https://www.matterhackers.com/news/how-to-succeed-when-printing-with-petg-filament#:~:text=Other%20Print%20Bed%20Surfaces&amp;text=It's%20not%20uncommon%20for%20PETG,permanently%20bonds%20to%20the%20surface</a>.</p> <p>If you aren't printing directly on glass, you can use a lower bed temperature to see how it affects the adhesion. Note this reference indicates you don't need a heated bed for PETG on an adhesive surface.</p> <p><a href="https://all3dp.com/2/petg-print-bed-temperature-all-you-need-to-know/" rel="nofollow noreferrer">https://all3dp.com/2/petg-print-bed-temperature-all-you-need-to-know/</a></p> <p>With a PEI sheet on a glass bed at 50C, I'm getting good adhesion without it being too much.</p>
1,692
<p>For most GUI's I've used, when a control that contains text gets the focus, the entire contents of the control are selected. This means if you just start typing, you completely replace the former contents.</p> <p>Example: You have spin control that is initialized with the value zero. You tab to it and type "1" The value in the control is now 1.</p> <p>With Swing, this doesn't happen. The text in the control is not selected and the carat appears at one end or another of the existing text. Continuing the above example:</p> <p>With a Swing JSpinner, when you tab to the spin control, the carat is at the left. You type "1" and the value in the control is now 10.</p> <p>This drives me, (and my users) up a wall, and I'd like to change it. Even more important, I'd like to change it globally so the new behavior applies to JTextField, JPasswordField, JFormattedTextField, JTextArea, JComboBox, JSpinner, and so on. The only way I have found to do this to add a FocusAdapter to each control and override the focusGained() method to Do The Right Thing[tm].</p> <p>There's gotta be an easier, and less fragile way. Please?</p> <p>EDIT: One additional piece of information for this particular case. The form I am working with was generated using Idea's form designer. That means I normally don't actually write the code to create the components. It is possible to tell Idea that you want to create them yourself, but that's a hassle I'd like to avoid.</p> <p>Motto: All good programmers are basically lazy.</p>
<p>When I've needed this in the past, I've created subclasses of the components I wanted to add "auto-clearing" functionality too. eg:</p> <pre><code>public class AutoClearingTextField extends JTextField { final FocusListener AUTO_CLEARING_LISTENER = new FocusListener(){ @Override public void focusLost(FocusEvent e) { //onFocusLost(e); } @Override public void focusGained(FocusEvent e) { selectAll(); } }; public AutoClearingTextField(String string) { super(string); addListener(); } private void addListener() { addFocusListener(AUTO_CLEARING_LISTENER); } } </code></pre> <p>The biggest problem is that I haven't found a "good" way to get all the standard constructors without writing overrides. Adding them, and forcing a call to addListener is the most general approach I've found.</p> <p>Another option is to watch for ContainerEvents on a top-level container with a ContainerListeer to detect the presence of new widgets, and add a corresponding focus listener based on the widgets that have been added. (eg: if the container event is caused by adding a TextField, then add a focus listener that knows how to select all the text in a TextField, and so on.) If a Container is added, then you need to recursively add the ContainerListener to that new sub-container as well.</p> <p>Either way, you won't need to muck about with focus listeners in your actual UI code -- it will all be taken care of at a higher level.</p>
<p>The only way I know is to create a FocusListener and attach it to your component. If you want it this FocusListener to be global to all components in your application you might consider using Aspect Oriented Programming (AOP). With AOP is possible to code it once and apply your focus listener to all components instantiated in your app without having to copy-and-paste the <em>component.addFocusListener(listener)</em> code throughout your application..</p> <p>Your aspect would have to intercept the creation of a JComponent (or the sub-classes you want to add this behaviour to) and add the focus listener to the newly created instance. The AOP approach is better than copy-and-pasting the FocusListener to your entire code because you keep it all in a single piece of code, and don't create a maintenance nightmare once you decide to change your global behavior like removing the listener for JSpinners.</p> <p>There are many AOP frameworks out there to choose from. I like <a href="http://www.jboss.org/jbossaop/" rel="nofollow noreferrer">JBossAOP</a> since it's 100% pure Java, but you might like to take a look at <a href="http://www.eclipse.org/aspectj/" rel="nofollow noreferrer">AspectJ</a>.</p>
9,197
<p>I want to create a client side mail creator web page. I know the problems of using the mailto action in an html form (not standard, no default mail appication set on the client). But the web page isn't very important, and they don't care very much.</p> <p>The mail created by the mailto action has the syntax:</p> <blockquote> <p>subject: undefined subject<br> body:</p> <p>param1=value1<br> param2=value2<br> .<br> .<br> .<br> paramn=valuen </p> </blockquote> <p>Can I use JavaScript to format the mail like this?</p> <blockquote> <p>Subject:XXXXX</p> <p>Body: Value1;Value2;Value3...ValueN</p> </blockquote>
<p>What we used in a projet is a popup window that opens a mailto: link, it is the only way we found to compose a mail within the default mail client that works with all mail clients (at least all our clients used).</p> <pre><code>var addresses = "";//between the speech mark goes the receptient. Seperate addresses with a ; var body = ""//write the message text between the speech marks or put a variable in the place of the speech marks var subject = ""//between the speech marks goes the subject of the message var href = "mailto:" + addresses + "?" + "subject=" + subject + "&amp;" + "body=" + body; var wndMail; wndMail = window.open(href, "_blank", "scrollbars=yes,resizable=yes,width=10,height=10"); if(wndMail) { wndMail.close(); } </code></pre>
<p>Is there a reason you can't just send the data to a page which handles sending the mail? It is pretty easy to send an email in most languages, so unless there's a strong reason to push it to client side, I would recommend that route.</p>
2,914
<p>I want to practice my skills away from a keyboard (i.e. pen and paper) and I'm after simple practice questions like Fizz Buzz, Print the first N primes.</p> <p>What are your favourite simple programming questions?</p>
<p>I've been working on <a href="http://projecteuler.net/" rel="noreferrer">http://projecteuler.net/</a></p>
<p>Towers of Hannoi is great for practice on recursion.</p> <p>I'd also do a search on sample programming interview questions. </p>
4,982
<p>What's the easiest way to get the filename associated with an open HANDLE in Win32?</p>
<p>There is a correct (although undocumented) way to do this on Windows XP <strong>which also works with directories</strong> -- the same method <a href="http://msdn.microsoft.com/en-us/library/aa364962.aspx" rel="noreferrer">GetFinalPathNameByHandle</a> uses on Windows Vista and later.</p> <p>Here are the eneded declarations. Some of these are already in <code>WInternl.h</code> and <code>MountMgr.h</code> but I just put them here anyway:</p> <pre><code>#include "stdafx.h" #include &lt;Windows.h&gt; #include &lt;assert.h&gt; enum OBJECT_INFORMATION_CLASS { ObjectNameInformation = 1 }; enum FILE_INFORMATION_CLASS { FileNameInformation = 9 }; struct FILE_NAME_INFORMATION { ULONG FileNameLength; WCHAR FileName[1]; }; struct IO_STATUS_BLOCK { PVOID Dummy; ULONG_PTR Information; }; struct UNICODE_STRING { USHORT Length; USHORT MaximumLength; PWSTR Buffer; }; struct MOUNTMGR_TARGET_NAME { USHORT DeviceNameLength; WCHAR DeviceName[1]; }; struct MOUNTMGR_VOLUME_PATHS { ULONG MultiSzLength; WCHAR MultiSz[1]; }; extern "C" NTSYSAPI NTSTATUS NTAPI NtQueryObject(IN HANDLE Handle OPTIONAL, IN OBJECT_INFORMATION_CLASS ObjectInformationClass, OUT PVOID ObjectInformation OPTIONAL, IN ULONG ObjectInformationLength, OUT PULONG ReturnLength OPTIONAL); extern "C" NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FileInformation, IN ULONG Length, IN FILE_INFORMATION_CLASS FileInformationClass); #define MOUNTMGRCONTROLTYPE ((ULONG) 'm') #define IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH \ CTL_CODE(MOUNTMGRCONTROLTYPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) union ANY_BUFFER { MOUNTMGR_TARGET_NAME TargetName; MOUNTMGR_VOLUME_PATHS TargetPaths; FILE_NAME_INFORMATION NameInfo; UNICODE_STRING UnicodeString; WCHAR Buffer[USHRT_MAX]; }; </code></pre> <p>Here's the core function:</p> <pre><code>LPWSTR GetFilePath(HANDLE hFile) { static ANY_BUFFER nameFull, nameRel, nameMnt; ULONG returnedLength; IO_STATUS_BLOCK iosb; NTSTATUS status; status = NtQueryObject(hFile, ObjectNameInformation, nameFull.Buffer, sizeof(nameFull.Buffer), &amp;returnedLength); assert(status == 0); status = NtQueryInformationFile(hFile, &amp;iosb, nameRel.Buffer, sizeof(nameRel.Buffer), FileNameInformation); assert(status == 0); //I'm not sure how this works with network paths... assert(nameFull.UnicodeString.Length &gt;= nameRel.NameInfo.FileNameLength); nameMnt.TargetName.DeviceNameLength = (USHORT)( nameFull.UnicodeString.Length - nameRel.NameInfo.FileNameLength); wcsncpy(nameMnt.TargetName.DeviceName, nameFull.UnicodeString.Buffer, nameMnt.TargetName.DeviceNameLength / sizeof(WCHAR)); HANDLE hMountPointMgr = CreateFile(_T("\\\\.\\MountPointManager"), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL); __try { DWORD bytesReturned; BOOL success = DeviceIoControl(hMountPointMgr, IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH, &amp;nameMnt, sizeof(nameMnt), &amp;nameMnt, sizeof(nameMnt), &amp;bytesReturned, NULL); assert(success &amp;&amp; nameMnt.TargetPaths.MultiSzLength &gt; 0); wcsncat(nameMnt.TargetPaths.MultiSz, nameRel.NameInfo.FileName, nameRel.NameInfo.FileNameLength / sizeof(WCHAR)); return nameMnt.TargetPaths.MultiSz; } __finally { CloseHandle(hMountPointMgr); } } </code></pre> <p>and here's an example usage:</p> <pre><code>int _tmain(int argc, _TCHAR* argv[]) { HANDLE hFile = CreateFile(_T("\\\\.\\C:\\Windows\\Notepad.exe"), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); assert(hFile != NULL &amp;&amp; hFile != INVALID_HANDLE_VALUE); __try { wprintf(L"%s\n", GetFilePath(hFile)); // Prints: // C:\Windows\notepad.exe } __finally { CloseHandle(hFile); } return 0; } </code></pre>
<p>On unixes there is no real way of reliably doing this. In unix with the traditional unix filesystem, you can open a file and then unlink it (remove its entry from the directory) and use it, at which point the name isn't stored anywhere. In addition, because a file may have multiple hardlinks into the filesystem, each of the names are equivalent, so once you've got just the open handle it wouldn't be clear which filename you should map back towards.</p> <p>So, you may be able to do this on Win32 using the other answers, but should you ever need to port the application to a unix enviornment, you'll be out of luck. My advice to you is to refactor your program, if possible, so that you don't need the OS to be able to maintain an open resource to filename connection.</p>
9,094
<p>What are the best practices to consider when catching exceptions and re-throwing them? I want to make sure that the <code>Exception</code> object's <code>InnerException</code> and stack trace are preserved. Is there a difference between the following code blocks in the way they handle this?</p> <pre><code>try { //some code } catch (Exception ex) { throw ex; } </code></pre> <p>Vs:</p> <pre><code>try { //some code } catch { throw; } </code></pre>
<p>The way to preserve the stack trace is through the use of the <code>throw;</code> This is valid as well</p> <pre><code>try { // something that bombs here } catch (Exception ex) { throw; } </code></pre> <p><code>throw ex;</code> is basically like throwing an exception from that point, so the stack trace would only go to where you are issuing the <code>throw ex;</code> statement.</p> <p><a href="https://stackoverflow.com/questions/22623/net-throwing-exceptions-best-practices#22649">Mike</a> is also correct, assuming the exception allows you to pass an exception (which is recommended).</p> <p><a href="http://openmymind.net" rel="noreferrer">Karl Seguin</a> has a <a href="http://codebetter.com/blogs/karlseguin/archive/2008/05/29/foundations-of-programming-pt-8-back-to-basics-exceptions.aspx" rel="noreferrer">great write up on exception handling</a> in his <a href="http://openmymind.net/FoundationsOfProgramming.pdf" rel="noreferrer">foundations of programming e-book</a> as well, which is a great read.</p> <p>Edit: Working link to <a href="http://openmymind.net/FoundationsOfProgramming.pdf" rel="noreferrer">Foundations of Programming</a> pdf. Just search the text for "exception".</p>
<p>FYI I just tested this and the stack trace reported by 'throw;' is not an entirely correct stack trace. Example:</p> <pre><code> private void foo() { try { bar(3); bar(2); bar(1); bar(0); } catch(DivideByZeroException) { //log message and rethrow... throw; } } private void bar(int b) { int a = 1; int c = a/b; // Generate divide by zero exception. } </code></pre> <p>The stack trace points to the origin of the exception correctly (reported line number) but the line number reported for foo() is the line of the throw; statement, hence you cannot tell which of the calls to bar() caused the exception.</p>
4,267
<p>As 3D printers become more and more reliable, their prints get better and better. But FDM printers do have their problems too: you print tiny ovals that smooch together at the edges, and infill makes it awkward at times. So, how do I make a 3D-printed die fair (as in: not favoring one side too much)?</p>
<p>This is going to become a 3-step answer, as 3D Printing uses 3 different steps: <em>Design, Slicing &amp; Material choice</em> before I elaborate alternate ways to some fair dice. Yet, we start with the material, as we need to know about it first. In this case it does impact everything from design to slicing and the print.</p> <h1>Variant A: Printed perfect(?)</h1> <h2>Step 1: Know your material</h2> <p>Let's face it: most materials used in Fused Deposition Modeling (FDM) face an non-homogenous shrinking between XY plane and Z axis. But if you know these specific properties for your printer/filament/temperature combo, you can compensate for that. <strong>Know your material</strong> - you will need that for slicing. Run a test print of a 10x10x10 mm cube and measure - the offset of the 10mm on each axis is what you need to compensate for via your slicer.</p> <h2>Step 2: Design fairly</h2> <h3>Platonic bodies</h3> <p>When designing your STL, try to <strong>design as fair as you can</strong>. Either indent the numbers as little as you can while maintaining readability, or, if you have a 2 color printer, fill the numbers with same density material but from the other color.</p> <p>Another thing to consider: indent the same surface area on each face of the body. That way you remove the same volume and thus same weight from each face, making it somewhat fair in the design, as the Center of Mass should be mostly in the center of the body now.</p> <h3>Prism-"dice"</h3> <p>A cylindrical (or rather: prism) design that is rolled over its "cylinder" surfaces might be the most easy to be designed fairly and be reasonably easy to slice, without having to resort to specialist slicing methods and tons of different compensations to keep in mind or having to assemble the object after print. It might be made with or without a "fall over" cone/elipsoid shape at both ends. Or it might be made like a dreidl, having only one conical/elipsoid tip for easy printing, possibly even havign the 'stem' printed as a different object and then assembled after print.</p> <h2>Step 3: Slicing</h2> <p>Now, there is a pretty fair design... but what settings to use when printing it?!</p> <p>Infill will make it wonky, so there are 2 options: solid (100% infill) and fully hollow (0% infill). Solid is easier to print and heavier. Hollow saves (depending on surface sides) 95% or more of the material in contrast to solid but can fall victim to sagging flat surfaces or wall thickness being not the same as flat area thickness.</p> <p>Now, after we chose the infill settings, we need to choose some other things. We want to print fairly delicate stuff, so we should use a smaller layer height than normally (0.05 mm, for example), and better a smaller nozzle - 0.2 mm or even less, if available. This again means, calibrating the printer/material combo for these two settings (XY / Z shrinking).</p> <p>After calibration, finally print! The dice should be pretty ok in fairness with that, but they are still not totally fair...</p> <h2>Extra-step: Postprocessing</h2> <p>You might make a test for bias by floating it on a salt water layer under tap water... if you managed to get it solid enough to reduce the air inside it to make it sink between these layers. That way you can slightly sand the heavier side until it is unbiased.</p> <p>If you manage to print somewhat fair and hollow, you might consider filling the cavity with some kind of resin (for example epoxy) to give the objects a bit of weight. This has some caveats on its own though: you'll have to leave a filling hole and you'll have to coat the inside equally or refill it several times to ensure a complete fill as most resins shrink when curing. Also, most resins heat up in curing, though usually not to the degree it melts FDM. As you work with resin, <strong>Wear gloves</strong> as it is aggressive to skin!</p> <p>BUT! 3D printink can do more!</p> <h1>Variant B: Printed Perfection</h1> <p>FDM is home printer stuff, but maybe you have access to something more... industrial. They are tricky in their own way, and you better know what you do with them.</p> <p><strong>SLS (solid laser sintering)</strong> You just need to know your material shrinking coefficients in that case... and no, you don't need to think about infill, you only can do solid, 100% filled objects this way. But you will also have virtually no air in your print. Having SLS at home is rare though. This is however likely what you get when you order printed... but remember: the SLS powder is highly hygroscopic and will need to be sealed. Also, it does turn yellowish over time if it starts white. Using reused powder to a large degree degrades print quality also. And <em>never</em> look into the working machine. </p> <p><strong>DLMS (Direct Laser Metal Smelting)</strong> is quite new and pretty much the metal variant of SLS. If you make your dice in that way and get them almost indistinguishable from cast metal. Polish the surfaces a little, don't sniff the breath the powder and don't look into the laser.</p> <p><strong>DLP/SLA (Direct Light Processing/Stereo Lithography)</strong> Printing the thing from curing resin actually is pretty much close to SLS, but it has some resemblence to FDM in parts... biggest benefit: you can make very delicate details, and your layer heights get really thin - and you have a huge array of colors to choose from. But you have to take in mind, that you might want to either make the dice solid or design them with a hole in each of the sides or corners to allow surplus resin to flow out. You get perfect surfaces and can reuse the resin for quite a bit<sup>depending on printer and storeage</sup>, but remember: SLA is a stinky thing, never look into the printing machine &amp; the resins are very agressive to skin, so <em>use gloves</em> when working with the printing and the print until properly cleaned.</p> <h1>Variant C: Lost Print</h1> <p>But wait, what if you don't actually print the dice but just print a positive of the dice and then make a negative mold from that?</p> <p>Yes, that can be done. You know lost wax casting? There you go. Here's your step by step:</p> <ul> <li>Print your dice. <ul> <li>maybe even puzzle the positive together from several faces printed all in the same orientation for maximum equality in the print.</li> </ul></li> <li>Add a casting inlet and air outlet to the print.</li> <li>cast the positive in either a clay material or gypsum. Allow it to dry/set.</li> <li>Burn/melt out the positive, you get a hot and empty negative form.</li> <li>cast in liquid metal or a resin</li> <li>break mold, remove the inlets, polish some and... voila!</li> </ul> <p>If you are good at green sand casting, you might use that instead of lost wax casting - and reuse the positive for a second casting. Or, if you are good, you can make two-part molds that are reuseable.</p> <h2>Variant 3b: mold it!</h2> <p>If we can print a positive and make a mold from that, we might as well print a mold directly. We can just cast in "cold" materials then, but if you have something that can be cast that way (some resins or wax) you can make either the dice or casting sprues for lost wax casting that way. Designing here will be different on the last steps though: after doing your wanted object, use this as a "tool" to cut out from a more or less square block that surrounds it. cut out the inlet/outlet for material and air from the block. Then cut up to your liking, if you want a reusable multi-part mold. You might want to add a roove to add wire or a rubber band around the print to keep the mold together while casting.</p> <p>Or we go industrial with that model, grab a CNC and make the mold halves that way and give up on printing the dice...</p> <h1>tl;dr:</h1> <p>Know your printer, know your material, design for your printer's requirements, design fairly, maybe avoid printing the actual dice but print a positive to be molded and cast or print a mold.</p>
<h2>Honestly, I wouldn't.</h2> <p>You can find dice templates at places like <a href="https://www.thingiverse.com/" rel="nofollow noreferrer">thingiverse</a>, but with my (admittedly limited) experience of affordable 3D printers, I would be highly skeptical that the machine tolerances are up to snuff for producing a fair die. </p> <p>See this <a href="https://3dprinting.stackexchange.com/questions/3605/will-3d-printed-dice-be-fair">discussion</a> from the 3d printing exchange, especially these <a href="https://3dprinting.stackexchange.com/a/3640">two</a> <a href="https://3dprinting.stackexchange.com/a/3606">answers</a>. </p> <p>If you're really bound and determined to do this (we all have our geeky little passion projects!) I'd advise trying to find a template which the authors claim to have tested with chi-square, then find out what (type of) device they used. If you can replicate that, go for it... and then do the chi-square test yourself. It's ridiculously easy to set something up wrong, or forget something (like the possible effects of internal orientation.) </p>
721
<p>I'm new with my 3D printer, I just print two different pawn pieces from thingverse. I just used Cura to convert the files to be readable for the printer. Is my problem with the pieces has to do with the configuration from the Cura software? or with my printer itself? </p> <p><a href="https://i.stack.imgur.com/xh3Bi.jpg" rel="nofollow noreferrer" title="Print showing issue"><img src="https://i.stack.imgur.com/xh3Bi.jpg" alt="Print showing issue" title="Print showing issue"></a></p> <p>Update:</p> <p>I just printed a baymax that came with the SD printer. And it looks awesome. I think the problem is with the configuration from Cura.</p> <p><a href="https://i.stack.imgur.com/iXMhm.png" rel="nofollow noreferrer" title="Print of acceptable quality"><img src="https://i.stack.imgur.com/iXMhm.png" alt="Print of acceptable quality" title="Print of acceptable quality"></a></p>
<p>That looks like horrible underextrusion. Either the extruder steps/mm are way off, but more likely is that your nozzle is clogged (because I wouldn't expect the steps/mm to be this far off). It's also possible that the temperature you're printing at is inappropriate for the filament you're using. Also, make sure that the fan that is cooling the heatsink of the extruder is always on. If not, filament may soften in places it's not supposed to and jam.</p> <p>Try heating the extruder up and pushing the filament through by hand. You'll probably feel a lot of resistance and the filament won't come out smoothly. You could try doing a couple of <a href="http://bukobot.com/nozzle-cleaning" rel="noreferrer">cold pulls</a>, that is, put a piece of filament in while the hotend is hot, then let it cool down and attempt to extract the filament at the lowest possible temperature. This may pull debris or particles blocking the nozzle out.</p> <p>If this doesn't help, there are various other ways of clearing a clog from the nozzle. One popular technique is disassembling the entire hotend and burning out all the debris from the nozzle with a blowtorch. Another is using a special drill bit to clear out the nozzle but this has a high risk of damaging it.</p>
<p>That looks like horrible underextrusion. Either the extruder steps/mm are way off, but more likely is that your nozzle is clogged (because I wouldn't expect the steps/mm to be this far off). It's also possible that the temperature you're printing at is inappropriate for the filament you're using. Also, make sure that the fan that is cooling the heatsink of the extruder is always on. If not, filament may soften in places it's not supposed to and jam.</p> <p>Try heating the extruder up and pushing the filament through by hand. You'll probably feel a lot of resistance and the filament won't come out smoothly. You could try doing a couple of <a href="http://bukobot.com/nozzle-cleaning" rel="noreferrer">cold pulls</a>, that is, put a piece of filament in while the hotend is hot, then let it cool down and attempt to extract the filament at the lowest possible temperature. This may pull debris or particles blocking the nozzle out.</p> <p>If this doesn't help, there are various other ways of clearing a clog from the nozzle. One popular technique is disassembling the entire hotend and burning out all the debris from the nozzle with a blowtorch. Another is using a special drill bit to clear out the nozzle but this has a high risk of damaging it.</p>
468
<p>I'm trying out <strong>Git on Windows</strong>. I got to the point of trying "git commit" and I got this error:</p> <blockquote> <p>Terminal is dumb but no VISUAL nor EDITOR defined. Please supply the message using either -m or -F option.</p> </blockquote> <p>So I figured out I need to have an environment variable called EDITOR. No problem. I set it to point to Notepad. That worked, almost. The default commit message opens in Notepad. But Notepad doesn't support bare line feeds. I went out and got <a href="http://notepad-plus.sourceforge.net/uk/site.htm" rel="noreferrer">Notepad++</a>, but I can't figure out how to get Notepad++ set up as the <code>%EDITOR%</code> in such a way that it works with Git as expected.</p> <p>I'm not married to Notepad++. At this point I don't mind what editor I use. I just want to be able to <strong>type commit messages in an editor</strong> rather than the command line (with <code>-m</code>).</p> <p>Those of you using Git on Windows: What tool do you use to edit your commit messages, and what did you have to do to make it work?</p>
<p>Update September 2015 (6 years later)</p> <p>The <a href="https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1" rel="noreferrer">last release of git-for-Windows (2.5.3)</a> now includes:</p> <blockquote> <p>By configuring <strong><code>git config core.editor notepad</code></strong>, users <a href="https://github.com/git-for-windows/git/issues/381" rel="noreferrer">can now use <code>notepad.exe</code> as their default editor</a>.<br> Configuring <code>git config format.commitMessageColumns 72</code> will be picked up by the notepad wrapper and line-wrap the commit message after the user edits it.</p> </blockquote> <p>See <a href="https://github.com/git-for-windows/build-extra/commit/69b301bbd7c18226c63d83638991cb2b7f84fb64" rel="noreferrer">commit 69b301b</a> by <a href="https://github.com/dscho" rel="noreferrer">Johannes Schindelin (<code>dscho</code>)</a>.</p> <p>And Git 2.16 (Q1 2018) will show a message to tell the user that it is waiting for the user to finish editing when spawning an editor, in case the editor opens to a hidden window or somewhere obscure and the user gets lost.</p> <p>See <a href="https://github.com/git/git/commit/abfb04d0c74cde804c734015ff5868a88c84fb6f" rel="noreferrer">commit abfb04d</a> (07 Dec 2017), and <a href="https://github.com/git/git/commit/a64f213d3fa13fa01e582b6734fe7883ed975dc9" rel="noreferrer">commit a64f213</a> (29 Nov 2017) by <a href="https://github.com/larsxschneider" rel="noreferrer">Lars Schneider (<code>larsxschneider</code>)</a>.<br> Helped-by: <a href="https://github.com/gitster" rel="noreferrer">Junio C Hamano (<code>gitster</code>)</a>.<br> <sup>(Merged by <a href="https://github.com/gitster" rel="noreferrer">Junio C Hamano -- <code>gitster</code> --</a> in <a href="https://github.com/git/git/commit/0c69a132cb1adf0ce9f31e6631f89321e437cb76" rel="noreferrer">commit 0c69a13</a>, 19 Dec 2017)</sup></p> <blockquote> <h2><code>launch_editor()</code>: indicate that Git waits for user input</h2> <p>When a graphical <code>GIT_EDITOR</code> is spawned by a Git command that opens and waits for user input (e.g. "<code>git rebase -i</code>"), then the editor window might be obscured by other windows.<br> The user might be left staring at the original Git terminal window without even realizing that s/he needs to interact with another window before Git can proceed. To this user Git appears hanging.</p> <p>Print a message that Git is waiting for editor input in the original terminal and get rid of it when the editor returns, if the terminal supports erasing the last line</p> </blockquote> <hr> <p>Original answer</p> <p>I just tested it with git version 1.6.2.msysgit.0.186.gf7512 and Notepad++5.3.1</p> <p>I prefer to <em>not</em> have to set an EDITOR variable, so I tried:</p> <pre class="lang-bash prettyprint-override"><code>git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\"" # or git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\" %*" </code></pre> <p>That always gives:</p> <pre><code>C:\prog\git&gt;git config --global --edit "c:\Program Files\Notepad++\notepad++.exe" %*: c:\Program Files\Notepad++\notepad++.exe: command not found error: There was a problem with the editor '"c:\Program Files\Notepad++\notepad++.exe" %*'. </code></pre> <p>If I define a npp.bat including:</p> <pre><code>"c:\Program Files\Notepad++\notepad++.exe" %* </code></pre> <p>and I type:</p> <pre><code>C:\prog\git&gt;git config --global core.editor C:\prog\git\npp.bat </code></pre> <p>It just works from the DOS session, <strong>but not from the git shell</strong>.<br> (not that with the core.editor configuration mechanism, a script with "<code>start /WAIT...</code>" in it would not work, but only open a new DOS window)</p> <hr> <p><a href="https://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows/1431003#1431003">Bennett's answer</a> mentions the possibility to avoid adding a script, but to reference directly the program itself <strong>between simple quotes</strong>. Note the direction of the slashes! Use <code>/</code> NOT <code>\</code> to separate folders in the path name!</p> <pre class="lang-bash prettyprint-override"><code>git config --global core.editor \ "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" </code></pre> <p>Or if you are in a 64 bit system:</p> <pre class="lang-bash prettyprint-override"><code>git config --global core.editor \ "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" </code></pre> <p>But I prefer using a script (see below): that way I can play with different paths or different options without having to register again a <code>git config</code>.</p> <hr> <p>The actual solution (with a script) was to realize that:<br> <strong>what you refer to in the config file is actually a shell (<code>/bin/sh</code>) script</strong>, not a DOS script.</p> <p>So what does work is:</p> <pre><code>C:\prog\git&gt;git config --global core.editor C:/prog/git/npp.bat </code></pre> <p>with <code>C:/prog/git/npp.bat</code>:</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/sh "c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*" </code></pre> <p>or</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/sh "c:/Program Files/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*" </code></pre> <p>With that setting, I can do '<code>git config --global --edit</code>' from DOS or Git Shell, or I can do '<code>git rebase -i ...</code>' from DOS or Git Shell.<br> Bot commands will trigger a new instance of notepad++ (hence the <code>-multiInst</code>' option), and wait for that instance to be closed before going on.</p> <p>Note that I use only '/', not <code>\</code>'. And I <a href="https://stackoverflow.com/questions/623518/msysgit-on-windows-what-should-i-be-aware-of-if-any">installed msysgit using option 2.</a> (Add the <code>git\bin</code> directory to the <code>PATH</code> environment variable, but without overriding some built-in windows tools)</p> <p>The fact that the notepad++ wrapper is called .bat is not important.<br> It would be better to name it 'npp.sh' and to put it in the <code>[git]\cmd</code> directory though (or in any directory referenced by your PATH environment variable).</p> <hr> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program/255212#255212">How do I view ‘git diff’ output with visual diff program?</a> for the general theory</li> <li><a href="https://stackoverflow.com/questions/780425/how-do-i-setup-diffmerge-with-msysgit-gitk/783667#783667">How do I setup DiffMerge with msysgit / gitk?</a> for another example of external tool (DiffMerge, and WinMerge)</li> </ul> <hr> <p><a href="https://stackoverflow.com/users/2716305/lightfire228">lightfire228</a> adds <a href="https://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows/773973#comment74027740_773973">in the comments</a>:</p> <blockquote> <p>For anyone having an issue where N++ just opens a blank file, and git doesn't take your commit message, see "<a href="https://stackoverflow.com/q/30085970/6309">Aborting commit due to empty message</a>": change your <code>.bat</code> or <code>.sh</code> file to say:</p> </blockquote> <pre><code>"&lt;path-to-n++" .git/COMMIT_EDITMSG -&lt;arguments&gt;. </code></pre> <blockquote> <p>That will tell notepad++ to open the temp commit file, rather than a blank new one.</p> </blockquote>
<p>I just use <a href="http://en.wikipedia.org/wiki/TortoiseGit" rel="nofollow noreferrer">TortoiseGit</a> straight out the box. It integrates beautifully with my <a href="http://en.wikipedia.org/wiki/PuTTY" rel="nofollow noreferrer">PuTTY</a> public keys. </p> <p>It has a perfect editor for commit messages.</p>
3,175
<p>How do you go about the requirements gathering phase? Does anyone have a good set of guidelines or tips to follow? What are some good questions to ask the stakeholders? </p> <p>I am currently working on a new project and there are a lot of unknowns. I am in the process of coming up with a list of questions to ask the stakeholders. However I cant help but to feel that I am missing something or forgetting to ask a critical question. </p>
<p>You're almost certainly missing something. A lot of things, probably. Don't worry, it's ok. Even if you remembered everything and covered all the bases stakeholders aren't going to be able to give you very good, clear requirements without any point of reference. The best way to do this sort of thing is to get what you can from them now, then take that and give them something to react to. It can be a paper prototype, a mockup, version 0.1 of the software, whatever. Then they can start telling you what they really want. </p>
<p>I recently started using the concepts, standards and templates defined by the <a href="http://www.theiiba.org" rel="nofollow noreferrer">International Institute of Business Analysts</a> organization (<a href="http://www.theiiba.org" rel="nofollow noreferrer">IIBA</a>). </p> <p>They have a pretty good BOK (Book of Knowledge) that can be downloaded from their website. They do also have a certificate.</p>
4,878
<p>I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, where do I go to find if a given Python library call may throw exception(s) and what those are? </p>
<p>Well, <code>re.compile</code> certainly may:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; re.compile('he(lo') Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "C:\Python25\lib\re.py", line 180, in compile return _compile(pattern, flags) File "C:\Python25\lib\re.py", line 233, in _compile raise error, v # invalid expression sre_constants.error: unbalanced parenthesis </code></pre> <p><a href="https://web.archive.org/web/20080913142948/http://docs.python.org/lib/node46.html" rel="nofollow noreferrer">The documentation</a> does support this, in a roundabout way - check the bottom of the "Module Contents" page for (brief) description of the <code>error</code> exception.</p> <p>Unfortunately, I don't have any answer to the general question. I suppose the documentation for the various modules varies in quality and thoroughness. If there were particular modules you were interested in, you might be able to <a href="https://web.archive.org/web/20081004235506/http://www.depython.net/" rel="nofollow noreferrer">decompile</a> them (if written in Python) or even <a href="http://www.python.org/download/" rel="nofollow noreferrer">look at the source</a>, if they're in the standard library.</p>
<p>Unlike Java, where there are exceptions that must be declared to be raised (and some that don't have to be, but that's another story), any Python code may raise any exception at any time.</p> <p>There are a list of <a href="https://docs.python.org/2.7/library/exceptions.html" rel="nofollow noreferrer">built-in exceptions</a>, which generally has some description of when these exceptions might be raised. Its up to you as to how much exception handling you will do, and if you will handle stuff gracefully, or just fail with a traceback.</p>
8,253
<p>I've always used Subversion or CVS for version control, which use a 'merge' methodology. One of my friends raves about Perforce and how great it is with its change lists and check-out methodology.</p> <p>While I'm sure a lot of it comes down to experience &amp; personal preference, I was wondering if any research had been done into which method of version control is more efficient to work in? </p> <p><strong>EDIT:</strong> To clarify, I know both Perforce &amp; SVN allow locking &amp; merging, but SVN 'encourages' a liberal edit &amp; merge method, whereas as I understand it, Perforce encourages a checkout-checkin method.</p>
<p>Merge is more efficient. For the simple reason that changes to the same file simultaneously tends to be common, and merge allows you to recover from that. In contrast, single checkout prevents that little bit of extra work but it does so at the cost of huge inefficiencies in scheduling. Typically it takes a short amount of time to merge two changes to the same file (e.g. minutes), whereas it takes a significant amount of time to make changes to a file (e.g. many hours or days) so that preventing access to editing a file is a huge inefficiency.</p> <p>Note that Perforce does not force the checkout methodology, it allows concurrent checkouts (equivalent to merge).</p>
<p>Not sure about the research, but here's one data point for you:<br> My team chose PVCS (checkout) mostly because of comfort. Doubts about merge and lack of awareness of tools like Subversion definitely contributed to that.</p>
4,882
<p>Take a .Net Winforms App.. mix in a flakey wireless network connection, stir with a few users who like to simply pull the blue plug out occasionally and for good measure, add a Systems Admin that decides to reboot the SQL server box without warning now and again just to keep everyone on their toes.</p> <p>What are the suggestions and strategies for handling this sort of scenario in respect to :</p> <ul> <li><p>Error Handling - for example, do you wrap every call to the server with a Try/Catch or do you rely on some form of Generic Error Handling to manage this? If so what does it look like?</p></li> <li><p>Application Management - for example, do you disable the app and not allow users to interact with it until a connection is detected again? What would you do?</p></li> </ul>
<p>Answer depends on type of your application. There are applications that can work offline - Microsoft Outlook for example. Such applications doesn't treat connectivity exceptions as critical, they can save your work locally and synchronize it later. Another applications such as online games will treat communication problem as critical exception and will quit if connection gets lost.</p> <p>As of error handling, I think that you should control exceptions on all layers rather than relying on some general exception handling piece of code. Your business layer should understand what happened on lower layer (data access layer in our case) and respond correspondingly. Connection lost should not be treated as <em>unexpected exception</em> in my opinion. For good practices of exceptions management I recommend to take a look at <a href="http://msdn.microsoft.com/en-us/library/cc309505.aspx" rel="nofollow noreferrer">Exception Handling Application Block</a>.</p> <p>Concerning application behavior, you should answer yourself on the following question "Does my application have business value for customer in disconnected state?" In many cases it would be beneficial to end user to be able to continues their work in disconnected state. However such behavior tremendously hard to implement.</p> <p>Especially for your scenario Microsoft developed <a href="http://msdn.microsoft.com/en-us/library/cc540753.aspx" rel="nofollow noreferrer">Disconnected Service Agent Application Block</a></p>
<p>In our application, we give the user the option to connect to another server, e.g., if the database connection fails, a dialog box displays saying that the server is unavailable, and they could input another IP address to try.</p>
7,197
<p>I'm working on an open source project that uses SQL Server 2005 as the data store. We need a DB compare tool to generate diff scripts to be able to upgrade a DB from one version to another.</p> <p>Is there an open source or free SQL Server DB diff tool out there that generates a convert script?</p>
<p>I think that Open DBiff does a good job. It's simple and I works with SQL Server 2005/2008.</p> <p>But only generate the change script. Nothing more and nothing less.</p>
<p>Hmm, none that I know of. You can always retrieve the definitions as SQL and then run a diff tool on them, but it's a bit of a pain in the rear.</p> <p>Probably the best solution for this is using some kind of "Migrations" tool, so you can keep your database definitions together with your code, and version them, etc.</p>
4,280
<p>EditPad Lite has a nice feature (<kbd>CTRL</kbd>-<kbd>E</kbd>, <kbd>CTRL</kbd>-<kbd>I</kbd>) which inserts a time stamp e.g. "2008-09-11 10:34:53" into your code.</p> <p>What is the best way to get this functionality in Vim?</p> <p>(I am using Vim 6.1 on a Linux server via SSH. In the current situation a number of us share a login so I don't want to create abbreviations in the home directory if there is another built-in way to get a timestamp.)</p>
<p><a href="http://kenno.wordpress.com/2006/08/03/vim-tip-insert-time-stamp/" rel="noreferrer">http://kenno.wordpress.com/2006/08/03/vim-tip-insert-time-stamp/</a></p> <p>Tried it out, it works on my mac:</p> <pre><code>:r! date </code></pre> <p>produces:</p> <pre><code>Thu Sep 11 10:47:30 CEST 2008 </code></pre> <p>This:</p> <pre><code>:r! date "+\%Y-\%m-\%d \%H:\%M:\%S" </code></pre> <p>produces:</p> <pre><code>2008-09-11 10:50:56 </code></pre>
<p>Another quick way not included by previous answers: type-</p> <p>!!date</p>
7,993
<p>My MakerBot 2 jams after a couple hours of prints. It is a couple months old, and the tip stops extruding after a couple straight hours of prints. I am guessing that there is a design flaw and that the media is melting inside the extruder before the feeding teeth. Does anyone have experience with this?</p>
<p>You may wish to consider <a href="https://craftunique.com/craftware" rel="nofollow">Craftware</a> for your purposes. It's a free program in beta form that does provide a tool-path animation for printing the layers. It is not so much specific to a printer as it is configurable for your own requirements. <a href="https://www.youtube.com/watch?v=dv_WxUm1JC8" rel="nofollow">The video</a> shows what I believe you are seeking at about the two minute point.</p> <p>Simplify3D also provides such information, but is not a free program.</p>
<p>I'm using <a href="http://www.mattercontrol.com" rel="nofollow">MatterControl</a> and it has such visualization. User can see synchronized animation which shows how the object is actually printed and user is able to see each path of filament put onto the layer.</p> <p>It's possible to control starting and ending position so it's possible to precisely visualize each milimiter of filament even between start and end point.</p> <p>MatterControl also visualizes extrude flow so if user set extrude to 150% or 200% then application shows wider "line".</p> <p>All of it can be seen in 2D (from top view) and in 3D (perspective view). There is also possible to see overlay (by transparency) and print speed (visualized by color).</p> <p>MatterControl also shows non-printing moves and retraction points and their hight.</p>
270
<p>I want to combine two structures with differing fields names.</p> <p>For example, starting with:</p> <pre><code>A.field1 = 1; A.field2 = 'a'; B.field3 = 2; B.field4 = 'b'; </code></pre> <p>I would like to have:</p> <pre><code>C.field1 = 1; C.field2 = 'a'; C.field3 = 2; C.field4 = 'b'; </code></pre> <p>Is there a more efficient way than using "fieldnames" and a for loop?</p> <p><strong>EDIT:</strong> Let's assume that in the case of field name conflicts we give preference to <code>A</code>.</p>
<p>Without collisions, you can do </p> <pre><code>M = [fieldnames(A)' fieldnames(B)'; struct2cell(A)' struct2cell(B)']; C=struct(M{:}); </code></pre> <p>And this is reasonably efficient. However, <code>struct</code> errors on duplicate fieldnames, and pre-checking for them using <code>unique</code> kills performance to the point that a loop is better. But here's what it would look like:</p> <pre><code>M = [fieldnames(A)' fieldnames(B)'; struct2cell(A)' struct2cell(B)']; [tmp, rows] = unique(M(1,:), 'last'); M=M(:, rows); C=struct(M{:}); </code></pre> <p>You might be able to make a hybrid solution by assuming no conflicts and using a try/catch around the call to <code>struct</code> to gracefully degrade to the conflict handling case.</p>
<p>In C, a struct can have another struct as one of it's members. While this isn't exactly the same as what you're asking, you could end up either with a situation where one struct contains another, or one struct contains two structs, both of which hold parts of the info that you wanted.</p> <p>psuedocode: i don't remember the actual syntax.</p> <pre><code>A.field1 = 1; A.field2 = 'a'; A.field3 = struct B; </code></pre> <p>to access: A.field3.field4;</p> <p>or something of the sort.</p> <p>Or you could have struct C hold both an A and a B:</p> <pre><code>C.A = struct A; C.B = struct B; </code></pre> <p>with access then something like</p> <pre><code>C.A.field1; C.A.field2; C.B.field3; C.B.field4; </code></pre> <p>hope this helps!</p> <p>EDIT: both of these solutions avoid naming collisions.</p> <p>Also, I didn't see your <code>matlab</code> tag. By convention, you should want to edit the question to include that piece of info.</p>
5,956
<p>Is it a deliberate design decision or a problem with our current day browsers which will be rectified in the coming versions?</p>
<p>JavaScript does not support multi-threading because the JavaScript interpreter in the browser is a single thread (AFAIK). Even Google Chrome will not let a single web page’s JavaScript run concurrently because this would cause massive concurrency issues in existing web pages. All Chrome does is separate multiple components (different tabs, plug-ins, etcetera) into separate processes, but I can’t imagine a single page having more than one JavaScript thread.</p> <p>You can however use, as was suggested, <code>setTimeout</code> to allow some sort of scheduling and “fake” concurrency. This causes the browser to regain control of the rendering thread, and start the JavaScript code supplied to <code>setTimeout</code> after the given number of milliseconds. This is very useful if you want to allow the viewport (what you see) to refresh while performing operations on it. Just looping through e.g. coordinates and updating an element accordingly will just let you see the start and end positions, and nothing in between.</p> <p>We use an abstraction library in JavaScript that allows us to create processes and threads which are all managed by the same JavaScript interpreter. This allows us to run actions in the following manner:</p> <ul> <li>Process A, Thread 1</li> <li>Process A, Thread 2</li> <li>Process B, Thread 1</li> <li>Process A, Thread 3</li> <li>Process A, Thread 4</li> <li>Process B, Thread 2</li> <li>Pause Process A</li> <li>Process B, Thread 3</li> <li>Process B, Thread 4</li> <li>Process B, Thread 5</li> <li>Start Process A</li> <li>Process A, Thread 5</li> </ul> <p>This allows some form of scheduling and fakes parallelism, starting and stopping of threads, etcetera, but it will not be true multi-threading. I don’t think it will ever be implemented in the language itself, since true multi-threading is only useful if the browser can run a single page multi-threaded (or even more than one core), and the difficulties there are way larger than the extra possibilities.</p> <p>For the future of JavaScript, check this out: <a href="https://web.archive.org/web/20170920070053/https://developer.mozilla.org/presentations/xtech2006/javascript/" rel="noreferrer">https://developer.mozilla.org/presentations/xtech2006/javascript/</a></p>
<p>Multi-threading with javascript is clearly possible using webworkers bring by HTML5.</p> <p>Main difference between webworkers and a standard multi-threading environment is memory resources are not shared with the main thread, a reference to an object is not visible from one thread to another. Threads communicate by exchanging messages, it is therefore possible to implement a synchronzization and concurrent method call algorithm following an event-driven design pattern.</p> <p>Many frameworks exists allowing to structure programmation between threads, among them OODK-JS, an OOP js framework supporting concurrent programming <a href="https://github.com/GOMServices/oodk-js-oop-for-js" rel="nofollow">https://github.com/GOMServices/oodk-js-oop-for-js</a></p>
6,104
<p>I am attempting to construct model tank tracks with accompanying wheels and sprockets. All parts will be printed in PLA. The tracks will be driven by electric motors.</p> <p>What would be a suitable grease for this project to minimize friction without damaging the plastics.</p>
<p>I use cosmetic vaseline - <a href="https://en.wikipedia.org/wiki/Petroleum_jelly" rel="noreferrer">petroleum jelly</a>. Usually it is white to transparent and odorless. It's cheap and available in all drugstores and cosmetics stores.</p> <p>As suggested by Tom van der Zanden I'm adding additional info about interactions of vaseline and plastics. I've found many web sites which claim that vaseline can damage plastics but none of them really proved that statement. There is nothing about it neither on producers sites nor wikipedia or any other believable sources I've found. So according to it and my practice I'm pretty sure that vaseline won't damage popular plastics (including common filaments).</p> <p>The only information I've found is that vaseline can damage natural rubber but I cannot confirm that on my own.</p> <p>Of course it might not be true for some materials so be careful and check the interactions first on invisible side or on refuses.</p>
<p>I have been using <em>sewing machine oil</em> for my 3D printed extruder gear for a couple of years, without any noticeable wear so far.</p> <p>In general, I believe any kind of low viscosity oil would do, but then again, it also depends on the environment in which you plan to use the model. If you plan on using it outside, for instance, you probably should get some grease that does not attract dirt, as the dirt itself will grind down the gears quickly.</p>
298
<p>In unmanaged C/C++ code, what are the best practices to detect memory leaks? And coding guidelines to avoid? (As if it's that simple ;)</p> <p>We have used a bit of a silly way in the past: having a counter increment for every memory allocation call and decrement while freeing. At the end of the program, the counter value should be zero.</p> <p>I know this is not a great way and there are a few catches. (For instance, if you are freeing memory which was allocated by a platform API call, your allocation count will not exactly match your freeing count. Of course, then we incremented the counter when calling API calls that allocated memory.)</p> <p>I am expecting your experiences, suggestions and maybe some references to tools which simplify this.</p>
<p>If your C/C++ code is portable to *nix, few things are better than <a href="http://valgrind.org/info/about.html" rel="noreferrer">Valgrind</a>.</p>
<p><a href="http://en.wikipedia.org/wiki/Mtrace" rel="nofollow noreferrer">Mtrace</a> appears to be the standard built-in one for linux. The steps are :</p> <ol> <li>set up the environment variable MALLOC_TRACE in bash<br> <i>MALLOC_TRACE=/tmp/mtrace.dat</i><br> <i>export MALLOC_TRACE;</i></li> <li>Add <i>#include &lt;mcheck.h&gt;</i> to the top of you main source file</li> <li>Add <i>mtrace();</i> at the start of main and <i>muntrace();</i> at the bottom (before the return statement)</li> <li>compile your program with the -g switch for debug information</li> <li>run your program</li> <li>display leak info with <br><i>mtrace your_prog_exe_name /tmp/mtrace.dat</i><br> (I had to install the mtrace perl script first on my fedora system with <i>yum install glibc_utils</i>&nbsp;&nbsp;)</li> </ol>
6,760
<p>I am an art rubber stamp maker, using a vulcanizer to make art rubber stamps from molds that are usually created with a magnesium plate. </p> <p>The normal process is to send artwork off to an engraving firm to acid etch the magnesium plate (11 pt depth is desired) and that metal plate is then used with uncured matrix boards (a bakelight type material) that is "cured" in the vulcanizer that is then used over and over to make as many images of the rubber stamps as one would want. The vulcanizer heats up to 300 to 320&nbsp;°F, and one usually uses 2000 to 2500 p.s.i. of pressure for 10 to 15 minutes to cure a mold. Once the mold is cured, it is impervious to the heat used in the vulcanizer, and the heat is used to cure the unvulcanized rubber (again, 300 or so degrees, 2000 psi, or so, for 8 to 10 minutes.</p> <p>In reading up about the melting points of PLA and ABS, the 200&nbsp;°C equates to around 460&nbsp;°F, so there doesn't seem like the heat of the vulcanizer will be an issue, and the pressure isn't applied all at once, one usually allows the uncured matrix board to heat up before the high pressure is obtained, I'm just curious if any other stamp makers have had success with this method and/or have any suggestions about STL files for this type of printing, if there needs to be 2 or 3 degree shoulder angle added to the file configuration, or any other suggestions.</p>
<p>This would likely not work. ABS has a <em>glass transition</em> temperature of 105&nbsp;°C. It doesn't have <em>a</em> melting point because it's amorphous. Rather, as you heat the part up, it gradually transitions from a solid to a viscous liquid, but there is no "hard" transition from solid to molten at one particular temperature.</p> <p>The glass transition temperature, at 105&nbsp;°C, is significantly lower than the 200&nbsp;°C "melting point" of ABS you quoted. At 160&nbsp;°C, while ABS would not be molten sufficiently for 3D printing, it definitely becomes flexible and would deform easily.</p> <p>I do not think it would hold its shape very well over the long period of time it has to spend in your vulcanizing machine, under high pressure and well above its glass transition temperature.</p> <p>The surface of 3D printed objects also usually has a somewhat rough finish. If you wanted to make satisfactory stamps, you would probably need to spend a long time manually finishing the 3D printed master before making a mold from it.</p>
<p>I don't know if I understood your question properly. You using the mold to create a rubber stamp and then you use that to stamp over stuff? If so, you simply can use 3D printing to create the stamp, if not, my answer is rubbish. </p> <p>You can use a flex material to create the stamp itself and then use some hard material to create the handle. Also, you can create a mold around the stamp and use resin to fill it and/or create a resin mold and then use that mold to create the stamps by filling the "holes" with more resin.</p>
675
<p>What do search engine bots use as a starting point? Is it DNS look-up or do they start with some fixed list of well-know sites? Any guesses or suggestions?</p>
<p>Your question can be interpreted in two ways:</p> <p>Are you asking where search engines start their crawl from in general, or where they start to crawl a particular site?</p> <p>I don't know how the big players work; but if you were to make your own search engine you'd probably seed it with popular portal sites. <a href="https://web.archive.org/web/20080916124519/http://www.dmoz.org/" rel="nofollow noreferrer">DMOZ.org</a> seems to be a popular starting point. Since the big players have so much more data than we do they probably start their crawls from a variety of places.</p> <p>If you're asking where a SE starts to crawl your particular site, it probably has a lot to do with which of your pages are the most popular. I imagine that if you have one super popular page that lots of other sites link to, then that would be the page that SEs starts will enter from because there are so many more entry points from other sites.</p> <p>Note that I am not in SEO or anything; I just studied bot and SE traffic for a while for a project I was working on.</p>
<p>You can submit your site to search engines using their <a href="http://www.google.com/addurl/" rel="nofollow noreferrer">site submission forms</a> - this will get you into their system. When you actually get crawled after that is impossible to say - from experience it's usually about a week or so for an initial crawl (homepage, couple of other pages 1-link deep from there). You can increase how many of your pages get crawled and indexed using clear semantic link structure and submitting a <a href="https://www.google.com/webmasters/tools/docs/en/protocol.html" rel="nofollow noreferrer">sitemap</a> - these allow you to list all of your pages, and weight them relative to one another, which helps the search engines understand how important you view each part of site relative to the others.</p> <p>If your site is linked from other crawled websites, then your site will also be crawled, starting with the page linked, and eventually spreading to the rest of your site. This can take a long time, and depends on the crawl frequency of the linking sites, so the url submission is the quickest way to let google know about you!</p> <p>One tool I can't recommend highly enough is the <a href="http://www.google.com/webmaster" rel="nofollow noreferrer">Google Webmaster Tool</a>. It allows you to see how often you've been crawled, any errors the googlebot has stumbled across (broken links, etc) and has a host of other useful tools in there. </p>
6,271
<p>So I just fixed a bug in a framework I'm developing. The pseudo-pseudocode looks like this:</p> <pre><code>myoldObject = new MyObject { someValue = "old value" }; cache.Insert("myObjectKey", myoldObject); myNewObject = cache.Get("myObjectKey"); myNewObject.someValue = "new value"; if(myObject.someValue != cache.Get("myObjectKey").someValue) myObject.SaveToDatabase(); </code></pre> <p>So, essentially, I was getting an object from the cache, and then later on comparing the original object to the cached object to see if I need to save it to the database in case it's changed. The problem arose because the original object is a reference...so changing someValue also changed the referenced cached object, so it'd never save back to the database. I fixed it by cloning the object off of the cached version, severing the reference and allowing me to compare the new object against the cached one.</p> <p>My question is: <strong>is there a better way to do this, some pattern, that you could recommend?</strong> I can't be the only person that's done this before :)</p>
<p>Dirty tracking is the normal way to handle this, I think. Something like:</p> <pre><code>class MyObject { public string SomeValue { get { return _someValue; } set { if (value != SomeValue) { IsDirty = true; _someValue = value; } } public bool IsDirty { get; private set; } void SaveToDatabase() { base.SaveToDatabase(); IsDirty = false; } } myoldObject = new MyObject { someValue = "old value" }; cache.Insert("myObjectKey", myoldObject); myNewObject = cache.Get("myObjectKey"); myNewObject.someValue = "new value"; if(myNewObject.IsDirty) myNewObject.SaveToDatabase(); </code></pre>
<p>I've done similar things, but I got around it by cloning too. The difference is that I had the cache do the cloning. When you put an object into the cache, the cache will clone the object first and store the cloned version (so you can mutate the original object without poisoning the cache). When you get an object from the cache, the cache returns a clone of the object instead of the stored object (again so that the caller can mutate the object without effecting the cached/canonical object).</p> <p>I think that this is perfectly acceptable as long as the data you're storing/duping is small. </p>
5,352
<p>What is the the best JavaScript compressor available? I'm looking for a tool that:</p> <ul> <li>is easy to use</li> <li>has a high compression rate</li> <li>Produce reliable end results (doesn't mess up the code)</li> </ul>
<p>I recently released <a href="http://github.com/mishoo/UglifyJS" rel="noreferrer">UglifyJS</a>, a JavaScript compressor which is written in JavaScript (runs on the NodeJS <a href="http://en.wikipedia.org/wiki/Nodejs" rel="noreferrer">Node.js</a> platform, but it can be easily modified to run on any JavaScript engine, since it doesn't need any <code>Node.js</code> internals). It's a lot faster than both <a href="http://developer.yahoo.com/yui/compressor/" rel="noreferrer">YUI Compressor</a> and <a href="http://en.wikipedia.org/wiki/Google_Closure_Tools" rel="noreferrer">Google Closure</a>, it compresses better than <a href="http://en.wikipedia.org/wiki/Yahoo!_UI_Library" rel="noreferrer">YUI</a> on all scripts I tested it on, and it's safer than Closure (knows to deal with "eval" or "with").</p> <p>Other than whitespace removal, UglifyJS also does the following:</p> <ul> <li>changes local variable names (usually to single characters)</li> <li>joins consecutive var declarations</li> <li>avoids inserting any unneeded brackets, parens and semicolons</li> <li>optimizes IFs (removes "else" when it detects that it's not needed, transforms IFs into the &amp;&amp;, || or ?/: operators when possible, etc.).</li> <li>transforms <code>foo["bar"]</code> into <code>foo.bar</code> where possible</li> <li>removes quotes from keys in object literals, where possible</li> <li>resolves simple expressions when this leads to smaller code (1+3*4 ==> 13)</li> </ul> <p>PS: Oh, it can "beautify" as well. ;-)</p>
<p><a href="http://blog.madskristensen.dk/post/Optimize-WebResourceaxd-and-ScriptResourceaxd.aspx" rel="nofollow noreferrer">Here's the source code</a> of an HttpHandler which does that, maybe it'll help you</p>
4,857
<p>I have got a problem that after upgrading my printer to an aluminum frame my extruder went from around 400 steps per mm at 16 micro steps (which did match the manufacturer's recommendation perfectly) to a bit over 1000 steps per mm at 16 micro steps.</p> <p>This is a problem for me, since the limited amount of steps per second lower my maximum retraction speed.</p> <p>What I tried since the rebuild:</p> <ol> <li><p>Replace and adjust the current of the stepper driver - no change, even with another type of driver on different micro steps, of course with other values, but also about 2.5 times too high;</p> </li> <li><p>Connecting another motor with another cable - the other motor with nothing attached to it drove the same angle as my extruder stepper.</p> </li> </ol> <p>Could it be that the ATmega2560 on my MKS gen 1.4 board got damaged? Or did I change something in the firmware, which does have this effect?</p> <p>I am using Marlin 1.8.5 and a E3D Titan 1:3 geared extruder and I am using the same setup as before! E3D claims to have 437 steps per mm on a 200 steps/revolution Nema 17 stepper and 16 micro steps. This value was working perfectly fine before.</p> <h3>Update:</h3> <p>With an Arduino Nano I measured the amount of steps my board sends at 418.5 steps/mm (programmed in EEPROM and in firmware) on a specific amount of extrusion length</p> <pre><code>G92 E0 -&gt; G1 F100 E30 </code></pre> <p>and I got</p> <pre><code>5220 steps for 30mm extrusion (reproducible). </code></pre> <p>It should be</p> <pre><code>418.5 steps/mm*30mm = 12555 steps. </code></pre> <p>Where,</p> <pre><code>(12555/5220) * 418.5 steps/mm = 1007 steps/mm </code></pre> <p>to have the effect of 418.5 steps/mm</p> <p>...which is, oddly, the exact number that I got by marking filament, extruding, measuring and calculating.</p>
<p>Ok, thanks everyone for at least taking time to read or thinking about this.</p> <p>The Problem is an absolute mess and there are two possible reasons:</p> <p>-> the octoprint eeprom editor is broken</p> <p>-> the ATMega2560's eeprom is broken. as far as i know companies buy used atmegas to cheapen the price and the >100k writes on my chip has been reached</p> <p>I will try to figure out the exact problem, if i find time in the next days. My current setup is just deactivate eeprom and i'm good to go. Even wiping eeprom with a small arduino sketch will get the error to return.</p> <p>Now i will be able to sleep again :D</p>
<p>After a rebuild, and certainly after changing to another extruder (e.g. replacing it by a geared extruder like you supposedly did as taken from the comments above before the edit, which now clearly is not the case) or setup e.g. other stepper drivers, you should always calibrate the extruder. </p> <p>To calibrate you e.g. disconnect the hot end nozzle and command to extrude 100 mm. Be sure to make marks and measure the extruded distance. Divide the latter value by 100 to divide this result by the steps per mm value in the configuration file. So, if you measured 102 mm and commanded 100 for 400 steps, the new would be 400/(102/100) = 392. There is a lot to find on this matter on the internet. All can be done with G-codes that can be entered through a terminal connected over the USB port. E.g. applications as Pronterface, Repetier-Host, OctoPrint, etc. all have a terminal interface to the printer if connected over USB.</p> <p>You could find more detailed instructions e.g. <a href="https://www.matterhackers.com/articles/how-to-calibrate-your-extruder" rel="nofollow noreferrer">here</a>, or this <a href="https://www.google.no/url?sa=t&amp;source=web&amp;rct=j&amp;url=%23&amp;ved=0ahUKEwjsuYaexNXbAhWxx6YKHXtTADIQwqsBCEYwBQ&amp;usg=AOvVaw0VTJzWxrN8ZFOD4xbU2nov" rel="nofollow noreferrer">video</a>.</p>
935
<p>I'm wondering about MP3 decoding/encoding, and I was hoping to pull this off in Flash using AS3</p> <p>I'm sure it'll be a right pain...</p> <p>I have no idea where to start, can anyone offer any pointers? reference material?</p> <p>----much later--- Thank you all very much for your input... It seems I have a long road ahead of me yet!</p>
<p>See <a href="http://lame.sourceforge.net/" rel="nofollow noreferrer">LAME MP3 Encoder</a>. You can checkout their source code and their <a href="http://lame.sourceforge.net/links.php" rel="nofollow noreferrer">link page</a>. <a href="http://www.mpeg.org/" rel="nofollow noreferrer">Mpeg.org</a> should have documents too.</p>
<p>It's going to be <strong>VERY</strong> slow doing this in AS3. You really need a C/C++ implementation if you care at all about how long it will take.</p>
7,684
<p>I'm an <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="noreferrer">ASP.NET</a> developer who has used <code>Microsoft SQL Server</code> for all my database needs (both at work and for personal projects). </p> <p>I am considering trying out the <a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29" rel="noreferrer">LAMP</a> stack for some of my personal projects. </p> <p>What are some of the main differences between <code>MySQL</code> and <code>SQL Server</code>? Is using <a href="http://en.wikipedia.org/wiki/Stored_procedure" rel="noreferrer">stored procedures</a> a common practice in <code>MySQL</code>? </p> <p>Any advice or resources you'd recommend to help me with the switch? </p> <p>To those who have experience with both, are there any missing features from <code>MySQL</code>?</p>
<p>One thing you have to watch out for is the fairly severe differences in the way SQL&nbsp;Server and MySQL implement the SQL syntax.</p> <p>Here's a nice <a href="http://troels.arvin.dk/db/rdbms/" rel="noreferrer">Comparison of Different SQL Implementations</a>.</p> <p>For example, take a look at the top-n section. In MySQL:</p> <pre><code>SELECT age FROM person ORDER BY age ASC LIMIT 1 OFFSET 2 </code></pre> <p>In SQL&nbsp;Server (T-SQL):</p> <pre><code>SELECT TOP 3 WITH TIES * FROM person ORDER BY age ASC </code></pre>
<p>Spending some time working with MySQL from the MSSQL to MySQL syntax POV I kept finding myself limited in what I could do.</p> <p>There are bizzare limits on updating a table while refrencing the same table during an update.</p> <p>Additionally UPDATE FROM does not work and last time I checked they don't support the Oracle MERGE INTO syntax either. This was a show stopper for me and I stopped thinking I would get anywhere with MySQL after that.</p>
3,182
<p>How to implement Repository pattern withe LinqToEntities how to implement the interface </p>
<p>At first one might think that reads and writes of the native machine size are atomic but there are a number of issues to deal with including cache coherency between processors/cores. Use atomic operations like Interlocked* on Windows and the equivalent on Linux. C++0x will have an "atomic" template to wrap these in a nice and cross-platform interface. For now if you are using a platform abstraction layer it may provide these functions. <a href="http://www.cse.wustl.edu/~schmidt/ACE.html" rel="noreferrer">ACE</a> does, see the class template <a href="http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/ace/Atomic_Op.inl" rel="noreferrer">ACE_Atomic_Op</a>.</p>
<p>The only portable way is to use the sig_atomic_t type defined in signal.h header for your compiler. In most C and C++ implementations, that is an int. Then declare your variable as "volatile sig_atomic_t."</p>
7,780
<p>Before I start, I'll give you my setup:</p> <ul> <li>Ender 3 Pro</li> <li>Marlin 2.0.7.2</li> <li>Material/Nozzle: PETG 0.4 mm @ 215 °C</li> <li>Bed: Glass @ 80 °C</li> <li>Default printing speed: 70 mm/s</li> <li>Standard part cooling fan</li> </ul> <p>Since I've updated the Marlin FW on from factory default to 2.0.7.2, my printer stops printing and gives out an thermal runaway exception message. Note that, after the firmware flash, I performed a PID-Tune multiple times.</p> <p>The problem is absolutely repeatable and happens always on beginning of layer 2 (more precisely: 40 seconds after beginning layer 2). Changing PID values doesn't change anything to the moment of the error occurring.</p> <p>I managed to run it longer by repeatedly dropping the temperature set-point and making a photo of the temperature plot. First photo is right after the initial drop from 215 to 205 °C. Second is when the temperature started rising slowly again.</p> <p><a href="https://i.stack.imgur.com/b67wW.jpg" rel="nofollow noreferrer" title="Right after the initial drop from 215 to 205 °C"><img src="https://i.stack.imgur.com/b67wW.jpg" alt="Right after the initial drop from 215 to 205 °C" title="Right after the initial drop from 215 to 205 °C" /></a></p> <p><a href="https://i.stack.imgur.com/BNF1j.jpg" rel="nofollow noreferrer" title="Temperature starting to rise slowly"><img src="https://i.stack.imgur.com/BNF1j.jpg" alt="Temperature starting to rise slowly" title="Temperature starting to rise slowly" /></a></p> <p>After this temperature drop, the hotend temperature seemed to be much less stable and reached only 205 °C.</p> <p>At Layer 12, the same thing happened again. But dropping the temperature far too low for PETG and having the &quot;same&quot; issue again, making me stop the print.</p> <p>This problem is pretty urgent and I haven't found any suitable solution by now. Do you have any ideas of what may cause this trouble? New heaters and thermistors are on their way right now. But I fear that this is not a hardware problem since none of the components are damaged and dysfunctional, nor the moment of failure is random.</p>
<p>It turned out, it was a faulty heater, that wasn't able to reach and maintain temperatures over 195 °C in a stable manner. The order came, had a new 50 W heater, thermistor and a PTFE-Bowden tube. It works just fine again, now!</p>
<p>Wrap all the heat system (above nozzle) with heat tape. I solved my problem with this!</p>
1,803
<p>Is there a graceful way to handle passing a list of ids as a parameter to a stored procedure? </p> <p>For instance, I want departments 1, 2, 5, 7, 20 returned by my stored procedure. In the past, I have passed in a comma delimited list of ids, like the below code, but feel really dirty doing it. </p> <p>SQL Server 2005 is my only applicable limitation I think.</p> <pre><code>create procedure getDepartments @DepartmentIds varchar(max) as declare @Sql varchar(max) select @Sql = 'select [Name] from Department where DepartmentId in (' + @DepartmentIds + ')' exec(@Sql) </code></pre>
<p>Erland Sommarskog has maintained the authoritative answer to this question for the last 16 years: <em><a href="http://www.sommarskog.se/arrays-in-sql.html" rel="noreferrer">Arrays and Lists in SQL Server</a></em>.</p> <p>There are at least a dozen ways to pass an array or list to a query; each has their own unique pros and cons. </p> <ul> <li><a href="http://www.sommarskog.se/arrays-in-sql-2008.html" rel="noreferrer">Table-Valued Parameters</a>. SQL Server 2008 and higher only, and probably the closest to a universal "best" approach.</li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#iterative" rel="noreferrer">The Iterative Method</a>. Pass a delimited string and loop through it. </li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#CLR" rel="noreferrer">Using the CLR</a>. SQL Server 2005 and higher from .NET languages only. </li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#XML" rel="noreferrer">XML</a>. Very good for inserting many rows; may be overkill for SELECTs.</li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#tblnum" rel="noreferrer">Table of Numbers</a>. Higher performance/complexity than simple iterative method.</li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#fixed-length" rel="noreferrer">Fixed-length Elements</a>. Fixed length improves speed over the delimited string</li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#fn_nums" rel="noreferrer">Function of Numbers</a>. Variations of Table of Numbers and fixed-length where the number are generated in a function rather than taken from a table.</li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#CTEs" rel="noreferrer">Recursive Common Table Expression</a> (CTE). SQL Server 2005 and higher, still not too complex and higher performance than iterative method.</li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#dynamic-sql" rel="noreferrer">Dynamic SQL</a>. Can be slow and has security implications. </li> <li>Passing the List as <a href="http://www.sommarskog.se/arrays-in-sql-2005.html#manyparameters" rel="noreferrer">Many Parameters</a>. Tedious and error prone, but simple. </li> <li><a href="http://www.sommarskog.se/arrays-in-sql-2005.html#realslow" rel="noreferrer">Really Slow Methods</a>. Methods that uses charindex, patindex or LIKE.</li> </ul> <p>I really can't recommend enough to <a href="http://www.sommarskog.se/arrays-in-sql.html" rel="noreferrer">read the article</a> to learn about the tradeoffs among all these options.</p>
<p>You could use XML. </p> <p>E.g. </p> <pre><code>declare @xmlstring as varchar(100) set @xmlstring = '&lt;args&gt;&lt;arg value="42" /&gt;&lt;arg2&gt;-1&lt;/arg2&gt;&lt;/args&gt;' declare @docid int exec sp_xml_preparedocument @docid output, @xmlstring select [id],parentid,nodetype,localname,[text] from openxml(@docid, '/args', 1) </code></pre> <p>The command <a href="http://msdn.microsoft.com/en-us/library/ms187367.aspx" rel="nofollow noreferrer">sp_xml_preparedocument</a> is built in. </p> <p>This would produce the output: </p> <pre><code>id parentid nodetype localname text 0 NULL 1 args NULL 2 0 1 arg NULL 3 2 2 value NULL 5 3 3 #text 42 4 0 1 arg2 NULL 6 4 3 #text -1 </code></pre> <p>which has all (more?) of what you you need.</p>
6,484
<p>I am using an ASP.NET MVC project and everytime I add a class to a folder it makes really long namespaces. </p> <p><strong>Example</strong>: </p> <pre><code>Project = Tully.Saps.Data Folder = DataAccess/Interfaces Namespace = Tully.Saps.Data.DataAccess.Interfaces Folder = DataAccess/MbNetRepositories Namespace = Tully.Saps.Data.DataAccess.MbNetRepositories </code></pre> <p><strong>Question</strong>:<br> Is it best to leave the namespace alone and add the using clause to the classes that access it or change the namespace to Tully.Saps.Data for everything in this project?</p>
<p>Leave them alone and add the usings. You're asking for trouble manually changing things like that (harder to debug, inconsistent with other projects, et cetera).</p>
<p>It is really up to you how you want to deal with it. If you are only going to be accessing a member of a namespace once or twice, then adding the "using" statement really doesn't do much for you. </p> <p>If you are going to use it multiple times then reducing the namespace chain is probably going to make things easier to read.</p> <p>You could always change the namespace so it doesn't add the new folder name if you are just looking to logically group files together, without creating a new namespace.</p>
9,213
<p>I have an Ender 3 and I have a problem with auto home. I use auto home and then level the bed with the wheels beneath the bed. I then start a print and the first layer is well above the bed. Perhaps about a millimeter. If I stop the print at this point and level the bed so that the first layer prints the normal paper width above the bed, everything works fine.</p> <p>The stops for the 3 axes seem to be in the right places and there is nothing noticeable obstructing them. When I use auto home it does touch the stops at all 3 axes. My belts seem to be tight and there is no movement of the bed if I try to jiggle it with my hand.</p> <p>Is there a way to adjust the Z axis so that the auto home elevation and the elevation of first layer of the print will be the same? </p> <p>This is an example of the first lines of G-code:</p> <pre><code>;FLAVOR:Marlin ;TIME:4724 ;Filament used: 1.70716m ;Layer height: 0.16 ;MINX:96.551 ;MINY:96.545 ;MINZ:0.2 ;MAXX:138.448 ;MAXY:138.455 ;MAXZ:100.4 ;Generated with Cura_SteamEngine 4.5.0 M140 S50 M105 M190 S50 M104 S200 M105 M109 S200 M82 ;absolute extrusion mode ; Ender 3 Custom Start G-code G92 E0 ; Reset Extruder G28 ; Home all axes G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little </code></pre>
<p>It sounds like there’s two things that could be going wrong here:</p> <ol> <li><p>Your starting G-code has some code in it that’s making it think that you want to treat a few layers up as <code>Z0</code>. If I were you I would minimize the start G-code until you get this sorted out. A quick fix would Be to add the following code to the end of your starting G-code:</p> <pre><code>G28: Homes all axis G28 Z0: Homes the Z-axis G29: Auto-bed-leveling (optional if you’ve already attached a leveling device) G1 Z3 F5000: Raises the Z position up 3 mm relative to where it was (G1 tells the machine to move, Z3 tells it how much to move and along which axis, F5000 is the speed of movement) G92 Z0.3: Treats the current position as Z = 0.3 (applying an offset of -0.3 and creating a sort of false home for the Z-axis). </code></pre> <p>Any commands made after this simple code will assume the print bed is lower than what it actually is (to account for any original gap between the nozzle and the print bed). If you want to have the nozzle raised, you’ll have to insert a negative value after the <code>G92</code> command.</p> </li> <li><p>You have a Z-offset set in your slicer software. This is a super easy fix if you find that you have one set, and it’s usually just because the slicer is using the preset for an Ender 3 with a glass bed. I would try setting it back to 0 if there is one already and try the G-code above.</p> <p>Even if the starting G-code I provided doesn’t solve your problem you should still find the Z-Offset setting in your slicer software and set it down -0.1 mm at a time until your printer starts printing in the correct Z-Axis position.</p> </li> </ol> <p>Here’s an All3DP article that helped a ton when I first got started: <a href="https://m.all3dp.com/2/ender-3-pro-z-offset/" rel="nofollow noreferrer">Ender 3 (Pro) Z Offset: How to Adjust It</a></p>
<p>The Z stop can be loosened and moved up but it seems weird that it would need to be moved and I don't think that would fix your issue. The Z height should be the same for the auto home and printing. I auto home then disable steppers and slowly move to all 4 corners. I have caught myself resting my arm on the X axis and moving it down. If that happens I manually move the Z until it just barely presses the Z stop in when I hear the button click. I have heard some say that they got a warped bed. I wonder if that's the issue. A glass plate would be a good way to be sure or maybe using a straight edge to check.You could also double check the tightness on the wheels is just right. Tomb of 3D Printed Horrors has a really good setup video called "Creality Ender 3 assembly and pro build tips" that has a few other tips that really helped me get set up well.</p>
1,612
<p>Is there a way to check to see if an iPhone is online from a web app. That is, in mobile Safari, can I check the online status of the device to see if I should try an AJAX call or not.</p> <p>In Firefox/regular WebKit, this would be:</p> <pre><code>if(navigator.onLine) { onlineCode() } </code></pre>
<p>That same code should work in the WebKit nightly build as of May 16th 2008. I guess that means you need to hope the 2.1 update included a new build of safari.</p> <p><a href="https://bugs.webkit.org/show_bug.cgi?id=19105" rel="nofollow noreferrer">https://bugs.webkit.org/show_bug.cgi?id=19105</a></p>
<p>That same code should work in the WebKit nightly build as of May 16th 2008. I guess that means you need to hope the 2.1 update included a new build of safari.</p> <p><a href="https://bugs.webkit.org/show_bug.cgi?id=19105" rel="nofollow noreferrer">https://bugs.webkit.org/show_bug.cgi?id=19105</a></p>
9,201
<p>I have a query that is dynamically built after looking up a field list and table name. I execute this dynamic query inside a stored proc. The query is built without a where clause when the two proc parameters are zero, and built with a where clause when not.</p> <p>When I execute the proc with SET FMTONLY ON exec [cpExportRecordType_ListByExportAgentID] null, null It returns no column information. I have just now replaced building the query without a where clause to just executing the same query directly, and now I get column information. I would love to know what causes this, anyone?</p>
<p>Perhaps it is related to the fact that the passed parameters are NULL, check how your query is build perhaps it behaves in different way then expected when you pass NULL. Does you proc returns expected results when you call: SET FMTONLY OFF exec [cpExportRecordType_ListByExportAgentID] null, null ?</p> <p>Other possibility: I understand that you build your query dynamically by getting results from calling another queries to get the column names. Perhaps the query that would normally give you the column names returns no data but only column information (SET FMTONLY ON) so you do not have data to build you dynamic query.</p>
<p>Perhaps it is related to the fact that the passed parameters are NULL, check how your query is build perhaps it behaves in different way then expected when you pass NULL. Does you proc returns expected results when you call: SET FMTONLY OFF exec [cpExportRecordType_ListByExportAgentID] null, null ?</p> <p>Other possibility: I understand that you build your query dynamically by getting results from calling another queries to get the column names. Perhaps the query that would normally give you the column names returns no data but only column information (SET FMTONLY ON) so you do not have data to build you dynamic query.</p>
9,780
<p>So, I'm pretty new to 3D Printing, and to quote Spock from <em>Wrath of Khan</em> I would say &quot;He is intelligent, but not experienced&quot;. Now everything I have been reading about Z-offset seems to talk about a 0.2 mm gap and using a piece of paper.</p> <p>Wishing to be accurate, I have tried to use my 0.2 mm feeler gauges and this is too high.</p> <p>However, the thickness of paper depends on the GSM (grams per square metre). A Google search tells me that the average thickness of paper is ~0.1 mm but how can we be accurate with this variation.</p> <p>I tried using a 0.1 mm feeler gauge and even this seemed too high. Is this because of the lack of give in the metal? Anyway, I have now settled for a Lotto slip (UK Lottery) which has a thickness of 0.1 mm and seems to allow me to set a good offset.</p> <p>However, I would welcome someone who can explain the science behind this.</p>
<p>They are all generic guidelines. Don't count on them too much.</p> <p>What you need is a reproducible offset to get the same value everywhere in the bed, then you can correct the overall offset via gcode at the beginning of your print.</p> <p>You can also get an approximate Z-offset value, then print a solid 30x30x5 mm cube.</p> <p>If, starting from the third-fourth layer, you see some over-extrusion, you need to adjust the extrusion multiplier or the E steps calibration and reprint.</p> <p>Once the solid cube looks good starting from the third-fourth layer up, then you can tune the Z offset by printing a cube which is only 0.2 mm high (or 0.25 mm, or whatever your first layer height is).</p> <p>If you see over-extrusion, the Z offset is too big. If you see visible gaps between extrusion lines, the Z offset is too small.</p> <p>If unsure, better get some small remaining gaps rather than overextrusion and excess material.</p> <p>The idea is that extrusion issues in the first layer can be caused either by the offset or by the multiplier, so you must adjust the multiplier first by looking at the print after about 1 mm height (the first layer issues tend to disappear after some layers). Once you know the extrusion is right, set properly the first layer.</p> <hr /> <p><strong>Edit</strong></p> <p>For a good guide check <a href="https://github.com/AndrewEllis93/Print-Tuning-Guide/" rel="nofollow noreferrer">Andrew Ellis' guide</a>: set first the <a href="https://github.com/AndrewEllis93/Print-Tuning-Guide/blob/main/articles/extrusion_multiplier.md" rel="nofollow noreferrer">extrusion multiplier</a> and then the <a href="https://github.com/AndrewEllis93/Print-Tuning-Guide/blob/main/articles/first_layer_squish.md" rel="nofollow noreferrer">first layer squish</a>.</p>
<p>Measuring a gap with paper is just a rule of thumb. Personally I didn't measure anything, I've just made sure my bed is level and adjusted z-offset bit by bit until I was satisfied with the results. I couldn't tell you how wide the gap is.</p> <p>On the other note you might not have to reconfigure your Marlin. You might be able to configure your z-offset by adjusting it directly in your printer config menu or alternatively if you are using Cura you can download a plug-in that allows you to adjust z-offset. You just have to remember to reslice your model if you print on multiple surfaces with different thickness</p>
1,856
<p>I'm a front-end developer and I was looking for opinions about the best all-round online documentation for javascript/css/html/xhtml/dom/browser quirks and support. I've tried Sitepoint, Quirksmode, W3Schools but all of these seem to be lacking in certain aspects and have been using them in combination.</p>
<p>I like <strike>gotapi.com</strike> (Update 2: Site is apparently offline -- Use another resource such as <a href="https://developer.mozilla.org/en-US/" rel="nofollow noreferrer">MDN</a>)</p> <p><strong>Update:</strong> the original answer was from 2008 -- today I would say to check out <a href="https://developer.mozilla.org/en-US/" rel="nofollow noreferrer">Mozilla Developer Network</a> (as many others have also said). </p>
<p>I tend to go to <a href="http://msdn.microsoft.com/" rel="nofollow noreferrer">http://msdn.microsoft.com/</a> first.</p>
8,938
<p>I'm new to SVN and I'd like to know what methods are available for backing up repositories in a Windows environment?</p>
<p>You could use something like (Linux):</p> <pre><code>svnadmin dump repositorypath | gzip &gt; backupname.svn.gz </code></pre> <p>Since Windows does not support GZip it is just:</p> <pre><code>svnadmin dump repositorypath &gt; backupname.svn </code></pre>
<p>as others have said, hot-backup.py from the Subversion team has some nice features over just plain <code>svnadmin hotcopy</code></p> <p>I run a scheduled task on a python script that spiders for all my repositories on the machine, and uses hotbackup to keep several days worth of hotcopies (paranoid of corruption) and an <code>svnadmin svndump</code> on a remote machine. Restoration is really easy from that - so far.</p>
5,302
<p>I'm exploring the possibility of writing an application in Erlang, but it would need to have a portion written in Cocoa (presumably Objective-C). I'd like the front-end and back-end to be able to communicate easily. How can this best be done?</p> <p>I can think of using C ports and connected processes, but I think I'd like a reverse situation (the front-end starting and connecting to the back-end). There are named pipes (FIFOs), or I could use network communications over a TCP port or a named BSD socket. Does anyone have experience in this area?</p>
<p>One way would be to have the Erlang core of the application be a daemon that the Cocoa front-end communicates with over a Unix-domain socket using some simple protocol you devise.</p> <p>The use of a Unix-domain socket means that the Erlang daemon could be launched on-demand by <code>launchd</code> and the Cocoa front-end could find the path to the socket to use via an environment variable. That makes the rendezvous between the app and the daemon trivial, and it also makes it straightforward to develop multiple front-ends (or possibly a framework that wraps communication with the daemon).</p> <p>The Mac OS X <code>launchd</code> system is really cool this way. If you specify that a job should be launched on-demand via a secure Unix-domain socket, <code>launchd</code> will actually create the socket itself with appropriate permissions, and advertise its location via the environment variable named in the job's property list. The job, when started, will actually be passed a file descriptor to the socket by <code>launchd</code> when it does a simple check-in.</p> <p>Ultimately this means that the entire process of the front-end opening the socket to communicate with the daemon, <code>launchd</code> launching the daemon, and the daemon responding to the communication can be secure, even if the front-end and the daemon run at different privilege levels.</p>
<p>Usually when creating Cocoa applications that front UNIX commands or other headless programs you use an <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSTask_Class/Reference/Reference.html" rel="nofollow noreferrer"><code>NSTask</code></a>:</p> <blockquote> <p>Using the NSTask class, your program can run another program as a subprocess and can monitor that program’s execution. An NSTask object creates a separate executable entity; it differs from NSThread in that it does not share memory space with the process that creates it.</p> <p>A task operates within an environment defined by the current values for several items: the current directory, standard input, standard output, standard error, and the values of any environment variables. By default, an NSTask object inherits its environment from the process that launches it. If there are any values that should be different for the task, for example, if the current directory should change, you must change the value before you launch the task. A task’s environment cannot be changed while it is running.</p> </blockquote> <p>You can communicate with the backend process by way of <code>stdin</code>/<code>stdout</code>/<code>stderr</code>. Bascially <code>NSTask</code> is a high-level wrapper around <code>exec</code> (or <code>fork</code> or <code>system</code>, I always forget the difference).</p> <p>As I understand it you don't want the Erland program to be a background daemon that runs continuously, but if you do, go with <a href="https://stackoverflow.com/questions/37381/whats-a-good-way-to-write-a-cocoa-front-end-to-an-erlang-application#37408">@Chris's</a> suggestion.</p>
5,805
<p>Where can I find a good tutorial on learning ASP.NET MVC using VB.net 2008 as the language? Most in-depth tutorials that I found in searching the web were written in C#.</p>
<p>Have you tried adding the word &quot;VB&quot; to your searches??</p> <p><a href="http://www.myvbprof.com/2007_Version/MVC_Intro_Tutorial.aspx" rel="nofollow noreferrer">http://www.myvbprof.com/2007_Version/MVC_Intro_Tutorial.aspx</a></p> <p><a href="http://www.asp.net/learn/mvc/tutorial-07-vb.aspx" rel="nofollow noreferrer">http://www.asp.net/learn/mvc/tutorial-07-vb.aspx</a></p> <p>&lt;<a href="https://web.archive.org/web/20170119043903/http://geekswithblogs.net:80/jwhitehorn/archive/2007/12/10/117569.aspx" rel="nofollow noreferrer">Link</a>&gt;</p>
<p><a href="http://quickstarts.asp.net/3-5-extensions/mvc/default.aspx" rel="nofollow noreferrer">http://quickstarts.asp.net/3-5-extensions/mvc/default.aspx</a></p> <p>Is that relevant?</p>
5,262
<p>Is it possible to launch a new window in JavaScript using the window.Open function, then set the focus to that tab?</p> <p>Here's what I'm doing today: <code></p> <pre> var winRef = window.open(outUrl,wName,'left='+ wX +',top=' + wY + ',height=' + wH + ',width=' + wW + args); try { // Not all window types support the focus() property. winRef.focus(); } catch (exception) { } </pre> <p></code></p> <p>The window opens, but the new tab doesn't receive focus.</p>
<p>Jay,</p> <p>You are seeing designed behavior. To limit opportunities for malicious behavior, scripts running in tabbed windows cannot affect other tabs.</p> <p>For more information, please see Tabbed Browsing for Developers at <a href="http://msdn.microsoft.com/en-us/library/ms537636.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms537636.aspx</a> :</p> <p>"The ability to open multiple documents within the same browser window has certain practical and security implications [...] Active tabs (tabs with focus) cannot be affected by scripts that run in inactive or background tabs."</p> <p>BR.</p>
<p>As a user, I never want applications (or tabs) to take focus unless I specifically requested it. I have gone to great lengths to prevent tabs in my browser (Firefox) from taking focus for this reason. </p>
9,855
<p>I'm wondering if there's a way to do what I can do below with Python, in Ruby:</p> <pre><code>sum = reduce(lambda x, y: x + y, map(lambda x, y: x * y, weights, data)) </code></pre> <p>I have two arrays of equal sizes with the weights and data but I can't seem to find a function similar to map in Ruby, reduce I have working.</p>
<p>@Michiel de Mare</p> <p>Your Ruby 1.9 example can be shortened a bit further:</p> <pre><code>weights.zip(data).map(:*).reduce(:+) </code></pre> <p>Also note that in Ruby 1.8, if you require ActiveSupport (from Rails) you can use:</p> <pre><code>weights.zip(data).map(&amp;:*).reduce(&amp;:+) </code></pre>
<p>An alternative for the map that works for more than 2 arrays as well:</p> <pre><code>def dot(*arrays) arrays.transpose.map {|vals| yield vals} end dot(weights,data) {|a,b| a*b} # OR, if you have a third array dot(weights,data,offsets) {|a,b,c| (a*b)+c} </code></pre> <p>This could also be added to Array:</p> <pre><code>class Array def dot self.transpose.map{|vals| yield vals} end end [weights,data].dot {|a,b| a*b} #OR [weights,data,offsets].dot {|a,b,c| (a*b)+c} </code></pre>
2,546
<p>I have an unusual situation in which I need a SharePoint timer job to both have local administrator windows privileges and to have <code>SHAREPOINT\System</code> SharePoint privileges.</p> <p>I can get the windows privileges by simply configuring the timer service to use an account which is a member of local administrators. I understand that this is not a good solution since it gives SharePoint timer service more rights then it is supposed to have. But it at least allows my SharePoint timer job to run <code>stsadm</code>.</p> <p>Another problem with running the timer service under local administrator is that this user won't necessarily have <code>SHAREPOINT\System</code> SharePoint privileges which I also need for this SharePoint job. It turns out that <code>SPSecurity.RunWithElevatedPrivileges</code> won't work in this case. Reflector shows that <code>RunWithElevatedPrivileges</code> checks if the current process is <code>owstimer</code> (the service process which runs SharePoint jobs) and performs no elevation this is the case (the rational here, I guess, is that the timer service is supposed to run under <code>NT AUTHORITY\NetworkService</code> windows account which which has <code>SHAREPOINT\System</code> SharePoint privileges, and thus there's no need to elevate privileges for a timer job).</p> <p>The only possible solution here seems to be to run the timer service under its usual NetworkService windows account and to run stsadm as a local administrator by storing the administrator credentials somewhere and passing them to System.Diagnostics.Process.Run() trough the StarInfo's Username, domain and password.</p> <p>It seems everything should work now, but here is another problem I'm stuck with at the moment. Stsamd is failing with the following error popup (!) (Winternals filemon shows that stsadm is running under the administrator in this case):</p> <p><code>The application failed to initialize properly (0x0c0000142).</code> <br /> <code>Click OK to terminate the application.</code></p> <p>Event Viewer registers nothing except the popup.</p> <p>The local administrator user is my account and when I just run <code>stsadm</code> interactively under this account everything is ok. It also works fine when I configure the timer service to run under this account.</p> <p>Any suggestions are appreciated :)</p>
<p>I'm not at work so this is off the top of my head, but: If you get a reference to the Site, can you try to create a new SPSite with the SYSTEM-UserToken?</p> <pre><code>SPUserToken sut = thisSite.RootWeb.AllUsers["SHAREPOINT\SYSTEM"].UserToken; using (SPSite syssite = new SPSite(thisSite.Url,sut) { // Do what you have to do } </code></pre>
<p>Other applications if run this way (i.e. from a timer job with explicit credentials) are failing the same way with "The application failed to initialize propely". I just worte a simple app which takes a path of another executable and its arguments as parameres and when run from that timer job it fails the same way.</p> <pre><code>internal class ExternalProcess { public static void run(String executablePath, String workingDirectory, String programArguments, String domain, String userName, String password, out Int32 exitCode, out String output) { Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardError = true; process.StartInfo.RedirectStandardOutput = true; StringBuilder outputString = new StringBuilder(); Object synchObj = new object(); DataReceivedEventHandler outputAppender = delegate(Object sender, DataReceivedEventArgs args) { lock (synchObj) { outputString.AppendLine(args.Data); } }; process.OutputDataReceived += outputAppender; process.ErrorDataReceived += outputAppender; process.StartInfo.FileName = @"C:\AppRunner.exe"; process.StartInfo.WorkingDirectory = workingDirectory; process.StartInfo.Arguments = @"""" + executablePath + @""" " + programArguments; process.StartInfo.UserName = userName; process.StartInfo.Domain = domain; SecureString passwordString = new SecureString(); foreach (Char c in password) { passwordString.AppendChar(c); } process.StartInfo.Password = passwordString; process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); exitCode = process.ExitCode; output = outputString.ToString(); } } </code></pre> <p>AppRunner basically does the same as the above fragment, but without username and password</p>
2,578
<p>Has anyone tried the steel-reinforced polyurethane timing belts? If so, how do they compare to the rubber ones?</p>
<p>Belts come in several formulations. This <a href="https://www.mcmaster.com/#belts/=1e9qsqj" rel="noreferrer">page</a> from McMaster-Carr lists several types of belts. The main materials (rubbers) are Neoprene and urethane, with fiberglass, Kevlar, and steel reinforcement. I would suggest spending some time looking at these, comparing the specs, and basing your choice on the needs of your application.</p> <p>I used 1/4" wide MXL series cut-to-length in my machine. I have yet to see a wear or stretch problem and haven't yet done the high-speed photography to look for dynamic stretch. IMO, I have a bigger problem with the length of belt resonating like a guitar string than I do with the stretch of the belt. The compliance needed for resonance can come not only from the belt but also from the mechanical system it is mounted to. In some cases, a slightly stretchy belt could dampen oscillations that would otherwise result from impulse forces being coupled into the printer frame.</p>
<p>I had really bad problems with GT2 PU belts (including steel reinforced), under big tension they degrade suddenly with big change in the geometry at some position. When removed they look twisted. Looks like some reinforcing wires slipped inside the PU body of the belt.</p> <p>Once switched to rubber GT2 belts (fibreglass reinforced) I never had problems connected to the belts. I can tell that rubber GT2 belts have no noticeable change in the geometry over many years of constant use under high tension with the spring.</p>
1,007
<p>I have a WCF Web Service which is referenced from a class library. After the project is run, when creating the service client object from inside a class library, I receive an InvalidOperationException with message:</p> <blockquote> <p>Could not find default endpoint element that references contract 'MyServiceReference.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.</p> </blockquote> <p>The code I am using to create the instance is:</p> <pre><code>myServiceClient = new MyServiceClient(); </code></pre> <p>where MyServiceClient inherits from</p> <p>System.ServiceModel.ClientBase</p> <p>How do I solve this?</p> <p>Note: I have a seperate console application which simply creates the same service object and makes calls to it and it works without no problems.</p>
<blockquote> <p>Here is my app.config file of the class library:</p> </blockquote> <p>You should put this configuration settings to main app's config file. .NET application (which is calling your class library) uses data from it's own config file not from your library config file.</p>
<p>It would probably help if you posted your app.config file, since this kind of error tends to point to a problem in the <code>&lt;endpoint&gt;</code> block. Make sure the contract attribute seems right to you.</p> <p>Edit: Try fully qualifying your contract value; use the full namespace. I think that is needed.</p>
4,464
<p>I can easily set breakpoints in embedded JS functions, but I don't see any way of accessing external JS scripts via Firebug unless I happen to enter them during a debug session. Is there a way to do this without having to 'explore' my way into the script?</p> <p>@Jason: This is a good point, but in my case I do not have easy access to the script. I am specifically talking about the client scripts which are invoked by the ASP.Net Validators that I would like to debug. I can access them during a debug session through entering the function calls, but I could not find a way to access them directly.</p>
<p>Place <code>debugger;</code> in your external script file on the line you want to break on.</p>
<p>After you place a break point in them, you can also call them by name in the firebug console, and see the output of (or step through) any intermediate functions. This can help when the main entry point calls many other helper functions, and you are really just concerned with how these helpers are working.</p> <p>That being said, I don't knwo anything about ASP.Net validators, so its possible this doesn't apply.</p>
5,259
<p>I am new to 3D printing. I have a Longer LK5 Pro. I was making a part that has raised letters, and wanted to have white letters on the black part. I used a Post Processing script on the Cura program called &quot;change filament&quot;, which is supposed to stop printing, retract the head, and allow you to change the filament. Mine just keeps on printing. I've tried &quot;pause&quot; and done the filament change, but unsuccessfully so far because of blobs deposited on the letters.</p> <p>Any suggestions?</p>
<p>I've done it a few ways depending on the desired effect I'm after.</p> <p>Manually pausing the machine is what seems to come out best. If you design for it, you can sometimes have it pause while it's over infill and therefore has no blobs to worry about. I haven't looked into doing it automatically, but perhaps it's possible to pause partway through a layer.</p> <p>If the design doesn't have to be flat, then I'll do a solid colour and the last top layers another colour with the design cut out. This is to my mind optimal as you get a bit of texture with the design inset as well as different colour and makes for a nice clean method.</p> <p>The other way was z-hopping which is an idea I got from a Youtube video. Cura has a setting for this. Basically you can make the nozzle lift when it moves. You split the colours into two separate objects and you print in one colour. Then you change filament and print another colour as a separate print right over the top of it and the nozzle hops over the original print.</p>
<p>I found that raised letters look and work better when picked-out using paint or permanent marker.</p> <p>Print your lettering in your part but don't even bother changing filament. Instead carefully use a marker pen or paint brush to colour in the top of the lettering. Depending on the paint you might choose to do several layers.</p> <p>Nail polish is an excellent paint option - it comes in a plethora of colours and the budget stuff works fine. Gold/silver/metallic &quot;art markers&quot; give a nice look on black or white PLA too.</p> <p>Note, white/light filament jobs may encourage pigments to track between the layers, giving a shadow look. Test before committing.</p> <p>When dry, you might chose to do a clearcoat of spray paint on top for durability.</p> <p>IMO changing filament colour is a feature that doesn't work very reliably.</p>
2,213
<p>I'm using the RESTful authentication Rails plugin for an app I'm developing. I'm having a strange issue I can't get to the bottom of. Essentially, the first time I log into the app after a period of inactivity (the app is deployed in production, but only being used by me), I will be brought to a 404 page, but if I go back to the home page and log in again, everything works according to plan. Any ideas?</p>
<p>Please check your routes.</p> <p>Not all routes are created equally. Routes have priority defined by the order of appearance of the routes in the config/routes.rb file. The priority goes from top to bottom. The last route in that file is at the lowest priority and will be applied last. If no route matches, <strong>404</strong> is returned.</p> <p>More info: <a href="http://api.rubyonrails.org/classes/ActionController/Routing.html" rel="nofollow noreferrer">http://api.rubyonrails.org/classes/ActionController/Routing.html</a></p>
<p>I'm using a slightly modified version of that plugin so I'm not 100% sure that this will be the same for you, but for me the default is to redirect to the root path, or the page you were trying to get to if there is one. (check your lib/authenticated_system.rb to see your default) If you don't have map.root defined in your routes, I believe that would cause the error you're describing -- it wouldn't find root_path at first but if you tried "from" a page in your app it would redirect to that page.</p> <p>Let us know what happens with this one if you would, I'm curious to see what this ends up being in case I run into it in the future. :)</p>
5,989
<p>How to serve users a dynamically generated ZIP archive in Django?</p> <p>I'm making a site, where users can choose any combination of available books and download them as ZIP archive. I'm worried that generating such archives for each request would slow my server down to a crawl. I have also heard that Django doesn't currently have a good solution for serving dynamically generated files.</p>
<p>The solution is as follows.</p> <p>Use Python module <a href="https://docs.python.org/3/library/zipfile.html" rel="noreferrer">zipfile</a> to create zip archive, but as the file specify <a href="https://docs.python.org/3/library/io.html#io.StringIO" rel="noreferrer">StringIO</a> object (ZipFile constructor requires file-like object). Add files you want to compress. Then in your Django application return the content of StringIO object in <code>HttpResponse</code> with mimetype set to <code>application/x-zip-compressed</code> (or at least <code>application/octet-stream</code>). If you want, you can set <code>content-disposition</code> header, but this should not be really required.</p> <p>But beware, creating zip archives on each request is bad idea and this may kill your server (not counting timeouts if the archives are large). Performance-wise approach is to cache generated output somewhere in filesystem and regenerate it only if source files have changed. Even better idea is to prepare archives in advance (eg. by cron job) and have your web server serving them as usual statics.</p>
<p>Can't you just write a link to a "zip server" or whatnot? Why does the zip archive itself need to be served from Django? A 90's era CGI script to generate a zip and spit it to stdout is really all that's required here, at least as far as I can see.</p>
9,299
<p>This gets the value of whatever is selected in my dropdown menu.</p> <pre><code>document.getElementById('newSkill').value </code></pre> <p>I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at <a href="http://w3schools.com/" rel="noreferrer">W3Schools</a> but that didn't have the answer, does anybody here know?</p> <p>For those not sure, here's the HTML for a drop down box.</p> <pre><code>&lt;select name="newSkill" id="newSkill"&gt; &lt;option value="1"&gt;A skill&lt;/option&gt; &lt;option value="2"&gt;Another skill&lt;/option&gt; &lt;option value="3"&gt;Yet another skill&lt;/option&gt; &lt;/select&gt; </code></pre>
<p>Based on your example HTML code, here's one way to get the displayed text of the currently selected option:</p> <pre><code>var skillsSelect = document.getElementById("newSkill"); var selectedText = skillsSelect.options[skillsSelect.selectedIndex].text; </code></pre>
<pre><code> var ele = document.getElementById('newSkill') ele.onchange = function(){ var length = ele.children.length for(var i=0; i&lt;length;i++){ if(ele.children[i].selected){alert(ele.children[i].text)}; } } </code></pre>
2,779
<p>When an application is behind another applications and I click on my application's taskbar icon, I expect the entire application to come to the top of the z-order, even if an app-modal, WS_POPUP dialog box is open.</p> <p>However, some of the time, for some of my (and others') dialog boxes, only the dialog box comes to the front; the rest of the application stays behind.</p> <p>I've looked at Spy++ and for the ones that work correctly, I can see WM_WINDOWPOSCHANGING being sent to the dialog's parent. For the ones that leave the rest of the application behind, WM_WINDOWPOSCHANGING is not being sent to the dialog's parent.</p> <p>I have an example where one dialog usually brings the whole app with it and the other does not. Both the working dialog box and the non-working dialog box have the same window style, substyle, parent, owner, ontogeny.</p> <p>In short, both are WS_POPUPWINDOW windows created with DialogBoxParam(), having passed in identical HWNDs as the third argument.</p> <p>Has anyone else noticed this behavioral oddity in Windows programs? What messages does the TaskBar send to the application when I click its button? Who's responsibility is it to ensure that <em>all</em> of the application's windows come to the foreground?</p> <p>In my case the base parentage is an MDI frame...does that factor in somehow?</p>
<p>I know this is very old now, but I just stumbled across it, and I know the answer.</p> <p>In the applications you've seen (and written) where bringing the dialog box to the foreground did <strong>not</strong> bring the main window up along with it, the developer has simply neglected to specify the owner of the dialog box.</p> <p>This applies to both modal windows, like dialog boxes and message boxes, as well as to modeless windows. Setting the owner of a modeless popup also keeps the popup above its owner at all times.</p> <p>In the Win32 API, the functions to bring up a dialog box or a message box take the owner window as a parameter:</p> <pre><code>INT_PTR DialogBox( HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, /* this is the owner */ DLGPROC lpDialogFunc ); int MessageBox( HWND hWnd, /* this is the owner */ LPCTSTR lpText, LPCTSTR lpCaption, UINT uType ); </code></pre> <p>Similary, in .NET WinForms, the owner can be specified:</p> <pre><code>public DialogResult ShowDialog( IWin32Window owner ) public static DialogResult Show( IWin32Window owner, string text ) /* ...and other overloads that include this first parameter */ </code></pre> <p>Additionally, in WinForms, it's easy to set the owner of a modeless window:</p> <pre><code>public void Show( IWin32Window owner, ) </code></pre> <p>or, equivalently:</p> <pre><code>form.Owner = this; form.Show(); </code></pre> <p>In straight WinAPI code, the owner of a modeless window can be set when the window is created:</p> <pre><code>HWND CreateWindow( LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, /* this is the owner if dwStyle does not contain WS_CHILD */ HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam ); </code></pre> <p>or afterwards:</p> <pre><code>SetWindowLong(hWndPopup, GWL_HWNDPARENT, (LONG)hWndOwner); </code></pre> <p>or (64-bit compatible)</p> <pre><code>SetWindowLongPtr(hWndPopup, GWLP_HWNDPARENT, (LONG_PTR)hWndOwner); </code></pre> <p>Note that MSDN has the following to say about <a href="http://msdn.microsoft.com/en-us/library/ms644898(VS.85).aspx" rel="noreferrer">SetWindowLong[Ptr]</a>:</p> <blockquote> <p>Do not call <strong>SetWindowLongPtr</strong> with the GWLP_HWNDPARENT index to change the parent of a child window. Instead, use the <a href="http://msdn.microsoft.com/en-us/library/ms633541(VS.85).aspx" rel="noreferrer">SetParent</a> function. </p> </blockquote> <p>This is somewhat misleading, as it seems to imply that the last two snippets above are wrong. This isn't so. Calling <code>SetParent</code> will turn the intended popup into a <em>child</em> of the parent window (setting its <code>WS_CHILD</code> bit), rather than making it an owned window. The code above is the correct way to make an existing popup an owned window.</p>
<p>Is the dialog's parent window set correctly?</p> <p>After I posted this, I started my own Windows Forms application and reproduced the problem you describe. I have two dialogs, one works correctly the other does not and I can't see any immediate reason is to why they behave differently. I'll update this post if I find out.</p> <p>Raymond Chen where are you!</p>
7,410
<p>Right now my heated bed is down and I had no time to try and fix it and I am trying to print something for a friend. I am having the PLA lift around the edges which I have NEVER experienced. The glue is not helping like it did with the heat. And I also tried rubbing alcohol on the masking tape I use, heard that helps and it was not that much better than the glue stick. What can I do to keep the plastic sticking to the bed during print. </p> <p>I will note that the lift is not super bad, but I do like the littlest of lift on any print. </p>
<p>Most of the same reccomendations that apply for adhesion to a hot bed apply for a cold one. The first ones to come to mind:</p> <ul> <li>really dial in the nozzle height</li> <li>make the first layer taller than the rest (e.g.: 0.2mm if the rest of your print is 0.1mm)</li> <li>print the first layer very slowly</li> <li>print the first layer at higher temperature</li> <li>use a brim or a raft (on my first printer, that had no heated bed, rafts gave the least deformation)</li> <li>turn off the part fan for the first layer</li> <li>adapt your model to reduce twisting forces (relief cuts, print it in parts, choose orientation wisely, etc...)</li> </ul> <p>If your slicer has this feature, you could also try to print with a shroud.</p>
<p><strong>Fresh</strong> 3M blue painter’s tape coated in a watered down solution of Elmer’s white glue works wonders - even when cold - for PLA.</p> <p>The tape needs to be re-applied and coated for each print for it to <strong>really</strong> stick, but it beats every other print surface I have tested for PLA other than PEI @ 70&nbsp;&deg;C. I’m guessing it has something to do with microscopic surface fibers on the tape...</p> <p>(I like to print PETG as well, and that sticks too well to PEI, so I use blue 3M tape for both.)</p>
824
<p>A 3D printer needs to be homed (homing) before the print starts.</p> <ul> <li>What is homing?</li> <li>What is the purpose of homing?</li> <li>Is it necessary?</li> </ul>
<blockquote> <ul> <li>What is homing?</li> </ul> </blockquote> <p>From the <a href="https://3dprinting.stackexchange.com/tags/homing/info">tag wiki</a> <a href="/questions/tagged/homing" class="post-tag" title="show questions tagged &#39;homing&#39;" rel="tag">homing</a> we can read:</p> <blockquote> <p>The process of determining the location of a 3D printer nozzle in three dimension using a reference point (home location) is referred to as &quot;homing&quot;. Homing should occur before every print and involves bringing the X, Y and Z-Axis motors to pre-defined limit locations (usually these are endstops). Pre-recorded homing data offset values determine the position of the build plate origin with respect to the endstop locations.</p> </blockquote> <blockquote> <ul> <li>What is the purpose of homing?</li> </ul> </blockquote> <p>So, homing is defining the printer coordinate system location with respect to a reference location we call &quot;home&quot;. Why? The controller board or steppers have no memory for storing their position and could have been manually moved. Once the axes have &quot;seen&quot; there reference location, the printer will remember to refer all movements in respect to this point (this may include offset values to get to the origin of the printer (see <a href="https://3dprinting.stackexchange.com/questions/6375/how-to-center-my-prints-on-the-build-platform-re-calibrate-homing-offset">How to center my prints on the build platform? (Re-calibrate homing offset)</a>). Note, if a problem occurs where e.g. the nozzle hits the bed or print object, the nozzle may be out of sync with the reference point. Such an anomaly is e.g. layer shifting which occurs on open-loop stepper movement (servo steppers have feedback to prevent this from happening, but these are more expensive). The purpose of homing is to set a reference so that your sliced objects can be printed at the correct location within the printer print volume. If correctly configured, and no problems like layer shifting occur, the benefit is that proper homing prevent the machine to print within the limits of the printer.</p> <blockquote> <ul> <li>Is it necessary?</li> </ul> </blockquote> <p>Strictly speaking, no, it is not necessary. But if you do not automatically set a reference for each axis, you would need to manually provide a position to start from. This can work just as well, but the use of end stops automate the procedure so that it is very easy for the printer operator. Some (of the cheaper) CNC machines do not have end stops, the operator needs to be aware to position the tool head of the CNC machine at the proper starting position.</p>
<p>Most 3d printers control head position using stepper motors and end stops with no position feedback. The stepper motor does not actually know its location.</p> <p>The printer's control system can only know the location of the head by keeping track of the relative number of steps the head has been moved by the stepper motors.</p> <p>Homing moves all the axes in one direction until it hits the end stops for each axis. Once that has been done, then the control system knows exactly where the head is and future relative motions can be offset from there.</p> <p>Some control systems will move the axis at a relatively high speed (so you don't get bored, but not fast enough to cause damage) and then overshoot the end stop's activation point and stop. Then they will back off to release the end stop and then move towards it more slowly to get a more exact reading of the activation point.</p> <p>When the printer is idle, frequently the stepper motors are unpowered to save energy and keep the motors cool. When the motors are unpowered, they can free spin (you can push the axis with your hand or the vertical axis might even slip a bit with gravity), so the position would be uncertain, and it would be necessary to re-home. Once it has rehomed, the control system will keep the motors powered to prevent slipping.</p> <p>It is only necessary to home if you care about where the printer starts printing. In theory, you could get away with only homing the vertical axis (so the print starts on a surface and the first layer is the correct thickness), and manually set the horizontal start position. However, this might make using the full horizontal limits of the build area difficult if you didn't start it in the right place.</p>
2,059
<p>Does anybody here have positive experience of working with MS SQL Server 2005 from Rails 2.x?</p> <p>Our developers use Mac OS X, and our production runs on Linux. For legacy reasons we should use MS SQL Server 2005.</p> <p>We're using ruby-odbc and are running into various problems, too depressing to list here. I get an impression that we're doing something wrong. </p> <p>I'm talking about the no-compromise usage, that is, with migrations and all.</p> <p>Thank you,</p>
<p>Have you considered using JRuby? Microsoft has a <a href="http://msdn.microsoft.com/en-us/data/aa937724.aspx" rel="nofollow noreferrer">JDBC driver for SQL Server</a> that can be run on UNIX variants (it's pure Java AFAIK). I was able to get the 2.0 technology preview working with JRuby and Rails 2.1 today. I haven't tried migrations yet, but so far the driver seems to be working quite well.</p> <p>Here's a rough sketch of how to get it working:</p> <ol> <li>Make sure Java 6 is installed</li> <li>Install JRuby using the instructions on the <a href="http://www.jruby.org/" rel="nofollow noreferrer">JRuby website</a></li> <li>Install Rails using gem (<code>jruby -S gem install rails</code>)</li> <li>Download the UNIX package of <a href="http://msdn.microsoft.com/en-us/data/aa937724.aspx" rel="nofollow noreferrer">Microsoft's SQL Server JDBC driver</a> (Version 2.0)</li> <li>Unpack Microsoft's SQL Server driver</li> <li>Find sqljdbc4.jar and copy it to JRuby's lib directory</li> <li><code>jruby -S gem install activerecord-jdbcmssql-adapter</code></li> <li>Create a rails project (<code>jruby -S rails hello</code>)</li> <li>Put the proper settings in database.yml (example below)</li> <li>You're all set! Try running <code>jruby script/console</code> and creating a model.</li> </ol> <pre> development: host: localhost adapter: jdbc username: sa password: kitteh driver: com.microsoft.sqlserver.jdbc.SQLServerDriver url: jdbc:sqlserver://localhost;databaseName=mydb timeout: 5000 </pre> <p>Note: I'm not sure you can use Windows Authentication with the JDBC driver. You may need to use SQL Server Authentication.</p> <p>Best of luck to you!</p> <p>Ben</p>
<p>I would strongly suggest you weigh up migrating from the legacy database. You'll probably find yourself in a world of pain pretty quickly. From experience, Rails and legacy schemas don't go too well together either.</p> <p>I don't think there's a "nice solution" to this one, I'm afraid.</p>
9,272
<p>I did calibrate the extruder to extrude exactly 50/100 mm and it is fine. I have replaced the old (prehistorical) extruder that was giving me the problem with a new one. The issue does not go away. It is severely under extruded. The nozzle is a 0.4 mm, if I extrude manually the extrusion is nice and clean but when printing its a mess. I have the following setting in Slic3:</p> <ul> <li>Layer height: 0,16</li> <li>First layer height: 0,16</li> <li>Filament diameter: 2,94</li> <li>Extruder temperature: 184°C</li> <li>Extrusion multiplier: 1</li> <li>Fill density: 15%</li> </ul> <p>In Marlin I have the following setting for the extruder:</p> <ul> <li>Steps per unit: 1450 (I use micro steps)</li> <li>Default acceleration: 3000</li> <li>Default retract acceleration: 3000</li> <li>Default Ejerk: 5</li> </ul> <p>How can I solve this problem?</p> <p><a href="https://i.stack.imgur.com/2axcC.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/2axcC.jpg" alt="enter image description here"></a></p> <p>This is a 20 mm cube I stopped after 15 layers!</p> <p>Here is another 20 mm cube, the dimensions are perfect but is absolutely a mess. <a href="https://i.stack.imgur.com/zZTMq.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/zZTMq.jpg" alt="enter image description here"></a></p>
<p>Assuming your filament dimension settings are correct and your extruder is correctly calibrated...</p> <p><strong>Your extruder temperature may be too low.</strong> While 184C can be hot enough, it is very near the bottom of the range for PLA and it appears your filament isn't melting quickly enough to keep up with your other settings. Your extruder may even be running slightly cooler than you think so your 184C setting may actually be printing at 180C or less.</p> <p><strong>To solve this:</strong></p> <ul> <li><strong>Raise your extruder temperature.</strong> I suggest raising your print temperature to 220 degrees and then gradually lower it until other aspects of your print quality are acceptable (bridging, oozing, etc).</li> <li><strong>Slow down your print.</strong> Slowing down reduces the volume of melted plastic your extruder has to deliver in a given amount of time. This allows more time for the plastic to melt and allows you to use a lower print temperature</li> </ul> <p><strong>Your filament feed mechanism may be slipping.</strong> Even if you have adequate temperature and perfectly calibrated firmware and print settings, if your filament feed mechanism (the thing that pushes filament into your extruder) is slipping, you will have under-extruded parts.</p> <p><strong>To solve this:</strong></p> <ul> <li><strong>Make sure you have adequate tension on your filament feed mechanism.</strong> If your feed mechanism is too loose, filament may slip and cause under extrusion. The part to check is the part the pushes the filament into the rotating hobbed bolt or friction wheel...make sure it applies adequate pressure. "Adequate pressure" or "adequate tension" will vary depending you your printer's design, but it should be enough to provide a firm grip on the filament.</li> <li><strong>Verify your feed mechanism is clean.</strong> A hobbed bolt or similar filament drive mechanism that has become clogged or otherwise contaminated may cause filament to slip and under-extrude.</li> <li><strong>Ensure the end of your filament is not damaged from slipping.</strong> Once your filament has slipped, it may be damaged with a worn spot, a bulge, or some other defect that can prevent proper feeding even after you fix the root cause of your problem. So, as tbm0115 pointed out, be sure to clip off the damaged end to make sure you have good filament feeding into your extruder.</li> </ul> <p>I hope this helps!</p>
<p>Looks to me like you have your slicer set to 3mm filament when you're using 1.75mm filament. Confirm that your slicer has its filament setting set to 1.75mm and not 3mm (this obviously assumes you are using 1.75mm filament..)</p> <p>Failing this:</p> <ul> <li>Test extruder steps/mm</li> <li>Ensure nozzle diameter is set correctly (usually doesnt make too much difference anyway...)</li> <li>Ensure extrusion multiplier is set correctly.</li> </ul>
407
<p>I would like to do full-text searching of data in my Ruby on Rails application. What options exist?</p>
<p>There are several options available and each have different strengths and weaknesses. If you would like to add full-text searching, it would be prudent to investigate each a little bit and try them out to see how well it works for you in your environment.</p> <p>MySQL has built-in support for full-text searching. It has online support meaning that when new records are added to the database, they are automatically indexed and will be available in the search results. The <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html" rel="nofollow noreferrer">documentation</a> has more details.</p> <p><a href="http://code.google.com/p/acts-as-tsearch/" rel="nofollow noreferrer"><code>acts_as_tsearch</code></a> offers a wrapper for similar built-in functionality for recent versions of <a href="http://www.postgresql.org/docs/8.3/static/textsearch.html" rel="nofollow noreferrer">PostgreSQL</a></p> <p>For other databases you will have to use other software.</p> <p><a href="http://lucene.apache.org/" rel="nofollow noreferrer">Lucene</a> is a popular search provider written in Java. You can use Lucene through its search server <a href="http://lucene.apache.org/solr/" rel="nofollow noreferrer">Solr</a> with Rails using <a href="http://acts-as-solr.rubyforge.org/" rel="nofollow noreferrer"><code>acts_as_solr</code></a>.</p> <p>If you don't want to use Java, there is a port of Lucene to Ruby called <a href="http://ferret.davebalmain.com/trac/wiki" rel="nofollow noreferrer">Ferret</a>. Support for Rails is added using the <a href="http://projects.jkraemer.net/acts_as_ferret/wiki" rel="nofollow noreferrer"><code>acts_as_ferret</code></a> plugin.</p> <p><a href="http://xapian.org/" rel="nofollow noreferrer">Xapian</a> is another good option and is supported in Rails using the <a href="http://github.com/frabcus/acts_as_xapian/wikis" rel="nofollow noreferrer"><code>acts_as_xapian</code></a> plugin.</p> <p>Finally, my preferred choice is <a href="http://www.sphinxsearch.com/" rel="nofollow noreferrer">Sphinx</a> using the <a href="http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/files/README.html" rel="nofollow noreferrer">Ultrasphinx</a> plugin. It is extremely fast and has many options on how to index and search your databases, but is no longer being actively maintained.</p> <p>Another plugin for Sphinx is <a href="http://ts.freelancing-gods.com/" rel="nofollow noreferrer">Thinking Sphinx</a> which has a lot of positive <a href="http://www.williambharding.com/blog/rails/rails-thinking-sphinx-plugin-full-text-searching-thats-cooler-than-a-polar-bears-toenails/" rel="nofollow noreferrer">feedback</a>. It is a little easier to get started using Thinking Sphinx than Ultrasphinx. I would suggest investigating both plugins to determine which fits better with your project.</p>
<p>I've been compiling a <a href="https://stackoverflow.com/questions/73527/whats-the-best-option-for-searching-in-ruby-on-rails">list of the various Ruby on Rails search options in this other question</a>. I'm not sure how, or if to combine our questions.</p>
6,990
<p>So I'm getting really sick of E*TRADE and, being a developer, would love to find an online broker that offers an API. It would be great to be able to write my own trading tools, and maybe even modify existing ones.</p> <p>Based on my research so far, I've only found one option. Interactive Brokers offers a multi-language API (Java/C++/ActiveX/DDE) and has some fairly decent commission rates to boot. I want to make sure there aren't any other options out there I should be considering. Any ideas?</p> <p>Update: Based on answers so far, here's a quick list...</p> <ul> <li><a href="http://www.interactivebrokers.com/" rel="noreferrer">Interactive Brokers</a> <ul> <li>Java</li> <li>C++</li> <li>ActiveX</li> <li>DDE for Excel</li> </ul></li> <li><a href="http://www.pcmtrading.com" rel="noreferrer">Pinnacle Trading</a> <ul> <li>C++</li> <li>Perl</li> <li>VB.NET</li> <li>Excel</li> </ul></li> <li><a href="http://www.mbtrading.com/developersMain.aspx?page=sdk" rel="noreferrer">MB Trading</a></li> </ul>
<p>I vote for IB(Interactive Brokers). I've used them in the past as was quite happy. Pinnacle Capital Markets trading also has an API (pcmtrading.com) but I haven't used them.</p> <p><strong>Interactive Brokers:</strong></p> <p><a href="https://www.interactivebrokers.com/en/?f=%2Fen%2Fsoftware%2Fibapi.php" rel="noreferrer">https://www.interactivebrokers.com/en/?f=%2Fen%2Fsoftware%2Fibapi.php</a></p> <p><strong>Pinnacle Capital Markets:</strong></p> <p><a href="http://www.pcmtrading.com/es/technology/api.html" rel="noreferrer">http://www.pcmtrading.com/es/technology/api.html</a></p>
<p>Only related with currency trading (Forex), but many Forex brokers are offering MetaTrader which let you code in MQL. The main problem with it (aside that it's limited to Forex) is that you've to code in MQL which might not be your preferred language.</p>
8,390
<p>How do I store binary data in <a href="http://en.wikipedia.org/wiki/MySQL" rel="noreferrer">MySQL</a>?</p>
<p>The answer by phpguy is correct but I think there is a lot of confusion in the additional details there.</p> <p>The basic answer is in a <code>BLOB</code> data type / attribute domain. <strong>BLOB</strong> is short for Binary Large Object and that column data type is specific for handling binary data.</p> <p>See <a href="http://dev.mysql.com/doc/refman/5.7/en/blob.html" rel="noreferrer">the relevant manual page for MySQL</a>.</p>
<p>The question also arises how to get the data into the BLOB. You can put the data in an INSERT statement, as the PHP example shows (although you should use <a href="http://www.php.net/mysql-real-escape-string" rel="noreferrer">mysql_real_escape_string</a> instead of addslashes). If the file exists on the database server, you can also use MySQL's <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_load-file" rel="noreferrer" title="LOAD FILE">LOAD_FILE</a></p>
2,237
<p>Can I use <a href="http://struts.apache.org/" rel="nofollow noreferrer">Struts</a> as a backend and PHP as front end for a web application? If yes, what may be the implications.</p>
<p>The first thing to came to mind is <a href="http://www.caucho.com/resin-3.0/quercus/" rel="nofollow noreferrer">Quercus</a> (from the makers of the Resin servlet engine), as Jordi mentioned. It is a Java implementation of the PHP runtime and purportedly allows you to access Java objects directly from your PHP (part of me says "yay, at last").</p> <p>On the other hand, while I have been itching to try a project this way, I would probably keep the separation between Java EE and PHP unless there was a real reason to integrate on the code-level.</p> <p>Instead, why don't you try an <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture" rel="nofollow noreferrer">SOA</a> approach, where your PHP "front-end" calls into the Struts application over a defined REST or SOAP API (strong vote for REST here) over HTTP. </p> <pre><code>http://mydomain.com/rest/this-is-a-method-call?parameter1=foo </code></pre> <p>You can use Struts to build your entire "backend" model, dealing only with business logic and data, and completely ignoring presentation. As you expose the API with these URLs, and you are basically building a REST API (which may come in handy later if you ever need to provide greater access to your backend, perhaps by other client apps).</p> <p>Your PHP application can be built separately (and rather thinly), calling into the REST API (perhaps using Curl) as if it would call into a database or some native PHP class library.</p> <p>Anyway, that's what I'd do. But, if you do use Quercus, please post how it went.</p>
<p>What do you mean by backend and and frontend?</p> <p>If you mean using Java for the admin side of your site and PHP for the part that the public will see then there is nothing stopping you.</p> <p>The implications are that you will have to maintain two applications in different languages.</p>
5,995
<p>It's criminal how wasteful the Stratsys uPrint SE Plus is with it's 'one use' modelling bases. Is there a reliable way to re purpose them? I have tried ethanol and acetone, but not had any luck. </p>
<p>People have done quite a bit of experimenting with reusing Mojo build plates over the years. The uPrint is likely similar. Basically a different adhesion layer is placed on the bed that has easier release. BuildTak has been used successfully. Gluestick or hairspray such as Aquanet will work and are water soluble for easier removal post-print. </p>
<p>By oversight in training, the operators of one of our UPrint SE Plus printers was simply placing the tray in the bath with the printed part. After it was in the bath, all support material was removed and they dried and reused the tray. This process was used for months before it was discovered, and they used the same tray for many prints. Has anyone else tried this? </p>
337
<p>How can i add a line break to the text area in a html page? i use VB.net for server side coding.</p>
<p>If it's not vb you can use <code>&amp;#013;&amp;#010;</code> (ascii codes for cr,lf)</p>
<p>I believe this will work:</p> <pre><code>TextArea.Text = "Line 1" &amp; vbCrLf &amp; "Line 2" </code></pre> <p>System.Environment.NewLine could be used in place of vbCrLf if you wanted to be a little less VB6 about it.</p>
9,232
<p>I'm having a lot of trouble printing polypropylene right now, and I think it may have to do with the conditions. I'm using a very thin coat of ABS on the base plate (just as you would do when printing with ABS) in order to promote sticking.</p> <p>In this following first picture, I attempted with a 240°C tip and a 150°C bed (above PP's Tg). Oddly enough, one side actually looked somewhat decent while the other clearly had trouble sticking. The print speed on this was 1500 mm/min.</p> <p>In the second picture, I was printing with the tip at 220°C and a 50°C bed. What's interesting in that print (you may be able to see it) is that the polymer extruded with little blips of material followed by a more stringy section, rather than a steady, even filament. (Print speed on this was 2100 mm/min)</p> <p><a href="https://i.stack.imgur.com/KCbye.jpg" rel="nofollow noreferrer" title="240°C tip and a 150°C bed"><img src="https://i.stack.imgur.com/KCbye.jpg" alt="240°C tip and a 150°C bed" title="240°C tip and a 150°C bed"></a></p> <p><a href="https://i.stack.imgur.com/IaF8Z.jpg" rel="nofollow noreferrer" title="220°C tip and a 50°C bed"><img src="https://i.stack.imgur.com/IaF8Z.jpg" alt="220°C tip and a 50°C bed" title="220°C tip and a 50°C bed"></a></p> <p>Does anyone have suggestions for doing better prints with PP? </p>
<p>Polypropylene CAN be printed with excellent results, you just need a good filament roll and good printing setup. A few days ago I read this topic and was kind of afraid of testing it, now I am so happy I tried it.</p> <p>I am printing the PP filament from the brand Smart Materials 3D (search on google).</p> <p>I am using a Prusa i3 Mk2, bed heated to 70ºC and hotend to 210ºC. I ventilate the printer as much as possible: room windows open and fan at 100% after second layer. </p> <p>IMPORTANT: apply some cheap brown packaging adhesive strips to the bed, where the part is going to touch the bed, with adhesive facing down. I tried many other solutions but none worked.</p> <p><a href="https://i.stack.imgur.com/8SBUz.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/8SBUz.gif" alt="enter image description here"></a></p> <p>I have printed so far at 20mm/s constant, with 0.2 mm layer heigth, 0.4 mm extrusion width, 0.8mm retraction, flow 125%. Still optimizing setings. Parts come out very nice, with good flexibility and amazing inter layer bonding. Density is a bit lower than ABS, so excellent, and impact resistance is awesome. Check some parts I printed today:</p> <p><a href="https://i.stack.imgur.com/m3bXX.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/m3bXX.jpg" alt="enter image description here"></a></p>
<p>First picture clearly shows that temperature was too hight, second one suggests too small extruding speed (too little) which is connected to your printing speed.</p> <p>35mm/s is quite slow :)</p>
245
<p>How do you customize the Copy/Paste behavior in Visual Studio 2008?</p> <p>For example I create a new <code>&lt;div id="MyDiv"&gt;&lt;/div&gt;</code> and then copy and paste it in the same file.</p> <p>VisualStudio pastes <code>&lt;div id="Div1"&gt;&lt;/div&gt;</code> instead of the original text I copied.</p> <p>It is even more frustrating when I'm trying to copy a group of related div's that I would like to copy/paste several times and only change one part of the id.</p> <p>Is there a setting I can tweak to change the copy/paste behavior?</p>
<p>Go into Tools > Options > Text Editor > HTML > Miscellaneous and uncheck "Auto ID elements on paste in Source view"</p>
<p>In Visual Studio 2019 the new location is<br /> <code>Tools &gt; Text Editor &gt; ASP.NET Web Forms</code><br /> and Check <code>Format HTML on paste</code>.<br /> So now it is possible to efficiently duplicate sequential ID codes.</p>
9,280
<p>Recycling a Robin Nano board to build a 3D printer using an old computer PSU (300 W), it only boots on when I have no endstops pugged in at all or if I trigger all the ones I have plugged. At the moment I release them the screen goes off (but the fan of the PSU is still on). Does anyone have any clue about what's going on ?</p>
<p>It ended up I had like super cheap endstops that were actually shorting VCC to GND, as suspected by r_ahlskog. Just bought other ones and now it's working fine.</p>
<p>It ended up I had like super cheap endstops that were actually shorting VCC to GND, as suspected by r_ahlskog. Just bought other ones and now it's working fine.</p>
1,492
<p>I have heard using PDB files can help diagnose where a crash occurred.<br> My <em>basic</em> understanding is that you give Visual studio the source file, the pdb file and the crash information (from Dr Watson?)<br> Can someone please explain how it all works / what is involved? (Thank you!)</p>
<p>PDB files are generated when you build your project. They contain information relating to the built binaries which Visual Studio can interpret.</p> <p>When a program crashes and it generates a crash report, Visual Studio is able to take that report and link it back to the source code via the PDB file for the application. PDB files must be built from the same binary that generated the crash report!</p> <p>There are some issues that we have encountered over time.</p> <ul> <li>The machine that is debugging the crash report needs to have the source on the same path as the machine that built the binary.</li> <li>Release builds often optimize to the extent where you cannot view the state of object member variables</li> </ul> <p>If anyone knows how to defeat the former, I would be grateful for some input.</p>
<p>You should look into setting up a symbol server and indexing the PDB files to your source code control system. I just recently went through this process for our product and it works very well. You don't have to be concerned about making PDB files available with the binaries, nor how to get the appropriate source code when debugging dump files.</p> <p>John Robbins' book: <a href="https://rads.stackoverflow.com/amzn/click/com/0735622027" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Debugging-Microsoft-NET-2-0-Applications/dp/0735622027/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1222366012&amp;sr=8-1</a></p> <p>Look here for some sample code for generating minidumps (which don't have to be restricted to post-crash analysis -- you can generate them at any point in your code without crashing): <a href="http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx</a></p>
9,768
<p>Is there a way to make all your prints seamless?? I know there was this program that printed a vase constantly changing the z axis making it seamless. Why cant this be done with regular prints?</p>
<p>If you ever seen 3d printouts on your own and you did keep it in hand then you probably felt layers. Most printouts contains 3 main "components"</p> <ol> <li>bottom and top component (floor and ceiling)</li> <li>outline (perimeters)</li> <li>infill (inside supporting structure)</li> </ol> <p>It is almost imposible (and for sure sensless) to create all these components with one continues line as it would be very complex and sophisticated line.</p> <p>Second reason. It would be very often that printer would cross outlines (perimeters) so it would destroy good looking external surface.</p> <p>And third reason. Objects can have "islands". Imagine printed elephant which is standing on 4 legs. How to draw leg leyers with one line if these legs are separated (at the floor level).</p> <p>That's why "round vase" is the only option to print seamless. :)</p>
<p>Look into post processing your model with an <a href="http://makezine.com/2014/09/24/smoothing-out-your-3d-prints-with-acetone-vapor/" rel="nofollow">Acetone vapor Bath.</a>. ABS plastic disolves in acetone. if you put your print in a chamber full of acetone vapor, the outer skin will sort of melt, and give you the effect you are looking for. The goal is to leave it in long enough that the outer skin melts a bit. Too short a time, and you don't get enough melting. Too long a time and more than the skin melts, and the print may deform.</p>
250
<p>I began build LCD printer and I want make some modifications.</p> <p>What if I will place LCD below VAT<a href="https://i.stack.imgur.com/Tznt5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tznt5.jpg" alt="enter image description here"></a>? Will the display break when printing? what are the risks? I seen a lot of printers and all of them use PP material for VAT bottom and attach with a lot of screws. I want make more simple VAT-LCD constructions and I think this construction transmis UV light better</p>
<p>Your calculations about the theoretical extruder resolution are spot on. I did a similar calculation to evaluate which extruder to use with different hot ends, I paste the results. The dark cells are the input cells, the rest is calculated. You can see that for some lines I entered directly the mm/microstep value, since I wanted not a theoretical but practical result for my printer (3 mm filament) or for known extruders (BMG).</p> <p><a href="https://i.stack.imgur.com/3mQeA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3mQeA.png" alt="enter image description here" /></a></p> <p>Concerning the question, the resolution of the extruder matters, but it's a bit complicated to estimate exactly how much.</p> <p>In general, this are the factors I can think about.</p> <p>A poor resolution may not impact straight lines much, since the rotation of the extruder is continuous and the extruder is unlikely to snap exactly to the desired microstep position as soon as you ask for it: it's likely a bit behind all the time, that's how torque is obtained (more or less).</p> <p>The issue may become smaller with drivers which interpolate microsteps up to 256x.</p> <p>However, whenever there is a change of flow rate, poor resolution implies that you cannot control the exact location/moment where/when the flow changes. This matters mostly at the end and at the beginning or retractions/re-retractions. Maybe you get more ooze?</p> <p>However, the extruder resolution is not, in practice, as good as you calculated. In fact, as we know, microsteps reduce the incremental torque to very low values. The extruder is a motor which requires quite a lot of torque, since pushing the filament is quite hard, and it is unlikely that you can achieve all the time the 16x microstep accuracy you assumed. For example, due to friction in Bowden, hot end, ... the filament (= the motor shaft) may at a certain point stay &quot;back&quot; more than average. This would cause an increase of effective torque, pushing the filament a bit faster, which would it bring to in sync or so with the desired position, but at that point it would slow down, and so on. Depending on the average speed, this oscillation may be dampened (and then no rippling is visible) or may oscillate constantly, and you see ripples also along straight lines.</p> <p>This is why I placed the usteps column in my calculations: it is meant to calculate a more realistic resolution assuming that no accurate microstepping is achieved. I assumed higher achievable microsteps the lower the load on the motor is (this means gears, or thinner filament).</p> <p>Having a high resolution to begin with clearly helps to reduce this issue. You can try to increase the current to the max your drivers and motor and cooling allow, and see if the ripples change. I think it will be reduced.</p> <p>You may also try to build the <a href="https://www.thingiverse.com/thing:4223085" rel="noreferrer">Orbiter extruder</a> (linked also in the table) and see how it goes.</p>
<h2>Short answer</h2> <p><em>Usually</em> no.</p> <h2>Long answer</h2> <p>There are several big factors that limit how small things you can print. The bigger ones are pretty much:</p> <ul> <li>Positional accuracy and settings (limited by steps/mm in X, Y, Z)</li> <li>Nozzle diameter</li> </ul> <p>Now, why don't you need to care about steps/mm on the extruder that muchin the grand scale compared to the positional accuracy? Well, we have 1.8° per step, from which, with the diameter of the gear, 11mm, we get 0,1778 mm of filament extrusion or 0.428 mm³ of extruded plastic per full 1.8° step - which clearly is unsuitable to printing at all. But with the 16 micro-steps the shorter movements are possible and a single micro-step extrusion is in the area you calculated - I got to 0,0267 mm³, possibly the result of different rounding between us. With an assumed effective gear diameter of 11mm (usually the effective gear diameter is a little smaller, thus the 93 steps) we come to about 89.9 steps per mm of filament, which corresponds to about 2.4 mm³ of extruded plastic, or about 30 mm of line (with your given parameters), bringing us to about 3 microsteps per millimeter of line on the tray. So far, your math checks out. But that usually shouldn't be too much a limiting factor. We know from your given settings, that the <em>Configuration.h</em> will look like this, putting the microsteps into the steps/mm:</p> <pre><code>/** * Default Axis Steps Per Unit (steps/mm) * Override with M92 * X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]] */ #define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 93 } </code></pre> <p>As you don't have a micro-stepping driver, this part in <em>Configuration_adv.h</em> is non-functional:</p> <pre><code>// Microstep setting (Only functional when stepper driver microstep pins are connected to MCU. #define MICROSTEP_MODES {16,16,16,16,16} // [1,2,4,8,16] </code></pre> <p>With the proposed 0.4 mm/0.2 mm line, we are still somewhat on the good side, allowing us about 1/3rd of a millimeter as the shortest line printable as a single step extrusion. That's a consistent with printing a simple, circular dot being printable with these settings - 0.4 &gt; 1/3.</p> <p>But once you get to smaller nozzle diameters, the limitation gets more noticeable: at a 0.2 mm nozzle and 0.22 mm line at 0.1 mm height, that's a 0.022 mm² crosssection, so the 1-step extrusion is equivalent to a full millimeter of line! That's much more bothersome in theory.</p> <p>However, I haven't been able to witness the inability of showing that limit of lacking extrusion yet on my TronXY-X1 with a 0.2 mm nozzle - the steps/mm in it are also about 90-100 last I set them. The TronXY uses a very similar (virtually identical) extruder setup as the Ender 3, and it achieved printed lines of about 0.3 mm length at 0.1 mm layer height somewhat reliable, but the retraction made huge issues, which might also mask the problem.</p> <p>I believe that it needs these smaller nozzles to amplify the problems to make them noticeable. It also should become more noticeable if you'd use 2.85 mm or 3 mm filament.</p> <h2>Ways to improve resolution</h2> <p>However, if printing with smaller nozzles, it might be a good idea to think about how one could improve the accuracy of the extruder system.</p> <p>The most-easy way would be to alter the extruder and swap the gear to one of a <em>smaller</em> effective diameter - That way a single step accounts to <em>less</em> extrusion, which means, in turn, a higher number of steps/mm, and thus allowing for shorter extrusions that can be still achieved.</p> <p>Next one might think about getting a different motor/driver setup that might have either more microsteps or generally a smaller step size.</p> <p>Quadrupling the effective (micros)steps/mm would allow us to print about a 0.25 mm line on the 0.22 mm nozzle I proposed, being pretty much a spot - if it wouldn't be partially masked in other issues as I experience.</p>
1,603
<p>How do I select one or more random rows from a table using SQLAlchemy? </p>
<p>This is very much a database-specific issue.</p> <p>I know that PostgreSQL, SQLite, MySQL, and Oracle have the ability to order by a random function, so you can use this in SQLAlchemy:</p> <pre><code>from sqlalchemy.sql.expression import func, select select.order_by(func.random()) # for PostgreSQL, SQLite select.order_by(func.rand()) # for MySQL select.order_by('dbms_random.value') # For Oracle </code></pre> <p>Next, you need to limit the query by the number of records you need (for example using <code>.limit()</code>).</p> <p>Bear in mind that at least in PostgreSQL, selecting random record has severe perfomance issues; <a href="http://www.depesz.com/index.php/2007/09/16/my-thoughts-on-getting-random-row/" rel="noreferrer">here</a> is good article about it.</p>
<p>Theres a couple of ways through SQL, depending on which data base is being used.</p> <p>(I think SQLAlchemy can use all these anyways)</p> <p>mysql:</p> <pre><code>SELECT colum FROM table ORDER BY RAND() LIMIT 1 </code></pre> <p>PostgreSQL:</p> <pre><code>SELECT column FROM table ORDER BY RANDOM() LIMIT 1 </code></pre> <p>MSSQL:</p> <pre><code>SELECT TOP 1 column FROM table ORDER BY NEWID() </code></pre> <p>IBM DB2:</p> <pre><code>SELECT column, RAND() as IDX FROM table ORDER BY IDX FETCH FIRST 1 ROWS ONLY </code></pre> <p>Oracle:</p> <pre><code>SELECT column FROM (SELECT column FROM table ORDER BY dbms_random.value) WHERE rownum = 1 </code></pre> <p>However I don't know of any standard way</p>
8,583
<p>Using regular expressions, what is the simplest way to fetch a websites HTML and find the value inside this tag (or any attribute's value for that matter):</p> <pre><code>&lt;html&gt; &lt;head&gt; [snip] &lt;meta name="generator" value="thevalue i'm looking for" /&gt; [snip] </code></pre>
<p>Depends on how sophisticated of an Http request you need to build (authentication, etc). Here's one simple way I've seen used in the past. </p> <pre><code>StringBuilder html = new StringBuilder(); java.net.URL url = new URL("http://www.google.com/"); BufferedReader input = null; try { input new BufferedReader( new InputStreamReader(url.openStream())); String htmlLine; while ((htmlLine=input.readLine())!=null) { html.appendLine(htmlLine); } } finally { input.close(); } Pattern exp = Pattern.compile( "&lt;meta name=\"generator\" value=\"([^\"]*)\" /&gt;"); Matcher matcher = exp.matcher(html.toString()); if(matcher.find()) { System.out.println("Generator: "+matcher.group(1)); } </code></pre> <p><em>Probably plenty of typos here to be found when compiled. (hope this wasn't homework)</em></p>
<p>You may want to check the documentation for Apache's org.apache.commons.HttpClient package and the related packages <a href="http://hc.apache.org/httpclient-3.x/apidocs/index.html" rel="nofollow noreferrer">here</a>. Sending an HTTP request from a Java application is pretty easy to do. Poking through the documentation should get you off in the right direction.</p>
5,136
<p>I assume SLA printing only works on Earth and upright.</p> <p>But would fused-filament printer (e.g. Prusa Mk3) work in zero gravity? What about upside down or sideways? If not, could it be modified to work in other orientations? Have there been any demonstrations of it?</p>
<p>I think it's safe to say that there's at least one model of 3D printer that works in microgravity -- since <a href="https://www.nasa.gov/mission_pages/station/research/news/3d-printing-in-space-long-duration-spaceflight-applications" rel="nofollow noreferrer">one was sent to the International Space Station a few months ago</a>. I presume the one there is an FDM type, as those need not be dependent on gravity; my Ender 3, for instance, has positive drive both ways on all three axes, so as long as the filament source is kept captive, the printer ought to work the same as it would on Earth.</p> <p>Beyond that, there is the Quinly setup, in which a common FDM printer like the Ender 3 is set up at about a 45 degree angle, using a polymer coated glass bed, to allow network printing part after part (the printer pushes the parts off the cooled bed with the X gantry and hot end housing before preheating for the next print). Similar methods are used to print at a significant angle on a flat build surface for conveyor bed printers that can both print very long parts, and print sequences of parts one after the other (the belt carries the parts to the turn-around, then the flex pops them off).</p> <p>The operation of common FDM printers depends on mechanical grip of the filament, screw or toothed belt drive of the axes, and adhesion of the first layer to the build surface and of subsequent layers to those already laid down --- this ought to work even upside down, against gravity, at least until the weight of the part starts to compete with its adhesion strength.</p>
<p>Lulzbot used to do this at trade shows -- printers on their side, printing all day long.</p> <p>So long as it sticks to the bed, and sticks to the subsequent layers of the part, it works.</p> <p>The determining factor is gravity -- if the part being printed has overhangs or unsupported areas, the extruded material would fall back at the extruder, instead of down onto the part. You may get around this with dual extrusion supports, but if there's any layer separation, it would probably fail quickly, lol.</p> <p>Zero gravity? Easier than upside down with gravity, I'd think!</p>
1,812
<p>As you develop an application database changes inevitably pop up. The trick I find is keeping your database build in step with your code. In the past I have added a build step that executed SQL scripts against the target database but that is dangerous in so much as you could inadvertanly add bogus data or worse. </p> <p>My question is what are the tips and tricks to keep the database in step with the code? What about when you roll back the code? Branching?</p>
<p>Version numbers embedded in the database are helpful. You have two choices, embedding values into a table (allows versioning multiple items) that can be queried, or having an explictly named object (such as a table or somesuch) you can test for.</p> <p>When you release to production, do you have a rollback plan in the event of unexpected catastrophe? If you do, is it the application of a schema rollback script? Use your rollback script to rollback the database to a previous code version.</p>
<p>I like the way that Django does it. You build models and the when you run a syncdb it applies the models that you have created. If you add a model you just need to run syncdb again. This would be easy to have your build script do every time you made a push. </p> <p>The problem comes when you need to alter a table that is already made. I do not think that syncdb handles that. That would require you to go in and manually add the table and also add a property to the model. You would probably want to version that alter statement. The models would always be under version control though, so if you needed to you could get a db schema up and running on a new box without running the sql scripts. Another problem with this is keeping track of static data that you always want in the db.</p> <p>Rails migration scripts are pretty nice too. </p> <p>A DB versioning system would be great, but I don't really know of such a thing. </p>
5,372
<p>Assuming you can't use LINQ for whatever reason, is it a better practice to place your queries in stored procedures, or is it just as good a practice to execute <em>ad hoc</em> queries against the database (say, SQL Server for argument's sake)?</p>
<p>In my experience writing mostly WinForms Client/Server apps these are the simple conclusions I've come to:</p> <p><strong>Use Stored Procedures:</strong></p> <ol> <li>For any complex data work. If you're going to be doing something truly requiring a cursor or temp tables it's usually fastest to do it within SQL Server.</li> <li>When you need to lock down access to the data. If you don't give table access to users (or role or whatever) you can be sure that the only way to interact with the data is through the SP's you create.</li> </ol> <p><strong>Use ad-hoc queries:</strong></p> <ol> <li>For CRUD when you don't need to restrict data access (or are doing so in another manner).</li> <li>For simple searches. Creating SP's for a bunch of search criteria is a pain and difficult to maintain. If you can generate a reasonably fast search query use that.</li> </ol> <p>In most of my applications I've used both SP's and ad-hoc sql, though I find I'm using SP's less and less as they end up being code just like C#, only harder to version control, test, and maintain. I would recommend using ad-hoc sql unless you can find a specific reason not to.</p>
<blockquote> <p>is it good system architecture if you let connect 1000 desktops directly to database?</p> </blockquote> <p>No it's obviously not, it's maybe a poor example but I think the point I was trying to make is clear, your DBA looks after your database infrastructure this is were their expertise is, stuffing SQL in code locks the door to them and their expertise.</p>
4,293
<p>I have a vs.net project, and after some refactoring, have modified the name of the project. How can I easily rename the underlying windows folder name to match this new project name under a TFS controlled project and solution?<br> Note, I used to be able to do by fiddling with things in the background using SourceSafe ... </p>
<ol> <li><strong>Check in</strong> all pending changes within the folder and ensure that all other team members to do the same.</li> <li>Ensure that you have a copy of the folder in your working directory (otherwise, you will not have the option to rename the folder in the <em>Source Control Explorer</em> in the next step). <strong>Get latest version</strong> on the folder to get a copy if you don't already have one.</li> <li><strong>Close the solution</strong>.</li> <li><strong>Rename</strong> the folder within the <em>Source Control Explorer</em>. This will move all of the files that are tracked in source control from the original folder on your file system to the new one. Note that files not tracked by source control will remain in the original folder - you will probably want to remove this folder once you have confirmed that there are no files there that you need.</li> <li><strong>Open the solution</strong> and select '<strong><code>No</code></strong>' when prompted to get projects that were newly added to the solution from source control. You will get a warning that one of the projects in the solution could not be loaded.</li> <li><strong>Select the project</strong> within <em>Solution Explorer</em>. <blockquote> <p>Note that it will be grayed out and marked as <em>'Unavailable'</em>.</p> </blockquote></li> <li>Open the <strong>Properties</strong> pane.</li> <li><strong>Edit the <em>'File Path'</em></strong> property either directly or using the '<code>...</code>' button. <blockquote> <p>Note also that this property is <a href="http://blogs.msmvps.com/deborahk/solution-files-change-project-directory-location/" rel="noreferrer">only editable in Visual Studio 2010</a>. In newer versions of Visual Studio, you will need to manually edit the project paths within the solution file.</p> </blockquote></li> <li>Right-click on the project in the <em>Solution Explore</em>r and select <strong>Reload Project</strong> from the context menu. If you get an error message saying that the project cannot be loaded from the original folder, try closing the solution, deleting the suo file in the same folder as the solution file then reopening the solution.</li> <li><strong>Check in</strong> the changes as a single changeset.</li> <li>Have other team members 'Get latest version' for the solution (right click on the solution within <em>Solution Explorer</em> and select 'Get Latest Version' from the context menu.</li> </ol> <hr> <blockquote> <p>Note: Other suggested solutions that involve removing and then re-adding the project to the solution will break project references.</p> </blockquote> <p>If you perform these steps then you might also consider renaming the following to suit.</p> <ol> <li>Project File</li> <li>Default/Root Namespace</li> <li>Assembly</li> </ol> <p>Also, consider modifying the values of the following <a href="http://msdn.microsoft.com/en-us/library/4w8c1y2s.aspx" rel="noreferrer">assembly attributes</a>.</p> <ol> <li><code>AssemblyProductAttribute</code></li> <li><code>AssemblyDescriptionAttribute</code></li> <li><code>AssemblyTitleAttribute</code></li> </ol>
<p>You could just rename the project (.Xproj file and project folder) in TFS, delete the local folder structure and all of its contents, then do a get latest for the project. All of this depends the notion of your source repository is completely up to date and compilable.</p>
7,147
<p>I just got a GeeeTech Rostock 301 mixer head delta printer and am having trouble honing in on why the extruder is struggling with my first spool of ABS.</p> <p>Being the main parts of the printer came assembled I am unsure of where to start taking things apart. I have a read a multitude of possible causes and am hoping for some direction on which is most likely so I can start there.</p> <h2>Symptoms:</h2> <p>Extruder clicking. The extruder makes a low grinding noise every time it tries to extrude more than 1mm of filament using the manual controls. Again I am working with ABS so I have the hotend heated to 250 degrees C. The extruder had no trouble when I was first putting the filament in and using the extruder to push it thorough the Bowden tube.</p> <p>But when I tried using the manual controls to extrude a small amount of filament it seems to be fine, just a small time delay between the extruder moving and the plastic coming out of the hotend. </p> <h2>Things I have read to try</h2> <p>Again this a kit printer and the involved components came assembled (see below) so I am not sure what I should look at first. I assume that if it came pre-assembled then it is most likely done correctly.</p> <ol> <li>Clean out the hotend, do a cold pull</li> <li>Take apart the extruder and realign the driving cog, check for shaft slippage</li> <li>Replace your Bowden Tubes</li> <li>Tweak slicer settings</li> </ol> <p>For the first 3 I think its new so it should be clean, in working order. And for number 4 I put what was in the manual except for the temperatures (because the settings shown in the manual were for PLA but it is a PLA or ABS printer)</p> <h2>Assembly:</h2> <p>The printer being a kit came with the print head completely assembled as shown in the picture. <a href="https://i.stack.imgur.com/NCO1Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NCO1Y.png" alt="Printer Head-hotend"></a></p> <p>Not shown in the picture it also had the Bowden tubes in place. It also came with the extruder assembled as shown in the picture. <a href="https://i.stack.imgur.com/VJV5E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VJV5E.png" alt="The extruder"></a></p> <p>So aside from wiring and mounting these pieces the only thing I did was cut a clean edge on the Bowden tube and connect that to the extruder.</p>
<p>First you have to see if nothing jams the filament (blocked nozzle or anything in its path, PTFE tube not good, etc).</p> <p>Second, the temp for ABS is about 225°C to 230°C. At least that worked for me.</p> <p>If none of the above, then go for the motor. The problem could be from bad settings, low power or a motor malfunction. Maybe the motor is no good to begin with. </p> <p>Good luck !!! </p>
<p>This is worth pointing out as it hasn't been said yet, make sure your stepper driver isn't overheating. If it overheats, it will cause the stepper to temporarily shut down, and it will click when it happens. This could be caused by inadequate power or by insufficient cooling. </p>
488
<p>So I bought this printer three days ago as a way to dip my toes into the 3D printing world, and it was working great at first. But at some point, the ABL procedure started behaving oddly: Instead of moving down to touch each corner of the printing bed, it's now only doing so for one corner, then moving to the next, but instead of going down, it goes up. It then continues to the third corner, stops, and moves up again. After that, it returns back to home position. The result is that the extruder hovers way above where it's supposed to be --or alternatively bumps into the printing bed when it's near the origin corner-- thinking it's adjusting for some nonexistent slant, dripping filament all over the place.</p> <p>The gantry itself is totally level, and I can't see any mechanical faults. As far as I can tell, there's no way to manually level the bed, the only option is to use ABL.</p> <p>I found out that the Monoprice Cadet printer is the exact same one as the Tina2, so if anyone has experience with that printer in particular, it'll apply here too.</p>
<p>This is a community wiki answer from <a href="https://www.reddit.com/r/3Dprinting/comments/lz4c9l/comment/gr9v9pb/?utm_source=reddit&amp;utm_medium=web2x&amp;context=3" rel="nofollow noreferrer">an answer</a> on <a href="https://www.reddit.com/r/3Dprinting/comments/lz4c9l/monoprice_cadet_autoleveling_question/" rel="nofollow noreferrer">Reddit - Monoprice Cadet auto-leveling question</a>, for those who stumble upon this question:</p> <blockquote> <p>Then I tried their text chat support and the response was basically:</p> <p>&quot;It is a bad level sensor, which we've never heard of happening to a 3 month old printer and is very rare in general. You are under warranty so here's a preprinted return shipping label, and we'll send you a new printer once we receive your busted one.&quot;</p> </blockquote> <hr /> <p><em>From the many &quot;me too&quot; answers, this appears to be a genuine issue rather than a &quot;one-off&quot; issue...</em></p>
<p>According to the <a href="http://www.weedo.ltd/product-detail/tina2/" rel="nofollow noreferrer">manufacturer's page for the Weedo Tina 2</a>, the bed sensor for the ABL is magnetic -- which means that if you've removed the magnetic build surface you likely have removed the printer's ability to sense the bed height. You most likely need to replace the worn out magnetic build surface for the (mandatory) ABL to work.</p> <p>Weedo ought to sell replacements for a part that wears out, but if not, you can buy one made for the Ender 3 (and cut it down to fit) on Amazon (very reasonably priced, too) and have it in your hands in a couple days, though I have no way to know the original didn't have specific poles in particular locations on the sheet. You'll likely need to remove the base sheet from the Tina 2, if there is one, so as to follow the instructions on the Creality and ensure the upper, removable, flexible sheet actually sticks to the adhesive-backed lower sheet.</p>
1,953
<p>I use the VS2008 command prompt for builds, TFS access etc. and the cygwin prompt for grep, vi and unix-like tools. Is there any way I can 'import' the vcvars32.bat functionality into the cygwin environment so I can call "tfs checkout" from cygwin itself?</p>
<p>According to <a href="http://www.cs.ucl.ac.uk/research/vr/Dive/Local/compile.html" rel="noreferrer">this page</a> you need to:</p> <p>"Depending on your preference, you can either add the variables required for compilation direct to your environment, or use the vcvars32.bat script to set them for you. Note you have to compile from a cygwin bash shell, to use vcvars32, first run a DOS shell, then run vcvars32.bat, then run cygwin.bat from the directory where you installed cygwin. You can speed this up by adding the directory containgin vcvars32 (somewhere under \Microsoft Visual Studio\VC98\bin) and the directory containing cygwin.bat to your path."</p>
<p>witkamp's answer works for vs2005 -- for vs2008, use </p> <p>CALL "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"</p>
8,736
<p>I want to copy the entire contents of a directory from one location to another in C#.</p> <p>There doesn't appear to be a way to do this using <code>System.IO</code> classes without lots of recursion.</p> <p>There is a method in VB that we can use if we add a reference to <code>Microsoft.VisualBasic</code>:</p> <pre><code>new Microsoft.VisualBasic.Devices.Computer(). FileSystem.CopyDirectory( sourceFolder, outputFolder ); </code></pre> <p>This seems like a rather ugly hack. Is there a better way?</p>
<p>Much easier</p> <pre><code>private static void CopyFilesRecursively(string sourcePath, string targetPath) { //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(sourcePath, &quot;*&quot;, SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(sourcePath, targetPath)); } //Copy all the files &amp; Replaces any files with the same name foreach (string newPath in Directory.GetFiles(sourcePath, &quot;*.*&quot;,SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(sourcePath, targetPath), true); } } </code></pre>
<p>Better than any code (extension method to DirectoryInfo with recursion)</p> <pre><code>public static bool CopyTo(this DirectoryInfo source, string destination) { try { foreach (string dirPath in Directory.GetDirectories(source.FullName)) { var newDirPath = dirPath.Replace(source.FullName, destination); Directory.CreateDirectory(newDirPath); new DirectoryInfo(dirPath).CopyTo(newDirPath); } //Copy all the files &amp; Replaces any files with the same name foreach (string filePath in Directory.GetFiles(source.FullName)) { File.Copy(filePath, filePath.Replace(source.FullName,destination), true); } return true; } catch (IOException exp) { return false; } } </code></pre>
8,318
<p>Using VS2005 and VB.NET.</p> <p>I have a project that is an API for a data-store that I created. When compiled creates <code>api.dll</code>.</p> <p>I have a second project in the same solution that has a project reference to the API project which when compiled will create <code>wrapper.dll</code>. This is basically a wrapper for the API that is specific to an application. When I use <code>wrapper.dll</code> in that other application, I have to copy <code>wrapper.dll</code> and <code>api.dll</code> to my new application. How can I get the wrapper project to compile the <code>api.dll</code> into itself so that I only have one <code>dll</code> to move around?</p>
<p>@Jas, it's a special feature in Visual Studio. The procedure is outlined in <a href="http://blogs.msdn.com/shawnfa/archive/2006/04/24/582278.aspx" rel="nofollow noreferrer">this blog entry, called "Sharing a Strong Name Key File Across Projects"</a>. The example is for sharing strong name key files, but will work for any kind of file.</p> <p>Briefly, you right-click on your project and select "Add Existing Item". Browse to the directory of the file(s) you want to link and highlight the file or files. Insted of just hitting "Add" or "Open" (depending on your version of Visual Studio), click on the little down arrow on the right-hand side of that button. You'll see options to "Open" or "Link File" if you're using Visual Studio 2003, or "Add" or "Add as Link" with 2005 (I'm not sure about 2008). In any case, choose the one that involves the word "Link". Then your project will essentially reference the file - it will be accessible both from the original project its was in and the project you "linked" it to. </p> <p>This is a convenient way to create an assembly that contains all the functionality of wrapper.dll and api.dll, but you'll have to remember to repeat this procedure every time you add a new file to api.dll (but not wrapper.dll).</p>
<p>I think you could compile api.dll as a resource into wrapper.dll. Then manually access that Resource out of api.dll and manually load it. I have manually loaded assemblies from disk, so loading one from a Stream should not be any different.</p> <p>I would try including the dll in your project as a file, similar to including a text or xml file (in addition to its project reference for compilation). Then I would set the build action to "Embedded Resource." Within wrapper.dll, I would use the Assembly object to access api.dll just like any other embedded resource. You will then also want to load the assembly using Assembly.Load <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.load.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.reflection.assembly.load.aspx</a></p>
5,068
<p>I am still very much a novice and learning so here is the situation:</p> <ol> <li>Filament was not extruding from nozzle. Checked the filament feeder (worked fine, filament was being squeezed through) and tried to push filament through hot nozzle to see if anything came out. Nothing did.</li> <li>Did a cold pull, got a little bit of gunk out. Second cold pull didn't work out like the first one, and the glob of PLA that I fed into the nozzle remained stuck there.</li> <li>I heated and removed the nozzle properly. I am going to soak it in acetone to get rid of the gunk inside. However, when I tried to install my other nozzle, it would take in the threads, and I see now that a little bit of the plastic from the last cold pull melted and trickled down.</li> </ol> <p>What can I do to clean this out and install the nozzle? It is on an Ender 3 Pro.</p>
<p>I have encountered this many times. This is how I solved it:</p> <p>Sadly you have to disassemble the entire hotend. Remove the nozzle, remove the heatbreak and heatsink leaving the heater block in place, it does not need to be cleaned (unless I am mistaken). If there are any plastic pieces in those parts, remove them as well.</p> <p>Now for the cleaning. Use hot air gun to heat the nozzle/heatbreak/heatsink hot enough so the filament starts to melt. Then you can use a thin screwdriver (or metal wire) to push the stuck filament out.</p> <p>Alternatively, you can use blow torch (or gas soldering iron with the soldering tip removed) to melt and burn away the stuck plastic. However, when the plastic burns it transforms into a solid dirt which you have to manually remove. But it does not stick as well as the original filament.</p> <p>I advise against using q-tips because they are made out of plastic which can stick to the surface as well. Instead, use a piece of old cotton cloth (old sock or t-shirt will do) to wipe the surface or threads after heating the part.</p> <p>When doing so, use needle nose pliers to hold the part in one hand, with the other hand use hot air gun or blow torch to head it up. Then remove the source of heat and with the same hand use screw driver or piece of cloth to clean the part to your liking.</p> <p>It is ugly and messy and you will most likely burn yourself several times. But it solves the problem quite reliably, unlike cold-pulls and other methods (at least in my experience).</p> <p>Bathing the parts in acetone will most likely do nothing (unless the stuck filament is ABS) because most filaments in use are resistant against dissolving in acetone. If you need to remove filament from anywhere, use heat not chemicals. It is easier and works almost 100% time.</p> <p>Good luck.</p> <p>Note: The solution above for heatbreaks and heatsinks concerns only full metal hotends. Hotends with PTFE lining (such as on Ender 3 Pro - I do not own one, cannot confirm) need to wory about filament being stuck in the nozzle and/or in the PTFE tube, not in the heatbreak and/or heatsink.</p>
<p>I fixed this by using a q-tip to wipe out the threads!</p>
1,735
<p>I have a Creality Ender 3 that printed a spool of Sunlu PLA with no issues, so I bought a second to replace it, just in a different color.</p> <p>The problem is I can’t get it to stick. The bed is level, I’ve tried printing at different temps, even adjusted the fan, but no luck. No matter what, the print still only partially sticks to the bed before eventually being knocked loose by the nozzle, if it even sticks at all. Mostly it just extrudes in a spaghetti ball next to the nozzle.</p> <p>Does anyone know how I can fix this issue? I have tried everything!</p> <p>Update: More info for those who have asked: I have adjusted the temps of both the hot end and the bed to various temps within what is recommended with this filament (200-230 and 50-90 C) The bed is level I have attempted prints with both the plastic and glass beds (glass bed has never been printed on) Attempted to use hairspray While the print is somewhat sticking, it now produces a glob of pla while making its first pass down, which it then hits and completely unsticks. I think the glob is caused by the pla not sticking to the bed from the very beginning but am unsure. Hope this helped!</p>
<h1>Level the bed</h1> <p>Make sure that the bed is level. The nozzle must be equally high over heated surface, otherwise only part of the print will have chance to be smeared and adhere properly.</p> <h1>Clean thoroughly</h1> <p>First thing I do when I notice that increasing bed temperature does not work anymore, is washing the glass with soap or detergent. Some advice to use also isopropyl alcohol. My impression is that the main mistake is to use alcohol to wipe the glass instead of <strong>dismounting and thoroughly cleaning the glass from any grease</strong>. This is a bit more work, and for me works great.</p> <p>Applying alcohol, brake cleaner or similar no-trace solvent could enhance the effect (as suggested by FarO).</p> <h1>Reduce the air flow</h1> <p>Disable fan for the first layer (or even more layers above).</p> <p>Isolate the printer from environment - e.g. buy or build enclosure. Remove any drafts. Ensure that ambient temperature is not cooling prints down too fast (for example printing in garage or shed may fail until the space is heated).</p> <h1>Use kapton tape</h1> <p>You may like the idea to put kapton tape on the surface (only glass?). Wide kapton roll would be needed to cover big area at once, to cover the whole glass with good quality and in reasonable time. Created surface should be as ideal as possible, because any bubbles will cause later trouble, it is not easy but doable. The outcome is great. Any accidents with hotend should be avoided, and prints removed with some care, to remain tape undamaged as long as possible. (I use 50 mm tape. And I save this surface for printing ABS, and only occasionally for PLA, because it sticks so well that I had problem to remove prints saving the surface, even after cooling down.)</p> <h1>Apply adhesive</h1> <p>You can use adhesives like <a href="https://3dprinting.stackexchange.com/questions/11182/why-does-hairspray-work-as-an-adhesive-for-abs/11183?r=SearchResults&amp;s=4%7C13.2803#11183">hairspray</a>, <a href="https://3dprinting.stackexchange.com/questions/15281/are-all-glue-sticks-pva-based-how-to-find-out/15282?r=SearchResults&amp;s=1%7C20.5123#15282">glue stick</a> or even better a <a href="https://3dprinting.stackexchange.com/a/15282/">dedicated adhesion spray</a>. It is suggested especially for larger parts, which tend to wrap without this kind of adhesive aid. There is no one good solution. You may want to experiment, starting from cheap and widely accepted to commercial and wildly advertised products, with regards to your local market. Look for example links at the bottom.</p> <h1>Expand line settings for initial layer</h1> <p>Make sure that amount of extruded material is correct. This mean proper calibration regarding settings like: steps/mm for E axis, flow rate. Small difference in amount of extruded filament will reduce the quality of the rest of the print. Bigger differences may ruin print at the initial layer, and for sure will spoil the rest.</p> <p>Use slicer settings to increase line width for first layer. Values of 120-140% are standard settings for improving adhesion.</p> <p>Slightly increasing height of initial layer may also help to overcome bed surface roughness or slight leveling errors.</p> <h1>Decrease speed to 20 mm/s or less</h1> <p>Reduce printing speed for initial layer <a href="https://3dprinting.stackexchange.com/questions/14958/filament-sticks-to-nozzle/15231#15231">to 20 mm/s or even lower</a>, and raise it carefully after trouble is really resolved. (In my opinion it is better to decrease speed to let plastic melt and stick, than to increase temperature.)</p> <h1>Modify temperature</h1> <p>The temperature of heated bed should be high enough to keep the initial layer of filament within glass transition zone. This usually means more than 60 °C for PLA (between 50 °C - 80 °C depending on contents). (I usually print at 70 °C, and raise to 80 °C when meet issues.)</p> <p>Increasing the temperature of nozzle also may improve the adhesion. But it may also be temporary success, because of negative effects related to temperature differences, and for example cause wrapping - ruining especially wider prints. So decreasing the nozzle temperature is also an option to check, when wrapping is observed.</p> <h1>Experiment with more advanced techniques</h1> <p>If you are still failing, then try experiment following many advices around (contrary, but sometimes working). If the firs layer adhere to the bed, but problems appear later, then other advanced techniques may help - like slicing model with additional structures (brim or raft).</p> <p>The best advice may depend on kind of heated bed, surface or environment. This checklist may be of some use: <a href="https://all3dp.com/2/3d-printer-bed-adhesion-all-you-need-to-know/" rel="nofollow noreferrer">3D Printer Bed Adhesion: All You Need To Know</a>. Also there are many troubleshooting threads on the web, like this on Reddit: <a href="https://www.reddit.com/r/ender3/comments/di1j2t/sunlu_pla_will_not_adhere_to_build_surface/" rel="nofollow noreferrer">SUNLU PLA+ will not adhere to build surface</a>, or; this on Thingiverse: <a href="https://www.thingiverse.com/groups/ender3/forums/general/topic:41047" rel="nofollow noreferrer">SUNLO PLA+: does not stick.</a>.</p>
<p>In addition to the suggestion of cleaning the glass with soap (dish soap works very well) and THEN also with any alcohol or brake cleaner or similar no-trace solvent, you can use hairspray or glue stick for larger parts.</p>
1,829
<p>I would like my website to record flvs using webcams. These flvs need to play smoothly so I can play with them afterwards, for example transcoding them to avis.</p> <p>I've tried many different servers to handle the flv recording. The resulting flvs play OK in Wimpy FLV Player, for example, except that the progress indicator doesn't move smoothly or in a regular fashion. This is a sign that there is something wrong and if I try to transcode them using "ffmpeg -i input.flv output.avi" (with or without the framerate option "-r 15") I don't get the right avi.</p> <p>Here's what I tried and the kind of problem I get:</p> <ol> <li><p>Using <a href="http://osflash.org/red5" rel="nofollow noreferrer">red5</a> (v 0.6.3 and 0.7.0, both on OS X 10.5.4 and Ubuntu 8.04) and the publisher.html example it includes. Here's the <a href="http://www.marc-andre.ca/posts/blog/webcam/test-red5-publisher.flv" rel="nofollow noreferrer">resulting flv</a>. The indicator jumps towards the end very rapidly.</p></li> <li><p>Still using red5, but publishing "live" and starting the recording after a couple of seconds. I used <a href="http://sziebert.net/posts/server-side-stream-recording-with-red5/" rel="nofollow noreferrer">these example files</a>. Here's the <a href="http://www.marc-andre.ca/posts/blog/webcam/test-red5-live-sziebert.flv" rel="nofollow noreferrer">resulting flv</a>. The indicator still jumps to the end very rapidly, no sound at all with this method...</p></li> <li><p>Using <a href="http://www.wowzamedia.com/products.html" rel="nofollow noreferrer">Wowza Media Server Pro</a> (v 1.5.3, on my mac). The progress indicator doesn't jump to the end, but it moves more quickly at the very beginning. This is enough that conversion to other formats using ffmpeg will have the visual not synchronized properly with the audio. Just to be sure I tried the <a href="http://www.marc-andre.ca/posts/blog/webcam/test-wowza.flv" rel="nofollow noreferrer">video recorder that comes with it</a>, as well as using red5's publisher.html (with <a href="http://www.marc-andre.ca/posts/blog/webcam/test-wowza-publisher.flv" rel="nofollow noreferrer">identical results</a>).</p></li> <li><p>Using Flash Media Server 3 through an account hosted at <a href="http://www.influxis.com" rel="nofollow noreferrer">www.influxis.com</a>. I get yet another progression pattern. The progress indicator jumps a bit a the beginning and then becomes regular. Here's <a href="http://www.marc-andre.ca/posts/blog/webcam/test-influxis.flv" rel="nofollow noreferrer">an example</a>.</p></li> </ol> <p>I know it is possible to record a "flawless" flv because facebook's video application does it (using red5?) Indeed, it's easy to look at the HTML source of facebook video and get the http URL to download the flvs they produce. When played back in Wimpy, the progress indicator is smooth, and transcoding with "ffmpeg -i facebook.flv -r 15 facebook.avi" produces a good avi. Here's <a href="http://www.marc-andre.ca/posts/blog/webcam/test-facebook.flv" rel="nofollow noreferrer">an example</a>.</p> <p>So, can I manage to get a good flv with a constant framerate?</p> <p>PS: Server must be either installable on Linux or else be available at a reasonably priced hosting provider.</p> <p>Edit: As pointed out, maybe the problem is not framerate per say but something else. I am not knowledgeable in video and I don't know how to inspect the examples I gave to check things out; maybe someone can shed some light on this.</p>
<p>Looking at your red5 example flv in <a href="http://www.richapps.de/?p=66" rel="nofollow noreferrer">richflv</a> (very handy flv editing tool) we can see that you have regular keyframes but the duration metadata isn't set.</p> <p>The facebook example flv has hardly any keyframes (which would mean you wouldn't be able 'seek' within it very well) however the metadata duration is correct.</p> <p>I'd look into flvtool2 and flvtool++ (which is a more memory efficient alternative for long files) to insert the correct metadata post capture.</p>
<p>Your problem might not be with the framerate but with keyframes and markers.</p>
9,307
<p>I've been trying to find a solution to a problem I've been having recently whereby the bottom layers of my print (1.2&nbsp;mm; 12 layers) are either being compressed. over extruded or both. The problem results in the nozzle being dragged through previously extruded filament leaving deep groove marks and the bottom layers being risen/wavy, thus causing (I believe) the print layers to expand horizontally outwards </p> <p>Settings are:</p> <ul> <li>Anycubic Chiron </li> <li>0.1&nbsp;mm layer height</li> <li>200&nbsp;&deg;C hotends temperature</li> <li>55&nbsp;&deg;C bed temperature</li> <li>40&nbsp;mm/s print speed</li> <li>eSun black 1.75&nbsp;mm PLA</li> <li>Cura 4.4.1</li> </ul> <p>It's less noticeable on less intrinsic prints but for my <a href="https://forums.eagle.ru/showthread.php?t=260512" rel="nofollow noreferrer">latest project</a>, its becoming a real issue. The problem is that for the square holes for the buttons (of which there are a lot), the bottom layers are extruding (essentially elephants foot-ing) which is impacting the tolerances of the build (holes should be 13&nbsp;mm to accept 12.5&nbsp;mm square buttons but are coming out at ~12.7&nbsp;mm only on the bottom layer, I've measured the walls of the square holes and they're coming out perfectly).</p> <p>I've tried almost everything I can think of/find on Google: </p> <ol> <li>Levelling the bed (multiple times)</li> <li>Tried print temps from 190&nbsp;&deg;C to 210&nbsp;&deg;C (even printed a temp tower which confirmed printing at ~200&nbsp;&deg;C is correct for my filament (eSun black PLA)</li> <li>Calibrated the extruder</li> <li>Calibrated the Z-axis </li> <li>Set different horizontal expansion settings in Cura</li> <li>Reduced entire print flow rates (have tried 90&nbsp;%, 85&nbsp;% and 80&nbsp;%); this somewhat worked but produced problems elsewhere in the print due to lack of material (skin overlap etc.)</li> <li>Used the 'modify settings for overlap' mesh setting to reduce infill flow &amp; inner wall flow to 45&nbsp;% and 55&nbsp;% respectively for the bottom layers (up to 1.2&nbsp;mm). </li> </ol> <p>The last point in that list is where I've had the most success but it does leave a slight indentation around the outer wall until the full flow rate kicks in (i.e. >1.2&nbsp;mm) and I'm thinking there may be other things at play that are causing the issue and I shouldn't have to do this reduce bottom layer flow so much if at all.</p> <p>Has anyone seen this before?</p>
<p>The first thing that comes to mind is that, even though you have levelled the bed, the print nozzle may be too close causing too much "squish" on the first layer. Squish isn't bad as it promotes adhesion, but in your case, as you are looking for finer tolerances on the holes, it may be a problem. I use a feeler gauge and aim for 0.15&nbsp;mm gap when printing at 0.2&nbsp;mm layer height.</p> <p>Next thing to consider is ensuring you have calibrated your flow rate/extrusion multiplier. <a href="https://e3d-online.dozuki.com/Guide/Flow+rate+(Extrusion+multiplier)+calibration+guide./89" rel="nofollow noreferrer">See here for detailed procedure</a></p> <p>Assuming flow rate is calibrated I can think of some settings in Cura that could affect your print.</p> <ul> <li>Initial Layer Flow</li> <li>Flow Rate Compensation Factor</li> <li>Combing Mode / Avoid Printed Parts</li> </ul> <p><em>Initial Layer Flow</em> enable the use of a higher/lower flow rate in you first layer. Typically I set this to a value larger that my flow rate, 120&nbsp;%, as I want good adhesion and am less worried about the elephant's foot effect. However, you could reduce it to less than your flow rate although that may compromise adhesion unless you use a brim.</p> <p><em>Flow Rate Compensation Factor</em> For most circumstances this should be 100&nbsp;% which indicates that your flow rate should be used as set and not compensated for. I would check that this value has not been altered cause over-extrusion.</p> <p>Lastly, there are two travel settings. <em>Combing Mode</em> and <em>Avoid Printed Parts</em> work in combination to reducing the impact of travels in the finished print. I would ensure you have combing turned on (e.g. Not in Skin) and that you have enabled Avoid Printed Parts. More details on these settings can be found <a href="https://ultimaker.com/en/resources/52838-travel" rel="nofollow noreferrer">here</a> </p>
<p>I had similar issues during the past few days. My first 3~5 layers overlapped. I ended up with figuring out it was the screws to mount Z stepper became loose and the stepper shifted itself downwards instead shifting up the nozzle for the first several layers, until the stepper had nowhere to go.</p>
1,595
<p>I'm specifically interested in tools that can be plugged into Vim to allow CScope-style source browsing (1-2 keystroke commands to locate function definitions, callers, global symbols and so on) for languages besides C/C++ such as Java and C# (since Vim and Cscope already integrate very well for browsing C/C++). I'm not interested in IDE-based tools since I know Microsoft and other vendors already address that space -- I prefer to use Vim for editing and browsing, but but don't know of tools for C# and/or Java that give me the same power as CScope.</p> <p>The original answer to this question included a pointer to the CSWrapper application which apparently fixes a bug that some users experience integrating Vim and CScope. However, my Vim/CScope installation works fine; I'm just trying to expand the functionality to allow using Vim to edit code in other languages.</p>
<p>CScope does work for Java.</p> <p>From <a href="http://cscope.sourceforge.net/cscope_vim_tutorial.html" rel="nofollow noreferrer">http://cscope.sourceforge.net/cscope_vim_tutorial.html</a>:</p> <blockquote> <p>Although Cscope was originally intended only for use with C code, it's actually a very flexible tool that works well with languages like C++ and Java. You can think of it as a generic 'grep' database, with the ability to recognize certain additional constructs like function calls and variable definitions. By default Cscope only parses C, lex, and yacc files (.c, .h, .l, .y) in the current directory (and subdirectories, if you pass the -R flag), and there's currently no way to change that list of file extensions (yes, we ought to change that). So instead you have to make a list of the files that you want to parse, and call it 'cscope.files' (you can call it anything you want if you invoke 'cscope -i foofile'). An easy (and very flexible) way to do this is via the trusty Unix 'find' command:</p> </blockquote> <pre><code>find . -name '*.java' &gt; cscope.files </code></pre> <blockquote> <p>Now run 'cscope -b' to rebuild the database (the -b just builds the database without launching the Cscope GUI), and you'll be able to browse all the symbols in your Java files. Apparently there are folks out there using Cscope to browse and edit large volumes of documentation files, which shows how flexible Cscope's parser is.</p> </blockquote>
<p>This may be what you're looking for:</p> <p><a href="http://www.vim.org/scripts/script.php?script_id=1783" rel="nofollow noreferrer">http://www.vim.org/scripts/script.php?script_id=1783</a></p> <p>You can also mimic some CScope functionality in your own .vimrc file by using the various flavors of <a href="http://vimdoc.sourceforge.net/htmldoc/map.html" rel="nofollow noreferrer">map</a>.</p>
9,118
<p>To experiment, I've (long ago) implemented Conway's <a href="http://en.wikipedia.org/wiki/Conway&#39;s_Game_of_Life" rel="noreferrer">Game of Life</a> (and I'm aware of <a href="https://stackoverflow.com/questions/1823/writing-a-conways-game-of-life-program">this</a> related question!).</p> <p>My implementation worked by keeping 2 arrays of booleans, representing the 'last state', and the 'state being updated' (the 2 arrays being swapped at each iteration). While this is reasonably fast, I've often wondered about how to optimize this.</p> <p>One idea, for example, would be to precompute at iteration N the zones that <em>could</em> be modified at iteration (N+1) (so that if a cell does not belong to such a zone, it won't even be considered for modification at iteration (N+1)). I'm aware that this is very vague, and I never took time to go into the details...</p> <p>Do you have any ideas (or experience!) of how to go about optimizing (for speed) Game of Life iterations?</p>
<p>I am going to quote my answer from the other question, because the chapters I mention have some very interesting and fine-tuned solutions. Some of the implementation details are in c and/or assembly, yes, but for the most part the algorithms can work in any language:</p> <blockquote> <p>Chapters <a href="http://www.jagregory.com/abrash-black-book/#chapter-17-the-game-of-life" rel="noreferrer">17</a> and <a href="http://www.jagregory.com/abrash-black-book/#chapter-18-its-a-plain-wonderful-life" rel="noreferrer">18</a> of Michael Abrash's <a href="http://www.jagregory.com/abrash-black-book/" rel="noreferrer">Graphics Programmer's Black Book</a> are one of the most interesting reads I have ever had. It is a lesson in thinking outside the box. The whole book is great really, but the final optimized solutions to the Game of Life are incredible bits of programming.</p> </blockquote>
<p>Don't exactly know how this can be done, but I remember some of my friends had to represent this game's grid with a Quadtree for a assignment. I'm guess it's real good for optimizing the space of the grid since you basically only represent the occupied cells. I don't know about execution speed though.</p>
6,172
<p>I switched locally from subversion 1.4 to 1.5, our server still runs 1.4. Since then every merge takes ages to perform. What took only a couple of seconds is now in the area of 5-10 minutes (or more). There is no difference between the command line client and tortoise (so we talk about the windows versions).</p> <p>Has anybody else this strange phenomenon?</p>
<p>Upgrading to 1.5.3 (when it is out) will significantly speed up your merges.</p>
<p>We've had problems when trying to add large numbers of files to repositories through the client which I assume created orphaned processes on the server when we killed the crashed client. We had to kill the server processes too and restart the subversion service (we run SVN as a windows service). Our SVN machine is dedicated so we actually just rebooted the box and everything went back to normal.</p>
2,876
<p>I was having some issues with printing, most noticeably in this picture:</p> <p><img src="https://i.imgur.com/oCKwkBj.jpg" alt="Noticeable layers in print" title="Noticeable layers in print" /></p> <p>The layers are very noticeable and sometimes have gaps, and the overhangs don't print very well (although the former is more of an issue). I just calibrated my E-steps so I don't think that is the issue. It was doing the same thing before I upgraded anything (i.e., I had issues on stock hardware).</p> <p>My printer is an Ender 3 with the metal extruder upgrade (which replaces the plastic parts as seen <a href="https://rads.stackoverflow.com/amzn/click/com/B07B96QMN2" rel="nofollow noreferrer" rel="nofollow noreferrer">here</a>), an E3D v6, printed fan duct (Bullseye), glass bed, BLTouch, and vanilla Marlin. Pictures of it are also in the below album. The printed upgrades were printed on a Prusa MK3S and don't have the same issue.</p> <p>I am using Hatchbox 1.75 mm gray PLA, printed at 215 °C with my bed at 60 °C. I am using Ultimaker Cura 4.1 but was also having the problems on an older version of Ultimaker Cura (maybe 3.6, but I can't remember which it was). The problems also existed with some Hatchbox 1.75 mm black PLA but I used the same roll on my Prusa MK3S without any issues, so I'm not sure if filament could be the cause (although it is a different printer so it's still a possibility).</p> <p>I have tried at different printing speeds and the problem still persists.</p> <p>I also recently tried varying the temperature during printing (first up to 222 °C then down to 200 °C) with no noticeable difference.</p> <p>Extra pictures <a href="https://imgur.com/a/W95BXf0" rel="nofollow noreferrer">here</a>.</p> <p>Model is part of <a href="https://www.printablescenery.com/product/sorcerers-tower/" rel="nofollow noreferrer">Printable Scenery's sorcerer tower</a>.</p>
<p>The main issue here (the gaps between layers) was solved by reducing combing.</p> <p>Combing was enabled without a limit on the range so a max combing distance of 10&nbsp;mm was introduced. This prevented too much filament from oozing out during travels.</p> <p>The oozing filament was causing nothing to come out of the nozzle at the beginning of an extrusion, thus creating the gaps that were consistent in location.</p>
<p>These lines could be caused by a mechanical issue with the printer; it looks as if the positioning is not up to par. </p> <p>This can be related to loose belts of the X-axis and Y-axis, or play in your system, e.g. look at the rollers of the carriage.</p> <hr> <p><em>I've experienced an issue with play between the idler mounts and the smooth linear rods on a cheap 3D printer kit myself, but that is not the case here. Just added to explain where play may come from.</em></p>
1,430
<p>I'm trying to print a supporting base which will house the spindle for an electrostatic rotor. It's basically just a truncated cone with a hole down it's center to house the spindle.</p> <p>For reasons that I cannot fathom, Ultimaker Cura keeps on adding an unrequested top/bottom layer (color-coded yellow in the screenshots) inside this hole, so instead of a single hollow cylinder of 10&nbsp;mm depth, the result is a hole only a few millimeters deep with another hollow cylinder behind it.</p> <p>Here is the intended model, note the open space for the hole at the top.</p> <p><a href="https://i.stack.imgur.com/tUdBC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tUdBC.png" alt="enter image description here"></a></p> <p>Here is the inner view of the hole being printed as expected:</p> <p><a href="https://i.stack.imgur.com/kXV5x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kXV5x.png" alt="enter image description here"></a></p> <p>Finally, here is a layer view of the print a few millimeters from the final top layer with the unrequested top/bottom layer that covers the spindle hole:</p> <p><a href="https://i.stack.imgur.com/Yd8mn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yd8mn.png" alt="enter image description here"></a></p> <p>The STL file is on <a href="https://github.com/gearoid-murphy/3dprints/blob/master/spindle.stl" rel="nofollow noreferrer">Github</a> (with a built-in viewer).</p> <p>Can anyone help me understand why this is happening?</p>
<p>It would appear that your model does not conform properly to STL standards. I base this conclusion on a couple of factors. When I loaded the model into Simplify3D slicer, it displayed fine, but when sliced, displayed nothing. Using the onboard repair feature, it presented the entire model as being composed of non-manifold surfaces.</p> <p>Meshmixer's Analysis/Inspector feature also highlighted the entire model as flawed.</p> <p>Another observation is that there is an extraordinary amount of facets/triangles/faces to this model. Nearly three-quarters of a million triangles for something that should be much simpler.</p> <p>The most recent version of Prusa Slicer 2.0 presents an error message indicating that no layers were detected. This is peculiar indeed.</p> <p>All of the above points to a problem with the source file or the software used to create it.</p> <p>Please consider to add to your post the program you used or the source of the model.</p>
<p>I had the same issue exporting from Sketchup to STL. I imported my STL to Tinkercad and then exported it again and it resolved my issue.</p> <p>Tinkercad is a free and online tool.</p>
1,443
<p>I'm working on a setup which <em>wants to include the Microsoft.Web.Services3 (WSE 3.0) DLL</em>. However, I typically do not like including Microsoft DLL's in our installs except by way of Microsoft's redistributables. There is both a developer and a redist install package available from Microsoft.</p> <p>So, as a best practice, should I include the single DLL in my install or refer them to one of the WSE 3.0 installs (assuming they do not already have it installed)?</p>
<p>Usually, redistributing any of Microsoft DLLs outside of the redistributable package is forbidden by their EULA, so you might first want to check the appropriate EULA for that DLL.</p> <p>Generally, I would prefer the redist package since that makes sure that it's correctly "registered" into the system, i.e. if you install a newer version of the redist it gets updated (like DirectX) or not overwritten if it's an older version (also like DirectX).</p>
<p>If you don't include it you should at the very least link to it directly on your site or have your installer open the web browser to it (or even download it automatically). Or better yet, include the redistributable in your software package.</p> <p>However, if the DLL is not very large and you suspect that few users will have it, in the interest of a better user I would prepackage it in the default installer. However, you can always have an installer that does not include it for those who want a smaller installer... a great deal of other vendors do this all the time.</p>
3,842