instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I have seen lots of questions recently about WPF...</p> <ul> <li>What is it?</li> <li>What does it stand for?</li> <li>How can I begin programming WPF?</li> </ul>
<p>WPF is a new technology that will supersede Windows Forms. WPF stands for Windows Presentation Foundation Here are some useful topics on SO:</p> <ol> <li><a href="https://stackoverflow.com/questions/9591/what-wpf-books-would-you-recommend">What WPF books would you recommend</a></li> <li><a href="https://stackoverflow.com/questions/7837/what-real-world-wpf-applications-are-out-there">What real world WPF applications are out there</a></li> </ol> <p>From my practice I can say that WPF is a truly amazing technology however it takes some time to get used to because it's totally different from the WinForms. I would recommend you to take a look at this <a href="http://perseus.franklins.net/dnrtvplayer/player.aspx?ShowNum=0115" rel="nofollow noreferrer">demo</a>.</p>
<p>Windows Presentation Foundation. It's basically Microsoft's latest attempt to make development easier, and provide a whole heap of nice functionality out of the box. I'm not sure where to start, but googling "WPF 101" should throw up a few useful links. </p>
5,870
<p>In .NET, is it more appropriate to throw an argument null exception for an Integer if the value is Integer.MinValue or Integer = 0 (assuming that 0 is not a valid value)?</p>
<p>Throwing an ArgumentNullException isn't appropriate unless the argument is actually <strong>null</strong>. Throw an ArgumentOutOfRangeException instead (preferably with a message informing the user what values of int are actually acceptable).</p> <blockquote> <p><strong>ArgumentOutOfRangeException</strong> is thrown when a method is invoked and at least one of the arguments passed to the method is not a null reference (<strong>Nothing</strong> in Visual Basic) and does not contain a valid value.</p> </blockquote>
<p>If the argument is not null, don't throw an <code>ArgumentNullException</code>. It would probably be more reasonable to throw an <code>ArgumentException</code>, <a href="http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx" rel="nofollow noreferrer">explained here.</a></p> <p><strong>edit:</strong> <code>ArgumentOutOfRangeException</code> is probably even better, as suggested above by Avenger546.</p>
3,734
<p>So, in your experience, whats the best way? Is there a secure way that's also scriptable/triggerable in a build automation tool?</p> <p>Edit: I should mention this is windows/.net and I'll be deploying to iis6</p>
<p>For some projects I use <a href="http://www.capify.org/" rel="nofollow noreferrer">Capistrano</a> to push out to live. It is built on top of ruby and makes deploy script writing super easy and uses ssh. </p> <p>On other projects I have a tiny deploy app that uses bash to do an svn export to a temporary directory and then rsync it over to the live server. You can make rsync use ssh.</p> <p>I greatly prefer the Capistrano method, even if your project isn't in ruby/rails.</p>
<p>You could always write a small client/server app that encrypts at the source, pushes the files, and then decrypts at the destination. That's a little bit of work, but probably a trivial amount. And it's scriptable as long as your automation tool supports executing something in the file system (which I think all do).</p> <p>The only downside is that you may not be able to get meaningful error messages on failure in your integration environment without a bit more work on your part (though depending on your setup, this could be as simple as sending error messages to stdout).</p>
3,883
<p>I'm using OLEDB provider for ADO.Net connecting to an Oracle database. In my loop, I am doing an insert:</p> <pre><code>insert into ps_tl_compleave_tbl values('2626899', 0, TO_DATE('01/01/2002', 'MM/DD/YYYY'), 'LTKN', 'LTKN', '52', TO_DATE('01/01/2002', 'MM/DD/YYYY'), 16.000000, 24.000)insert into ps_tl_compleave_tbl values('4327142', 0, TO_DATE('03/23/2002', 'MM/DD/YYYY'), 'LTKN', 'LTKN', '51', TO_DATE('03/23/2002', 'MM/DD/YYYY'), 0.000000, 0.000) </code></pre> <p>The first insert succeeds but the second one gives an error:</p> <pre><code>ORA-00933: SQL command not properly ended </code></pre> <p>What am I doing wrong?</p>
<p>In .net, when we try to execute a single Oracle SQL statement with a semicolon at the end. The result will be an oracle error: ora-00911: invalid character. OK, you figure that one SQL statement doesn't need the semicolon, but what about executing 2 SQL statement in one string for example:</p> <pre><code>Dim db As Database = DatabaseFactory.CreateDatabase("db") Dim cmd As System.Data.Common.DbCommand Dim sql As String = "" sql = "DELETE FROM iphone_applications WHERE appid = 1; DELETE FROM iphone_applications WHERE appid = 2; " cmd = db.GetSqlStringCommand(sql) db.ExecuteNonQuery(cmd) </code></pre> <p>The code above will give you the same Oracle error: ora-00911: invalid character.</p> <p>The solution to this problem is to wrap your 2 Oracle SQL statements with a <code>BEGIN</code> and <code>END;</code> syntax, for example:</p> <pre><code>sql = "BEGIN DELETE FROM iphone_applications WHERE appid = 1; DELETE FROM iphone_applications WHERE appid = 2; END;" </code></pre> <p>Courtesy: <a href="http://www.lazyasscoder.com/Article.aspx?id=89&amp;title=ora-00911%3A+invalid+character+when+executing+multiple+Oracle+SQL+statements" rel="noreferrer">http://www.lazyasscoder.com/Article.aspx?id=89&amp;title=ora-00911%3A+invalid+character+when+executing+multiple+Oracle+SQL+statements</a></p>
<p>It's a long shot but in the first insert the sql date format is valid for both uk/us, the second insert is invalid if the Oracle DB is setup for UK date format, I realise you have used the TO_DATE function but I don't see anything else ...</p>
9,774
<p>For all the RSS feeds I subscribe to I use <a href="http://www.google.com/reader/" rel="nofollow noreferrer">Google Reader</a>, which I love. I do however have a couple of specific RSS feeds that I'd like to be notified of as soon as they get updated (say, for example, an RSS feed for a forum I like to monitor and respond to as quickly as possible). </p> <p>Are there any tools out there for this kind of monitoring which also have some kind of alert functionality (for example, a prompt window)? </p> <p>I've tried <a href="http://web.archive.org/web/20110615171752/http://www.simbolic.net:80/software/rssalert/" rel="nofollow noreferrer">Simbolic RSS Alert</a> but I found it a bit buggy and couldn't get it to alert me as often as I liked.</p> <p>Suggestions? Or perhaps a different experience with Simbolic? </p>
<p>If you have access to Microsoft Outlook 2007 or Thunderbird, these email clients allow you to add RSS feeds in the same way you would add an email account.</p> <p>I use Google Reader generally but when I want to keep up-to-date with something specific, I add the RSS feed to Outlook and it arrives in my inbox as if it was an email.</p>
<p>I've used <a href="http://www.pingie.com" rel="nofollow noreferrer">Pingie</a> to send me an SMS when a new item appears in an RSS feed. Perhaps, it will be useful for you, if you have a cellphone text messaging plan.</p>
2,427
<p>One thing I really miss about Java is the tool support. FindBugs, Checkstyle and PMD made for a holy trinity of code quality metrics and automatic bug checking. </p> <p>Is there anything that will check for simple bugs and / or style violations of Ruby code? Bonus points if I can adapt it for frameworks such as Rails so that Rails idioms are adhered to.</p>
<p>I've recently started looking for something like this for Ruby. What I've run across so far:</p> <ul> <li><a href="http://saikuro.rubyforge.org/" rel="noreferrer">Saikuro</a></li> <li><a href="http://www.martyandrews.net/blog/2008/09/first_official_release_of_rood.html" rel="noreferrer">Roodi</a></li> <li><a href="http://ruby.sadi.st/Flog.html" rel="noreferrer">Flog</a></li> </ul> <p>These might be places to start. Unfortunately I haven't used any of the three enough yet to offer a good opinion.</p>
<p>There is also <a href="https://github.com/simplabs/excellent" rel="nofollow">excellent</a>. I haven't tried it yet, but it too looks promising. </p>
7,902
<p>I have a little problem with a Listview.</p> <p>I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view, only the first column shows the error]. There is a a narrow strip that doesn't paint. The width of that strip is approximately the same as a row header would be if I had a row header. </p> <p>If you have a thought on what can be done to make the background draw I'd love to hear it. </p> <p>Now just to try a new idea, I'm offering a ten vote bounty for the first solution that still has me using this awful construct of a mess of a pseudo grid view. [I love legacy code.]</p> <p><strong>Edit:</strong></p> <p>Here is a sample that exhibits the problem.</p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); ListView lv = new ListView(); lv.Dock = System.Windows.Forms.DockStyle.Fill; lv.FullRowSelect = true; lv.GridLines = true; lv.HideSelection = false; lv.Location = new System.Drawing.Point(0, 0); lv.TabIndex = 0; lv.View = System.Windows.Forms.View.Details; lv.AllowColumnReorder = true; this.Controls.Add(lv); lv.MultiSelect = true; ColumnHeader ch = new ColumnHeader(); ch.Name = "Foo"; ch.Text = "Foo"; ch.Width = 40; ch.TextAlign = HorizontalAlignment.Left; lv.Columns.Add(ch); ColumnHeader ch2 = new ColumnHeader(); ch.Name = "Bar"; ch.Text = "Bar"; ch.Width = 40; ch.TextAlign = HorizontalAlignment.Left; lv.Columns.Add(ch2); lv.BeginUpdate(); for (int i = 0; i &lt; 3; i++) { ListViewItem lvi = new ListViewItem("1", "2"); lvi.BackColor = Color.Black; lvi.ForeColor = Color.White; lv.Items.Add(lvi); } lv.EndUpdate(); } } </code></pre>
<p>Ah! I see now :}</p> <p>You want hacky? I present unto you the following:</p> <pre><code> ... lv.OwnerDraw = true; lv.DrawItem += new DrawListViewItemEventHandler( lv_DrawItem ); ... void lv_DrawItem( object sender, DrawListViewItemEventArgs e ) { Rectangle foo = e.Bounds; foo.Offset( -10, 0 ); e.Graphics.FillRectangle( new SolidBrush( e.Item.BackColor ), foo ); e.DrawDefault = true; } </code></pre> <p>For a more inventive - and no less hacky - approach, you could try utilising the background image of the ListView ;)</p>
<p>Ok I'm adding some additional solution notes. If you use the solution above you also need to insert a draw handler for the column headers, otherwise they won't paint. The selected item rectangle also looks funny so you'll want to check for that in the lv_DrawItem function and implement a similar solution. Remeber that highlighting is chosen at the system level and not in you application. </p>
8,517
<p>I’m just getting my feet wet with 3D printing, and I’ve had a few prints do this. Curious if anyone has any ideas for me that might help clean this up? (I don’t really have anyone in my personal circle who can help out, so hoping this community can :) )</p> <p>Edit 5/23 The first layer of the print is inconsistent in the way it’s deposited. Some areas feel correct while others are very thin. Usually there are large gaps like in the pictures below. After the first layer, the rest of the print seems to be fine. I’m curious is anyone has any insight into what could be causing the inconsistency.</p> <p>I try to level the bed before each print, but I’m not sure if it’s at the correct height as the instructions I got with the printer are pretty subjective: “use a piece of A4 paper and you should be able to pull it with <strong>some resistance</strong>”.</p> <p><a href="https://i.stack.imgur.com/OD6cz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OD6cz.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/cNVrs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cNVrs.jpg" alt="enter image description here" /></a></p>
<p>It looks like your nozzle is a little too close to the bed, if there is not enough space, you can see through the layer and pressure can build up and ooze out when there is a little more room in a different location (if the bed isn't completely flat/straight).</p> <p>You could level with a thicker piece of paper or add a Z-offset to the whole print ( e.g. in your slicer, or change the G-code by redefining the Z height).</p> <p>You could <em>also</em> increase the first layer a little when slicing.</p>
<p>It looks like a bed adhesion problem to me. Some additive information: What is your bed material?</p> <p>Z-calibration problem isn't the only suspect. I've seen the same problem with my printer before. There were defects in some parts of my glass print bed that prevented it from sticking.</p> <p>The molten filament from the hot nozzle has two adhesion chances; full adhesion to the bed or adhesion next to the previous extruded filament. If the previous filament is not stuck to the bed, it means you are printing on the air shown in the pictures.</p> <p>Without forgetting, your images also seem to have a Z-calibration problem, but as I said, I don't think it's the only suspect for blobs. It will be useful to clean the surface.</p>
1,946
<p>The application my team is currently developing has a DLL that is used to perform all database access. The application can not use a trusted connection because the database is behind a firewall and the domain server is not. So it appears that the connection string needs to have a DB username and password. The DLL currently has the database connection string hard coded, but I don't want to do this when we launch as the assembly can be disassembled and the username and password would be right there in the open.</p> <p>One of the requirements is that the password needs to be changed once every few months, so we would need to roll that out to our internal user base.</p> <p>Is there a way to store the password encrypted in such a way we can easily distribute to the entire user base without storing it in the assembly?</p> <p>UPDATE: Thanks to everyone who's answered. I'll try to answer some of the questions back to me... The data DLL is used by both ASP.NET WebForms and VB.NET WinForms. I understand that Applications can have their own config files, but I haven't seen anything on config files for DLLs. Unfortunately, I can't get to the Jon Galloway post at work so I can't judge if that will work. From a development standpoint, we don't want to use web services inhouse, but may be providing them to third parties sometime next year. I don't think impersonation will work because we can't authenticate the user through the firewall. As a user (or former user) can be an attacker, we're keeping it from everyone!</p>
<p>I'm not certain, but I believe you can put it in a config file and encrypt the config file.</p> <p>Update: See Jon Galloway's post <a href="http://weblogs.asp.net/jongalloway/archive/2008/04/13/encrypting-passwords-in-a-net-app-config-file.aspx" rel="nofollow noreferrer">here.</a></p>
<p>If the app is an ASP.NET app then just encrypt the connection strings section of your <code>web.config</code>.</p> <p>If the app is a client application running on multiple machines, instead of storing the connection string locally, consider using a web service or some other kind of secure mechanism to store it centrally. This would facilitate easier updates in the future and you're not storing the connection string locally.</p> <p>Just some thoughts.</p> <p><strong>Updated:</strong> @<a href="https://stackoverflow.com/questions/6113/what-is-the-best-way-to-store-connection-string-in-net-dlls#6162">lassevk</a></p> <p><em>&quot;Storing the connection string on a server, and obtaining it through a web connection sounds good, until you realize that you need security on that web connection as well, otherwise an attacker could just as well impersonate your program and talk to the web connection.&quot;</em></p> <p>Security on the web service was implicit. Depending on the type of deployment there are a numerous options...for example client side certificates.</p>
2,792
<p>I was trying to add a favicon to a website earlier and looked for a better way to implement this than to dump a <code>favicon.ico</code> file in the root of the website.</p> <p>I found this nice little guide: <a href="http://www.w3.org/2005/10/howto-favicon" rel="noreferrer">How to Add a Favicon</a>. However, the preferred method did not work in IE (7) and the second method is the old fashioned way (which I resigned myself to use).</p> <p>Is there a third method that works across all the most popular browsers?</p>
<p>This is what I always use: </p> <pre><code>&lt;link rel="icon" href="favicon.ico" type="image/x-icon" /&gt; &lt;link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /&gt; </code></pre> <p>The second one is for IE. The first one is for other browsers.</p>
<p>This is how they're doing it right here on Stack Overflow:</p> <pre><code>&lt;link rel="shortcut icon" href="/favicon.ico" /&gt; </code></pre>
2,838
<p>Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file my database client is using.</p> <p>What's the best way to figure this out? ++happy for various platform solutions. </p>
<p>Oracle provides a utility called <code>tnsping</code>:</p> <pre><code>R:\&gt;tnsping someconnection TNS Ping Utility for 32-bit Windows: Version 9.0.1.3.1 - Production on 27-AUG-20 08 10:38:07 Copyright (c) 1997 Oracle Corporation. All rights reserved. Used parameter files: C:\Oracle92\network\ADMIN\sqlnet.ora C:\Oracle92\network\ADMIN\tnsnames.ora TNS-03505: Failed to resolve name R:\&gt; R:\&gt;tnsping entpr01 TNS Ping Utility for 32-bit Windows: Version 9.0.1.3.1 - Production on 27-AUG-20 08 10:39:22 Copyright (c) 1997 Oracle Corporation. All rights reserved. Used parameter files: C:\Oracle92\network\ADMIN\sqlnet.ora C:\Oracle92\network\ADMIN\tnsnames.ora Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (COMMUNITY = **) (PROTOCOL = TCP) (Host = ****) (Port = 1521))) (CONNECT_DATA = (SID = ENTPR0 1))) OK (40 msec) R:\&gt; </code></pre> <p>This should show what file you're using. The utility sits in the Oracle <code>bin</code> directory.</p>
<p>The easiest way is probably to check the <strong>PATH</strong> environment variable of the process that is connecting to the database. Most likely the tnsnames.ora file is in <em>first Oracle bin directory in path</em>..\network\admin. TNS_ADMIN environment variable or value in registry (for the current Oracle home) may override this.</p> <p>Using filemon like suggested by others will also do the trick.</p>
3,169
<p>Using CSS,</p> <p>I'm trying to specify the height of a <code>span</code> tag in Firefox, but it's just not accepting it (IE does).</p> <p>Firefox accepts the <code>height</code> if I use a <code>div</code>, but the problem with using a <code>div</code> is the annoying line break after it, which I can't have in this particular instance. </p> <p>I tried setting the CSS style attribute of: <pre>display: inline</pre> for the <code>div</code>, but Firefox seems to revert that to <code>span</code> behavior anyway and ignores the <code>height</code> attribute once again.</p>
<pre><code>&lt;style&gt; #div1 { float:left; height:20px; width:20px; } #div2 { float:left; height:30px; width:30px } &lt;/style&gt; &lt;div id="div1"&gt;FirstDiv&lt;/div&gt; &lt;div id="div2"&gt;SecondDiv&lt;/div&gt; </code></pre> <p>As long as the container for whatever is holding <code>div's</code> 1 and 2 is wide enough for them to fit, this should be fine.</p>
<p><code>height</code> in <code>em</code> = <code>relative line-height</code></p> <p>for example <code>height:1.1em</code> with <code>line-height:1.1</code></p> <p>= 100% filled</p>
4,468
<p>What is the best way to profile a controller action in Ruby on Rails. Currently I am using the brute-force method of throwing in <code>puts Time.now</code> calls between what I think will be a bottleneck. But that feels really, really dirty. There has got to be a better way.</p>
<p>I picked up this technique a while back and have found it quite handy.</p> <p>When it's in place, you can add <code>?profile=true</code> to any URL that hits a controller. Your action will run as usual, but instead of delivering the rendered page to the browser, it'll send a detailed, nicely formatted ruby-prof page that shows where your action spent its time.</p> <p>First, add ruby-prof to your Gemfile, probably in the development group:</p> <pre><code>group :development do gem "ruby-prof" end </code></pre> <p>Then add an <a href="http://guides.rubyonrails.org/action_controller_overview.html#after-filters-and-around-filters" rel="nofollow noreferrer">around filter</a> to your ApplicationController:</p> <pre><code>around_action :performance_profile if Rails.env == 'development' def performance_profile if params[:profile] &amp;&amp; result = RubyProf.profile { yield } out = StringIO.new RubyProf::GraphHtmlPrinter.new(result).print out, :min_percent =&gt; 0 self.response_body = out.string else yield end end </code></pre> <p>Reading the ruby-prof output is a bit of an art, but I'll leave that as an exercise.</p> <p><strong>Additional note by ScottJShea:</strong> If you want to change the measurement type place this:</p> <p><code>RubyProf.measure_mode = RubyProf::GC_TIME #example</code></p> <p>Before the <code>if</code> in the profile method of the application controller. You can find a list of the available measurements at the <a href="https://github.com/ruby-prof/ruby-prof#measurements" rel="nofollow noreferrer">ruby-prof page</a>. As of this writing the <code>memory</code> and <code>allocations</code> data streams seem to be corrupted (<a href="https://github.com/ruby-prof/ruby-prof/issues/86" rel="nofollow noreferrer">see defect</a>).</p>
<p>This works in Rails 4.2.6:</p> <pre><code> o=OpenStruct.new(logger: Rails.logger) o.extend ActiveSupport::Benchmarkable o.benchmark 'name' do # ... your code ... end </code></pre>
5,125
<p>I sent 3 emails last week as replies from our website. None received them! One was yahoo, hotmail and an overseas domain. I am wondering if it's not a good idea to open a yahoo account with our domain name as the user just to reply to prospective buyers. </p>
<p>Your mail server's IP may have been black listed. This is common on shared servers. <a href="http://www.mxtoolbox.com/blacklists.aspx" rel="nofollow noreferrer">http://www.mxtoolbox.com/blacklists.aspx</a> </p>
<p>You could also try looking at <a href="http://www.google.com/apps/intl/en/business/index.html" rel="nofollow noreferrer">gmail for domains</a>. It's what I use and so far I haven't had a problem withany spam filters. Also make sure that you are not writing the content of the message to where a spam filter could flag it as spam. There's some guides on the net somewhere. I found out that by removing the word "free" from the message the emails started going though (before I was on gmail).</p>
9,398
<p>I'm looking for sources of inspiration and/or design patterns for navigation 'breadcrumbs'. So far I have found the <a href="http://patterntap.com/tap/collection/breadcrumbs" rel="noreferrer">breadcrumb collection on Pattern Tap</a>. Does anyone know of any other sources?</p>
<p>The article '<a href="http://www.alistapart.com/articles/taminglists/" rel="noreferrer">Taming lists</a>' from A List Apart has some good advice on CSS styling for breadcrumbs (look down for the heading 'Breadcrumb Trails').</p>
<p>If using Microsoft ASP.NET, there's a built in control: <a href="http://msdn.microsoft.com/en-us/library/x20z8c51.aspx" rel="nofollow noreferrer">SiteMapPath</a>.</p>
7,230
<p>If you have an <code>NSMutableArray</code>, how do you shuffle the elements randomly?</p> <p>(I have my own answer for this, which is posted below, but I'm new to Cocoa and I'm interested to know if there is a better way.)</p> <hr> <p>Update: As noted by @Mukesh, as of iOS 10+ and macOS 10.12+, there is an <code>-[NSMutableArray shuffledArray]</code> method that can be used to shuffle. See <a href="https://developer.apple.com/documentation/foundation/nsarray/1640855-shuffledarray?language=objc" rel="noreferrer">https://developer.apple.com/documentation/foundation/nsarray/1640855-shuffledarray?language=objc</a> for details. (But note that this creates a new array, rather than shuffling the elements in place.)</p>
<p>I solved this by adding a category to NSMutableArray.</p> <p><strong>Edit:</strong> Removed unnecessary method thanks to answer by Ladd.</p> <p><strong>Edit:</strong> Changed <code>(arc4random() % nElements)</code> to <code>arc4random_uniform(nElements)</code> thanks to answer by Gregory Goltsov and comments by miho and blahdiblah</p> <p><strong>Edit:</strong> Loop improvement, thanks to comment by Ron</p> <p><strong>Edit:</strong> Added check that array is not empty, thanks to comment by Mahesh Agrawal</p> <pre><code>// NSMutableArray_Shuffling.h #if TARGET_OS_IPHONE #import &lt;UIKit/UIKit.h&gt; #else #include &lt;Cocoa/Cocoa.h&gt; #endif // This category enhances NSMutableArray by providing // methods to randomly shuffle the elements. @interface NSMutableArray (Shuffling) - (void)shuffle; @end // NSMutableArray_Shuffling.m #import "NSMutableArray_Shuffling.h" @implementation NSMutableArray (Shuffling) - (void)shuffle { NSUInteger count = [self count]; if (count &lt;= 1) return; for (NSUInteger i = 0; i &lt; count - 1; ++i) { NSInteger remainingCount = count - i; NSInteger exchangeIndex = i + arc4random_uniform((u_int32_t )remainingCount); [self exchangeObjectAtIndex:i withObjectAtIndex:exchangeIndex]; } } @end </code></pre>
<pre><code>NSUInteger randomIndex = arc4random() % [theArray count]; </code></pre>
8,063
<p>I've seen questions about (like <a href="https://3dprinting.stackexchange.com/q/2670/11157">What is stopping us from mixing 3d filament colors in an Extruder?</a>) and some solutions for mixing filament colors/materials at print time for multi-color printing, but my question is different: Are there any (affordable) commercially available devices, or DIY/homebrew solutions, for taking 2 or more 1.75&nbsp;mm filaments, mixing them in proportion, and extruding back as 1.75&nbsp;mm filament for use in a printer?</p> <p>In principle it should just take N extruder drives fed a the right proportional rates, one of the multi-input hotends, a 1.75&nbsp;mm extrusion nozzle, and another drive to pull the extruded filament at the right rate to keep the diameter stable. But I'm curious if anyone's tried and tuned this. Another approach might be taking a hotend made for 3 mm filament, drilling the nozzle orifice out to 1.75 mm, and feeding 3 pieces of 1.75 mm filament into it at once (size seems to match pretty closely).</p> <p>My interest in this is that I mostly print small things, and it takes months to go through even a single kg of filament, so it's impractical to buy and keep around a bunch of different colors. I'd also like to be able to experiment with mixing flex PLA and plain PLA to get a material with a lot less plasticizer, so that it's not flexible, just less brittle.</p> <p>Shredding into pellets and measuring out ratios is too much overhead to make it worth it. The key part of the question is doing it direct from filament to filament.</p>
<p>OK, it just turned up on Thingiverse that someone has demonstrated a trivial machine to do exactly what I asked for: any FDM printer.</p> <blockquote> <p>Its sounds crazy, but it works! This technique will allow you to create one offs, and to color match your 3D-prints.</p> <p>It works by changing the filament (and the color) of your filament while printing, and this causes a multi colored filament, that can be printed again to archive a homogenic-color.</p> </blockquote> <p><img src="https://i.stack.imgur.com/b7aIr.jpg" alt="Rendering of STL file from the link" /></p> <p>Source <a href="https://www.thingiverse.com/thing:3565827" rel="nofollow noreferrer">3D-Printable Filament! -Print Your Own Filament for Multi-Color!</a>, with <a href="https://www.youtube.com/watch?v=6kbjZobJtbM" rel="nofollow noreferrer">demonstration video</a>.</p> <p>I'm in the process of trying this and it looks promising! The filament:</p> <p><img src="https://i.stack.imgur.com/aT5aP.jpg" alt="printed filament" /></p> <p>measures 1.65-1.75 mm in diameter and feeds and extrudes cleanly.</p> <p>The first test print:</p> <p><img src="https://i.stack.imgur.com/pICnN.jpg" alt="mixed filament frog next to unmixed comparison prints" /></p> <p>came out somewhat underextruded, but decent, with uniform mixing of color. Mixed filaments were white flex PLA and blue regular PLA, and the plasticizer seems to have mixed as expected too, but the print feels brittle due to underextrusion still. I suspect with some tuning of flow printing the filament, very good results could be had.</p> <p>On further inspection, the brittleness/underextrusion seems to be somewhat localized, so it likely comes from <em>inconsistent</em> diameter/density of printed filament. This actually seems consistent with what I saw from the slicer output for printing the filament: there were regions at +/- 45 degrees (+ or - depending on layer) in the spiral where it seems like wall gaps differed and extra gap fill material did or didn't get printed. This could be a slicer bug but it seems more likely it's a bug in the model, and I'd probably do better to recreate it myself in OpenSCAD...</p>
<h2>Making your own filament</h2> <p>Theoretically, this could be done with any filament producing equipment by taking the two filaments and shredding them into pellets and feeding them to the machine in the right mix for the color you want. Industrial setups like a <a href="https://www.filabot.com/" rel="nofollow noreferrer">Filabot</a> are heavy, large and expensive though.</p> <p>Luckily, hobbyist filament making setups exist. They vary in price and quality but can achieve ok to good results, if you tinker with them a little. Among the kits that I have seen to work is the <a href="https://www.filastruder.com/collections/filastruders-accessories" rel="nofollow noreferrer">Filastruder</a>, but there are also <a href="https://all3dp.com/make-low-cost-filament-extruder/" rel="nofollow noreferrer">DIY instructables</a> that cost less than 200 $.</p> <h3>Obtaining pellets</h3> <p>If you are good with mechanics, you might design a feed mechanism that pushes the part filaments with known feed rate into a cutter to pelletize the filament in the wanted amounts to each other, creating a homogenous mix over the length of the filament.</p> <h3>Blended waste</h3> <p>As an alternative to self-made pellets to mix in the hopper for the filament maker, one can use shredded waste prints/support structures. After smashing the material to rough chunks, using a blender to gain evenly sized small chunks of 1-2 mm, the stuff should be small enough to feed through the hopper without a problem. the blender also would take care of proper mixing and could take raw filament to mix with <em>used</em> ones.</p> <h2>Mixing in the hotend</h2> <p>Mixing filaments in the hotend would need a specialized hotend with two feed ends into the melt zone and two extruders that push the filaments with the same feed rate. The modification of the feeding system would be extensive and demand a custom firmware.</p> <h2>Splicing filaments</h2> <p>Another possibility would be a machine that splices the filament in a defined manner. One machine that might be able to do this seems to be the Palette 2 by Mosaic, but it costs (April 2019) round 600 USD. Another possibility could be to use the multi-material upgrade of a Prusa i3 Mk3.</p> <p>This would generate however a non-homogenous mix of the filaments, the transition zones changing from high concentrations of material A to high concentrations of material B whenever the materials swap. Even with very short areas of spliced material the mix will be inconsistent. With colored filaments, this could generate a rainbow pattern.</p>
1,296
<p>What tools are available to monitor graphics card memory usage in linux?</p>
<p><a href="http://developer.nvidia.com/content/nvidia-perfkit" rel="nofollow noreferrer">NVIDIA PerfKit</a> has a linux version which allows real-time monitoring of various graphics card properties, including graphics card memory usage. Obviously, this only works for NVIDIA graphics cards, and it also requires the use of a special instrumented driver.</p>
<p>If you just need to know it for 3D graphics development purposes, you may want to look into something like <a href="http://www.gremedy.com/" rel="nofollow noreferrer">gDEBugger</a> or, if you only care about NVIDIA cards, you can try <a href="http://developer.nvidia.com/content/nvidia-perfhud" rel="nofollow noreferrer">NVIDIA PerfHUD</a>. I have not used them myself, but I would expect them to track such information.</p>
7,265
<p>I recently discussed editors with a co-worker. He uses one of the less popular editors and I use another (I won't say which ones since it's not relevant and I want to avoid an editor flame war). I was saying that I didn't like his editor as much because it doesn't let you do find/replace with regular expressions.</p> <p>He said he's never wanted to do that, which was surprising since it's something I find myself doing all the time. However, off the top of my head I wasn't able to come up with more than one or two examples. Can anyone here offer some examples of times when they've found regex find/replace useful in their editor? Here's what I've been able to come up with since then as examples of things that I've actually had to do:</p> <ol> <li><p>Strip the beginning of a line off of every line in a file that looks like:<br> <code>Line 25634 :</code><br> <code>Line 632157 :</code></p></li> <li><p>Taking a few dozen files with a standard header which is slightly different for each file and stripping the first 19 lines from all of them all at once.</p></li> <li><p>Piping the result of a MySQL select statement into a text file, then removing all of the formatting junk and reformatting it as a Python dictionary for use in a simple script.</p></li> <li><p>In a CSV file with no escaped commas, replace the first character of the 8th column of each row with a capital A.</p></li> <li><p>Given a bunch of GDB stack traces with lines like<br> <code>#3 0x080a6d61 in _mvl_set_req_done (req=0x82624a4, result=27158) at ../../mvl/src/mvl_serv.c:850</code><br> strip out everything from each line except the function names.</p></li> </ol> <p>Does anyone else have any real-life examples? The next time this comes up, I'd like to be more prepared to list good examples of why this feature is useful.</p>
<p>Just last week, I used regex find/replace to convert a CSV file to an XML file.</p> <p>Simple enough to do really, just chop up each field (luckily it didn't have any escaped commas) and push it back out with the appropriate tags in place of the commas.</p>
<p>The first thing I do with any editor is try to figure out it's Regex oddities. I use it all the time. Nothing really crazy, but it's handy when you've got to copy/paste stuff between different types of text - SQL &lt;-> PHP is the one I do most often - and you don't want to fart around making the same change 500 times.</p>
7,510
<p>I am rewriting code to handle some embedded communications and right now the protocol handling is implemented in a While loop with a large case/switch statement. This method seems a little unwieldy. What are the most commonly used flow control methods for implementing communication protocols?</p>
<p>It sounds like the "while + switch/case" is a statemachine implementation. I believe that a well thought out statemachine is often the easiest and most readable way to implement a protocol.</p> <p>When it comes to statemachines, breaking some of the traditional programming rules comes with the territory. Rules like "every function should be less than 25 lines" just don't work. One might even argue that statemachines are GOTOs in disguise.</p>
<p>For cases where you key off of a field in a protocol header to direct you to the next stage of processing for that protocol, arrays of function pointers can be used. You use the value from the protocol header to index into the array and call the function for that protocol.</p> <p>You <strong>must</strong> handle all possible values in this array, even those which are not valid. Eventually you will get a packet containing the invalid value, either because someone is trying an attack or because a future rev of the protocol adds new values.</p>
9,004
<p>I have a multi dimensional OLAP cube with a number of dimensions. Some of these dimensions have hierarchies. The users would like to perform 'what-if' analysis on the measures in the cube by changing the hierarchies in the dimensions. </p> <p>For example, they want to know the impact on departmental resource budgets by moving employees between departments or the movement in cost of manufacture if a product is moved from one factory to another.</p> <p>Does anyone have a straight forward way to do this in a modern OLAP engine?</p>
<p>have you taken a look here? <a href="http://office.microsoft.com/en-us/excel/HA011265551033.aspx" rel="nofollow noreferrer">http://office.microsoft.com/en-us/excel/HA011265551033.aspx</a> if you are using sql server and excel, you want the "Excel Add-in for SQL Server Analysis Services" and you can perform writeback to the cubes. Might not be exactly what you want, but it is the closest I have come across.</p> <p>"What-if analysis and writeback What-if analysis enables you to initiate a "what-if" scenario by updating data and analyzing the effects of changes on your data. You can save the scenario for future analysis. When you save the scenario, changes you made to data (known as writeback data) are written to the cube. Once you write back changes, the data is available for future analysis and can be viewed by and shared with others who have access to the cube."</p>
<p>There may be tools that allow this sort of analysis, but I only have experience of writing MDX, which ought to be able to help you.</p> <p>Typical 'what if' analysis is more about changing values in the OLAP cube (e.g. change net sales from 845.45 to 700.00 and see what happens to gross profit). Your case is a bit different as you want to move members within a hierarhy, but keep the same values.</p> <p>I haven't worked through a full solution, but the way I would approach it would be to create a new 'calculated member' or set (on the fly) and use that to build up the new hierarchy that you want. Your query can then use that on one axis.</p> <p>Look carefully into 'visual totals' as there may be potential pitfalls there!</p>
5,457
<p>In Google Reader, you can use a bookmarklet to "note" a page you're visiting. When you press the bookmarklet, a little Google form is displayed on top of the current page. In the form you can enter a description, etc. When you press Submit, the form submits itself without leaving the page, and then the form disappears. All in all, a very smooth experience.</p> <p>I obviously tried to take a look at how it's done, but the most interesting parts are minified and unreadable. So...</p> <p>Any ideas on how to implement something like this (on the browser side)? What issues are there? Existing blog posts describing this?</p>
<p>Aupajo has it right. I will, however, point you towards a bookmarklet framework I worked up for our site (<a href="http://www.iminta.com" rel="nofollow noreferrer">www.iminta.com</a>).</p> <p>The bookmarklet itself reads as follows:</p> <pre><code>javascript:void((function(){ var e=document.createElement('script'); e.setAttribute('type','text/javascript'); e.setAttribute('src','http://www.iminta.com/javascripts/new_bookmarklet.js?noCache='+new%20Date().getTime()); document.body.appendChild(e) })()) </code></pre> <p>This just injects a new script into the document that includes this file:</p> <p><a href="http://www.iminta.com/javascripts/new_bookmarklet.js" rel="nofollow noreferrer">http://www.iminta.com/javascripts/new_bookmarklet.js</a></p> <p>It's important to note that the bookmarklet creates an iframe, positions it, and adds events to the document to allow the user to do things like hit escape (to close the window) or to scroll (so it stays visible). It also hides elements that don't play well with z-positioning (flash, for example). Finally, it facilitates communicating across to the javascript that is running within the iframe. In this way, you can have a close button in the iframe that tells the parent document to remove the iframe. This kind of cross-domain stuff is a bit hacky, but it's the only way (I've seen) to do it.</p> <p>Not for the feint of heart; if you're not good at JavaScript, prepare to struggle.</p>
<p>At it's very basic level it will be using <code>createElement</code> to create the elements to insert into the page and <code>appendChild</code> or <code>insertBefore</code> to insert them into the page.</p>
9,327
<p>I'm looking for suggestions for 3D design software which support designing multi-material parts.</p> <p>I will be printing on a multi-extruder machine based on RepRap firmware. The printer will handle the files when given a proper g-code file. Slic3r will produce a proper g-code file given the right input. STL seems to be single-material, so I am looking for something like AMF files, or any alternative.</p> <p>My question is, what is available for 3D design software which will produce a geometry file which slic3r (or some other slicing software) will properly process? I'm not asking for opinions on which software is best.</p> <p>I believe this is my first question in any StackExchange forum, so if I have trespassed on community standards, it was not my intention.</p>
<h2>A Scriptable Process for Generating Multi-Material STL Files:</h2> <p>I am now using interactive CAD software to define the more complex features of the object I am printing (in the current case, clock faces), and then using OpenSCAD to do the boolean volume operations. </p> <p>To print the composite object, I need three STL files, one for each material I am using. The three parts are the clock body, the translucent optics to conduct the LED lights, and the clock numbers. </p> <p>I need:</p> <ul> <li>one STL for the body minus the LED optics and minus the numbers.</li> <li>one STL for the numbers minus the LED optics, and</li> <li>one STL for the LED optics.</li> </ul> <p>The CAD package supports the operations, but every time I change anything, I have to jump through several hoops to combine the three parts, manually and recreate the three objects. </p> <p>I had used OpenSCAD to make the optics and the numbers, and they were never in the same coordinate system as the clock body from the interactive CAD package.</p> <p>So, I scripted it and used OpenSCAD to read the clock body STL and being it into OpenScad. I transformed it into the common coordinate system. I then did, one by one, based on a command-line parameter, the boolean operations, rendered the result, and exported the resulting STL file.</p> <p>When I read the three files into PrusaSlicer, the lined up perfectly and everything worked simply, without and precision hand-eye coordination, and with no drama.</p> <p>Scripts and command lines work for repeatability far better than squint, drag, and guess.</p>
<p>You do not necessarily need a specific design tool, you can use any tool you want to create your multiple material product. It is the slicer software that manages the materials by assigning the correct extruder. E.g. Cura is able to join 2 STL files that fit together and assign each part a specific extruder and thus material. Please read more <a href="https://ultimaker.com/en/blog/34012-get-started-with-cura-printing-with-two-colors" rel="nofollow noreferrer">here for instructions</a></p>
860
<p>Not quite sure what's happening here. I printed it as a single ball and had this effect. I thought it might be a cooling issue so I printed 4 at once but the issue still occurred. If I size the ball up, the problem reduces.</p> <p>Note that the hole is supposed to be a cylinder.</p> <p><a href="https://i.stack.imgur.com/owZtw.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/owZtw.jpg" alt="Photo of four balls exhibiting bumps around a cyclindrical through hole"></a></p>
<p>It looks like possibly a combination of too high of extruder temperature and poor retraction.</p> <ol> <li>First, try <strong><em>reducing your extruder temperature</em></strong>. PLA ideal extruder temps range from about 185C to 225C; depending on purity, quality, and climate. This can help prevent additional oozing and clogging. If your extruder clogs easily, you probably have too high of temperature.</li> <li>After you've verified you have correct extrusion temperature. Try <strong><em>finding/adjusting retraction settings</em></strong> in your preferred slicing engine. Here's a good troubleshoot page from <a href="https://www.simplify3d.com/support/print-quality-troubleshooting/#blobs-and-zits" rel="nofollow noreferrer">Simplify3D's website</a>.</li> </ol>
<p>It looks like it is trying to fill in what might be small gaps and is putting blobs down because the gaps to too small of a detail to accurately fill.</p>
411
<p>I have a very simple problem which requires a very quick and simple solution in SQL Server 2005.</p> <p>I have a table with x Columns. I want to be able to select one row from the table and then transform the columns into rows.</p> <pre><code>TableA Column1, Column2, Column3 </code></pre> <p>SQL Statement to ruturn</p> <pre><code>ResultA Value of Column1 Value of Column2 Value of Column3 </code></pre> <hr> <p><strong>@Kevin:</strong> I've had a google search on the topic but alot of the example where overly complex for my example, <strong>are you able to help further?</strong></p> <p>@Mario: The solution I am creating has 10 columns which stores the values 0 to 6 and I must work out how many columns have the value 3 or more. So I thought about creating a query to turn that into rows and then using the generated table in a subquery to say count the number of rows with Column >= 3</p>
<p>You should take a look at the UNPIVOT clause.</p> <p><strong>Update1</strong>: GateKiller, strangely enough I read an article (about something unrelated) about it this morning and I'm trying to jog my memory where I saw it again, had some decent looking examples too. It'll come back to me I'm sure.</p> <p><strong>Update2</strong>: Found it: <a href="http://weblogs.sqlteam.com/jeffs/archive/2008/04/23/unpivot.aspx" rel="nofollow noreferrer">http://weblogs.sqlteam.com/jeffs/archive/2008/04/23/unpivot.aspx</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms180026.aspx" rel="nofollow noreferrer">UNION</a> should be your friend:</p> <pre><code>SELECT Column1 FROM table WHERE idColumn = 1 UNION ALL SELECT Column2 FROM table WHERE idColumn = 1 UNION ALL SELECT Column3 FROM table WHERE idColumn = 1 </code></pre> <p>but it can <a href="http://blog.falafel.com/2006/01/20/TSQLTipAvoidUNION.aspx" rel="nofollow noreferrer">also be your foe</a> on large result sets.</p>
2,559
<p>Trying to get my css / C# functions to look like this:</p> <pre><code>body { color:#222; } </code></pre> <p>instead of this:</p> <pre><code>body { color:#222; } </code></pre> <p>when I auto-format the code.</p>
<p><strong>C#</strong></p> <ol> <li>In the <em>Tools</em> Menu click <em>Options</em></li> <li>Click <em>Show all Parameters</em> (checkbox at the bottom left) (<em>Show all settings</em> in VS 2010)</li> <li>Text Editor</li> <li>C#</li> <li>Formatting</li> <li>New lines</li> </ol> <p>And there check when you want new lines with brackets</p> <p><strong>Css:</strong></p> <p><em>almost the same, but fewer options</em></p> <ol> <li>In the <em>Tools</em> Menu click <em>Options</em></li> <li>Click <em>Show all Parameters</em> (checkbox at the bottom left) (<em>Show all settings</em> in VS 2010)</li> <li>Text Editor</li> <li>CSS</li> <li>Format</li> </ol> <p>And than you select the formatting you want (in your case second radio button)</p> <p><strong>For Visual Studio 2015:</strong></p> <p>Tools → Options</p> <p>In the sidebar, go to Text Editor → C# → Formatting → New Lines</p> <p>and uncheck every checkbox in the section <em>&quot;New line options for braces&quot;</em></p> <p><a href="https://i.stack.imgur.com/Drc10.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Drc10.png" alt="enter image description here" /></a></p> <p><strong>For Mac OS users:</strong><br /> Preferences → Source Code → Code Formatting → choose what ever you want to change (like C# source code) → C# Format → Edit -→ New Lines</p>
<p>If you're looking for this option within <strong>Visual Studio 2014</strong>, then it's under advanced and is now a 'Brace positions' drop down box:</p> <p><img src="https://i.stack.imgur.com/QbA8S.png" alt="enter image description here"></p>
6,064
<p>How would I go about replacing Windows Explorer with a third party tool such as TotalCommander, explorer++, etc?</p> <p>I would like to have one of those load instead of win explorer when I type "C:\directoryName" into the run window. Is this possible?</p>
<p>From a comment on the first LifeHacker link,</p> <h3>How to make x² your default folder application</h3> <p>As part of the installation process, x² adds "open with xplorer2" in the context menu for filesystem folders.</p> <p>If you want to have this the default action (so that folders always open in x2 when you click on them) then make sure this is the default verb, either using Folder Options ("file folder" type) or editing the registry:</p> <pre><code>[HKEY_CLASSES_ROOT\Directory\shell] @="open_x2" </code></pre> <p>If you want some slightly different command line options, you can add any of the supported options by editing the following registry key:</p> <pre><code>[HKEY_CLASSES_ROOT\Directory\shell\open\command] @="C:\Program files\zabkat\xplorer2\xplorer2_UC.exe" /T /1 "%1" </code></pre> <p>Notes:</p> <ol> <li><p>Please check your installation folder first: Your installation path may be different. Secondly, your executable may be called <code>xplorer2.exe</code>, if it is the non-Unicode version.</p></li> <li><p>Note that <code>"%1"</code> is required (including the quotation marks), and is replaced by the folder path you are trying to open.</p></li> <li><p>The <code>/T</code> switch causes no tabs to be restored and the <code>/1</code> switch puts x² in single pane mode. (You do not have to use these switches, but they make sense).</p></li> </ol> <p><em>(The above are from xplorer2 user manual)</em></p>
<p>If you go to Control Panel -> Folder Options And go to the File Types tab. You can go to the "Folder" file type (with "(NONE)" as the extension). Go to Advanced, create a new action that uses your program (I tried it with FreeCommander). Make sure you set it as default.</p> <p>That should do it.</p>
7,864
<p>If I call <code>os.stat()</code> on a broken <code>symlink</code>, python throws an <code>OSError</code> exception. This makes it useful for finding them. However, there are a few other reasons that <code>os.stat()</code> might throw a similar exception. Is there a more precise way of detecting broken <code>symlinks</code> with Python under Linux?</p>
<p>A common Python saying is that it's easier to ask forgiveness than permission. While I'm not a fan of this statement in real life, it does apply in a lot of cases. Usually you want to avoid code that chains two system calls on the same file, because you never know what will happen to the file in between your two calls in your code.</p> <p><strong>A typical mistake is to write something like</strong>:</p> <pre><code>if os.path.exists(path): os.unlink(path) </code></pre> <p>The second call (os.unlink) may fail if something else deleted it after your if test, raise an Exception, and stop the rest of your function from executing. (You might think this doesn't happen in real life, but we just fished another bug like that out of our codebase last week - and it was the kind of bug that left a few programmers scratching their head and claiming 'Heisenbug' for the last few months)</p> <p>So, in your particular case, I would probably do:</p> <pre><code>try: os.stat(path) except OSError, e: if e.errno == errno.ENOENT: print 'path %s does not exist or is a broken symlink' % path else: raise e </code></pre> <p>The annoyance here is that stat returns the same error code for a symlink that just isn't there and a broken symlink.</p> <p>So, I guess you have no choice than to break the atomicity, and do something like</p> <pre><code>if not os.path.exists(os.readlink(path)): print 'path %s is a broken symlink' % path </code></pre>
<p>I had a similar problem: how to catch broken symlinks, even when they occur in some parent dir? I also wanted to log all of them (in an application dealing with a fairly large number of files), but without too many repeats.</p> <p>Here is what I came up with, including unit tests.</p> <p><strong>fileutil.py</strong>:</p> <pre><code>import os from functools import lru_cache import logging logger = logging.getLogger(__name__) @lru_cache(maxsize=2000) def check_broken_link(filename): """ Check for broken symlinks, either at the file level, or in the hierarchy of parent dirs. If it finds a broken link, an ERROR message is logged. The function is cached, so that the same error messages are not repeated. Args: filename: file to check Returns: True if the file (or one of its parents) is a broken symlink. False otherwise (i.e. either it exists or not, but no element on its path is a broken link). """ if os.path.isfile(filename) or os.path.isdir(filename): return False if os.path.islink(filename): # there is a symlink, but it is dead (pointing nowhere) link = os.readlink(filename) logger.error('broken symlink: {} -&gt; {}'.format(filename, link)) return True # ok, we have either: # 1. a filename that simply doesn't exist (but the containing dir does exist), or # 2. a broken link in some parent dir parent = os.path.dirname(filename) if parent == filename: # reached root return False return check_broken_link(parent) </code></pre> <p>Unit tests:</p> <pre><code>import logging import shutil import tempfile import os import unittest from ..util import fileutil class TestFile(unittest.TestCase): def _mkdir(self, path, create=True): d = os.path.join(self.test_dir, path) if create: os.makedirs(d, exist_ok=True) return d def _mkfile(self, path, create=True): f = os.path.join(self.test_dir, path) if create: d = os.path.dirname(f) os.makedirs(d, exist_ok=True) with open(f, mode='w') as fp: fp.write('hello') return f def _mklink(self, target, path): f = os.path.join(self.test_dir, path) d = os.path.dirname(f) os.makedirs(d, exist_ok=True) os.symlink(target, f) return f def setUp(self): # reset the lru_cache of check_broken_link fileutil.check_broken_link.cache_clear() # create a temporary directory for our tests self.test_dir = tempfile.mkdtemp() # create a small tree of dirs, files, and symlinks self._mkfile('a/b/c/foo.txt') self._mklink('b', 'a/x') self._mklink('b/c/foo.txt', 'a/f') self._mklink('../..', 'a/b/c/y') self._mklink('not_exist.txt', 'a/b/c/bad_link.txt') bad_path = self._mkfile('a/XXX/c/foo.txt', create=False) self._mklink(bad_path, 'a/b/c/bad_path.txt') self._mklink('not_a_dir', 'a/bad_dir') def tearDown(self): # Remove the directory after the test shutil.rmtree(self.test_dir) def catch_check_broken_link(self, expected_errors, expected_result, path): filename = self._mkfile(path, create=False) with self.assertLogs(level='ERROR') as cm: result = fileutil.check_broken_link(filename) logging.critical('nothing') # trick: emit one extra message, so the with assertLogs block doesn't fail error_logs = [r for r in cm.records if r.levelname is 'ERROR'] actual_errors = len(error_logs) self.assertEqual(expected_result, result, msg=path) self.assertEqual(expected_errors, actual_errors, msg=path) def test_check_broken_link_exists(self): self.catch_check_broken_link(0, False, 'a/b/c/foo.txt') self.catch_check_broken_link(0, False, 'a/x/c/foo.txt') self.catch_check_broken_link(0, False, 'a/f') self.catch_check_broken_link(0, False, 'a/b/c/y/b/c/y/b/c/foo.txt') def test_check_broken_link_notfound(self): self.catch_check_broken_link(0, False, 'a/b/c/not_found.txt') def test_check_broken_link_badlink(self): self.catch_check_broken_link(1, True, 'a/b/c/bad_link.txt') self.catch_check_broken_link(0, True, 'a/b/c/bad_link.txt') def test_check_broken_link_badpath(self): self.catch_check_broken_link(1, True, 'a/b/c/bad_path.txt') self.catch_check_broken_link(0, True, 'a/b/c/bad_path.txt') def test_check_broken_link_badparent(self): self.catch_check_broken_link(1, True, 'a/bad_dir/c/foo.txt') self.catch_check_broken_link(0, True, 'a/bad_dir/c/foo.txt') # bad link, but shouldn't log a new error: self.catch_check_broken_link(0, True, 'a/bad_dir/c') # bad link, but shouldn't log a new error: self.catch_check_broken_link(0, True, 'a/bad_dir') if __name__ == '__main__': unittest.main() </code></pre>
4,115
<p>When looking beyond the <a href="https://en.wikipedia.org/wiki/Rapid_application_development" rel="noreferrer">RAD</a> (drag-drop and configure) way of building user interfaces that many tools encourage you are likely to come across three design patterns called <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="noreferrer">Model-View-Controller</a>, <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter" rel="noreferrer">Model-View-Presenter</a> and <a href="http://en.wikipedia.org/wiki/Model_View_ViewModel" rel="noreferrer">Model-View-ViewModel</a>. My question has three parts to it:</p> <ol> <li>What issues do these patterns address?</li> <li>How are they similar?</li> <li>How are they different?</li> </ol>
<h2>Model-View-Presenter</h2> <p>In <strong>MVP</strong>, the Presenter contains the UI business logic for the View. All invocations from the View delegate directly to the Presenter. The Presenter is also decoupled directly from the View and talks to it through an interface. This is to allow mocking of the View in a unit test. One common attribute of MVP is that there has to be a lot of two-way dispatching. For example, when someone clicks the &quot;Save&quot; button, the event handler delegates to the Presenter's &quot;OnSave&quot; method. Once the save is completed, the Presenter will then call back the View through its interface so that the View can display that the save has completed.</p> <p>MVP tends to be a very natural pattern for achieving separated presentation in WebForms. The reason is that the View is always created first by the ASP.NET runtime. You can <a href="https://web.archive.org/web/20071211153445/http://www.codeplex.com/websf/Wiki/View.aspx?title=MVPDocumentation" rel="noreferrer">find out more about both variants</a>.</p> <h3>Two primary variations</h3> <p><strong>Passive View:</strong> The View is as dumb as possible and contains almost zero logic. A Presenter is a middle man that talks to the View and the Model. The View and Model are completely shielded from one another. The Model may raise events, but the Presenter subscribes to them for updating the View. In Passive View there is no direct data binding, instead, the View exposes setter properties that the Presenter uses to set the data. All state is managed in the Presenter and not the View.</p> <ul> <li>Pro: maximum testability surface; clean separation of the View and Model</li> <li>Con: more work (for example all the setter properties) as you are doing all the data binding yourself.</li> </ul> <p><strong>Supervising Controller:</strong> The Presenter handles user gestures. The View binds to the Model directly through data binding. In this case, it's the Presenter's job to pass off the Model to the View so that it can bind to it. The Presenter will also contain logic for gestures like pressing a button, navigation, etc.</p> <ul> <li>Pro: by leveraging data binding the amount of code is reduced.</li> <li>Con: there's a less testable surface (because of data binding), and there's less encapsulation in the View since it talks directly to the Model.</li> </ul> <h2>Model-View-Controller</h2> <p>In the <strong>MVC</strong>, the Controller is responsible for determining which View to display in response to any action including when the application loads. This differs from MVP where actions route through the View to the Presenter. In MVC, every action in the View correlates with a call to a Controller along with an action. In the web, each action involves a call to a URL on the other side of which there is a Controller who responds. Once that Controller has completed its processing, it will return the correct View. The sequence continues in that manner throughout the life of the application:</p> <pre> Action in the View -> Call to Controller -> Controller Logic -> Controller returns the View. </pre> <p>One other big difference about MVC is that the View does not directly bind to the Model. The view simply renders and is completely stateless. In implementations of MVC, the View usually will not have any logic in the code behind. This is contrary to MVP where it is absolutely necessary because, if the View does not delegate to the Presenter, it will never get called.</p> <h2>Presentation Model</h2> <p>One other pattern to look at is the <strong>Presentation Model</strong> pattern. In this pattern, there is no Presenter. Instead, the View binds directly to a Presentation Model. The Presentation Model is a Model crafted specifically for the View. This means this Model can expose properties that one would never put on a domain model as it would be a violation of separation-of-concerns. In this case, the Presentation Model binds to the domain model and may subscribe to events coming from that Model. The View then subscribes to events coming from the Presentation Model and updates itself accordingly. The Presentation Model can expose commands which the view uses for invoking actions. The advantage of this approach is that you can essentially remove the code-behind altogether as the PM completely encapsulates all of the behavior for the view. This pattern is a very strong candidate for use in WPF applications and is also called <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx" rel="noreferrer">Model-View-ViewModel</a>.</p> <p>There is a <a href="http://msdn.microsoft.com/en-us/library/ff921080.aspx" rel="noreferrer">MSDN article about the Presentation Model</a> and a section in the <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx" rel="noreferrer">Composite Application Guidance for WPF</a> (former Prism) about <a href="http://msdn.microsoft.com/en-us/library/cc707862.aspx" rel="noreferrer">Separated Presentation Patterns</a></p>
<p><strong>MVP</strong></p> <p>MVP stands for Model - View- Presenter. This came to a picture in early 2007 where Microsoft introduced Smart Client windows applications. </p> <p>A presenter is acting as a supervisory role in MVP which binding View events and business logic from models.</p> <p>View event binding will be implemented in the Presenter from a view interface. </p> <p>The view is the initiator for user inputs and then delegates the events to the Presenter and the presenter handles event bindings and gets data from models.</p> <p><strong>Pros:</strong> The view is having only UI not any logics High level of testability </p> <p><strong>Cons:</strong> Bit complex and more work when implementing event bindings</p> <p><strong>MVC</strong></p> <p>MVC stands for Model-View-Controller. Controller is responsible for creating models and rendering views with binding models. </p> <p>Controller is the initiator and it decides which view to render. </p> <p><strong>Pros:</strong> Emphasis on Single Responsibility Principle High level of testability </p> <p><strong>Cons:</strong> Sometimes too much workload for Controllers, if try to render multiple views in same controller. </p>
2,428
<p>Let's say you work someplace where every change to source code must be associated with a bug-report or feature-request, and there is no way to get that policy reformed. In such an environment, what is the best way to deal with code refactorings (that is, changes that improve the code but do not fix a bug or add a feature)?</p> <ul> <li>Write up a bug-report and associate the refactoring with it.</li> <li>Write up a feature-request and associate the refactoring with it.</li> <li>Sneak in the refactorings while working on code that is associated with a bug-report/feature-request.</li> <li>Just don't do any refactoring.</li> <li>Other</li> </ul> <p>Note that all bug reports and feature descriptions will be visible to managers and customers.</p>
<p>I vote for the "sneak in refactorings" approach, which is, I believe, the way refactoring is meant to be done in the first place. It's probably a bad idea to refactor just for the sake of "cleaning up the code." This means that you're making changes for no real reason. Refactoring is, by definition, modifying the without the intent of fixing bugs or adding features. If you're following the KISS principle, any new feature is going to need at least some refactoring because you're not really thinking about how to make the most extensible system possible the first time around.</p>
<p>Lets have a look at each option:</p> <ul> <li>Write up a bug-report and associate the refactoring with it.</li> </ul> <p>If you feel that, in your opinion, the original code poses a security risk or potential for crashing or instability. Write a small bug report outlining the danger, and then fix it.</p> <ul> <li>Write up a feature-request and associate the refactoring with it.</li> </ul> <p>It might be harder to reactor code based on a feature request. But you could use valid feature request to do this which leads me onto the next point...</p> <ul> <li>Sneak in the refactorings while working on code that is associated with a bug-report/feature-request.</li> </ul> <p>If there is a valid bug or feature, state that function x had to be change slightly to fix the bug or add the feature.</p> <ul> <li>Just don't do any refactoring.</li> </ul> <p>This seems to suggest the self development through improving an application is not allowed. Developers should be allowed, if not, encourage to explorer new techniques and technologies.</p> <ul> <li>Other</li> </ul> <p>Perhaps you could discuss your improvement at relevant meeting, giving convincing reasons why the changes should be made. Then at least you will have management backing to the change without having to sneak in the code through another method.</p>
7,790
<p>I have jQuery but I'm not sure if it has any built-in sorting helpers. I could make a 2d array of each item's <code>text</code>, <code>value</code>, and <code>selected</code> properties, but I don't think that javascript's built in <code>Array.sort()</code> would work correctly.</p>
<p>Extract options into a temporary array, sort, then rebuild the list:</p> <pre><code>var my_options = $("#my_select option"); var selected = $("#my_select").val(); my_options.sort(function(a,b) { if (a.text &gt; b.text) return 1; if (a.text &lt; b.text) return -1; return 0 }) $("#my_select").empty().append( my_options ); $("#my_select").val(selected); </code></pre> <p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort" rel="noreferrer" title="Mozilla&#39;s sort documentation">Mozilla's sort documentation</a> (specifically the compareFunction) and <a href="http://en.wikipedia.org/wiki/Sorting_algorithm" rel="noreferrer">Wikipedia's Sorting Algorithm page</a> are relevant.</p> <p>If you want to make the sort case insensitive, replace <code>text</code> with <code>text.toLowerCase()</code></p> <p>The sort function shown above illustrates how to sort. Sorting non-english languages accurately can be complex (see the <a href="http://www.unicode.org/reports/tr10/" rel="noreferrer">unicode collation algorithm</a>). Using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare" rel="noreferrer">localeCompare</a> in the sort function is a good solution, eg:</p> <pre><code>my_options.sort(function(a,b) { return a.text.localeCompare(b.text); }); </code></pre>
<p>Seems jquery still is not particularly helpful enough for sorting options in a html select element. Here is some plain-plain javascript code for sorting options:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function sortOptionsByText(a,b) { // I keep an empty value option on top, b.value comparison to 0 might not be necessary if empty value is always on top... if (a.value.length==0 || (b.value.length&gt;0 &amp;&amp; a.text &lt;= b.text)) return -1; // no sort: a, b return 1; // sort switches places: b, a } function sortOptionsByValue(a,b) { if (a.value &lt;= b.value) return -1; // a, b return 1; // b, a } function clearChildren(elem) { if (elem) { while (elem.firstChild) { elem.removeChild(elem.firstChild); } } } function sortSelectElem(sel,byText) { const val=sel.value; const tmp=[...sel.options]; tmp.sort(byText?sortOptionsByText:sortOptionsByValue); clearChildren(sel); sel.append(...tmp); sel.value=val; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>RACE: &lt;select id="list" size="6"&gt; &lt;option value=""&gt;--PICK ONE--&lt;/option&gt; &lt;option value="1"&gt;HUMANOID&lt;/option&gt; &lt;option value="2"&gt;AMPHIBIAN&lt;/option&gt; &lt;option value="3"&gt;REPTILE&lt;/option&gt; &lt;option value="4"&gt;INSECTOID&lt;/option&gt; &lt;/select&gt;&lt;br&gt; &lt;button type="button" onclick="sortSelectElem(document.getElementById('list'));"&gt;SORT LIST BY VALUE&lt;/button&gt;&lt;br&gt; &lt;button type="button" onclick="sortSelectElem(document.getElementById('list'),true);"&gt;SORT LIST BY TEXT&lt;/button&gt;</code></pre> </div> </div> </p>
6,790
<p>I have a dropdownlist with the autopostback set to true. I want the user to confirm if they really want to change the value, which on post back fires a server side event (selectedindexchanged).</p> <p>I have tried adding an onchange attribute "return confirm('Please click OK to change. Otherwise click CANCEL?';") but it will not postback regardless of the confirm result and the value in the list does not revert back if cancel selected. </p> <p>When I remove the onchange attribute from the DropdownList tag, the page does postback. It does not when the onchange attribute is added. Do I still need to wire the event handler (I'm on C# .Net 2.0 ).</p> <p>Any leads will be helpful.</p> <p>Thanks!</p>
<p>Have you tried to set the onChange event to a javascript function and then inside the function display the javascript alert and utilize the __doPostback function if it passes?</p> <p>i.e.</p> <pre><code> drpControl.Attributes("onChange") = "DisplayConfirmation();" function DisplayConfirmation() { if (confirm('Are you sure you want to do this?')) { __doPostback('drpControl',''); } } </code></pre>
<p>Make sure your event is wired:</p> <pre><code>dropDown.SelectedIndexChanged += new EventHandler(dropDown_SelectedIndexChanged); </code></pre> <p>You can also apply a client-side attribute to return the confirmation. Set the index accordingly if cancelled.</p> <pre><code>dropDown.Attributes.Add("onchange", "javascript: return confirm('confirmation msg')"); </code></pre>
9,946
<p>We need a good CMS that supports data clustering (managing and storing data on different servers). By "good" , I mean : reliable , minimum bugs , the faster the better. (Oh , and it should make coffee :) ) </p>
<p>Yes … kitchen sink + community + support: Plone. Development heading very much in the right direction. </p> <p>Plone is in some ways a different creature from many other systems. Depending on the environment, ultra-high performance may require some attention but in the community there's great expertise to steer any attention that may be required.</p> <p><a href="http://plone.org/support" rel="nofollow noreferrer">http://plone.org/support</a> | Chat Room is a great venue for diverse and honest advice on this subject. We regularly steer people away from Plone -- when some other system will better suit their needs. </p>
<p>I am not sure about "Performance-oriented" means for you. There are sites with Drupal and Joomla that receives million of visits month after month, and do not need special configurations like data clustering.</p> <p>I think you must ask yourself if you need all you said.</p> <p>For reliability, and no bugs or minimum bugs i can stand for Joomla.</p> <p>I think the performance is a function of the hardware.</p>
9,521
<p>I´ve have read an article to change different pattern depending on amount of layers, but my question is if is possible to have different infill in the same part? For example:</p> <ul> <li>Base: has the infill of 25&nbsp;% but the same base has some tabs for screws and mount the part for this area the infill need to be 40&nbsp;% or greater.</li> <li>The walls and forms: this has the same of the whole part and can be filled at 25&nbsp;% but some areas need to be filled at 15&nbsp;% or less.</li> </ul> <p>Probably someone has seen or reviewed another software to achieve this, or I'm fooling myself.</p>
<p>This answer explains that you can have different infill within the same part. Firstly the implementation in <strong>Ultimaker Cura</strong> is described, secondly how you can do this in <strong>Slic3r</strong>.</p> <hr /> <h2>Ultimaker Cura</h2> <p>I've used a feature in <strong>Ultimaker Cura</strong> that can be used to alter the infill density locally. What you need to do is load your model into Cura, then load other objects (models) at the size of the area/volume you want your infill differently and position those at the position you want a different infill. Alternatively, you can add support blocker cubes that can be used as well. So basically, you use other models to intersect with your primary model to create intersections that can take a different infill percentage (please note that you can alter even more options, as long as you add these to the intersecting volume). This is extremely useful for lugs and brackets where you need some extra infill (e.g. extra stiffness for compression stresses) at the fastener holes. Note that this is an advanced feature which is not easy to use, but quite handy if you master it.</p> <p>I could not find the video (<em>on second thoughts, I think it was animated GIF</em>) posted by Team Ultimaker, so I quote a section of one of their forum topics.</p> <p><a href="https://community.ultimaker.com/topic/20470-infill-density-for-smaller-parts/" rel="nofollow noreferrer">A short how-to:</a> (italic font is not in the reference, but added to reflect recent version of Cura)</p> <blockquote> <ul> <li>Unselect &quot;keep models apart&quot; <em>(now called: &quot;Ensure models are kept apart&quot;)</em> and &quot;drop models to build plate&quot; <em>(now called: &quot;Automatically drop models to the build plate&quot;)</em> in Cura preferences</li> <li>Import a second object (for example a simple cube)</li> <li>Put Cura in &quot;custom mode&quot;</li> <li>Select the cube, and use the button &quot;per object settings&quot; on the left side</li> <li>Select &quot;Infill Mesh&quot; <em>(now called: &quot;Modify settings for infill of other models&quot;)</em> and enable that setting</li> <li>The cube now turns transparent gray.</li> <li>Position the cube to overlap part of your model. It should overlap with the section that you want to change the infill for.</li> <li>Also with &quot;per object settings&quot; <em>(now called: &quot;Per model settings&quot;)</em> select the option &quot;infill density&quot;</li> <li>Set it to the desired value. All is more or less illustrated in the screenshot below</li> <li>The picture shows a cube on the buildplate with infill 20 %. Locally, with a rotated 2nd cube, the infill % is raised to 100 %.</li> <li>What happens is that the volume where the cube intersects with your object is locally sliced with different infill.</li> </ul> <p><a href="https://i.stack.imgur.com/oIjIj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIjIj.png" alt="Example of a cube with different infill settings" /></a></p> </blockquote> <p>Please find below another example of a simple bracket that has extra cylindrical objects loaded to create the intersections with the bracket at the fastener holes. In the <a href="https://community.ultimaker.com/topic/20470-infill-density-for-smaller-parts/?do=findComment&amp;comment=193146" rel="nofollow noreferrer">example</a>, the infill at the fastener holes is set to 99 %.</p> <blockquote> <p><a href="https://i.stack.imgur.com/MqSpA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MqSpA.png" alt="Example of local 99 % infill at bracket fastener holes" /></a></p> </blockquote> <p>After slicing, you will see that the infill at the intersections is adjusted accordingly.</p> <blockquote> <p><a href="https://i.stack.imgur.com/v9guy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v9guy.png" alt="Detail of sliced bracket showing local infill percentage" /></a></p> </blockquote> <p><strong>Note:</strong> I've tested this in Ultimaker Cura 3.4.1, and confirm it works. I sliced a part with the inserts for fasteners and it actually is not very difficult, it just requires a little more work. You will have to make some STL's of cylinders and position them correctly. If you make your own 3D models it will be a very easy task to add extra components while you design, positioning will be a lot more easy then (as they align with your model). An example is the following linear <a href="https://www.thingiverse.com/thing:4441751/files" rel="nofollow noreferrer">Z rod bracket of a Hypercube Evolution CoreXY printer</a>, this bracket requires local reinforcements for the bolts clamping the bracket onto the aluminum extrusion profile:</p> <p><a href="https://i.stack.imgur.com/zVlF1.png" rel="nofollow noreferrer" title="Hypercube Evolution Z rod bracket"><img src="https://i.stack.imgur.com/zVlF1.png" alt="enter image description here" title="Hypercube Evolution Z rod bracket" /></a></p> <p>Inserts are modeled together with the development of the bracket:</p> <p><a href="https://i.stack.imgur.com/w8XlM.png" rel="nofollow noreferrer" title="Hypercube Evolution Z rod bracket insert"><img src="https://i.stack.imgur.com/w8XlM.png" alt="enter image description here" title="Hypercube Evolution Z rod bracket insert" /></a></p> <p>When combined, it looks like this:</p> <p><a href="https://i.stack.imgur.com/qJszQ.png" rel="nofollow noreferrer" title="Hypercube Evolution Z rod bracket and bracket insert"><img src="https://i.stack.imgur.com/qJszQ.png" alt="enter image description here" title="Hypercube Evolution Z rod bracket and bracket insert" /></a></p> <p>Now the infill can be modified locally to 100 % to increase compression strength.</p> <p>Note that this will also work if you want a different infill percentage at the first X layers, just use a large cube (larger than the model) and position it correctly. Note that Cura already has an option called &quot;Gradual Infill Steps&quot; to adjust the density at the top layers.</p> <hr /> <h2>Slic3r</h2> <p><a href="http://manual.slic3r.org/advanced/modifier-mesh" rel="nofollow noreferrer">This reference</a> describes how to do this for <strong>Slic3r</strong> in detail.</p> <p>The blog describes the use of a simple volume (the green volume loaded from an STL file). After loading:</p> <blockquote> <p>Right-clicking on the main part brought up the object settings menu. From there, clicking &quot;Load Modifier&quot; and selecting the previously saved model adds it to the part as a modifier.</p> <p>The green &quot;+&quot; was selected and &quot;Fill Density&quot; was added to modifier list and set to 100 %.</p> </blockquote> <p><a href="https://i.stack.imgur.com/llvIG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/llvIG.jpg" alt="Part with box for alternative mesh infill" /></a></p> <p><a href="https://i.stack.imgur.com/EslBH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EslBH.jpg" alt="enter image description here" /></a> This shows that the functionality in Slic3r is very similar to the functionality in Ultimaker Cura.</p>
<p>Yes, it's possible, and not just limited to Cura. If you use GrabCAD Print (for Stratasys printers), the <em>Advanced FDM</em> feature allows different infill in different regions of your part - not based on layers, but based on your CAD geometry. Because of this, you have to start the process in CAD, by creating a part with multiple bodies. (For example, in Solidworks, you do this by turning off "merge" when you add a second boss, or by making a cut from a sketch and turning on "keep both parts".)</p> <p>Once you've done this, go into the <em>Advanced FDM</em> tab in GrabCAD Print, and add your CAD part (the CAD file itself, not an STL). The two or more bodies in your part will be shown separately in the project panel: select them all and choose "merge". Now they will all be printed as a single part, but you can select each one and give them different infill settings.</p> <p>You can also select any CAD face (i.e. not individual triangles) and override its wall thickness.</p> <p>You can read a <a href="https://help.grabcad.com/article/245-advanced-fdm" rel="nofollow noreferrer">full tutorial about Advanced FDM</a> on the GrabCAD website.</p>
980
<p>I am trying to print a wing for a rc plane with my 3D printer. In order to make the wing as light as possible I need to hollow it (and afterwards put some stable structure there). I've tried the Blender Solidify modifier to do this but without success. The material on the sharp edge on the rear part of the wing gets thinner and thinner although the "Even Thickness" option is checked (see picture). When preparing this for printing, the slicer puts only one line of filament there instead of two. What I need is a brim on the inner side of the stl file with a constant spacing.</p> <p><a href="https://i.stack.imgur.com/XUo9C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XUo9C.png" alt="Blender Solidify problem"></a></p> <p>I've also tried the Meshmixer Hollow and Extrude modifiers. They both had problems with those sharp edges (see picture).</p> <p><a href="https://i.stack.imgur.com/wPNym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wPNym.png" alt="meshmixer hollow problem"></a></p> <p>The third program I've tested was FreeCAD. But it crashed at all :-(</p> <p>Can someone please help me? I would appreciate any suggestion or other programs which can handle this problem. Remodeling is no option for me as I have even more complex objects to hollow for example the fuselage.</p> <p>The stl file of the wing can be found here: <a href="https://files.fm/u/5futezwj" rel="nofollow noreferrer">https://files.fm/u/5futezwj</a></p> <p>Thanks so much for your help!</p>
<p>I am sorry to inform you, that the answer to "How do I fix the thickness" is "Remodel them" - especially in this case as the whole design is... awkward.</p> <p>But you don't necessarily need to resign them from scratch, if you can fix it... But beware, fixing does only work <strong>sometimes</strong>...</p> <p>First of all, <strong>Blender is NOT a good modeling software for designing parts that shall be printed</strong>, Blender is a 3D Artist program, not a CAD program. It can serve its course, but it can and will ruin your day. I suggest grabbing <a href="https://www.autodesk.com/products/fusion-360/overview" rel="nofollow noreferrer">Autodesk Fusion 360</a>, since it is mighty and free for small makers.</p> <h1>Step 1: Transfer into CAD software</h1> <p>For our first step, we want to take the surface of the Wing and export it as an STL. To do this, remove all interior vertices. ALL. Save as a work-project. Look for "BAD" areas - try to have as little vertices as possible. If several are in the same flat area feel free to remove some. The simpler, the better - compare these two pictures - left the bad side, right the good.</p> <p><a href="https://i.stack.imgur.com/IxrNM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IxrNM.png" alt="Bad side, unneeded vertices and faces"></a><a href="https://i.stack.imgur.com/DjNE9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DjNE9.png" alt="good side, jsut functional ones"></a></p> <p>Export via <code>File &gt; Export &gt; .stl</code>.</p> <p>Open Fusion 360 and import via the process outlined <a href="https://knowledge.autodesk.com/support/fusion-360/troubleshooting/caas/sfdcarticles/sfdcarticles/How-to-insert-a-mesh-body-into-Fusion-360.html" rel="nofollow noreferrer">here</a>: <code>Insert &gt; Mesh</code>.</p> <p>Now we need to turn our Mesh into a BRep like described <a href="https://knowledge.autodesk.com/support/fusion-360/learn-explore/caas/sfdcarticles/sfdcarticles/How-to-Convert-a-Mesh-to-a-BRep-in-Fusion-360.html" rel="nofollow noreferrer">here</a>: </p> <ul> <li>Deactivate the pickup of model history by right-clicking the project in the left, then "Don't capture design history"</li> <li><code>Modify &gt; Mesh &gt; Mesh tp BRep</code></li> <li>choose your object and <code>OK</code></li> <li>reactivate the model history by right-clicking the project in the left, then "Don't capture design history"</li> </ul> <h1>Step 2: assigning Thickness</h1> <p>We got a surface now... or rather several that are stitched together. We want to give them thickness...</p> <ul> <li><code>create &gt; thicken</code></li> <li>click on one area, choose the thickness as a negative value. For example <code>-1 mm</code></li> <li>click on the body's lightbulb to make it visible again</li> <li>rinse and repeat for each area not yet thickened <ul> <li>Hint: <code>rightclick</code> opens a context menu that offers <code>repeat ...</code>, where ... is the last used operation, in this case: thicken. This considerably can speed it up.</li> </ul></li> </ul> <h1>Step 3: Combining thickened parts</h1> <p>Now, we have several thickened parts, all of them intersecting or touching. like, what usually looks like this...</p> <p><a href="https://i.stack.imgur.com/Bagjv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bagjv.png" alt="a part"></a></p> <p>actually is these different parts (which I colored for showing only - it is totally unnecessary!) <a href="https://i.stack.imgur.com/leVVI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/leVVI.png" alt="showing which is which"></a></p> <p>It's easy to see these all intersect. And luckily, intersecting parts can be easily merged! </p> <ul> <li><code>Modify &gt; Combine</code></li> <li>click one, then another. OK.</li> <li>rinse and repeat as much as you can - some pieces will throw an "inconsistent edge-face-relationship" error. If these crop up, you need to start over, fixing the Mesh.</li> </ul> <p><a href="https://i.stack.imgur.com/0s1sX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0s1sX.png" alt="After a little fixup - 2 parts remaining"></a></p> <p>To state it clear after wasting 2 hours on this:</p> <h1>Your files needs to be done again from scratch.</h1> <p>In a proper CAD modeling software. Because what you have there is not fixable easily.</p>
<p>Don't design your part as hollow. Make it solid. Then put it in the slicer and chose the infill (i recomment cubic pattern in cura) you want. So you have a mainly hollow wing with a nice structure in it. </p>
1,079
<p>I am coming from an Enterprise Java background which involves a fairly heavyweight software stack, and have recently discovered the <a href="http://www.stripesframework.org/" rel="noreferrer">Stripes framework</a>; my initial impression is that this seems to do a good job of minimising the unpleasant parts of building a web application in Java.</p> <p>Has anyone used Stripes for a project that has gone live? And can you share your experiences from the project? Also, did you consider any other technologies and (if so) why did you chose Stripes?</p>
<p>We've been using Stripes for about 4 years now. Our stack is Stripes/EJB3/JPA.</p> <p>Many use Stripes plus Stripernate as a single, full stack solution. We don't because we want our business logic within the EJB tier, so we simply rely on JPA Entities as combined Model and DTO.</p> <p>Stripes does the binding to our Entities/DTO and we shove them back in to the EJB tier for work. For most of our CRUD stuff this is very thing and straightforward, making our 80% use case trivial to work with. Yet we have the flexibility to do whatever we want for the edge cases that always come up with complicate applications.</p> <p>We have a very large base Action Bean which encapsulates the bulk of our CRUD operations that makes call backs in to the individual subclasses specific to the entities and forms.</p> <p>We also have a large internal tag file library to manage our pages, security, navigation, tasks, etc. A simple CRUD edit form is little more than a list of field names, and we get all of the chrome and menus and access controls "for free".</p> <p>The beauty of this is that we get to keep the HTTP request based metaphor that we like and we get to choose the individual parts of the system rather than use one fat stack. The Stripes layer is lean and mean, and never gets in our way.</p> <p>We have a bunch of Ajax integrating YUI and JQuery, all working against our Stripes and EJB stack painlessly.</p> <p>I also ported a lighter version of the stack to GAE for a sample project, basically having to do minor work to our EJB tier. So, the entire stack is very nimble and amicable to change. Stripes is a big factor of that since we let it do the few things that it does, and does very well. Then delegate the rest to other parts of the stack.</p> <p>As always there are parts folks would rather have different at times, but Stripes would be the last part to go in our stack, frankly. It could be better at supporting the full HTTP verb set, but I'd rather fix Stripes to do that better than switch over to something else.</p>
<p>Stripes is yesterdays technology, if you can pick something a little more modern like GWT.</p>
6,984
<p>How do I page results in SQL Server 2005?</p> <p>I tried it in SQL Server 2000, but there was no reliable way to do this. I'm now wondering if SQL Server 2005 has any built in method?</p> <p>What I mean by paging is, for example, if I list users by their username, I want to be able to only return the first 10 records, then the next 10 records and so on.</p> <p>Any help would be much appreciated.</p>
<p>You can use <code>the Row_Number()</code> function. Its used as follows:</p> <pre><code>SELECT Row_Number() OVER(ORDER BY UserName) As RowID, UserFirstName, UserLastName FROM Users </code></pre> <p>From which it will yield a result set with a <code>RowID</code> field which you can use to page between.</p> <pre><code>SELECT * FROM ( SELECT Row_Number() OVER(ORDER BY UserName) As RowID, UserFirstName, UserLastName FROM Users ) As RowResults WHERE RowID Between 5 AND 10 </code></pre> <p>etc</p>
<p>I believe you'd need to perform a separate query to accomplish that unfortionately.</p> <p>I was able to accomplish this at my previous position using some help from this page: <a href="https://web.archive.org/web/20210510021915/http://aspnet.4guysfromrolla.com/articles/031506-1.aspx" rel="nofollow noreferrer">Paging in DotNet 2.0</a></p> <p>They also have it pulling a row count seperately.</p>
2,498
<p>I've been using <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="nofollow noreferrer">Subversion</a> for a few years and after using <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_SourceSafe" rel="nofollow noreferrer">SourceSafe</a>, I just love Subversion. Combined with <a href="http://en.wikipedia.org/wiki/TortoiseSVN" rel="nofollow noreferrer">TortoiseSVN</a>, I can't really imagine how it could be any better. </p> <p>Yet there's a growing number of developers claiming that Subversion has problems and that we should be moving to the new breed of distributed version control systems, such as <a href="http://git.or.cz/" rel="nofollow noreferrer" title="Git Distributed Version Control System">Git</a>. </p> <p>How does Git improve upon Subversion?</p>
<p>Git is not better than Subversion. But is also not worse. It's different.</p> <p>The key difference is that it is decentralized. Imagine you are a developer on the road, you develop on your laptop and you want to have source control so that you can go back 3 hours.</p> <p>With Subversion, you have a Problem: The SVN Repository may be in a location you can't reach (in your company, and you don't have internet at the moment), you cannot commit. If you want to make a copy of your code, you have to literally copy/paste it.</p> <p>With Git, you do not have this problem. Your local copy is a repository, and you can commit to it and get all benefits of source control. When you regain connectivity to the main repository, you can commit against it.</p> <p>This looks good at first, but just keep in mind the added complexity to this approach.</p> <p>Git seems to be the "new, shiny, cool" thing. It's by no means bad (there is a reason Linus wrote it for the Linux Kernel development after all), but I feel that many people jump on the "Distributed Source Control" train just because it's new and is written by Linus Torvalds, without actually knowing why/if it's better.</p> <p>Subversion has Problems, but so does Git, Mercurial, CVS, TFS or whatever.</p> <p><strong>Edit:</strong> So this answer is now a year old and still generates many upvotes, so I thought I'll add some more explanations. In the last year since writing this, Git has gained a lot of momentum and support, particularly since sites like GitHub really took off. I'm using both Git and Subversion nowadays and I'd like to share some personal insight.</p> <p>First of all, Git can be really confusing at first when working decentralized. What is a remote? and How to properly set up the initial repository? are two questions that come up at the beginning, especially compared to SVN's simple "svnadmin create", Git's "git init" can take the parameters --bare and --shared which seems to be the "proper" way to set up a centralized repository. There are reasons for this, but it adds complexity. The documentation of the "checkout" command is very confusing to people changing over - the "proper" way seems to be "git clone", while "git checkout" seems to switch branches.</p> <p>Git REALLY shines when you are decentralized. I have a server at home and a Laptop on the road, and SVN simply doesn't work well here. With SVN, I can't have local source control if I'm not connected to the repository (Yes, I know about SVK or about ways to copy the repo). With Git, that's the default mode anyway. It's an extra command though (git commit commits locally, whereas git push origin master pushes the master branch to the remote named "origin").</p> <p>As said above: Git adds complexity. Two modes of creating repositories, checkout vs. clone, commit vs. push... You have to know which commands work locally and which work with "the server" (I'm assuming most people still like a central "master-repository").</p> <p>Also, the tooling is still insufficient, at least on Windows. Yes, there is a Visual Studio AddIn, but I still use git bash with msysgit.</p> <p>SVN has the advantage that it's MUCH simpler to learn: There is your repository, all changes to towards it, if you know how to create, commit and checkout and you're ready to go and can pickup stuff like branching, update etc. later on.</p> <p>Git has the advantage that it's MUCH better suited if some developers are not always connected to the master repository. Also, it's much faster than SVN. And from what I hear, branching and merging support is a lot better (which is to be expected, as these are the core reasons it was written).</p> <p>This also explains why it gains so much buzz on the Internet, as Git is perfectly suited for Open Source projects: Just Fork it, commit your changes to your own Fork, and then ask the original project maintainer to pull your changes. With Git, this just works. Really, try it on Github, it's magic.</p> <p>What I also see are Git-SVN Bridges: The central repository is a Subversion repo, but developers locally work with Git and the bridge then pushes their changes to SVN.</p> <p>But even with this lengthy addition, I still stand by my core message: Git is not better or worse, it's just different. If you have the need for "Offline Source Control" and the willingness to spend some extra time learning it, it's fantastic. But if you have a strictly centralized Source Control and/or are struggling to introduce Source Control in the first place because your co-workers are not interested, then the simplicity and excellent tooling (at least on Windows) of SVN shine.</p>
<p>First, concurrent version control seems like an easy problem to solve. It's not at all. Anyway...</p> <p>SVN is quite non-intuitive. Git is even worse. [sarcastic-speculation] This might be because developers, that like hard problems like concurrent version control, don't have much interest in making a good UI. [/sarcastic-speculation]</p> <p>SVN supporters think they don't need a distributed version-control system. <strong>I thought that too.</strong> But now that we use Git exclusively, I'm a believer. Now version control works for me AND the team/project instead of just working for the project. When I need a branch, I branch. Sometimes it's a branch that has a corresponding branch on the server, and sometimes it does not. Not to mention all the other advantages that I'll have to go study up on (thanks in part to the arcane and absurd lack of UI that is a modern version control system).</p>
2,330
<p>Had an interesting discussion with some colleagues about the best scheduling strategies for realtime tasks, but not everyone had a good understanding of the common or useful scheduling strategies.</p> <p>For your answer, please choose one strategy and go over it in some detail, rather than giving a little info on several strategies. If you have something to add to someone else's description and it's short, add a comment rather than a new answer (if it's long or useful, or simply a much better description, then please use an answer)</p> <ul> <li>What is the strategy - describe the general case (assume people know what a task queue is, semaphores, locks, and other OS fundamentals outside the scheduler itself)</li> <li>What is this strategy optimized for (task latency, efficiency, realtime, jitter, resource sharing, etc)</li> <li>Is it realtime, or can it be made realtime</li> </ul> <p>Current strategies:</p> <ul> <li><a href="https://stackoverflow.com/questions/49962/task-schedulers#74894">Priority Based Preemptive</a></li> <li><a href="https://stackoverflow.com/questions/49962/task-schedulers#50056">Lowest power slowest clock</a></li> </ul> <p>-Adam</p>
<p>As described in a paper titled <a href="http://www.ee.duke.edu/~krish/wip.pdf" rel="noreferrer">Real-Time Task Scheduling for Energy-Aware Embedded Systems</a>, Swaminathan and Chakrabarty describe the challenges of real-time task scheduling in low-power (embedded) devices with multiple processor speeds and power consumption profiles available. The scheduling algorithm they outline (and is shown to be only about 1% worse than an optimal solution in tests) has an interesting way of scheduling tasks they call the LEDF Heuristic.</p> <p>From the paper:</p> <blockquote> <p><em>The low-energy earliest deadline first heuristic, or simply LEDF, is an extension of the well-known earliest deadline first (EDF) algorithm. The operation of LEDF is as follows: LEDF maintains a list of all released tasks, called the “ready list”. When tasks are released, the task with the nearest deadline is chosen to be executed. A check is performed to see if the task deadline can be met by executing it at the lower voltage (speed). If the deadline can be met, LEDF assigns the lower voltage to the task and the task begins execution. During the task’s execution, other tasks may enter the system. These tasks are assumed to be placed automatically on the “ready list”. LEDF again selects the task with the nearest deadline to be executed. As long as there are tasks waiting to be executed, LEDF does not keep the pro- cessor idle. This process is repeated until all the tasks have been scheduled.</em></p> </blockquote> <p>And in pseudo-code:</p> <pre><code>Repeat forever { if tasks are waiting to be scheduled { Sort deadlines in ascending order Schedule task with earliest deadline Check if deadline can be met at lower speed (voltage) If deadline can be met, schedule task to execute at lower voltage (speed) If deadline cannot be met, check if deadline can be met at higher speed (voltage) If deadline can be met, schedule task to execute at higher voltage (speed) If deadline cannot be met, task cannot be scheduled: run the exception handler! } } </code></pre> <p>It seems that real-time scheduling is an interesting and evolving problem as small, low-power devices become more ubiquitous. I think this is an area in which we'll see plenty of further research and I look forward to keeping abreast!</p>
<p>One common real-time scheduling scheme is to use priority-based preemptive multitasking.<br> Each tasks is assigned a different priority level.<br> The highest priority task on the ready queue will be the task that runs. It will run until it either gives up the CPU (i.e. delays, waits on a semaphore, etc...) or a higher priority task becomes ready to run.</p> <p>The advantage of this scheme is that the system designer has full control over what tasks will run at what priority. The scheduling algorithm is also simple and should be deterministic.</p> <p>On the other hand, low priority tasks might be starved for CPU. This would indicate a design problem. </p>
7,258
<p>I'm working on VS 2005 and something has gone wrong on my machine. Suddenly, out of the blue, I can no longer build deployment files. The build message is:</p> <pre><code>ERROR: An error occurred generating a bootstrapper: Invalid syntax. ERROR: General failure building bootstrapper ERROR: Unrecoverable build error </code></pre> <p>A quick Google search brings up the last 2 lines, but nobody in cyberspace has ever reported the first message before. (Hooray! I'm first at SOMETHING on the 'net!)</p> <p>Other machines in my office are able to do the build. My machine has been able to do the build before. I have no idea what changed that upset the delicate balance of things on my box. I have also tried all the traditional rituals i.e. closing Visual Studio, blowing away all the bin and obj folders, rebooting, etc. to no avail.</p> <p>For simplicity's sake, I created a little "Hello World" app with a deployment file. Herewith the build output:</p> <pre><code>------ Build started: Project: HelloWorld, Configuration: Debug Any CPU ------ HelloWorld -&gt; C:\Vault\Multi Client\Tests\HelloWorld\HelloWorld\bin\Debug\HelloWorld.exe ------ Starting pre-build validation for project 'HelloWorldSetup' ------ ------ Pre-build validation for project 'HelloWorldSetup' completed ------ ------ Build started: Project: HelloWorldSetup, Configuration: Debug ------ Building file 'C:\Vault\Multi Client\Tests\HelloWorld\HelloWorldSetup\Debug\HelloWorldSetup.msi'... ERROR: An error occurred generating a bootstrapper: Invalid syntax. ERROR: General failure building bootstrapper ERROR: Unrecoverable build error ========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ========== </code></pre> <p>I am using:</p> <ul> <li>MS Visual Studio 2005 Version 8.0.50727.762 (SP .050727-7600) </li> <li>.NET Framework Version 2.0.50727 </li> <li>OS: Windows XP Pro</li> </ul> <p>Again, I have no idea what changed. All I know is that one day everything was working fine; the next day I suddenly can't do any deployment builds at all (though all other projects still compile fine).</p> <p>I posted <a href="http://social.msdn.microsoft.com/forums/en-US/vssetup/thread/240c82e9-1696-4618-846c-aaae21427a52/" rel="nofollow noreferrer">this on MSDN</a> about a month ago, and they don't seem to know what's going on, either.</p> <p>Anyone have any idea what this is about?</p> <hr> <p>@Brad Wilson: Thanks, but if you read my original post, you'll see that I already did start an entire solution from scratch, and that didn't help.</p> <hr> <p>@deemer: I went through all the pain of uninstalling and reinstalling, even though I didn't have your recommended reading while waiting... and - Misery! - still the same error reappears. It seems that my computer has somehow been branded as unsuitable for doing deployment builds ever again.</p> <p>Does anyone have any idea where this "secret switch" might be?</p>
<p><strong>SOLUTION!</strong><br> Thanks to Michael Bleifer of Microsoft support - I installed .NET 2.0 SP1, and the problem was solved!</p>
<p>If it doesn't build only on the one machine, then either you've managed to make that machine different, or the VS2005 install is corrupted. If you take the error message at face-value, then the problem is probably the latter. Try running the repair feature of the VS2005 installer, or failing that, reinstall VS2005. Ender's Game is a good book to read while you're waiting :-|.</p>
9,517
<p>I'm trying to check, using an automated discovery tool, when JAR files in remote J2EE application servers have changed content. Currently, the system downloads the whole JAR using WMI to checksum it locally, which is slow for large JARs.</p> <p>For UNIXy servers (and Windows servers with Cygwin), I can just log in over SSH and run <code>md5sum foo.jar</code>. Ideally, I'd like to avoid installing extra software on the remote servers (there may be thousands), so is there a good way to do this on vanilla Windows servers?</p>
<p>I'd imagine its one of:</p> <ul> <li><p>Eclipse doesn't want to display non-C++ resources in the tree (I've had problems with this)</p></li> <li><p>You don't have "Preferences > C/C++ > Indexer > Index All Files" enabled.</p></li> <li><p>You want to use the "Full C/C++ Indexer" rather than the "Fast C/C++ Indexer"</p></li> </ul>
<p>The CDT parser/indexer won't recognize weird extensions like that. The only thing you can do is to define macros on the Paths and Symbols property page to trick the parser. Try creating macros for <code>$hdr</code>, <code>$end</code> and <code>$src</code> that have empty bodies. That way the preprocessor will remove them and the parser won't choke on them.</p>
8,295
<p>Context: I have absolutely no knowledge of 3D printing other than you need a computer, a printer, some software, and a design. That is literally the extent of my knowledge on 3D printing.</p> <p>However, I have an idea of something I'd like to have 3D printed. While the idea has a fairly reasonably defined shape in mind, it doesn't exist in any digital or paper format and has some specifics that still need to be filled out (such as accurate dimensions and a few design details).</p> <p>I need to bridge the chasm of knowledge between my current design and limited knowledge to a fleshed-out design file with chosen materials and other specifics. A good chunk of my problem is that I don't even know <em>what</em> I should know. While I realize that this site is still fairly new and things are being nailed down, how do I ask the proper question(s) to fill in my knowledge gaps that will be on-topic for the site? Is there even a path forward for these kinds of questions on the site?</p>
<p><s>There is a <a href="https://3dprinting.meta.stackexchange.com/questions/138/what-is-our-scope">new question on Meta</a> that should help define what is okay on this site. </s></p> <p>However, your question is important to address here.</p> <p>Ultimately, you shouldn't be afraid to go ahead and ask the question. If the question does not meet the conditions of the present site, the general public will be sure to let you know and (hopefully) help direct you in at least asking a more direct question.</p> <p>If you post a question that is closed, it would acceptable to post a question here on Meta that specifically asks how to make your question fit within the scope of the site.</p> <p>I would suggest providing as much information as you have and feel free to ask the more general questions about 3D printing. Most people in the community will ask specific questions to try and help you. Some may even be able to fill in the blanks of what you're asking and provide you with very helpful answers.</p>
<p>I think your situation fits for many new users on this site, and saying that "easy" or "semi-defined" questions are discouraged would probably turn you - and many others - away from the site.</p> <p>Rather, I believe it is the community's job to help you find a proper scope for your question. As long as you follow it up, edit and improve your questions according to feedback (as we all should), I'm pretty sure even the "easiest" question will turn out good.</p> <p>In other words: ask anyway and stay open to (or even better, request) feedback to help define your question better. </p>
27
<p>We have a requirement to increase the functionality of a grid we are using to edit on our webapp, and our manager keeps citing Excel as the perfect example for a data grid :/ He still doesn't really get that a Spreadsheet like control doesn't exist out of the box, but I thought I'd do a bit of searching nonetheless.</p> <p>I've found a couple of products on Google, but was wondering if anyone else has any feedback around any such controls (obviously the cheaper or <em>ahem</em> freer the better)</p> <p><strong>EDIT</strong> We do currently have the Telerik controls, but what the 'current' requirement is, is a control that can copy and paste (e.g) 3 cells from one row and paste them on another, the row by row editing of Telerik doesn't really cut it. We are currently in competition with an 'Excel' based solution, which is always a nightmare in winning users around, who always prefer flexibility to structure</p>
<p>Update: with Silverlight fast approaching, maybe you can use a real excel control.</p> <p><a href="http://www.devexpress.com/Products/NET/Controls/ASP/Grid/" rel="nofollow noreferrer">Devexpress</a> has a powerful grid control for both web and windows. It is not free and I guess nothing really matches Excel. But once the users started using it, they wanted every app with it. Check these <a href="http://www.devexpress.com/Products/NET/Controls/ASP/Grid/quickstart.xml" rel="nofollow noreferrer">videos</a> especially the data grouping one.</p>
<p>This may not be directly related to your question, but on the server side have you considered what operations you will need to perform that will mimic Excel? You may want to check out <a href="http://www.spreadsheetgear.com/" rel="nofollow noreferrer">SpreadsheetGear</a> which will give you complete macro functionality. </p> <p>They have new charting features that I haven't used yet, but they are supposed to work with Asp.net.</p>
8,265
<p>Can I write a plug in for Microsoft SQL Enterprise Manager which changes the query window background if the query window points to a production database?</p>
<p>No, Enterprise Manager doesn't have a plug-in framework for you to hook in to.</p>
<p>I see this has already been answered but I'm going to add this in case it helps future readers. The Enterprise Manager has been replaced by SQL Management Studio. Management Studio does have support for add-ins. Also, when you register a server in the properties window you can associate a custom color with the connection. Whenever you open a query window, the status bar along the bottom of the window will be this color. We have an Access database that contains information about the systems we support, including SQL Server and database names. I wrote a SQL Powershell script that registers all of the servers and sets their custom color to Green, Yellow, and Red for Development, Acceptance, and Production. It doesn't change the entire query window color but it might be useful to you.</p>
8,951
<p>I'm trying to find a way to list the (static) dependency requirements of a jar file, in terms of which symbols are required at run time.</p> <p>I can see that the methods exported by classes can be listed using "javap", but there doesn't seem to be an opposite facility to list the 'imports'. Is it possible to do this?</p> <p>This would be similar to the dumpbin utility in Windows development which can be used to list the exports and imports of a DLL.</p> <p>EDIT : Thanks for the responses; I checked out all of the suggestions; accepted DependencyFinder as it most closely meets what I was looking for.</p>
<p>You could use the <a href="http://depfind.sourceforge.net/Manual.html#ShowingOnlyOutboundDependencies" rel="nofollow noreferrer">Outbound dependencies</a> feature of <a href="http://depfind.sourceforge.net/" rel="nofollow noreferrer">DependencyFinder</a>. You can do that entirely in the GUI, or in command line exporting XML.</p>
<p>There's a tool called <a href="http://www.kirkk.com/main/Main/JarAnalyzer" rel="nofollow noreferrer">JarAnalyzer</a> that will give you the dependencies between the jars in a directory. It'll also give you a list of dependencies that don't exist in the directory.</p>
4,815
<p>After the suggestion to use a library for <a href="https://stackoverflow.com/questions/34486/what-more-is-needed-for-ajax-than-this-function">my ajax needs</a> I am going to use one, the problem is that there are so many and I've no idea how to even begin telling them apart.</p> <p>Thus, can anybody <br /> A) Give a rundown of the differences or <br /> B) Point me (and others like me) somewhere that has such a list. <br /><br />Failing that plan C is to go with whichever gets mentioned the most here.</p>
<p>To answer B:</p> <p><a href="http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks" rel="noreferrer"><strong>Comparison of JavaScript frameworks</strong></a></p> <hr> <p><strong>EDIT:</strong> Although everyone and their mom is apparently riding the <a href="http://jquery.com/" rel="noreferrer"><strong>jQuery</strong></a> bandwagon (I use <a href="http://www.mochikit.com" rel="noreferrer"><strong>MochiKit</strong></a>), there are many libraries which provide the same functionality - the problem set which most libraries solve (async client-server communication, DOM manipulation, etc.) is the same, and there are few that don't have what you will need to get the job done. </p> <p>The important thing to determine for yourself is whether or not a library will fit your particular style and sensibilities. Wide-spread ignorance about how <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="noreferrer"><strong>JavaScript</strong></a>, the language, actually works, coupled with the negative press resulting thereby, coupled with the now-immense popularity of jQuery leads most people down that road. Thankfully, it isn't a bad road to be on as there are a lot of travellers to keep you company when the abstractions leak and you need help. You probably can't go wrong choosing jQuery.</p>
<p>I've been using <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype</a> + <a href="http://script.aculo.us/" rel="nofollow noreferrer">Scriptaculous</a>. </p> <p>They have good API documentation and work great for me! The biggest benefits are:</p> <ul> <li>Cleans up messy javascript code</li> <li>Cross browser compatibility</li> <li>Simplifies AJAX handling</li> <li>Smooth UI effects</li> </ul>
5,550
<p>What is the best method for executing FTP commands from a SQL Server stored procedure? we currently use something like this:</p> <pre><code>EXEC master..xp_cmdshell 'ftp -n -s:d:\ftp\ftpscript.xmt 172.1.1.1' </code></pre> <p>The problem is that the command seems to succeed even if the FTP ended in error. Also, the use of <code>xp_cmdshell</code> requires special permissions and may leave room for security issues.</p>
<p>If you're running SQL 2005 you could do this in a CLR integration assembly and use the FTP classes in the System.Net namespace to build a simple FTP client.</p> <p>You'd benefit from being able to trap and handle exceptions and reduce the security risk of having to use xp_cmdshell.</p> <p>Just some thoughts.</p>
<p>If you need to do FTP from within the database, then I would go with a .NET assembly as Kevin suggested. That would provide the most control over the process, plus you would be able to log meaningful error messages to a table for reporting.</p> <p>Another option would be to write a command line app that read the database for commands to run. You could then define a scheduled task to call that command line app every minutes or whatever the polling period needed to be. That would be more secure than enabling CLR support in the database server.</p>
2,627
<p>Has anyone worked much with Microsoft's Managed Extensibility Framework (MEF)? Kinda sounds like it's trying to be all things to all people - It's an add-in manager! It's duck typing! I'm wondering if anyone has an experience with it, positive or negative.</p> <p>We're currently planning on using an generic IoC implementation ala MvcContrib for our next big project. Should we throw MEF in the mix?</p>
<p>We are not aiming for MEF to be an all-purpose IoC. The best way to think about the IoC aspects of MEF is an implementation detail. We use IoC as a pattern because it is a great way to address the problems we are looking to solve. </p> <p>MEF is focused on extensibility. When you think of MEF look at it as an investment in taking our platform forward. Our future products and the platform will leverage MEF as a standard mechanism for adding extensibility. Third-party products and frameworks will also be able to leverage this same mechanism. The average "user" of MEF will author components that MEF will consume and will not be directly consuming MEF within their applications.</p> <p>Imagine when you want to extend our platform in the future, you drop a dll in the bin folder and you are done. The MEF enabled app lights up with the new extension. That's the vision for MEF.</p>
<p>More detailed discussion on this in this post and the comments</p> <p><a href="http://mikehadlow.blogspot.com/2008/09/managed-extensibility-framework-why.html" rel="nofollow noreferrer">http://mikehadlow.blogspot.com/2008/09/managed-extensibility-framework-why.html</a> </p>
6,369
<p>How can I left-align the numbers in an ordered list?</p> <pre><code>1. an item // skip some items for brevity 9. another item 10. notice the 1 is under the 9, and the item contents also line up </code></pre> <p>Change the character after the number in an ordered list?</p> <pre><code>1) an item </code></pre> <p>Also is there a CSS solution to change from numbers to alphabetic/roman lists instead of using the type attribute on the ol element.</p> <p>I am mostly interested in answers that work on Firefox 3.</p>
<p>This is the solution I have working in Firefox 3, Opera and Google Chrome. The list still displays in IE7 (but without the close bracket and left align numbers):</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>ol { counter-reset: item; margin-left: 0; padding-left: 0; } li { display: block; margin-bottom: .5em; margin-left: 2em; } li::before { display: inline-block; content: counter(item) ") "; counter-increment: item; width: 2em; margin-left: -2em; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ol&gt; &lt;li&gt;One&lt;/li&gt; &lt;li&gt;Two&lt;/li&gt; &lt;li&gt;Three&lt;/li&gt; &lt;li&gt;Four&lt;/li&gt; &lt;li&gt;Five&lt;/li&gt; &lt;li&gt;Six&lt;/li&gt; &lt;li&gt;Seven&lt;/li&gt; &lt;li&gt;Eight&lt;/li&gt; &lt;li&gt;Nine&lt;br&gt;Items&lt;/li&gt; &lt;li&gt;Ten&lt;br&gt;Items&lt;/li&gt; &lt;/ol&gt;</code></pre> </div> </div> </p> <p><strong>EDIT:</strong> Included multiple line fix by strager</p> <blockquote> <p>Also is there a CSS solution to change from numbers to alphabetic/roman lists instead of using the type attribute on the ol element.</p> </blockquote> <p>Refer to <a href="http://www.w3.org/TR/CSS2/generate.html#lists" rel="noreferrer">list-style-type</a> CSS property. Or when using counters the second argument accepts a list-style-type value. For example the following will use upper roman:</p> <pre><code>li::before { content: counter(item, upper-roman) ") "; counter-increment: item; /* ... */ </code></pre>
<p>I have it. Try the following:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type='text/css'&gt; ol { counter-reset: item; } li { display: block; } li:before { content: counter(item) ")"; counter-increment: item; display: inline-block; width: 50px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;ol&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;li&gt;Something&lt;/li&gt; &lt;/ol&gt; &lt;/body&gt; </code></pre> <p>The catch is that this <em>definitely</em> won't work on older or less compliant browsers: <code>display: inline-block</code> is a very new property.</p>
3,206
<p>How do I use JUnit to test a class that has internal private methods, fields or nested classes?</p> <p>It seems bad to change the access modifier for a method just to be able to run a test.</p>
<p>If you have somewhat of a legacy <strong>Java</strong> application, and you're not allowed to change the visibility of your methods, the best way to test private methods is to use <a href="http://en.wikipedia.org/wiki/Reflection_%28computer_programming%29" rel="noreferrer">reflection</a>.</p> <p>Internally we're using helpers to get/set <code>private</code> and <code>private static</code> variables as well as invoke <code>private</code> and <code>private static</code> methods. The following patterns will let you do pretty much anything related to the private methods and fields. Of course, you can't change <code>private static final</code> variables through reflection.</p> <pre><code>Method method = TargetClass.getDeclaredMethod(methodName, argClasses); method.setAccessible(true); return method.invoke(targetObject, argObjects); </code></pre> <p>And for fields:</p> <pre><code>Field field = TargetClass.getDeclaredField(fieldName); field.setAccessible(true); field.set(object, value); </code></pre> <hr /> <blockquote> <p><strong>Notes:</strong></p> <ol> <li><code>TargetClass.getDeclaredMethod(methodName, argClasses)</code> lets you look into <code>private</code> methods. The same thing applies for <code>getDeclaredField</code>.</li> <li>The <code>setAccessible(true)</code> is required to play around with privates.</li> </ol> </blockquote>
<p>In your class:</p> <pre><code>namespace my_namespace { #ifdef UNIT_TEST class test_class; #endif class my_class { public: #ifdef UNIT_TEST friend class test_class; #endif private: void fun() { cout &lt;&lt; &quot;I am private&quot; &lt;&lt; endl; } } } </code></pre> <p>In your unit test class:</p> <pre><code>#ifndef UNIT_TEST #define UNIT_TEST #endif #include &quot;my_class.h&quot; class my_namespace::test_class { public: void fun() { my_obj.fun(); } private: my_class my_obj; } void my_unit_test() { test_class test_obj; test_obj.fun(); // here you accessed the private function ;) } </code></pre>
5,487
<p>I'm interested to get a free, WYSIWYG HTML editor that is compatible with Django template. Any ideas?</p> <blockquote> <p>Thanks LainMH.</p> <p>But I afraid fckeditor is used in web app, for the purpose of editing HTML. What I want is an editor that allows me to write HTML that is Django compatible. </p> <p>Hope this clarifies the issue.</p> </blockquote>
<p><a href="http://www.fckeditor.net/" rel="noreferrer">http://www.fckeditor.net/</a> ?</p> <p>EDIT: Just found this: <a href="http://blog.newt.cz/blog/integration-fckeditor-django/" rel="noreferrer">http://blog.newt.cz/blog/integration-fckeditor-django/</a></p>
<p>According to brief Googling (no personal experience with this), Aptana now supports Python development via Pydev. Pydev again can be configured to work with Django.</p> <p>Thus I would expect Aptana to be usable with Django templates aswell, though I have no complete guide these links should be helpful :</p> <ul> <li><a href="http://www.aptana.com/python" rel="nofollow noreferrer">http://www.aptana.com/python</a></li> <li><a href="http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html" rel="nofollow noreferrer">http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html</a></li> </ul> <p>Hope this helps.</p>
8,639
<p>Is there a way to create a <code>JButton</code> with your own button graphic and not just with an image inside the button? </p> <p>If not, is there another way to create a custom <code>JButton</code> in java?</p>
<p>When I was first learning Java we had to make Yahtzee and I thought it would be cool to create custom Swing components and containers instead of just drawing everything on one <code>JPanel</code>. The benefit of extending <code>Swing</code> components, of course, is to have the ability to add support for keyboard shortcuts and other accessibility features that you can't do just by having a <code>paint()</code> method print a pretty picture. It may not be done the best way however, but it may be a good starting point for you.</p> <p>Edit 8/6 - If it wasn't apparent from the images, each Die is a button you can click. This will move it to the <code>DiceContainer</code> below. Looking at the source code you can see that each Die button is drawn dynamically, based on its value.</p> <p><img src="https://i.stack.imgur.com/pgyQp.jpg" alt="alt text"><br> <img src="https://i.stack.imgur.com/jkYRd.jpg" alt="alt text"><br> <img src="https://i.stack.imgur.com/9BI34.jpg" alt="alt text"></p> <p>Here are the basic steps:</p> <ol> <li>Create a class that extends <code>JComponent</code></li> <li>Call parent constructor <code>super()</code> in your constructors</li> <li>Make sure you class implements <code>MouseListener</code></li> <li><p>Put this in the constructor:</p> <pre><code>enableInputMethods(true); addMouseListener(this); </code></pre></li> <li><p>Override these methods:</p> <pre><code>public Dimension getPreferredSize() public Dimension getMinimumSize() public Dimension getMaximumSize() </code></pre></li> <li><p>Override this method:</p> <pre><code>public void paintComponent(Graphics g) </code></pre></li> </ol> <p>The amount of space you have to work with when drawing your button is defined by <code>getPreferredSize()</code>, assuming <code>getMinimumSize()</code> and <code>getMaximumSize()</code> return the same value. I haven't experimented too much with this but, depending on the layout you use for your GUI your button could look completely different.</p> <p>And finally, the <a href="https://github.com/kdeloach/labs/blob/master/java/yahtzee/src/Dice.java" rel="noreferrer">source code</a>. In case I missed anything. </p>
<p>I haven't done SWING development since my early CS classes but if it wasn't built in you could just inherit <code>javax.swing.AbstractButton</code> and create your own. Should be pretty simple to wire something together with their existing framework.</p>
2,436
<p>This is re-posted from something I posted on the DDD Yahoo! group.</p> <p>All things being equal, do you write phone.dial(phoneNumber) or phoneNumber.dialOn(phone)? Keep in mind possible future requirements (account numbers in addition to phone numbers, calculators in addition to phones).</p> <p>The choice tends to illustrate how the idioms of Information Expert, Single Responsibility Principle, and Tell Don't Ask are at odds with each other.</p> <p>phoneNumber.dialOn(phone) favors Information Expert and Tell Don't Ask, while phone.dial(phoneNumber) favors Single Responsibility Principle.</p> <p>If you are familiar with Ken Pugh's work in Prefactoring, this is the <a href="http://moffdub.wordpress.com/2008/09/10/the-spreadsheet-conundrum/" rel="noreferrer">Spreadsheet Conundrum</a>; do you add rows or columns?</p>
<p><code>phone.dial()</code>, because it's the phone that does the dialing.</p> <p>Actor.Verb( inputs ) -> outputs.</p>
<p>Not to be the negative one here, but these kinds of questions are very academic. It completely depends on the application. I can think of very good reasons for doing it either way, and I've seen too many good programmers get bogged down in this kind of moot design details.</p>
9,415
<p>Although I've done programming, I'm not a programmer. I've recently agreed to coordinate getting a Website up for a club. The resources are--me, who has done Web content maintenance (putting content into HTML and ColdFusion templates via a gatekeeper to the site itself; doing simple HTML and XML coding); a serious Web developer who does database programming, ColdFusion, etc., and talks way over the heads of the rest of us; two designers who use Dreamweaver; the guy who created the original (and now badly broken) site in Front Page and wants to use Expression Web; and assorted other club members who are even less technically inclined.</p> <p>What we need up first is some text and graphics (a gorgeous design has been created in Dreamweaver), some links (including to existing PDF newsletters for download), and maybe hooking up an existing Blogspot blog. Later (or earlier if it's not hard), we may add mouseover menus to the links, a gallery, a calendar, a few Mapquest hotlinks, and so on.</p> <p>My question--First, is there any real problem with sticking with HTML and jpegs for the initial site? Second, for the "later" part of the site development, what's the simplest we can go with? Third, are there costs in doing this the simple way that will make us regret it down the road? Also, is there a good site/resource where I can learn more about this from a newbie perspective? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>If you don't require any dynamic content, heck, if you don't plan on editing the content more than once a week, I'd say stick to basic HTML.</p> <p>Later, you'd probably want a basic, no-fuss and easily installable CMS. The brand really depends on the platform (most likely PHP/Rails/ASP), but most of them can be found by typing " CMS" into Google. Try prefixing it with "free" or "open source" if you want.</p> <p>I'm pretty sure you can do all this for absolutely free. Most PHP and Ruby CMS's are free and web hosting is free/extremely cheap if you're not demanding.</p> <p>And last/best tip: Find someone who has done this before, preferably more than once. He'll probably set you up so you never have to look at anything more complicated than a WYSIWYG editor.</p>
<p>Personally, I'd never use JPEG images on a website, mainly because of three reasons:</p> <ol> <li>JPEGs often contains artifacts.</li> <li>Quality is often proportional with filesize. </li> <li>Does not support alpha transparency.</li> </ol> <p>That said, I'd recommend you to use PNGs for images since it's lossless and a 24-bit palette (meaning full colors + alpha transparency). The only quirk is that IE6 and below does not support native alpha for PNGs, however this could be resolved by running a javascript which would fix this issue.</p> <p>As for designing a website, there's both pros and cons for this. I suggest you read through:</p> <ul> <li><a href="http://www.37signals.com/svn/posts/1061-why-we-skip-photoshop" rel="nofollow noreferrer">37 Signal's Why We Skip Photoshop</a></li> <li><a href="http://jeffcroft.com/blog/2008/jun/04/why-we-dont-skip-photoshop/" rel="nofollow noreferrer">Jeff Croft's Why We Don't Skip Photoshop</a></li> </ul> <p>As for newbie resources, I'd recommend you flip through the pages at <a href="http://w3schools.com/" rel="nofollow noreferrer">W3 Schools</a>.</p>
3,796
<p>Is there a way to disallow publishing of debug builds with ClickOnce?</p> <p>I only want to allow release builds through, but right now human error causes a debug build to slip through once in a while. </p> <p>We're publishing the build from within Visual Studio.</p>
<p>I have started to modify the .csproj files to include the following code to throw an error for debug deploys, effectively preventing the deploy from happening:</p> <pre><code>&lt;!-- The following makes sure we don’t try to publish a configuration that defines the DEBUG constant --&gt; &lt;Target Name="BeforePublish"&gt; &lt;Error Condition="'$(DebugSymbols)' == 'true'" Text="You attempted to publish a configuration that defines the DEBUG constant!" /&gt; &lt;/Target&gt; </code></pre> <p>Just place it at the end of the file, right before the <code>&lt;/Project&gt;</code> tag.</p> <p>(original source: <a href="http://www.nathanpjones.com/wp/2010/05/preventing-clickonce-publishing-a-debug-configuration/comment-page-1/#comment-625">http://www.nathanpjones.com/wp/2010/05/preventing-clickonce-publishing-a-debug-configuration/comment-page-1/#comment-625</a>)</p>
<p>I have chosen another solution that worked for me:</p> <p>I couldn't change my build process. So I did <em>Tools</em> → <em>Customize...</em> and change the text of the action, adding an alert like "Publish [CONFIGURE TO RELEASE!]", and placing the Publish button next to the Debug/Release configuration option. It's easy!</p> <p>With this I considerably reduced the risk of human error. Those buttons should always be together.</p>
6,930
<p>Following my question regarding a <a href="https://stackoverflow.com/questions/42071/net-yaml-library">.NET YAML Library</a>... as there doesn't seem to be great support for YAML in .NET, are there and good open source <em>really simple</em> .NET XML libraries. I just want something where I can pass it a section name and a key and it gives me the value as well as being able to give me a list of all the current sections and keys.</p> <p>Also, preferably something with a license that allows it to be used commercially.</p>
<p>isn't the system.xml namespace suficient?</p> <p>once i had to use it for the simple scenarios that you described and thought that it was a simple and efficient solutions.</p> <p>take a look at this examples</p> <p><a href="http://msdn.microsoft.com/en-us/library/443c16cf(VS.71).aspx" rel="nofollow noreferrer">Reading Node Trees with XmlNodeReader</a> and the <a href="http://msdn.microsoft.com/en-us/library/hf9hbf87(VS.80).aspx" rel="nofollow noreferrer">XML Document Object Model (DOM) Reference</a></p>
<p>Can you use the 3.5 framework? Linq to XML is fantastic, and simple.</p>
6,350
<p>Is there a way to check to see if an Microsoft Office process (i.e. Word, Excel) has hung when using Office Automation? Additionally, if the process is hung, is there a way to terminate it?</p>
<p>Let me start off saying that I don't recommend doing this in a service on a server, but I'll do my best to answer the questions.</p> <p>Running as a service makes it difficult to clean up. For example with what you have running as a service survive killing a hung word or excel. You may be in a position to have to kill the service. Will your service stop if word or excel is in this state. </p> <p>One problem with trying to test if it is hung, is that your test could cause a new instance of word to startup and work, while the one that the service is running would still be hung.</p> <p>The best way to determine if it's hung is to ask it to do what it is supposed to be doing and check for the results. I would need to know more about what it is actually doing. </p> <p>Here are some commands to use in a batch file for cleaning up (both should be in the path):</p> <ul> <li>sc stop servicename - stops service named servicename</li> <li>sc start servicename - starts service named servicename</li> <li><p>sc query servicename - Queries the status of servicename</p></li> <li><p>taskkill /F /IM excel.exe - terminates all instances of excel.exe</p></li> </ul>
<p>I can answer the latter half; if you have a reference to the application object in your code, you can simply call "Quit" on it:</p> <pre><code>private Microsoft.Office.Interop.Excel.Application _excel; // ... do some stuff ... _excel.Quit(); </code></pre> <p>For checking for a hung process, I'd guess you'd want to try to get some data from the application and see if you get results in a reasonable time frame (check in a timer or other thread or something). There's probably a better way though.</p>
3,122
<p>I am working on g code for my homebrew 3d printer and i have found the line <code>G1 -2.000 F2400.000</code>. From what i understand there should be an axis before the number and x and y shouldnt have negative. I am using grbl which is for cnc milling but and i have been deleting this line with no problems but i am wondering what it does because i will be upgrading to a "real" 3d printer asap</p>
<blockquote> <p>G1 -2.000 F2400.000</p> </blockquote> <p>Is not valid G-code. As you note, <code>-2.000</code> should be prefixed with an axis (X,Y,Z or E).</p> <p>Marlin would ignore the <code>-2.000</code> bit and simply treat the command as equivalent to</p> <pre><code>G1 F2400.000 </code></pre> <p>which doesn't perform any movement, but sets the feedrate for any future moves to 2400mm/min.</p> <blockquote> <p>x and y shouldnt have negative</p> </blockquote> <p>Not necessarily. Even though normally printing is done in the positive quadrant, negative values can be valid. Not only in relative movement mode, but even in absolute mode (for instance, if you set the center of your bed as (0,0) or if you use a negative z-axis offset the bring the nozzle closer to the bed).</p>
<p>G1 indicates a movement and -2.000 the distance, F2400.000 the feed rate mm/min, normally the <strong>(-)</strong> values are for retraction on extrusion <strong>E</strong>, for example:</p> <p>G0 X12 (move to 12mm on the X axis) <br> G0 F1500 (Set the feedrate to 1500mm/minute) <br> G1 X90.6 Y13.8 E22.4 (Move to 90.6mm on the X axis and 13.8mm on the Y axis while extruding 22.4mm of material) </p> <pre><code>1. G1 F1500 2. G1 X50 Y25.3 E22.4 </code></pre> <p>In the above example, we set the feedrate to 1500mm/minute on line 1, then move to 50mm on the X axis and 25.3mm on the Y axis while extruding 22.4mm of filament between the two points. </p> <pre><code>1. G1 F1500 2. G1 X50 Y25.3 E22.4 F3000 </code></pre> <p>However, in the above example, we set a <strong>feedrate of 1500 mm/minute</strong> on <strong>line 1</strong>, then do the move described above <strong><em>accelerating to a feedrate of 3000 mm/minute</em></strong> as it does so. The extrusion will accelerate along with the X and Y movement, so everything stays synchronized. </p> <p><strong><em>So, in your case if some axis is not defined the feed rate applies to all motors.</em></strong></p> <p><em>(part of this content is from reprap-wiki)</em></p> <p>You will see negative numbers if your starting point is on the center of the bed just like rectangular coordinates.</p> <pre><code>G1 X-50.318 Y8.849 E11.70313 G1 X-52.606 Y3.087 E12.26689 G1 X-53.240 Y1.297 E12.43953 G1 X-54.398 Y-2.097 E12.76562 G1 X-54.683 Y-2.995 E12.85132 </code></pre>
727
<p>I was recently asked to come up with a script that will allow the end user to upload a PSD (Photoshop) file, and split it up and create images from each of the layers.</p> <p>I would love to stay with PHP for this, but I am open to Python or Perl as well.</p> <p>Any ideas would be greatly appreciated.</p>
<p>Oops, it's</p> <pre><code>$('#mySelect').attr('size', value) </code></pre>
<pre><code>$("#mySelect").bind("click", function(){ $("#myOtherSelect").children().remove(); var myArray = [ "value1", "value2", "value3" ]; for (var i = 0; i &lt; myArray.length; i++) { $("#myOtherSelect").append( '&lt;option value="' + myArray[i] + '"&gt;' + myArray[i] + '&lt;/option&gt;' ); } $("#myOtherSelect").attr( "size", myArray.length ); }); </code></pre>
9,100
<p>I have a page upon which a user can choose up to many different paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can be too long for a mailto link.</p> <p>Any way around this?</p> <hr> <p>We were thinking about having an SP from the SQL Server do it but the user needs a nice way of 'seeing' the email before they blast 50 executive level employees with items that shouldn't be sent...and of course there's the whole thing about doing IT for IT rather than doing software programming. 80(</p> <p>When you build stuff for IT, it doesn't (some say shouldn't) have to be pretty just functional. In other words, this isn't the dogfood we wake it's just the dog food we have to eat.</p> <hr> <p>We started talking about it and decided that the 'mail form' would give us exactly what we are looking for.</p> <ol> <li>A very different look to let the user know that the gun is loaded and aimed.</li> <li>The ability to change/add text to the email.</li> <li>Send a copy to themselves or not.</li> <li>Can be coded quickly.</li> </ol>
<p>By putting the data into a form, I was able to make the body around 1800 characters long before the form stopped working.</p> <p>The code looked like this:</p> <pre><code>&lt;form action="mailto:youremail@domain.com"&gt; &lt;input type="hidden" name="Subject" value="Email subject"&gt; &lt;input type="hidden" name="Body" value="Email body"&gt; &lt;input type="submit"&gt; &lt;/form&gt; </code></pre> <hr> <p><strong>Edit</strong>: The best way to send emails from a web application is of course to do just that, send it directly from the web application, instead of relying on the users mailprogram. As you've discovered, the protocol for sending information to that program is limited, but with a server-based solution you would of course not have those limitations.</p>
<p>Does the e-mail content need to be in the e-mail? Could you store the large content somewhere centrally (file-share/FTP site) then just send a link to the content?</p> <p>This makes the recipient have an extra step, but you have a consistent e-mail size, so won't run into reliability problems due to unexpectedly large or excessive content.</p>
2,769
<p>I have a solution consisting of five projects, each of which compile to separate assemblies. Right now I'm code-signing them, but I'm pretty sure I'm doing it wrong. What's the best practice here?</p> <ul> <li>Sign each with a different key; make sure the passwords are different</li> <li>Sign each with a different key; use the same password if you want</li> <li>Sign each with the same key</li> <li>Something else entirely</li> </ul> <p>Basically I'm not quite sure what "signing" does to them, or what the best practices are here, so a more generally discussion would be good. All I really know is that <a href="http://en.wikipedia.org/wiki/FxCop" rel="noreferrer">FxCop</a> yelled at me, and it was easy to fix by clicking the "Sign this assembly" checkbox and generating a .pfx file using Visual Studio (2008).</p>
<p>If your only objective is to stop FxCop from yelling at you, then you have found the best practice.</p> <p>The best practice for signing your assemblies is something that is completely dependent on your objectives and needs. We would need more information like your intended deployment:</p> <ul> <li>For personal use</li> <li>For use on corporate network PC's as a client application</li> <li>Running on a web server</li> <li>Running in SQL Server</li> <li>Downloaded over the internet</li> <li>Sold on a CD in shrink wrap</li> <li>Uploaded straight into a cybernetic brain</li> <li>Etc.</li> </ul> <p>Generally you use code signing to verify that the Assemblies came from a specific trusted source and have not been modified. <strong><em>So each with the same key is fine.</em></strong> Now how that trust and identity is determined is another story.</p> <p><strong>UPDATE:</strong> How this benefits your end users when you are deploying over the web is if you have obtained a <a href="http://www.thawte.com/code-signing/index.html?click=main-nav-products-codesigning" rel="noreferrer">software signing certificate from a certificate authority</a>. Then when they download your assemblies they can verify they came from <em>Domenic's Software Emporium</em>, and they haven't been modified or corrupted along the way. You will also want to sign the installer when it is downloaded. This prevents the warning that some browsers display that it has been obtained from an unknown source.</p> <p>Note, you will pay for a software signing certificate. What you get is the certificate authority become the trusted 3rd party who verifies you are who you say you are. This works because of a web of trust that traces its way back to a root certificate that is installed in their operating system. There are a few certificate authorities to choose from, but you will want to make sure they are supported by the root certificates on the target operating system.</p>
<p>Signing is used to uniquely identify an assembly. More details are in <em><a href="http://msdn.microsoft.com/en-us/library/ms247123%28VS.80%29.aspx" rel="nofollow noreferrer">How to: Sign an Assembly (Visual Studio)</a></em>.</p> <p>In terms of best practice, it's fine to use the same key as long as the assemblies have different names.</p>
5,585
<p>Is it possible to do image processing in silverlight 2.0?</p> <p>What I want to do is take an image, crop it, and then send the new cropped image up to the server. I know I can fake it by clipping the image, but that only effects the rendering of the image. I want to create a new image.</p> <p>After further research I have answered my own question. Answer: <strong>No</strong>. Since all apis would be in <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.aspx" rel="nofollow noreferrer">System.Windows.Media.Imaging</a> and that namespace does not have the appropriate classes in Silverlight</p> <p>I'm going to use fjcore. <a href="http://code.google.com/p/fjcore/" rel="nofollow noreferrer">http://code.google.com/p/fjcore/</a></p> <p>Thanks <a href="https://stackoverflow.com/users/585/jonas-folles">Jonas</a></p>
<p>Well, you can actually do local image processing in Silverlight 2... But there are no built in classes to help you. But you can load any image into a byte array, and start manipulating it, or implement your own image encoder.</p> <p>Joe Stegman got lots of great information about "editable images" in Silverlight over at <a href="http://blogs.msdn.com/jstegman/" rel="nofollow noreferrer">http://blogs.msdn.com/jstegman/</a>. He does things like applying filters to images, generating mandlebrots and more.</p> <p>This blog discuss a JPEG Silverilght Encoder (FJCore) you can use to resize and recompress photos client size: <a href="http://fluxcapacity.net/2008/07/14/fjcore-to-the-rescue/" rel="nofollow noreferrer">http://fluxcapacity.net/2008/07/14/fjcore-to-the-rescue/</a></p> <p>Another tool is "Fluxify" which lets you resize and upload photos using Silverilght 2. Can be found over at <a href="http://fluxtools.net/" rel="nofollow noreferrer">http://fluxtools.net/</a></p> <p>So yes, client side image processing can definetly be done in Silverilght 2. Happy hacking!</p>
<p>There is first-class support for bitmap surfaces in Silverlight 3: <a href="http://blogs.msdn.com/kaevans/archive/2009/03/20/some-silverlight-3-goodness-using-writeablebitmap.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/kaevans/archive/2009/03/20/some-silverlight-3-goodness-using-writeablebitmap.aspx</a></p>
5,556
<p>I have a new database table I need to create...<br> It logically contains an <code>ID</code>, a <code>name</code>, and a <code>"value"</code>.<br> That value field could be either numeric or a character string in nature. </p> <p>I don't think I want to just make the field a <code>varchar</code>, because I also want to be able to query with filters like <code>WHERE value &gt; 0.5</code> and such.</p> <p>What's the best way to model this concept in SQL Server 2005?</p> <p><strong>EDIT:</strong> I'm not opposed to creating multiple fields here (one for numbers, one for non-numbers), but since they're all really the same concept, I wasn't sure that was a great idea.<br> I guess I could create separate fields, then have a view that sort of coalesces them into a single logical column. </p> <p>Any opinions on that?</p> <p>What I want to achieve is really pretty simple... usually this data will just be blindly displayed in a grid-type view.<br> I want to be also able to filter on the numeric values in that grid. This table will end up being in the tens of millions of records, so I don't want to paint myself into a corner with querying performance.<br> That querying performance is my main concern.</p>
<p>Your issue with mixing data may be how Sql 2005 sorts text data. It's not a 'natural' sort.</p> <p>If you have a varchar field and you do:</p> <pre><code>where value &gt; '20.5' </code></pre> <p>Values like "5" will be in your result (as in a character based sort "5" comes after "20.5")</p> <p>You're going to be better off with separate columns for storage.</p> <p>Use Coalesce to merge them into one column if you need them merged in your results:</p> <pre><code>select [ID], [Name], Coalesce( [value_str], [value_num] ) from [tablename] </code></pre>
<p>If you want to store numeric and string values in the same column, I am not sure you can avoid doing a lot of casts and converts when using that column as a query filter. </p>
5,462
<p>I have the <a href="http://us.xyzprinting.com/us_en/Product/da-Vinci-1.0">XYZPrinting da-Vinci-1.0</a> with ABS filament. I am concerned about ventilation. If this is used inside, what safety precautions are necessary, which are recommended, and/or which are optional?</p>
<p>Yes... The issue with <em>all</em> 3d printing materials. Not just ABS, but worse with ABS is the fine air particulate and Ultra fine it creates during the 3d printing process. PLA is considered <em>safer</em> than ABS. But I fear people will use this as justification, it is like saying I only smoke one cig a day instead of two so I am safe and healthy. No it really should be taken seriously.</p> <p>There are a number of scientific papers and articles proving that this is an issue. Specifically that 3d printers release ultra fine particles into the air. Which can damage the lungs over time. I would STRONGLY advise not using a 3d printer around children, or at least putting it in the garage where you will not contaminate your homes air supply.</p> <p>I.E.</p> <ul> <li><a href="http://www.sciencedirect.com/science/article/pii/S1352231013005086" rel="nofollow noreferrer">http://www.sciencedirect.com/science/article/pii/S1352231013005086</a></li> <li><a href="http://built-envi.com/portfolio/ultrafine-particle-emissions-from-3d-printers/" rel="nofollow noreferrer">http://built-envi.com/portfolio/ultrafine-particle-emissions-from-3d-printers/</a></li> <li><a href="https://www.ncbi.nlm.nih.gov/pubmed/11139166" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/pubmed/11139166</a></li> <li><a href="http://www.3ders.org/articles/20160201-new-study-shows-health-hazards-of-3d-printing-suggests-pla-could-be-your-safest-bet.html" rel="nofollow noreferrer">http://www.3ders.org/articles/20160201-new-study-shows-health-hazards-of-3d-printing-suggests-pla-could-be-your-safest-bet.html</a></li> </ul> <p>Lot of these have some scary looking graphs. Note that I am being a bit sarcastic when I say "scary looking graphs" the take away is ABS has twice the Fine Partical emission as PLA. However should you be worried, is still up to debate. The idea is that FPE can maybe contribute to cancer or other illnesses. FPEs are thought to irritate the lungs. </p> <p>These graphs are of the ultra fine particle emissions. <a href="https://i.stack.imgur.com/kFA4o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kFA4o.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/tcg08.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tcg08.png" alt="enter image description here"></a></p> <p>as you can see PLA is MUCH safer in this regard.</p> <p>I cannot find the paper at the moment, but the recommendation is a full air cycle several times an hour. As someone that lives in a Cold state I personally just use PLA and am rolling the dice. </p> <p>There is <a href="https://3dprinting.stackexchange.com/questions/513/what-are-the-best-air-filtration-options-for-enclosures/3212#3212">another SO</a> where I cover my future plans for an air scrubber.</p> <p>I will note that other materials such as Polycarbonate should just be plain avoided.</p> <p>I also want to provide these links on WHY ultra fine particles are bad. In summary they really upset your lungs and are thought to cause lung cancer over time.</p> <p><a href="https://en.wikipedia.org/wiki/Ultrafine_particle" rel="nofollow noreferrer">Wikipedia on Ultra fine particulates.</a> <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1740105/pdf/v058p00211.pdf" rel="nofollow noreferrer">White paper on ultra fine particulates.</a></p>
<p>your fine at practical temperatures. source: <a href="https://en.wikipedia.org/wiki/Acrylonitrile_butadiene_styrene#Hazard_for_humans" rel="nofollow">https://en.wikipedia.org/wiki/Acrylonitrile_butadiene_styrene#Hazard_for_humans</a></p> <p>recommended would probably be set your controller to not go above 380c if your really worried. but it's not needed.</p>
328
<p>I've got a custom handler applied to a class (using the Policy Injection Application Block in entlib 4) and I would like to know whether the input method is a property when Invoke is called. Following is what my handler looks like.</p> <pre><code>[ConfigurationElementType(typeof(MyCustomHandlerData))] public class MyCustomHandler : ICallHandler { public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { if (input.MethodBase.IsPublic &amp;&amp; (input.MethodBase.Name.Contains("get_") || input.MethodBase.Name.Contains("set_"))) { Console.WriteLine("MyCustomHandler Invoke called with input of {0}", input.MethodBase.Name); } return getNext().Invoke(input, getNext); } public int Order { get; set; } } </code></pre> <p>As you can see from my code sample, the best way I've thought of so far is by parsing the method name. Isn't there a better way to do this?</p>
<p>You can also check IsSpecialName is true. this will be true in a property (amongst other things)</p> <p>At the il level the methods are exposed as follows (using Environment.ExitCode as example):</p> <pre><code>.method public hidebysig specialname static int32 get_ExitCode() cil managed .method public hidebysig specialname static void set_ExitCode(int32 'value') cil managed </code></pre> <p>If you wanted to get fancy you could verify after extracting the name that said property exists but to be honest </p> <pre><code>if (m.IsSpecialName &amp;&amp; (m.Attributes &amp; MethodAttributes.HideBySig) != 0)) </code></pre> <p>as well as starts with get_ or set_ then you should be good even for people using nasty names (faking the hidebysig is easy enough, faking the IsSpecialName would be very tricky)</p> <p>Nothing is guaranteed though. Someone could emit a class with a set_Foo method that looked just like a real set method but actually wasn't a set on a read only property. Unless you check whether the property CanRead/CanWrite as well.</p> <p>This strikes me as madness for you though you aren't expecting deliberate circumvention. A simple utility/extension method on MethodInfo which did this logic wouldn't be too hard and including IsSpecialName would almost certainly cover all your needs.</p>
<p>You could check the IsSpecialName property; it will be true for property getters and setters. However, it will also be true for other special methods, like operator overloads.</p>
9,911
<p>My background is primarily as a Java Developer, but lately I have been doing some work in .NET. So I have been trying to do some simple projects at home to get better at working with .NET. I have been able to transfer much of my Java experience into working with .NET (specifically C#), but the only thing that has really perplexed me is namespaces.</p> <p>I know namespaces are similar to Java packages, but as from what I can tell the main difference is that with Java packages they use actual file folders to show the seperation, while in .NET it does not and all the files reside in a single folder and the namespace is simply declared in each class.</p> <p>I find this odd, because I always saw packages as a way to organize and group related code, making it easier to navigate and comprehend. Since in .NET it does not work this work this way, overtime, the project appears more overcrowded and not as easy to navigate.</p> <p>Am I missing something here? I have to be. Should I be breaking things into separate projects within the solution? Or is there a better way to keep the classes and files organized within a project?</p> <p>Edit: As Blair pointed out this is pretty much the same question asked <a href="https://stackoverflow.com/questions/4664/should-the-folders-in-a-solution-match-the-namespace">here</a>.</p>
<p>I can't claim that it's a best practice, but I often see files organized in a directory hierarchy that mirrors the namespace. If it fits your mental model of the code better, then do so - I can't think of any harm. Just because the .NET model doesn't enforce relationships between namespaces, projects, and directory structure doesn't mean you can't have such relationships if you want to.</p> <p>I'd be a little leery of breaking up the code into more projects than you need, as this can slow compilation and add a little bit of overhead when you have to manage multiple assemblies.</p> <p>EDIT: Note that this question is nearly a duplicate of <a href="https://stackoverflow.com/questions/4664/should-the-folders-in-a-solution-match-the-namespace">should the folders in a solution match the namespace?</a></p>
<p>I've always considered source file organization and assigning identifiers to classes and objects to be two separate problems. I tend to keep related classes in groups, but not every group should be a namespace. Namespaces exist (more or less) to solve the problem of name conflicts—in flat-namespace languages like C, you can't walk two feet without tripping over identifiers like <code>mycompany_getcurrentdate</code> or <code>MYCGetCurrentDate</code>, because the risk of a conflict with another function in a third-party (or system) library is that much smaller. If you created a package or namespace for every logical separation, you would get (Java example) class names like <code>java.lang.primitivewrapper.numeric.Integer</code>, which is pretty much overkill.</p>
7,950
<p>I'm working on building a development tool that is written in JavaScript.</p> <p>This will not be an open source project and will be sold (hopefully) as a commercial product.</p> <p>I'm looking for the best way to protect my investment. Is using an obfuscator (code mangler) enough to reasonably secure the code?</p> <p>Are there other alternatives that I am not aware of?</p> <p>(I'm not sure if obfuscator is the right word, it's one of the apps that takes your code and makes it very unreadable.)</p>
<p>I'm going to tell you a secret. Once you understand it, you'll feel a lot better about the fact that Javascript obfuscation is only really useful for saving bandwidth when sending scripts over the wire.</p> <p>Your source-code is not worth stealing.</p> <p>I know this comes as a shock to the ego, but I can say this confidently without ever having seen a line of code you've written because outside the very few realms of development where serious magic happens, it's true of all source-code.</p> <p>Say, tomorrow, someone dumped a pile of DVDs on your doorstep containing the source code for Windows Vista. What would you be able to do with it? Sure, you could compile it and give away copies, but that's just one step more effort than copying the retail version. You could painstakingly find and remove the license-checking code, but that's something some bright kid has already done to the binaries. Replace the logo and graphics, pretend you wrote it yourself and market it as "Vicrosoft Mista"? You'll get caught.</p> <p>You could spend an enormous amount of time reading the code, trying to understand it and truly "stealing the intellectual property" that Microsoft invested in developing the product. But you'd be disappointed. You'd find the code was a long series of mundane decisions, made one after the other. Some would be smarter than you could think of. Some would leave you shaking your head wondering what kind of monkeys they're hiring over there. Most would just make you shrug and say "yeah, that's how you do that."</p> <p>In the process you'll learn a lot about writing operating systems, but that's not going to hurt Microsoft.</p> <p>Replace "Vista" with "Leopard" and the above paragraphs don't change one bit. It's not Microsoft, it's <em>software</em>. Half the people on this site could probably develop a Stack Overflow clone, with or without looking at the source of this site. They just haven't. The source-code of Firefox and WebKit are out there for anyone to read. Now go write your own browser from scratch. See you in a few years.</p> <p>Software development is an investment of time. It's utter hubris to imagine that what you're doing is so special that nobody could clone it without looking at your source, or even that it would make their job that much easier without an actionable (and easily detectable) amount of cut and paste. </p>
<p>That's probably about the best you can do. Just be aware that anybody with enough dedication, can probably de-obfuscate your program. Just make sure you're comfortable with that before embarking on your project. I think the biggest problem with this would be to control who's using it on their site. If somebody goes to a site with your code on it, and likes what it does, it doesn't matter that they don't understand what the code does, or can't read it, when they can just copy the code, and use it on their own site.</p>
4,904
<p>How does Google manage to properly align the second column <em>(i.e. the ticker name)</em> in the "Get Quotes" search box suggestion drop-down in <a href="http://finance.google.com" rel="nofollow noreferrer">google finance url</a></p> <p><strong>Example:</strong> If you enter <code>iii</code> - the second column is perfectly aligned.</p> <p>It does not use a fixed width font - so just adding the correct numbers of spaces to the <em>ticker</em> will not work.</p> <p>How do they do that? ­­­­­­­­­­­­­­­­­­­­­</p>
<p>most likely just using margins. float the first column left then set the margin to the width of the first column.</p>
<p>I just viewed source with a DOM inspector and it appears that they are <code>span</code>s for each cell with a margin set (as Darren said) to position the right column over.</p>
7,361
<p>I'm setting up my printer in a small room, and I thought I'd come up with a system for more easily swapping filaments, but I'm not yet sure it is feasible.</p> <p>Rather than physically replace the spool, I'd like to hang most of my spools on the wall, where they can rotate, and only swap filament leads in the (direct drive) extruder. The spools would be placed at some distance from the extruder, and at various angles. So to make sure the filament is pulled from the spool at the proper angle, and to avoid breaking it, I think it should probably run through a <a href="http://www.amazon.co.uk/dp/B01CVKM62Q" rel="noreferrer">flexible tube</a> to reach the printer.</p> <p>I know such tubes are used for Bowden style extruders, but what I'm proposing is different in at least two ways: <strong>[1]</strong> the extruder motor would be <em>pulling</em> (not <em>pushing</em>) filament through the tube and <strong>[2]</strong> the tube would be longer than normal, e.g., between 1 and 2 meters.</p> <p>Is this plan feasible? Or are the problems I am not foreseeing?</p> <hr> <p><strong>Edit 1:</strong> I don't know where I got 1-2 meters from. The distance is actually closer to 50cm.</p> <p><strong>Edit 2:</strong> To clarify my proposed setup, here's a crude mockup:</p> <p><a href="https://i.stack.imgur.com/nWcuk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nWcuk.png" alt="mockup"></a></p>
<p>I would say it's not the best approach. </p> <p>In the situation you've described I would rather install some kind of vertical ring a bit above your printer. This ring would organize your filament going from any direction. </p> <p>So let's assume you got one spool on the right and one on the left of your printer, both are 1m away from the printer itself. If you get filament and put throught the ring then to your extruder.</p> <p>In my opinion the ring should be around 15..20cm over the printer, it should have around 10..15cm diameter and spools should not be too low.</p> <p>The only issue I see is unwinding spools which are too far from the printer because then filament would be unwinded angular but the same issue would be with and without teflon tube.</p> <p><strong>[edit]</strong> Here is a simple change of your design</p> <p><a href="https://i.stack.imgur.com/slvWkm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/slvWkm.png" alt="enter image description here"></a></p> <p><strong>[edit2]</strong> Please also note that you can assure proper angle of unwinding filament by installing small rings ("eyes") next to spools. These eyes will direct filament out of spool and then filament will turn to your big ring mounted on the printer. This is common solution in textile industry</p> <p><a href="https://i.stack.imgur.com/RQjybm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RQjybm.jpg" alt="enter image description here"></a></p>
<p>Your idea is actually good, but i would add some edits to it. First of all, to keep your equipment clean, you would like to add little foam rubbers to clean the filament at the entrance of the tubes, to clean out the dust that will be accumulating over the rolls.</p> <p>Another thing that i would recommend is to hang the tubes on a separate support for them and not on the extruder head, as it would add some additional friction to it and can cause the 3d model with additional friction making it distorted.</p>
314
<p>It's one of those things that seems to have an odd curve where the more I think about it, the more it makes sense. To a certain extent, of course. And then it doesn't make sense to me at all.</p> <p>Care to enlighten me?</p>
<p>Because in most cases you've got to sort your results first. For example, when you search on Google, <a href="http://www.google.com.au/search?hl=en&amp;safe=off&amp;q=google&amp;start=1000&amp;sa=N" rel="noreferrer">you can view only up to 100 pages of results</a>. They don't bother sorting by page-rank beyond 1000 websites for given keyword (or combination of keywords).</p> <p><strong>Pagination is fast. Sorting is slow.</strong></p>
<p>Of course sorting on a random query takes some time, but if you're having problems with the same paginated query being used regulary, there's either something wrong with the database setup (improperly indexing/none at all, too little memory etc. I'm not a db-manager) or you're doing pagination seriously wrong: </p> <p>Terribly wrong: e.g. doing <code>select * from hugetable where somecondition;</code> into an array getting the page count with the array.length pick the relevant indexes and dicard the array - then repeating this for each page... That's what I call seriously wrong. </p> <p>The better solution two queries: one getting just the count then another getting results using <code>limit</code> and <code>offset</code>. (Some proprietary, nonstandard-sql server might have a one query option, I dunno)</p> <p>The bad solution might actually work quite okay in on small tables (in fact it's not unthinkable that it's faster on very small tables, because the overhead of making two queries is bigger than getting all rows in one query. I'm not saying it <em>is</em> so...) but as soon as the database begins to grow the problems become obvious.</p>
4,925
<p>I knew of some performance reasons back in the SQL 7 days, but do the same issues still exist in SQL Server 2005? If I have a resultset in a stored procedure that I want to act upon individually, are cursors still a bad choice? If so, why?</p>
<p>Because cursors take up memory and create locks.</p> <p>What you are really doing is attempting to force set-based technology into non-set based functionality. And, in all fairness, I should point out that cursors <em>do</em> have a use, but they are frowned upon because many folks who are not used to using set-based solutions use cursors instead of figuring out the set-based solution.</p> <p>But, when you open a cursor, you are basically loading those rows into memory and locking them, creating potential blocks. Then, as you cycle through the cursor, you are making changes to other tables and still keeping all of the memory and locks of the cursor open.</p> <p>All of which has the potential to cause performance issues for other users.</p> <p>So, as a general rule, cursors are frowned upon. Especially if that's the first solution arrived at in solving a problem.</p>
<p>The basic issue, I think, is that databases are designed and tuned for set-based operations -- selects, updates, and deletes of large amounts of data in a single quick step based on relations in the data.</p> <p>In-memory software, on the other hand, is designed for individual operations, so looping over a set of data and potentially performing different operations on each item serially is what it is best at.</p> <p>Looping is not what the database or storage architecture are designed for, and even in SQL Server 2005, you are not going to get performance anywhere close to you get if you pull the basic data set out into a custom program and do the looping in memory, using data objects/structures that are as lightweight as possible.</p>
8,255
<p>Most sites are either fully released, or in beta.</p> <p>But what happens if you have a large site, and some of the parts are still in Beta, and other parts aren't. </p> <p>How do you effectively communicate this to the customer?</p>
<p>Maybe take a look at how Facebook, Bloglines, Gmail did it?</p> <p>Like "We have this beta thing going on, come on over and see the same site with new stuff, but if it doesnt work, use the old parts"</p> <p>Maybe gmail labs where you can sign up for "beta features"</p>
<p>If there's a certain way you enter the part of the beta site, maybe you can have a modal that pops up that they have to agree to every time. I wouldn't have it on every page since it gets annoying, so I would only use this approach if there is a definitive way to get into that part of the site (e.g. people won't be coming to random parts of the beta section through Google or something).</p>
7,459
<p>Wikipedia says SQL Server Express Edition is limited to "one processor, 1 GB memory and 4 GB database files". Does anyone have practical experience with how well this scales?</p>
<p>It's a regular sql server, it just has a limit. SharePoint by default uses the sql server express if that gives you any idea. We have our entire office (80+) people running on that instance.</p>
<p>It really comes down to the nature of your database and application. What kind of application(s) are hitting SQL Server? In my experience, it only handles 5-10 users with a heavy read/write application.</p>
5,610
<p>Using core jQuery, how do you remove all the options of a select box, then add one option and select it?</p> <p>My select box is the following.</p> <pre><code>&lt;Select id="mySelect" size="9"&gt; &lt;/Select&gt; </code></pre> <p>EDIT: The following code was helpful with chaining. However, (in Internet&nbsp;Explorer) <code>.val('whatever')</code> did not select the option that was added. (I did use the same 'value' in both <code>.append</code> and <code>.val</code>.)</p> <pre><code>$('#mySelect').find('option').remove().end() .append('&lt;option value="whatever"&gt;text&lt;/option&gt;').val('whatever'); </code></pre> <p>EDIT: Trying to get it to mimic this code, I use the following code whenever the page/form is reset. This select box is populated by a set of radio buttons. <code>.focus()</code> was closer, but the option did not appear selected like it does with <code>.selected= "true"</code>. Nothing is wrong with my existing code - I am just trying to learn jQuery.</p> <pre><code>var mySelect = document.getElementById('mySelect'); mySelect.options.length = 0; mySelect.options[0] = new Option ("Foo (only choice)", "Foo"); mySelect.options[0].selected="true"; </code></pre> <p>EDIT: selected answer was close to what I needed. This worked for me:</p> <pre><code>$('#mySelect').children().remove().end() .append('&lt;option selected value="whatever"&gt;text&lt;/option&gt;') ; </code></pre> <p>But both answers led me to my final solution..</p>
<pre><code>$('#mySelect') .find('option') .remove() .end() .append('&lt;option value="whatever"&gt;text&lt;/option&gt;') .val('whatever') ; </code></pre>
<p>Try</p> <pre><code>mySelect.innerHTML = `&lt;option selected value=&quot;whatever&quot;&gt;text&lt;/option&gt;` </code></pre> <p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function setOne() { console.log({mySelect}); mySelect.innerHTML = `&lt;option selected value="whatever"&gt;text&lt;/option&gt;`; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button onclick="setOne()" &gt;set one&lt;/button&gt; &lt;Select id="mySelect" size="9"&gt; &lt;option value="1"&gt;old1&lt;/option&gt; &lt;option value="2"&gt;old2&lt;/option&gt; &lt;option value="3"&gt;old3&lt;/option&gt; &lt;/Select&gt;</code></pre> </div> </div> </p>
7,008
<p>I want to create a simple http proxy server that does some very basic processing on the http headers (i.e. if header x == y, do z). The server may need to support hundreds of users. I can write the server in C# (pretty easy) or c++ (much harder). However, would a C# version have as good of performance as a C++ version? If not, would the difference in performance be big enough that it would not make sense to write it in C#?</p>
<p>You can use <strong>unsafe</strong> C# code and <strong>pointers</strong> in critical bottleneck points to make it run faster. Those behave much like C++ code and I believe it executes <em>as fast</em>.</p> <p>But most of the time, C# is JIT-ted to uber-fast already, I don't believe there will be much differences as with what everyone has said.</p> <p>But one thing you might want to consider is: <strong>Managed code (C#) string operations are rather slow compared to using pointers effectively in C++.</strong> There are more optimization tricks with C++ pointers than with CLR strings.</p> <p>I think I have done some benchmarks before, but can't remember where I've put them.</p>
<p>The proxy server you describe would deal mostly with string data and I think its reasonable to implement in C#. In your example,</p> <pre><code>if header x == y, do z </code></pre> <p>the slowest part might actually be doing whatever 'z' is and you'll have to do that work regardless of the language.</p>
5,059
<p>Using WPF, I have a TreeView control that I want to set its ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere.</p> <pre><code>myTreeViewControl.ItemTemplate = ?? </code></pre>
<p>If the template is defined in your &lt;Window.Resources&gt; section directly:</p> <pre><code>myTreeViewControl.ItemTemplate = this.Resources["SomeTemplate"] as DataTemplate; </code></pre> <p>If it's somewhere deep within your window, like in a &lt;Grid.Resources&gt; section or something, I think this'll work:</p> <pre><code>myTreeViewControl.ItemTemplate = this.FindResource("SomeTemplate") as DataTemplate; </code></pre> <p>And if it's elsewhere in your application, I <em>think</em> App.FindResource("SomeTemplate") will work.</p>
<p>if your treeview control requires different templates for your items, you should implement DataTemplateSelector class and set it's instance to your tree view. as far as i remember there is a property of DataTemplateSelector.</p>
5,116
<p>Let's say I've got Alpha things that may or may not <em>be</em> or be <em>related to</em> Bravo or Charlie things.</p> <p>These are one-to-one relationships: No Alpha will relate to more than one Bravo. And no Bravo will relate to more than one Alpha.</p> <p>I've got a few goals:</p> <ul> <li>a system that's easy to learn and maintain.</li> <li>data integrity enforced within my database.</li> <li>a schema that matches the real-world, logical organization of my data.</li> <li>classes/objects within my programming that map well to database tables (à la Linq to SQL)</li> <li>speedy read and write operations</li> <li>effective use of space (few null fields)</li> </ul> <p>I've got three ideas&hellip;</p> <pre><code>PK = primary key FK = foreign key NU = nullable </code></pre> <p>One table with many nullalbe fields (flat file)&hellip;</p> <pre><code> Alphas -------- PK AlphaId AlphaOne AlphaTwo AlphaThree NU BravoOne NU BravoTwo NU BravoThree NU CharlieOne NU CharlieTwo NU CharlieThree </code></pre> <p>Many tables with zero nullalbe fields&hellip;</p> <pre><code> Alphas -------- PK AlphaId AlphaOne AlphaTwo AlphaThree Bravos -------- FK PK AlphaId BravoOne BravoTwo BravoThree Charlies -------- FK PK AlphaId CharlieOne CharlieTwo CharlieThree </code></pre> <p>Best (or worst) of both: Lots of nullalbe foreign keys to many tables&hellip;</p> <pre><code> Alphas -------- PK AlphaId AlphaOne AlphaTwo AlphaThree NU FK BravoId NU FK CharlieId Bravos -------- PK BravoId BravoOne BravoTwo BravoThree Charlies -------- PK CharlieId CharlieOne CharlieTwo CharlieThree </code></pre> <p>What if an Alpha must be either Bravo or Charlie, but not both?</p> <p>What if instead of just Bravos and Charlies, Alphas could also be any of Deltas, Echos, Foxtrots, or Golfs, etc&hellip;?</p> <hr> <p><strong>EDIT:</strong> This is a portion of the question: <a href="https://stackoverflow.com/questions/56981/which-is-the-best-database-schema-for-my-navigation#57056">Which is the best database schema for my navigation?</a></p>
<p>If you want each Alpha to be related to by only one Bravo I would vote for the possibility with using a combined FK/PK:</p> <pre><code> Bravos -------- FK PK AlphaId BravoOne BravoTwo BravoThree </code></pre> <p>This way one and only one Bravo may refer to your Alphas.</p> <p>If the Bravos and Charlies have to be mutually exclusive, the simplest method would probably to create a discriminator field:</p> <pre><code> Alpha -------- PK AlphaId PK AlphaType NOT NULL IN ("Bravo", "Charlie") AlphaOne AlphaTwo AlphaThree Bravos -------- FK PK AlphaId FK PK AlphaType == "Bravo" BravoOne BravoTwo BravoThree Charlies -------- FK PK AlphaId FK PK AlphaType == "Charlie" CharlieOne CharlieTwo CharlieThree </code></pre> <p>This way the AlphaType field forces the records to always belong to exactly one subtype.</p>
<p>I'd go with option 1 unless I had a significant reason not to. It might not cost you as much space as you think, esp. if you are using varchars in Bravo. Don't forget that splitting it will cost you for foreign keys, secondary identity and needed indexes. <p>A place where you might run into trouble is if Bravo is unlikely to be needed (&lt;%10) AND you need to quickly query by one of its fields so you index it.</p>
8,135
<p>I have <code>ci</code>, so our staging environment builds itself.<br> Should I have a script that not only builds production but does all the branching for it as well?<br> When you have one code base on two different urls with skinning, should they be required to build at once?</p>
<p>The only way to be too automated is if you are spending more time fighting with building or fixing automation scripts than you would just doing the job manually. As long as your automation scripts take less time and produce fewer errors than doing the job manually, then automation is great.</p> <p>Scripts to build and branch for production are a great idea!</p>
<p>In my opinion it's only too automated if no one in your production support group can deploy an application manually in a pinch. Automated deployments really cut down on simple but common errors such as configuration mistakes. However, a manual deployment must always be an option. </p>
4,906
<p>I wonder if someone knows if there is a pre-made solution for this: I have a List on an ASP.net Website, and I want that the User is able to re-sort the list through Drag and Drop. Additionally, I would love to have a second list to which the user can drag items from the first list onto.</p> <p>So far, I found two solutions:</p> <ul> <li>The ReorderList from the <a href="http://www.codeplex.com/AjaxControlToolkit" rel="nofollow noreferrer">Ajax Control Toolkit</a>, which requires a bit of manual work to make sure changes <a href="http://www.codeproject.com/KB/ajax/PersistentReorderList.aspx" rel="nofollow noreferrer">are persisted</a> into the database, and that does not support drag/drop between lists.</li> <li>The <a href="http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/DragAndDrop/DefaultCS.aspx" rel="nofollow noreferrer">RadGrid</a> from Telerik which does all I want, but is priced far far beyond my Budget.</li> </ul> <p>Does anyone else have some ideas or at least some keywords/pointers to do further investigation on? Espectially the Drag/Drop between two lists is something I am rather clueless about how to do that in ASP.net.</p> <p>Target Framework is 3.0 by the way.</p>
<p>The Mootools sortables plugin does just that, and best of all, it's free ;)</p> <p><a href="http://demos.mootools.net/Sortables" rel="nofollow noreferrer">http://demos.mootools.net/Sortables</a></p>
<p>I've evaluated the <a href="http://www.telerik.com/" rel="nofollow noreferrer">Telerik</a> grid as well as <a href="http://www.infragistics.com/Default.aspx" rel="nofollow noreferrer">Infragistics</a> version. In the end we took an approach similar to what tags2k suggested. We just wrote our own javascript and called <a href="http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx" rel="nofollow noreferrer">.Net PageMethods</a> to do the server side work. </p> <p>We found both of the "out of the box" solutions to be bloated. Unless you put paging in at like 20 records per row they really stunk performance wise. </p>
3,453
<p>Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing:</p> <pre><code>/index.html /favicon.ico /images/logo.gif </code></pre> <p>A call to <strong>www.example.com/<em>index.html</em></strong> works great! But if one were to call <strong>www.example.com/</strong> we'd either get a 403 or a REST object listing XML document depending on how bucket-level ACL was configured.</p> <p>So, the question: Is there a way to have index.html functionality with content hosted on S3?</p>
<p>Amazon S3 now supports <a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/IndexDocumentSupport.html" rel="noreferrer">Index Documents</a></p> <p>The <em>index document</em> for a bucket can be set to something like <code>index.html</code>. When accessing the root of the site or a sub-directory containing a document of that name that document is returned.</p> <p>It is extremely easy to do using the aws cli:</p> <pre><code>aws s3 website $MY_BUCKET_NAME --index-document index.html </code></pre> <p>You can set the <em>index document</em> from the AWS Management Console:</p> <p><img src="https://i.stack.imgur.com/HALQp.png" alt="enter image description here"></p>
<p>you can do it using dns webforwards and cloaking. just forward to the complete path of the index.html</p> <p>www.example.com forwards to <a href="http://www.example.com.s3.amazonaws.com" rel="nofollow noreferrer">http://www.example.com.s3.amazonaws.com</a> and make sure you cloak the output.</p>
4,756
<p>I want my controller to return the right HTTP response code when the user lacks permission to view a particular page.</p>
<p>Create an Exception annotated with <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/bind/annotation/ResponseStatus.html">@ResponseStatus</a> e.g. like this:</p> <pre class="lang-java prettyprint-override"><code>@ResponseStatus(HttpStatus.FORBIDDEN) public class ForbiddenException extends RuntimeException { } </code></pre> <p>Now just throw that Exception in your handler method and the response will have status 403.</p>
<p>Use this: <code>response.setStatus(403)</code>.</p>
6,747
<p>There seem to be two rival Eclipse plugins for integrating with Maven: <a href="http://m2eclipse.codehaus.org/" rel="nofollow noreferrer">m2Eclipse</a> and <a href="http://code.google.com/p/q4e/" rel="nofollow noreferrer">q4e</a>. </p> <p>Has anyone recently evaluated or used these plugins?<br> Why would I choose one or the other?</p>
<p><a href="http://docs.codehaus.org/display/MAVENUSER/Eclipse+Integration" rel="nofollow noreferrer">Side by side comparison table of three maven plugins.</a> </p>
<p>I have been using m2Eclipse for quiet some time now and have found it to be very reliable. I wasn't aware of q4e until I saw this question so I can't recommend one over the other.</p>
6,979
<p>I am having problems with my tevo tarantula large bed 12Volt power supply, I am getting the thermal protection message when heating my bed with target temperature set to 115 degrees. The process slows down after reaching 90. I changed merlin settings to trigger thermal shutdown after 5minutes/2degrees and added a cover to the printer, so getting now 103 degrees (usually shutdown was at 100/101).</p> <p>link to a video showing panel: <a href="https://photos.app.goo.gl/jiW9NE7wEB4H0mOy1" rel="nofollow noreferrer">https://photos.app.goo.gl/jiW9NE7wEB4H0mOy1</a> <a href="https://i.stack.imgur.com/l3D0P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l3D0P.jpg" alt="printer under the polystyrene cover"></a></p>
<p>You need to increase the power of the heated bed. With a given amount of power, there is an upper limit to the maximum temperature you can reach because at a given point losses due to conduction, convection and radiation will balance out the heating power and the temperature will not increase any more.</p> <p>Sometimes, inability of the bed to heat up is due to the supply voltage sagging under load. First, measure the supply voltage with and without the bed turned on. If you find the supply drops significantly when the bed is turned on, you need a new power supply.</p> <p>Otherwise, you will need to either:</p> <ol> <li><p>Get a new, higher-power heated bed. Make sure that it is compatible with your electronics, or upgrade them as needed.</p></li> <li><p>Increase the supply voltage so that the bed you already have will give more power. Some power supplies have a small adjustment potentiometer that lets you adjust the output voltage. Be careful when doing this. Even a small change in voltage gives a big increase in power. For a heated bed with resistance R at voltage U, the power dissipation is U<sup>2</sup>/R. Going from 12V to 13.5V already gives 26% more power.</p></li> </ol>
<p>Some simple steps that may help to reach higher temperature:</p> <ol> <li>Check if you can use heated bed insulation of any kind - the most common approach is to use cork sheet</li> <li>Protect heated bed and printer from any possible air movements - arrange a set of walls around printer or just simply put it in the cardboard box large enough</li> <li>Cover heated bed with cloth or cork sheet until it reaches desired temperature</li> <li>Replace wires from heated bed to the power supply with thicker ones (2.mm<sup>2</sup> / AWG14 should be fine)</li> </ol>
834
<p>Recently got a Creator 3 (v2) and single-colour prints are great, but dual colour Benchies are coming out quite bad. Initially, I thought it was X/Y calibration as when I printed a dual-colour cube, I could feel a slight bump as I ran my fingernail across the joins. I tweaked that and the cube now seems good (pics attached), but the Benchy came out the same, with a lot of scruffy plastic in several places.</p> <p>I had the same with some old Balco filament and now with Technology Outlet filament (all four reels have printed fine on their own, the prints are really good).</p> <p>I'm using Flashprint 5.1 for slicing, with mostly default settings (though infill reduced to 10 % and temp increased from 200 °C to 210 °C for the Technology Outlet filament). I'm using an Ooze Shield and a brim. Stock 0.4 mm nozzles.</p> <p>Any suggestions on what the issue might be or what I can do to improve it some? The <a href="http://www.3dbenchy.com/wp-content/uploads/2015/07/Dualprint-3DBenchy-Main-image-Dual.jpg" rel="nofollow noreferrer">dual-colour pic on the Benchy website</a> looks way better, so I don't think it's just that these parts of the models are difficult to print.</p> <p>Thanks!</p> <p><a href="https://i.stack.imgur.com/KLOF7.jpg" rel="nofollow noreferrer" title="Dual-colour Benchy highlighting printing errors"><img src="https://i.stack.imgur.com/KLOF7.jpg" alt="Dual-colour Benchy highlighting printing errors" title="Dual-colour Benchy highlighting printing errors" /></a></p> <p><a href="https://i.stack.imgur.com/dtNCh.jpg" rel="nofollow noreferrer" title="Another dual colour Benchy with printing errors"><img src="https://i.stack.imgur.com/dtNCh.jpg" alt="Another dual-colour Benchy with printing errors" title="Another dual colour Benchy with printing errors" /></a></p> <p><a href="https://i.stack.imgur.com/8UjKx.jpg" rel="nofollow noreferrer" title="A dual-colour cube showing good X/Y alignment"><img src="https://i.stack.imgur.com/8UjKx.jpg" alt="A dual-colour cube showing good X/Y alignment" title="A dual-colour cube showing good X/Y alignment" /></a></p> <p><a href="https://i.stack.imgur.com/2wEj3.jpg" rel="nofollow noreferrer" title="Another side of a dual-colour cube showing good X/Y alignment"><img src="https://i.stack.imgur.com/2wEj3.jpg" alt="Another side of a dual-colour cube showing good X/Y alignment" title="Another side of a dual-colour cube showing good X/Y alignment" /></a></p>
<p>You have a problem with retraction or more broadly with what happens to the material in the inactive extruder while it's waiting to be used again. I'm not sure what your printer does, but there are various strategies for how to handle this, which can possibly be mixed:</p> <ul> <li>doing nothing and letting it make a mess</li> <li>a large amount of extra retraction to get the filament entirely out of the heated zone, followed by a slow unretract into the heated zone when the extruder becomes active again</li> <li>using a priming tower (sacrificial junk part) to re-prime the inactive nozzle when it's activated again</li> <li>priming in thin air and using a wiping brush to clean the inactive nozzle when it's activated again</li> <li>maybe others</li> </ul> <p>You need to figure out what options are available for your printer and how to tune them to get results you're happy with.</p>
<p>I've tracked down the cause of this, although I don't yet know a solution. It only occurs with dual-colour prints and I noticed the stringing is coming from when the nozzle moves <em>away</em> from the print, not from the new nozzle coming towards it.</p> <p>After watching some prints, I realised what it is. After finishing with a nozzle, the bed is lowered (like a z-hop), and it's thta action that is pulling filament out of the nozzle causing the string. For a standard single-nozzle print, this action does not occur, and no filament is pulled out.</p> <p>The only z-hop option in Flashprint is disabled, so I'm not hopeful I can fix it here though. Perhaps other slices may do better (I'm going to try Cura next).</p>
2,010
<p>Having started with an Ender 3, it just seemed natural to me that the heatbreak should not be load-bearing; Creality's stock hotend has 2 bolts holding the heat block to the heat sink, which of course waste some heating power and increase the cooling needed to avoid heat creep, but serve the important purpose of keeping the nozzle position rigid relative to the carriage and making it so you don't bend or snap the heatbreak when changing nozzles.</p> <p>Looking at hotends (especially all-metal ones) for a possible future printer build, I'm surprised to see that many (most?) don't have this property, and have the heatbreak playing a load-bearing role. This seems really undesirable. Only the Mosquito <em>makes a point of</em> doing this right, and supposedly has a patent on this or related design decisions. Is that really the case? Are there basic all-metal hotends that are designed to avoid making the heatbreak load-bearing that don't cost $150?</p>
<p>The drop-in replacement all metal hotends for the Ender 3 that I've looked at seem to have the two screws -- though I've read/heard opinions that these are intended to be removed after assembly, these are common Mk. 8 type hot ends, but with 2 mm bore through the entire heat break instead of 4 mm. That seems to be the only modification (other than not anodizing the aluminum heat sink).</p> <p>While the brand name units of this type run approximately 65 USD at retail, they're available from Chinese vendors for under 10 USD plus a few dollars shipping, if you don't mind waiting a few weeks instead of a couple days to receive your part -- and if they aren't from the same production but sold without extensive vendor support, they're very close physical copies, according to review videos I've seen.</p> <p>It's also possible to replace just the heat break for similar cost, either in stainless or titanium, with a 2 mm bore unit; this would obviously preserve whatever additional mounting hardware exists on/between your original heat block and heat sink.</p> <p>BTW, if they aren't already, replacing the screws with stainless will significantly reduce heat loss through the screws -- stainless is a much poorer conductor of heat than common steels used with plated screws.</p>
<p>You ask in general, not specifically for Ender, so since you mention the Mosquito, which has a characteristic shape and a size, the obvious alternative which doesn't cost that much is the Phaetus Dragon.</p> <p>It copies the idea of the Mosquito, but it is repackaged in a shape and size fully equivalent to standard v6 hotends so it's a drop-in replacement for any v6 hotend. You don't have one, but in general...</p> <p>Footnote: Slice Engineering got the patent in US, but not in Europe and China, yet. Also, in Europe <a href="https://register.epo.org/application?tab=doclist&amp;number=EP18801363&amp;lng=en" rel="nofollow noreferrer">their idea</a> apparently was <a href="https://register.epo.org/application?documentId=E5RB12D46652DSU&amp;number=EP18801363&amp;lng=en&amp;npl=false" rel="nofollow noreferrer">found</a> as not original. Who knows...</p>
1,973
<p>I'm just in the process of parsing some text and can't remember what the escape character is for a tab in C#?</p>
<p>Easy one! "\t"</p> <p>Edit: In fact, here's something official: <a href="http://msdn.microsoft.com/en-us/library/h21280bw.aspx" rel="noreferrer">Escape Sequences</a></p>
<p>For someone who needs quick reference of <strong>C# Escape Sequences</strong> that can be used in <code>string</code> literals:</p> <blockquote> <p>\t &nbsp; &nbsp; Horizontal tab (ASCII code value: 9)</p> <p>\n &nbsp; &nbsp; Line feed (ASCII code value: 10)</p> <p>\r &nbsp; &nbsp; Carriage return (ASCII code value: 13)</p> <p>\' &nbsp; &nbsp; Single quotation mark</p> <p>\" &nbsp; &nbsp; Double quotation mark</p> <p>\\ &nbsp; &nbsp; Backslash</p> <p>\? &nbsp; &nbsp; Literal question mark</p> <p>\x12 &nbsp; &nbsp; ASCII character in hexadecimal notation (e.g. for 0x12)</p> <p>\x1234 &nbsp; &nbsp; Unicode character in hexadecimal notation (e.g. for 0x1234)</p> </blockquote> <p>It's worth mentioning that these (in most cases) are universal codes. So \t is 9 and \n is 10 char value on Windows and Linux. But newline sequence is not universal. On Windows it's \n\r and on Linux it's just \n. That's why it's best to use <code>Environment.Newline</code> which gets adjusted to current OS settings. With .Net Core it gets really important.</p>
2,762
<p>It will be important for developers wanting to develop for the chrome browser to be able to review existing bugs (to avoid too much pulling-out of hair), and to add new ones (to improve the thing). Yet I can't seem to find the bug tracking for this project. It <em>is</em> open source, right?</p>
<p>Google is calling it <a href="http://code.google.com/chromium/" rel="noreferrer">Chromium</a> on Google Code</p> <p>The <a href="http://dev.chromium.org/for-testers/bug-reporting-guidelines" rel="noreferrer">Chromium Bug Reporting Page</a> is there and has the link to submit bugs listed. (Google Account Required)</p> <p><a href="https://accounts.google.com/ServiceLogin?service=ah&amp;passive=true&amp;continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://bugs.chromium.org/p/chromium/issues/entryafterlogin" rel="noreferrer">Here's a direct link</a> to the bug report form.</p>
<p>From the <a href="http://www.google.com/support/chrome/bin/answer.py?answer=95760&amp;query=bug&amp;topic=&amp;type=" rel="nofollow noreferrer">Google Site</a></p> <ol> <li>Click the Page menu page menu.</li> <li>Select Report a bug or broken website.</li> <li>Choose an issue type from the drop-down menu. The web address of the webpage you're on is recorded automatically.</li> <li>If possible, add key details in the 'Description' field, including steps to reproduce the issue you're experiencing.</li> <li>Keep 'Send source of current page' and 'Send screenshot of current page' checkboxes selected.</li> <li>Click the Send report button to report a Google Chrome bug.</li> </ol> <p>I don't see any reference to public bug tracking... </p>
6,194
<p>one of the most frequent requests I get is to create XY report for YZ App. These apps are normally built on PHP, so far I have manually created most of this reports, and while I enjoy the freedom of building it as I want, it usually becomes pretty tedious to calculate subtotals, averages, exporting to different formats etc.</p> <p>What solutions are out there (free/OSS preferred) that help me get this repetitive tasks cranking?</p> <p>edits: </p> <ul> <li>I'm talking about reports/summaries from SQL data. Many times from DBs not designed for reporting use.</li> <li>while I'm aware of "business-intelligence" we're not ready to implement a full scaled "intelligence" structure, looking more for a helper of sorts...</li> </ul>
<p>The problem you're facing is solved by so-called Business Intelligence software. This software tends to be bloated and expensive, but if you know your way around them you will be able to crank out such reports in no time at all. </p> <p>I'm only familiar with one particular proprietary solution, which isn't too great either. But a quick search turns up the following page, which lists a number of free/open source alternatives: </p> <p><a href="http://en.wikipedia.org/wiki/Business_intelligence_tools" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Business_intelligence_tools</a></p>
<p>It depends on what kind of reports you're talking about. For example... site stats... you could install google analytics and the client could export whatever format they wanted.</p>
9,162
<p>In my web application I include all of my JavaScripts as js files that are embedded resources in the assembly, and add them to the page using <code>ClientScriptManager.GetWebResourceUrl()</code>. However, in some of my js files, I have references to other static assets like image urls. I would like to make those assembly resources as well. Is there a way to tokenize the reference to the resource? e.g.</p> <pre><code>this.drophint = document.createElement('img'); this.drophint.src = '/_layouts/images/dragdrophint.gif'; </code></pre> <p>Could become something like:</p> <pre><code>this.drophint = document.createElement('img'); this.drophint.src = '{resource:assembly.location.dragdrophint.gif}'; </code></pre>
<p>I'd suggest that you emit the web resources as a dynamic javascript associative array.</p> <p>Server side code:</p> <pre><code>StringBuilder script = new StringBuilder(); script.Append("var imgResources = {};"); script.AppendFormat("imgResources['{0}'] = '{1}';", "drophint", Page.ClientScript.GetWebResourceUrl(Page.GetType(), "assembly.location.dragdrophint.gif")); script.AppendFormat("imgResources['{0}'] = '{1}';", "anotherimg", Page.ClientScript.GetWebResourceUrl(Page.GetType(), "assembly.location.anotherimg.gif")); Page.ClientScript.RegisterClientScriptBlock( Page.GetType(), "imgResources", script.ToString(), true); </code></pre> <p>Then your client side code looks like this:</p> <pre><code>this.drophint = document.createElement('img'); this.drophint.src = imgResources['drophint']; this.anotherimg = document.createElement('img'); this.anotherimg.src = imgResources['anotherimg']; </code></pre> <p>Hope this helps.</p>
<p>I don't particularly care for the exact implementation <a href="https://stackoverflow.com/questions/46489/referencing-embedded-resources-from-other-resources-in-c#47242"><strong>@Jon</strong></a> suggests, but the idea behind it is sound and I would concur that emitting these would be a good thing to do. </p> <p>A slightly better implementation, though this is all subjective to some degree, would be to create a server-side model (read: C# class(es)) that represents this dictionary (or simply use an instance of Dictionary&lt;string, string&gt;) and serialize that to JavaScript literal object notation. That way you are not dealing with the string hacking you see in Jon's example (if that bothers you).</p>
6,862
<p>I know there are a lot of positive things mod-rewrite accomplishes. But are there any negative? Obviously if you have poorly written rules your going to have problems. But what if you have a high volume site and your constantly using mod-rewrite, is it going to have a significant impact on performance? I did a quick search for some benchmarks on Google and didn't find much. </p>
<p>I've used mod_rewrite on sites that get millions/hits/month without any significant performance issues. You do have to know which rewrites get applied first depending on your rules.</p> <p>Using mod_rewrite is most likely faster than parsing the URL with your current language. </p> <p>If you are really worried about performance, don't use <code>.htaccess</code> files, those are slow. Put all your rewrite rules in your Apache config, which is only read once on startup. <code>.htaccess</code> files get re-parsed on every request, along with <strong>every</strong> <code>.htaccess</code> file in parent folders.</p>
<p>If you're worried about apache's performance, one thing to consider if you have a lot of rewrite rules is to use the "skip" flag. It is a way to skip matching on rules. So, whatever overhead would have been spent on matching is saved.</p> <p>Be careful though, I was on a project which utilized the "skip" flag a lot, and it made maintenance painful, since it depends on the order in which things are written in the file.</p>
4,612
<p>Ender 3 Pro, PLA, temps 200 °C and 60 °C.</p> <p>I want to not heat the nozzle until after Auto Bed Leveling (CR Touch) is complete. I can do that in the start G-code, but by then, Cura has already heated the nozzle to the temp specified under material and filament starts oozing out during bed leveling. I'd rather set a variable to that value and call it with <code>M104</code> when I'm ready.</p> <p>This is the start of Cura's g-code:</p> <pre><code>;FLAVOR:Marlin ;TIME:2888 ;Filament used: 1.96332m ;Layer height: 0.2 ;MINX:93.266 ;MINY:10.195 ;MINZ:0.2 ;MAXX:126.734 ;MAXY:210.658 ;MAXZ:4.2 ;Generated with Cura_SteamEngine 4.13.1 M140 S60 M105 M190 S60 M104 S200 M105 M109 S200 M82 ;absolute extrusion mode ; Ender 3 Custom Start G-code G92 E0 ; Reset Extruder G28 ; Home all axes G29 ; Auto Bed Level (CR Touch) G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line G92 E0 ; Reset Extruder ... </code></pre> <p>The lines right after &quot;Generated with Cura_SteamEngine&quot; are the ones I'd like to change but I can't find them in the Cura app. I know that 60 °C and 200 °C are the temps defined for bed and nozzle. Cura inserts them as constants for the <code>M140</code> and <code>M104</code> commands. I'd like Cura to set variables to those values (like <code>{bed_temp} = 60</code>) so I can refer to that variable when I insert the <code>M140</code> command in my Custom Start G-code. Can that be done?</p> <p>A related question was asked a few years ago and part of the start code example then was:</p> <pre><code>; Ender 3 Custom Start G-code M104 S{material_print_temperature_layer_0} ; Set Extruder temperature M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature G28 ; Home all axes G29 ; BLTOUCH Mesh Generation M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature </code></pre> <p>The variable <code>{material_bed_temperature_layer_0}</code> was already set but I don't know where or how that was done.</p>
<p>I've sorted this out. <em>IF</em> I include my own heating commands in my start G-Code, Cura knows to NOT add its own heating commands at the start of the G-Code file.</p> <p>The variables I was referring to have dedicated names. <code>material_print_temperature_layer_0</code> is the printing (extruder/nozzle) temp set under Material in Cura. <code>material_bed_temperature_layer_0</code> is the build plate temp set under Material in Cura.</p> <p>Cura substitutes the values of those variables for the variable names in the G-code file.</p> <p>So to avoid filament ooze during auto bed leveling, I set the nozzle temp to 150 °C (hot, but lower than the defined printing temp and low enough to avoid ooze). I set the bed temp to its defined temp.</p> <p>Then I auto-level the bed.</p> <p>Then I heat the nozzle up to its defined printing temp and start the print job.</p> <p>This is my Start G-code:</p> <pre><code>; Ender 3 Custom Start G-code G92 E0 ; Reset Extruder G28 ; Home all axes M104 S150 ; Set Extruder temperature for bed leveling M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature M109 S150 ; Wait for Extruder temperature for bed leveling M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature G29 ; Auto Bed Level (CR Touch) M104 S{material_print_temperature_layer_0} ; Set Extruder temperature M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line G92 E0 ; Reset Extruder G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish </code></pre> <p>And this is how Cura writes the G-code file:</p> <pre><code>;FLAVOR:Marlin ;TIME:2888 ;Filament used: 1.96332m ;Layer height: 0.2 ;MINX:93.266 ;MINY:10.195 ;MINZ:0.2 ;MAXX:126.734 ;MAXY:210.658 ;MAXZ:4.2 ;Generated with Cura_SteamEngine 4.13.1 M82 ;absolute extrusion mode ; Ender 3 Custom Start G-code G92 E0 ; Reset Extruder G28 ; Home all axes M104 S150 ; Set Extruder temperature for bed leveling M140 S60 ; Set Heat Bed temperature M109 S150 ; Wait for Extruder temperature for bed leveling M190 S60 ; Wait for Heat Bed temperature G29 ; Auto Bed Level (CR Touch) M104 S200 ; Set Extruder temperature M109 S200 ; Wait for Extruder temperature G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line G92 E0 ; Reset Extruder G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish G92 E0 ... </code></pre> <p>I hope this helps someone with a similar question.</p> <p>Cheers.</p>
<p>Go to the <code>Settings</code> -&gt; <code>Printers</code> menu from the top menu,</p> <p><a href="https://i.stack.imgur.com/jmivX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jmivX.png" alt="enter image description here" /></a></p> <p>select your active printer (or <code>Activate</code> it) and manage your printer trough <code>Machine Settings</code>.</p> <p><a href="https://i.stack.imgur.com/L3CUC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L3CUC.png" alt="enter image description here" /></a></p> <p>It will open the printer settings,</p> <p><a href="https://i.stack.imgur.com/rBjqg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rBjqg.png" alt="enter image description here" /></a></p> <p>there you are able to change the lines you want in the <code>Start G-code</code> section.</p> <p>Note the default Start G-code doesn't include heating up the bed and core, you need to add these after the <code>G29</code> in your case. Personally I use heat up bed and continue (<code>M140</code>), than heat up core and wait till temperature is reached (<code>M109</code>), then heat up and wait until bed temperature is reached (<code>M190</code>).</p>
2,152
<p>How can you make the display frames per second be independent from the game logic? That is so the game logic runs the same speed no matter how fast the video card can render. </p>
<p>I think the question reveals a bit of misunderstanding of how game engines should be designed. Which is perfectly ok, because they are damn complex things that are difficult to get right ;)</p> <p>You are under the correct impression that you want what is called Frame Rate Independence. But this does not only refer to Rendering Frames.</p> <p>A Frame in single threaded game engines is commonly referred to as a Tick. Every Tick you process input, process game logic, and render a frame based off of the results of the processing.</p> <p>What you want to do is be able to process your game logic at any FPS (Frames Per Second) and have a deterministic result.</p> <p>This becomes a problem in the following case:</p> <p>Check input: - Input is key: 'W' which means we move the player character forward 10 units:</p> <blockquote> <p>playerPosition += 10;</p> </blockquote> <p>Now since you are doing this every frame, if you are running at 30 FPS you will move 300 units per second.</p> <p>But if you are instead running at 10 FPS, you will only move 100 units per second. And thus your game logic is <em>not</em> Frame Rate Independent.</p> <p>Happily, to solve this problem and make your game play logic Frame Rate Independent is a rather simple task.</p> <p>First, you need a timer which will count the time each frame takes to render. This number in terms of seconds (so 0.001 seconds to complete a Tick) is then multiplied by what ever it is that you want to be Frame Rate Independent. So in this case:</p> <p>When holding 'W'</p> <blockquote> <p>playerPosition += 10 * frameTimeDelta;</p> </blockquote> <p><em>(Delta is a fancy word for "Change In Something")</em></p> <p>So your player will move some fraction of 10 in a single Tick, and after a full second of Ticks, you will have moved the full 10 units.</p> <p>However, this will fall down when it comes to properties where the rate of change also changes over time, for example an accelerating vehicle. This can be resolved by using a more advanced integrator, such as "Verlet".</p> <h2><strong>Multithreaded Approach</strong></h2> <p>If you are still interested in an answer to your question (since I didn't answer it but presented an alternative), here it is. Separating Game Logic and Rendering into different threads. It has it's draw backs though. Enough so that the vast majority of Game Engines remain single threaded.</p> <p>That's not to say there is only ever one thread running in so called single threaded engines. But all significant tasks are usually in one central thread. Some things like Collision Detection may be multithreaded, but generally the Collision phase of a Tick blocks until all the threads have returned, and the engine is back to a single thread of execution.</p> <p>Multithreading presents a whole, very large class of issues, even some performance ones since everything, even containers, must be thread safe. And Game Engines are very complex programs to begin with, so it is rarely worth the added complication of multithreading them.</p> <h2><strong>Fixed Time Step Approach</strong></h2> <p>Lastly, as another commenter noted, having a Fixed size time step, and controlling how often you "step" the game logic can also be a very effective way of handling this with many benefits.</p> <p>Linked here for completeness, but the other commenter also links to it: <a href="http://gafferongames.com/game-physics/fix-your-timestep/" rel="noreferrer">Fix Your Time Step</a></p>
<p>From my experience (not much) Jesse and Adam's answers should put you on the right track.</p> <p>If you are after further information and insight into how this works, i found that the sample applications for <a href="http://www.truevision3d.com/" rel="nofollow noreferrer">TrueVision 3D</a> were very useful.</p>
3,807
<p>One of the things that get me thoroughly confused is the use of <code>session.Flush</code>,in conjunction with <code>session.Commit</code>, and <code>session.Close</code>.</p> <p>Sometimes <code>session.Close</code> works, e.g., it commits all the changes that I need. I know I need to use commit when I have a transaction, or a unit of work with several creates/updates/deletes, so that I can choose to rollback if an error occurs.</p> <p>But sometimes I really get stymied by the logic behind <code>session.Flush</code>. I have seen examples where you have a <code>session.SaveOrUpdate()</code> followed by a flush, but when I remove Flush it works fine anyway. Sometimes I run into errors on the Flush statement saying that the session timed out, and removing it made sure that I didn't run into that error.</p> <p>Does anyone have a good guideline as to where or when to use a Flush? I've checked out the NHibernate documentation for this, but I still can't find a straightforward answer.</p>
<p>Briefly:</p> <ol> <li>Always use transactions</li> <li>Don't use <code>Close()</code>, instead wrap your calls on an <code>ISession</code> inside a <code>using</code> statement or <strong>manage the lifecycle of your ISession somewhere else</strong>.</li> </ol> <p>From <a href="http://nhibernate.info/doc/nh/en/index.html#manipulatingdata-flushing" rel="noreferrer">the documentation</a>:</p> <blockquote> <p>From time to time the <code>ISession</code> will execute the SQL statements needed to synchronize the ADO.NET connection's state with the state of objects held in memory. This process, flush, occurs by default at the following points</p> <ul> <li>from some invocations of <code>Find()</code> or <code>Enumerable()</code></li> <li>from <code>NHibernate.ITransaction.Commit()</code></li> <li>from <code>ISession.Flush()</code></li> </ul> <p>The SQL statements are issued in the following order</p> <ol> <li>all entity insertions, in the same order the corresponding objects were saved using <code>ISession.Save()</code></li> <li>all entity updates</li> <li>all collection deletions</li> <li>all collection element deletions, updates and insertions</li> <li>all collection insertions</li> <li>all entity deletions, in the same order the corresponding objects were deleted using <code>ISession.Delete()</code></li> </ol> <p>(An exception is that objects using native ID generation are inserted when they are saved.)</p> <p><strong>Except when you explicity <code>Flush()</code>, there are absolutely no guarantees about when the Session executes the ADO.NET calls, only the order in which they are executed</strong>. However, NHibernate does guarantee that the <code>ISession.Find(..)</code> methods will never return stale data; nor will they return the wrong data.</p> <p>It is possible to change the default behavior so that flush occurs less frequently. The <code>FlushMode</code> class defines three different modes: only flush at commit time (and only when the NHibernate <code>ITransaction</code> API is used), flush automatically using the explained routine, or never flush unless <code>Flush()</code> is called explicitly. The last mode is useful for long running units of work, where an <code>ISession</code> is kept open and disconnected for a long time.</p> </blockquote> <p>...</p> <p>Also refer to <a href="http://nhibernate.info/doc/nh/en/index.html#manipulatingdata-endingsession" rel="noreferrer">this section</a>:</p> <blockquote> <p>Ending a session involves four distinct phases:</p> <ul> <li>flush the session</li> <li>commit the transaction</li> <li>close the session</li> <li>handle exceptions</li> </ul> <h2>Flushing the Session</h2> <p>If you happen to be using the <code>ITransaction</code> API, you don't need to worry about this step. It will be performed implicitly when the transaction is committed. Otherwise you should call <code>ISession.Flush()</code> to ensure that all changes are synchronized with the database.</p> <h2>Committing the database transaction</h2> <p>If you are using the NHibernate ITransaction API, this looks like:</p> <pre><code>tx.Commit(); // flush the session and commit the transaction </code></pre> <p>If you are managing ADO.NET transactions yourself you should manually <code>Commit()</code> the ADO.NET transaction.</p> <pre><code>sess.Flush(); currentTransaction.Commit(); </code></pre> <p>If you decide not to commit your changes:</p> <pre><code>tx.Rollback(); // rollback the transaction </code></pre> <p>or:</p> <pre><code>currentTransaction.Rollback(); </code></pre> <p>If you rollback the transaction you should immediately close and discard the current session to ensure that NHibernate's internal state is consistent.</p> <h2>Closing the ISession</h2> <p>A call to <code>ISession.Close()</code> marks the end of a session. The main implication of Close() is that the ADO.NET connection will be relinquished by the session.</p> <pre><code>tx.Commit(); sess.Close(); sess.Flush(); currentTransaction.Commit(); sess.Close(); </code></pre> <p>If you provided your own connection, <code>Close()</code> returns a reference to it, so you can manually close it or return it to the pool. Otherwise <code>Close()</code> returns it to the pool.</p> </blockquote>
<p>Here are two examples of my code where it would fail without session.Flush():</p> <p><a href="http://www.lucidcoding.blogspot.co.uk/2012/05/changing-type-of-entity-persistence.html" rel="nofollow noreferrer">http://www.lucidcoding.blogspot.co.uk/2012/05/changing-type-of-entity-persistence.html</a></p> <p>at the end of this, you can see a section of code where I set identity insert on, save the entity then flush, then set identity insert off. Without this flush it seemed to be setting identity insert on and off then saving the entity. </p> <p>The use of Flush() gave me more control over what was going on.</p> <p>Here is another example:</p> <p><a href="https://stackoverflow.com/questions/12494943/sending-nservicebus-message-inside-transactionscope">Sending NServiceBus message inside TransactionScope</a></p> <p>I don't fully understand why on this one, but Flush() prevented my error from happening.</p>
6,492
<p>So we're trying to set up replicated repositories using PlasticSCM, one in the US, and one in Australia and running into a bit of a snag.</p> <p>The US configuration is Active Directory, the AU configuration is User/Password. This in itself is not a big deal, I've already set up the SID translation table. </p> <p>The problem is with plasticscm's replicate command itself. This is the command which should replicate from the US to AU, run ON the AU server.</p> <pre><code>cm replicate br:/main@rep:default@repserver:US:8084 rep:myrep@repserver:AU:9090 --trmode=name --trtable=trans.txt --authdata=ActiveDirectory:192.168.1.3:389:john.doe@factory.com:fPBea2rPsQaagEW3pKNveA==:dc=factory,dc=com </code></pre> <p>The part I'm stuck at is the authdata part (the above is an EXAMPLE only). How can I generate the obscured password? I think it's the only thing preventing these two repositories from talking to each other.</p>
<p>Ok, I've solved my own problem.<br> To get that "authdata" string, you need to configure your client to how you need to authenticate.<br> Then navigate to c:[users directory][username]\Local Settings\Application Data\plastic.<br> Pick up the client.conf and extract the string from the SecurityConfig element in the XML.</p>
<p>Check the new GUI <a href="http://www.plasticscm.com/demos/distributed_intro/distributed_intro.html" rel="nofollow noreferrer">here</a>. It's a little bit easier.</p>
5,090
<p>In a C# Windows Forms application I want to detect if another instance of the application is already running. If so, activate the main form of the running instance and exit this instance.</p> <p>What is the best way to achieve this?</p>
<p>Scott Hanselman <a href="http://www.hanselman.com/blog/TheWeeklySourceCode31SingleInstanceWinFormsAndMicrosoftVisualBasicdll.aspx" rel="noreferrer">answers</a> on you question in details.</p>
<p>Aku, that is a good resource. I answered a question similar to this one a while back. You can check my <a href="https://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application#19326">answer here</a>. Even though this was for WPF, you can use the same logic in WinForms.</p>
7,512
<pre><code>&gt;&gt;&gt; import time &gt;&gt;&gt; time.strptime("01-31-2009", "%m-%d-%Y") (2009, 1, 31, 0, 0, 0, 5, 31, -1) &gt;&gt;&gt; time.mktime((2009, 1, 31, 0, 0, 0, 5, 31, -1)) 1233378000.0 &gt;&gt;&gt; 60*60*24 # seconds in a day 86400 &gt;&gt;&gt; 1233378000.0 / 86400 14275.208333333334 </code></pre> <p><code>time.mktime</code> should return the number of seconds since the epoch. Since I'm giving it a time at midnight and the epoch is at midnight, shouldn't the result be evenly divisible by the number of seconds in a day?</p>
<p>Short answer: Because of timezones.</p> <p>The Epoch is in UTC.</p> <p>For example, I'm on IST (Irish Standard Time) or UTC+1. <a href="https://docs.python.org/3/library/time.html#time.gmtime" rel="nofollow noreferrer"><code>time.mktime()</code></a> is relative to my timezone, so on my system this refers to</p> <pre><code>&gt;&gt;&gt; time.mktime((2009, 1, 31, 0, 0, 0, 5, 31, -1)) 1233360000.0 </code></pre> <p>Because you got the result 1233378000, that would suggest that you're 5 hours behind me</p> <pre><code>&gt;&gt;&gt; (1233378000 - 1233360000) / (60*60) 5 </code></pre> <p>Have a look at the <a href="https://docs.python.org/3/library/time.html#time.gmtime" rel="nofollow noreferrer"><code>time.gmtime()</code></a> function which works off UTC.</p>
<p>Interesting. I don't know, but I did try this:</p> <pre><code>&gt;&gt;&gt; now = time.mktime((2008, 8, 22, 11 ,17, -1, -1, -1, -1)) &gt;&gt;&gt; tomorrow = time.mktime((2008, 8, 23, 11 ,17, -1, -1, -1, -1)) &gt;&gt;&gt; tomorrow - now 86400.0 </code></pre> <p>which is what you expected. My guess? Maybe some time correction was done since the epoch. This could be only a few seconds, something like a leap year. I think I heard something like this before, but can't remember exactly how and when it is done...</p>
4,197
<p>Is there an official convention for naming private fields in VB.NET? For example, if I have a property called 'Foo', I normally call the private field '_Foo'. This seems to be frowned upon in the <a href="http://msdn.microsoft.com/en-us/library/ms229012.aspx" rel="noreferrer">Offical Guidelines</a>:</p> <p>"Do not use a prefix for field names. For example, do not use g_ or s_ to distinguish static versus non-static fields."</p> <p>In C#, you could call the private field 'foo', the property 'Foo', and refer to the private field as 'this.foo' in the constructor. As VB.NET is case insensitive you can't do this - any suggestions?</p>
<p>I still use the _ prefix in VB for private fields, so I'll have _foo as the private field and Foo as the property. I do this for c# as well and pretty much any code I write. Generally I wouldn't get too caught up in "what is the right way to do it" because there isn't really a "right" way (altho there are some very bad ways) but rather be concerned with doing it consistently.</p> <p>At the end of the day, being consistent will make your code much more readable and maintainable than using any set of "right" conventions.</p>
<p>I agree with @lomaxx, it's more important to be consistent throughout the team than to have the <em>right</em> convention.</p> <p>Still, here are several good places to get ideas and guidance for coding conventions:</p> <ol> <li><a href="http://www.dotnet2themax.com/PracticalGuidelines.aspx" rel="nofollow noreferrer">Practical Guidelines and Best Practices for Microsoft Visual Basic and Visual C#</a> Developers by Francesco Balena is a great book that addresses many of these issues.</li> <li><a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;tabid=1" rel="nofollow noreferrer">IDesign Coding Standards</a> (for C# and for WCF)</li> <li>The .NET Framework <a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" rel="nofollow noreferrer">Source Code</a> (in VS2008)</li> </ol>
2,919
<p>Most of the guides I can find are just canned responses to specific questions. Instead I'm looking for something meant to teach good fundamental understanding and core needed skills. Beginner's guides are common in other hobbies but I am having trouble finding one for 3d printing.</p>
<p>Here's a brief outline I threw out in chat once. I'm marking this as a &quot;community Wiki&quot; answer so feel free to edit.</p> <p>It is not a full Primer, so should date better than a Word6.0 manual.</p> <hr /> <p>Start by reading the instructions that came with your printer. There's a high chance that some assembly is required, and if you get something wrong then things may nor work right later. Some brands come complete, some are better than others in this regard. Take your time.</p> <p>For most people, they spend the first couple of weeks failing prints for multiple reasons. For me it was bed levelling and getting the first layer-adhesion, and filament tension.</p> <p>So work on getting the bed levelled, work out how much gluestick or tape your filament needs to work, and what temperatures work in your environment.</p> <p>I use 210 °C on the hotend for PLA+ and 60 °C bed temp, though others get away with 190 °C on the hotend and 50 °C on the bed. My printer is in a garage though.</p> <p>Try and print a 20 mm cube or a benchy.</p> <p>After that, explore <a href="http://thingiverse.com" rel="nofollow noreferrer">http://thingiverse.com</a> or <a href="http://thangs.com" rel="nofollow noreferrer">http://thangs.com</a> looking for pre-made stuff that you would benefit from. Start small.</p> <p>The Grab Toy Infinite is a great starter - it's very forgiving about tolerances, and kids like it. Expect rough handling to break it.</p> <p>When you're happy printing other people's things, identify some needs of your own. In fact, make up a document / draught email / notepad of ideas of things to print. I add stuff to mine all the time.</p> <p>When you've got a need that no one else can fill, you can start designing your own item and do the whole</p> <pre><code>idea --&gt; ||: (re)design --&gt; implement --&gt; test --&gt; curse :|| success!! loop. </code></pre> <p>Many people bang on about expensive fancy software, but you can make a perfectly adequate part using <a href="http://tinkercad.com/" rel="nofollow noreferrer">http://tinkercad.com/</a> as a grounding.</p> <p>For example, I had too many spare hacksaw blades and none of the &quot;holders&quot; I could buy were perfect, nor even close. Here's my output:</p> <p><a href="https://www.tinkercad.com/things/9yQMmxRv4Lz-spare-hacksaw-blade-holder" rel="nofollow noreferrer">https://www.tinkercad.com/things/9yQMmxRv4Lz-spare-hacksaw-blade-holder</a></p> <p>Like many things in making, expect to fail and learn and do it again.</p> <p>Sometimes it looks like we buy printers to print things for the printers for printing things for the printers...repeat.</p> <p>Look for needs in your life and design something to fill them. It's most satisfying.</p> <p>There's a huge gap between Functional prints, which do a job, and pretty prints which are just to look nice.</p> <p>Functional things are great - you can therefore justify the cost of more printer upgrades. LOOK AT ALL THE MONEY WE SAVED!</p> <p>But overall enjoy yourself and the time you spend making things.</p>
<p>Thera are plenty of such guides. But from necessity they deal with specifics, there are too many things to cover otherwise.</p> <p>Multiple types of printers, multiple brands, multiple slicers, multiple ways of modelling etc,. With more all the time. Reading up on something that tells me how to model and slice in Freecad &amp; Creality, when I'm using Blender &amp; Cura is a waste of time.</p> <p>Generic instructions that apply to everything are so vague as to be essentially useless. (Plenty of those online though)</p>
2,143
<p>I know this will be a really obvious question to some people, but I have bricked about 3 boards doing this so I want to be certain before I brick a fourth. I don't have a lot of experience working with AC voltage, especially crimping / hacking it like what's going on here. Trust me it was my last resort to ask this.</p> <p>Basically, as a chamber heater I'm using some 120V heat lamps (here in the U.S.). The problem seems to be that when I connect my laptop to the board (if the laptop is plugged in, which it has to be for long-term serial control), sometimes I:</p> <ol> <li>Hear an electric shock sound -- the board is fried</li> <li>Don't hear an electric shock sound -- the board is fried, though</li> </ol> <p>What I interpret from this is that I'm stupidly wiring the 120V heat lamps incorrectly relative to my 3D printer board, such that when I connect it to my charging laptop via USB, the AC voltages are out of phase, causing my board to be fried. Alternatively, it's the 12V/24V power supply that's wired wrong relative to everything else, which also needs to be wired to the same polarity. <a href="https://i.stack.imgur.com/hPD8v.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hPD8v.png" alt="enter image description here"></a></p> <p>I was on the understanding that when crimping a three-wire male electrical cord:</p> <ol> <li>White = Neutral</li> <li>Black = Hot (or Load)</li> <li>Green = Ground</li> </ol> <p>... reinforced on the left side of the below image as well: </p> <p><a href="https://i.stack.imgur.com/HgeRE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HgeRE.png" alt="enter image description here"></a></p> <p>So, I know that much already. <strong>The question is</strong>, when I connect this AC outlet to a <a href="https://rads.stackoverflow.com/amzn/click/com/B00LW15D1M" rel="noreferrer" rel="nofollow noreferrer">relay</a> like this, I got <code>NO</code>, <code>COM</code>, <code>NC</code> on one side and <code>IN</code>, <code>DC+</code>, <code>DC-</code> on the other. Which wire goes to <code>COM</code>, and which goes to <code>D-</code>? The board uses <code>COM</code> to denote the voltage that is switched 'on' by the relay, and <code>D-</code> to denote whatever the shared ground is among, the 3D printer, heat lamp, printer board, etc... (For more info, see link to relay) <a href="https://i.stack.imgur.com/nuc81.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nuc81.png" alt="enter image description here"></a></p> <p>This 5V relay says it supports AC loads being managed by an arduino / 3D printer, so I was under the impression that I could connect the white wire to its <code>D-</code> pin (which also should receive the "GND" for my 3D printer board) and the black wire to its <code>COM</code> pin. However, what do I do about the green wire? Nothing? Also, was it wrong for me to assume it would support this function when the Arduino is connected to a charging laptop via USB?</p> <p>Basically, I just need to be sure that my laptop (3-prong), power supply (3-prong), heat lamps (2 or 3 prong) and relay (only 2-prong) all have matching polarities and don't cause an electric shock or fry my board. But I am getting really conflicting results and frying a lot of boards, probably by overthinking this. </p>
<p>In effect, the ground (from mains) does not need to be connected to the relay, the relay interrupts the "hot" or "neutral" (preferably the "hot", but that is not possible for all plugs, e.g. some European plugs can be inserted 180&deg; turned into the sockets). You connect one of the interrupted wires to the <code>COM</code>, the other interrupted wire (that goes to the lamps) to the <code>NO</code> (or the <code>NC</code>, depending on safety, the logic and/or preference). The ground wire from the mains power socket is not necessary at all (some lamp amratures require this to be connected though). See a schematic below, it uses an Arduino Uno, but you can think of it being the printer board. Note to never connect the ground from mains to the printer board directly!</p> <p><a href="https://i.stack.imgur.com/oKLoi.png" rel="nofollow noreferrer" title="Connecting lamp to relay"><img src="https://i.stack.imgur.com/oKLoi.png" alt="Connecting lamp to relay" title="Connecting lamp to relay"></a></p> <p><sub><a href="http://osoyoo.com/2017/08/28/arduino-lesson-1-channel-relay-module" rel="nofollow noreferrer">Image based on source: osoyoo.com</a></sub></p> <p>The logic (low voltage side of the relay) needs to be wired as follows:</p> <ul> <li><code>DC+</code> is the voltage power supply of the relay module, this is frequently +5&nbsp;V, but some modules use +3.3&nbsp;V (sometimes there is a jumper cap to select the voltage)</li> <li><code>DC-</code> is the ground from the printer board</li> <li><code>IN</code> is the trigger that needs to be connected to the port on the printer board that electronically switches the relay</li> </ul>
<p>Let's look at the notes on the relay first, as these tell us what to connect the terminals to.</p> <h2>Powered side</h2> <ul> <li><code>NO</code>/<code>NC</code> - Normally Open/Normally Closed lead. Which you use determines the switching behavior: open line on signal (NC) or closed line on signal (NO). Connect this to the powered component. <ul> <li>For heater components <strong>it is best to use NO</strong>, as a failure of a signal automatically stops heating, making this a safety means! If any of the supply wires are ripped or pulled from the terminals or the board is fried, the power of the heater doesn't come through.</li> </ul></li> <li><code>COM</code> - Common. This is the other lead of the switch part of the component, the line that transports the power to the switch. Connect this to the power supply.</li> </ul> <h2>Low Voltage signal side</h2> <ul> <li><code>IN</code> - Input. Here the switch signal goes in <ul> <li>This is a 5 V Signal</li> </ul></li> <li><code>DC+</code>/<code>DC-</code> - This is the power supply for the switch and should be the same as the power supply for the Board. Check your Rating! <ul> <li>Red "High" on DC+ </li> <li>Black "Low" on DC-</li> </ul></li> </ul> <p><a href="https://i.stack.imgur.com/lzuv9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lzuv9.png" alt="Wiring Diagram"></a></p> <p>Note I used European colors to differentiate the 5 V side from the mains-power side better. You have your Neutral in white, Phase in black, Ground in green on your Power Supply picture. This <a href="https://paladintech.files.wordpress.com/2014/10/2014-10-11-18.png" rel="nofollow noreferrer">color conversion</a> can be handy.</p> <p>If the heater lamp has a connection for the ground wire, use it! This should be the same ground wire the power supply is connected to, to ensure safety.</p>
1,500
<p>I've just done my <a href="https://www.thingiverse.com/thing:3709044" rel="nofollow noreferrer">first print</a> on an Ultimaker 3 Extended and I'm slightly disappointed with the results, so I'm trying to understand how I can do better next time.</p> <h2>My first print</h2> <p>Preparing for printing I naively just dropped the two <code>stl</code> files into Cura, set the recommended layer height and infill, selected support (defaulting to Extruder 1), deselected adhesion, ran the slice, saved the g-code and started the print running. Luckily the head 1 did have the same PLA AA 0.4 filament that Cura assumed.</p> <p>When the print finished, I stripped out the support structures, cleaning out the hollow, and cleaning off lots of stringy loose filaments between the lower support and the bottom edge of the print.</p> <p>Even after cleaning up though, the overhanging structure above the support structure turned out to be very rough with many individual filaments visible and in irregular positions, rather than the nice concentric lines in the slice.</p> <h2>My first attempt to optimise the print</h2> <p>Looking at the completed print I realised that there would have been only a fraction of the support structure, and probably clean edges, if the part had been oriented as a <code>d</code> rather than as a <code>p</code> (the rough surface being the bottom of the <code>p</code> overhang).</p> <p>I re-ran the slice in <code>d</code> orientation and that saved 10 minutes of print time, and a 100&nbsp;mm of filament, so I know I'll definitely need to look out for that in the future. I can also see how that would fix the problem with the external overhang separating out into loose threads, since that face would no longer be an overhang.</p> <h2>Trying to add water soluble supports</h2> <p>After the first fix, I wondered what I could do with the second extruder and realised that it was filled with water soluble PVA filament. This made me wonder if this would have helped with the internal overhang.</p> <p>I Configured Extruder 2 as PVA BB 0.4 and selected Extruder 2 for the support structures and re-ran the slice.</p> <p>I was surprised that the it was now taking 40 minutes longer and using almost 470&nbsp;mm more filament!</p> <p>Looking at the slices, Cura had created a huge PVA scaffolding on the <em>outside</em> of the print, leaving the inside, where the previous PLA support had been, completely empty:</p> <p><a href="https://i.stack.imgur.com/KXOTE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KXOTEm.png" alt="Print with PVA support"></a>vs.<a href="https://i.stack.imgur.com/ur5eG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ur5eGm.png" alt="Print with PLA support"></a></p> <p>This was not what I was expecting.</p> <h2>Questions</h2> <ul> <li><p>Why didn't the slicing algorithm place PVA support structures inside the overhang, in the same way as it placed the PLA support structures?</p></li> <li><p>What is the reason for the external scaffolding, and how does it help support the internal overhang, which now has no internal support at all?</p></li> <li><p>Is the behaviour I expected possible, advisable or configurable in Cura? If so, what options should I be looking at, if not is there other software that does support this?</p></li> </ul>
<p>Owning the Ultimaker 3 Extended and having printed kilometers of filament on this printer I can tell you that printing with PVA, apart from the slicing problems you mention, is not easy as it looks. PVA clogs up very fast and is very hygroscopic. Moist PVA will make popping sounds on extrusion and is prone to failing. PVA is not my preferred solution. An alternative solution is to use break-away filament, my colleagues have some reasonable good experience with that.</p> <blockquote> <p>Why didn't the slicing algorithm place PVA support structures inside the overhang, in the same way as it placed the PLA support structures?</p> </blockquote> <p>The difference you report could be caused by the slicer settings. I get exactly the same results if you set the slicing parameter <code>Support Placement</code> to <code>Touching Buildplate</code> (first image), or <code>Everywhere</code> (second image).</p> <p><a href="https://i.stack.imgur.com/AWlKOm.png" rel="nofollow noreferrer" title="`Support Placement` option `Touching Buildplate`"><img src="https://i.stack.imgur.com/AWlKOm.png" alt="&lt;code&gt;Support Placement&lt;/code&gt; option &lt;code&gt;Touching Buildplate&lt;/code&gt;" title="`Support Placement` option `Touching Buildplate`"></a>vs.<a href="https://i.stack.imgur.com/xHc76m.png" rel="nofollow noreferrer" title="`Support Placement` option `Everywhere`"><img src="https://i.stack.imgur.com/xHc76m.png" alt="&lt;code&gt;Support Placement&lt;/code&gt; option &lt;code&gt;Everywhere&lt;/code&gt;" title="`Support Placement` option `Everywhere`"></a></p> <blockquote> <p>What is the reason for the external scaffolding, and how does it help support the internal overhang, which now has no internal support at all?</p> </blockquote> <p>To answer the scaffolding part of your question, that can only be explained by being the decision of the developers. There must be very good reasons for doing it like this as a similar support structure is generated in other slicers, e.g. Slic3r (actually this is caused by a slicer setting, see <a href="/a/11006/">this answer</a> explaining why the scaffolding is caused). Some slicers do have options to change the support type, e.g. Slic3r has the option <code>pillars</code>, which creates pillars without external scaffolding:</p> <p><a href="https://i.stack.imgur.com/Gpzssm.png" rel="nofollow noreferrer" title="Slic3r pillars support option"><img src="https://i.stack.imgur.com/Gpzssm.png" alt="Slic3r pillars support option" title="Slic3r pillars support option"></a>vs.<a href="https://i.stack.imgur.com/pllIVm.png" rel="nofollow noreferrer" title="Slic3r rectangular support option"><img src="https://i.stack.imgur.com/pllIVm.png" alt="Slic3r rectangular support option" title="Slic3r rectangular support option"></a></p> <blockquote> <p>Is the behaviour I expected possible, advisable or configurable in Cura? If so, what options should I be looking at, if not is there other software that does support this?</p> </blockquote> <p>Playing with the settings to reduce the amount of PVA as suggested in the comments by enabling the type of extruder for specific parts of the extruder I was able to create a solution without scaffolding. This solution only uses PVA for the bottom and top layer of the support structure.</p> <p><a href="https://i.stack.imgur.com/edr4b.png" rel="nofollow noreferrer" title="Cura additional support extruder settings"><img src="https://i.stack.imgur.com/edr4b.png" alt="Cura additional support extruder settings" title="Cura additional support extruder settings"></a></p> <p>The shown settings<sup>1)</sup> produce a support structure with PVA top and bottom layers:</p> <p><a href="https://i.stack.imgur.com/1ysAhm.png" rel="nofollow noreferrer" title="Non scaffolding support structure"><img src="https://i.stack.imgur.com/1ysAhm.png" alt="Non scaffolding support structure" title="Non scaffolding support structure"></a>or<a href="https://i.stack.imgur.com/Zk35Cm.png" rel="nofollow noreferrer" title="Non scaffolding support structure in material color"><img src="https://i.stack.imgur.com/Zk35Cm.png" alt="Non scaffolding support structure in material color" title="Non scaffolding support structure in material color"></a></p> <p>Where the latter image is in material color; black PLA and natural colored PVA</p> <hr> <p><sup>1)</sup> <em>It might be worth mentioning that by default, the Support section doesn't show the Support interface extruder options and you have to go into Preferences and check the Setting Visibility option for those to appear.</em></p>
<blockquote> <p>What is the reason for the external scaffolding...?</p> </blockquote> <p>Reading through the <a href="https://ultimaker.com/en/resources/52663-support" rel="nofollow noreferrer">Ultimaker support page</a>, I discovered that there is a <em>Support horizontal expansion</em> option in the <em>Support</em> section of the Custom Profile.</p> <p>This appears to default to 0 mm for PLA, but defaults to 3 mm for PVA, which explains the difference in slicing behaviour.</p> <p>If I set <em>Support horizontal expansion</em> to 0 mm, then I get the support I originally expected:</p> <p><a href="https://i.stack.imgur.com/pAtNh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pAtNh.png" alt="Print with PVA support and Support horizontal expansion of 0"></a></p> <p>Ultimately though, the solution proposed by <a href="https://3dprinting.stackexchange.com/users/8884/trish">Trish</a> and detailed in <a href="https://3dprinting.stackexchange.com/users/5740/0scar">Oscar</a>'s <a href="https://3dprinting.stackexchange.com/a/11004/63">answer</a> using PVA just at the interfaces would be a <em>much</em> better solution, given the cost of PVA.</p>
1,465