instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>One of the joys of working for a government healthcare agency is having to deal with all of the paranoia around dealing with PHI (Protected Health Information). Don't get me wrong, I'm all for doing everything possible to protect people's personal information (health, financial, surfing habits, etc.), but sometimes people get a little too jumpy.</p> <p>Case in point: One of our state customers recently found out that the browser provides the handy feature to save your password. We all know that it has been there for a while and is completely optional and is up to the end user to decide whether or not it is a smart decision to use or not. However, there is a bit of an uproar at the moment and we are being demanded to find a way to disable that functionality for our site.</p> <p><strong>Question</strong>: Is there a way for a site to tell the browser not to offer to remember passwords? I've been around web development a long time but don't know that I have come across that before.</p> <p>Any help is appreciated.</p>
<p>I'm not sure if it'll work in all browsers but you should try setting autocomplete=&quot;off&quot; on the form.</p> <pre><code>&lt;form id=&quot;loginForm&quot; action=&quot;login.cgi&quot; method=&quot;post&quot; autocomplete=&quot;off&quot;&gt; </code></pre> <blockquote> <p>The easiest and simplest way to disable Form <strong>and Password storage prompts</strong> and prevent form data from being cached in session history is to use the autocomplete form element attribute with value &quot;off&quot;.</p> </blockquote> <blockquote> <p>From <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion</a></p> </blockquote> <p>Some minor research shows that this works in IE to but I'll leave no guarantees ;)</p> <p><a href="https://stackoverflow.com/questions/32369/disable-browser-save-password-functionality#32408">@Joseph</a>: If it's a strict requirement to pass XHTML validation with the actual markup (don't know why it would be though) you could theoretically add this attribute with javascript afterwards but then users with js disabled (probably a neglectable amount of your userbase or zero if your site requires js) will still have their passwords saved.</p> <p>Example with jQuery:</p> <pre><code>$('#loginForm').attr('autocomplete', 'off'); </code></pre>
<blockquote> <p>Is there a way for a site to tell the browser not to offer to remember passwords?</p> </blockquote> <p>The website tells the browser that it is a password by using <code>&lt;input type="password"&gt;</code>. So if you <em>must</em> do this from a website perspective then you would have to change that. (Obviously I don't recommend this).</p> <p>The best solution would be to have the user configure their browser so it won't remember passwords.</p>
5,229
<p>LINQ simplifies database programming no doubt, but does it have a downside? Inline SQL requires one to communicate with the database in a certain way that opens the database to injections. Inline SQL must also be syntax-checked, have a plan built, and then executed, which takes precious cycles. Stored procedures have also been a rock-solid standard in great database application programming. Many programmers I know use a data layer that simplifies development, however, not to the extent LINQ does. Is it time to give up on the SP's and go LINQ? </p>
<p>LINQ to SQL actually presents some alarming performance problems in the database. Basically, it creates multiple execution plans based on the length of the parameter you are using. I posted about it a while back on my blog <a href="http://facility9.com/2008/08/28/linq-to-sql-may-cause-performance-problems/" rel="noreferrer">LINQ to SQL may cause performance problems</a>. </p> <p>Now, is that to say that LINQ doesn't have a place? Hardly. LINQ definitely has a place in the development toolkit, just like stored procedures. Ultimately, you want to use stored procedures when performance is absolutely necessary and use an ORM tool in any other situation.</p> <p>As far as inline SQL goes, there are ways to execute inline SQL so that the plan is only built once and is never recompiled. Most ORMs should take care of this aspect of performance tuning as well and using these methods is usually the safest way to execute your SQL since it forces you to use parameterized queries.</p> <p>Like most database solutions, the right answer depends on the problem you're trying to solve. If you favor development speed over database/application performance, then using LINQ or another DAL/ORM tool is the best way to go. If you favor performance over ease of development, then using stored procedures and pure datasets is going to be your best bet. LLBLGen even provides a LINQ to LLBLGen layer so you can use LINQ to query LLBLGen's objects and have LLBLGen actually handle building your queries and avoid some of the downfalls of LINQ.</p>
<p>It depends on what you're doing. LINQ is going to be less efficient at the actual data/set manipulation than a real database. But you'll save a lot in not having to connect to the database over a network.</p> <p>If your database is on the same machine or is formally 'well-connected', you're probably better off using it.</p> <p>But if you're getting back a large result set from a remote db that could mean significant transmission time, or if it's a really short query that won't justify the overhead, LINQ would likely be better.</p>
9,778
<p>I am working on a project management web application. The user has a variety of ways to display a list of tasks. When viewing a list page, they click on task and are redirected to the task edit page. </p> <p>Since they are coming from a variety of ways, I am just curious as to the <strong>best</strong> way to <strong>redirect</strong> the user back to the calling page. I have some ideas, but would like to get other developers input.</p> <p>Would you store the <strong>calling</strong> url in session? as a cookie? I like the concept of using an object <strong>handle</strong> the redirection.</p>
<p>I would store the referring URL using the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.viewstate.aspx" rel="noreferrer">ViewState</a>. Storing this outside the scope of the page (i.e. in the Session state or cookie) may cause problems if more than one browser window is open.</p> <p>The example below validates that the page was called internally (i.e. not requested directly) and bounces back to the referring page after the user submits their response.</p> <pre><code>public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Request.UrlReferrer == null) { //Handle the case where the page is requested directly throw new Exception("This page has been called without a referring page"); } if (!IsPostBack) { ReturnUrl = Request.UrlReferrer.PathAndQuery; } } public string ReturnUrl { get { return ViewState["returnUrl"].ToString(); } set { ViewState["returnUrl"] = value; } } protected void btn_Click(object sender, EventArgs e) { //Do what you need to do to save the page //... //Go back to calling page Response.Redirect(ReturnUrl, true); } } </code></pre>
<p>I personally would store the required redirection info in an object and handle globally. I would avoid using a QueryString param or the like since they could try bouncing themselves back to a page they are not supposed to (possible security issue?). You could then create a static method to handle the redirection object, which could read the information and act accordingly. This encapsulates your redirection process within one page.</p> <p>Using an object also means you can later extend it if required (such as adding return messages and other info).</p> <p>For example (this is a 2 minute rough guideline BTW!):</p> <pre><code>public partial class _Default : System.Web.UI.Page { void Redirect(string url, string messsage) { RedirectionParams paras = new RedirectionParams(url, messsage); RedirectionHandler(paras); // pass to some global method (or this could BE the global method) } protected void Button1_Click(object sender, EventArgs e) { Redirect("mypage.aspx", "you have been redirected"); } } public class RedirectionParams { private string _url; public string URL { get { return _url; } set { _url = value; } } private string _message; public string Message { get { return _message; } set { _message = value; } } public RedirectionParams(string url, string message) { this.URL = url; this.Message = message; } } </code></pre>
5,734
<p>I have lots of article store in MS SQL server 2005 database in a table called Articles-</p> <pre><code>"Articles (ArticleID, ArticleTitle, ArticleContent)" </code></pre> <p>Now I want some SP or SQL query which could return me similar Article against any user's input (very much like "Similar Posts" in blogs OR "Related Questions" in stackoverflow). The matching should work on both ArticleTitle and ArticleContent. The query should be intelligent enough to sort the result on the basis on their relevancy.</p> <p>Is it possible to do this in MS SQL Server 2005?</p>
<p>Something like this might work, a kind of ranking system. You would probably have to split the string in your application to build a SQL string, but I have used similar to build an effective site search.</p> <pre><code>Select Top 10 ArticleID, ArticleTitle, ArticleContent From Articles Order By (Case When ArticleTitle = 'Article Title' Then 1 Else 0 End) Desc, (Case When ArticleTitle = 'Article' Then 1 Else 0 End) Desc, (Case When ArticleTitle = 'Title' Then 1 Else 0 End) Desc, (Case When Soundex('Article Title') = Soundex(ArticleTitle) Then 1 Else 0 End) Desc, (Case When Soundex('Article') = Soundex(ArticleTitle) Then 1 Else 0 End) Desc, (Case When Soundex('Title') = Soundex(ArticleTitle) Then 1 Else 0 End) Desc, (Case When PatIndex('%Article%Title%', ArticleTitle) &gt; 0 Then 1 Else 0 End) Desc, (Case When PatIndex('%Article%', ArticleTitle) &gt; 0 Then 1 Else 0 End) Desc, (Case When PatIndex('%Title%', ArticleTitle) &gt; 0 Then 1 Else 0 End) Desc, (Case When PatIndex('%Article%Title%', ArticleContent) &gt; 0 Then 1 Else 0 End) Desc, (Case When PatIndex('%Article%', ArticleContent) &gt; 0 Then 1 Else 0 End) Desc, (Case When PatIndex('%Title%', ArticleContent) &gt; 0 Then 1 Else 0 End) Desc </code></pre> <p>You can then add/remove case statements from the order by clause to improve the list based on your data.</p>
<p>First of all you need to define what article similarity means.<br> For example you can associate some meta information with articles, like tags.<br> To be able to find similar articles you need to extract some features from them, for example you can build full text index.</p> <p>You can take advantage of full text search capability of MSSQL 2005</p> <pre><code>-- Assuming @Title contains title of current articles you can find related articles runnig this query SELECT * FROM Acticles WHERE CONTAINS(ArticleTitle, @Title) </code></pre>
6,029
<p>I'm trying to parse an INI file using C++. Any tips on what is the best way to achieve this? Should I use the Windows API tools for INI file processing (with which I am totally unfamiliar), an open-source solution or attempt to parse it manually?</p>
<p>You can use the Windows API functions, such as <a href="https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprivateprofilestring" rel="noreferrer">GetPrivateProfileString()</a> and <a href="https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprivateprofileint" rel="noreferrer">GetPrivateProfileInt()</a>.</p>
<p>Maybe a late answer..But, worth knowing options..If you need a cross-platform solution , definitely you can try GLIB,, its interesting.. (<a href="https://developer.gnome.org/glib/stable/glib-Key-value-file-parser.html" rel="nofollow">https://developer.gnome.org/glib/stable/glib-Key-value-file-parser.html</a>)</p>
3,370
<p>Is there a way to tell subversion "update/merge unless it would cause a conflict"?</p> <p>I know you can use <code>--dry-run</code> / <code>status -u</code> to check before running the update, but I often have others running updates and getting broken webpages because they don't notice the "C index.php" line.</p> <p>I've also noticed that svn doesn't seem too unhappy about conflicts - it still says "updated to revision blah" and exits zero, regardless of conflicts. So I have to parse the line-by-line output to discover them. Surely there's a better way?</p>
<p>You can use the --accept parameter to indicate what should happen when a conflict occurs:</p> <pre><code>--accept ARG : specify automatic conflict resolution action ('postpone', 'base', 'mine-full', 'theirs-full', 'edit', 'launch') </code></pre> <p>See also the <a href="http://svnbook.red-bean.com/en/1.5/svn.tour.cycle.html#svn.tour.cycle.resolve.diff" rel="nofollow noreferrer">interactive conflict resolution</a> page in the svnbook</p>
<p>you could also use a pre-commit script to look for conflict markers in files and prevent commit when they are present.</p>
5,353
<p>I am performing a find and replace on the line feed character (<code>&amp;#10;</code>) and replacing it with the paragraph close and paragraph open tags using the following code:</p> <pre><code>&lt;xsl:template match="/STORIES/STORY"&gt; &lt;component&gt; &lt;xsl:if test="boolean(ARTICLEBODY)"&gt; &lt;p&gt; &lt;xsl:call-template name="replace-text"&gt; &lt;xsl:with-param name="text" select="ARTICLEBODY" /&gt; &lt;xsl:with-param name="replace" select="'&amp;#10;'" /&gt; &lt;xsl:with-param name="by" select="'&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;'" /&gt; &lt;/xsl:call-template&gt; &lt;/p&gt; &lt;/xsl:if&gt; &lt;/component&gt; &lt;/xsl:template&gt; &lt;xsl:template name="replace-text"&gt; &lt;xsl:param name="text"/&gt; &lt;xsl:param name="replace" /&gt; &lt;xsl:param name="by" /&gt; &lt;xsl:choose&gt; &lt;xsl:when test="contains($text, $replace)"&gt; &lt;xsl:value-of select="substring-before($text, $replace)"/&gt; &lt;xsl:value-of select="$by" disable-output-escaping="yes"/&gt; &lt;xsl:call-template name="replace-text"&gt; &lt;xsl:with-param name="text" select="substring-after($text, $replace)"/&gt; &lt;xsl:with-param name="replace" select="$replace" /&gt; &lt;xsl:with-param name="by" select="$by" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$text"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; </code></pre> <p>This almost works perfectly, except that I really need it to de-dup the line feeds as the paragraphs tend to be separated by 2 or more resulting in <code>&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;</code>. </p> <p>Is it possible to get it so that it will only ever replace this once per paragraph?</p>
<p><code>disable-output-escaping</code> isn't evil in itself, but there are only few cases where you should use it and this isn't one of them. In XSLT you work with trees, not markup string. Here's an XSTL 1.0 solution:</p> <pre><code>&lt;xsl:template match="/STORIES/STORY"&gt; &lt;component&gt; &lt;xsl:if test="ARTICLEBODY"&gt; &lt;xsl:call-template name="wrap-text"&gt; &lt;xsl:with-param name="text" select="ARTICLEBODY"/&gt; &lt;xsl:with-param name="delimiter" select="'&amp;#10;'"/&gt; &lt;xsl:with-param name="element" select="'p'"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:if&gt; &lt;/component&gt; &lt;/xsl:template&gt; &lt;xsl:template name="wrap-text"&gt; &lt;xsl:param name="text"/&gt; &lt;xsl:param name="delimiter"/&gt; &lt;xsl:param name="element"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="contains($text, $delimiter)"&gt; &lt;xsl:variable name="t" select="substring-before($text, $delimiter)"/&gt; &lt;xsl:if test="normalize-space($t)"&gt; &lt;xsl:element name="{$element}"&gt; &lt;xsl:value-of select="$t"/&gt; &lt;/xsl:element&gt; &lt;/xsl:if&gt; &lt;xsl:call-template name="wrap-text"&gt; &lt;xsl:with-param name="text" select="substring-after($text, $delimiter)"/&gt; &lt;xsl:with-param name="delimiter" select="$delimiter"/&gt; &lt;xsl:with-param name="element" select="$element"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:if test="normalize-space($text)"&gt; &lt;xsl:element name="{$element}"&gt; &lt;xsl:value-of select="$text"/&gt; &lt;/xsl:element&gt; &lt;/xsl:if&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; </code></pre>
<p>Given the XPath functions that you're calling which I don't remember having the luxury of in my MSXSL work, it looks like you're using an XPath 2-compatible processor. </p> <p>If that's the case, doesn't XPath 2 have a replace(string, pattern, replacement) function that takes a regex as a second parameter? </p> <pre><code>&lt;xsl:value-of select="replace(string(.), '&amp;#10;(\s|&amp;#10;)*', '&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;')" /&gt; </code></pre> <p>It might help to have some sample Xml input and to know what processor you plan to use.</p> <p>From your original example, it seems that the duplicate paragraphs all have a white-space only prefix. So something like this slight modification might trim the dupes.</p> <pre><code>&lt;xsl:when test="contains($text, $replace)"&gt; &lt;xsl:variable name="prefix" select="substring-before($text, $replace)" /&gt; &lt;xsl:choose&gt; &lt;xsl:when test="normalize-string($prefix)!=''"&gt; &lt;xsl:value-of select="$prefix"/&gt; &lt;xsl:value-of select="$by" disable-output-escaping="yes"/&gt; &lt;/xsl:when&gt; &lt;/xsl:choose&gt; &lt;xsl:call-template name="replace-text"&gt; &lt;xsl:with-param name="text" select="substring-after($text, $replace)"/&gt; &lt;xsl:with-param name="replace" select="$replace" /&gt; &lt;xsl:with-param name="by" select="$by" /&gt; &lt;/xsl:call-template&gt; </code></pre> <p></p>
5,130
<p>How can I set the cookies in my <code>PHP apps</code> as <code>HttpOnly cookies</code>?</p>
<ul> <li>For <strong>your cookies</strong>, see this answer.</li> <li>For <strong>PHP's own session cookie</strong> (<code>PHPSESSID</code>, by default), see <a href="https://stackoverflow.com/a/8726269/1820">@richie's answer</a></li> </ul> <p>The <a href="http://php.net/manual/en/function.setcookie.php" rel="noreferrer"><code>setcookie()</code></a> and <a href="http://php.net/manual/en/function.setrawcookie.php" rel="noreferrer"><code>setrawcookie()</code></a> functions, introduced the boolean <code>httponly</code> parameter, back in the dark ages of PHP 5.2.0, making this nice and easy. Simply set the 7th parameter to true, as per the syntax</p> <p><em>Function syntax simplified for brevity</em></p> <pre><code>setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly ) setrawcookie( $name, $value, $expire, $path, $domain, $secure, $httponly ) </code></pre> <p>In PHP &lt; 8, specify <code>NULL</code> for parameters you wish to remain as default.</p> <p>In PHP &gt;= 8 you can benefit from using named parameters. See <a href="https://stackoverflow.com/a/64997399/1820">this question about named params</a>.</p> <pre><code>setcookie( $name, $value, httponly:true ) </code></pre> <p>It is also possible using the older, lower-level <a href="http://php.net/manual/en/function.header.php" rel="noreferrer"><code>header()</code></a> function:</p> <pre><code>header( &quot;Set-Cookie: name=value; HttpOnly&quot; ); </code></pre> <p>You may also want to consider if you should be setting the <code>Secure</code> parameter.</p>
<p>A more elegant solution since <strong>PHP >=7.0</strong> </p> <pre><code>session_start(['cookie_lifetime' =&gt; 43200,'cookie_secure' =&gt; true,'cookie_httponly' =&gt; true]); </code></pre> <p><a href="https://www.php.net/manual/en/function.session-start.php" rel="nofollow noreferrer">session_start</a></p> <p><a href="https://www.php.net/manual/en/session.configuration.php#ini.session.use-strict-mode" rel="nofollow noreferrer">session_start options</a></p>
5,747
<p>I assumed there were only bug fixes/(no new types) in .NET 2.0 SP1 until I came across <a href="http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx" rel="nofollow noreferrer">few</a> posts which were mentioning <a href="http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx" rel="nofollow noreferrer">DateTimeOffset</a> structure, that was added in .NET 2.0 SP1.</p> <p>Is there a full listing of the newly added types in .NET 2.0 SP1?</p>
<p>Here's what you're looking for:</p> <p><img src="https://i.stack.imgur.com/abAMI.gif" alt="alt text"></p> <p>Full Article: <a href="http://www.hanselman.com/blog/CatchingRedBitsDifferencesInNET20AndNET20SP1.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/CatchingRedBitsDifferencesInNET20AndNET20SP1.aspx</a></p> <p>This may also be helpful:</p> <p><img src="https://i.stack.imgur.com/X7q0e.gif" alt="alt text"></p> <p>Full Article: <a href="http://www.hanselman.com/blog/ChangesInTheNETBCLBetween20And35.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/ChangesInTheNETBCLBetween20And35.aspx</a></p>
<p>DateTimeOffset was added to 2.0 SP1 - I'm not aware of any other new types.</p> <p>Given the coincidental timing, it's perhaps worth reminding people that 2.0 SP1 shipped with 3.5 RTM (i.e November 2007) and 2.0 SP2 shipped with 3.5 SP1.</p>
6,256
<p>When I'm initializing a dialog, I'd like to select one of the radio buttons on the form. I don't see a way to associate a Control variable using the Class Wizard, like you would typically do with CButtons, CComboBoxes, etc...</p> <p>Further, it doesn't like a CRadioButton class even exists.</p> <p>How can I select one of the several radio buttons?</p>
<p>Radio buttons and check buttons are just buttons. Use a <code>CButton</code> control and use <code>GetCheck</code>/<code>SetCheck</code>.</p>
<pre><code>void CMyDlg::DoDataExchange(CDataExchange* pDX) { ... DDX_Radio(pDX, IDC_RADIO1, m_Radio); ... } </code></pre> <p>but it is the same thing Wizard generates</p>
9,919
<p>High performance polymers are becoming available for specific applications.</p> <p>One of such materials is PEEK (<a href="https://en.wikipedia.org/wiki/Polyether_ether_ketone" rel="noreferrer">PolyEther Ether Ketone</a>), a thermoplastic polymer in the polyaryletherketone (PAEK) family. PEEK competes with certain Aluminium alloys but is half the weight of Aluminium. For aerospace application this sounds very promising!</p> <p>NASA has <a href="https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20170000214.pdf" rel="noreferrer">shown</a> that printing these types of polymers is feasible using low-cost, open source hardware.</p> <p><strong>Does anybody know why the prices of PEEK are so high?</strong></p> <p>Depending on the supplier/manufacturer you're looking at about 700 - 900 Euro per kg.</p> <p><a href="https://i.stack.imgur.com/fqNar.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fqNar.png" alt="Natural colored PEEK filament samples"></a></p>
<p>My assumptions about PEEK filament price are:</p> <ul> <li>Raw material is more expensive. Compare price of <a href="https://www.alibaba.com/showroom/abs-pellet.html" rel="noreferrer">ABS</a> with <a href="https://www.alibaba.com/showroom/peek-pellet.html" rel="noreferrer">PEEK</a> pellets.</li> <li>Demand is much lower. There are not many printers able to print peek. If you manufacture PEEK filament you have to store a filament batch for longer time. Manufacturer has to calculate into price storage space, material degradation, ...</li> <li>Filament machine tuning. You have to tune filament extrude machine for PEEK, which takes time because it's a totally different plastic. Maybe there is a cleanup needed after finishing a batch and switching to another material.</li> <li>Working conditions. PEEK is quite smelly and I am not sure if you have to improve work conditions like better ventilation. </li> <li>Research costs. You have to distribute research costs to a filament production where demand is low. </li> </ul>
<p><strong>Patents</strong> still seem to play a role as well.</p> <p>I was curious about this question and did a bit of research: If you filter the <a href="https://patents.google.com/?q=%22Polyether%20ether%20ketone%22&amp;country=US&amp;after=priority:20100101" rel="noreferrer">U.S. patents after 2010 mentioning PEEK</a> and its various applications and improvements, you still get roughly 10,000 patents. Those are not all primarily patents for PEEK, but still.</p> <p>Even <em>Victrex PLC</em>, formerly named <em><a href="https://drakeplastics.com/peek/" rel="noreferrer">Imperial Chemical Industries</a></em>, who filed the <a href="https://register.epo.org/application?number=EP78300314&amp;tab=main" rel="noreferrer">first patent for PEEK back in 1978</a>, had a <a href="https://patents.justia.com/patent/20160208045" rel="noreferrer">patent published in 2016</a> for a new PEEK production procedure:</p> <blockquote> <p>The process can be used to produce high quality, relatively light coloured polymers having a lower Tm than those produced using a standard PEEK process.</p> </blockquote>
979
<p>Let's say the first N integers divisible by 3 starting with 9.</p> <p>I'm sure there is some one line solution using lambdas, I just don't know it that area of the language well enough yet.</p>
<p>Just to be different (and to avoid using a where statement) you could also do:</p> <pre><code>var numbers = Enumerable.Range(0, n).Select(i =&gt; i * 3 + 9); </code></pre> <p><strong>Update</strong> This also has the benefit of not running out of numbers.</p>
<p>I can't say this is any good, I'm not a C# expert and I just whacked it out, but I think it's probably a canonical example of the use of <code>yield</code>.</p> <pre><code>internal IEnumerable Answer(N) { int n=0; int i=9; while (true) { if (i % 3 == 0) { n++; yield return i; } if (n&gt;=N) return; i++; } } </code></pre>
9,302
<p>I am using python 3.6 with pySerial library to connect to the Hyrel System 30M 3D Printer. I am able to read the data from the device but unable to write any commands to it</p> <p>Here is the code:</p> <pre><code> ser = serial.Serial() ser.port = 'COM4' ser.baudrate = 38400 out = ser.readline() ser.write(b'M106 T14 S30\n') %This is the command to turn on the fan at 30% power </code></pre> <p>Can somebody suggest me how to write commands to printer through python</p>
<p>If the one in your question is your <em>complete</em> code, a possibility is that your computer is just buffering the output for the serial port, withholding it in memory. Try to add</p> <pre><code>ser.flush() </code></pre> <p>after your last line. This command will... well... <em>flush</em> anything into the buffer through the actual connection.</p>
<p>Sorry for the late answer, but with Repetrel v3 and later, we have the option for you to configure a secondary COM port, and relay G- or M-Code commands from your other source through the Repetrel software to the printer. Please contact us for assistance.</p> <p>Note: I work for Hyrel 3D.</p>
801
<p>My question is... Is there a SIMPLE/easy way to load TPU without tearing my printer apart to insert a hose that probably wont work anyways. It keeps curling up by the cog. I have read a few topics in other places but I didn't like the answers. Hoping you all might have a simple fix. </p>
<p>Loading TPU/TPE can be particularly challenging because many printer loading scripts run too fast for the soft flexible filament to effectively purge whatever normal filament you were using before. A couple tips:</p> <ul> <li>Load with a slightly higher temp than either the TPU or previous filament require, so as to minimize the melt viscosity and reduce the force required.</li> <li>Make a custom gcode file that contains a slower loading routine: wait for heat, then advance the extruder at a very slow rate for a long distance. Then you just "print" this gcode file whenever you need to load TPU.</li> </ul> <p>However, simply being able to load is not necessarily enough. <strong>Not all extruders can reliably print flexible filaments, period.</strong> The larger the gap between the pinch wheel and inlet to the hot end, the more likely the filament is to buckle and come out the side. You need to make sure this gap is as short as possible. If there is more than a couple mm of gap, you'll need to make gap-filler or print yourself a new extruder designed for flexibles.</p> <p>Printing slow and without major velocity changes can help, too. Use relatively low layer heights and low, constant feedrates so the extruder doesn't have to run fast or change pressure often. </p> <p>Harder flexible filaments will be easier to print if your setup is borderline. Ninjaflex is one of the hardest to print because it is relatively soft. Semi-flex type filaments are much easier to print if your hardware isn't set up optimally.</p>
<p>I've noticed that the first layer seems more prone to wrapping flexible filament around the drive, particularly if the nozzle is a bit on the low side. The extra extrusion force required to push the filament against the resistance of the bed means that the filament can't sustain enough pressure without folding. </p> <p>As a quick workaround for this, I lowered the extrusion multiplier to 60% on the fly for the first layer (as well as keeping the speed right down).</p>
347
<p>Have people been using 3D printing to genuinely create a number of needed objects in their homes, and if so, what? Or is 3D printing better for special niche interests like art projects, home engineering projects, etc?</p>
<p>Both.</p> <p>3D printing is especially useful for creating replacement parts for things for which it would otherwise be difficult, expensive, or impossible to obtain a conventionally manufactured one. You may have seen in the news recently the <a href="https://www.bbc.com/news/technology-51911070" rel="nofollow noreferrer">story about 3D printing being used to replace hospital ventilator valves</a> that were not available in time to save patients who needed them, and that normally cost \$11000 from the manufacturer. But the same kind of thing applies to regular household items too. For example, I've replaced broken wheels on my child's toy cars, a broken windshield washer fluid coupling in my car, and various similar things. I'm also planning to replace broken plastic wheel bearings in my vacuum cleaner (the manufacturer's design was atrociously bad and I'll probably adapt it to use real bearings with a 3D printed adapter), a window switch in my car, and lots of other things I can't remember at the moment.</p> <p>Of course you can do craft and hobby things too. I don't think this really calls for examples/evidence.</p>
<p>Both.</p> <p>3D printing is especially useful for creating replacement parts for things for which it would otherwise be difficult, expensive, or impossible to obtain a conventionally manufactured one. You may have seen in the news recently the <a href="https://www.bbc.com/news/technology-51911070" rel="nofollow noreferrer">story about 3D printing being used to replace hospital ventilator valves</a> that were not available in time to save patients who needed them, and that normally cost \$11000 from the manufacturer. But the same kind of thing applies to regular household items too. For example, I've replaced broken wheels on my child's toy cars, a broken windshield washer fluid coupling in my car, and various similar things. I'm also planning to replace broken plastic wheel bearings in my vacuum cleaner (the manufacturer's design was atrociously bad and I'll probably adapt it to use real bearings with a 3D printed adapter), a window switch in my car, and lots of other things I can't remember at the moment.</p> <p>Of course you can do craft and hobby things too. I don't think this really calls for examples/evidence.</p>
1,614
<p>I'm just looking for a simple, concise explanation of the difference between these two. MSDN doesn't go into a hell of a lot of detail here.</p>
<ul> <li><p><code>__declspec(dllexport)</code> tells the linker that you want this object to be made available for other DLL's to import. It is used when creating a DLL that others can link to.</p></li> <li><p><code>__declspec(dllimport)</code> imports the implementation from a DLL so your application can use it.</p></li> </ul> <p>I'm only a novice C/C++ developer, so perhaps someone's got a better explanation than I.</p>
<p>Dllexport is used to mark a function as exported. You implement the function in your DLL and export it so it becomes available to anyone using your DLL.</p> <p>Dllimport is the opposite: it marks a function as being imported from a DLL. In this case you only declare the function's signature and link your code with the library.</p>
8,244
<p>I've updated my Ender 3 with V4.2.7 mainboard, BLTouch and 400XL kit (extends the capabilities of your Creality Ender 3 3D Printer to a 400 mm X, 400 mm Y and a 500 mm Z printing platform). Now I need to update the firmware. YouTube did not provide any help: i.e.: out of date, so cryptic as to be unusable. Marlin &amp; Creality had overly complicated, for what I need, solutions. Trying these led only to frustrations! Any ideas?</p>
<p>Without knowing exactly which Youtube videos you've looked at, I think where I would start is by downloading the latest Marlin Fimrware and configuration files for the Ender 3 with 4.2.7 board:</p> <p><a href="https://github.com/MarlinFirmware/Marlin/archive/2.0.x.zip" rel="nofollow noreferrer">Latest Release of Marlin Firmware on Github</a></p> <p><a href="https://github.com/MarlinFirmware/Configurations/tree/release-2.0.7.2/config/examples/Creality/Ender-3%20V2" rel="nofollow noreferrer">Configuration File Repository on Github</a></p> <p><a href="https://code.visualstudio.com/download" rel="nofollow noreferrer">Microsoft visual Studio</a></p> <p><a href="https://platformio.org/install/ide?install=vscode" rel="nofollow noreferrer">PlatormIO</a></p> <p>If I were doing your upgrade in your place, I would refer to <a href="https://www.youtube.com/watch?v=neS7lB7fCww&amp;t=495s" rel="nofollow noreferrer">this video</a> for how to compile the firmware for the correct board. I've had to compile firmware for my Ender 3 a few times and I sometimes forget a step. This video is the best that I've found for showing/reminding me of each step.</p> <p>Essentially, what I think you need to do is compile your firmware as if it were a stock Ender 3 V2 using the settings files I linked above but then change your print area the configuration.h file to match the X400 x Y400 x Z500 print bed area.</p> <p>Look for the following:</p> <pre><code>// The size of the print bed #define X_BED_SIZE 200 #define Y_BED_SIZE 200 </code></pre> <p>Change to the following:</p> <pre><code>// The size of the print bed #define X_BED_SIZE 400 #define Y_BED_SIZE 400 </code></pre> <p>And then look for</p> <pre><code>#define Z_MAX_POS 200 </code></pre> <p>and change to:</p> <pre><code>#define Z_MAX_POS 500 </code></pre> <p>There are other changes you'd need to make to the settings file (refer to the video for those). I haven't done your particular upgrade on my machine, so I'm just guessing those extra couple of changes would work for you.</p>
<p>I've done the board upgrade on my Ender 3 Pro. As I've read the BLTouch is easy to install. I'd go over to the Creality <a href="https://forums.creality3dofficial.com/" rel="nofollow noreferrer">forum/help</a> site. You can open a support ticket. They actively have information on firmware in both &quot;release&quot; and &quot;beta&quot; threads. Look there &amp; see if you can get your answers.</p>
1,901
<p>I know this is a broad question, but I've inherited several poor performers and need to optimize them badly. I was wondering what are the most common steps involved to optimize. So, what steps do some of you guys take when faced with the same situation?</p> <blockquote> <p>Related Question:<br> <a href="https://stackoverflow.com/questions/39331/what-generic-techniques-can-be-applied-to-optimize-sql-queries">What generic techniques can be applied to optimize SQL queries?</a></p> </blockquote>
<ol> <li>Look at the execution plan in query analyzer</li> <li>See what step costs the most</li> <li>Optimize the step!</li> <li>Return to step 1 [thx to <strong>Vinko</strong>]</li> </ol>
<p>Look at the indexes on the tables that make the query. An indexes may be needed on particular fields that participate in the where clause. Also look at the fields used in the joins in the query (if joins exist). If indexes already exist, look at the type of index. </p> <p>Failing that (because there are negatives to using locking hints) Look at locking hints and explicitly naming the index to use in the join. Using NOLOCKS is more obvious if you're getting a lot of deadlocked transactions.</p> <p>Do what roman and Andy S mentioned first though.</p>
8,612
<p>A while ago bought a Bowden extruder to replace the old built-in one (It was malfunctioning or something that I cannot remember well). This one in particular has been acquired:</p> <p><a href="https://i.stack.imgur.com/LF28s.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LF28s.jpg" alt="The extruder set"></a></p> <p>The thing is, that almost a year has passed since the printer did something rather than getting jammed and not work properly. The extruder itself seems to work properly, when I heats up and push the filament by hand seems to pass properly.</p> <p>When assembled and start to print, the printer at first seems to work, but after a minute or so, it stops extruding (gets jammed or something).</p> <p>The last time that I removed the filament and I've found out that it was coiled inside (Very strange):</p> <p><a href="https://i.stack.imgur.com/wBjnr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wBjnr.jpg" alt="Coiled ugly deformed filament"></a></p> <p>My first thought was that the filament was thinner than the extruder's specs, but the seller says that is for 1.75mm, and all my filaments have that diameter.</p> <p>What I am missing? Something maybe that is not properly mounted?</p> <p>The product is not official, bought on Amazon (I didn't know about e3d v6).</p> <p>Printing temperature should be 180ºC but I've seen now that Cura sets the first layers to print at 200ºC. Material: PLA</p> <p>My printer is a <a href="https://www.bq.com/en/support/prusa/support-sheet" rel="nofollow noreferrer">BQ Prusa i3 Hephestos</a>.</p>
<p>As long as there is no more information about the printer itself (I searched a bit and around half of buyers were severely unhappy with the result), I'd advise you to make a full check of all of the important parts that make up a 3D printer making ok prints:</p> <ul> <li>Are motors moving as they should?</li> <li>Is the extruder actually extrude filament when told so (do the check "2cm" = 2cm extruded)?</li> <li>Is the Z calibration ok (&lt;- VERY important, will make tons of weird problems if extruder is too close to the bed, believe me, don't skip out on this one. A blue tape or not a blue tape makes a world of difference).</li> </ul> <p>Also of course check your filament (no variations too big of the diameter).</p> <p>For the temperature, IMO go for the higher for starters (maybe no, see "heat creep" below), you won't be able to bridge / less good quality etc. but you'll get pieces done.</p> <p>NOW, the image you posted shows a twisted (I don't know how to handle that) or a grinded filament.</p> <p>When I say 'grinded' I mean that the filament got stuck somewhere (see below) and the (cogged) wheel pushing the filament is so strong that is grinds off plastic from it, forming waves on the filament. Eating away parts so it looks like your photo.</p> <p>If that's the case, then you should check out "heat creep", it's basically the heat in the lowest part of the extruder (the thing you call a bowden extruder) will heat up the filament and make it melt Above the heat block, making a blob of half melt plastic stopping the forward movement of the filament. This is usually mitigated by two things, that lacks more or less in cheap chinese knock offs: * The fan and it's cooling efficiency (the fan must blow when the heat block is hot, even if there is no printing going on. Even if the heat block is no longer heating. I shut the fan off at around 60°C). * The Heat break: if it's heavy it will conduct too much heat, if it's thin it might work but will break easily.</p> <p>3D Printing is not obvious or easy, but spend some time and it'll start to work well!</p> <p>Cheers</p>
<p>If you converted a printer from direct to Bowden feed, it is possible that the cold side of the hot end is too hot, and you are suffering from heat creap. Simple, less expensive printers often use the extruder stepper and the extruder stepper mount as part of the cooling system.</p> <p>If there is any sort of a heat-sink on the cold side of the hot-end, try to rig a fan to blow through the heat sink. If there isn't a heat sink, find one and add it. Heat sinks made for round transistor cases can sometime be fitted to the cold side. A little heat sink great, a couple of transistor heat sinks, and a fan may completely solve your problem.</p>
1,119
<p>My <code>master</code> and <code>development</code> branches are tracked remotely on <a href="http://en.wikipedia.org/wiki/GitHub" rel="noreferrer">GitHub</a>. How do I clone both these branches?</p>
<p>First, clone a remote <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> repository and <a href="http://en.wikipedia.org/wiki/Cd_%28command%29" rel="noreferrer"><code>cd</code></a> into it:</p> <pre><code>$ git clone git://example.com/myproject $ cd myproject </code></pre> <p>Next, look at the local branches in your repository:</p> <pre><code>$ git branch * master </code></pre> <p>But there are other branches hiding in your repository! See these using the <code>-a</code> flag:</p> <pre><code>$ git branch -a * master remotes/origin/HEAD remotes/origin/master remotes/origin/v1.0-stable remotes/origin/experimental </code></pre> <p>To take a quick peek at an upstream branch, check it out directly:</p> <pre><code>$ git checkout origin/experimental </code></pre> <p>To work on that branch, create a local tracking branch, which is done automatically by:</p> <pre><code>$ git checkout experimental Branch experimental set up to track remote branch experimental from origin. Switched to a new branch 'experimental' </code></pre> <p>Here, &quot;new branch&quot; simply means that the branch is taken from the index and created locally for you. As the <em>previous</em> line tells you, the branch is being set up to track the remote branch, which usually means the origin/branch_name branch.</p> <p>Your local branches should now show:</p> <pre><code>$ git branch * experimental master </code></pre> <p>You can track more than one remote repository using <code>git remote</code>:</p> <pre><code>$ git remote add win32 git://example.com/users/joe/myproject-win32-port $ git branch -a * master remotes/origin/HEAD remotes/origin/master remotes/origin/v1.0-stable remotes/origin/experimental remotes/win32/master remotes/win32/new-widgets </code></pre> <p>At this point, things are getting pretty crazy, so run <code>gitk</code> to see what's going on:</p> <pre><code>$ gitk --all &amp; </code></pre>
<p>If you use Bitbucket, you can use <strong>import Repository</strong>. This will import all Git history (all the branches and commits).</p>
9,325
<p>I'm writing a web service, and I want to return the data as XHTML. Because it's data, not markup, I want to keep it very clean - no extra <code>&lt;div&gt;</code>s or <code>&lt;span&gt;</code>s. However, as a convenience to developers, I'd also like to make the returned data reasonably readable in a browser. To do so, I'm thinking a good way to go about it would be to use CSS. </p> <p>The thing I specifically want to do is to insert linebreaks at certain places. I'm aware of <code>display: block</code>, but it doesn't really work in the situation I'm trying to handle now - a <code>form</code> with <code>&lt;input&gt;</code> fields. Something like this: </p> <pre><code>&lt;form&gt; Thingy 1: &lt;input class="a" type="text" name="one" /&gt; Thingy 2: &lt;input class="a" type="text" name="two" /&gt; Thingy 3: &lt;input class="b" type="checkbox" name="three" /&gt; Thingy 4: &lt;input class="b" type="checkbox" name="four" /&gt; &lt;/form&gt; </code></pre> <p>I'd like it to render so that each label displays on the same line as the corresponding input field. I've tried this: </p> <pre class="lang-css prettyprint-override"><code>input.a:after { content: "\a" } </code></pre> <p>But that didn't seem to do anything. </p>
<p>It'd be best to wrap all of your elements in label elements, then apply css to the labels. The :before and :after pseudo classes are not completely supported in a consistent way.</p> <p>Label tags have a lot of advantages including increased accessibility (on multiple levels) and more.</p> <pre><code>&lt;label&gt; Thingy one: &lt;input type="text" name="one"&gt;; &lt;/label&gt; </code></pre> <p>then use CSS on your label elements...</p> <pre class="lang-css prettyprint-override"><code>label {display:block;clear:both;} </code></pre>
<p>Use javascript. If you're using the jQuery library, try something like this:</p> <pre><code>$("input.a").after("&lt;br/&gt;") </code></pre> <p>Or whatever you need.</p>
9,150
<p>What, if any, considerations (HTML, CSS, JavaScript) should you take when designing for Google Chrome? </p>
<p>Chrome uses Webkit, the same engine as is used by Safari, OmniWeb, iCab and more. Just code everything based on the standards and verify in each browser.</p>
<p>Are you designing specifically <em>for</em> Chrome, or do you want to make sure your pages work well with Chrome?</p> <p>Assuming it's the latter, then just use the same design considerations you'd do for any browser. If applicable, keep in mind that many phones and video game consoles have web browsers now.</p> <p>Chrome uses a new JavaScript engine, so you'll have to test your JavaScript using Chrome as well as Safari. The HTML and CSS may render pretty much the same, but they use different JavaScript engines.</p>
6,785
<p>I'm looking for a Java profiler that works well with the JVM coming with WebSphere 6.0.2 (IBM JVM 1.4.2). I use yourkit for my usual profiling needs, but it specifically refuses to work with this old jvm (I'm sure the authors had their reasons...).</p> <p>Can anybody point to a decent profiler that can do the job? Not interested in a generic list of profilers, BTW, I've seen the other stackoverflow theread, but I'd rather not try them one by one.</p> <p>I would prefer a free version, if possible, since this is a one-off need (I hope!) and I would rather not pay for another profiler just for this. </p>
<p>Update: I found out that <a href="http://www.ej-technologies.com/products/jprofiler/overview.html" rel="nofollow noreferrer">JProfiler</a> integrates smoothly with WAS 6.0.2 (IBM JDK 1.4). </p>
<p>What are you looking to profile? Is it stuff in the JVM or the App Server? If it's the latter, there's loads of stuff in WAS 6 GUI to help with this. Assuming you really want to see stuff like the heap etc, then the IBM <a href="http://alphaworks.ibm.com/tech/heapanalyzer" rel="nofollow noreferrer">HeapAnalyzer</a> might help. There are other tools listed off the bottom of this page.</p> <p>Something else I've learned, ideally, youll be able to connect your IDE's profiler to the running JVM. Some let you do this to a remote one as well as the local one you are developing on. Is the JVM you wish to profile in live or remote? If so, you might have to force dumps and take them out of the live environment to look at at your leisure. Otherwise, set up something local and get the info from it that way. </p>
8,711
<p>Sometimes I use a DIY 3D printer running Marlin firmware and I have a hard time to set my heat bed temperature. when I set it to 70&nbsp;&deg;C for PLA, after a few minutes it decreases to 67&nbsp;&deg;C and I see these error:</p> <pre><code>READ: Error:Thermal Runaway, system stopped! Heater_ID: bed READ: Error:Printer halted. kill() called! </code></pre> <p>Since then the communication with printer is lost, the printing process stops and I have to reconnect to serial port... It's a disaster. I guess I need to lower the sensitivity to 3 degrees at least. I don't know how!?</p>
<p>I had a similar issue when printing with ABS, because my print cooling fan only activated once it got to a certain height above the bed. I'd say you need to do a PID tuning session, insulate the bottom of the bed better, and see if you can make sure your cooling fan doesn't blow air over the bed itself.</p>
<p>I had a similar issue when printing with ABS, because my print cooling fan only activated once it got to a certain height above the bed. I'd say you need to do a PID tuning session, insulate the bottom of the bed better, and see if you can make sure your cooling fan doesn't blow air over the bed itself.</p>
1,305
<p>Does anyone know of an easy way to escape HTML from strings in <a href="http://jquery.com/" rel="noreferrer">jQuery</a>? I need to be able to pass an arbitrary string and have it properly escaped for display in an HTML page (preventing JavaScript/HTML injection attacks). I'm sure it's possible to extend jQuery to do this, but I don't know enough about the framework at the moment to accomplish this.</p>
<p>Since you're using <a href="https://jquery.com/" rel="noreferrer">jQuery</a>, you can just set the element's <a href="http://api.jquery.com/text/" rel="noreferrer"><code>text</code></a> property:</p> <pre><code>// before: // &lt;div class="someClass"&gt;text&lt;/div&gt; var someHtmlString = "&lt;script&gt;alert('hi!');&lt;/script&gt;"; // set a DIV's text: $("div.someClass").text(someHtmlString); // after: // &lt;div class="someClass"&gt;&amp;lt;script&amp;gt;alert('hi!');&amp;lt;/script&amp;gt;&lt;/div&gt; // get the text in a string: var escaped = $("&lt;div&gt;").text(someHtmlString).html(); // value: // &amp;lt;script&amp;gt;alert('hi!');&amp;lt;/script&amp;gt; </code></pre>
<p><a href="https://stackoverflow.com/a/10825766/819417">This answer</a> provides the jQuery and normal JS methods, but this is shortest without using the DOM:</p> <pre><code>unescape(escape("It's &gt; 20% less complicated this way.")) </code></pre> <p>Escaped string: <code>It%27s%20%3E%2020%25%20less%20complicated%20this%20way.</code></p> <p>If the escaped spaces bother you, try:</p> <pre><code>unescape(escape("It's &gt; 20% less complicated this way.").replace(/%20/g, " ")) </code></pre> <p>Escaped string: <code>It%27s %3E 20%25 less complicated this way.</code></p> <p>Unfortunately, the <code>escape()</code> function was <a href="http://www.w3schools.com/jsref/jsref_escape.asp" rel="nofollow noreferrer">deprecated in JavaScript version 1.5</a>. <code>encodeURI()</code> or <code>encodeURIComponent()</code> are alternatives, but they ignore <code>'</code>, so the last line of code would turn into this:</p> <pre><code>decodeURI(encodeURI("It's &gt; 20% less complicated this way.").replace(/%20/g, " ").replace("'", '%27')) </code></pre> <p>All major browsers still support the short code, and given the number of old websites, i doubt that will change soon.</p>
4,445
<p>For example; with the old command prompt it would be:</p> <pre><code>cmd.exe /k mybatchfile.bat </code></pre>
<p>Drop into a cmd instance (or indeed PowerShell itself) and type this:</p> <pre><code>powershell -? </code></pre> <p>You'll see that powershell.exe has a "-noexit" parameter which tells it not to exit after executing a "startup command".</p>
<p>I am sure that you already figure this out but I just post it</p> <pre><code>$CreateDate = (Get-Date -format 'yyyy-MM-dd hh-mm-ss') $RemoteServerName ="server name" $process = [WMICLASS]"\\$RemoteServerName\ROOT\CIMV2:win32_process" $result = $process.Create("C:\path to a script\test.bat") $result | out-file -file "C:\some path \Log-$CreatedDate.txt" </code></pre>
3,507
<p>It's pretty manageable right now due to the low question rate, but I think maybe ~3% of all questions this site will get, forever, will be "what's the best printer" or "what printer should I buy" type questions. They're mostly coming from people who don't know enough about 3DP to articulate their requirements, so they're difficult to help and very unfocused. Is there a better way to handle this than locking them as they come up? </p>
<p>A good option would be to have several reference questions, such as "What to look for when comparing printers?" or "How to select a 3D printer?" to which we could redirect these users.</p>
<p>I face this question very very frequently. On 3d printing and 3d printing hobbyists facebook group we can see this daily. </p> <p>The ideas of giving people a catch all set of questions is nice.. That is exactly what I did 6 months ago. I put it in the group rules and did everything I could to get people to read it. To date 0 people, even after directly being told to, have used my list of questions.</p> <p>In my opinion we need to educate the user, nicely. Also we need to remove the question with flagging. Hopefully without offending the person and thus scaring them away from the community.. Maybe just flag as duplicate, etc. Unfortunately this will one of those situations where we cannot perfectly solve. </p>
31
<p>I'm working on a project with will be buried in soil. It's an enclosure for a sensor that will be potted inside the 3D printed part. What filament will give me the longest life in soil? </p> <p>ETA: burial will be permanent, and I'd like it to last at least five years.</p> <p>ETA: The printed part will provide mechanical support for the sensor, so it needs to retain most of its mechanical properties.</p>
<p>I would recommend PETG - only because it is structurally similar to the plastic used in the bottles that last forever, and most PETG is food grade - implying that its chemical stability should be reasonably good...</p>
<p>If TPU ends up not being rigid enough for you: I've had good enough luck with ABS coated in automotive RTV.</p> <p>Thing with ABS though is that it's a special (not so)"solid" that gets softer as it gets hotter. My use had water in it when warm so wasn't too much of an issue, and it never experienced freezing temperatures.</p> <p>Also it hasn't been 5 years yet. ~2 years and counting.</p>
1,649
<p>Long story short, my wife and I are now the proud owners of an AnyCubic D, also known as the Predator. This is not our first 3D printer, but it is our first "delta" design, with the circular build plate and the extruder suspended by stepper-controlled tie rods (as opposed to the IMO more intuitive Cartesian designs like the MakerBot R2X and Ender 3 Pro we already have). </p> <p>Got it all put together last night and ran all the basic setups including an auto bed leveling. This feature is both a blessing and a curse. It's a blessing because the actual leveling is a matter of fitting the probe, hitting a button and walking away as it maps the build plate, and the results in terms of a consistent extrusion thickness around the plate are excellent each and every time.</p> <p>It's a curse because the printer <em>depends</em> on auto-leveling due to the build plate being bolted directly to the base; with no manual adjustment possible, probing is the only form of leveling you can do, and that leveling is dependent on an accurate "zeroing" of the extruder above the center of the plate, which has to be done using the steppers to bring the extruder down from "home" to the typical paper-thin clearance over the plate surface.</p> <p>Thus the problem; the zeroing procedure has a minimum adjustment of 0.1mm. Getting the clearance <em>just right</em> for a solid first layer requires at least another order of magnitude finer adjustment. For now, I have it "good enough" to stick the first layer onto the plate, but the resulting prints show pretty classic plate clearance issues:</p> <p><a href="https://i.stack.imgur.com/iOVKz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iOVKz.jpg" alt="enter image description here"></a></p> <p>You can see the lines of the bottom layer aren't connecting horizontally, and the extrusions are thin and tubular, which are the textbook symptoms of excessive build plate clearance (not enough "squish" of the filament between extruder and plate). It's close, but this is a game of just tens of microns, and the printer simply does not give me that level of control; one more step down at 0.1mm and I hit the plate. The manual says you can babystep the Z offset at 0.04mm while actually running a print, but I have run several (including the leveling test GCode included on the printer's SD card) and have never seen that option enabled in the leveling menu.</p> <p>I was wondering if there were any AnyCubic D/Predator owners with insight into how they really dial in the proper zero height on these printers. I do have Cura's features to work with; theoretically I could send a relative-positioned <code>G0 Z-0.04 F100</code> command from its remote control panel as the last step down in zero height adjustment (assuming the printer is listening to USB input while running the leveling procedure), or I could put a similar command in the start Gcode followed by a <code>G92 Z0</code> which will re-zero the extruder height at the new level (assuming the printer accepts a relative move below its known zero; Marlin 1.1.0 actively prevents that, but indications are the AnyCubic firmware is proprietary, so who knows). I could also leave the extruder height as-is and bump Cura's first layer flow rate setting in the material profile, to push more filament into the taller space on the first layer and so get more squish. </p> <p>However, none of these strike me as something I should <em>have</em> to do to dial in a printer, given that extruder clearance is a problem trivially solved on either of the other printers, and these fairly kludgy fixes would have to be repeated every time the bed was re-leveled (such as after any disassembly for maintenance or any move to a new location, including one beyond USB cable distance of the slicing computer).</p>
<p>I recently corrected a similar problem on a Robo3D R1+ printer. It is described as the z-offset setting.</p> <p>An entry in the <a href="https://www.thingiverse.com/groups/anycubic-predator/forums/bigtreetech-skr-v13-tmc2280-swap/topic:41518" rel="nofollow noreferrer">Thingiverse forum</a> appears to reference this problem as well. The sensor provides reference information to the board, but the compensation is not always as it should be.</p> <p>For the Robo, the command sequence was M565 Z0.7 in this specific instance, followed by M500 to store the value.</p> <p>I'm not certain this is the answer for the Predator as the above is specific to the Robo3d.</p> <p>An <a href="https://3dprinting.stackexchange.com/questions/7264/how-to-set-the-z-home-offset">answer in this SE</a> suggests that one can use M206 Zxx followed by the M500 storage command.</p> <p>Further research regarding the z-offset for your particular board is warranted.</p>
<p>The owners manual tells how to micro adjust the z while it is printing the 1st layer. See page 23. I did this and it works perfectly.</p>
1,553
<p>I know in JavaScript, <em>objects</em> double as hashes, but I have been unable to find a built-in function to get the keys:</p> <pre><code>var h = {a:'b', c:'d'}; </code></pre> <p>I want something like</p> <pre><code>var k = h.keys() ; // k = ['a', 'c']; </code></pre> <p>It is simple to write a function myself to iterate over the items and add the keys to an array that I return, but is there a standard cleaner way to do that?</p> <p>I keep feeling it must be a simple built in function that I missed but I can't find it!</p>
<p>There is function in modern JavaScript (ECMAScript 5) called <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys" rel="noreferrer"><code>Object.keys</code></a> performing this operation:</p> <pre><code>var obj = { "a" : 1, "b" : 2, "c" : 3}; alert(Object.keys(obj)); // will output ["a", "b", "c"] </code></pre> <p>Compatibility details can be found <a href="http://kangax.github.com/es5-compat-table/" rel="noreferrer">here</a>. </p> <p>On the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys" rel="noreferrer">Mozilla site</a> there is also a snippet for backward compatibility:</p> <pre><code>if(!Object.keys) Object.keys = function(o){ if (o !== Object(o)) throw new TypeError('Object.keys called on non-object'); var ret=[],p; for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p); return ret; } </code></pre>
<p>If you are trying to get the elements only, but not the functions then this code can help you:</p> <pre><code>this.getKeys = function() { var keys = new Array(); for (var key in this) { if (typeof this[key] !== 'function') { keys.push(key); } } return keys; } </code></pre> <p>This is part of my implementation of the HashMap and I only want the keys. <code>this</code> is the hashmap object that contains the keys.</p>
3,941
<p>Most of my C/C++ development involves monolithic module files and absolutely no classes whatsoever, so usually when I need to make a <strong>DLL</strong> with accessible functions I just export them using the standard <code>__declspec(dllexport)</code> directive. Then access them either dynamically via <code>LoadLibrary()</code> or at compile time with a header and lib file. </p> <p>How do you do this when you want to export an entire class (and all it's public methods and properties)?</p> <p>Is it possible to dynamically load that class at runtime and if so, how?</p> <p>How would you do it with a header and lib for compile time linking?</p>
<blockquote> <p>What about late-binding? As in loading it with LoadLibrary() and GetProcAddress() ? I'm used being able to load the library at run time and it would be great if you could do that here.</p> </blockquote> <p>So there are two ways to load the DLL. The first is to reference one or more symbols from the DLL (your classname, for example), supply an appropriate import .LIB and let the linker figure everything out.</p> <p>The second is to explicitly load the DLL via LoadLibrary.</p> <p>Either approach works fine for C-level function exports. You can either let the linker handle it or call GetProcAddress as you noted.</p> <p>But when it comes to exported <strong>classes</strong>, typically only the first approach is used, i.e., implicitly link to the DLL. In this case the DLL is loaded at application start time, and the application fails to load if the DLL can't be found.</p> <p>If you want to link to a class defined in a DLL, and you want that DLL to be loaded dynamically, sometime after program initiation, you have two options:</p> <ol> <li><p>Create objects of the class using a special factory function, which internally will have to use (a tiny bit of) assembler to "hook up" newly created objects to their appropriate offsets. This has to be done at run-time AFTER the DLL has been loaded, obviously. A good explanation of this approach can be found <a href="http://www.codeproject.com/KB/DLL/classesexportedusingLL.aspx" rel="noreferrer">here</a>.</p></li> <li><p>Use a <a href="http://msdn.microsoft.com/en-us/library/151kt790.aspx" rel="noreferrer">delay-load DLL</a>.</p></li> </ol> <p>All things considered... probably better to just go with implicit linking, in which case you definitely want to use the preprocessor technique shown above. In fact, if you create a new DLL in Visual Studio and choose the "export symbols" option these macros will be created for you.</p> <p>Good luck...</p>
<p>If you're willing to put a vtable in the class you're exporting, you can export a function that returns an interface and implement the class in the .dll, then put that in the .def file. You might have to do some declaration trickery, but it shouldn't be too hard.</p> <p>Just like COM. :)</p>
4,766
<p>I have an old Solidoodle 2 that I bought broken from a garage sale that I am converting to use RAMPS 1.4 with Marlin Firmware. All the motors work correctly, I am just having issues getting the endstops to work.<br><br> </p> <p>I am using a regular limit switch with NC going to the signal pin and the other to ground. I have this switch plugged into first header column for X-min. My endstop configuration is currently:<br></p> <pre><code>//=========================================================================== //============================== Endstop Settings =========================== //=========================================================================== // @section homing // Specify here all the endstop connectors that are connected to any endstop or probe. // Almost all printers will be using one per axis. Probes will use one or more of the // extra connectors. Leave undefined any used for non-endstop and non-probe purposes. #define USE_XMIN_PLUG true #define USE_YMIN_PLUG true #define USE_ZMIN_PLUG true //#define USE_XMAX_PLUG false //#define USE_YMAX_PLUG false //#define USE_ZMAX_PLUG false // coarse Endstop Settings #define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors #if DISABLED(ENDSTOPPULLUPS) // fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined //#define ENDSTOPPULLUP_XMAX //#define ENDSTOPPULLUP_YMAX //#define ENDSTOPPULLUP_ZMAX //#define ENDSTOPPULLUP_XMIN //#define ENDSTOPPULLUP_YMIN //#define ENDSTOPPULLUP_ZMIN //#define ENDSTOPPULLUP_ZMIN_PROBE #endif // Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). #define X_MIN_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop. #define Y_MIN_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MIN_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define X_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Y_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop. </code></pre> <p>I have X-min enabled and inverted. When I send an M119 (endstop status code) I recieve:</p> <pre><code>Send: M119 Recv: Reporting endstop status Recv: x_min: open Recv: y_min: TRIGGERED Recv: z_min: TRIGGERED </code></pre> <p>And then when I press down the X endstop with my hand I get:</p> <pre><code>Send: M119 Recv: Reporting endstop status Recv: x_min: open Recv: y_min: TRIGGERED Recv: z_min: TRIGGERED </code></pre> <p>-No change. There is no mechanical failure with the switches, I've tested it with a continuity tester. I have even shorted the signal and ground pins on the Ramps board with a jumper wire and I still haven't seen any change.</p> <p>Where is the fault at?</p>
<p>try uncommenting the following lines to enable endstop detection on all pins for troubleshooting.</p> <pre><code>//#define USE_XMAX_PLUG false //#define USE_YMAX_PLUG false //#define USE_ZMAX_PLUG false </code></pre> <p>This way the M119 will show any changes.</p> <p>The only thing I can think of is that either the switch is plugged into the wrong pin on the ramps board (Max instead of Min) or the switch doesn't require the pullup (your could try commenting that back as a second test as well)</p>
<p>Yesterday I has same error with board MKS Robin Nano with Marlin 2.0.6.</p> <p>Try to find and uncomment this definition:</p> <pre><code>#define ENDSTOP_INTERRUPTS_FEATURE </code></pre> <p>Failure was in disabled endstop interrupts and broken part of code, which going to home and unchecks endstop status between steps. But if you activated endstop before sending homing command - it will work as needed.</p>
418
<p>Using cyanoacrylate to glue PLA parts sometimes leaves a white residue or haze near the glue locations. Is there an easy way to remove it?</p> <p>I've tried water and alcohol swabs but after drying the haze remains.</p> <p><a href="https://i.stack.imgur.com/cw1pu.jpg" rel="nofollow noreferrer" title="Photo showing white residue"><img src="https://i.stack.imgur.com/cw1pu.jpg" alt="Photo showing white residue" title="Photo showing white residue" /></a></p>
<h2>Make sure to set the scale properly for your use case!</h2> <p>In CAD, you define your measurement space in either Inch or in Millimeter units, and that is your grid. In blender, the native unit is the meter.</p> <p>This can be easily converted in exporting (remember to set it to scale!), but it is best to just set the measurement scale to actually match what you design: if you want to design a 5 mm hole, set your scale to Millimeters and make sure you export in millimeters. If you want to design in meters (maybe you design a building), then work in meters, and set your export scale in the end so that 1 meter actually is represented as 1 meter - or rather as 1000 millimeters.</p> <p><a href="https://3dprinting.stackexchange.com/a/7561/8884">The STL in the end will not know the difference</a>: it all is defined in scales of <em>unitary units</em>, and it doesn't even know if it was originally designed in meters, inch or angström. The typical slicer expects the unit to be either millimeters or inch, so any scaling of the exported model that does not result in units equivalent to 1 mm or 24.5 mm is bad procedure - converting between these two types is just scaling the model by 2450%.</p> <h2>Make sure to design closed manifolds made up of triangles!</h2> <p>When working with blender, it is very easy to leave the item in a shape that contains multiple intersecting, non-manifold surfaces and areas of inverted surfaces. While <em>interecting shells</em> is not a problem (the slicers can handle those by unionizing the item), the intersection usually covers up the non-manifold areas, making them hard to spot.</p> <p>As a result, before finalizing your project, I suggest follow this procedure:</p> <ul> <li>In Blender, turn on the visual for the normals of surfaces. If an area does not look like a hedgehog after that, the normals in that area are reversed and you need to flip the surfaces there or re-mesh it.</li> <li>Triangulate the surface using the triangulate modifier. This is to spot artifacts from conversion to STL early and be able to fix them: STL only knows triangles, while blender knows <em>bent</em> n-gons.</li> <li>Add a new object. A cube with side length 1.</li> <li>Do a test export to STL with scale 1, which also contains the 1-unit cube as an extra shell.</li> <li>Import the model into a software such as meshmixer, that has a command to separate shells.</li> <li>Separate the item to all shells. In Meshmixer this is in analyze, separate shells.</li> <li>After separating the shells, measure your 1-unit cube. If it is not 1 mm, calculate your scaling factor. It should be a multiple of 10.</li> <li>Next, you should check each shell for gaps or other errors. In meshmixer, the automatic analyze feature points to these areas with red, blue and magenta lines.</li> <li>Fix the marked errors in blender, then return to the test export. This time use the proper scaling factor. Repeat until no errors remain.</li> </ul>
<p>It doesn't matter, you scale it in the slicer or elsewhere. You're not going to slice the STL file in Blender. You'll probably need to do more work to get things print ready outside blender anyway.</p> <p>So when I use blender I don't even bother checking what units it's using. I don't use it for parts design or tech drawing.</p>
2,123
<p>I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a maximum with of 20 characters, there GUIs should automatically constrain the user from typing more than 20 characters in a related form field.</p> <p>And I have strong antipathy to ORMs which want to define my database tables, or are based on some hack where every table needs to have extra numeric ID columns because of the ORM.</p> <p>I've looked a bit into Python database frameworks and I think I can conclude the SQLAlchemy fits best to my mentality.</p> <p>Now, I need to find a web application framework which fits naturally with SQLAlchemy (or an equivalent) and perhaps even with my appetite for coupling. With "web application framework", I mean products/project such as Pyhons, Django, TurboGears, web2py, etc.</p> <p>E.g., it should ideally be able to:</p> <ul> <li><strong>automatically select a suitable form widget</strong> for data entering a given column if told to do so; e.g., if the column has a foreign key to a column with 10 different values, widget should display the 10 possible values as a dropdown</li> <li><strong>auto-generate javascript form validation code</strong> which gives the end-user quick error feedback if a string is entered into a field which is about to end up in an INTEGER column, etc</li> <li>auto-generate a <strong>calendar widget</strong> for data which will end up in a DATE column</li> <li><strong>hint NOT NULL constraints</strong> as javascript which complains about empty or whitespace-only data in a related input field</li> <li>generate javascript validation code which matches relevant (simple) <strong>CHECK-constraints</strong></li> <li>make it easy to <strong>avoid SQL injection</strong>, by using prepared statements and/or validation of externally derived data</li> <li>make it easy to <strong>avoid cross site scripting</strong> by automatically escape outgoing strings when appropriate</li> <li><strong>make use of constraint names</strong> to generate somewhat user friendly error messages in case a constrataint is violated</li> </ul> <p>All this should happen dynamically, so table adjustments are automatically reflected on the frontend - probably with a caching mechanism, so that all the model introspection wouldn't kill performance. In other words, I don't want to repeat my model definition in an XML file (or alike) when it has already been carefully been defined in my database.</p> <p>Does such a framework exist for Python (or for any language, for that matter)? If not: Which of the several Python web application frameworks will be least in the way if I were to add parts of the above features myself?</p>
<p>web2py does most of what you ask:</p> <p>Based on a field type and its validators it will render the field with the appropriate widget. You can override with</p> <pre><code>db.table.field.widget=... </code></pre> <p>and use a third party widget.</p> <p>web2py has js to blocks the user from entering a non-integer in a integer field or a non-double in a double field. time, date and datetime fields have their own pickers. These js validation work with (not instead) of server side validation.</p> <p>There is <code>IS_EMPTY_OR(...)</code> validator.</p> <p>The DAL prevents SQL injections since everthing is escaped when goes in the DB.</p> <p>web2py prevents XSS because in {{=variable}}, 'variable' is escaped unless specified otherwise {{=XML(variable)}} or {{=XML(variable,sanitize=True)}}</p> <p>Error messages are arguments of validators for example</p> <pre><code>db.table.field.requires=IS_NOT_EMPTY(error_message=T('hey! write something in here')) </code></pre> <p>T is for internationalization.</p>
<p>I believe that Django models does not support composite primary keys (see <a href="http://docs.djangoproject.com/en/dev/topics/db/models/#automatic-primary-key-fields" rel="nofollow noreferrer">documentation</a>). But perhaps you can use SQLAlchemy in Django? A <a href="http://www.google.com/search?q=sqlalchemy+django" rel="nofollow noreferrer">google search</a> indicates that you can. I have not used Django, so I don't know.</p> <p>I suggest you take a look at:</p> <ul> <li><a href="http://toscawidgets.org/" rel="nofollow noreferrer">ToscaWidgets</a></li> <li><a href="http://code.google.com/p/dbsprockets/" rel="nofollow noreferrer">DBSprockets</a>, including <a href="http://code.google.com/p/dbsprockets/wiki/DBMechanic" rel="nofollow noreferrer">DBMechanic</a></li> <li><a href="http://www.checkandshare.com/catwalk/" rel="nofollow noreferrer">Catwalk</a>. Catwalk is an application for TurboGears 1.0 that uses SQLObject, not SQLAlchemy. Also check out this <a href="http://www.checkandshare.com/blog/?p=41" rel="nofollow noreferrer">blog post</a> and <a href="http://www.checkandshare.com/CATWALK2/lview/index.html" rel="nofollow noreferrer">screencast</a>.</li> <li><a href="http://docs.turbogears.org/1.0/DataController" rel="nofollow noreferrer">FastData</a>. Also uses SQLObject.</li> <li><a href="http://code.google.com/p/formalchemy/" rel="nofollow noreferrer">formalchemy</a></li> <li><a href="http://rumdemo.toscawidgets.org/" rel="nofollow noreferrer">Rum</a></li> </ul> <p>I do not have any deep knowledge of any of the projects above. I am just in the process of trying to add something similar to one of my own applications as what the original question mentions. The above list is simply a list of interesting projects that I have stumbled across.</p> <p>As to web application frameworks for Python, I recommend TurboGears 2. Not that I have any experience with any of the other frameworks, I just like TurboGears...</p> <p>If the original question's author finds a solution that works well, please update or answer this thread.</p>
6,498
<p><em><strong>TL;DR</strong> - Please help me rebuild my CR-6 SE so that I can move on</em></p> <hr /> <p>Here's a link to the latest issue that I had to make proof of in a video: <a href="https://youtu.be/9vChL7Il_9Y" rel="nofollow noreferrer">CR6-SE failed</a></p> <p>Basically, it's failing to reach/maintain temperature (set point of 240 °C, fails to heat above 230 °C), issues start to happen at temps as low as 210 °C. Creality support is evasive/dodgy. First, they want to see a video proof for the problem reported, and after a while and emails from me asking, suggested something obvious (set temp to 200 °C).</p> <p>And without any video, they don't respond. Just like last time when I ran into the defective/burned power switch and failed bed leveling.</p> <p><em>If you have some spare time, please quickly check the video and provide some feedback.</em></p> <p>I already fixed the burned power switch and auto-leveling (Creality ignored me, so I got the parts from Amazon).</p> <p>This is the last issue that I need to do a &quot;mercy&quot; fix, so that I can either repurpose it or, just give it away (but I still have to make it working again and safe!). I already placed an order for an i3 MK3S+, should've bought this in the first place to help me study 3D modeling, <em>not working my degree towards fixing Creality printer failures</em> :)</p> <p>Thanks in advance.</p> <p>My troubleshooting steps so far after a screw fell off during print:</p> <ul> <li>Disassembled the hotend: found heater block loose, screws were bent and somewhat stripped</li> <li>Heater resistor has a bad crimp</li> <li>Thermistor is reading temp, but I don't know if it's accurate (don't have a multimeter+thermocouple)</li> </ul> <p>Ordered a hotend from AliExpress, hopefully, that's it</p>
<p>70 °C is a specialty filament. It is well below the <code>MIN_TEMP</code> defined in any sane firmware. In Marlin, you <strong>can't</strong> turn on the extruder in any way, while this is online.</p> <p>You do need to define your firmware to allow such a print - either by dropping the value in the firmware or disabling Mintemp-protection and then <em>flashing that firmware</em>. That is quite invasive.</p> <p>To <a href="https://marlinfw.org/docs/gcode/M302.html" rel="nofollow noreferrer">temporarily</a> disable the <code>MIN_TEMP</code>, you need to run the G-code <code>M302 P1</code> or <code>M302 S0</code> - <code>M302</code> on its own does nothing. However, some firmware distributions might explicitly prevent these two commands of <em>turning off</em> the check.</p> <p>In that case, you might use <code>M302 S65</code> or similar to drop the <code>MIN_TEMP</code>.</p>
<p>In Cura Machine Settings, add <code>M302 S70</code>.</p> <p>Apparently, <code>M302 P1</code> and <code>M302 S0</code> do nothing, you need to define a non-zero minimum, and in my case, 70. Thanks to 0scar and Trish for your help.</p>
1,850
<p>How can I show a grey transparent overlay in C#?<br> It should overlay other process which are not owned by the application doing the overlay.</p>
<p>Ah. Found a comment on php.net that reminded me of the answer; you need to wildcard your value before the bindParam is evaluated, and not worry about quoting it. So for example this works fine:</p> <pre><code>$str = "%$str%"; $query = $db-&gt;prepare("select * from comments where comment like :search"); $query-&gt;bindParam(':search', $str); $query-&gt;execute(); </code></pre>
<p>5 years later, in case anyone else stumbles upon this, there is an alternative method I've discovered. The accepted solution wasn't really feasible for my situation, but this method seems to get the job done as well:</p> <pre><code>$query = $db-&gt;prepare("select * FROM table WHERE field LIKE CONCAT('%',:search,'%')"); $query-&gt;bindParam(':search', $str); $query-&gt;execute(); </code></pre> <p>I'm not sure if there will be a performance hit due to the overhead of calling the <code>CONCAT</code> function, but I wanted to pass this along as an option. Hopefully it will help someone.</p>
8,580
<p>Can ANTLR output C# using StringTemplate or any text I want it to like Yacc/Bison or does it only output to java? From the examples I've looked at it appears to be a very java centric tool.</p>
<p>The ANTLR IDE has option by which you can switch between Java and C# code generation.</p> <p>Better, consult this article (the Specifying Code Generation section):</p> <p><a href="http://www.antlr2.org/doc/csharp-runtime.html" rel="nofollow noreferrer">http://www.antlr2.org/doc/csharp-runtime.html</a></p>
<p>You can download the latest source code as a tar file from <a href="http://antlr.org/download/antlr-3.0.1.tar.gz" rel="nofollow noreferrer">here</a>. The C# runtime (binary) is also available directly, <a href="http://antlr.org/download/DOT-NET-runtime.zip" rel="nofollow noreferrer">here</a>.</p> <p>Which solution are you looking for?</p>
9,204
<p>I've been printing small quantities from a PLA filament spool on a Craftbot printer for about two months now. Recently the printed objects have been coming out very brittle. Some structures that printed fine two months ago are now difficult to re-print. The print head gets clogged easily, and when the object does print, it's quite brittle and 1/4" to 1/8" rods will easily snap off if not handled gently.</p> <p>I'll admit to not following the precautions for storage of PLA. It's much easier to just leave the filament installed rather than trying to remove it after each print, so this one spool has just been sitting on the back of the printer for all these weeks now. I'm sure it's been humid some of the days, we've had some rain here.</p> <p>Has the spool of PLA been damaged just by leaving it exposed to room air for two months? Could that be the sole cause of the brittle prints, or are there other possible causes? Is there any way to fix the spool or future prints from this spool, or do I have to scrap it and get a new spool?</p>
<p>Increase nozzle temperature. When the filament is new it will print easier, requiring less heat to print well. So if you didn't store your filament properly to begin with, increasing print temperature will make it jam less and increase layer bonding. </p> <p>The reason for this is because the moisture that accumulates in the filament will absorb heat and evaporate when printed, meaning that the filament itself isn't getting the same amount of heating as it used to.</p> <p>That being said, the storage suggestions mentioned by tbm should be your first priority. I personally put my filament in Zip Lock plastic bags and store these in a dry location not exposed to sun or temperature changes.</p>
<p>PLA absorbs moisture, so keeping the filament dry is a key factor. Aside from that, PLA is naturally more brittle than other plastics like ABS and Nylon Sorry, tried to find a graph to prove it, but couldn't find one.</p> <p>There's a good <a href="https://groups.google.com/forum/#!topic/makerbot/Rdx2ZnJeQzs">Google Group discussion</a> and many other resources that go over good storage habits, but as for fixing the existing filament.</p> <p>Try the following: </p> <ul> <li>Place PLA in an enclosure (plastic bin, Zip-loc bag, etc.)</li> <li>If you have some, add some moisture absorber(s)</li> <li>Place the tub in a warm environment (naturally or artificially) and make sure the area is dry as possible (not in the shed in the back, by the woods...). Possibly next to a heater vent or space heater in your house?</li> </ul> <p>Essentially, you're trying to treat the material. When the material goes through a heat treatment (aka the heat block in the extruder), the mechanical properties are beginning to change. The brittleness can be set by how quickly the material cools. I'm speculating that the moisture does any of the following:</p> <ol> <li>Keeps the filament from heating up to the desired extrusion temperature.</li> <li>Burns the filament.</li> <li>The moisture is evaporated, leaving gaps in the extruded filament (under microscope).</li> </ol> <p>I looked into this a few years ago and have forgotten most of what I found out, but I'll keep looking and update my answer here.</p>
325
<p>Over at <a href="https://stackoverflow.com/questions/38664/can-you-modify-text-files-when-committing-to-subversion">Can you modify text files when committing to subversion?</a> <a href="https://stackoverflow.com/questions/38664/can-you-modify-text-files-when-committing-to-subversion#38666">Grant</a> suggested that I block commits instead.</p> <p>However I don't know how to check a file ends with a newline. How can you detect that the file ends with a newline?</p>
<p><strong><a href="https://stackoverflow.com/questions/38746/how-to-detect-file-ends-in-newline#39185">@Konrad</a></strong>: tail does not return an empty line. I made a file that has some text that doesn't end in newline and a file that does. Here is the output from tail:</p> <pre class="lang-none prettyprint-override"><code>$ cat test_no_newline.txt this file doesn't end in newline$ $ cat test_with_newline.txt this file ends in newline $ </code></pre> <p>Though I found that tail has get last byte option. So I modified your script to:</p> <pre><code>#!/bin/sh c=`tail -c 1 $1` if [ &quot;$c&quot; != &quot;&quot; ]; then echo &quot;no newline&quot; fi </code></pre>
<p>The <code>read</code> command can not read a line without newline.</p> <pre class="lang-sh prettyprint-override"><code>if tail -c 1 "$1" | read -r line; then echo "newline" fi </code></pre> <p>Another answer.</p> <pre class="lang-sh prettyprint-override"><code>if [ $(tail -c 1 "$1" | od -An -b) = 012 ]; then echo "newline" fi </code></pre>
5,969
<p>I've read <a href="https://stackoverflow.com/questions/41354/is-the-stackoverflow-login-situation-bearable">https://stackoverflow.com/questions/41354/is-the-stackoverflow-login-situation-bearable</a> and must agree to a certain point that openid (for me) makes it more difficult to log in. Not a show stoper but I'm used to opening the front page of the site, there's a small login form, firefox' password manager already filled in the correct values, submit, done. One click. Here - and it's currently the only site with openid I use - the password/form manager doesn't even fill in my "login id". I often close all browser windows and all cookies are erased - and I would like to keep it this way.</p> <p>Are there any firefox plugins you would recommend that make the login process easier? Maybe something that checks my status at myOpenId and performs the login if necessary.</p> <p>Edit: Unfortunately RichQ is right and I can't use Seatbelt. And Sxipper ...not quite what I had in mind ;) Anyway, both solutions would take away some of the "pain", so upvotes for both of you.</p> <p>I've also tried the ssl certificate. But that only adds more steps. Hopefully I did something wrong and some of those steps can be eliminated:</p> <ul> <li>Click "login" at stackoverflow <li>Click on the "select provider" Button. <li>Click on MyOpenId <li>Enter Username <li>Click "Login" (Sxipper could reduce the previous 4 steps to a single mouseclick) <li>MyOpenId login page is loaded <li>Click "Sign in with an SSL certificate" <li>Choose Certificate (grrr) <li>Click "Login" (GRRR) <li>Back to stackoverflow, finally. </ul> <p>What I really would like is: <ul> <li>Click "login" at stackoverflow <li>My (only) LoginId is filled in <li>Click "Login" <li>If necessary the certificate is chosen automagically, ssl login performed <li>Back to stackoverflow without any further user interaction. </ul>That would be more or less what I'm used to - and I'm a creature of habit :)</p>
<p>VeriSign (ick)'s SeatBelt plugin: <a href="https://pip.verisignlabs.com/seatbelt.do" rel="noreferrer">https://pip.verisignlabs.com/seatbelt.do</a></p> <p>Ideally, the plugin would allow a higher-level of authentication. I know something like this was planned for the OLPC.</p>
<p>You could try <a href="http://www.sxipper.com" rel="nofollow noreferrer">Sxipper</a>. It provides intelligent automatic form-fill, including auto-login. </p> <p>From the Sxipper FAQ:</p> <blockquote> <p><em>How does Sxipper support OpenID?</em><br> Sxipper remembers your OpenIDs and presents an overlay. You choose the one you want to use and login with one click. Sxipper also helps protect you against phishing.</p> </blockquote>
7,077
<p>How do you specify that a foreign key constraint should be a 1:1 relationship in transact sql? Is declaring the column UNIQUE enough? Below is my existing code.!</p> <pre><code>CREATE TABLE [dbo].MyTable( [MyTablekey] INT IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, [OtherTableKey] INT NOT NULL UNIQUE CONSTRAINT [FK_MyTable_OtherTable] FOREIGN KEY REFERENCES [dbo].[OtherTable]([OtherTableKey]), ... CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED ( [MyTableKey] ASC ) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO </code></pre>
<p>A foreign key column with the UNIQUE and NOT NULL constraints that references a UNIQUE, NOT NULL column in another table creates a 1:(0|1) relationship, which is probably what you want.</p> <p>If there was a true 1:1 relationship, every record in the first table would have a corresponding record in the second table and vice-versa. In that case, you would probably just want to make one table (unless you needed some strange storage optimization).</p>
<p>Based on your code above, the unique constraint would be enough given that the for every primary key you have in the table, the unique constrained column is also unique. Also, this assumes that in [OtherTable], the [OtherTableKey] column is the primary key of that table.</p>
5,227
<p>Best practices recommend not installing Sql Server to run as SYSTEM. What is the bare minumum you need to give the user account you create for it?</p>
<p>By default, SQL Server 2005 installation will create a security group called SQLServer2005MSSQLUser$ComputerName$MSSQLSERVER with the correct rights. You just need to create a domain user or local user and make it a member of that group. </p> <p>More details are available in the SQL Server Books Online: <a href="http://msdn.microsoft.com/en-us/library/ms143504(SQL.90).aspx#Review_NT_rights" rel="nofollow noreferrer" title="Setting Up Windows Service Accounts">Reviewing Windows NT Rights and Privileges Granted for SQL Server Service Accounts</a></p>
<p>Typically I create a Domain User with only the specific rights on the network which I will require the server to have (i.e. to write to the network backup drive), I then add the account to local power users or local administrators depending on what needs to be done on the machine, however this isn't required. I've installed SQL a number of times using a standard user as a Service Account but you need to ensure that the user has access to write to the resources as listed at <a href="https://web.archive.org/web/20081223155956/http://support.microsoft.com/kb/283811" rel="nofollow noreferrer">https://web.archive.org/web/20081223155956/http://support.microsoft.com/kb/283811</a> . Its probably not as defined an answer as you wanted but I'm only a developer (not a professional DBA / System Engineer).</p> <p>Mauro PS dont downmark me for saying "only a developer" :P</p>
8,220
<p>Typically when writing new code you discover that you are missing a #include because the file doesn't compile. Simple enough, you add the required #include. But later you refactor the code somehow and now a couple of #include directives are no longer needed. How do I discover which ones are no longer needed? </p> <p>Of course I can manually remove some or all #include lines and add them back until the file compiles again, but this isn't really feasible in a large project with thousands of files. Are there any tools available that will help automating task?</p>
<p>You can use <a href="http://www.gimpel.com/" rel="nofollow noreferrer">PC-Lint/FlexeLint</a> to do that.</p> <p>Unusually there isn't a free OS version of the tool available.</p> <p>You can remove #includes by passing by reference instead of passing by value and forward declaring. This is because the compiler doesn't need to know the size of the object at compile time. This will require a large amount of manual work on your behalf however. The good thing is it will reduce your compile times.</p>
<p>Here is 'brute force' VC6 macro which works on single <strong><em>.cpp</strong> or <strong></em>.h</strong> file opened in editor by commenting include by include and running compile:</p> <pre><code>Sub RemoveNotUsedIncludes() 'Check if already processed; Exit if so ActiveDocument.Selection.FindText "//INCLUDE NOT USED", dsMatchFromStart IF ActiveDocument.Selection &lt;&gt; "" THEN ActiveDocument.Selection.SetBookmark MsgBox "Already checked" ActiveDocument.Selection.ClearBookmark EXIT SUB END IF 'Find first #include; Exit if not found ActiveDocument.Selection.FindText "#include", dsMatchFromStart IF ActiveDocument.Selection = "" THEN MsgBox "No #include found" EXIT SUB END IF Dim FirstIncludeLine FirstIncludeLine = ActiveDocument.Selection.CurrentLine FOR i=1 TO 200 'Test build ActiveDocument.Selection.SetBookmark ActiveDocument.Selection = "//CHECKING... #include" Build ActiveDocument.Undo ActiveDocument.Selection.ClearBookmark IF Errors = 0 THEN 'If build failed add comment ActiveDocument.Selection.EndOfLine ActiveDocument.Selection = " //INCLUDE NOT USED" END IF 'Find next include ActiveDocument.Selection.EndOfLine ActiveDocument.Selection.FindText "#include" 'If all includes tested exit IF ActiveDocument.Selection.CurrentLine = FirstIncludeLine THEN EXIT FOR NEXT </code></pre> <p>End Sub</p> <p>Of case it could be improved to work on whole project.</p>
7,467
<p>What is Lazy Loading?</p> <p>[Edit after reading a few answers] Why do people use this term so often? </p> <p>Say you just use a ASP/ADO recordset and load it with data or ADO.NET Datasource for a gridview.</p> <p>I guess I should have asked why people use the term Lazy Loading, what "other" types are their?</p>
<p>It's called lazy loading because, like a lazy person, you are putting off doing something you don't want to. The opposite is Eager Loading, where you load something right away, long before you need it.</p> <p>If you are curious why people might use lazy loading, consider an application that takes a LOOOOONG time to start. This application is probably doing a lot of eager loading... loading things from disk, and doing calculations and whatnot long before it is ever needed.</p> <p>Compare this to lazy loading, the application would start much faster, but then the first time you need to do something that requires some long running load, there may be a slight pause while it is loaded for the first time. Thus, with lazy loading, you are amortizing the load time throughout the course of running your application... and you may actually save from loading things that the user may never intend to use.</p>
<p>According to geeksforgeeks, Lazy loading is a software design pattern where the initialization of an object occurs only when it is actually needed and not before to preserve the simplicity of usage and improve performance.</p> <p><a href="https://www.geeksforgeeks.org/lazy-loading-design-pattern/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/lazy-loading-design-pattern/</a></p>
5,693
<p>I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called <a href="http://en.wikipedia.org/wiki/Spss" rel="noreferrer">SPSS</a>. Part of the output that they care about looks like this:</p> <p><img src="https://i.stack.imgur.com/m0swl.png" alt="[Part of the SPSS output"></p> <p>They're really only concerned about the <code>F</code> and <code>Sig.</code> values. My problem is that I have no background in statistics, and I can't figure out what the tests are called, or how to calculate them.</p> <p>I thought the <code>F</code> value might be the result of the <a href="http://en.wikipedia.org/wiki/F-test#Table_on_F-test" rel="noreferrer">F-test</a>, but after following the steps given on Wikipedia, I got a result that was different from what <code>SPSS</code> gives.</p>
<p><a href="http://people.richland.edu/james/lecture/m170/ch13-2wy.html" rel="nofollow noreferrer">This website</a> might help you out a bit more. Also <a href="http://www.unesco.org/webworld/idams/advguide/Chapt4_3.htm" rel="nofollow noreferrer">this one</a>.</p> <p>I'm working from a fairly rusty memory of a statistics course, but here goes nothing:</p> <p>When you're doing analysis of variance (ANOVA), you actually calculate the F statistic as the ratio from the mean-square variances "between the groups" and the mean-square variances "within the groups". The second link above seems pretty good for this calculation.</p> <p>This makes the F statistic measure exactly how powerful your model is, because the "between the groups" variance is explanatory power, and "within the groups" variance is random error. High F implies a highly significant model.</p> <p>As in many statistical operations, you back-determine Sig. using the F statistic. Here's where your Wikipedia information comes in slightly handy. What you want to do is - using the degrees of freedom given to you by SPSS - find the proper P value at which an <a href="http://www.ento.vt.edu/~sharov/PopEcol/tables/f005.html" rel="nofollow noreferrer">F table</a> will give you the F statistic you calculated. The P value where this happens [F(table) = F(calculated)] is the significance.</p> <p>Conceptually, a lower significance value shows a very strong ability to reject the null hypothesis (which for these purposes means to determine your model has explanatory power).</p> <p>Sorry to any math folks if any of this is wrong. I'll be checking back to make edits!!!</p> <p>Good luck to you. Stats is fun, just maybe not this part. =)</p>
<p>Can you explain more why SPSS itself isn't a fine solution to the problem? Is it that it generates pivot tables as output that are hard to manipulate? Is it the cost of the program? </p> <p>F-statistics can arise from any number of particular tests. The F is just a distribution (loosely: a description of the "frequencies" of groups of values), like a Normal (Gaussian), or Uniform. In general they arise from ratios of variances. Opinion: many statisticians (myself included), find F-based tests to be unstable (jargon: non-<em>robust</em>).</p> <p>The particular output statistics (Pillai's trace, etc.) suggest that the original analysis is a MANOVA example, which as other posters describe is a complicated, and hard to get right procedure.</p> <p>I'm guess also that, based on the MANOVA, and the use of SPSS, this is a psychology or sociology project... if not please enlighten. It might be that other, simpler models might actually be easier to understand and more repeatable. Consult your local university statistical consulting group, if you have one. </p> <p>Good luck! </p>
2,400
<p>I have always been able to read and write basic text files in C++, but so far no one has discussed much more than that. </p> <p>My question is this:</p> <p>If developing a file type by myself for use by an application I also create, how would I go about writing the data to a file and preserve the layout, formatting, etc.? Are there any standards, or does it just depend on the creativity of the programmer?</p>
<p>There are a number of standards of course. The likely one to use is some flavor of xml since there are libraries and tools that already exist to help you work with it, but nothing is stopping you from inventing your own.</p>
<p>If you create a binary file , you can write any file to it . The only drawback is that you have to know exactly where it starts and where it ends .</p>
9,982
<p>I need to build me a small support wall 250x80 cm mounted on two metal supports approximately 200 cm apart.</p> <p>I was looking into WPC (Wood Plastic Composite) boards and then it hit me that I may be able to make it functional AND pretty with my 3D printer (Prusa MK3S + MMU2).</p> <p>However, I have zero idea on how to calculate whether the board will be able to handle the weight of the soil I would shovel behind it, if at all.</p> <p>My current design proposal is to make a hexagon mesh of PETG filament. The hexagons would have cylinder cutouts in all three directions, through which I would then hammer in cylinders to bind them together. Perhaps even some edge contours so that they fit perfectly.</p> <p>But, my problem is that I don't know how to calculate the strength of such a solution (or any other).</p> <p>Is this even a viable idea?</p> <p>The filament type needs a bit more explanation: My current proposal is PETG since I read that PLA will become brittle with time (as I can attest to myself having to replace my flag pole holder every 3 - 4 years)</p> <p>I don't want ABS since I have horrible experience printing it.</p> <p>I did not find anything of particular use when searching for &quot;3D print load-bearing&quot; on this site and similar with Google searches...</p>
<p>You could print a decorative layer that attaches to the WPC board.</p> <p>It would be faster and cheaper, and there'd be no doubt about its strength.</p>
<p>Here are some general issues with load bearing 3d prints for this type of usage:</p> <ul> <li>If this is to be used outside, plastic has issues with both water and UV exposure making it brittle. PETG does better on both of these areas than either PLA or ABS.</li> <li>Plastic generally does better with compression than with shear or pulling. In other words, hanging something from plastic might not work well but it might work as a bottom support or in a situation where it is squeezed rather than pulled.</li> <li>Even if the plastic appears strong enough initially, it may &quot;creep&quot; where the plastic deforms under stress over time. This applies to all three of compression, shear, and pulling.</li> <li>To optimize for strength, print direction is critical. You want to make sure that the stress will not be trying to shear print layers. Also (for any material, not just 3d printed plastic), curved shapes are stronger than square corners. A fillet instead of a corner makes a big difference, but more extreme curves are even better.</li> <li>If you are going to make this out of modular pieces joined with a second material, it is very hard to characterize the strength of the resulting composite, but generally it is stronger than using a single material.</li> </ul>
2,215
<p>In Maven, dependencies are usually set up like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt; &lt;groupId&gt;wonderful-inc&lt;/groupId&gt; &lt;artifactId&gt;dream-library&lt;/artifactId&gt; &lt;version&gt;1.2.3&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Now, if you are working with libraries that have frequent releases, constantly updating the &lt;version&gt; tag can be somewhat annoying. Is there any way to tell Maven to always use the latest available version (from the repository)? </p>
<p><em><strong>NOTE:</strong></em></p> <p><em>The mentioned <code>LATEST</code> and <code>RELEASE</code> metaversions <a href="https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-PluginMetaversionResolution" rel="noreferrer">have been dropped <strong>for plugin dependencies</strong> in Maven 3 &quot;for the sake of reproducible builds&quot;</a>, over 6 years ago. (They still work perfectly fine for regular dependencies.) For plugin dependencies please refer to this <strong><a href="https://stackoverflow.com/a/1172805/363573">Maven 3 compliant solution</a></strong></em>.</p> <hr /> <p>If you always want to use the newest version, Maven has two keywords you can use as an alternative to version ranges. You should use these options with care as you are no longer in control of the plugins/dependencies you are using.</p> <blockquote> <p>When you depend on a plugin or a dependency, you can use the a version value of LATEST or RELEASE. LATEST refers to the latest released or snapshot version of a particular artifact, the most recently deployed artifact in a particular repository. RELEASE refers to the last non-snapshot release in the repository. In general, it is not a best practice to design software which depends on a non-specific version of an artifact. If you are developing software, you might want to use RELEASE or LATEST as a convenience so that you don't have to update version numbers when a new release of a third-party library is released. When you release software, you should always make sure that your project depends on specific versions to reduce the chances of your build or your project being affected by a software release not under your control. Use LATEST and RELEASE with caution, if at all.</p> </blockquote> <p>See the <a href="http://www.sonatype.com/books/maven-book/reference/pom-relationships-sect-pom-syntax.html#pom-relationships-sect-latest-release" rel="noreferrer">POM Syntax section of the Maven book</a> for more details. Or see this doc on <a href="http://www.mojohaus.org/versions-maven-plugin/examples/resolve-ranges.html" rel="noreferrer">Dependency Version Ranges</a>, where:</p> <ul> <li>A square bracket ( <code>[</code> &amp; <code>]</code> ) means &quot;closed&quot; (inclusive).</li> <li>A parenthesis ( <code>(</code> &amp; <code>)</code> ) means &quot;open&quot; (exclusive).</li> </ul> <p>Here's an example illustrating the various options. In the Maven repository, com.foo:my-foo has the following metadata:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;metadata&gt; &lt;groupId&gt;com.foo&lt;/groupId&gt; &lt;artifactId&gt;my-foo&lt;/artifactId&gt; &lt;version&gt;2.0.0&lt;/version&gt; &lt;versioning&gt; &lt;release&gt;1.1.1&lt;/release&gt; &lt;versions&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;version&gt;1.0.1&lt;/version&gt; &lt;version&gt;1.1&lt;/version&gt; &lt;version&gt;1.1.1&lt;/version&gt; &lt;version&gt;2.0.0&lt;/version&gt; &lt;/versions&gt; &lt;lastUpdated&gt;20090722140000&lt;/lastUpdated&gt; &lt;/versioning&gt; &lt;/metadata&gt; </code></pre> <p>If a dependency on that artifact is required, you have the following options (other <a href="https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges" rel="noreferrer">version ranges</a> can be specified of course, just showing the relevant ones here):</p> <p>Declare an exact version (will always resolve to 1.0.1):</p> <pre class="lang-xml prettyprint-override"><code>&lt;version&gt;[1.0.1]&lt;/version&gt; </code></pre> <p>Declare an explicit version (will always resolve to 1.0.1 unless a collision occurs, when Maven will select a matching version):</p> <pre class="lang-xml prettyprint-override"><code>&lt;version&gt;1.0.1&lt;/version&gt; </code></pre> <p>Declare a version range for all 1.x (will currently resolve to 1.1.1):</p> <pre class="lang-xml prettyprint-override"><code>&lt;version&gt;[1.0.0,2.0.0)&lt;/version&gt; </code></pre> <p>Declare an open-ended version range (will resolve to 2.0.0):</p> <pre class="lang-xml prettyprint-override"><code>&lt;version&gt;[1.0.0,)&lt;/version&gt; </code></pre> <p>Declare the version as LATEST (will resolve to 2.0.0) (removed from maven 3.x)</p> <pre class="lang-xml prettyprint-override"><code>&lt;version&gt;LATEST&lt;/version&gt; </code></pre> <p>Declare the version as RELEASE (will resolve to 1.1.1) (removed from maven 3.x):</p> <pre class="lang-xml prettyprint-override"><code>&lt;version&gt;RELEASE&lt;/version&gt; </code></pre> <p>Note that by default your own deployments will update the &quot;latest&quot; entry in the Maven metadata, but to update the &quot;release&quot; entry, you need to activate the &quot;release-profile&quot; from the <a href="http://maven.apache.org/guides/introduction/introduction-to-the-pom.html" rel="noreferrer">Maven super POM</a>. You can do this with either &quot;-Prelease-profile&quot; or &quot;-DperformRelease=true&quot;</p> <hr /> <p>It's worth emphasising that any approach that allows Maven to pick the dependency versions (LATEST, RELEASE, and version ranges) can leave you open to build time issues, as later versions can have different behaviour (for example the dependency plugin has previously switched a default value from true to false, with confusing results).</p> <p>It is therefore generally a good idea to define exact versions in releases. As <a href="https://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency/1172805#1172805">Tim's answer</a> points out, the <a href="http://www.mojohaus.org/versions-maven-plugin/" rel="noreferrer">maven-versions-plugin</a> is a handy tool for updating dependency versions, particularly the <a href="http://www.mojohaus.org/versions-maven-plugin/use-latest-versions-mojo.html" rel="noreferrer">versions:use-latest-versions</a> and <a href="http://www.mojohaus.org/versions-maven-plugin/use-latest-releases-mojo.html" rel="noreferrer">versions:use-latest-releases</a> goals.</p>
<p>MY solution in maven 3.5.4 ,use nexus, in eclipse:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;yilin.sheng&lt;/groupId&gt; &lt;artifactId&gt;webspherecore&lt;/artifactId&gt; &lt;version&gt;LATEST&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>then in eclipse: <code>atl + F5</code>, and choose the <code>force update of snapshots/release</code></p> <p>it works for me.</p>
5,047
<p>I'm using <a href="http://jquery.com/" rel="noreferrer">jQuery</a> and <a href="http://www.ericmmartin.com/projects/simplemodal/" rel="noreferrer">SimpleModal</a> in an ASP.Net project to make some nice dialogs for a web app. Unfortunately, any buttons in a modal dialog can no longer execute their postbacks, which is not really acceptable.</p> <p>There is one source I've found with a <a href="http://blog.hurlman.com/post/jQuery2c-simpleModal2c-and-ASPNet-postbacks-do-not-play-well-together.aspx" rel="noreferrer">workaround</a>, but for the life of me I can't get it to work, mostly because I am not fully understanding all of the necessary steps.</p> <p>I also have a workaround, which is to replace the postbacks, but it's ugly and probably not the most reliable. I would really like to make the postbacks work again. Any ideas?</p> <p>UPDATE: I should clarify, the postbacks are not working because the Javascript used to execute the post backs has broken in some way, so nothing happens at all when the button is clicked.</p>
<p>Both of you were on the right track. What I realized is that SimpleModal appends the dialog to the body, which is outside ASP.Net's <code>&lt;form&gt;</code>, which breaks the functionality, since it can't find the elements.</p> <p>To fix it, I just modified the SimpleModal source to append eveything to <code>'form'</code> instead of <code>'body'</code>. When I create the dialog, I also use the <code>persist: true</code> option, to make sure the buttons stay through opening and closing.</p> <p>Thanks everyone for the suggestions!</p> <p><em>UPDATE:</em> Version 1.3 adds an <code>appendTo</code> option in the configuration for specifying which element the modal dialog should be appended to. <a href="http://www.ericmmartin.com/projects/simplemodal/#options" rel="noreferrer">Here are the docs</a>.</p>
<p>if you don want modify the SimpleModal source. try this..</p> <p>After you call the modal() method add this:</p> <pre><code>$("#simplemodal-overlay").appendTo('form'); $("#simplemodal-container").appendTo('form'); </code></pre> <p>the SimpleModal plugin add two this to your markup. </p> <ol> <li>'simplemodal-overlay' for the background</li> <li>'simplemodal-container' containig the div that you whant as pop up modal.</li> </ol>
4,887
<p>How do I setup an Ant task to generate <a href="http://emma.sourceforge.net" rel="noreferrer">Emma</a> code coverage reports?</p>
<p>To answer questions about where the source and instrumented directories are (these can be switched to whatever your standard directory structure is):</p> <pre><code>&lt;property file="build.properties" /&gt; &lt;property name="source" location="src/main/java" /&gt; &lt;property name="test.source" location="src/test/java" /&gt; &lt;property name="target.dir" location="target" /&gt; &lt;property name="target" location="${target.dir}/classes" /&gt; &lt;property name="test.target" location="${target.dir}/test-classes" /&gt; &lt;property name="instr.target" location="${target.dir}/instr-classes" /&gt; </code></pre> <p>Classpaths:</p> <pre><code>&lt;path id="compile.classpath"&gt; &lt;fileset dir="lib/main"&gt; &lt;include name="*.jar" /&gt; &lt;/fileset&gt; &lt;/path&gt; &lt;path id="test.compile.classpath"&gt; &lt;path refid="compile.classpath" /&gt; &lt;pathelement location="lib/test/junit-4.6.jar" /&gt; &lt;pathelement location="${target}" /&gt; &lt;/path&gt; &lt;path id="junit.classpath"&gt; &lt;path refid="test.compile.classpath" /&gt; &lt;pathelement location="${test.target}" /&gt; &lt;/path&gt; </code></pre> <p>First you need to setup where Ant can find the Emma libraries:</p> <pre><code>&lt;path id="emma.lib" &gt; &lt;pathelement location="${emma.dir}/emma.jar" /&gt; &lt;pathelement location="${emma.dir}/emma_ant.jar" /&gt; &lt;/path&gt; </code></pre> <p>Then import the task:</p> <pre><code>&lt;taskdef resource="emma_ant.properties" classpathref="emma.lib" /&gt; </code></pre> <p>Then instrument the code:</p> <pre><code>&lt;target name="coverage.instrumentation"&gt; &lt;mkdir dir="${instr.target}"/&gt; &lt;mkdir dir="${coverage}"/&gt; &lt;emma&gt; &lt;instr instrpath="${target}" destdir="${instr.target}" metadatafile="${coverage}/metadata.emma" mode="copy"&gt; &lt;filter excludes="*Test*"/&gt; &lt;/instr&gt; &lt;/emma&gt; &lt;!-- Update the that will run the instrumented code --&gt; &lt;path id="test.classpath"&gt; &lt;pathelement location="${instr.target}"/&gt; &lt;path refid="junit.classpath"/&gt; &lt;pathelement location="${emma.dir}/emma.jar"/&gt; &lt;/path&gt; &lt;/target&gt; </code></pre> <p>Then run a target with the proper VM arguments like:</p> <pre><code>&lt;jvmarg value="-Demma.coverage.out.file=${coverage}/coverage.emma" /&gt; &lt;jvmarg value="-Demma.coverage.out.merge=true" /&gt; </code></pre> <p>Finally generate your report:</p> <pre><code>&lt;target name="coverage.report" depends="coverage.instrumentation"&gt; &lt;emma&gt; &lt;report sourcepath="${source}" depth="method"&gt; &lt;fileset dir="${coverage}" &gt; &lt;include name="*.emma" /&gt; &lt;/fileset&gt; &lt;html outfile="${coverage}/coverage.html" /&gt; &lt;/report&gt; &lt;/emma&gt; &lt;/target&gt; </code></pre>
<p>Emma 2.1 introduces another way of obtaining runtime coverage information (.ec file). One can remotely request the data from the given port of the computer where an instrumented application is runnig. So there's no need to stop VM.</p> <p>To get the file with runtime coverage data you need to insert the following snippet in your Ant script between running of your tests and generating coverage report:</p> <pre><code>&lt;emma&gt; &lt;ctl connect="${emma.rt.host}:${emma.rt.port}" &gt; &lt;command name="coverage.get" args="${emma.ec.file}" /&gt; &lt;command name="coverage.reset" /&gt; &lt;/ctl&gt; &lt;/emma&gt; </code></pre> <p>Other steps are similar to Emma 2.0. They are perfectly described in <a href="https://stackoverflow.com/questions/52984/how-do-i-generate-emma-code-coverage-raeports-using-ant#52994">previous post</a></p> <p>More information on Emma 2.1 features: <a href="http://sourceforge.net/project/shownotes.php?group_id=108932&amp;release_id=336859" rel="nofollow noreferrer">http://sourceforge.net/project/shownotes.php?group_id=108932&amp;release_id=336859</a></p>
7,635
<p>Some things look strange to me:</p> <ul> <li>What is the distinction between 0.0.0.0, 127.0.0.1, and [::]?</li> <li>How should each part of the foreign address be read (part1:part2)?</li> <li>What does a state Time_Wait, Close_Wait mean?</li> <li>etc.</li> </ul> <p>Could someone give a quick overview of how to interpret these results?</p>
<p>0.0.0.0 usually refers to stuff listening on all interfaces. 127.0.0.1 = localhost (only your local interface) I'm not sure about [::]</p> <p>TIME_WAIT means both sides have agreed to close and TCP must now wait a prescribed time before taking the connection down.</p> <p>CLOSE_WAIT means the remote system has finished sending and your system has yet to say it's finished. </p>
<p>For those seeing [::] in their netstat output, I'm betting your machine is running IPv6; that would be equivalent to 0.0.0.0, i.e. listen on any IPv6 address. </p>
4,126
<p>I'm a bit stuck on this. Basically I want to do something like the following SQL query in LINQ to SQL:</p> <pre><code>SELECT f.* FROM Foo f WHERE f.FooId IN ( SELECT fb.FooId FROM FooBar fb WHERE fb.BarId = 1000 ) </code></pre> <p>Any help would be gratefully received.</p>
<p>Have a look at <a href="http://blog.wekeroad.com/2008/02/27/creating-in-queries-with-linq-to-sql" rel="noreferrer">this article</a>. Basically, if you want to get the equivalent of IN, you need to construct an inner query first, and then use the Contains() method. Here's my attempt at translating:</p> <pre><code>var innerQuery = from fb in FoorBar where fb.BarId = 1000 select fb.FooId; var result = from f in Foo where innerQuery.Contains(f.FooId) select f;</code></pre>
<p>Try this</p> <pre><code>var fooids = from fb in foobar where fb.BarId=1000 select fb.fooID var ff = from f in foo where f.FooID = fooids select f </code></pre>
7,438
<p>Any ideas what the average user's download speed is? I'm working on a site that streams video and am trying to figure out what an average download speed as to determine quality.</p> <p>I know i might be comparing apples with oranges but I'm just looking for something to get a basis for where to start.</p>
<p><a href="http://speedtest.net/global.php" rel="noreferrer">Speedtest.net</a> has a lot of stats broken down by country, region, city and ISP. Not sure about accuracy, since it's only based on the people using their "bandwidth measurement" service.</p>
<p>There are a lot of factors involved (server bandwidth, local ISP, network in between, etc) which make it difficult to give a hard answer. With my current ISP, I typically get 200-300 kB/sec. Although when the planets align I've gotten as much as 2 MB/sec (the "quoted" peak downlink speed). That was with parallel streams, however. The peak bandwidth I've achieved on a single stream is 1.2 MB/sec</p>
7,370
<p>Has anyone configured BLTouch with Marlin firmware?</p> <p>I could only find videos about older firmware version. I followed <a href="https://docs.wixstatic.com/ugd/f5a1c8_77c6538efc934dbeab2f6e06e175ec35.pdf" rel="nofollow noreferrer">this document</a>. To avoid causing any damage to the printer, I removed all connections, took the board out and connected a stepper to Z-axis terminal and BLTouch to Z-min and servo 1. All other axes are not connected. X-min and Y-min end stops were shorted using jumper (Mine is NC configuration). </p> <p>After updating the firmware, I can move the X and Y steppers, but not Z stepper. There's a blue light glowing inside BLTouch, which turns off if I remove Servo connections.</p> <p>The <code>M119</code> command shows all end stops are open.</p> <p>Do I have to change pull up settings of end stop?</p> <p>I cuurently have:</p> <ul> <li>Marlin 1.1.6</li> <li>BLTouch Classic</li> </ul> <p>Here's my <a href="https://drive.google.com/open?id=1hX5qZ3nnSY7cxfvX1J8z8wPrAGqynfKL" rel="nofollow noreferrer">configuration</a> file</p> <p><a href="https://i.stack.imgur.com/NIoLA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NIoLA.png" alt="enter image description here"></a></p>
<p>For security reasons, you cannot move Z until home position is applied to X, Y and Z.</p> <p>With the level sensor attached, we need to home X and Y, and then Z will be homed in the middle of the bed (as configured). Execute <code>G28</code> to home all axis and then you shall be able to run 'Z'.</p> <p>To test that, you can unplug just steppers (with power switched off to prevent damaging the stepper drivers) and move X and Y manually to home position, then just give a touch to the BL sensor (when servo/pin) is deployed to confirm home position.</p>
<p><strong>Edit:</strong> <em>The answer below reflected the original question and upload of the configuration that was incorrectly configured. The value of this answer can be found in checking your configuration thoroughly before you post a question. It also answers the question whether pull-up resistors need to be set for the end stops.</em></p> <hr> <p>Basically you need to follow the instructions of the manual/sheet you mention in your question. Be sure to <strong>get all the changes correct in your configuration.h</strong> file!</p> <p>E.g. in your configuration</p> <pre><code>//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command </code></pre> <p>should be</p> <pre><code>#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command </code></pre> <p>So no servo was defined (the servo pulls up the pin of the BLTouch sensor)! Also your BLTouch delay is <code>375</code> while <code>100</code> is prescribed. Please check that you managed to get all the proposed changes in the configuration file (as I stopped comparing for you after finding 2 errors in your configuration!) as I believe that you have not updated your configuration correctly as described. There should be no differences in setup for Marlin 1.1.6 or 1.1.8.</p> <p><strong>To answer your question</strong>: No, you do not need to change pull-up settings.</p>
924
<p>I have a table <code>story_category</code> in my database with corrupt entries. The next query returns the corrupt entries:</p> <pre><code>SELECT * FROM story_category WHERE category_id NOT IN ( SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id=category.id); </code></pre> <p>I tried to delete them executing:</p> <pre><code>DELETE FROM story_category WHERE category_id NOT IN ( SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id=category.id); </code></pre> <p>But I get the next error: </p> <blockquote> <p>#1093 - You can't specify target table 'story_category' for update in FROM clause </p> </blockquote> <p>How can I overcome this?</p>
<p><em>Update: This answer covers the general error classification. For a more specific answer about how to best handle the OP's exact query, please see other answers to this question</em></p> <p>In MySQL, you can't modify the same table which you use in the SELECT part.<br> This behaviour is documented at: <a href="http://dev.mysql.com/doc/refman/5.6/en/update.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.6/en/update.html</a></p> <p><strong>Maybe you can just join the table to itself</strong></p> <p>If the logic is simple enough to re-shape the query, lose the subquery and join the table to itself, employing appropriate selection criteria. This will cause MySQL to see the table as two different things, allowing destructive changes to go ahead.</p> <pre><code>UPDATE tbl AS a INNER JOIN tbl AS b ON .... SET a.col = b.col </code></pre> <p><strong>Alternatively, try nesting the subquery deeper into a from clause ...</strong></p> <p>If you absolutely need the subquery, there's a workaround, but it's ugly for several reasons, including performance:</p> <pre><code>UPDATE tbl SET col = ( SELECT ... FROM (SELECT.... FROM) AS x); </code></pre> <p>The nested subquery in the FROM clause creates an <em>implicit temporary table</em>, so it doesn't count as the same table you're updating. </p> <p><strong>... but watch out for the query optimiser</strong></p> <p>However, beware that from <a href="http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-6.html" rel="noreferrer">MySQL 5.7.6</a> and onward, the optimiser may optimise out the subquery, and still give you the error. Luckily, the <code>optimizer_switch</code> variable can be used to switch off this behaviour; although I couldn't recommend doing this as anything more than a short term fix, or for small one-off tasks.</p> <pre><code>SET optimizer_switch = 'derived_merge=off'; </code></pre> <p><em>Thanks to <a href="https://stackoverflow.com/users/345716/peter-v-m%C3%B8rch">Peter V. Mørch</a> for this advice in the comments.</em></p> <p>Example technique was from Baron Schwartz, <a href="http://grokbase.com/t/mysql/mysql/08259dm24b/error-you-cant-specify-target-table-for-update-in-from-clause" rel="noreferrer">originally published at Nabble</a>, paraphrased and extended here.</p>
<p>If something does not work, when coming thru the front-door, then take the back-door:</p> <pre><code>drop table if exists apples; create table if not exists apples(variety char(10) primary key, price int); insert into apples values('fuji', 5), ('gala', 6); drop table if exists apples_new; create table if not exists apples_new like apples; insert into apples_new select * from apples; update apples_new set price = (select price from apples where variety = 'gala') where variety = 'fuji'; rename table apples to apples_orig; rename table apples_new to apples; drop table apples_orig; </code></pre> <p>It's fast. The bigger the data, the better.</p>
6,738
<p>I've joined a team that works on a product. This product has been around for ~5 years or so, and uses ASP.NET WebForms. Its original architecture has faded over time, and things have become relatively disorganized throughout the solution. It's by no means terrible, but definitely can use some work; you all know what I mean.</p> <p>I've been performing some refactorings since coming on to the project team about 6 months ago. Some of those refactorings are simple, Extract Method, Pull Method Up, etc. Some of the refactorings are more structural. The latter changes make me nervous as there isn't a comprehensive suite of unit tests to accompany every component. </p> <p>The whole team is on board for the need to make structural changes through refactoring, but our Project Manager has expressed some concerns that we don't have adequate tests to make refactorings with the confidence that we aren't introducing regression bugs into the system. He would like us to write more tests first (against the existing architecture), then perform the refactorings. My argument is that the system's class structure is too tightly coupled to write adequate tests, and that using a more Test Driven approach while we perform our refactorings may be better. What I mean by this is not writing tests against the existing components, but writing tests for specific functional requirements, then refactoring existing code to meet those requirements. This will allow us to write tests that will probably have more longevity in the system, rather than writing a bunch of 'throw away' tests.</p> <p>Does anyone have any experience as to what the best course of action is? I have my own thoughts, but would like to hear some input from the community.</p>
<p>Your PM's concerns are valid - make sure you get your system under test before making any major refactorings.</p> <p>I would strongly recommend getting a copy of Michael Feather's book <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="noreferrer" rel="nofollow noreferrer">Working Effectively With Legacy Code</a> (by "Legacy Code" Feathers means any system that isn't adequately covered by unit tests). This is chock full of good ideas for how to break down those couplings and dependencies you speak of, in a safe manner that won't risk introducing regression bugs.</p> <p>Good luck with the refactoring programme; in my experience it's an enjoyable and cathartic process from which you can learn a lot.</p>
<p>Just tossing out a second recommendation for Working Effectively with Legacy Code, an excellent book that really opened my eyes to the fact that almost any old / crappy / untestable code can be wrangled!</p>
4,061
<p>I understand what <a href="http://msdn.microsoft.com/en-us/library/ms404247.aspx" rel="noreferrer">System.WeakReference</a> does, but what I can't seem to grasp is a practical example of what it might be useful for. The class itself seems to me to be, well, a hack. It seems to me that there are other, better means of solving a problem where a WeakReference is used in examples I've seen. What's the canonical example of where you've really got to use a WeakReference? Aren't we trying to get <i>farther</i> away from this type of behavior and use of this class? </p>
<p>One useful example is the guys who run DB4O object oriented database. There, WeakReferences are used as a kind of light cache: it will keep your objects in memory only as long as your application does, allowing you to put a real cache on top.</p> <p>Another use would be in the implementation of weak event handlers. Currently, one big source of memory leaks in .NET applications is forgetting to remove event handlers. E.g.</p> <pre><code>public MyForm() { MyApplication.Foo += someHandler; } </code></pre> <p>See the problem? In the above snippet, MyForm will be kept alive in memory forever as long as MyApplication is alive in memory. Create 10 MyForms, close them all, your 10 MyForms will still be in memory, kept alive by the event handler.</p> <p>Enter WeakReference. You can build a weak event handler using WeakReferences so that someHandler is a weak event handler to MyApplication.Foo, thus fixing your memory leaks!</p> <p>This isn't just theory. Dustin Campbell from the DidItWith.NET blog posted <a href="http://diditwith.net/PermaLink,guid,aacdb8ae-7baa-4423-a953-c18c1c7940ab.aspx" rel="noreferrer">an implementation of weak event handlers</a> using System.WeakReference.</p>
<p>There are two reasons why you would use <code>WeakReference</code>. </p> <ol> <li><p><strong>Instead of global objects declared as static</strong>: Global objects are declared as static fields and static fields cannot be GC'ed (garbage-collected) until the <code>AppDomain</code> is GC'ed. So you risk out-of-memory exceptions. Instead, we can wrap the global object in a <code>WeakReference</code>. Even though the <code>WeakReference</code> itself is declared static, the object it points to will be GC'ed when memory is low. </p> <p>Basically, use <code>wrStaticObject</code> instead of <code>staticObject</code>.</p> <pre><code>class ThingsWrapper { //private static object staticObject = new object(); private static WeakReference wrStaticObject = new WeakReference(new object()); } </code></pre> <p>Simple app to prove that static object is garbage-collected when AppDomain is.</p> <pre><code>class StaticGarbageTest { public static void Main1() { var s = new ThingsWrapper(); s = null; GC.Collect(); GC.WaitForPendingFinalizers(); } } class ThingsWrapper { private static Thing staticThing = new Thing("staticThing"); private Thing privateThing = new Thing("privateThing"); ~ThingsWrapper() { Console.WriteLine("~ThingsWrapper"); } } class Thing { protected string name; public Thing(string name) { this.name = name; Console.WriteLine("Thing() " + name); } public override string ToString() { return name; } ~Thing() { Console.WriteLine("~Thing() " + name); } } </code></pre> <p>Note from the output below <code>staticThing</code> is GC'ed at the very end even after <code>ThingsWrapper</code> is - i.e. GC'ed when <code>AppDomain</code> is GC'ed.</p> <pre><code>Thing() staticThing Thing() privateThing ~Thing() privateThing ~ThingsWrapper ~Thing() staticThing </code></pre> <p>Instead we can wrap <code>Thing</code> in a <code>WeakReference</code>. As <code>wrStaticThing</code> can be GC'ed, we'll need a lazy-loaded method which I've left out for brevity. </p> <pre><code>class WeakReferenceTest { public static void Main1() { var s = new WeakReferenceThing(); s = null; GC.Collect(); GC.WaitForPendingFinalizers(); if (WeakReferenceThing.wrStaticThing.IsAlive) Console.WriteLine("WeakReference: {0}", (Thing)WeakReferenceThing.wrStaticThing.Target); else Console.WriteLine("WeakReference is dead."); } } class WeakReferenceThing { public static WeakReference wrStaticThing; static WeakReferenceThing() { wrStaticThing = new WeakReference(new Thing("wrStaticThing")); } ~WeakReferenceThing() { Console.WriteLine("~WeakReferenceThing"); } //lazy-loaded method to new Thing } </code></pre> <p>Note from output below that <code>wrStaticThing</code> is GC'ed when GC thread is invoked.</p> <pre><code>Thing() wrStaticThing ~Thing() wrStaticThing ~WeakReferenceThing WeakReference is dead. </code></pre></li> <li><p><strong>For objects that are time-consuming to initialize</strong>: You do not want objects that are time-consusming to init to be GC'ed. You can either keep a static reference to avoid that (with cons from above point) or use <code>WeakReference</code>. </p></li> </ol>
3,637
<p>can you recommend some good ASP.NET tutorials or a good book? Should I jump right to ASP.NET MVC/html/javascript or learn web forms first? </p> <p>Thanks</p>
<p>A great book if you're just beginning is Matthew MacDonald's <a href="https://rads.stackoverflow.com/amzn/click/com/1590598911" rel="nofollow noreferrer" rel="nofollow noreferrer">Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional</a>. Once you're done with that a great reference (also by MacDonald) is <a href="https://rads.stackoverflow.com/amzn/click/com/1590598938" rel="nofollow noreferrer" rel="nofollow noreferrer">Pro ASP.NET 3.5 in C# 2008</a>. One of my favorite sources of information online is <a href="https://web.archive.org/web/20211027112438/https://aspnet.4guysfromrolla.com/default.aspx" rel="nofollow noreferrer">4GuysFromRolla</a>.</p>
<p>MVC www.asp.net/mvc great videos Asp.net www.asp.net </p>
4,264
<p>Better yet, how can I make My Computer always open in Explorer as well?</p> <p>I usually make a shortcut to my programming directories on my quick launch bar, but I'd love for them to open in Explorer.</p>
<p>explorer -d c:\path</p>
<p>Have you considered the win+e hotkey? It isn't quite what you want, but might be close enough.</p>
7,676
<p>The <a href="http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/UsingiPhoneApplications/chapter_6_section_4.html" rel="nofollow noreferrer">Apple Developer Documentation</a> (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Safari on the iPhone, the Google Maps application that is provided as standard with the iPhone will launch.</p> <p>How can I launch the same Google Maps application with a specific address from within my own native iPhone application (i.e. not a web page through Mobile Safari) in the same way that tapping an address in Contacts launches the map?</p> <p><strong>NOTE: THIS ONLY WORKS ON THE DEVICE ITSELF. NOT IN THE SIMULATOR.</strong></p>
<p>For iOS 5.1.1 and lower, use the <code>openURL</code> method of <code>UIApplication</code>. It will perform the normal iPhone magical URL reinterpretation. so</p> <pre><code>[someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]] </code></pre> <p>should invoke the Google maps app.</p> <p>From iOS 6, you'll be invoking Apple's own Maps app. For this, configure an <code>MKMapItem</code> object with the location you want to display, and then send it the <code>openInMapsWithLaunchOptions</code> message. To start at the current location, try:</p> <pre><code>[[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil]; </code></pre> <p>You'll need to be linked against MapKit for this (and it will prompt for location access, I believe).</p>
<p>If you need more flexibility than the Google URL format gives you or you would like to embed a map in your application instead of launching the map app <a href="https://sourceforge.net/projects/quickconnect" rel="nofollow noreferrer">here is an example</a>.</p> <p>It will even supply you with the source code to do all of the embedding.</p>
4,990
<p>In 3D printing firmware and slicers, jerk settings are expressed in units if mm/s. This is contrary the physical definition of jerk, which is in units of mm/s³, being the second derivative of speed with respect to time (or the third derivative of position). What is the reason for this discrepancy and how does one interpret jerk in this contect?</p>
<p>The jerk setting in 3D printing G-code and firmware represents a concept similar to, but distinct from, the physical definition of jerk. Rather, it's a [limit on] instantaneous change of speed.</p> <p>Mathematically, one way to make sense of this is to think that, rather than being the second derivative of speed with respect to time, this &quot;jerk&quot; is the entire remainder of the first-order expansion of speed with respect to time - it corresponds to the second-order term <em>and all higher order terms</em>. Such terms cannot be combined just as coefficients, since they all have different units corresponding to different powers of time; rather, they can be combined only <em>with their corresponding powers of time</em>, in which case the resulting unit is mm/s.</p>
<p>The units for jerk should be meters per second cubed or m/s<sup>3</sup>. </p> <p>Meters are the basic unit for <em>distance</em>. The first derivative is speed, or <em>velocity</em>, m/s. The second derivative is <em>acceleration</em>, m/s<sup>2</sup>. The third derivative is <em>jerk</em>, m/s<sup>3</sup>.</p> <p>It is rate of change in acceleration. </p> <p>While seldom used, I've only heard it once concerning the Hubble Space telescope, there is a fourth derivative call <em>jounce</em>, m/s<sup>4</sup>. </p>
1,376
<p>I'm working on an editor for files that are used by an important internal testing tool we use. The tool itself is large, complicated, and refactoring or rewriting would take more resources than we are able to devote to it for the forseeable future, so my hands are tied when it comes to large modifications. I must use a .NET language.</p> <p>The files are XML serialized versions of four classes that are used by the tool (let's call them A, B, C, and D). The classes form a tree structure when all is well. Our editor works by loading a set of files, deserializing them, working out the relationships between them, and keeping track of any bad states it can find. The idea is for us to move away from hand-editing these files, which introduces tons of errors.</p> <p>For a particular type of error, I'd like to maintain a collection of all files that have the problem. All four classes can have the problem, and I'd like to reduce duplication of code as much as possible. An important requirement is the user needs to be able to get the items in sets; for example, they need to get all A objects with an error, and telling them to iterate over the whole collection and pick out what they want is unacceptable compared to a <code>GetAs()</code> method. So, my first thought was to make a generic item that related the deserialized object and some metadata to indicate the error:</p> <pre><code>public class ErrorItem&lt;T&gt; { public T Item { get; set; } public Metadata Metadata { get; set; } } </code></pre> <p>Then, I'd have a collection class that could hold all of the error items, with helper methods to extract the items of a specific class when the user needs them. This is where the trouble starts.</p> <p>None of the classes inherit from a common ancestor (other than <code>Object</code>). This was probably a mistake of the initial design, but I've spent a few days thinking about it and the classes really don't have much in common other than a GUID property that uniquely identifies each item so I can see why the original designer did not relate them through inheritance. This means that the unified error collection would need to store <code>ErrorItem&lt;Object&gt;</code> objects, since I don't have a base class or interface to restrict what comes in. However, this makes the idea of this unified collection a little sketchy to me:</p> <pre><code>Public Class ErrorCollection { public ErrorItem&lt;Object&gt; AllItems { get; set; } } </code></pre> <p>However, this has consequences on the public interface. What I really want is to return the appropriate <code>ErrorItem</code> generic type like this:</p> <pre><code>public ErrorItem&lt;A&gt;[] GetA() </code></pre> <p>This is impossible because I can only store <code>ErrorItem&lt;Object&gt;</code>! I've gone over some workarounds in my head; mostly they include creating a new <code>ErrorItem</code> of the appropriate type on-the-fly, but it just feels kind of ugly. Another thought has been using a <code>Dictionary</code> to keep items organized by type, but it still doesn't seem right.</p> <p>Is there some kind of pattern that might help me here? I know the easiest way to solve this is to add a base class that A, B, C, and D derive from, but I'm trying to have as small an impact on the original tool as possible. Is the cost of any workaround great enough that I should push to change the initial tool?</p>
<p>If A, B, C and D have nothing in common then adding a base class won't really get you anything. It will just be an empty class and in effect will be the same as object.</p> <p>I'd just create an ErrorItem class without the generics, make Item an object and do some casting when you want to use the objects referenced. If you want to use any of the properties or methods of the A, B, C or D class other than the Guid you would have had to cast them anyway.</p>
<p>If A, B, C and D have nothing in common then adding a base class won't really get you anything. It will just be an empty class and in effect will be the same as object.</p> <p>I'd just create an ErrorItem class without the generics, make Item an object and do some casting when you want to use the objects referenced. If you want to use any of the properties or methods of the A, B, C or D class other than the Guid you would have had to cast them anyway.</p>
7,784
<p>Is there any difference between</p> <pre><code> int on_exit(void (*function)(int , void *), void *arg); </code></pre> <p>and</p> <pre><code> int atexit(void (*function)(void)); </code></pre> <p>other than the fact that the function used by on_exit gets the exit status?</p> <p>That is, if I don't care about the exit status, is there any reason to use one or the other?</p> <p><strong>Edit:</strong> Many of the answers warned against <code>on_exit</code> because it's non-standard. If I'm developing an app that is for internal corporate use and guaranteed to run on specific configurations, should I worry about this? </p>
<p>According to <a href="http://www.delorie.com/gnu/docs/glibc/libc_560.html" rel="noreferrer">this link</a> I found, it seems there are a few differences. <code>on_exit</code> will let you pass in an argument that is passed in to the <code>on_exit</code> function when it is called... which might let you set up some pointers to do some cleanup work on when it is time to exit.</p> <p>Furthermore, it appears that <code>on_exit</code> was a SunOS specific function that may not be compatible on all platforms... so you may want to stick with atexit, despite it being more restrictive.</p>
<p>@Nathan</p> <p>First, see if there is another API call to determine exit status... a quick glance and I don't see one, but I am not well versed in the standard C API.</p> <p>An easy alternative is to have a global variable that stores the exit status... the default being an unknown error cause (for if the program terminates abnormally). Then, when you call exit, you can store the exit status in the global and retrieve it from any atexit functions. This requires storing the exit status diligently before every exit call, and clearly is not ideal, but if there is no API and you don't want to risk <code>on_exit</code> not being on the platform... it might be the only option.</p>
3,189
<p>What do you use to capture webpages, diagram/pictures and code snippets for later reference?</p>
<p>Evernote <a href="http://www.evernote.com" rel="nofollow noreferrer">http://www.evernote.com</a> and delicious <a href="http://www.delicious.com" rel="nofollow noreferrer">http://www.delicious.com</a></p>
<p>I prefer to use the <a href="http://del.icio.us" rel="nofollow noreferrer">good old url</a> for delicious</p> <p>Apart from that i use the <a href="http://amb.vis.ne.jp/mozilla/scrapbook/" rel="nofollow noreferrer">Scrapbook extension</a> in firefox when i want to save something on the disk. It's possible to tag the page, edit it and remove those stupids ads before saving it.</p> <p>I also have a <a href="http://stickwiki.sourceforge.net/" rel="nofollow noreferrer">Wiki on a stick</a> that i carry around on a usbkey for code snippets that should go to other clients when i'm travelling around</p> <p>Mostly, my code snippets are embedded into projects i carry on the same usb key, which allows me to demonstrate some technologies right off to the client and get his advice based on a demonstration, not a listing of code...</p>
7,658
<p>I have a very strange problem. Under some elusive circumstances I fail to apply any jQuery selector on my pages under IE. It's OK under Firefox though. The jQuery function simply returns empty array. </p> <p>Any suggestions?</p> <p>Page is too complex to post it here. Practically any selector, except <code>"#id"</code> selectors, returns a zero element array. The jQuery version is 1.2.3</p>
<p>Try upgrading to jQuery 1.2.6, you should be on the latest release of jQuery if you are having problems first ensure you are on the latest and greatest.</p>
<p>What version(s) of IE is it failing under? Is it failing for a specific complex selector? I think we need an example.</p> <p>Edit: Does the problem go away if you upgrade to 1.2.6? 1.2.6 is primarily a bug-fix release according to <a href="http://docs.jquery.com/Release:jQuery_1.2.6" rel="nofollow noreferrer">this page</a>.</p> <p>Failing that, the best way to find the problem is to create a minimum page that can reproduce the bug. Without that, it's just about impossible to troubleshoot.</p>
6,137
<p>The HTML standard defines a clear separation of concerns between CSS (presentation) and HTML (semantics or structure).</p> <p>Does anyone use a coding standards document for CSS and XHTML that has clauses which help to maintain this separation? What would be good clauses to include in such a coding standards document?</p>
<p>We don't have a physical document we all adhere to where I work. There are a number of guidelines we try and keep in mind but there isn't really enough information to require a physcial document. <a href="http://www.louddog.com/bloggity/2008/03/css-best-practices.php" rel="nofollow noreferrer">This article</a> sums them up these guidelines pretty well. You may also consider formatting your <code>CSS</code> to make it easier to read. <a href="http://www.smashingmagazine.com/2008/05/02/improving-code-readability-with-css-styleguides/" rel="nofollow noreferrer">Smashing Magazine</a> has a great article on this subject.</p>
<p>The article referred to by @Lee Theobald is a good start.</p> <p>Some basic ideas I try to keep in mind when marking up:</p> <p><strong>Regarding html:</strong></p> <p>Try to write for the next person - that is, think about how easy or difficult it might be for someone else to come and pick up your work and carry on. </p> <p>To support this principle, you should try and make sure your markup is as legible as possible - class and id tags in particular should relate <em>as much as possible</em> to their intended content. In other words, try to use your tags to describe the kind of content they will have. </p> <p>For example, "Sub-navigation", "content" etc. </p> <p>The aim is to provide markup that someone can pickup having not looked at before and get a sense of the logical structure of the document.</p> <p>Also, try to avoid the addition of markup that is purely to achieve a visual effect. But bear in mind that any website that requires even slightly sophisticated styling is unlikely to be able avoid non-semantic markup, due to weaknesses in current implementations of CSS and browser-compatibility issues.</p> <p><strong>Regarding CSS files:</strong></p> <p>Many people divide their css up into sections using comments, separating them into functional or structural areas. So you might have a section for your header, your footer, or typography and so on. Others take this further and split css across files, having one for typography, one for layout etc. However, this can according to Yslow! can have a negative impact on page loading, due to increased http requests.</p> <p>I could write more, but as you can see I struggle to be concise. I hope this is of some use to you.</p>
5,102
<p>I'm thinking about buliding my own 3D printer from scratch. </p> <p>Is it better to buy a starter DIY kit and try to build your printer around it, or to order separate parts for printer, and then to combine a printer?</p>
<p>From a general point of view, there are a few things to consider.</p> <p><strong>If you buy a kit</strong>:</p> <p>Pros:</p> <ul> <li>You get some insurance that <em>you have all the parts that you need</em> to get a functional printer - all the electronics, structure, bolts, nuts, screws, washers, wires and so on.</li> <li>Most likely, all the parts you get are made to <em>fit together</em>.</li> <li>You will (usually) get a <em>manual</em>, often a community that can help you out, and sometimes even technical support.</li> <li>Sometimes, it can be <em>cheaper</em> than buying each part separately (but it can also be more expensive)</li> </ul> <p>Cons:</p> <ul> <li>You have limited/no options to customize your printer to your own preferences without purchasing additional parts. </li> <li>Some kits can be difficult to upgrade later or may be locked to some configuration or software.</li> </ul> <p><strong>My opinion:</strong></p> <p>The way I look at it, the better option for <em>you</em> depends on how you want to spend your time. That is:</p> <ol> <li>If you get a kit, you can spend more time building.</li> <li>If you collect all the parts yourself, you will have to spend time planning, ordering parts (possibly multiple times) in addition to actually building the printer. A possible lack of manuals could also increase the building difficulty.</li> </ol> <p>If you don't already own a 3D printer, I would recommend getting a kit, simply because struggling with trivial things like parts not fitting together can take away the fun for many people.</p>
<p>Three great answers have already been posted, and it has been extremely interesting to read them. I shall try not to repeated what has already been said.</p> <p>I have sourced the parts <em>separately</em> for three different printers:</p> <ul> <li>P3Steel (the frame was a kit, mind: <a href="https://3dprinting.stackexchange.com/questions/3312/orientation-of-long-thin-rod-on-p3steel-v4">Orientation of long thin rod on P3Steel v4</a>)</li> <li>Wilson II</li> <li>Kossel XL and Mini</li> </ul> <p>I have been coding Arduinos and Pis and building robots and quadcopters for a few years now. Then, in November 2016, because I needed a prop guard for a ZMR250 quadcopter that I found hard to obtain, but easy to print, I started reading about 3D printers (mostly RepRap wiki, and then individual blogs of straight forward builds, as well as design modifications, of Prusa, P3Steel, Wilson and Delta/Kossel printers), watching countless construction videos and asking questions here on SE 3D Printers, and reading other's questions and answers, as well as going through eBay for hours at a time, looking up parts and making numerous Bill Of Materials (BOMs) and blogging the information that I gleaned. So this gave me a good grounding and starting point for when I did get around to ordering. In fact, the process is still on going...</p> <p>After ordering the parts, in December, piecemeal, I then had to wait for a month for the parts to arrive from China, during which time I read some more, and revised what I had already learned.</p> <p>I then, finally, got to work on the P3Steel, in January, but two and a half weeks later, before I had finished it, I had to move to BKK for an extended period.</p> <p>I suffered delays with the P3Steel build due to postal latency, obviously, but also, some partial kits where missing critical parts (see <a href="https://3dprinting.stackexchange.com/questions/3332/is-the-8mm-x-20mm-bearing-axle-for-the-x-axis-idler-of-a-p3steel-a-custom-part">Is the 8mm x 20mm bearing axle for the X-axis idler (of a P3Steel) a custom part?</a>), so I had to get them machined in Thailand (because it only costs around $3 to get something machined here). Hopefully, when I get back to the UK, I should have everything to hand and be able to finish the build in a few weeks maximum</p> <p>Once in Bangkok, I started sourcing parts for a Wilson II, and then, subsequently, a Kossel, mostly because the aluminium and steel rods are a quarter, to a half, the price that they are in Europe. Also, I had to go through the ordering process again, getting parts from China for these two printers - however, the parts from China only take two weeks to arrive to Thailand, not a month or so, for the UK. The Wilson II parts I plan to take back to the UK, in order to complete the build there, hopefully printing the plastic parts on the P3Steel, when/if the P3Steel is completed.</p> <p>Note, that seven, or eight months, down the line from when I first took an interest in 3D printing, I <em>still</em> haven't completed a single printer, yet. However, I sure as hell have learnt a lot. Note: most of the delay is due to the six month relocation away from my printer build in the UK.</p> <p>Also, due to my reading of the modification blogs for the Wilson and Kossel, I have recently been re-purchasing upgrades, before I have even fitted a bolt together, for the Kossel and Wilson, let alone completed either of the base builds. For example, I have just purchased Chinese aluminium vertices, rather than the plastic PLA prints that I got from Sintron. So I have ended up with a fair collection of spare (redundant?) parts, but again, it has helped me gain a great insight as to what works well, and what does not.</p> <p>To reiterate that which <a href="https://3dprinting.stackexchange.com/questions/409/what-are-the-pros-and-cons-of-collecting-parts-yourself-versus-getting-a-diy-ki#answer-415">TestGeek has said</a>, <em>one major tip</em> I would have is (and I read this on a forum when I was first getting into 3D printer building), if you are sourcing the parts separately, is to buy bulk (get packs of 10 pcs, 50 pcs, 100 pcs), and buy more than you require: nuts, bolts, bearings, GT2 belt, GT2 pulleys. The price comes down phenomenally, and you can resell the spares, locally, for about as much as you paid for the whole lot, online, thereby covering, or almost covering, the cost of the printer. Plus, spares come in handy for further builds down the road. Don't buy anything from the US (unless you are already in the US, I guess) - the import/postage fees are outrageous.</p> <hr /> <h3>TL;DR</h3> <p>In the same way as you learn more from building a kit as opposed to buying a pre-built printer, you will learn more sourcing the parts separately, but it might cost more, in redundant parts. Also:</p> <ul> <li>Research extensively first</li> <li>Buy bulk</li> <li>Be prepared for delays, be patient</li> <li>Be prepared for an iterative design</li> </ul>
172
<p>So I'm working on a project that will allow users to enter <strong>poker hand histories</strong> from sites like PokerStars and then display the hand to them.</p> <p>It seems that regex would be a great tool for this, however I rank my regex knowledge at "slim to none".</p> <p>So I'm using PHP and looping through this block of text line by line and on lines like this:</p> <pre><code>Seat 1: fabulous29 (835 in chips) Seat 2: Nioreh_21 (6465 in chips) Seat 3: Big Loads (3465 in chips) Seat 4: Sauchie (2060 in chips) </code></pre> <p>I want to extract seat <code>number, name, &amp; chip count</code> so the format is</p> <pre><code>Seat [number]: [letters&amp;numbers&amp;characters] ([number] in chips) </code></pre> <p>I have NO IDEA where to start or what commands I should even be using to optimize this.</p> <p>Any advice is greatly appreciated - even if it is just a link to a tutorial on PHP regex or the name of the command(s) I should be using.</p>
<p>Look at the PCRE section in the PHP Manual. Also, <a href="http://www.regular-expressions.info/" rel="nofollow noreferrer">http://www.regular-expressions.info/</a> is a great site for learning regex. Disclaimer: Regex is very addictive once you learn it.</p>
<pre><code>Seat [number]: [letters&amp;numbers&amp;characters] ([number] in chips) </code></pre> <p>Your Regex should look something like this</p> <pre><code>Seat (\d+): ([a-zA-Z0-9]+) \((\d+) in chips\) </code></pre> <p>The brackets will let you capture the seat number, name and number of chips in groups.</p>
3,729
<p>As it stands now, I'm a Java and C# developer. The more and more I look at Ruby on Rails, the more I really want to learn it. </p> <p>What have you found to be the best route to learn RoR? Would it be easier to develop on Windows, or should I just run a virtual machine with Linux? </p> <p>Is there an IDE that can match the robustness of Visual Studio? Any programs to develop that give a good overhead of what to do? Any good books? </p> <p>Seriously, any tips/tricks/rants would be awesome.</p>
<p>I've been moving from C# in my professional career to looking at Ruby and RoR in my personal life, and I've found linux to be slightly more appealing personally for development. Particularly now that I've started using git, the implementation is cleaner on linux.</p> <p>Currently I'm dual booting and getting closer to running Ubuntu full time. I'm using gedit with various plugins for the development environment. And as of late 2010, I'm making the push to use Vim for development, even over Textmate on OS X.</p> <p>A large amount of the Rails developers are using (gasp) Macs, which has actually got me thinking in that direction.</p> <p>Although I haven't tried it, <a href="http://www.sapphiresteel.com/" rel="nofollow noreferrer">Ruby in Steel</a> gives you a Ruby IDE inside the Visual Studio world, and <a href="http://www.ironruby.net/" rel="nofollow noreferrer">IronRuby</a> is the .NET flavor of Ruby, if you're interested.</p> <p>As far as books are concerned, the <em><a href="http://pragprog.com/titles/ruby3/programming-ruby-3" rel="nofollow noreferrer">Programming Ruby</a></em> (also known as the Pickaxe) book from the Pragmatic Programmers is the de-facto for learning Ruby. I bit the bullet and purchased that book and <em><a href="http://pragprog.com/book/rails4/agile-web-development-with-rails" rel="nofollow noreferrer">Agile Web Development with Rails</a></em>; both books have been excellent.</p> <p><a href="http://peepcode.com/" rel="nofollow noreferrer">Peepcode</a> screencasts and PDF books have also been great for getting started; at $9 per screencast it's hard to go wrong. I actually bought a 5-pack.</p> <p>Also check out the following:</p> <ul> <li><a href="http://guides.rubyonrails.org/" rel="nofollow noreferrer">Official Rails Guides</a></li> <li><a href="http://railscasts.com/" rel="nofollow noreferrer">Railscasts</a></li> <li><a href="http://railsapi.com/" rel="nofollow noreferrer">railsapi.com</a> or <a href="http://apidock.com/rails" rel="nofollow noreferrer">Ruby on Rails - APIdock</a></li> <li><a href="http://rubyshow.com/" rel="nofollow noreferrer">The Ruby Show</a></li> <li><a href="http://railsforzombies.org" rel="nofollow noreferrer">Rails for Zombies</a></li> <li><a href="http://www.softiesonrails.com/" rel="nofollow noreferrer">Softies on Rails</a> - Ruby on Rails for .NET Developers</li> <li><a href="http://podcast.rubyonrails.org/" rel="nofollow noreferrer">Rails Podcast</a></li> <li><a href="http://www.codeschool.com/courses/rails-best-practices" rel="nofollow noreferrer">Rails Best Practices</a></li> </ul> <p>I've burned through the backlog of Rails and Rails Envy podcasts in the past month and they have provided wonderful insight into lots of topics, even regarding software development in general.</p>
<p>Ruby: I used Learn to program (in a weekend), Ruby Visual QuickStart (believe it or not this QS book was "off the hook" excellent). This took about a week.</p> <p>Rails: I just went through Learn Rails in one "aggressive" week. Definitely feel I have the nuts and bolts. It's 2009 which I deemed important!</p> <p>Now I plan to combine a more advanced book with a real project. </p> <p>IDE: VIM with rails plugin is great if you're a vim addict. Otherwise, try any suggested above.</p> <p>Of course railscast, etc., are useful for most up to date stuff.</p>
7,937
<p>We all know, that the best layer hight is, when you have multiples of full steps. If it is not, sometimes steps get skipped and end up bad layer-to-layer adhesion when one height step missed a tiny bit and then the next catches up, creating an extra-thick layer. For example, this was printed somewhat deliberately, and here, the extra spaced layers are perfect for delaminating the print with just a fingernail:</p> <p><a href="https://i.stack.imgur.com/QwkYK.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/QwkYK.jpg" alt="Delaminating Print"></a></p> <p>The Ender 3 I have uses the following Z-Rod:</p> <ul> <li>Diameter 8 mm</li> <li>4 flutes</li> <li>ca 13 Threads per inch <ul> <li>That is <a href="https://mdmetric.com/tech/tict.htm" rel="noreferrer">according to the table</a>, a 2 mm pitch for <em>one</em> thread.</li> <li>As a result, it's an 8 mm pitch for each of the 4 threads.</li> </ul></li> </ul> <p>The firmware (Marlin) I use claims in <code>configuration.h</code> that the NEMA17 motor would be using 400 Steps per mm in Z. <code>configuration_adv.h</code> tells that the microsteps on the Z-axis motor are 16.</p> <p>In the printer's menu, Babystepping is in increments of 0.049 mm (though some rounding error seems to be there: 5 Babysteps are 0.250 mm).</p>
<blockquote> <p>that the NEMA17 motor would be using 400 Steps per mm in Z. <code>configuration_adv.h</code> tells that the microsteps on the Z-axis motor are 16.</p> </blockquote> <p>Easy. There are 400 microsteps in a millimeter, and 16 microsteps in a full step. So, there are 400/16=25 full steps in a millimeter. So a full step is 1/25<sup>th</sup> of a millimeter, or 0.04&nbsp;mm. Your layer height should be a multiple of this.</p> <p>As your leadscrew has a lead of 8&nbsp;mm (i.e., a full rotation will move the Z-axis by 8&nbsp;mm), a full step is either 8/200=0.04&nbsp;mm (for a 1.8 degree stepper) or 8/400=0.02&nbsp;mm (for a 0.9 degree stepper). So, apparently, you have a 1.8 degree stepper (and this is the most common type of stepper).</p>
<p>I see you've already accepted an answer, but based on your comments I think you have some misunderstandings of the topic which are worth clarifying as part of answering this question.</p> <blockquote> <p>0.2125 layer height (+1/4 microstep) and doing all the movements in absolute movements instead of relative forced the result, as the target heights were as a result at 0.2125 mm (for the stepper that's effectively a 0.2 mm), 0.425 (0.4), 0.675 (for the stepper that's, depending on rounding or truncting, 0.6 or 0.7), 0.9 (here they are both 0.9) and so on.</p> </blockquote> <p>It sounds like your understanding is that the stepper driver is "rounding"/"truncating" to Z positions that are multiples of 0.1 mm. Perhaps that's based on the LCD status display of the Ender 3's firmware, which is based on Marlin 1.0 or something around that version, and shows current coordinates rounded or truncated (I forget which) to one decimal place. This does not have anything to do with the positioning limitations of the actual machine; it's just bad user interface design.</p> <p>The actual firmware position is translated from the floating point value in the gcode to the nearest step/microstep that the stepper driver can represent. With full steps being 0.04 mm, microsteps are 0.0025 mm (1/16 of a step). All of these positions are "exact" in a logical sense, but of course subject to physical limits of the mechanical parts and accuracy of microstepping. On the topic of microstepping accuracy, you should read <a href="https://hackaday.com/2016/08/29/how-accurate-is-microstepping-really/" rel="nofollow noreferrer">How Accurate Is Microstepping Really?</a> Most if not all models of the Ender 3 have A4988 stepper drivers, one of the chips reviewed in that article. But the important part is that there's no rounding/truncation to whole steps taking place. Rather, the stepper driver is <em>trying</em> to position the motor in between whole steps by balancing the magnetic fields pulling it in each direction, with the goal of producing a linear interpolation between the two adjacent full steps. How well it does this is a matter of the quality of the stepper drivers and the load on the motor.</p> <p>Back to your test, your layer height of 0.2125 mm is not one step plus 1/4 microstep. It's 5 steps (5 * 0.04 mm) plus 0.0125 mm which is 5 microsteps. This is probably a decent test - 5 is 1 mod 16, so you'll end up with a period-16 cycle of microstep positions, at 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, and 11 microsteps mod the whole step. This is pretty close to a period of 3, so you might expect to see some irregularity from poor microstepping accuracy that looks periodic every 3 layers, or you might see it repeating only every 16 layers (every 3.4 mm). But regardless I would not expect delamination problems from this. I think there's another serious extrusion problem behind the photo in your question, and you should probably open a new question about what it might be.</p>
1,464
<p>I've started working with ASP.net AJAX (finally ☺). and I've got an update panel together with a asp:UpdateProgress. My Problem: The UpdateProgress always forces a line-break, because it renders out as a div-tag.</p> <p>Is there any way to force it being a span instead? I want to display it on the same line as some other controls without having to use a table or even <em>shudders</em> absolute positioning in CSS.</p> <p>I'm stuck with ASP.net AJAX 1.0 and .net 3.0 if that makes a difference.</p>
<p>I've had the same issue. There is no easy way to tell the updateProgress to render inline. You would be better off to roll your own updateProgress element. You can add a beginRequest listener and endRequest listener to show and hide the element you want to display inline. Here is simple page which shows how to do it:</p> <p><strong>aspx</strong></p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager ID="sm" runat="server"&gt;&lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel runat="server" ID="up1" UpdateMode="Always"&gt; &lt;ContentTemplate&gt; &lt;asp:Label ID="lblTest" runat="server"&gt;&lt;/asp:Label&gt; &lt;asp:Button ID="btnTest" runat="server" Text="Test" OnClick="btnTest_OnClick" /&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;img id="loadingImg" src="../../../images/loading.gif" style="display:none;"/&gt;&lt;span&gt;Some Inline text&lt;/span&gt; &lt;script&gt; Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function(sender, args) { if (args.get_postBackElement().id == "btnTest") { document.getElementById("loadingImg").style.display = "inline"; } }); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(sender, args) { if (document.getElementById("loadingImg").style.display != "none") { document.getElementById("loadingImg").style.display = "none"; } }); &lt;/script&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p><strong>cs</strong></p> <pre><code>public partial class updateProgressTest : System.Web.UI.Page { protected void btnTest_OnClick(object sender, EventArgs e) { System.Threading.Thread.Sleep(1000); this.lblTest.Text = "I was changed on the server! Yay!"; } } </code></pre>
<p>You can make a div inline like this:</p> <pre><code>&lt;div style="display:inline"&gt;stuff&lt;/div&gt; </code></pre> <p>I'm skeptical of it rendering the div for you though... I don't remember having this problem on my pages...</p>
6,401
<p>I have a windows laptop (thinkpad) and somewhat recently rediscovered emacs and the benefit that all those wacky shortcuts can be when the arrow keys are located somewhere near you right armpit.</p> <p>I was discouraged after php-mode, css-mode, etc, under mmm-mode was inconsistent, buggy, and refused to properly interpret some of my files. (In all fairness, I'm most likely doin' it wrong) So I eventually found the nxhtml package which worked pretty well.</p> <p>However, nxhtml causes weird bugs and actually crashes on certain files (certain combinations of nested modes I supposed) under linux! (using Ubuntu 7.10 and Kubuntu 8.04)</p> <p>I'd like to be able to work on the laptop as well as the home linux pc without having to deal with inconsistent implementations of something that shouldn't be this hard. I've googled and looked around and there's a good chance I'm the only human on the planet having these problems... Anyone got some advice?</p> <p>(in lieu of an emacs solutions, a good enough cross-platform lightweight text editor with the dev features would also work I suppose...)</p>
<p>Although I use emacs when I have to (ie. when I'm at the command line), I use <a href="http://www.eclipse.org/" rel="nofollow noreferrer">Eclipse</a> for all my real development work. If you get the <a href="http://www.eclipse.org/webtools/wst/main.php" rel="nofollow noreferrer">Web Standards Toolkit</a> plug-in for it, it can do syntax coloring, tag auto-completion, and other fun stuff.</p> <p>Alternatively, if Eclipse is to "heavy" for you, <a href="http://www.jedit.org/" rel="nofollow noreferrer">jEdit</a> is another excellent program for doing web development (it has most of it's web dev support built in, but you can also get some additional plug-ins for features like HTML Tidy).</p> <p>Both programs are open source and Java-based, which means they're both free and run on (virtually) any platform.</p>
<p>You could try mmm-mode and multi-mode. I haven't tried them: I'm happy with nxhtml for now. What sort of problems did you encounter?</p>
7,822
<p>Do you know any open source/free software C++ libraries to manipulate images in these formats: .jpg .gif .png .bmp ? The more formats it supports, the better. I am implementing a free program in C++ which hides a text file into one or more images, using <a href="http://en.wikipedia.org/wiki/Steganography" rel="nofollow noreferrer">steganography</a>.</p> <p>I am working under Unix.</p>
<p><a href="http://www.imagemagick.org/" rel="noreferrer">ImageMagick</a> can manipulate about anything and has interfaces for a <a href="http://www.imagemagick.org/script/api.php" rel="noreferrer">dozen of languages</a>, including the <a href="http://www.imagemagick.org/Magick++/" rel="noreferrer">Magick++</a> API for C++.</p>
<p>Have you considered <a href="http://www.codeproject.com/KB/GDI-plus/cgdiplusbitmap.aspx" rel="nofollow noreferrer">GDI</a>?</p> <p>-- Kevin Fairchild</p>
6,301
<p>I'm setting up my team's source control + build/integration process from scratch. We were using VSS and a tool we created in-house to perform the build process. We decided to move on to a more modern environment. I have the SVN running, and I would like to set a continuous integration process with CruiseControl.NET. Is there a good step-by-step starter guide that will get me started with the best practices of this tool?</p>
<p>Before leveraging CruiseControl to it's fullest extent, you need to create an automated build script that can be run by msbuild or nant. After you get your project building in one step, then you can start integrating CruiseControl into the mix. Here are some resources to help get you started:</p> <ul> <li><a href="http://cruisecontrolnet.org/projects/ccnet/wiki" rel="nofollow noreferrer">CruiseControl.net Wiki</a> - A very good resource.</li> <li><a href="http://cruisecontrolnet.org/projects/ccnet/wiki/Subversion_(svn)" rel="nofollow noreferrer">CruiseControl.net SourceControl Block</a> - Shows how to use svn with CruiseControl.net with the sourcecontrol block</li> <li><a href="http://justinram.wordpress.com/2006/07/20/continuous-integration-cruisecontrolnet-subversion-msbuild-net-20/" rel="nofollow noreferrer">Getting CruiseControl.net, MsBuild, and SVN setup</a> - A resource stepping you through the steps to get everything meshing together.</li> </ul>
<p>Really, the <a href="http://confluence.public.thoughtworks.org/display/CCNET/Documentation" rel="nofollow noreferrer">documentation</a> is pretty solid</p>
3,781
<p>With hot plastic being laid down layer after layer, I am worried about fumes. Should I only print in a well ventilated work space? Should I add additional ventilation?</p>
<p>The short answer is: <strong>yes, it is always a good idea to print in a well-ventilated area</strong>. The longer answer can be articulated as follows:</p> <h3>Definition of &quot;fumes&quot;</h3> <p>&quot;Fumes&quot; is a fuzzy word that from a chemical/physical perspective includes at least three different things:</p> <ul> <li><strong>Vapour</strong> - the gas phase of a substance</li> <li><strong>Aerosol</strong> - a airborne suspension of tiny particles of liquid, solid, or both</li> <li><strong>Smoke</strong> - particles and gases emitted when a material undergoes combustion or pyrolysis (so really: a smoke is a combination of <em>vapours</em> and <em>aerosols</em> too... but the combustion/pyrolysis will have changed the very nature of the material, so it will be &quot;vapours and aerosols of <em>a different substance</em>&quot;</li> </ul> <h3>Interactions with the human body</h3> <p>Each of the above has a different way of interacting with the human body. The list of possible interactions is huge, and out-of-scope for this answer, but just to mention a few obvious ones:</p> <ul> <li>Vapours tend to enter cells by osmotic pressure and can have carcinogenic effects by either attacking the genome of the cell or by disrupting its metabolic processes (think: benzene in car fuel)</li> <li>Aerosols can trigger the immune system, and in return have the body develop allergies or autoimmune reactions.</li> <li>Aerosols can deposit their particles on the cellular membrane, making it impossible for it to operate correctly and eventually fail (like neurons failing to transmit electrical impulses, for example)</li> <li>...</li> </ul> <h3>Composition of filaments</h3> <p>Modern filaments are a combination of different substances: the basic plastic (PLA, ABS, PETG...) that gives the name to the filament is almost always mixed with <em>other plastics</em> and additives that change its physical characteristics.</p> <p>In some cases, the filament is host to <em>particles of other materials</em> (like wood, metals or phosphorescent compounds).</p> <p>Each of the different materials have different transition and critical and flash points (the temperatures at which they will become vapour and ignite respectively), and different physical properties which in turn will affect differently the size of the particles in the aerosol coming out of the printer.</p> <h3>Conclusion</h3> <p>The bottom-line is that it is close to impossible to have a <em>complete</em> understanding of how a given &quot;fume&quot; affects human health.</p> <p>Typically the safety of a substance is tested in a lab by directly observing its effect on cells, or by performing epidemiological studies in a population, if the exposure data to a given substance is known.</p> <p>When people comment on PLA being &quot;safe&quot; for example, they typically refer to studies that tested inert, cold, chemically pure PLA. But the <em>fumes</em> of a PLA filament will probably not be inert, nor cold, nor be exclusively PLA.</p> <p>Additionally, it has to be observed that it is much easier to rule a filament harmful than safe: for it to be considered harmful it is sufficient to know that one of its components is harmful (for ABS that is typically studies showing the adverse affect of ABS aerosols on health). For it to be deemed safe, one must know that <em>all</em> if its components are safe, but most filament do not go through the rigorous testing required to ascertain that.</p> <p>In conclusion, <strong>it is always a good idea to get rid of the fumes from 3D printing regardless of the type filament being used</strong>. The ideal solution is a printing enclosure maintaining negative pressure, but an enclosure with air filtering or a well ventilated room are also good options (ventilation can have adverse effects on printing quality though, due to drafts and their cooling effect).</p>
<p>There are some contradicting sources out there on whether plastics, especially ABS, have toxic fumes. It is well known that PLA is food safe, as it is an organic, biodegradable polymer being based on a particular cornstarch. This means that PLA <em>is</em> safe when printing, although it can produce foul smells from the dyes and other ingredients. As for the other plastics, it is most commonly said that the fumes are toxic, although, as stated earlier, there are some contradicting topics on this.</p> <p><a href="https://thesoftlanding.com/is-acrylonitrile-butadiene-styrene-abs-plastic-toxic/" rel="nofollow noreferrer">Here</a> and <a href="https://3dprintingindustry.com/news/toxic-abs-pla-fumes-3dsafety-org-inquires-vocs-60796/" rel="nofollow noreferrer">here</a> are some articles for further reading.</p>
873
<p>What do you think is the best set-up for RoR in a Win Vista environment? I've tried the radrails eclipse plug-in, and it just seemed too bulky for me, I've also started to just use Textpad and the command line, but I'm used to having somewhat of an IDE to work with.</p>
<p>I don't know about "best", because that's a subjective question, but I can tell you what setup I use and recommend:</p> <p><strong>Editor</strong>: <a href="http://e-texteditor.com" rel="noreferrer">E Text Editor</a><br> TextMate seems to be the editor of choice for Rails on Mac. E Text Editor is essentially TextMate for Windows. Its bundles are broadly compatible with TextMate's including the Rails 2 bundle which is included with the basic install.</p> <p>Alternatively, if you're into the whole Visual Studio ecosystem, then <a href="http://www.rubyinside.com/ruby-in-steel-pe-free-visual-studio-based-ruby-and-rails-ide-for-windows-1228.html" rel="noreferrer"><strong>Ruby in Steel PE</strong></a> might be a better bet. It's a really nice all-in-one package that actually comes with (a stripped-down version of) Visual Studio now.</p> <p><strong>Environment</strong>: <a href="http://www.virtualbox.org/" rel="noreferrer">VirtualBox</a> running Ubuntu Server<br> Deploying a Rails app can be a pain at the best of times; deploying a Rails app from a Windows environment onto a *nix server is even worse. Plus, <a href="http://railsforum.com/viewtopic.php?id=7219" rel="noreferrer">running Rails apps on Windows is slow</a>. Running your tests is slow. So I use VirtualBox to host a VM on my Windows machine that mirrors my target deployment environment as closely as possible. In my case I run Ubuntu Server because there are a really nice set of step-by-step tutorials for getting up-and-running with a full Ubuntu-based Rails stack on the <a href="http://articles.slicehost.com/ubuntu-hardy" rel="noreferrer">SliceHost wiki</a>. </p> <p>Here are the benefits of developing using a VM:</p> <ul> <li>I map a network drive to the VM so that I can edit the code on it directly from Windows using E Text Editor. The VM acts and feels just like a command line window. So you don't feel like you're in a completely alien environment.</li> <li>It runs Rails and other Ruby scripts (like tests) faster than running it natively in Windows</li> <li>Everything is contained and <a href="http://servervirtualization.blogs.techtarget.com/2008/06/25/getting-to-know-sun-xvm-virtualbox-snapshots/" rel="noreferrer">snapshottable</a>, so I can experiment and generally play around without worrying about breaking anything. If something does break, I just roll back to a previous good state.</li> <li>It uses hardly any RAM. It will typically use less that 100MB (it's currently using ~43MB, but I don't have a Rails app spun-up). Contrast this with, say, Firefox which will typically be hogging >200MB and you realize that running a Linux-based VM like this is amazingly efficient.</li> <li>I can move my environment between machines</li> <li>I have much more robust deployment workflow</li> <li>I can limit the VM to have exactly the same amount of RAM as the server I'll be hosting on. E.g., if I'm to be using a SliceHost 256MB slice, I would limit the RAM to 256MB.</li> <li>I can build a seperate environment for different hosts. If I wanted to host on Joyent, for example, I could build an Open Solaris VM</li> <li>Gems and other binaries won't need recompiling for your target environment</li> <li>It's "a good thing"™ to get to grips with the environment your Rails app is likely to be running on. Seeing as most, if not all, commercial Rails hosts run some sort of *nix derivative, you're going to want to be comfortable with the *nix environment.</li> </ul>
<p>You might want to take a look at this:</p> <p><a href="http://www.sapphiresteel.com/" rel="nofollow noreferrer">http://www.sapphiresteel.com/</a></p> <p>There's a free personal edition too</p> <p>(Updated: Assuming that you already have Visual Studio Full Fat Edition)</p>
2,554
<p>SQL Experts,</p> <p>Is there an efficient way to group runs of data together using SQL?<br> Or is it going to be more efficient to process the data in code. </p> <p>For example if I have the following data:</p> <pre><code>ID|Name 01|Harry Johns 02|Adam Taylor 03|John Smith 04|John Smith 05|Bill Manning 06|John Smith </code></pre> <p>I need to display this:</p> <pre><code>Harry Johns Adam Taylor John Smith (2) Bill Manning John Smith </code></pre> <p>@Matt: Sorry I had trouble formatting the data using an embedded html table it worked in the preview but not in the final display.</p>
<p>Try this:</p> <pre><code>select n.name, (select count(*) from myTable n1 where n1.name = n.name and n1.id &gt;= n.id and (n1.id &lt;= ( select isnull(min(nn.id), (select max(id) + 1 from myTable)) from myTable nn where nn.id &gt; n.id and nn.name &lt;&gt; n.name ) )) from myTable n where not exists ( select 1 from myTable n3 where n3.name = n.name and n3.id &lt; n.id and n3.id &gt; ( select isnull(max(n4.id), (select min(id) - 1 from myTable)) from myTable n4 where n4.id &lt; n.id and n4.name &lt;&gt; n.name ) ) </code></pre> <p>I think that'll do what you want. Bit of a kludge though.</p> <p>Phew! After a few edits I think I have all the edge cases sorted out.</p>
<p>For this particular case, all you need to do is group by the name and ask for the count, like this:</p> <pre><code>select Name, count(*) from MyTable group by Name </code></pre> <p>That'll get you the count for each name as a second column.</p> <p>You can get it all as one column by concatenating like this:</p> <pre><code>select Name + ' (' + cast(count(*) as varchar) + ')' from MyTable group by Name </code></pre>
4,166
<p>What memory leak detectors have people had a good experience with?</p> <p>Here is a summary of the answers so far:</p> <p><a href="http://valgrind.org/" rel="noreferrer">Valgrind</a> - Instrumentation framework for building dynamic analysis tools.</p> <p><a href="http://directory.fsf.org/project/ElectricFence/" rel="noreferrer">Electric Fence</a> - A tool that works with GDB</p> <p><a href="http://splint.org/" rel="noreferrer">Splint</a> - Annotation-Assisted Lightweight Static Checking</p> <p><a href="http://www.glowcode.com/" rel="noreferrer">Glow Code</a> - This is a complete real-time performance and memory profiler for Windows and .NET programmers who develop applications with C++, C#, or any .NET Framework</p> <p>Also see this <a href="https://stackoverflow.com/questions/45627/how-do-you-detectavoid-memory-leaks-in-your-unmanaged-code">stackoverflow post</a>.</p>
<p>second the <a href="http://valgrind.org/" rel="noreferrer">valgrind</a>... and I'll add <a href="http://directory.fsf.org/project/ElectricFence/" rel="noreferrer">electric fence</a>.</p>
<p>I'll second the valgrind as an external tool for memory leaks.<br> But, for most of the problems I've had to solve I've always used internally built tools. Sometimes the external tools have too much overhead or are too complicated to set up.</p> <p>Why use already written code when you can write your own :)</p> <p>I joke, but sometimes you need something simple and it's faster to write it yourself. Usually I just replace calls to malloc() and free() with functions that keep better track of who allocates what. Most of my problems seem to be someone forgot to free and this helps to solve that problem.</p> <p>It really depends on where the leak is, and if you knew that, then you would not need any tools. But if you have some insight into where you think it's leaking, then put in your own instrumentation and see if it helps you. </p>
7,686
<p>How do you OCR an tiff file using Tesseract's interface in c#?<br> Currently I only know how to do it using the executable.</p>
<p>Take a look at <a href="http://www.pixel-technology.com/freeware/tessnet2/" rel="noreferrer">tessnet</a></p>
<p>Disclaimer: I work for Atalasoft</p> <p>Our <a href="http://www.atalasoft.com/products/dotimage/ocr" rel="nofollow noreferrer">OCR module supports Tesseract</a> and if that proves to not be good enough, you can upgrade to a better engine and just change one line of code (we provide a common interface to multiple OCR engines).</p>
5,025
<p>I have a number of tracks recorded by a GPS, which more formally can be described as a number of line strings.</p> <p>Now, some of the recorded tracks might be recordings of the same route, but because of inaccurasies in the GPS system, the fact that the recordings were made on separate occasions and that they might have been recorded travelling at different speeds, they won't match up perfectly, but still look close enough when viewed on a map by a human to determine that it's actually the same route that has been recorded.</p> <p>I want to find an algorithm that calculates the similarity between two line strings. I have come up with some home grown methods to do this, but would like to know if this is a problem that's already has good algorithms to solve it.</p> <p>How would you calculate the similarity, given that similar means represents the same path on a map?</p> <p><b>Edit:</b> For those unsure of what I'm talking about, please look at this link for a definition of what a line string is: <a href="http://msdn.microsoft.com/en-us/library/bb895372.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb895372.aspx</a> - I'm <i>not</i> asking about character strings.</p>
<p>Compute the <a href="http://cgm.cs.mcgill.ca/~athens/cs507/Projects/2002/StephanePelletier/#what" rel="nofollow noreferrer">Fréchet distance</a> on each pair of tracks. The distance can be used to gauge the similarity of your tracks.</p> <p><em>Math alert:</em> Fréchet was a pioneer in the field of <a href="http://en.wikipedia.org/wiki/Metric_space" rel="nofollow noreferrer">metric space</a> which is relevant to your problem.</p>
<p>I actually side with the person (Aaron F) who said that you might be interested in the Levenshtein distance problem (and cited <a href="http://en.wikipedia.org/wiki/Fasta" rel="nofollow noreferrer">this</a>). His answer seems to me to be the best so far.</p> <p>More specifically, Levenshtein distance (also called edit distance), does not measure strictly the character-by-character distance, but also allows you to perform insertions and deletions. The best algorithm for this distance measure can be computed in quadratic time (pretty slow if your strings are long), but the computational biologists have pretty good heuristics for this, that might be of interest to you on their own. Check out <a href="http://en.wikipedia.org/wiki/BLAST" rel="nofollow noreferrer">BLAST</a> and <a href="http://en.wikipedia.org/wiki/Fasta" rel="nofollow noreferrer">FASTA</a>.</p> <p>In your problem, it seems that you are dealing with differences between strings of numbers, and you care about the numbers. If you give more information, I might be able to direct you to the right variant of BLAST/FASTA/etc for your purposes. In any case, you might consider adapting BLAST and FASTA for your needs. They're quite simple.</p> <p><a href="http://en.wikipedia.org/wiki/Fasta" rel="nofollow noreferrer">1</a>: <a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Levenshtein_distance</a>, <a href="http://www.nist.gov/dads/HTML/Levenshtein.html" rel="nofollow noreferrer">http://www.nist.gov/dads/HTML/Levenshtein.html</a></p>
8,793
<p>I have a UserControl that consists of three TextBoxes. On a form I can have one or more or my UserControl. I want to implement my own tab behavior so if the user presses Tab in the second TextBox I should only move to the third TextBox if the the second TextBox has anything entered. If nothing is entered in the second TextBox the next control of the form should get focus as per the normal tab behavior. If the user hasn't entered anything in the first or second TextBox and the presses tab there is this special case where a control on the form should be skipped. </p> <p>By using the ProcessDialogKey I have managed to get it work kind of ok but I still have one problem. My question is if there is a way to detect how a WinForms control got focus since I would also like to know if the my UserControl got focus from a Tab or Shift-Tab and then do my weird stuff but if the user clicks the control I don't want to do anything special. </p>
<p>As a general rule, I would say overriding the standard behavior of the TAB key would be a bad idea. Maybe you can do something like disabling the 3rd text box until a valid entry is made in the 2nd text box.</p> <p><em>Now, having said this, I've also broken this rule at the request of the customer. We made the enter key function like the tab key, where the enter key would save the value in a text field, and advance the cursor to the next field.</em></p>
<p>I agree with DannySmurf. Messing with the tab order might give you hell later on if the requirements for the application change.</p> <p>Another thing that you could do is to implement some kind of wizard for the user to go through.</p>
3,431
<p>I have a servlet that is used for many different actions, used in the <a href="http://java.sun.com/blueprints/patterns/FrontController.html" rel="noreferrer">Front Controller pattern</a>. Does anyone know if it is possible to tell if the data posted back to it is enctype="multipart/form-data"? I can't read the request parameters until I decide this, so I can't dispatch the request to the proper controller.</p> <p>Any ideas?</p>
<p>Yes, the <code>Content-type</code> header in the user agent's request should include <code>multipart/form-data</code> as described in (at least) the HTML4 spec:</p> <p><a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2" rel="noreferrer">http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2</a></p>
<p><a href="https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getParts()" rel="nofollow noreferrer">https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getParts()</a></p> <p>java.util.Collection getParts()</p> <p>Throws: ServletException - if this request is not of type multipart/form-data</p>
9,194
<p>I am looking for a Regular expression to match only if a date is in the first 28 days of the month. This is for my validator control in ASP.NET</p>
<p>Don't do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse routine instead:</p> <pre><code>DateTime parsedDate; if ( DateTime.TryParse( dateString, out parsedDate) &amp;&amp; parsedDate.Day &lt;= 28 ) { // logic goes here. } </code></pre> <p>Regex is nearly the <a href="http://en.wikipedia.org/wiki/Golden_hammer" rel="nofollow noreferrer">golden hammer</a> of input validation, but in this instance, it's the wrong choice.</p>
<p>Why not just covert it to a date data type and check the day? Using a regular expression, while it could be done, just makes it overly complicated.</p>
7,252
<p>I"m considering making my own filament, with a device like the one at <a href="http://www.thingiverse.com/thing:380987" rel="nofollow noreferrer">http://www.thingiverse.com/thing:380987</a>. Partly because it's another machine to build, which is cool, but also to save money on filament.</p> <p>Has anyone here tried to make their own filament? My main questions are:</p> <ul> <li><p>Is the quality comparable to typical off-the-shelf filaments? Put another way, with reasonable tuning can one produce filament that's good enough to use without a lot of frustration?</p></li> <li><p>Does it require a lot of attention to tuning, monitoring, or other details (which make it less worthwhile / more time-consuming)? Warning of pitfalls to avoid is also welcome.</p></li> <li><p>Are there useful things one can do this way, that are hard to achieve with off-the-shelf filaments? For example, unusual materials; better control of diameter, density, etc; or mixing one's own colors?</p></li> </ul>
<ol> <li><p>Quality depends on 3 things:</p> <ol> <li><p>Quality of pellets (purity, fillers, color)</p></li> <li><p>Where/how they are stored before and during the extrusion (humidity, contaminants)</p></li> <li><p>Have a filter in your extruder to get rid of random junk and air bubbles ending up in your filament (250 micron wire mesh filter)</p></li> </ol></li> </ol> <p>There's no secret formula the filament producing companies have, they just have very efficient and very fast filament producing machines (of course very expensive, too). But when it comes to vanilla ABS or PLA, it's almost the same content.</p> <ol start="2"> <li><p>Personal experience: no. If you get the same pellets, store it in the same place and run your extruder in the same place, it should behave the same.</p></li> <li><p>I don't think there is some filament mixture you won't be able to find anywhere, but you might be able to make it yourself cheaper. Example: mixing strontium aluminate powder for glow in the dark filament (come in many colors, not just green).</p></li> </ol> <p>I'd recommend this design: <a href="http://www.instructables.com/id/Build-your-own-3d-printing-filament-factory-Filame/" rel="nofollow noreferrer">http://www.instructables.com/id/Build-your-own-3d-printing-filament-factory-Filame/</a> It produces filament pretty fast (one full 1kg spoon in 3-4 hours). Just make sure you have enough experience to not electrocute yourself while assembling this as the heaters use mains power.</p> <p>I personally think the commercial "hobby" extruders are not worth the money. I also own the Filastruder and it's just no different and slower than the above, unless you care about a pretty plywood case for your extruder I see no advantage and since it uses off-the-shelf parts itself why bother buying a kit like that than sourcing the parts yourself?</p>
<p>You can basically use any machine that pulverizes your pellets into small pieces.</p> <p><a href="https://www.3dhubs.com/talk/thread/how-make-your-own-filament-recycling-old-3d-prints-part-1" rel="noreferrer"><strong>One guy on 3dhubs, explained it in details.</strong></a></p> <p>My conclusion is that you can recycle everything using this data gathered from research up in link there. </p> <p>Also, you can use any plastic material and pulverize it into pellets (even from the bottles) and you can try to do this process. Only thing that matters is quality of product.</p> <p>I was thinking about pellets from vinyl records. I bought one big collection before one year, and there was around 500-600 records that are completley useless. So, you can pulverize them and repeat the process, because process of making vinyl records and process of making bottles is completley different, and uses different kind of plastics. </p> <p>So to draw a conslusion: everything depends on quality of pellets.</p> <p>And to answer on your three questions:</p> <blockquote> <p>Is the quality comparable to typical off-the-shelf filaments? Put<br> another way, with reasonable tuning can one produce filament that's<br> good enough to use without a lot of frustration?</p> </blockquote> <p>No, it isn't Your filament would be lower quality if you don't get a great pellets.</p> <blockquote> <p>Does it require a lot of attention to tuning, monitoring, or other details (which make it less worthwhile / more time-consuming)? Warning of pitfalls to avoid is also welcome.</p> </blockquote> <p>Yes it does. Check the link up there.</p> <blockquote> <p>Are there useful things one can do this way, that are hard to achieve with off-the-shelf filaments? For example, unusual materials; better control of diameter, density, etc; or mixing one's own colors?</p> </blockquote> <p>Again, it all depends on type of filament you like to use. I wrote about plastic filaments.</p>
166
<p>I manage a high-school computer lab with ~40 machines, have old PCs with varying hardware. I need to roll out Windows XP + a standard set of apps and settings for new machines, and to re-format older machines. </p> <p>What tool is available to help with this? It doesn't have to be perfect, but if it minimizes the time I set in front of machines installing programs and tweaking settings, it's a win.</p>
<p>Remote Installation Services and/or Windows Deployment Services. One or the other comes "free" with Windows Server (RIS with Windows Server 2003 SP1 or earlier; WDS with Windows Server 2003 SP2 or later), and is pretty easy to set up and use. :-) Requires your computers to support PXE booting, however.</p>
<p><strong>Try <a href="http://www.net-runna.com/Products/net-runna_Enterprise/" rel="nofollow noreferrer">net-runna Enterprise</a>.</strong> </p> <p>It does so much more than just deploying operating systems. Typically in a lab environment you want to be able to return the desktops to a known good state. This product can be configured to do this on each boot and take minutes as it is file based, not sector based. It's not free, but worth the money as this it will save you hours of watching progress bars. </p>
9,351
<p>Is there an Eclipse command to surround the current selection with parentheses?</p> <p>Creating a template is a decent workaround; it doesn't work with the "Surround With" functionality, because I want to parenthesize an expression, not an entire line, and that requires <code>${word_selection}</code> rather than <code>${line_selection}</code>.</p> <p>Is there a way that I can bind a keyboard shortcut to this particular template? <kbd>Ctrl</kbd>-<kbd>space</kbd> <kbd>Ctrl</kbd>-<kbd>space</kbd> arrow arrow arrow isn't as slick as I'd hoped for.</p>
<p>Maybe not the correct answer, but at least a workaround:</p> <ol> <li><p>define a Java template with the name "parenthesis" (or "pa") with the following :</p> <p>(${word_selection})${cursor}</p></li> <li><p>once the word is selected, <kbd>ctrl</kbd>-<kbd>space</kbd> + <kbd>p</kbd> + use the arrow keys to select the template</p></li> </ol> <p>I used this technique for boxing primary types in JDK 1.4.2 and it saves quite a lot of typing.</p>
<p>Easy, Window->Prefs, then select Java->Editor->Templates</p> <p>Create a new template with : (${line_selection}${cursor})</p> <p>The "line_selection" means you have to select more than one line.</p> <p>You can try creating another one with "word_selection", too.</p> <p>Then, select text, right click, Surround With... and choose your new template.</p>
9,255
<p>Does anyone use "space saver" style vacuum storage bags to keep fillament dry? I picked up some Ziploc space bags, but they are larger than ideal. Would probably fit 2.5 spools. I would love a smaller version just big enough for one spool.</p>
<p>I've read people are using them, makes sense, the less air you contain, the less moisture would be in the bag. Myself, I'm using IKEA ziplock bags (and moisture absorbing sachets), they come in many sizes.</p>
<p>I have a commercially available product known as a foodsaver (TM) which removes the air from the bag and really squeezes tightly around the spool. The width of the bags I use barely takes the typical spool but it does fit with a little elbow grease.</p> <p>I include a bag of desiccant in each bag to pull any residual moisture.</p> <p>It's a good idea to use the cut-to-length bags on a roll, which allows you to add excess length, as you have to cut and toss away the previous seal each time you use the spool.</p> <p>I too purchased the big honking bags and never built the structure I planned to use with it.</p> <p>So many compromises regardless of the method used. I've since switched to Sealtite Storage Bins from Target. They have a gasket around the lid and I've increased the bag of desiccant in each one. They stack well too.</p>
1,369
<p>We have a case where clients seem to be eternally caching versions of applets. We're making use of the <code>&lt;param name="cache_version"&gt;</code> tag correctly within our <code>&lt;object&gt;</code> tag, or so we think. We went from a version string of <code>7.1.0.40</code> to <code>7.1.0.42</code> and this triggered a download for only about half of our clients.</p> <p>It doesn't seem to matter which version of the JRE the client is running. We've seen people have this problem on 1.4, 1.5 and 1.6.</p> <p>Does anybody have experience with explicit cache versions? Does it work more reliably (ignoring speed) to instead rely on the <code>cache_archive</code>'s "Last-Modified" and/or "Content-Length" values (as per <a href="http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/applet_caching.html" rel="noreferrer">Sun's Site</a>)?</p> <p>FYI, object block looks like this:</p> <pre><code>&lt;object&gt; &lt;param name="ARCHIVE" value="foo.jar"&gt; &lt;param name="CODE" value="com.foo.class"&gt; &lt;param name="CODEBASE" value="."&gt; &lt;param name="cache_archive" value="foo.jar"&gt; &lt;param name="cache_version" value="7.1.0.40"&gt; &lt;param name="NAME" value="FooApplet"&gt; &lt;param name="type" value="application/x-java-applet;jpi-version=1.4.2_13"&gt; &lt;param name="scriptable" value="true"&gt; &lt;param name="progressbar" value="true"/&gt; &lt;param name="boxmessage" value="Loading Web Worksheet Applet..."/&gt; &lt;/object&gt; </code></pre>
<p>Unfortunately, different versions of the Java Plug-In have different caching behaviors. Setting your Cache-Control and Last-Modified HTTP headers is the ideal solution, but it only works under <a href="http://java.sun.com/javase/6/docs/technotes/guides/deployment/enhancements.html" rel="noreferrer">the most recent versions</a> of the JRE. </p> <p>The only solution GUARANTEED to work is to rename your application jars when their versions change (we've seen strange caching behavior when trying other tricks like adding query strings based on file dates). This isn't so difficult to do if you have a properly automated deployment system. </p>
<p>As per <a href="http://docs.oracle.com/javase/1.3/docs/guide/misc/appletcaching.html" rel="nofollow">this link</a> , same jar file should not be listed int "archive" and "cache_archive" params. In that case, the JAR file is cached using the native browser cache.</p>
9,241
<p>What is the best way of testing a function that throws on failure? Or testing a function that is fairly immune to failure?</p> <p>For instance; I have a <code>I/O Completion Port</code> class that throws in the constructor if it can't initialise the port correctly. This uses the <code>Win32</code> function of <code>CreateIoCompletionPort</code> in the initialiser list. If the handle isn't set correctly - a non-null value - then the constructor will throw an exception. I have never seen this function fail.</p> <p>I am pretty certain that this (and other functions like it in my code) if they fail will behave correctly, the code is 50 lines long including white-space, so my questions are</p> <p>a) is it worth testing that it will throw<br> b) and if it is worth testing, how to?<br> c) should simple wrapper classes as these be unit-tested? </p> <p>For b) I thought about overriding <code>CreateIoCompletionPort</code> and passing the values through. In the unit test override it and cause it to return 0 when a certain value is passed in. However since this is used in the constructor then this needs to be static. Does this seem valid or not?</p>
<p>It is definitely worthwhile to test failure conditions, both that your class properly throws an exception when you want it to and that exceptions are handled properly in the class.</p> <p>This can easily be done if you are acting on an object passed in to the constructor... just pass in a mock. If not, I tend to prefer to have the functionality moved to a protected method, and override the protected method to evoke my failure case. I will use Java as an example, but it should be easy enough to port the ideas to a C# case:</p> <pre><code>public class MyClass { public MyClass() throws MyClassException { // Whatever, including a call to invokeCreateIoCompletionPort } protected int invokeCreateIoCompletionPort(String str, int i) { return StaticClass.createIoCompletionPort(str, i); } } public class MyTest { public void myTest() { try { new MyClass(); fail("MyClassException was not thrown!"); } catch (MyClassException e) { } } private static class MyClassWrapper extends MyClass { @Override protected int invokeCreateIoCompletionPort(String str, int i) { throw new ExpectedException(); } } } </code></pre> <p>As you can see, it is pretty easy to test whether an exception is being thrown by the constructor or method you are testing, and it is also pretty easy to inject an exception from an external class that can throw an exception. Sorry I'm not using your actual method, I just used the name to illustrate how it sounded like you are using it, and how I would test the cases it sounded you wanted to test.</p> <p>Basically, any API details you expose can usually be tested, and if you want to KNOW that exceptional cases work as they should, you probably will want to test it.</p>
<p>Sound like C++ to me. You need a seam to mock out the Win32 functions. E.g. in your class you would create a protected method <code>CreateIoCompletionPort()</code> which calls <code>::CreateIoCompletionPort()</code> and for your test you create a class that derives from you I/O Completion Port class and overrides <code>CreateIoCompletionPort()</code> to do nothing but return <code>NULL</code>. Your production class is still behaving like it was designed but you are now able to simulate a failure in the <code>CreateIoCompletionPort()</code> function.</p> <p>This technique is from Michael Feathers book "Working effectively with legacy code".</p>
2,917
<p>(Ender 3 Pro with Bigtreetech Board and Touchscreen, BlTouch)</p> <p>Hello everybody, I want to print something for my family but the hotend gets clogged every time in the same part of the print. I tried:</p> <ul> <li>Different Nozzles</li> <li>Different Filaments</li> <li>I cleaned every Part</li> <li>The E-Steps are set right</li> <li>The retraction Setting didn't make a difference</li> <li>The Extruder Position is perfect</li> <li>I tried different speeds</li> <li>Everything else you find on Google with a clogged hot end.</li> </ul> <p>The most odd thing about this is that the problem occurs at the same place every time.</p> <p>On Flat surfaces are some anomalies, that wasn't there when I had the normal clogged nozzle problems (from: retraction settings, dirty Printer, e-steps false). I think it has something to do with the anomalies.</p> <p>Another thing I don't get behind are missing layers after the layer change, even when I don't use retraction at all. In The Picture from the side you see the Support with the Layer change problem. After around about Layer 40 there is one Layer missing and the next Layers are not connected anymore. From the top you see the Surface anomaly I don't know how to describe. It would be helpful to know what I did wrong. I am sure I did Everything against a clogged Nozzel but I can be Wrong so tips in this direction are Helpful too. I am quite new to 3D Printing(2 Months) I had the usual clogged Nozzel Problem Solved and It Worked Perfectly. I Tried to Fix It with the same Solutions and Nothing Helped, so I think it is a different problem. Sry for my bad English I am from Germany.<a href="https://i.stack.imgur.com/mA9br.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mA9br.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/oKgpD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oKgpD.jpg" alt="enter image description here" /></a></p> <p>I have an Ender 3 Pro with Bigtreetech Board, Touchscreen and BlTouch which I use together with [insert slicer here]. I print in [PLA/ABS/PETG/Whatever Material] at [Extruder temperature] °C. The print bed is set to [Bed Temperature] °C. I use a print cooling fan at [whatever] %. The layer height I set to 0.[x] mm, the line width [line width/extrusion width] from the 0.[x] mm nozzle. The Printing Speed is set to [x] mm/s for walls and [x] mm/s for infill. My retraction is [off / [X] mm at [x] mm/s].</p>
<h1>Conclusion</h1> <p>So I found my mistake: It was the E-Steps I did wrong it over extruded. The best E-Steps per mm are 92 for me. The mistake took place because I took my E-step number from a Video Tutorial about my dual extruder. I found the optimal number by testing out; the formula I got for the E-Steps was in the Video and I think I used it wrong, I'll watch the Video again and look at what I did wrong and I'll write a comment about it. I will test more today to get it perfect but <a href="https://3dprinting.stackexchange.com/a/14915/8884">@Trish</a> was right.</p> <p>Thank you to everybody for their Time.</p> <p><a href="https://i.stack.imgur.com/S5nh7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S5nh7.jpg" alt="enter image description here" /></a></p> <h1>How the problem was diagnosed:</h1> <h2>Did I have a bad Temperature?</h2> <p>First, I tested all temperatures in the range of 190 to 210 °C, and the best looking is 200-205 °C. After that, I tried a different height for my print head which just resulted in the model not sticking to the bed. So I could rule out bad layer height.</p> <p>This was made at 200 °C, The problematic areas are at the corners and on Flat Surfaces parallel to the heat bed:</p> <p><a href="https://i.stack.imgur.com/YFf5a.jpg" rel="nofollow noreferrer" title="This was made with 200 °C, The problematic areas are at the corners and on Flat Surfaces parallel to the Heat bed."><img src="https://i.stack.imgur.com/YFf5a.jpg" alt="This was made with 200 °C, The problematic areas are at the corners and on Flat Surfaces parallel to the Heat bed." title="This was made with 200 °C, The problematic areas are at the corners and on Flat Surfaces parallel to the Heat bed." /></a></p> <h2>Is the Cura profile the culprit?</h2> <p>I made a new printer Profile to find out if I broke it in the settings. I got the same results.</p> <p>So I tried every Setting in Cura that could have something to do with that, the only thing that helped a little was using 50% Top Surface Flow:</p> <p><a href="https://i.stack.imgur.com/MMcm0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MMcm0.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/ynXsO.jpg" rel="nofollow noreferrer" title="this Picture is with 50 % Top Surface Flow"><img src="https://i.stack.imgur.com/ynXsO.jpg" alt="this Picture is with 50 % Top Surface Flow" title="this Picture is with 50 % Top Surface Flow" /></a></p> <p>While testing, I saw that the corners are really bad. I think it's because of the print head acceleration. So, I went back and tuned more...</p> <h2>E-Step Configuration Issue Identified:</h2> <p>Finally, I revisited the video I saw originally and figured out, it might be the E-steps per mm. I went through trial and error to come to 92 and realized, I had mistakenly inserted a number for a different extruder setup.</p>
<p>I noticed that on my Ender 3, if the belts aren't tight enough, I have a similar problem, but mostly when I print anything circular.</p>
1,785
<p>I am writing a C# client that calls a web service written in Java (by another person). I have added a web reference to my client and I'm able to call methods in the web service ok.</p> <p>The service was changed to return an array of objects, and the client does not properly parse the returned SOAP message.</p> <pre><code>MyResponse[] MyFunc(string p) class MyResponse { long id; string reason; } </code></pre> <p>When my generated C# proxy calls the web service (using SoapHttpClientProtocol.Invoke), I am expecting a MyResponse[] array with length of 1, ie a single element. What I am getting after the Invoke call is an element with id=0 and reason=null, regardless of what the service actually returns. Using a packet sniffer, I can see that the service is returning what appears to be a legitimate soap message with id and reason set to non-null values.</p> <p>Is there some trick to getting a C# client to call a Java web service that returns someobject[] ? I will work on getting a sanitized demo if necessary.</p> <p><strong>Edit</strong>: This is a web reference via "Add Web Reference...". VS 2005, .NET 3.0.</p>
<p>It has been a while, but I seem to remember having trouble with the slight differences in how default namespaces were handled between .Net and Java web services.</p> <p>Double check the generated c# proxy class and any namespaces declared within (especially the defaults xmlns=""), against what the Java service is expecting. There will be probably be very subtle differences which you will have to recreate.</p> <p>If this is the case then you will to provide more namespace declarations in the c# attributes.</p>
<p>From your question, it looks like you had the client working at one point, and then the service was changed to return an array. Make sure you re-generate the proxy so the returned SOAP message is deserialized on the client. It wasn't clear you had done this - just making sure.</p>
9,046
<p>I'm a recent AI graduate (circa 2 years) working for a modest operation. It has fallen to me (primarily as I'm the first 'adopter' in the department) to create a basic (read useful?) C# coding standards document. </p> <p>I think I should explain that I'm probably the most junior software engineer going, but I'm looking forward to this task as hopefully I might actually be able to produce something half usable. I've done a pretty extensive search of the Internet and read articles on what a coding standards document should / should not contain. This seems like a good as place as any to ask for some suggestions.</p> <p>I realise that I am potentially opening a door to a whole world of disagreement about 'the best way to do things'. I both understand and respect the undeniable fact that each programmer has a preferred method of solving each individual task, as a result I'm not looking to write anything so draconianly proscriptive as to stifle personal flair but to try and get a general methodology and agreed standards (e.g. naming conventions) to help make individuals code more readable.</p> <p>So here goes .... any suggestions? Any at all?</p>
<p>We start with </p> <ul> <li>Microsoft's .NET guidelines: <a href="http://msdn.microsoft.com/en-us/library/ms229042.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms229042.aspx</a> (link updated for .NET 4.5)</li> <li>Microsoft's C# guidelines: <a href="http://blogs.msdn.com/brada/articles/361363.aspx" rel="noreferrer">http://blogs.msdn.com/brada/articles/361363.aspx</a>.</li> </ul> <p>and then document the differences from and additions to that baseline.</p>
<p>I think I echo the other comments here that the MS guidlines already linked are an excellent starting point. I model my code largely on those.</p> <p>Which is interesting because my manager has told me in the past that he is not too keen on them :D</p> <p>You have a fun task ahead of you my friend. Best of luck, and please ask if you need anything more :)</p>
3,575
<p>Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc).</p> <p>However, I am currently running into issues while trying to bring over the CObArray data, as there seems to be a rather large header that is opaque to me, and it is unclear how it is persisting object type information.</p> <p>Is there a set of online documentation that would be helpful for this? Or some sample Java code from someone that has dealt with this in the past?</p>
<p>Since MFC ships with source code I would create a test MFC application that serializes a CObArray and step through the serialization code. This should give you all the information you need.</p>
<p>I agree with jmatthias: use the MFC source code.</p> <p>There's also <a href="http://msdn.microsoft.com/en-us/library/32wxt301%28VS.71%29.aspx" rel="nofollow noreferrer">this page</a> on MSDN that may be useful.</p>
7,911
<p>Because of the weight of my Z-axis and the relative ease of its motion, when the Z-axis motor is powered down the bed has a tendency to slip and fall down.</p> <p>Obviously leaving the motor powered solves this problem, but that is not ideal.</p> <p>I am looking for some kind of solution that passively stops the Z-axis motor from slipping; some kind of brake or clutch. Ideally I'm looking for something that I can add onto my current motors and that I could print myself. Commercial solutions (preferably ones that could be replicated with a 3D printer) would also make valid answers.</p>
<p>The simple way to do this is to use a self-locking screw pitch. Pretty much any single-start thread using a sliding nut cannot be back-driven so the load will not fall. Normal 8x8 trapezoidal thread screws will easily back-drive because of the steep pitch. </p> <p>Likewise, a worm drive between the motor and Z stage will hold the load. You would want to switch from screws to belts for the main motion stage in that case though, to avoid having too much total gear reduction. </p> <p>Both of these solutions will limit your maximum Z speed, of course. But they're simple and reliable. Clutches and brakes add a lot of complexity and must be actuated somehow. Designers who want the load to stay suspended almost always simply use single-start screws. </p>
<p>If your stepper motors have shafts protruding from both ends then it may be possible to simply 3d print a fixture that allows a thumb screw to be tightened and clamp down on the unused part of the shaft.</p> <p>This would however be a very manual approach and would require you to be mindful that the screw must always be disengaged just after motors are powered on..</p>
344
<p>What strategies have you used with Model Based Testing?</p> <ul> <li>Do you use it exclusively for integration testing, or branch it out to other areas (unit/functional/system/spec verification)? </li> <li>Do you build focused "sealed" models or do you evolve complex onibus models over time?</li> <li>When in the product cycle do you invest in creating MBTs?</li> <li>What sort of base test libraries do you exclusively create for MBTs?</li> <li><p>What difference do you make in your functional base test libraries to better support MBTs? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p></li> </ul>
<p>[There are several essays worth reading on this. Stack Overflow won't let me post more than one, so I've aggregated them in a blog post, linked at the end of this answer.]</p> <p>First, a quick note on terms. I tend to use James Bach’s definition of Testing as “Questioning a product in order to evaluate it”. All test rely on /mental/ models of the application under test. The term Model-Based Testing though is typically used to describe programming a model which can be explored via automation. For example, one might specify a number of states that an application can be in, various paths between those states, and certain assertions about what should occur in on the transition between those states. Then one can have scripts execute semi-random permutations of transitions within the state model, logging potentially interesting results.</p> <p>There are real costs here: building a useful model, creating algorithms for exploring it, logging systems that allow one to weed through for interesting failures, etc. Whether or not the costs are reasonable has a lot to do with <em>what are the questions you want to answer?</em> In general, start with “What do I want to know? And how can I best learn about it?” rather than looking for a use for an interesting technique.</p> <p>All that said, some excellent testers have gotten a lot of mileage out of automated model-based tests. Sometimes we have important questions about the application under test that are best explored by automated, high-volume semi-randomized tests. Harry Robinson (one of the leading theorists and proponents of model-based testing) describes one very colorful example where he discovered many interesting bugs in Google driving directions using a model-based test (written with ruby’s Watir library). <a href="http://testingjeff.wordpress.com/2009/06/03/question-about-model-based-testing/" rel="noreferrer">1</a></p> <p>Robinson has used MBT successfully at companies including Bell Labs, Microsoft, and Google, and has a number of helpful essays.[2]</p> <p>Ben Simo (another great testing thinker and writer) has also written quite a bit worth reading on model-based testing.[3] </p> <p>Finally, a few cautions: To make good use of a strategy, one needs to explore both its strengths and its weaknesses. Toward that end, James Bach has an excellent talk on the limits and challenges of Model-Based Testing. This blog post of Bach’s links to his hour long talk (and associated slides).[4]</p> <p>I’ll end with a note about what Boris Beizer calls the Pesticide Paradox: “Every method you use to prevent or find bugs leaves a residue of subtler bugs against which those methods are ineffective.” Scripted tests (whether executed by a computer or a person) are particularly vulnerable to the pesticide paradox, tending to find less and less useful information each time the same script is executed. Folks sometimes turn to model-based testing thinking that it gets around the pesticide problem. In some contexts model-based testing may well find a much larger set of bugs than a given set of scripted tests…but one should remember that it is still fundamentally limited by the Pesticide Paradox. Remembering its limits — and starting with questions MBT addresses well — it has the potential to be a very powerful testing strategy.</p> <p>Links to all essays mentioned above can be found here: <a href="http://testingjeff.wordpress.com/2009/06/03/question-about-model-based-testing/" rel="noreferrer">http://testingjeff.wordpress.com/2009/06/03/question-about-model-based-testing/</a></p>
<p>The best way is to try by yourself a Model based testing tool. It's the best way for know if the model based testing is adapted in your context. And what sort of strategies is the good one.</p> <p>I advise you the "MaTeLo" tool of All4Tec (www.all4tec.net)</p> <p>"MaTeLo is a test cases generator for black box functional and system testing. Conformed to the Model Based Testing approach, MaTeLo uses Markov chains for modeling the test. This statistic addin allows products validation in a Systematic way. The efficiency is achieved by a reduction of the human resources needed, an increase of the model reuse and by the enhancement of the test strategy relevance (due to the reliability target). MaTeLo is independent and user-friendly, offers to the validation activities to pass from test scripting to real test engineering and to focus on the real added value of testing: the test plans"</p> <p>You can ask an evaluation licence and try by yourself.</p> <p>You can find some exemples here : <a href="http://www.all4tec.net/wiki/index.php?title=Tutorials" rel="nofollow noreferrer">http://www.all4tec.net/wiki/index.php?title=Tutorials</a></p>
4,565
<p>I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. </p> <p>I've found solutions to this problem but they rely on alternative color palettes than RGB. I would rather just use straight RGB than mapping back and forth. These other solutions also can at most generate only 32 or so pleasing random colors. </p> <p>Any ideas would be great.</p>
<p>You could average the RGB values of random colors with those of a constant color:</p> <p><em>(example in Java)</em></p> <pre><code>public Color generateRandomColor(Color mix) { Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); // mix the color if (mix != null) { red = (red + mix.getRed()) / 2; green = (green + mix.getGreen()) / 2; blue = (blue + mix.getBlue()) / 2; } Color color = new Color(red, green, blue); return color; } </code></pre> <p><br/> Mixing random colors with white (255, 255, 255) creates neutral pastels by increasing the lightness while keeping the hue of the original color. These randomly generated pastels usually go well together, especially in large numbers.</p> <p>Here are some pastel colors generated using the above method:</p> <p><img src="https://i.stack.imgur.com/8jKGx.jpg" alt="First"></p> <p><br/> You could also mix the random color with a constant pastel, which results in a tinted set of neutral colors. For example, using a light blue creates colors like these:</p> <p><img src="https://i.stack.imgur.com/zI406.jpg" alt="Second"></p> <p><br/> Going further, you could add heuristics to your generator that take into account complementary colors or levels of shading, but it all depends on the impression you want to achieve with your random colors.</p> <p>Some additional resources:</p> <ul> <li><a href="http://en.wikipedia.org/wiki/Color_theory" rel="noreferrer">http://en.wikipedia.org/wiki/Color_theory</a></li> <li><a href="http://en.wikipedia.org/wiki/Complementary_color" rel="noreferrer">http://en.wikipedia.org/wiki/Complementary_color</a></li> </ul>
<p>you could have them be within a certain brightness. that would control the ammount of "neon" colors a bit. for instance, if the "brightness"</p> <pre><code>brightness = sqrt(R^2+G^2+B^2) </code></pre> <p>was within a certain high bound, it would have a washed out, light color to it. Conversely, if it was within a certain low bound, it would be darker. This would eliminate any crazy, standout colors and if you chose a bound really high or really low, they would all be fairly close to either white or black.</p>
6,467
<p>I'm currently trying to implement a data collector on my Replicator+ by utilizing JSON-RPC. Is there an <strong>official</strong> reference for this? MakerBot used to host a <a href="http://wiki.makerbot.com/" rel="nofollow noreferrer">wiki site</a>, but that seems to be gone for their "troubleshooting" pages.</p>
<p>It took some digging, but I was able to start scripting a wrapper in C# for the RPC commands.</p> <ul> <li><a href="https://github.com/TrueAnalyticsSolutions/MakerBotAgentAdapterCore#api" rel="nofollow noreferrer">C# Wrapper</a> (MTConnect Implementation)</li> <li>Unofficial <a href="https://github.com/TrueAnalyticsSolutions/MakerBotAgentAdapterCore/wiki/JSON-RPC" rel="nofollow noreferrer">JSON-RPC Reference</a></li> </ul> <p>I still don't understand what every method does to the machine or necessarily what the results are, so a number of the methods are marked as obsolete until I can test them.</p>
<h2>The Mystery of Makerbot-Wiki</h2> <p>According to the Wayback machine, the wiki.makerbot.com went offline on <a href="https://web.archive.org/web/20121126084944/http://wiki.makerbot.com:80/" rel="nofollow noreferrer">31st December 2012</a>:</p> <blockquote> <p>Over the past three amazing years, MakerBot owners and enthusiasts around the world have shared knowledge with us and with each other. As we welcome thousands more MakerBot owners and users into the MakerBot family, we want to make sure that everyone always has the best information regarding our company and products, and that it's easily accessible.</p> <p>Here’s one thing we're doing to help: on December 31, as we close out the year, we will also turn off the lights at wiki.makerbot.com.</p> <p>The MakerBot wiki has served us well, but lately we've seen an increase in spam and a decline in community activity. Instead of continuing to maintain two separate sites, we're going to consolidate them.</p> <p>What that means is that, as of December 31st, the MakerBot wiki will no longer be available at this address. An archived version of the wiki as it stands today will be available at <a href="http://makerbot.com/support/archive" rel="nofollow noreferrer">http://makerbot.com/support/archive</a> and more former wiki content will be available at <a href="http://makerbot.com/support" rel="nofollow noreferrer">http://makerbot.com/support</a>, which already hosts PDFs of some of the most useful Thing-O-Matic and Cupcake documentation. You may see some short periods of downtime as we finish moving this content.</p> <p>An archive of forum discussions will be available, but users seeking discussion with the incredibly knowledgable MakerBot community should head over to the <a href="https://groups.google.com/forum/#!forum/makerbot" rel="nofollow noreferrer">MakerBot Operators Google Group</a>. Requests for help and questions about MakerBot products should, as always, be sent to mailto:support@makerbot.com.</p> <p>Thanks for your contributions over the past few years to the MakerBot wiki. We hope you'll all continue to share your expertise with us and other MakerBot users for many years to come.</p> </blockquote> <p><a href="https://web.archive.org/web/20121114075819/http://wiki.makerbot.com/" rel="nofollow noreferrer">Before that</a>, the makerbot wiki did tell that the Documentations had been moved:</p> <blockquote> <p>Note<br> This wiki is intended for historical MakerBot documentation and community-supported projects. The new home for MakerBot documentation is <a href="http://www.makerbot.com/docs/" rel="nofollow noreferrer">http://www.makerbot.com/docs/</a></p> </blockquote> <hr> <h2>JSON-RPC</h2> <p>There is a late 2013/early 2014 <a href="https://github.com/makerbot/jsonrpc" rel="nofollow noreferrer">github</a> that seems to work on the JSON-RPC and which might help - and still showed <a href="https://github.com/makerbot/jsonrpc/graphs/contributors" rel="nofollow noreferrer">some activity</a> past the lockup of the wiki.makerbot.com. It is only very poorly documented. The earliest activity was in 2012 with the main bulk in 2013.</p> <p>The JSON project predates the start of work on the <a href="https://github.com/gryphius/makerbot-gen5-api/graphs/contributors" rel="nofollow noreferrer">makerbot-gen5-api</a> in 2014. This might mean that it might be documented there to some degree, But it might also be present in the generation 4 API.</p>
1,232
<p>Does anyone know of a good code obsfucator for Perl? I'm being ask to look into the option of obsfucating code before releasing it to a client. I know obsfucated code can still be reverse engineered, but that's not our main concern. </p> <p>Some clients are making small changes to the source code that we give them and it's giving us nightmares when something goes wrong and we have to fix it, or when we release a patch that doesn't work with what they've changed. So the intention is just to make it so that it's difficult for them to make their own changes to the code(they're not supposed to be doing that anyway).</p>
<p>I've been down this road before and it's an absolute nightmare when you have to work on "obfuscated" code because it drives up costs tremendously trying to debug a problem on the client's server when you, the developer, can't read the code. You wind up with "deobfuscators", copying the "real code" to the client's server or any of a number of other issues which just become a real hassle to maintain.</p> <p>I understand where you're coming from, but it sounds like management has a problem and they're looking to you to implement a chosen solution rather than figuring out what the correct solution is.</p> <p>In this case, it sounds like it's really a licensing or contractual issue. Let 'em have the code open source, but make it a part of the license that any changes they submit have to come back to you and be approved. When you push out patches, check the md5 sums of all code and if it doesn't match what's expected, they're in license violation and will be charged accordingly (and it should be a far, far higher rate). (I remember one company which let us have the code open source, but made it clear that if we changed anything, we've "bought" the code for $25,000 and they were no longer responsible for any bug fixes or upgrades unless we bought a new license).</p>
<p>Another not serious suggestion is to use <a href="https://metacpan.org/pod/Acme%3a%3aBleach" rel="nofollow">Acme::Bleach</a>, it will make your code very clean ;-)</p>
9,648
<p>What all would be the requirements for the following scenario:</p> <blockquote> <p>A GSM modem connected to a PC running a web based (ASP.NET) application. In the application the user selects a phone number from a list of phone nos. When he clicks on a button named the PC should call the selected phone number. When the person on the phone responds he should be able to have a conversation with the PC user. Similarly there should be a facility to send SMS.</p> </blockquote> <p>Now I don't want any code listings. I just need to know what would be the requirements besides asp.net, database for storing phone numbers, and GSM modem.</p> <p>Any help in terms of reference websites would be highly appreciated.</p>
<p>I'll pick some points of your very broad question and answer them. Note that there are other points where others may be of more help...</p> <p>First, a GSM modem is probably not the way you'd want to go as they usually don't allow for concurrency. So unless you just want one user at the time to use your service, you'd probably need another solution.</p> <p>Also, think about cost issues - at least where I live, providing such a service would be prohibitively expensive using a normal GSM modem and a normal contract - but this is drifting into off-topicness.</p> <p>The next issue will be to get voice data from the client to the server (which will relay it to the phone system - using whatever practical means). Pure browser based functionality won't be of much help, so you would absolutely need something plugin based.</p> <p>Flash may work, seeing they provide access to the microphone, but please don't ask me about the details. I've never done anything like this.</p> <p>Also, privacy would be a concern. While GSM data is encrypted, the path between client and server is not per default. And even if you use SSL, you'd have to convince your users trusting you that you don't record all the conversations going on, but this too is more of a political than a coding issue.</p> <p>Finally, you'd have to think of bandwidth. Voice uses a lot of it and also it requires low latency. If you use a SIP trunk, you'll need the bandwidth twice per user: Once from and to your client and once from and to the SIP trunk. Calculate with 10-64 KBit/s per user and channel.</p> <p>A feasible architecture would probably be to use a SIP trunk (they optimize on using VoIP as much as possible and thus can provide much lower rates than a GSM provider generally does. Also, they allow for concurrency), an Asterisk box (<a href="http://www.asterisk.org" rel="nofollow noreferrer">http://www.asterisk.org</a> - a free PBX), some custom made flash client and a custom made SIP client on the server.</p> <p>All in all, this is quite the undertaking :-)</p>
<p>You'll need a GSM library. There appear to be a few of these.<br> e.g. <a href="http://www.wirelessdevstudio.com/eng/" rel="nofollow noreferrer">http://www.wirelessdevstudio.com/eng/</a></p>
7,196
<p>The point of this question is to collect a list of examples of hashtable implementations using arrays in different languages. It would also be nice if someone could throw in a pretty detailed overview of how they work, and what is happening with each example. </p> <p><strong>Edit:</strong> </p> <p>Why not just use the built in hash functions in your specific language? </p> <p>Because we should know how hash tables work and be able to implement them. This may not seem like a super important topic, but knowing how one of the most used data structures works seems pretty important to me. If this is to become the wikipedia of programming, then these are some of the types of questions that I will come here for. I'm not looking for a CS book to be written here. I could go pull Intro to Algorithms off the shelf and read up on the chapter on hash tables and get that type of info. More specifically what I am looking for are <strong>code examples</strong>. Not only for me in particular, but also for others who would maybe one day be searching for similar info and stumble across this page. </p> <p>To be more specific: If you <strong>had</strong> to implement them, and could not use built-in functions, how would you do it? </p> <p>You don't need to put the code here. Put it in pastebin and just link it. </p>
<p>A hash table a data structure that allows lookup of items in constant time. It works by hashing a value and converting that value to an offset in an array. The concept of a hash table is fairly easy to understand, but implementing is obviously harder. I'm not pasting the whole hash table here, but here are some snippets of a hash table I made in C a few weeks ago...</p> <p>One of the basics of creating a hash table is having a good hash function. I used the djb2 hash function in my hash table:</p> <pre><code>int ComputeHash(char* key) { int hash = 5381; while (*key) hash = ((hash &lt;&lt; 5) + hash) + *(key++); return hash % hashTable.totalBuckets; } </code></pre> <p>Then comes the actual code itself for creating and managing the buckets in the table</p> <pre><code>typedef struct HashTable{ HashTable* nextEntry; char* key; char* value; }HashBucket; typedef struct HashTableEntry{ int totalBuckets; // Total number of buckets allocated for the hash table HashTable** hashBucketArray; // Pointer to array of buckets }HashTableEntry; HashTableEntry hashTable; bool InitHashTable(int totalBuckets) { if(totalBuckets &gt; 0) { hashTable.totalBuckets = totalBuckets; hashTable.hashBucketArray = (HashTable**)malloc(totalBuckets * sizeof(HashTable)); if(hashTable.hashBucketArray != NULL) { memset(hashTable.hashBucketArray, 0, sizeof(HashTable) * totalBuckets); return true; } } return false; } bool AddNode(char* key, char* value) { int offset = ComputeHash(key); if(hashTable.hashBucketArray[offset] == NULL) { hashTable.hashBucketArray[offset] = NewNode(key, value); if(hashTable.hashBucketArray[offset] != NULL) return true; } else { if(AppendLinkedNode(hashTable.hashBucketArray[offset], key, value) != NULL) return true; } return false; } HashTable* NewNode(char* key, char* value) { HashTable* tmpNode = (HashTable*)malloc(sizeof(HashTable)); if(tmpNode != NULL) { tmpNode-&gt;nextEntry = NULL; tmpNode-&gt;key = (char*)malloc(strlen(key)); tmpNode-&gt;value = (char*)malloc(strlen(value)); strcpy(tmpNode-&gt;key, key); strcpy(tmpNode-&gt;value, value); } return tmpNode; } </code></pre> <p>AppendLinkedNode finds the last node in the linked list and appends a new node to it.</p> <p>The code would be used like this:</p> <pre><code>if(InitHashTable(100) == false) return -1; AddNode("10", "TEN"); </code></pre> <p>Finding a node is a simple as:</p> <pre><code>HashTable* FindNode(char* key) { int offset = ComputeHash(key); HashTable* tmpNode = hashTable.hashBucketArray[offset]; while(tmpNode != NULL) { if(strcmp(tmpNode-&gt;key, key) == 0) return tmpNode; tmpNode = tmpNode-&gt;nextEntry; } return NULL; } </code></pre> <p>And is used as follows:</p> <pre><code>char* value = FindNode("10"); </code></pre>
<p>I went and read some of the Wikipedia-page on hashing: <a href="http://en.wikipedia.org/wiki/Hash_table" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Hash_table</a>. It seems like a lot of work, to put up code for a hashtable here, especially since most languages I use allready have them built in. Why would you want implementations here? This stuff really belongs in a languages library.</p> <p>Please elaborate on what your expected solutions should include:</p> <ul> <li>hash function</li> <li>variable bucket count</li> <li>collision behavior</li> </ul> <p>Also state what the purpose of collecting them here is. Any serious implementation will easily be quite a mouthfull = this will lead to very long answers (possibly a few pages long each). You might also be enticing people to copy code from a library...</p>
4,494