instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>If I have a query like:</p> <pre><code>Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3) </code></pre> <p>and I have an index on the <code>EmployeeTypeId</code> field, does SQL server still use that index?</p>
<p>Yeah, that's right. If your <code>Employee</code> table has 10,000 records, and only 5 records have <code>EmployeeTypeId</code> in (1,2,3), then it will most likely use the index to fetch the records. However, if it finds that 9,000 records have the <code>EmployeeTypeId</code> in (1,2,3), then it would most likely just do a table scan to get the corresponding <code>EmployeeId</code>s, as it's faster just to run through the whole table than to go to each branch of the index tree and look at the records individually. </p> <p>SQL Server does a lot of stuff to try and optimize how the queries run. However, sometimes it doesn't get the right answer. If you know that SQL Server isn't using the index, by looking at the execution plan in query analyzer, you can tell the query engine to use a specific index with the following change to your query.</p> <pre class="lang-sql prettyprint-override"><code>SELECT EmployeeId FROM Employee WITH (Index(Index_EmployeeTypeId )) WHERE EmployeeTypeId IN (1,2,3) </code></pre> <p>Assuming the index you have on the <code>EmployeeTypeId</code> field is named <code>Index_EmployeeTypeId</code>. </p>
<pre><code>Select EmployeeId From Employee USE(INDEX(EmployeeTypeId)) </code></pre> <p>This query will search using the index you have created. It works for me. Please do a try.. </p>
5,147
<p>I'm able to successfully uninstall a third-party application via the command line and via a custom Inno Setup installer. </p> <p>Command line Execution:</p> <pre><code>MSIEXEC.exe /x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn </code></pre> <p>Inno Setup Command:</p> <pre><code>[Run] Filename: msiexec.exe; Flags: runhidden waituntilterminated; Parameters: "/x {{14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; StatusMsg: "Uninstalling Service..."; </code></pre> <p>I am also able to uninstall the application programmatically when executing the following C# code in debug mode.</p> <p>C# Code:</p> <pre><code>string fileName = "MSIEXEC.exe"; string arguments = "/x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; ProcessStartInfo psi = new ProcessStartInfo(fileName, arguments) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; Process process = Process.Start(psi); string errorMsg = process.StandardOutput.ReadToEnd(); process.WaitForExit(); </code></pre> <p>The same C# code, however, produces the following failure output when run as a compiled, deployed Windows Service: </p> <pre><code>"This action is only valid for products that are currently installed." </code></pre> <p>Additional Comments:</p> <ul> <li>The Windows Service which is issuing the uninstall command is running on the same machine as the code being tested in Debug Mode. The Windows Service is running/logged on as the Local system account. </li> <li>I have consulted my application logs and I have validated that the executed command arguments are thhe same in both debug and release mode.</li> <li>I have consulted the Event Viewer but it doesn't offer any clues.</li> </ul> <p>Thoughts? Any help would be greatly appreciated. Thanks.</p>
<p><strong>Step 1:</strong> <a href="https://stackoverflow.com/questions/15109/visual-studio-2005-setup-project-install-crashes-over-terminal-server#15286">Check the MSI error log files</a></p> <p>I'm suspicious that your problem is due to running as LocalSystem. </p> <p>The Local System account is not the same as a normal user account which happens to have admin rights. It has no access to the network, and its interaction with the registry and file system is quite different.</p> <p>From memory any requests to read/write to your 'home directory' or HKCU under the registry actually go into either the default user profile, or in the case of temp dirs, <code>c:\windows\temp</code></p>
<p>This is bizarre. LocalSystem definitely has the privileges to install applications (that's how Windows Update and software deployment in Active Directory work), so it should be able to uninstall as well.</p> <p>Perhaps the application is initially installed per-user instead of per-machine?</p>
7,927
<p>When attempting to compile my C# project, I get the following error:</p> <pre><code>'C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\CleanerMenu\obj\Debug\CSC97.tmp' is not a valid Win32 resource file. </code></pre> <p>Having gone through many Google searches, I have determined that this is usually caused by a 256x256 image inside an icon used by the project. I've gone through all the icons and removed the 256x256 versions, but the error persists. Any ideas on how to get rid of this?</p> <hr> <p>@Mike: It showed up mysteriously one night. I've searched the csproj file, but there's no mention of a CSC97.tmp (I also checked the solution file, but I had no luck there either). In case it helps, I've posted the <a href="http://pastebin.com/mcd2607b" rel="noreferrer">contents of the csproj file on pastebin</a>.</p> <p>@Derek: No problem. Here's the compiler output.</p> <pre><code>------ Build started: Project: Infralution.Licensing, Configuration: Debug Any CPU ------ Infralution.Licensing -&gt; C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\Infralution.Licensing\bin\Debug\Infralution.Licensing.dll ------ Build started: Project: CleanerMenu, Configuration: Debug Any CPU ------ C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /main:CleanerMenu.Program /reference:"C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\Infralution.Licensing\bin\Debug\Infralution.Licensing.dll" /reference:..\NotificationBar.dll /reference:..\PSTaskDialog.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:obj\Debug\Interop.IWshRuntimeLibrary.dll /debug+ /debug:full /optimize- /out:obj\Debug\CleanerMenu.exe /resource:obj\Debug\CleanerMenu.Form1.resources /resource:obj\Debug\CleanerMenu.frmAbout.resources /resource:obj\Debug\CleanerMenu.ModalProgressWindow.resources /resource:obj\Debug\CleanerMenu.Properties.Resources.resources /resource:obj\Debug\CleanerMenu.ShortcutPropertiesViewer.resources /resource:obj\Debug\CleanerMenu.LocalizedStrings.resources /resource:obj\Debug\CleanerMenu.UpdatedLicenseForm.resources /target:winexe /win32icon:CleanerMenu.ico ErrorHandler.cs Form1.cs Form1.Designer.cs frmAbout.cs frmAbout.Designer.cs Licensing.cs ModalProgressWindow.cs ModalProgressWindow.Designer.cs Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs Scanner.cs ShortcutPropertiesViewer.cs ShortcutPropertiesViewer.Designer.cs LocalizedStrings.Designer.cs UpdatedLicenseForm.cs UpdatedLicenseForm.Designer.cs error CS1583: 'C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\CleanerMenu\obj\Debug\CSC97.tmp' is not a valid Win32 resource file Compile complete -- 1 errors, 0 warnings ------ Skipped Build: Project: CleanerMenu Installer, Configuration: Debug ------ Project not selected to build for this solution configuration ========== Build: 1 succeeded or up-to-date, 1 failed, 1 skipped ========== </code></pre> <p>I have also uploaded the icon I am using. You can <a href="http://rowdypixel.com/tmp/CleanerMenu.ico" rel="noreferrer">view it here.</a></p> <hr> <p>@Mike: Thanks! After removing everything but the 32x32 image, everything worked great. Now I can go back and add the other sizes one-by-one to see which one is causing me grief. :)</p> <p>@Derek: Since I first got the error, I'd done a complete reinstall of Windows (and along with it, the SDK.) It wasn't the main reason for the reinstall, but I had a slim hope that it would fix the problem.</p> <p>Now if only I can figure out why it previously worked with all the other sizes...</p>
<p>I don't know if this will help, but from <a href="http://forums.msdn.microsoft.com/en-US/csharplanguage/thread/4217bec6-ea65-465f-8510-757558b36094/" rel="noreferrer">this forum</a>:</p> <blockquote> <p>Add an .ico file to the application section of the properties page, and recieved the error thats been described, when I checked the Icon file with an icon editor, it turn out that the file had more than one version of the image ie (16 x 16, 24 x 24, 32 x 32, 48 x 48 vista compressed), I removed the other formats that I didnt want resaved the file (just with 32x 32) and the application now compiles without error.</p> </blockquote> <p>Try opening the icon in an icon editor and see if you see other formats like described (also, try removing the icon and seeing if the project will build again, just to verify the icon is causing it).</p>
<p>Is this a file you created and added to the project or did it mysteriously show up?</p> <p>You can maybe check your .csproj file and see how it is being referenced (it should be a simple xml file and you can search for CSC97.tmp).</p> <p>Perhaps post the information you find so we can have more details to help solve your problem</p>
2,865
<p>I'm creating PDFs on-demand with ColdFusion's <a href="http://cfquickdocs.com/cf8/?getDoc=cfdocument" rel="nofollow noreferrer">CFDocument</a> tag, like so:</p> <pre><code>&lt;cfdocument format="PDF" filename="#attributes.fileName#" overwrite="true"&gt; &lt;cfdocumentitem type="footer"&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr&gt; &lt;td align="left"&gt;&lt;font face="Tahoma" color="black"&gt;&lt;strong&gt;My Client's Corporation&lt;/strong&gt;&lt;br/&gt;Street address&lt;br/&gt;City, ST 55555&lt;/font&gt;&lt;/td&gt; &lt;td align="right"&gt;&lt;font face="Tahoma" color="black"&gt;Phone: 555.555.5555&lt;br/&gt;Fax: 555.555.5555&lt;br/&gt;Email: info@domain.com&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/cfdocumentitem&gt; &lt;html&gt; &lt;body&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;!--- some content here ... ---&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;/cfdocument&gt; </code></pre> <p>The problem I'm having is that sometimes (actually, most of the time, but not always) <strong><em>some</em></strong> of the footer text is there, but invisible. I can highlight it and copy/paste it into notepad, where I can see it all -- but in the generated PDF only the first line of the left column of the footer is visible, the rest is invisible. Hence why I added the font color of black in the code.</p> <p><img src="https://i.stack.imgur.com/LHZ96.png" alt="screenshot of problem"></p> <p>Any ideas on how to correct this?</p>
<p>A PDF is what I'm after, so I'm not sure how outputting another format would help.</p> <p>As it turns out, the footer space just wasn't enough to fit all of this text; verified by the fact that changing the font size to 4pt would fit it all in without a problem.</p> <p>I spent some time attempting to rewrite the footer code using DDX <a href="http://www.coldfusionjedi.com/index.cfm/2008/6/2/Changing-the-size-of-a-footer-in-CFDOCUMENT" rel="nofollow noreferrer">as outlined here</a> and the <a href="http://cfquickdocs.com/cf8/?getDoc=cfpdf" rel="nofollow noreferrer">CFPDF</a> tag to implement it; but even after several hours of hacking away and finally getting a valid DDX as reported by the new <a href="http://cfquickdocs.com/cf8/?getDoc=IsDDX" rel="nofollow noreferrer">isDDX function</a>, the CFPDF tag reported that it was invalid DDX for some reason.</p> <p>At this point I decided I had wasted enough of the client's time/money and just reformatted the footer to be 2 lines of centered text, which was good enough.</p>
<p>Usually when PDF shows blank text, it's because the font metrics are embedded in the document, but the glyphs are not. I know nothing about ColdFusion, but you might try the following:</p> <ul> <li>Try a font other than Tahoma as a test. All PDF readers must support 14 basic fonts, including 4 Helvetica variants, 4 Times variants, 4 Courier variants, Symbol and ZapfDingbats, so those are always safe choices</li> <li>See if ColdFusion offers any control over font embedding</li> <li>Try a list of alternatives in your font declaration, like "Tahoma,Helvetica,sans-serif"</li> </ul>
4,621
<p>Does anyone know where online copies of the old <em>The Perl Journal</em> articles can be found?</p> <p>I know they are now owned by Dr. Dobb's, just the main page for it says they are part of whatever section the subject matter is relevant too, rather than being indexed together. That said, I have never been able to find any of them online on that site.</p> <p>I know Mark Jason Dominus has a few of his articles <a href="http://perl.plover.com/" rel="noreferrer">on his site</a>, any one know of any other good places? Or even what search terms to use at Dr. Dobb's?</p>
<p>Volumes 1-5 (1996 -> 2000) can be found at <a href="http://www.foo.be/docs/tpj/" rel="noreferrer">http://www.foo.be/docs/tpj/</a></p> <p>Hmm, looks like that was the entire run? I though it was longer than that for some reason.</p>
<p>Randal Schwartz's Perl Journal articles are linked from <a href="http://www.stonehenge.com/merlyn/PerlJournal/" rel="nofollow noreferrer"><a href="http://www.stonehenge.com/merlyn/PerlJournal/" rel="nofollow noreferrer">http://www.stonehenge.com/merlyn/PerlJournal/</a></a></p>
2,700
<p>Is it possible to handle POSIX signals within the Java Virtual Machine?</p> <p>At least <a href="http://en.wikipedia.org/wiki/SIGINT_(POSIX)" rel="noreferrer">SIGINT</a> and <a href="http://en.wikipedia.org/wiki/SIGKILL" rel="noreferrer">SIGKILL</a> should be quite platform independent.</p>
<p>The JVM responds to signals on its own. Some will cause the JVM to shutdown gracefully, which includes running shutdown hooks. Other signals will cause the JVM to abort without running shutdown hooks.</p> <p>Shutdown hooks are added using <a href="http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29" rel="noreferrer">Runtime.addShutdownHook(Thread)</a>.</p> <p>I don't think the JDK provides an official way to handle signals within your Java application. However, I did find <a href="http://www.ibm.com/developerworks/java/library/i-signalhandling/" rel="noreferrer">this IBM article</a>, which describes using some undocumented <code>sun.misc.Signal</code> class to do exactly that. The article dates from 2002 and uses JDK 1.3.1, but I've confirmed that the <code>sun.misc.Signal</code> class still exists in JDK 1.6.0.</p>
<p>Perhaps <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29" rel="nofollow noreferrer">Runtime#addShutdownHook</a> ?</p>
6,162
<p>My printer has been doing weird things lately. It used to print fine, but now it's like the Y or X axis after a certain percentage time. ie on a 24 hour print: it got off at 5 hours on a 42 print it got off at 16%</p> <p>Thoughts?</p>
<p>That depends on how much noise you have on your motor power supply ground. You definitely want the 100&nbsp;µF capacitor to have a good high frequency response. Motors turning on and off can be noisy, and that noise can cause false clock signals in your logic circuitry if you tie the grounds together. </p>
<p>That depends on how much noise you have on your motor power supply ground. You definitely want the 100&nbsp;µF capacitor to have a good high frequency response. Motors turning on and off can be noisy, and that noise can cause false clock signals in your logic circuitry if you tie the grounds together. </p>
1,342
<p><strong>How do you install svn 1.5 on debian etch?</strong> The svn 1.5 packages available for etch are 1.4 and I really need the cool new merge tracking feature in svn1.5 (according to CollabNet its as good as ClearCase...an interesting statement in oh so many ways). So, what's the least painful way to go?</p> <p>My options are:</p> <ul> <li>build it from source</li> <li>create my own debian package </li> <li>upgrade to a test version of Lenny </li> <li>find someone else's svn 1.5 package</li> </ul> <p>Which one have you chosen or which do you think has the least amount of suffering?</p>
<p>Have you considered <a href="http://wiki.debian.org/AptPinning" rel="nofollow noreferrer">pinning</a>? Basically, you can upgrade <em>some</em> of your system (i.e. just Subversion and its dependencies) to Lenny, while keeping the rest as Etch.</p>
<p>It depends on whether you want to be able to upgrade Subversion in future using Debian's package management tools. Building it from source should be easy enough, and lets you configure it the way you want, but then each time you want to upgrade, you'll need to build it from source again, rather than a simple apt-get.</p>
9,224
<p>What tools are available for metamodelling? </p> <p>Especially for developing diagram editors, at the moment trying out <a href="http://www.eclipse.org/modeling/gmf/" rel="nofollow noreferrer">Eclipse GMF</a></p> <p>Wondering what other options are out there? Any comparison available?</p>
<p>Your question is simply too broad for a single answer - due to many aspects.</p> <p>First, meta-modelling is not a set term, but rather a very fuzzy thing, including modelling models of models and reaching out to terms like MDA.</p> <p>Second, there are numerous options to developing diagram editors - going the Eclipse way is surely a nice option.</p> <p>To get you at least started in the Eclipse department:</p> <ul> <li>have a look at MOF, that is architecture for "meta-modelling" from the OMG (the guys, that maintain UML)</li> <li>from there approach EMOF, a sub set which is supported by the Eclipse Modelling Framework in the incarnation of Ecore.</li> <li>building something on top of GMF might be indeed a good idea, because that's the way existing diagram editors for the Eclipse platform take (e.g. Omondo's EclipseUML)</li> <li>there are a lot of tools existing in the Eclipse environment, that can utilize Ecore - I simply hope, that GMF builts on top of Ecore itself.</li> </ul>
<p>Although generally a UML tool, I would look at <a href="http://staruml.sourceforge.net/en/" rel="nofollow noreferrer">StarUML</a>. It supports <a href="http://staruml.sourceforge.net/en/modules.php" rel="nofollow noreferrer">additional modules beyond what are already built in</a>. If it doesn't have what you need built in or as a module, I supposed you could make your own, but I don't know how difficult that is.</p>
7,485
<p>When you use Visual Studio's code analysic (FxCop), and want to suppress a message there are 3 options.</p> <ol> <li>Suppress a violation in code.</li> <li>Suppress a violation in a GlobalSupression.cs file.</li> <li>Disable the violation check in the project file (via Project -> Properties -> Code Analysic).</li> </ol> <p>The later is very hard to review when checking in to Source Control, and it is hard to get an overview of all disabled violations. So we would like to use option 2.</p> <p>The problem with option 1 and 2 is that you get one suppression line for each violation. E.g like: </p> <pre><code>[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Company.Project.Namespace2")] [assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Company.Project.Namespace1")] </code></pre> <p>We would love to do something like this ing GlobalSuppressions.cs:</p> <pre><code>[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes")] </code></pre> <p>But is this possible?</p>
<p>Suppressing multiple violations with a single <strong>SuppressMessage</strong> attribute is officially not supported. Apparently, this is by design.</p> <p>I agree, it might be annoying at times, but I can't say I disagree with the decision, since the attribute is their way to force you to say, "Yes, I know what I am doing", which should be evaluated in a case-by-case basis.</p>
<p>I think things have changed since this question was posted and answered. For Visual Studio 2010 and 2012 you can create a custom "rule set" file where you can specify which code analysis rules you want to suppress. </p> <p><a href="http://msdn.microsoft.com/en-us/library/dd380660.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd380660.aspx</a></p> <p>So what I've done is to create a single custom rule set file which is in the top level folder of my repository source collection, and I reference this file in each Visual Studio project. This means I have one central place where I can suppress the code analysis rules that I simply can't stand. But if I ever change my mind, or decide I should reconsider my bad coding habits, I can very simply reenable the rule and see how many code analysis messages I get. </p>
9,844
<p>How can I achieve keeping the motors active during pause to avoid moving their position during filament changes? I have changed the filament during some prints to change the color or to change the a newer spool, but sometimes the X axis is moved during the change. I'm now using some cloth clips to prevent moving during this change. </p> <p>To pause the 3D printer I'm using the LCD menu ->pause, then I go to Move axis X, then I move close to 0. This change is manually and random since I don't know when the old filament reel is going to finish. The printer use Marlin as firmware with Ramps 1.4</p>
<p>Is <code>ADVANCED_PAUSE_FEATURE</code> enabled in your printers <code>configuration_adv.h</code> file? There is a <code>PAUSE_PARK_NO_STEPPER_TIMEOUT</code> option included in there, which prevents the steppers from timing out during a pause, and may be more robust than a G-Code command if you plan to manually pause and resume the print instead of setting it up in the slicer.</p> <p>Alternatively, in the same file,</p> <pre><code>#define DEFAULT_STEPPER_DEACTIVE_TIME 120 #define DISABLE_INACTIVE_X true #define DISABLE_INACTIVE_Y true #define DISABLE_INACTIVE_Z true // set to false if the nozzle will fall down on your printed part when print has finished. #define DISABLE_INACTIVE_E true </code></pre> <p>can be found. You may want to increase the <code>DEFAULT_STEPPER_DEACTIVE_TIME</code>, or set </p> <pre><code>#define DISABLE_INACTIVE_X true #define DISABLE_INACTIVE_Y true #define DISABLE_INACTIVE_Z true // set to false if the nozzle will fall down on your printed part when print has finished. </code></pre> <p>to <code>false</code> to keep X, Y and Z engaged while allowing movement of the extruder stepper only.</p>
<p>I have not tried this, but you could use the <code>M84 S0</code> command, this prevents the motors to go into an idle state.</p> <p>From the <a href="https://reprap.org/wiki/G-code#M84:_Stop_idle_hold" rel="nofollow noreferrer"><code>M84</code> G-code wiki</a> (firmware specific!):</p> <blockquote> <p>On <strong><em>Marlin</em></strong>, Repetier and RepRapFirmware, M84 can also be used to configure or disable the idle timeout. For example, <code>M84 S10</code> will idle the stepper motors after 10 seconds of inactivity. <code>M84 S0</code> will disable idle timeout; steppers will remain powered up regardless of activity.</p> </blockquote> <p>What rests is to implement this command into your G-code file to be executed during pause. Depending on the pause method you could introduce this command. I have not tried this, but you could put the command in your start G-code and test if the motors keep powered!</p> <p>Furthermore, <em>a specific filament change command is available for specific firmware applications</em>. This code, <a href="https://reprap.org/wiki/G-code#M600:_Filament_change_pause" rel="nofollow noreferrer"><code>M600</code></a>, can be used to change filament. From the <a href="http://marlinfw.org/docs/gcode/M600.html" rel="nofollow noreferrer">Marlin documentation</a> you can read (since you are using Marlin Firmware, you could use this G-code command):</p> <blockquote> <p>The <code>M600</code> command initiates the filament change procedure. The basic procedure will move the print head away from the print, eject the filament, wait for new filament to be inserted and the user to confirm, load and prime the filament, and continue with the print. <code>M600</code> may be initiated automatically if a filament runout sensor is installed.</p> </blockquote> <p>Please do note that in Marlin Firmware the <code>M600</code> command is only available when the comments before <code>//#define ADVANCED_PAUSE_FEATURE</code> in the advanced configuration options file <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration_adv.h" rel="nofollow noreferrer">Configuration_adv.h</a> are removed, hereby activating the command.</p>
1,069
<p>What is a <strong>non recursive</strong> algorithm for deciding whether a passed in amount can be built additively from a set of numbers.<br> In my case I'm determining whether a certain currency amount (such as $40) can be met by adding up some combination of a set of bills (such as $5, $10 and $20 bills). That is a simple example, but the algorithm needs to work for any currency set (some currencies use funky bill amounts and some bills may not be available at a given time).<br> So $50 can be met with a set of ($20 and $30), but cannot be met with a set of ($20 and $40). The non-recursive requirement is due to the target code base being for <code>SQL Server 2000</code> where the support of recursion is limited.<br> In addition this is for supporting a multi currency environment where the set of bills available may change (think a foreign currency exchange teller for example).</p>
<p>You have twice stated that the algorithm cannot be recursive, yet that is the natural solution to this problem. One way or another, you will need to perform a search to solve this problem. If recursion is out, you will need to backtrack manually.</p> <p>Pick the largest currency value below the target value. If it's match, you're done. If not, push the current target value on a stack and subtract from the target value the picked currency value. Keep doing this until you find a match or there are no more currency values left. Then use the stack to backtrack and pick a different value.</p> <p>Basically, it's the recursive solution inside a loop with a manually managed stack.</p>
<p><strong>Edit:</strong> The following will work <em>some</em> of the time. Think about why it won't work all the time and how you might change it to cover other cases.</p> <p>Build it starting with the largest bill towards the smallest. This will yeild the lowest number of bills.</p> <p>Take the initial amount and apply the largest bill as many times as you can without going over the price.</p> <p>Step to the next largest bill and apply it the same way.</p> <p>Keep doing this until you are on your smallest bill.</p> <p>Then check if the sum equals the target amount.</p>
9,030
<p>I'm currently working on upgrading a product for the Chinese market. The target is a ARMTDMI7 with a QVGA display. Most resources I've located on the net are targeted at desktop or web programming rather than embedded devices.</p> <ul> <li>Can anyone suggest some tools and resources that might be useful?</li> <li>What are the best techniques for extracting literal strings and communicating with translators?</li> </ul>
<p>I suggest looking at EasyGUI but that depends on what graphics controller you use.</p> <p>EasyGUI is a tool that simplifies design of user interfaces and comes with complete source code and driver for a varity of display controllers.</p> <p>For localization you can use EasyTranslate that gives the translater a graphical representation of the interface. This lets the translator see how the translated texts fit on the screen.</p> <p>EasyGUI is available with unicode support aswell as right to left script.</p>
<p>Freetype might be good for rendering fonts.</p> <p><a href="http://www.freetype.org/" rel="nofollow noreferrer">www.freetype.org</a></p>
7,743
<p>I copied some Delphi code from one project to another, and found that it doesn't compile in the new project, though it did in the old one. The code looks something like this:</p> <pre><code>procedure TForm1.CalculateGP(..) const Price : money = 0; begin ... Price := 1.0; ... end; </code></pre> <p>So in the new project, Delphi complains that "left side cannot be assigned to" - understandable! But this code compiles in the old project. So my question is, <strong>why</strong>? Is there a compiler switch to allow consts to be reassigned? How does that even work? I thought consts were replaced by their values at compile time?</p>
<p>You need to turn assignable typed constants on. Project -> Options -> Compiler -> Assignable typed Constants</p> <p>Also you can add <code>{$J+}</code> or <code>{$WRITEABLECONST ON}</code> to the pas file, which is probably better, since it'll work even if you move the file to another project.</p>
<p>Like Barry said, people took advantage of consts; One of the ways this was used, was for keeping track of singleton instances. If you look at a classic singleton implementation, you would see this :</p> <pre><code> // Example implementation of the Singleton pattern. TSingleton = class(TObject) protected constructor CreateInstance; virtual; class function AccessInstance(Request: Integer): TSingleton; public constructor Create; virtual; destructor Destroy; override; class function Instance: TSingleton; class procedure ReleaseInstance; end; constructor TSingleton.Create; begin inherited Create; raise Exception.CreateFmt('Access class %s through Instance only', [ClassName]); end; constructor TSingleton.CreateInstance; begin inherited Create; // Do whatever you would normally place in Create, here. end; destructor TSingleton.Destroy; begin // Do normal destruction here if AccessInstance(0) = Self then AccessInstance(2); inherited Destroy; end; {$WRITEABLECONST ON} class function TSingleton.AccessInstance(Request: Integer): TSingleton; const FInstance: TSingleton = nil; begin case Request of 0 : ; 1 : if not Assigned(FInstance) then FInstance := CreateInstance; 2 : FInstance := nil; else raise Exception.CreateFmt('Illegal request %d in AccessInstance', [Request]); end; Result := FInstance; end; {$IFNDEF WRITEABLECONST_ON} {$WRITEABLECONST OFF} {$ENDIF} class function TSingleton.Instance: TSingleton; begin Result := AccessInstance(1); end; class procedure TSingleton.ReleaseInstance; begin AccessInstance(0).Free; end; </code></pre>
7,137
<p>I have a problem in regards to filament jam, however I don't think that my case is any related to the extruder nozzle. After 30 to 40 minutes printing my filament bends and get stuck on the tube entrance. To print a nut wheel which comes as a demo file, I had to repeat the operation 4 times, and I had to stop printing when it got stuck, and continue with the printing, which led to a small imperfection. What's the problem? The filament? The printer? Myself? I have a Voxelab Aquila (completely new) and the filament u just a generic PLA from Amazon.</p> <p><a href="https://i.stack.imgur.com/SkWzF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SkWzF.jpg" alt="Filament jam" /></a> <a href="https://i.stack.imgur.com/Hs1qY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hs1qY.jpg" alt="Filament jam from another angle" /></a></p>
<p>Something is stopping the filament from going down the tube 30 to 40 min. after you start printing. You are correct that this doesn't sound like a clogged nozzle. It could be deformed filament, but the closeness of the timing after the start sounds like heat creep. Other possibilities are also listed at the linked stackexchange article.</p> <p>Note: with heat creep the filament will not jam in the tube. It will jam just above the nozzle on a Bowden tube extruder; thus the filament stops going down the tube. The tube entrance is probably the largest location the tube can kink, although not very large.</p> <p><a href="https://3dprinting.stackexchange.com/questions/15629/what-are-ways-to-avoid-heat-creep">What are ways to avoid heat creep?</a></p>
<p>You need a better filament quality I have the same printer and I had switched to Overture. Know use PLA Plus or (PLA+)due to not sticking to the bed well enough and your issue. And this issue may be the way the entire module moves up and down the threads may need better positioning like tighten loosen or even level it out check for a bend.</p>
1,921
<p>Certainly there's the difference in general syntax, but what other critical distinctions exist? There are <em>some</em> differences, right?</p>
<p>The linked comparisons are very thorough, but as far as the main differences I would note the following:</p> <ul> <li><strike>C# has anonymous methods</strike>VB has these now, too</li> <li><strike>C# has the yield keyword (iterator blocks)</strike>VB11 added this</li> <li>VB supports <a href="http://smartypeeps.blogspot.com/2006/06/late-binding-in-c-and-vbnet.html" rel="noreferrer">implicit late binding</a> (C# has explicit late binding now via the dynamic keyword)</li> <li>VB supports XML literals</li> <li>VB is case insensitive</li> <li>More out-of-the-box code snippets for VB</li> <li><Strike>More out-of-the-box refactoring tools for C#</strike>Visual Studio 2015 now provides the same refactoring tools for both VB and C#.</li> </ul> <p>In general the things MS focuses on for each vary, because the two languages are targeted at very different audiences. <a href="http://blogs.msdn.com/ericlippert/archive/2004/03/02/cargo-cultists-part-three-is-mort-a-cargo-cultist.aspx" rel="noreferrer">This blog post</a> has a good summary of the target audiences. It is probably a good idea to determine which audience you are in, because it will determine what kind of tools you'll get from Microsoft.</p>
<p>When it gets to IL its all just bits. That case insensitivity is just a precompiler pass. But the general consensus is, vb is more verbose. If you can write c# why not save your eyes and hands and write the smaller amount of code to do the same thing.</p>
3,272
<p>I'm considering removing the driver motor from the extruder assembly, and placing it on a stationary mount point instead, and then using a flex-shaft type connector from the motor to the extruder assembly to actually drive the extruder. The motivation for this change is to reduce the overall weight of the extruder driver and hot end assembly, allowing for quicker movement of the carriage on it's associated axis(one of X,Y).</p> <p>Would it be better to run a pair of drivers (one for each direction) to manage reversing the filament pressure or would it be better to use just one driver and reverse the motor as usual?</p>
<p>Very cool idea, </p> <p>One motor would definitely be more than capable of producing the required torques even through a flexshaft connector. For any normal sized 3D-printer the torques required, and the speeds you'll need for rapid response are well within the capabilities of any off-the-shelf stepper motor. </p> <p>Just a note on the idea though, with a normal, 'rigid', connection there is essentially no winding or unwinding, and only the backlash between the gears and the filament to consider, and that is effectively zero. With a flex-shaft though, the stack-up of twists and flexing will be much greater. The system will require more rotations at the source to effect the same amount of torque at the end effector as the flex shaft flexes and bends under the load. For tiny torques with short flex shafts, this wont be an issue as filament pressure is pretty minimal. But if you scale up this project or start working at much higher speeds, you may run into some issues with this design. </p> <p>I have no idea how big or fast you'd need to be working at for this to begin to become a problem. I'm imagining pretty big though. Just something you might want to keep in mind if you try turning this into a huge, super fast 3D-printer.</p>
<p>If you're talking about a common 3D printer stepper motor and driver, then one driver is perfectly capable of driving the motor both forward and backward.</p> <p><strike>The flex tube setup you describe sounds like a <a href="https://en.wikipedia.org/wiki/Bowden_cable" rel="nofollow noreferrer">Bowden extruder</a></strike>.</p>
563
<p>I've been developing a "Form Builder" in Javascript, and coming up to the part where I'll be sending the spec for the form back to the server to be stored. The builder maintains an internal data structure that represents the fields, label, options (for select/checkbox/radio), mandatory status, and the general sorting order of the fields.</p> <p>When I want to send this structure back to the server, which format should I communicate it with?</p> <p>Also, when restoring a server-saved form back into my Javascript builder, should I load in the data in the same format it sent it with, or should I rebuild the fields using the builder's <code>createField()</code> functions?</p>
<p>When making and processing requests with JavaScript, I live and breath <a href="http://json.org/" rel="noreferrer">JSON</a>. It's easy to build on the client side and there are tons of parsers for the server side, so both ends get to use their native tongue as much as possible. </p>
<p>I'd implement some sort of custom <code>text serialization</code> and transmit plain text. As you say, you can rebuild the information doing the reversed process.</p>
3,725
<p>The image below I indicated where the point where the tip of my extruder returns after changing the layer height, I don't know if I am right to call this point &quot;Start Point&quot; ...</p> <p><a href="https://i.stack.imgur.com/mZmgC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mZmgC.jpg" alt="enter image description here" /></a></p> <p>The problem I am having is possible to see in the photo, because there is a slip of material and sometimes &quot;webs&quot; are created that compromise the quality of the print.</p> <p>I tried to modify the retraction parameters, such as: speed and retraction length ...</p> <p>Is there a parameter that I can modify to improve my print?</p> <p>The slicer software I use is the : FlashPrint_4.5.1 (because I have a FlashForge Dreamer NX)</p>
<p>Photo interpretation: I understand that the image on the right presents the actual error: it happens on many layers, following the red &quot;Starting Point&quot; line (so above it on the photo). Interesting issue. Btw. which side of the print is the bottom (zero layer)? - I believe the left side, and the right side is the top of the print.</p> <p>The problem seems to apeear only in the middle of print. Top and bottom layers are usually printed slower, this could be some hint to find the reason. Also, I guess that the vertical cross section is not just a rectangle, but is wider on the top part? - then print parameters (e.g. speed) may change because of overhangs.</p> <p>Could you share what type of filament do you print with? For example flexible materials will specifically react to the pressure and should not be forcefully retracted and pushed. What type</p> <p>Is there any exccessive material anywhere on the table? Like oozing or stringing? Do you see any material lost before printing the first layer? If not, the retraction is good enough or even too heavy - then try to minimize it: you may go down until you see any oozing, and then check the wall.</p> <p>Could you share what range of parameters you have tried- especially the speed and retraction values? Jerk and accelleration? Do you use coasting or other pressure affecting techniques?</p> <p>What is the hotend diameter? - the specs says 0.4 mm and the direct extruder. And (in comparision) what is the wall's line width for extrusion? What is the real width of this wall? (Is it properly sliced and reflected in G-Code? I advice to use G-Code viewer and inspect the details in given area.) What is the infill %, and how many wall lines do you have configured? And the layer height?</p> <p>I hope this is of some help for diagnosis.</p>
<p>Photo interpretation: I understand that the image on the right presents the actual error: it happens on many layers, following the red &quot;Starting Point&quot; line (so above it on the photo). Interesting issue. Btw. which side of the print is the bottom (zero layer)? - I believe the left side, and the right side is the top of the print.</p> <p>The problem seems to apeear only in the middle of print. Top and bottom layers are usually printed slower, this could be some hint to find the reason. Also, I guess that the vertical cross section is not just a rectangle, but is wider on the top part? - then print parameters (e.g. speed) may change because of overhangs.</p> <p>Could you share what type of filament do you print with? For example flexible materials will specifically react to the pressure and should not be forcefully retracted and pushed. What type</p> <p>Is there any exccessive material anywhere on the table? Like oozing or stringing? Do you see any material lost before printing the first layer? If not, the retraction is good enough or even too heavy - then try to minimize it: you may go down until you see any oozing, and then check the wall.</p> <p>Could you share what range of parameters you have tried- especially the speed and retraction values? Jerk and accelleration? Do you use coasting or other pressure affecting techniques?</p> <p>What is the hotend diameter? - the specs says 0.4 mm and the direct extruder. And (in comparision) what is the wall's line width for extrusion? What is the real width of this wall? (Is it properly sliced and reflected in G-Code? I advice to use G-Code viewer and inspect the details in given area.) What is the infill %, and how many wall lines do you have configured? And the layer height?</p> <p>I hope this is of some help for diagnosis.</p>
1,819
<p>This question is the other side of the question asking, "<a href="https://stackoverflow.com/questions/11/how-do-i-calculate-relative-time">How do I calculate relative time?</a>".</p> <p>Given some human input for a relative time, how can you parse it? By default you would offset from <code>DateTime.Now()</code>, but could optionally offset from another <code>DateTime</code>.</p> <p>(Prefer answers in C#)</p> <p>Example input:</p> <ul> <li>"in 20 minutes"</li> <li>"5 hours ago"</li> <li>"3h 2m"</li> <li>"next week"</li> </ul> <p><strong>Edit:</strong> Let's suppose we can define some limits on the input. This sort of code would be a useful thing to have out on the web.</p>
<p>That's building a DSL (Domain specific language) for date handling. I don't know if somebody has done one for .NET but the construction of a DSL is fairly straightforward:</p> <ol> <li>Define the language precisely, which input forms you will accept and what will you do with ambiguities</li> <li>Construct the grammar for the language</li> <li>Build the finite state machine that parses your language into an actionable AST</li> </ol> <p>You can do all that by yourself (with the help of <a href="http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools" rel="nofollow noreferrer">the Dragon Book</a>, for instance) or with the help of tools to the effect, as shown in this <a href="http://www.codeproject.com/KB/recipes/YourFirstDSL.aspx" rel="nofollow noreferrer">link</a>.</p> <p>Just by thinking hard about the possibilities you have a good chance, with the help of good UI examples, of covering more than half of the actual inputs your application will receive. If you aim to accept everything a human could possibly type, you can record the input determined as ambiguous and then add them to the grammar, whenever they can be interpreted, as there are things that will be inherently ambiguous.</p>
<p>This: <a href="http://www.codeproject.com/KB/edit/dateparser.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/edit/dateparser.aspx</a> Is fairly close to what you are trying to accomplish. Not the most elegant solution, but certainly might save you some work.</p>
7,919
<p>From <a href="http://blog.stackoverflow.com/2010/07/the-7-essential-meta-questions-of-every-beta/">The 7 Essential Meta Questions of Every Beta</a>:</p> <hr /> <h2>What should our documentation contain?</h2> <p>Much of the sites documentation will be the same as on every other Stack Exchange site: “be nice,” “how to create an account,” “how to ask questions” — it’s all pretty static. Even the sections about “what kind of questions should I (not) ask here?” comes primarily from <a href="http://area51.stackexchange.com/faq#questions">the Definition phase of Area 51</a>.</p> <p>But the questions you want to discuss in meta are those issues specific to your site that need to be mentioned in the Help Center.</p> <p>Take the <a href="https://superuser.com/faq">Super User &quot;About&quot; page</a> as an example:</p> <blockquote> <p>Super User is for computer enthusiasts and power users.</p> <p>Ask about...</p> <ul> <li>Specific issues with computer software, hardware or networking</li> <li>Real problems or questions that you’ve encountered</li> </ul> <p>Don't ask about...</p> <ul> <li>Anything not directly related to computer software or computer hardware</li> <li>Questions that are primarily opinion-based</li> <li>Questions with too many possible answers or require an extremely long answer</li> <li>Videogames, consoles, or other electronic devices, unless they connect to your computer</li> <li>Websites or web services like Google, Facebook, Twitter, and WordPress</li> <li>Shopping, buying or product recommendations</li> <li>Issues specific to corporate IT support and networks</li> </ul> </blockquote> <p>These are then elaborated on in SU's <a href="https://superuser.com/help/on-topic">What topics can I ask about here?</a> page.</p> <p>It took almost a year to figure out the list of “we want these sort of questions” and “we don’t want these sort of questions” on Super User. Area 51 gave you a head start but you should also be working out other FAQ-related issues <strong>specific to your topic and your community</strong>.</p>
<h1>Do worry about it (at least a little bit).</h1> <p>We need to have at least a rough idea of what is on and off topic to know what the site will be about. Without a least some discussion on this how will mods know when a question needs to be closed? Thats not to say that nothing will change or that we can't refine our thoughts on this but getting a rough draft wouldn't be the worst thing.</p> <p>Taking the Super User example, we could consider at least a few things, something like this, for example,</p> <h2>On topic for 3D Printing</h2> <ul> <li>Specific issues with a 3D printer (e.g. My 3D printer keeps failing prints)</li> <li>Real problems or questions you have (e.g. How do I level my 3D printer)</li> </ul> <h2>Off Topic</h2> <ul> <li>Anything not related to 3D printing</li> <li>Opinion based questions (e.g. Which is the better 3D printer?)</li> <li>Shopping, buying and product recommendations </li> <li>Questions with too many possible answers or require an extremely long answer</li> </ul> <h2>Things that we need to decide on</h2> <ul> <li>Legal questions (e.g. Can I 3D print a gun)</li> <li>Software questions (e.g. questions about Blender for making 3D models specifically to print, on topic or defer to the Blender Stack Exchange site)</li> </ul> <p>This is just a sample of some things I can think of, off the top of my head. </p>
<h1>Don't worry about this.</h1> <p>Before you worry about what you're Tour Page, Help Center... and stop is going to contain, you <em>first need to figure out what your site is about</em>. Make sure that you explain every close vote, discuss every controversial question, and so on. If you don't know the details of your scope, documentation should be the last of your worries.</p>
3
<p>I would like to move a file or folder from one place to another within the same repository without having to use Repo Browser to do it, and without creating two independent add/delete operations. Using Repo Browser works fine except that your code will be hanging in a broken state until you get any supporting changes checked in afterwards (like the .csproj file for example).</p> <p>Update: People have suggested "move" from the command line. Is there a TortoiseSVN equivalent?</p>
<p>To move a file or set of files using <code>Tortoise SVN</code>, right-click-and-drag the target files to their destination and release the right mouse button. The popup menu will have a <code>SVN move versioned files here</code> option.</p> <p><strong>Note that the destination folder must have already been added to the repository for the <code>SVN move versioned files here</code> option to appear.</strong></p>
<p>Use the <code>svn move</code> command to move file/folder.</p>
8,806
<p>Let's say I'm creating a chess program. I have a function</p> <pre><code>void foreachMove( void (*action)(chess_move*), chess_game* game); </code></pre> <p>which will call the function pointer action on each valid move. This is all well and good, but what if I need to pass more parameters to the action function? For example:</p> <pre><code>chess_move getNextMove(chess_game* game, int depth){ //for each valid move, determine how good the move is foreachMove(moveHandler, game); } void moveHandler(chess_move* move){ //uh oh, now I need the variables "game" and "depth" from the above function } </code></pre> <p>Redefining the function pointer is not the optimal solution. The foreachMove function is versatile and many different places in the code reference it. It doesn't make sense for each one of those references to have to update their function to include parameters that they don't need.</p> <p>How can I pass extra parameters to a function that I'm calling through a pointer?</p>
<p>Ah, if only C supported closures...</p> <p>Antonio is right; if you need to pass extra parameters, you'll need to redefine your function pointer to accept the additional arguments. If you don't know exactly what parameters you'll need, then you have at least three choices:</p> <ol> <li>Have the last argument in your prototype be a void*. This gives you flexibility of passing in anything else that you need, but it definitely isn't type-safe.</li> <li>Use variadic parameters (...). Given my lack of experience with variadic parameters in C, I'm not sure if you can use this with a function pointer, but this gives even more flexibility than the first solution, albeit still with the lack of type safety.</li> <li>Upgrade to C++ and use <a href="http://en.wikipedia.org/wiki/Function_object" rel="noreferrer">function objects</a>.</li> </ol>
<p>+1 to Antonio. You need to change your function pointer declaration to accept additional parameters.</p> <p>Also, please don't start passing around void pointers or (especially) arrays of void pointers. That's just asking for trouble. If you start passing void pointers, you're going to also have to pass some kind of message to indicate what the pointer type is (or types are). This technique is <em>rarely</em> appropriate.</p> <p>If your parameters are always the same, just add them to your function pointer arguments (or possibly pack them into a struct and use that as the argument if there are a lot of parameters). If your parameters change, then consider using multiple function pointers for the multiple call scenarios instead of passing void pointers.</p>
3,248
<p>I made some 3D printed supports for tools, using screws to fix it to the wall, some of them broken because of the screw forces. Is there a way to reinforce only the screw holes where it will have more stress/compress? I am using PLA, Fusion 360 and Ultimaker Cura.</p>
<p>You can test different print settings. Trying to visualize, but I believe you can increase the <strong>perimeter lines</strong>, since there is a hole, this will increase the resistance in that area. Or try to change the <strong>orientation</strong> with which the part will be printed</p>
<p>You can use a washer between the screw head and the plastic material to distribute the load</p> <p>In my designs I also put in a depression to fit the washer so that it sits flush with the resultant surface. </p> <p><a href="https://i.stack.imgur.com/2Mh31.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Mh31.png" alt="Cad design with recessed washer holes"></a></p>
1,198
<p>I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional HTML IDs in the code. </p> <p>There is heavy use of <code>CssClass='&amp;hellip;'</code>, or sometimes just <code>class='&amp;hellip;'</code>, but I can't seem to find a way to say id='&hellip;' and not have it swapped out by the server.</p> <p>Here is an example:</p> <pre><code>&lt;span id='position_title' runat='server'&gt;Manager&lt;/span&gt; </code></pre> <p>When the response comes back from the server, I get:</p> <pre><code>&lt;span id='$aspnet$crap$here$position_title'&gt;Manager&lt;/span&gt;</code></pre> <p>Any help here?</p>
<p>The 'crap' placed in front of the id is related to the container(s) of the control and there is no way (as far as I know) to prevent this behavior, other than not putting it in any container. </p> <p>If you need to refer to the id in script, you can use the ClientID of the control, like so:</p> <pre><code>&lt;script type="text/javascript"&gt; var theSpan = document.getElementById('&lt;%= position_title.ClientID %&gt;'); &lt;/script&gt; </code></pre>
<p>.Net will always replace your id values with some mangled (every so slightly predictable, but still don't count on it) value. Do you really NEED to have that id runat=server? If you don't put in runat=server, then it won't mangle it...</p> <p>ADDED: Like leddt said, you can reference the span (or any runat=server with an id) by using ClientID, but I don't think that works in CSS.</p> <p>But I think that you have a larger problem if your CSS is using ID based selectors. You can't re-use an ID. You can't have multiple items on the same page with the same ID. .Net will complain about that.</p> <p>So, with that in mind, is your job of refactoring the CSS getting to be a bit larger in scope?</p>
9,076
<p>This snippet of Perl code in my program is giving the wrong result.</p> <pre><code>$condition ? $a = 2 : $a = 3 ; print $a; </code></pre> <p>No matter what the value of <code>$condition</code> is, the output is always 3, how come?</p>
<p>This is explained in the Perl <a href="http://perldoc.perl.org/perlop.html#Conditional-Operator" rel="noreferrer">documentation</a>.</p> <p>Because of Perl operator precedence the statement is being parsed as</p> <pre><code>($condition ? $a= 2 : $a ) = 3 ; </code></pre> <p>Because the ?: operator produces an assignable result, 3 is assigned to the result of the condition.</p> <p>When $condition is true this means ($a=2)=3 giving $a=3</p> <p>When $condition is false this means ($a)=3 giving $a=3</p> <p>The correct way to write this is</p> <pre><code>$a = ( $condition ? 2 : 3 ); print $a; </code></pre> <p>We got bitten by this at work, so I am posting here hoping others will find it useful.</p>
<p>One suggestion to Tithonium's answer above:</p> <p>If you are want to assign different values to the same variable, this might be better (the copy-book way): </p> <p>$a = ($condition) ? 2 : 3;</p>
3,047
<p>I currently have a print job that is about 50% done, been running for 2 hours with 2 hours remaining. One side is curling/warping pretty bad, and I'm afraid there's no possible way this is going to finish without serious problems if I don't intervene.</p> <p>So what I'm doing is either brilliant or idiotic, I'm not sure which: I've paused the print job, stuck some elmers glue below the curling part (with toothpicks, careful not to budge anything else), added a couple degrees to the heatbed (for pliability hopefully), put a small book on top of it to smash it on the glue and let it rest for a little bit (I'll report back if this was a horrible idea or not).</p> <p><strong>So my main quesiton:</strong> Is there any other techniques that you folks can recommend for a scenario like this? McGuyver'y techniques to repair your in-progress print jobs? Has anyone tried this technique I'm attempting and if so how successful was it?</p> <p>In case it matters, I have an ANET A8 and generally send my print jobs to Octoprint (Raspi) from Cura with a Octoprint plugin (Windows). Printing with PLA filament. I've done quite a few successful prints recently, but this is the first one that goes from corner-to-corner on the heatbed (<a href="https://www.thingiverse.com/thing:2189694" rel="nofollow noreferrer">this specifically</a>). Printing at 207c with 60c heatbed (bumped up to 64 while glue settles). It's in a cooler room of the house, and doesn't have an enclosure so I'm afraid the cool temp is affecting it.</p> <p>Thanks</p> <p>Edit, last maybe significant (or maybe not) details: printing on glass with glue stick applied to it - been doing it for weeks and works quite well for the most part. Also, printing on a raft.</p> <p>Edit, here are a few pics. Both are from the back of the printer looking forward. I have one cam almost exactly level with the glass so I can see the hot-end extrude filament and another one slightly above it. Sorry for the bad lighting. Also included screenshots of my slicer settings for this print. </p> <p>Btw, I've since resumed printing after glueing it down, so far so good - but as you can see in the first pic it may have some possible structural defects and still has a slight curl:</p> <p><a href="https://i.stack.imgur.com/B2sxA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B2sxA.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/3YhXj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3YhXj.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/KhMjG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KhMjG.png" alt="Slicer Settings"></a></p> <p><a href="https://i.stack.imgur.com/wVyqz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wVyqz.png" alt="Slicer Settings (pt2)"></a></p>
<p>Three thoughts:</p> <ol> <li>bed temperature</li> <li>rim width</li> <li>bonding agent</li> </ol> <p>Bed Temperature:</p> <p>Often the edges of a heated bed are not as hot as the center. Making the heat pass through an insulator (the glass) makes the temperature profile on the corners more relatively cool compared to the center than if you were printing directly on the aluminum bed.</p> <p>To offset that, you could:</p> <ol> <li>Increase the overall heated bed temperature.</li> <li>Wrap some insulation (such as ceramic felt) around the edge, keeping it out of the way of the print.</li> <li>Add insulation to the underside corners of the bed, to reduce heat loss.</li> </ol> <p>Rim Thickness:</p> <p>I see that you are using a rim. Since the rim was also pulling up, rather than the print pulling out of the rim, you might benefit from making the rim broader.</p> <p>Bonding Agent:</p> <p>It looks as if you are printing on blue tape, but that might be the picture. IME, gluestick and blue tape aren't often used together. If you are using only blue tape, the condition of the tape is critical. Any grease or rubbing of the tape (such as by resting your hand on the bed when making other prints) can reduce the holding power.</p> <p>If you haven't tried it yet, you might try printing PLA with the PVA (polyvinyl alcohol) gluestick. I use the "purple until dry" Elmers gluesticks with good results.</p>
<p>More glue to hold it down and lower in-fill percentage will reduce the warping. Or adding more cut-outs to the design like you have further up the shaft. </p>
724
<p>I'm looking for a methodology to easily measure/evaluate Z positioning accuracy, using equipment on hand or easily obtainable such as a high-precision digital caliper. In particular I want to be able to evaluate whether steps (actual motor steps, or some other chosen unit of increment) are uniformly the nominal step height, or whether some are larger than others, and if so whether the irregularity is reproducible. Has anyone worked out a way to attach a caliper or equivalent measurement device sufficiently rigidly to both a fixed point and a moving-in-Z point (e.g. the bed and the gantry on a typical cartesian machine) that the magnitude of individual steps can be read off? Or maybe a high precision laser range finder/interferometer solution is more appropriate, but I'm not sure about cost/availability.</p> <p>I ask this in the context of recurring concerns about a common overconstained Z axis design (Ender 3 and nearly everything else with V rollers), but this question is intended to be about measuring not mitigations/fixes.</p> <p>I'd also be interested in opinions on the necessary measurement precision for this measurement to be meaningful. Almost surely errors as small as 5% of the layer height will lead to some visual surface inconsistency, XY dimensional accuracy problems, and weak points for part to break at, which you'd need 10 micro resolution for 0.2 mm layers to see, but I suspect the reality is much worse for lots of printers and even 20 micron resolution or worse might aid in making serious improvements.</p>
<p>In the world of hobbyist milling machines, a DRO accessory is extremely valuable for improving work flow and accuracy of project builds. The Digital Read Out devices run the gamut from affordable to astonishingly expensive and cover one, two and three axis readouts.</p> <p>For single axis purposes, some hobbyists will simply find a means to attach a digital caliper, as you've suggested, to the machine with appropriately fabricated brackets. That's one option. For a few dollars more, there are off-the-shelf digital read-outs, such as this one from <a href="https://rads.stackoverflow.com/amzn/click/com/B01G4FQI64" rel="nofollow noreferrer" rel="nofollow noreferrer">Amazon</a>:</p> <p><a href="https://i.stack.imgur.com/VToWb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VToWb.png" alt="single axis DRO" /></a></p> <p>Six, twelve and twenty-four inch travel options are available with the pictured six inch unit priced at US$39.95, a reasonable figure for 0.01 mm accuracy.</p> <p>One can purchase pricier models with higher resolution if required.</p> <p>Brackets included with the device may not fit well to your application and may require modification.</p> <p>Some DRO devices, such as the one installed on my mini-mill, use physical contact (gears) to read the position information, which means friction and loading of your printer. Other models use micro-engraved glass scales and have minimal friction, but will likely be a bit more expensive.</p>
<p>What you ask is probably not easily doable: you want to measure distances with no more than 1 micron error!</p> <p>1 micron because assuming 2 mm leadscrew pitch and full steps only, you have 100 full steps per mm (10 microns per step). With 10% error at most you need to measure 1 micron.</p> <p>What you can do is avoiding measuring distances and rather measure angles to verify that angles are at least equally spaced.</p> <p>Place a mirror on the shaft of the stepper motor and align a laser and a paper sheet so that the laser reflects on the mirror and reaches a known position on the paper.</p> <p>Then mark the position of the spot after each step and, with trigonometry, you can calculate the real angle movement per step.</p> <p>You will need to repeat the alignment every time the laser gets outside the surface of the paper, but you can also use a wall if you prefer. In any case, to cover 360° you need at least 200 measurements...</p> <p>And obviously take into account measurement errors.</p>
1,774
<p><strong>I was wondering if this printer(daVinci 1.0) had the ability to print very small objects, like insects, coins, or small nuts. (About the size of 1 -2 cubic centimeters)</strong></p> <p><a href="http://us.xyzprinting.com/us_en/Product/da-Vinci-1.0-AiO" rel="nofollow">Here</a> is a link to the printer on the website.</p> <p>The reason I ask is someone asked me if it was able to, but I have not been able to access the actual 3-D printer for use at this time, just manuals which I have looked through.</p> <p><strong>So if the 3-D printer was able to print small objects, would a novice be able to do such a thing?</strong></p> <p>Please let me know if any additional details are needed. </p>
<p>1) If we're talking about FFF/FDM printers:</p> <p>Accuracy of the electronics and motors allows it, yes. But how FDM printers work it might be very hard to lay down layers of molten plastic so small as to preserve little details in the X and Y axis, not much of a problem doing 20 micron layer height though (Z resolution). Check this answer to find out what the X and Y resolution is and what it depends on: <a href="https://3dprinting.stackexchange.com/a/509/381">https://3dprinting.stackexchange.com/a/509/381</a></p> <p>You'll need both a small enough nozzle, as well as somehow cool the plastic because since the printed objects are so tiny the nozzle keeps contact with the surface surrounding it and heats it longer, which might melt the whole object or even char it.</p> <p>I've seen very few people do tiny prints with success. And the smallest nozzles I know are 250 micron. Not trying to dscourage you, just letting you know. If it was easy to do I think more people would be doing it and more companies would be advertising their printers as capable of such a thing</p> <p>So you'll have around 20 micron Z resolution and around maybe 200 in the X/Y. If that's enough for you, then you could try. Calibrating it all won't be easy, tiniest backlash will be noticeable.</p> <p>2) It's a lot easier with curing resin 3d printers (SLA or DLP). Most of them actually have trouble printing larger objects, ironically (trouble sticking to the bed and cracking of the 3d print). Even here badly calibrated lasers would prevent you from doing this and even many Form 1 users have reported their lasers being assembled poorly resulting in poor beam profile.</p> <p>Size of the laser beam profile (aka laser "spot size") is what determines the X/Y resolution for SLA 3d printers. With the Form 2 its 140 micron, unless you'll get a badly calibrated printer. For DLP printers it's easier, it's the resolution of the DLP projector divided from the size of the print area.</p>
<p>Strictly by looking at the technical specifications of an FDM printer, there are a few things to note regarding the <em>maximum print quality</em> you can expect to achieve:</p> <ul> <li>The <strong>minimum layer height</strong> - here given to be <em>0.1 mm</em></li> <li>The <strong>nozzle diameter</strong> - here given to be <em>0.4 mm</em></li> </ul> <h3>Minimum layer height:</h3> <p>On a finished print, the minimum layer height will affect how visible the horisontal lines of the print will be. Printing at a lower layer height can dramatically increase the smoothness of the finished part, while equally increasing the printing time - among several other things.</p> <p>A minimum layer height of 0.1 mm is fairly common for low-cost desktop FDM printers.</p> <h3>Nozzle diameter:</h3> <p>Just like the layer height defines the vertical resolution of a print, the nozzle diameter defines the sharpness of horizontal features of a print.</p> <p>When printing with a large nozzle diameter, all sharp edges and corners of the model will have a slight roundness to them: the larger the nozzle diameter, the more rounded sharp corners will be, and vice versa. You might think of it as making a detailed drawing with a blunt pencil.</p> <p>A nozzle diameter of 0.4 mm can perhaps be considered the standard for desktop FDM printers today, and will allow you to print &quot;fairly accurate&quot; parts.</p> <h3>Will the daVinci work for you?</h3> <p>Since I've never worked with the daVinci printer before, I cannot make a statement on it's user friendliness, or actual performance.</p> <p>In general, if you intend to use it to print fragile, complex models such as insects, I believe a resin based printer might be more right for you, since they typically will allow for much higher reproduction of details than FDM printers. Printing solid/compact structures like coins and nuts, on the other hand, can typically be handled by a well calibrated FDM printer.</p>
195
<p>We are working with an oracle database in which the person that set it up is "long gone" and thus do not know the sysdba password, but need it. We have root access to the box (its on linux). Is there any way to recover or change the sys passwords?</p>
<p>Have you tried logging into Linux as your installed Oracle user then</p> <pre><code>sqlplus "/ as sysdba" </code></pre> <p>When you log in you'll be able to change your password.</p> <pre><code>alter user sys identified by &lt;new password&gt;; </code></pre> <p>Good luck :)</p>
<p>You can connect to the database locally using the combination of environment variables:</p> <ul> <li><strong>ORACLE_HOME</strong> </li> <li><strong>ORACLE_SID</strong> .</li> </ul> <p>Depending on your <strong>OS</strong>:</p> <p><strong>Unix/Linux:</strong></p> <pre><code>export ORACLE_HOME=&lt;oracle_home_directory_till_db_home&gt; export PATH=$PATH:$ORACLE_HOME/bin export ORACLE_SID=&lt;your_oracle_sid&gt; SQLPLUS / AS SYSDBA </code></pre> <p><strong>Windows</strong></p> <pre><code>set ORACLE_HOME=&lt;oracle_home_path_till_db_home&gt; set PATH=%PATH%||%ORACLE_HOME%\bin set ORACLE_SID=&lt;your_oracle_sid&gt; SQLPLUS / AS SYSDBA </code></pre> <p>Once connected, you could then <strong>alter the user</strong> to <strong>modify the password</strong>:</p> <pre><code>ALTER USER username IDENTIFIED BY password; </code></pre>
7,549
<p>How do I prevent vim from replacing spaces with tabs when autoindent is on?</p> <p>An example: if I have two tabs and 7 spaces in the beginning of the line, and <code>tabstop=3</code>, and I press Enter, the next line has four tabs and 1 space in the beginning, but I don't want that...</p>
<p>It is perhaps a good idea not to use tabs at all.</p> <pre><code>:set expandtab </code></pre> <p>If you want to replace all the tabs in your file to 3 spaces (which will look pretty similar to <code>tabstop=3</code>):</p> <pre><code>:%s/^I/ / </code></pre> <p>(where <code>^I</code> is the <kbd>TAB</kbd> character)</p> <p>From the VIM online help:</p> <pre><code>'tabstop' 'ts' number (default 8) local to buffer Number of spaces that a &lt;Tab&gt; in the file counts for. Also see |:retab| command, and 'softtabstop' option. Note: Setting 'tabstop' to any other value than 8 can make your file appear wrong in many places (e.g., when printing it). There are four main ways to use tabs in Vim: 1. Always keep 'tabstop' at 8, set 'softtabstop' and 'shiftwidth' to 4 (or 3 or whatever you prefer) and use 'noexpandtab'. Then Vim will use a mix of tabs and spaces, but typing &lt;Tab&gt; and &lt;BS&gt; will behave like a tab appears every 4 (or 3) characters. 2. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use 'expandtab'. This way you will always insert spaces. The formatting will never be messed up when 'tabstop' is changed. 3. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use a |modeline| to set these values when editing the file again. Only works when using Vim to edit the file. 4. Always set 'tabstop' and 'shiftwidth' to the same value, and 'noexpandtab'. This should then work (for initial indents only) for any tabstop setting that people use. It might be nice to have tabs after the first non-blank inserted as spaces if you do this though. Otherwise aligned comments will be wrong when 'tabstop' is changed. </code></pre>
<p><a href="http://www.jwz.org/doc/tabs-vs-spaces.html" rel="nofollow noreferrer">Maybe the bottom of this can help you?</a></p> <blockquote> <p>Standard vi interprets the tab key literally, but there are popular vi-derived alternatives that are smarter, like vim. To get vim to interpret tab as an ``indent'' command instead of an insert-a-tab command, do this:</p> <pre><code>set softtabstop=2 </code></pre> </blockquote>
9,542
<h2>Question</h2> <p>What is PLA+? How is it different than PLA? I'm looking for science, composition, formula, safety concerns (or lack thereof), etc.</p> <h2>Background</h2> <p>I picked up a roll of PLA+ at Microcenter (their in-house Inland brand) because it was on clearance. I didn't even notice the "+" until I decided to try that color, and then I noticed it on the sticker. It prints well, feels like ABS, smells like PLA when printing, and I can use PLA temps on my printer. It sands better than PLA, and if I I hadn't noticed the PLA+ sticker, and the smell, <strong>I would think it was ABS</strong>. It will break its line into my printer like PLA does; ABS doesn't break if left alone. However, PLA+ lasts longer than regular PLA before breaking.</p> <h2>Getting info from the Internet</h2> <p>Aside from a few discussions on reddit (<a href="https://www.reddit.com/r/3Dprinting/comments/4iqzop/pla_vs_pla_short_review/" rel="noreferrer">review</a>, <a href="https://www.reddit.com/r/3Dprinting/comments/4huvoj/introducing_esun_pla_pro_pla/" rel="noreferrer">commercial introduction</a>), I can't find anything about it.</p> <h2>Getting info from the Manufacturer</h2> <p>I went back to Microcenter and the guy that was there working the 3d printing section did not know what I was talking about.</p> <p>I went to Microcenter another time and the guy in the filament area said that all of their PLA filament was now PLA+, and that the + meant it was to be used at a higher temperature. The boxes are labeled with 205 - 225°C. It seems that all the inland brand PLA I have is PLA+, save for the first roll I bought. It does not have any kind of temperature markings on it.</p> <h2>Flash forward 1.5+ years from the original question</h2> <p>This question got some recent attention, so I looked to find the answer again. I found <a href="https://all3dp.com/2/pla-vs-pla-3d-printer-filament-compared/" rel="noreferrer">this article</a>, which is a hot pile of !usefulness, giving no data, lots of opinion, and probably some direct insights from someone's marketing department.</p> <p><a href="http://forum.makergear.com/viewtopic.php?t=3345" rel="noreferrer">These guys</a> say it's good stuff, but nothing about the chemical or compositional difference between the two. When I find people talking about the difference (like on reddit), those are the details usually mentioned, which are vague, anecdotal, and opinionated, and could be clever marketing (could be, not guaranteed to be). One man's shiny is another man's matte for example.</p> <p><a href="https://monopricesupport.kayako.com/article/3-what-is-the-difference-between-the-filaments-offered" rel="noreferrer">Monoprice confirmed</a> what I already did by reading the label and printing with it, but does mention TPU, which might be <a href="https://en.wikipedia.org/wiki/Thermoplastic_polyurethane" rel="noreferrer">Thermoplastic polyurethane</a>. No quantity or proportion or anything, and since they're the only manufacturer/reseller to officially say this, I consider it unconfirmed. One of the answers below says that PLA+ probably includes TPU or something like it, but that's conjecture or opinion by their own admission. </p> <blockquote> <p>PLA+ is a variation of PLA that has added material in order to make the filament less brittle, have a smoother surface finish, and less likely to absorb moisture. Typically, TPU is added into the filament in order to achieve this property. PLA+ will have the feel and functionality of ABS without the smell. If you didn’t know better, you would think it was ABS. We suggest printing with PLA+ at 205 to 210 degrees Celsius and with a bed temperature of 45 degrees Celsius. PLA+ responds very well to blue painter’s tape and a glue stick to hold properly and not peel up when printing.</p> </blockquote> <p><a href="http://forum.makergear.com/viewtopic.php?t=1552" rel="noreferrer">These people</a> also ask what it is, but they're doing science about it circa 2014 to try to figure it out.</p> <p>I'm not sure what to think of <a href="https://duchofilla.com/product-category/filament/pla-plus/" rel="noreferrer">this manufacturer/seller's description</a>. It sounds like they are implying that PLA has a branding problem, so they added a plus to it for a new formula to fix their branding.</p> <blockquote> <p>PLA Plus is an enhanced version of our PLA that's less brittle and more durable. ‘Enhanced’ PLAs have a bad reputation, some are no better than PLA, some perform worse in some conditions. We’ve taken a different approach: our ‘regular’ PLA is regarded as the strongest pure PLA in the industry, it’s hard to improve on the best. But sometimes you need something a little more durable. Enter our specially formulated PLA Plus. Prints like PLA, but with better durability. Its available with their brighter color options!</p> </blockquote> <h2>Final thoughts</h2> <p>I find a lot of articles/posts talking about "eSun PLA+" specifically. I'm starting to think that this might be the OEM and that other companies are selling it with their own branding, but that all PLA+ comes from the same place. I found their <a href="http://www.esun3d.net/products/142.html" rel="noreferrer">product page</a>, and it says this, which mentions nothing about the formula:</p> <blockquote> <p>Characteristics:</p> <ul> <li>extracted and purified from corn grain;</li> <li>high rigidity, good glossiness and transparency;</li> <li>suitable for printing larger models;</li> <li>toughness is 2 times more than the PLA on the market;</li> <li>no wiredrawing problems, the surface of the printouts will be smoother and more delicate;</li> <li>no cracking problem.</li> </ul> </blockquote>
<p>Disclaimer: I am not affiliated with any linked brand or company, I just link to them for reference of the suggested print settings.</p> <h1>What is PLA?</h1> <p>PLA is, by its definition PolyLacticAcid, a polymer of entwined lactic acids. It is commonly made from fermenting starch - not via Type I (alcohol) but Type II (lactic acid) fermentation<sup><a href="https://3dprinting.stackexchange.com/users/12857/user77232">user77232</a>, <a href="https://en.wikipedia.org/wiki/Lactic_acid_fermentation" rel="noreferrer">Wikipedia</a></sup>. Chemically it looks like this:</p> <p><a href="https://i.stack.imgur.com/JFAww.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JFAww.png" alt="Structural formula of PLA" /></a></p> <p>It's relevant physical data for the pure material are a density of 1.210–1.430 g·cm<sup>−3</sup> and a melting point of 150 to 160 °C.<sup><a href="https://en.wikipedia.org/wiki/Polylactic_acid" rel="noreferrer">Wikipedia</a></sup>.</p> <p>Usually, PLA sold under just the name PLA contains, besides PLA, additives to change the color from transparent to whatever color one is printing at. This can change the standard printing temperature depending on the amount, size and shape of the pigments embedded (see below).</p> <p>Common Printing temperatures are listed by the manufacturers in the range of 185 to 210 °C. The color can have an influence on the printing temperature, especially for the difference between transparent and opaque filaments. While a heated bed is not strictly necessary, the bed temperature is usually quoted with 60 °C.</p> <p>I myself print most PLA filaments at 200 °C and 60 °C bed, but for noncolored transparent filament, I had better results using 190 °C.</p> <p>Note that not all PLA is just PLA! It is very likely that some PLA brands contain fillers and additives from the house without claiming to be a +-filament, indeed, additives precede the idea of PLA+, as the case with Tiertime PP3DP filaments will show.</p> <h3>The special Tiertime mixture</h3> <p>Since back in 2012 or earlier, ABS made by Tiertime includes some unknown compound (possibly PC) that alters the best-result print temperature from the &quot;normal&quot; 220 - 240 °C to the much higher but narrower 260 - 270 °C band. Why this is done is a mystery among 3d-printing enthusiasts, but it might be either to get rid of any color-dependency of the print results or to make it harder to use generic ABS. Fact is, that this temperature was matching what was set as the (then unchangeable) standard temperature in the <em>Up 1.1.7</em> software of that time.<sup><a href="https://www.tiertime.com/forum/viewtopic.php?t=8233" rel="noreferrer">Angus aka MakersMuse</a> &amp; <a href="https://www.tiertime.com/forum/viewtopic.php?t=8233" rel="noreferrer">Tiertime Forums</a></sup>. The higher temperature hasn't changed over the years<sup><a href="https://www.genie-online.de/product/3D-printer-ABS-filament-1x700g-1.75mm-Color-black/239" rel="noreferrer">Tiertime ABS</a></sup>. Indeed, the Tiertime PLA introduced in March 2014<sup><a href="https://www.tiertime.com/tiertime-now-offers-pla-for-up-series-printers/" rel="noreferrer">Tiertime</a></sup> is also quoted to print at higher temperatures than generic PLA, and had similarly a higher default temperature in the then updated UP-spftware<sup><a href="https://www.tiertime.com/dami/viewtopic.php?t=54665" rel="noreferrer">Tiertime Forums</a></sup>, though I found listings from 200<sup><a href="https://3dprintersuperstore.com.au/products/black-up-pla" rel="noreferrer">here</a> &amp; <a href="https://www.reprap-3d-printer.com/product/1234568364-pla-tiertime-official-natural" rel="noreferrer">here</a></sup> to 215 °C<sup><a href="https://www.3dmensionals.de/tiertime-pp3dp-up-pla-filament-1000g?number=PSUPP0030V" rel="noreferrer">here</a> under Technische Daten</sup>.</p> <p><strong>The modern <em>UP-Studio</em> software allows setting the temperature freely</strong><sup><a href="https://youtu.be/uCnNxc_U9cE?t=437" rel="noreferrer">Angus aka MakersMuse</a></sup>.</p> <h1>What is PLA+?</h1> <p>Now, what differs PLA from PLA+? Well, PLA+ is a <em>modified</em> PLA, which means that it has additives in it to alter its properties. What exactly is added depends extremely on the manufacturer, and no two PLA+ are the same.<sup><a href="https://all3dp.com/2/pla-vs-pla-3d-printer-filament-compared/" rel="noreferrer">all3dp</a></sup>.</p> <h1>What is the difference?</h1> <p>PLA+ has - but for a few degrees - the same printing temperature as standard PLA. In fact, the printing temperature difference between standard PLA from different brands is often larger than the difference between PLA and PLA+.</p> <p><a href="https://all3dp.com/2/pla-vs-pla-3d-printer-filament-compared/" rel="noreferrer">All3dp</a> claims, that most PLA+ would have a better surface finish than the PLA from the same brand. Because of the additives, they also usually print best at elevated temperature compared to PLA. Among various manufacturers, I saw 210–240 °C<sup><a href="https://rads.stackoverflow.com/amzn/click/com/B079VYGNRG" rel="noreferrer" rel="nofollow noreferrer">Kodak PLA+</a></sup>, 190-220 °C<sup><a href="https://www.amazon.de/SUNLU-Filament-Printing-Dimensional-Accuracy/dp/B073P9LZWB" rel="noreferrer">SUNLU PLA+</a></sup> and 190-210 °C<sup><a href="https://www.amazon.de/eSun-Filament-Universal-Thing-matic/dp/B01KM6MDFG" rel="noreferrer">eSun PLA+</a></sup>.</p> <p>However, there is no uniformity in other effects on the filament. Some filaments would have less moisture absorption, a different stiffness or compressibility while others might have a higher tensile strength and feature an extremely glossy surface.</p> <p>Most commonly, the claimed benefits lie in the fields of the filament's strength, surface texture and glossiness, the printability of overhangs.</p> <h1>Conclusion</h1> <p>PLA+ is <strong>not one product</strong> per se but <strong>a family of modified PLA</strong>. While you can print PLA+ with the same settings as normal PLA, the resulting benefits between different brands are much more diverse than with normal PLA.</p> <ul> <li>Changing between different brands of <em>similar quality</em> normal PLA has usually little to no effect on the print's general properties.</li> <li>Changing between different brands of <em>similar quality</em> PLA+ can alter the print's properties immensely</li> </ul> <p>Because of the fact that no two brands of PLA+ are the same (and the manufacturers are silent on what additives they use to change the properties), one should not rely on the same effects when switching between brands.</p>
<p>Adding this as a new answer since it doesn't seem to be covered in existing ones:</p> <p>Despite &quot;PLA+&quot; being a marketing term without a specific definition, I've found that many (most?) filament vendors don't seem to be doing their own secret-sauce blending to make it, and most premium filament vendors who <em>do document</em> the source polymers they use are using roughly the same thing - most often one of the <a href="https://www.natureworksllc.com/Products/3D-series-for-3D-printing" rel="nofollow noreferrer">Natureworks Ingeo 3D series of polymers</a>, obtained in pellet source form, often 3D850 or 3D870. As such, if you can verify that this is what you filament marketed as &quot;PLA+&quot; is made from (or just search out one that's well-documented) you can use the data sheets for the polymer to find out more about how it's formulated.</p>
746
<p><a href="http://www.w3.org/TR/REC-CSS2/selector.html#attribute-selectors" rel="noreferrer">CSS Attribute selectors</a> allow the selection of elements based on attribute values. Unfortunately, I've not used them in years (mainly because they're not supported by all modern browsers). However, I remember distinctly that I was able to use them to adorn all external links with an icon, by using a code similar to the following:</p> <pre><code>a[href=http] { background: url(external-uri); padding-left: 12px; } </code></pre> <p>The above code doesn't work. My question is: <strong>How does it work?</strong> How do I select all <code>&lt;a&gt;</code> tags whose <code>href</code> attribute starts with <code>"http"</code>? The official CSS spec (linked above) doesn't even mention that this is possible. But I do remember doing this.</p> <p>(<em>Note</em>: The obvious solution would be to use <code>class</code> attributes for distinction. I want to avoid this because I have little influence of the way the HTML code is built. All I can edit is the CSS code.)</p>
<p>As for CSS 2.1, see <a href="http://www.w3.org/TR/CSS21/selector.html#attribute-selectors" rel="noreferrer">http://www.w3.org/TR/CSS21/selector.html#attribute-selectors</a></p> <p>Executive summary:</p> <pre> Attribute selectors may match in four ways: [att] Match when the element sets the "att" attribute, whatever the value of the attribute. [att=val] Match when the element's "att" attribute value is exactly "val". [att~=val] Match when the element's "att" attribute value is a space-separated list of "words", one of which is exactly "val". If this selector is used, the words in the value must not contain spaces (since they are separated by spaces). [att|=val] Match when the element's "att" attribute value is a hyphen-separated list of "words", beginning with "val". The match always starts at the beginning of the attribute value. This is primarily intended to allow language subcode matches (e.g., the "lang" attribute in HTML) as described in RFC 3066 ([RFC3066]). </pre> <p><a href="http://www.w3.org/TR/css3-selectors/#selectors" rel="noreferrer">CSS3 also defines a list of selectors</a>, but <a href="http://rakaz.nl/item/how_well_do_browsers_support_css_selectors" rel="noreferrer">the compatibility varies hugely</a>. </p> <p>There's also <a href="http://tools.css3.info/selectors-test/test.html" rel="noreferrer">a nifty test suite</a> that that shows which selectors work in your browser.</p> <p>As for your example,</p> <pre><code>a[href^=http] { background: url(external-uri); padding-left: 12px; } </code></pre> <p>should do the trick. Unfortunately, it is not supported by IE.</p>
<p>Note that, in Antti's example you'd probably want to add a catch for any absolute links you may have to your own domain, which you probably <strong>don't</strong> want to flag as 'external', e.g.:</p> <pre><code>a[href^="http://your.domain.com"] { background: none; padding: 0; } </code></pre> <p>And you'd want this <strong>after</strong> the previous declaration.</p> <p>You might also want to include the full protocol prefix, just in case you have a local document named "http-info.html" that you wish to link to, e.g.:</p> <pre><code>a[href^="http://"] { background: url(external-uri); padding-left: 12px; } </code></pre> <p>Note that, in both these slightly-more complex cases, you should quote the value. These work, for me, in IE7.</p>
7,189
<p>I need a C# profiler.</p> <p>Although I'm not averse to paying for one, something which is free or at least with a trial version would be ideal since it takes time to raise a purchase order.</p> <p>Any recommendations?</p>
<p>You can try the following:</p> <ul> <li><a href="http://nprof.sourceforge.net/Site/Description.html" rel="noreferrer">nprof</a> (free but kinda old)</li> <li><a href="http://sourceforge.net/projects/profilesharp/" rel="noreferrer">ProfileSharp</a> (open source)</li> <li><a href="http://memprofiler.com/" rel="noreferrer">.Net Memory Profiler</a> (really good for memory leaks, there's a trial version)</li> </ul> <hr> <p>Edit: Nprof has been replaced with <a href="https://code.google.com/p/slimtune/" rel="noreferrer">SlimTune</a> and works with .Net 4.0 applications</p>
<p>I found the <a href="http://memprofiler.com/" rel="nofollow noreferrer">.NET Memory Profiler</a> yesterday, and I must say that I'm very impressed by it.<br> I'm going to order my license today.</p>
3,185
<p>Are there any good PL/SQL libraries for JSON that you've worked with and found useful?</p> <p>In <a href="http://www.oracle.com/technology/tech/pl_sql/index.html" rel="noreferrer">PL/SQL</a>, I'm having to tediously hand code the return of <a href="http://www.json.org/" rel="noreferrer">JSON</a> values to JavaScript functions. I found <a href="http://www.erasme.org/pl-sql-library-for-JSON" rel="noreferrer">one PL/SQL library</a> for auto-generating JSON, but it doesn't do exactly everything I need it too. For example, I couldn't extend the base functions in the library to return a complex tree-like JSON data structure required by a JavaScript tree component I was using.</p> <p><strong>Note:</strong><br /> The system, which has been in production for 8+ years, was architected to use PL/SQL for the CRUDs and most of the business logic. The PL/SQL also generates 90% of the presentation layer (HTML/JavaScript), using mod PL/SQL. The other 10% is reported data done via Oracle Reports Builder. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>@Geoff- </p> <p>The system, which has been in production for 8+ years, was architected to use PL/SQL for the CRUDs and <em>most</em> of the business logic. The PL/SQL also generates 90% of the presentation layer (HTML/JavaScript), using <a href="http://www.orafaq.com/wiki/Mod_plsql_FAQ" rel="nofollow noreferrer">mod PL/SQL</a>. The other 10% is report data done via Oracle Reports Builder.</p> <p>So, there isn't application code like you'd see in more modern, better architected systems. I do <strong>want</strong> to do things the <em>right</em> way, I just don't have that luxury given organizational constraints.</p>
<p>I wonder why you don't want to bring the data from Oracle into some application code and make JSON there?</p>
4,623
<p>Given a (source) patch file, what's the easiest way to apply this patch on the source files under Windows?</p> <p>A GUI tool where I can visually compare the unchanged-changed source lines would be great.</p>
<p><a href="http://gnuwin32.sourceforge.net/packages/patch.htm" rel="noreferrer">Patch for Windows</a> is what you're looking for.</p>
<p>WinMerge is awesome.</p> <p><a href="http://winmerge.org/" rel="nofollow noreferrer">http://winmerge.org/</a></p>
4,004
<p>I'm running a long process stored procedure.</p> <p>I'm wondering if in case of a timeout or any case of disconnection with the database after initiating the call to the stored procedure. Is it still working and implementing the changes on the server? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<blockquote> <p>Anyway if the client is not there to commit at the end of the job the changes should be rolled back by the server.</p> </blockquote> <p>In other words, if you have a stored procedure making changes to the database and there is a possibility that the connection might disconnect in the middle, be sure to enclose all changes within a transaction.</p>
<p>I would suggest running your profiler on the database and watching the activity, and also create a basic test case so that you know for sure what happens. The outcome is dependent on your database and what you are using to connect to it.</p>
4,476
<p>Even though I always strive for complete validation these days, I often wonder if it's a waste of time. If the code runs and it looks the same in all browsers (I use browsershots.org to verify) then do I need to take it any further or am I just being overly anal?</p> <p>What level do you hold your code to when you create it for:</p> <p>a) yourself b) your clients</p> <p>P.S. Jeff and company, why doesn't stack overflow validate? :)</p> <p><strong>EDIT: Some good insights, I think that since I've been so valid-obsessed for so long I program knowing what will cause problems and what won't so I'm in a better position than people who create a site first and then "go back and fix the validation problems"</strong></p> <p><strong>I think I may post another question on stack overflow; "Do you validate as you go or do you finish and then go back and validate?" as that seems to be where this question is going</strong></p>
<p>a) Must look the same</p> <p>b) As standards-compliant as possible, but not so anal that it blocks finishing work</p> <p>In a situation where you have perpetual access to the code, I don't think standards-compliance is all that important, since you can always make changes to the code if something breaks. If you don't have perpetual access (ie, you sign off on the code and it becomes someone else's responsibility), it's probably best to be as standards-compliant as possible to minimize maintenance headaches later... even if you never have to deal with the code again, your reputation persists and can be transmitted to other potential clients, and many teams like to blame the previous developer(s) for problems that come up.</p>
<p>I think validation is a good litmus test of whether you've done things properly, so if there are only a few minor problems, why not fix them and ensure your site will at least be understood correctly by browsers in the future (even if they do render things differently for other reasons)?</p> <p>OTOH, for most projects, validation seems like a huge headache and if you can get things working across browsers, it's not worth spending an extra day/week+ on just validation.</p>
2,950
<p>When creating a new ASP.NET project in Visual Studio should I chose create: website or project? </p> <p>I understand that web application project was the way to do it back in the day with VS 2003 but is it still applicable today? What are some of the caveats using one over the other?</p>
<p>There's a <a href="http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5" rel="noreferrer">pretty good comparison chart on MSDN</a>.</p> <p>Website projects are simple, in that all files added to the project folders are automatically compiled and included, which was supposedly added to make it more palatable to classic ASP and PHP developers. Once benefit is that it includes build providers, which allow for certain actions to be associated with a filetype - that's how the first release of SubSonic would rebuild the data access layer when you added a .abp file to the site.</p> <p>Web Application Projects are a lot more flexible, though. For instance, all class libraries in a Website Project need to be in the App_Code folder, which is frustrating in a complex application. There are a lot of scenarios which just don't work for a Website Project.</p> <p>You can convert from one to another, although if you're unsure I'd recommend just starting with a Web Application.</p>
<p>I strongly disagree with some of what the <a href="http://igurr.com/blogs/programming/archive/2009/03/25/websites-and-web-projects.aspx" rel="nofollow noreferrer">Websites and Web Projects</a> article says.</p> <p>First, it wasn't any "small" group of developers who rebelled - I'd suggest it was most of us, who had not been asked if we wanted to totally change the way we developed. They certainly didn't ask me if I wanted to lose six weeks of development time figuring out what they did to break a perfectly good web service.</p> <p>It wasn't some "download" MS released - it was VS2005 SP1, and they released it pretty damned fast.</p> <p>In their plusses for projectless development, the "Copy Project" command works very well, and we don't have to avoid debug or project files; you can move pages around - if you don't use source control; where do they get that you have to lock the project files in order to collaborate? What are they using for source control?</p> <p>I'd also add one question to the debate: what's so special about web sites that they should be the only "project" type (as far as I know) that doesn't use a "project" file? I can't think of anything, unless it's that Microsoft thought that web developers were too simpleminded to understand projects.</p> <p>Of course, if anyone knows of any other Visual Studio "project" type that does not use a project file, I'd be grateful to be informed of it.</p>
3,195
<p>I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be able to bookmark at any point and thereby return to the current state. </p> <p>How are people handling maintaining RESTfulness in AJAX apps? </p>
<p>The way to do this is to manipulate <code>location.hash</code> when AJAX updates result in a state change that you'd like to have a discrete URL. For example, if your page's url is:</p> <blockquote> <p><a href="http://example.com/" rel="nofollow noreferrer">http://example.com/</a></p> </blockquote> <p>If a client side function executed this code:</p> <pre><code>// AJAX code to display the "foo" state goes here. location.hash = 'foo'; </code></pre> <p>Then, the URL displayed in the browser would be updated to:</p> <blockquote> <p><a href="http://example.com/#foo" rel="nofollow noreferrer">http://example.com/#foo</a></p> </blockquote> <p>This allows users to bookmark the "foo" state of the page, and use the browser history to navigate between states.</p> <p>With this mechanism in place, you'll then need to parse out the hash portion of the URL on the client side using JavaScript to create and display the appropriate initial state, as fragment identifiers (the part after the #) are not sent to the server.</p> <p><a href="http://benalman.com/projects/jquery-hashchange-plugin/" rel="nofollow noreferrer">Ben Alman's hashchange plugin</a> makes the latter a breeze if you're using jQuery.</p>
<p>SWFAddress works in Flash &amp; Javascript projects and lets you create bookmarkable URLs (using the hash method mentioned above) as well as giving you back-button support.</p> <p><a href="http://www.asual.com/swfaddress/" rel="nofollow noreferrer">http://www.asual.com/swfaddress/</a></p>
2,384
<p>I'm mainly a C# developer, but I'm currently working on a project in Python.</p> <p>How can I represent the equivalent of an Enum in Python? </p>
<p><a href="https://docs.python.org/3/library/enum.html" rel="noreferrer">Enums</a> have been added to Python 3.4 as described in <a href="http://www.python.org/dev/peps/pep-0435/" rel="noreferrer">PEP 435</a>. It has also been <a href="https://pypi.python.org/pypi/enum34" rel="noreferrer">backported to 3.3, 3.2, 3.1, 2.7, 2.6, 2.5, and 2.4</a> on pypi.</p> <p>For more advanced Enum techniques try the <a href="https://pypi.python.org/pypi/aenum" rel="noreferrer">aenum library</a> (2.7, 3.3+, same author as <code>enum34</code>. Code is not perfectly compatible between py2 and py3, e.g. you'll need <a href="https://stackoverflow.com/a/25982264/57461"><code>__order__</code> in python 2</a>).</p> <ul> <li>To use <code>enum34</code>, do <code>$ pip install enum34</code></li> <li>To use <code>aenum</code>, do <code>$ pip install aenum</code></li> </ul> <p>Installing <code>enum</code> (no numbers) will install a completely different and incompatible version.</p> <hr /> <pre><code>from enum import Enum # for enum34, or the stdlib version # from aenum import Enum # for the aenum version Animal = Enum('Animal', 'ant bee cat dog') Animal.ant # returns &lt;Animal.ant: 1&gt; Animal['ant'] # returns &lt;Animal.ant: 1&gt; (string lookup) Animal.ant.name # returns 'ant' (inverse lookup) </code></pre> <p>or equivalently:</p> <pre><code>class Animal(Enum): ant = 1 bee = 2 cat = 3 dog = 4 </code></pre> <hr /> <p>In earlier versions, one way of accomplishing enums is:</p> <pre><code>def enum(**enums): return type('Enum', (), enums) </code></pre> <p>which is used like so:</p> <pre><code>&gt;&gt;&gt; Numbers = enum(ONE=1, TWO=2, THREE='three') &gt;&gt;&gt; Numbers.ONE 1 &gt;&gt;&gt; Numbers.TWO 2 &gt;&gt;&gt; Numbers.THREE 'three' </code></pre> <p>You can also easily support automatic enumeration with something like this:</p> <pre><code>def enum(*sequential, **named): enums = dict(zip(sequential, range(len(sequential))), **named) return type('Enum', (), enums) </code></pre> <p>and used like so:</p> <pre><code>&gt;&gt;&gt; Numbers = enum('ZERO', 'ONE', 'TWO') &gt;&gt;&gt; Numbers.ZERO 0 &gt;&gt;&gt; Numbers.ONE 1 </code></pre> <p>Support for converting the values back to names can be added this way:</p> <pre><code>def enum(*sequential, **named): enums = dict(zip(sequential, range(len(sequential))), **named) reverse = dict((value, key) for key, value in enums.iteritems()) enums['reverse_mapping'] = reverse return type('Enum', (), enums) </code></pre> <p>This overwrites anything with that name, but it is useful for rendering your enums in output. It will throw a <code>KeyError</code> if the reverse mapping doesn't exist. With the first example:</p> <pre><code>&gt;&gt;&gt; Numbers.reverse_mapping['three'] 'THREE' </code></pre> <hr /> <p>If you are using MyPy another way to express &quot;enums&quot; is with <a href="https://mypy.readthedocs.io/en/stable/literal_types.html#parameterizing-literals" rel="noreferrer"><code>typing.Literal</code></a>.</p> <p>For example:</p> <pre class="lang-py prettyprint-override"><code>from typing import Literal #python &gt;=3.8 from typing_extensions import Literal #python 2.7, 3.4-3.7 Animal = Literal['ant', 'bee', 'cat', 'dog'] def hello_animal(animal: Animal): print(f&quot;hello {animal}&quot;) hello_animal('rock') # error hello_animal('bee') # passes </code></pre>
<pre><code>def enum( *names ): ''' Makes enum. Usage: E = enum( 'YOUR', 'KEYS', 'HERE' ) print( E.HERE ) ''' class Enum(): pass for index, name in enumerate( names ): setattr( Enum, name, index ) return Enum </code></pre>
5,755
<p>I have a postgres database with a user table (userid, firstname, lastname) and a usermetadata table (userid, code, content, created datetime). I store various information about each user in the usermetadata table by code and keep a full history. so for example, a user (userid 15) has the following metadata:</p> <pre><code>15, 'QHS', '20', '2008-08-24 13:36:33.465567-04' 15, 'QHE', '8', '2008-08-24 12:07:08.660519-04' 15, 'QHS', '21', '2008-08-24 09:44:44.39354-04' 15, 'QHE', '10', '2008-08-24 08:47:57.672058-04' </code></pre> <p>I need to fetch a list of all my users and the most recent value of each of various usermetadata codes. I did this programmatically and it was, of course godawful slow. The best I could figure out to do it in SQL was to join sub-selects, which were also slow and I had to do one for each code.</p>
<p>I suppose you're not willing to modify your schema, so I'm afraid my answe might not be of much help, but here goes...</p> <p>One possible solution would be to have the time field empty until it was replaced by a newer value, when you insert the 'deprecation date' instead. Another way is to expand the table with an 'active' column, but that would introduce some redundancy.</p> <p>The classic solution would be to have both 'Valid-From' and 'Valid-To' fields where the 'Valid-To' fields are blank until some other entry becomes valid. This can be handled easily by using triggers or similar. Using constraints to make sure there is only one item of each type that is valid will ensure data integrity.</p> <p>Common to these is that there is a single way of determining the set of current fields. You'd simply select all entries with the active user and a NULL 'Valid-To' or 'deprecation date' or a true 'active'.</p> <p>You might be interested in taking a look at the Wikipedia entry on <a href="http://en.wikipedia.org/wiki/Temporal_database" rel="nofollow noreferrer">temporal databases</a> and the article <a href="http://www.cs.arizona.edu/~rts/pubs/SIGMODRecordMarch94p52.pdf" rel="nofollow noreferrer">A consensus glossary of temporal database concepts</a>.</p>
<p>A subselect is the standard way of doing this sort of thing. You just need a Unique Constraint on UserId, Code, and Date - and then you can run the following:</p> <pre><code>SELECT * FROM Table JOIN ( SELECT UserId, Code, MAX(Date) as LastDate FROM Table GROUP BY UserId, Code ) as Latest ON Table.UserId = Latest.UserId AND Table.Code = Latest.Code AND Table.Date = Latest.Date WHERE UserId = @userId </code></pre>
4,484
<p>The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object instance. Although I know how to code the singleton pattern in C++ and Java, I was wondering if anyone know how to implement it in Ruby?</p>
<p>Actually, the above answer was not completely correct.</p> <pre><code>require 'singleton' class Example include Singleton end </code></pre> <p>You also need to include the require 'singleton' statement.</p>
<p>You could use modules to the same effect I believe, although its not "the singleton pattern" you can have global state that way (which is what a singleton is ! Naughty global state !).</p>
2,670
<p>What is a good data structure for storing phone numbers in database fields? I'm looking for something that is flexible enough to handle international numbers, and also something that allows the various parts of the number to be queried efficiently.</p> <p><strong>Edit:</strong> Just to clarify the use case here: I currently store numbers in a single varchar field, and I leave them just as the customer entered them. Then, when the number is needed by code, I normalize it. The problem is that if I want to query a few million rows to find matching phone numbers, it involves a function, like</p> <pre><code>where dbo.f_normalizenum(num1) = dbo.f_normalizenum(num2) </code></pre> <p>which is terribly inefficient. Also queries that are looking for things like the area code become extremely tricky when it's just a single varchar field.</p> <p><strong>[Edit]</strong></p> <p>People have made lots of good suggestions here, thanks! As an update, here is what I'm doing now: I still store numbers exactly as they were entered, in a varchar field, but instead of normalizing things at query time, I have a trigger that does all that work as records are inserted or updated. So I have ints or bigints for any parts that I need to query, and those fields are indexed to make queries run faster.</p>
<p>First, beyond the country code, there is no real standard. About the best you can do is recognize, by the country code, which nation a particular phone number belongs to and deal with the rest of the number according to that nation's format.</p> <p>Generally, however, phone equipment and such is standardized so you can almost always break a given phone number into the following components</p> <ul> <li>C Country code 1-10 digits (right now 4 or less, but that may change)</li> <li>A Area code (Province/state/region) code 0-10 digits (may actually want a region field and an area field separately, rather than one area code)</li> <li>E Exchange (prefix, or switch) code 0-10 digits</li> <li>L Line number 1-10 digits</li> </ul> <p>With this method you can potentially separate numbers such that you can find, for instance, people that might be close to each other because they have the same country, area, and exchange codes. With cell phones that is no longer something you can count on though.</p> <p>Further, inside each country there are differing standards. You can always depend on a (AAA) EEE-LLLL in the US, but in another country you may have exchanges in the cities (AAA) EE-LLL, and simply line numbers in the rural areas (AAA) LLLL. You will have to start at the top in a tree of some form, and format them as you have information. For example, country code 0 has a known format for the rest of the number, but for country code 5432 you might need to examine the area code before you understand the rest of the number.</p> <p>You may also want to handle <code>vanity</code> numbers such as <code>(800) Lucky-Guy</code>, which requires recognizing that, if it's a US number, there's one too many digits (and you may need to full representation for advertising or other purposes) and that in the US the letters map to the numbers differently than in Germany.</p> <p>You may also want to store the entire number separately as a text field (with internationalization) so you can go back later and re-parse numbers as things change, or as a backup in case someone submits a bad method to parse a particular country's format and loses information.</p>
<p>I would go for a freetext field and a field that contains a purely numeric version of the phone number. I would leave the representation of the phone number to the user and use the normalized field specifically for phone number comparisons in TAPI-based applications or when trying to find double entries in a phone directory. Of course it does not hurt providing the user with an entry scheme that adds intelligence like separate fields for country code (if necessary), area code, base number and extension.</p>
6,332
<p>I've been looking into the viability of manufacturing a replacement part for a kitchen blender that has a broken part. I found <a href="https://all3dp.com/1/food-safe-3d-printing-abs-pla-food-safe-filament/" rel="nofollow noreferrer">this page that talks about what makes a print food safe</a>. One of the items mentioned was:</p> <blockquote> <p>... a brass extruder may contain lead, and lead contamination can cause some nasty health problems. ...</p> </blockquote> <p>I own an Ender 3, and I haven't replaced the nozzle yet. How can I tell if my printer is capable of creating food safe prints in its current state?</p>
<p>Food packaging needs to comply with regulations. One certification agency informing about these (and their service to certify for them) is <a href="https://www.tuv-sud.com/home-com/resource-centre/publications/e-ssentials-newsletter/food-health-e-ssentials/e-ssentials-3-2015/regulations-for-food-packaging-products-and-materials" rel="nofollow noreferrer">TÜV Süd</a>, another is <a href="https://www.saiglobal.com/Assurance/resource-library/Food-Safety/packaging_Brochure.pdf" rel="nofollow noreferrer">SAI global</a>. A summary of the GFSI can be found <a href="https://www.manufacturing.net/article/2014/07/compliance-food-grade-product-manufacturing" rel="nofollow noreferrer">here</a>. Inform yourself about the standards you wish to apply! The stack can not give legally binding answers.</p> <h1><strong>No</strong></h1> <p>The Ender 3 is not approved to produce food products (and not usable for them out of the box) for lack of certification. In the design it comes from the box, you need to replace a lot of parts for food rated ones:</p> <ul> <li>The whole print head/bed need to be swapped out for food rated parts due to the exact composition being not known. They might contain banned materials. As a result: <ul> <li>You'll need an all-metal hot end that can be taken apart for cleaning up to the standards if needed.</li> <li>You'll need a food rated PTFE tube.</li> <li>You'll need a stainless steel nozzle that complies with food grade manufacturing demands.</li> <li>The extruder gear should be stainless steel as well.</li> <li>You'll need to add some part to prevent filament shreds/flakes from the extruder to enter the print area as they might act as contaminants or carry germs.</li> <li>Similar measures have to be taken for the wheels on the hot end carriage, as it might shred.</li> <li>As you include a volume of air into the print, you are likely to be demanded to print under a protective atmosphere to make sure no germs are inside the print.</li> <li>We do not know the composition of the build platform, so you'd need to replace the back surface with something that is food rated.</li> </ul></li> <li>You'll need to post-process your prints as smooth as possible, especially because of the small edges at the layer boundaries, which can and will act as spots where germs can grow. <ul> <li>This <em>can</em> be achieved with a material that is smoothable in some way.</li> <li>Alternatively, a sealing lacquer/coating that is food safe might help here.</li> </ul></li> </ul> <h1>Remember, safety first:</h1> <p>Printed plastics that are rated for food are not necessarily food safe because of the quality or blend of the material. PLA and ABS can be made food safe, but that is usually <em>pure</em> material. We usually don't know what kinds of fillers or coloring is in our filament. The heating process might destroy the colors or fillers, which in turn might make it unsafe.</p> <h1>Indirect manufacturing</h1> <p>If you are stone set you want/need, you can use indirect manufacturing: you don't print the actual object, you print a mold that makes the actual object. Clay and other ceramics can be made food safe very easily and they can be shaped with plastic molds.</p> <h1>Boxing</h1> <p>There is also another way to facilitate food safety in a 3D printed container, and that is checking where the food will actually make contact. For a lunch box, that is the inside. We could line this inside with a food safe surface, for example placing a steel cup in our plastic cup-holder. Accessories like a cup holder or a decorative container for the actual food container do not need to adhere to the food packaging regulations themselves.</p> <h1>Exposure time</h1> <p>I know this is all looking at industrial food rated production. The <a href="https://all3dp.com/1/food-safe-3d-printing-abs-pla-food-safe-filament/" rel="nofollow noreferrer">Primer</a> given in the question does include a point about time the product gets into contact with the food - if there is just a short exposure, you might <em>get away</em> with it, but it doesn't make it certified food safe. Another good read in this regard is <a href="https://pinshape.com/blog/3d-printing-food-safe/" rel="nofollow noreferrer">this</a> short discussion about the Pros and Cons.</p>
<p>Yes you have to change brass nozzle it contains lead. If you are planning to print in PLA don't do that because PLA filament we are using in 3D printer are not food safe it contains some nasty colour dyes which are not food safe. Consider some special food safe filaments available in market. I think extruder gears are also made up of brass. Consider also changing them. Steel extuder gears are available in market like below</p> <p><a href="https://i.stack.imgur.com/IHv9p.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IHv9p.jpg" alt="Exduder gear"></a></p>
1,041
<p>I'd like to get the Tree icon to use for a homegrown app. Does anyone know how to extract the images out as .icon files? I'd like both the 16x16 and 32x32, or I'd just do a screen capture.</p>
<p>In Visual Studio, choose "File Open..." then "File...". Then pick the Shell32.dll. A folder tree should be opened, and you will find the icons in the "Icon" folder.</p> <p>To save an Icon, you can right-click on the icon in the folder tree and choose "Export".</p>
<p>If you're on Linux, you can extract icons from a Windows DLL with <a href="https://github.com/muflone/gextractwinicons" rel="nofollow">gExtractWinIcons</a>. It's available in Ubuntu and Debian in the <code>gextractwinicons</code> package.</p> <p>This blog article has a <a href="http://ubuntugenius.wordpress.com/2010/07/17/how-to-extract-icons-from-exe-files-windows-programs-as-pngs-for-wine-launchers-in-ubuntu/" rel="nofollow">screenshot and brief explanation</a>.</p>
2,983
<p><strong>Thermal conductivity</strong> is how well a plastic conducts heat. Most plastics don't conduct heat very well at all, which is what allows them to be 3D printed. That being said, there are a lot of potential use cases for highly thermally conductive filament, assuming you could print them. A commonly discussed one is computer heatsinks. Similar heatsinks could also be used for stepper motors and extruders in 3d printing. </p> <p>To get a good picture which plastics are useful in such an application (like mentioned in question: "<a href="https://3dprinting.stackexchange.com/questions/10881/water-cooling-stepper-motor-with-aluminum-block">Water-cooling stepper motor with aluminum block</a>"), I need to know what is the thermal conductivity of the commonly used thermoplastics.</p>
<p>All values are in W/(m*K).</p> <ul> <li>PLA: 0.13</li> <li>HIPS: 0.20</li> <li>ABS: 0.25</li> <li>PETG: 0.29</li> <li>PEEK: 0.25</li> <li>PLA with copper: 0.25 (<a href="https://www.3dhubs.com/talk/t/thermal-conductivity-of-copper-based-filament-and-ceramic-resin/8798/7" rel="nofollow noreferrer">see discussion</a>) </li> <li>PETG with 40% graphite: 1.70 (ansiotropic)</li> <li><a href="https://tcpoly.com/products/filaments/" rel="nofollow noreferrer">TCPoly</a>: 15</li> <li>Steel (not a 3dprintable plastic): 10 - 50</li> </ul> <p><a href="https://i.stack.imgur.com/YOsQZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YOsQZ.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/DmOFV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DmOFV.png" alt="enter image description here"></a></p>
<p>Trimet3d has a Nano diamond PLA with a claimed thermal conductivity 3-5 times that of PLA. The diamonds are sub-microscopic and smooth. See <a href="https://www.tiamet3d.com/product-page/ultra-diamond-pla-1kg" rel="nofollow noreferrer">https://www.tiamet3d.com/product-page/ultra-diamond-pla-1kg</a> Primarily they seem to be doing it to gain strength.</p> <p>I would prefer larger diamonds for higher thermal conductivity. It would be ferociously abrasive even for a diamond nozzle. It would also limit the thermal expansion.</p>
1,471
<p>I am currently encountering a problem where under certain circumstances, the extruder stutters when it starts a new layer. I am printing on an Anycubic i3 Mega and am slicing with Cura 3.6.0. The problem seems to occur in the main part of prints, as well as in supports. However it seems to only occur after a retraction has taken place. I have taken a video of the stuttering which can be found here: <a href="https://photos.app.goo.gl/G3TLKveMsLNRQmgv7" rel="nofollow noreferrer">https://photos.app.goo.gl/G3TLKveMsLNRQmgv7</a> When a print is done the stuttering results in walls looking like this: <a href="https://i.stack.imgur.com/AlAZQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AlAZQ.jpg" alt="In this case, the problem occured in the support structure"></a> Can anyone help me figure out what is causing the stuttering? Thank you very much!</p>
<p>You retraction settings may be too high. Direct drive extruders require less retraction than Bowden style extruders. Typical retraction settings for direct drive are 1.5mm at 50mm/s and for Bowden, 4mm at 50mm/s. The speed usually makes more of a difference than distance beyond a certain point.</p> <p>You can get away with smaller retraction settings if you increase travel speed because there will be less time to ooze. You could also try using Coasting as well.</p> <p>Anyway, try reducing your retraction settings if they're higher than what I stated above. Another alternative is to set an extra prime distance so that extra filament is extruded after the retraction.</p>
<p><em>Definition: <strong>Sparse layer fill</strong> (called stuttering by the OP)</em></p> <hr /> <h2>Why a sparsely filled support structure... (at the support bottom)</h2> <p>Support structures are added by Ultimaker Cura as the first part of the layer before it progresses to the rest of the print object. The bottom part of the support structure is definitely showing under extrusion, as if there was not enough filament available to print the support solidly. Actually, that is exactly what is the problem, there is not enough filament available for printing as a result of a retraction and the following extrusion after movement of the filament. The bottom part of the support is most probably printed after <em><strong>the head stopped far from the support</strong></em> (end of the previous layer) while printing your object. This means that the filament needs to be retracted, the head moved to the support structure, filament extruded (de-retracted) and printing of the support structure starting. When retraction is not optimally tuned, the <em><strong>nozzle may not be primed correctly with filament and cause a sparsely printed support structure</strong></em>. A similar reasoning could apply to support structures being printed at the final stage of the layer (as long as there are large movements to the support structure requiring the activation of the retraction).</p> <h2>Why is the support better printed higher up...</h2> <p>You see that when Z advances above the thickness of the right part of the print, the support structure is better printed. This could be caused by the fact that the head now doesn't need to move far from the last position of the print to the support structure, this doesn't require a retraction action.</p> <h2>What to do to print better support structures...</h2> <p>Try tune your retraction settings, see e.g. <a href="https://3dprinting.stackexchange.com/a/7004/">this answer</a> shows an image of a <a href="https://www.thingiverse.com/thing:1159886" rel="nofollow noreferrer">calibration print</a> to determine the optimal settings.</p> <p>Note that you not only can play with the filament retraction settings (<code>Enable Retraction</code>, <code>Retraction Speed</code> and <code>Retraction Distance</code>), the option called <code>Enable Coasting</code> and <code>Coasting Volume</code> can also be used to stop extruding while the printer head prints the rest of the object to use the over-pressure of the molten filament in the nozzle and finally <code>Retraction Extra Prime Amount</code> can extrude some extra filament to prime the nozzle with some extra material so that the nozzle is optimally filled and ready for printing the support after the main print object. Also take care choosing the right <code>Support Speed</code>, too fast will result in lower quality.</p>
1,100
<p>3D Printing's <a href="https://3dprinting.stackexchange.com/election/1">First Pro-Tem moderator election</a> has come to a close, the votes have been tallied, and the new moderators is:</p> <p><a href="https://3dprinting.stackexchange.com/users/5740"><img src="https://3dprinting.stackexchange.com/users/flair/5740.png" alt="MOD1_NAME"></a></p> <p>They'll be joining <a href="https://3Dprinting.stackexchange.com/users?tab=moderators">the existing crew</a> shortly — please thank them for volunteering, and share your assistance and advice with them as they learn the ropes!</p> <p>Also, please join me in thanking tbm0115 who will be stepping down as moderator.</p> <p>For details on how the voting played out, you can download the election results <a href="https://3dprinting.stackexchange.com/election/1">here</a>, or <a href="https://www.opavote.com/results/5831275661230080" rel="nofollow noreferrer">view a summary report online</a>.</p>
<p>I like the expanded definitions, but there is probably an issue with some of the things you'd put into "just rough around the edges" portion of what you state.</p> <p>For instance, "Print Services" are mentioned as far as on-topic and what is allowed. <em>To what extent are Print Services</em> on-topic and allowed? In and of itself, as you've stated it, it could be anything from what to expect to giving them service recommendations (ie: <em>What's a good place to get xxxx done?</em> or <em>Who provides to best services in the Dallas, TX area?</em>) This isn't the only place where it could be done. If you don't want questions like this, throw a little more specification in there as far as what would be acceptable. </p>
<p>I like the expanded definitions, but there is probably an issue with some of the things you'd put into "just rough around the edges" portion of what you state.</p> <p>For instance, "Print Services" are mentioned as far as on-topic and what is allowed. <em>To what extent are Print Services</em> on-topic and allowed? In and of itself, as you've stated it, it could be anything from what to expect to giving them service recommendations (ie: <em>What's a good place to get xxxx done?</em> or <em>Who provides to best services in the Dallas, TX area?</em>) This isn't the only place where it could be done. If you don't want questions like this, throw a little more specification in there as far as what would be acceptable. </p>
69
<p>I am curious if anyone have used UnderC, Cint, Cling, Ch, or any other C++ interpreter and could share their experience.</p>
<p>There is <strong><a href="http://cern.ch/cling" rel="noreferrer">cling</a> Cern's project</strong> of C++ interpreter based on <a href="http://clang.llvm.org/" rel="noreferrer">clang</a> - it's <em>new approach</em> based on 20 years of experience in <em>ROOT cint</em> and it's quite stable and recommended by Cern guys.</p> <p>Here is nice <a href="http://www.youtube.com/watch?v=f9Xfh8pv3Fs" rel="noreferrer">Google Talk: Introducing cling, a C++ Interpreter Based on clang/LLVM</a>.</p>
<p>There is a program called <a href="http://neugierig.org/software/c-repl/" rel="nofollow noreferrer">c-repl</a> which works by repeatedly compiling your code into shared libraries using GCC, then loading the resulting objects. It seems to be evolving rapidly, considering <a href="http://packages.ubuntu.com/lucid/i386/c-repl" rel="nofollow noreferrer">the version</a> in Ubuntu's repository is written in Ruby (not counting GCC of course), while the <a href="http://neugierig.org/software/git/?url=c-repl/" rel="nofollow noreferrer">latest git</a> is in Haskell. :)</p>
9,491
<p>I imagine everyone has seen code like:</p> <pre><code>public void Server2ClientEnumConvert( ServerEnum server) { switch(server) { case ServerEnum.One: return ClientEnum.ABC //And so on. </code></pre> <p>Instead of this badness we could do somthing like:</p> <pre><code>public enum ServerEnum { [Enum2Enum(ClientEnum.ABC)] One, } </code></pre> <p>Now we can use reflection to rip through ServerEnum and get the conversion mappings from the enum declaration itself.</p> <p>The problem I am having here is in the declaration of the Enum2Enum attribute.</p> <p>This works but replacing object o with Enum e does not. I do not want to be able to pass in objects to the constructor, only other enums.</p> <pre><code>public class EnumToEnumAttribute : Attribute { public EnumToEnumAttribute(object o){} } </code></pre> <p>This fails to compile.</p> <pre><code>public class EnumToEnumAttribute : Attribute { public EnumToEnumAttribute(Enum e){} } </code></pre> <p>Is there a reason for the compile error? How else could I pass in the information needed to map besides: </p> <pre><code>EnumtoEnumAttribute(Type dest, string enumString) </code></pre> <p>This seems too verbose but if it is the only way then I guess I will use it.</p>
<p>Using almost the same example, you can achieve this directly in the enum:</p> <pre><code>public enum ServerEnum { One = ClientEnum.ABC, } </code></pre> <p>This has the benefit of not requiring Reflection, is easier to read (in my opinion), and overall requires less overhead.</p>
<p>I would probably use struct as the type, and then throw an exception if it isn't an Enum type. I don't see how your (Type, string) option is any safer than using object or struct.</p>
6,129
<p>tried searching but couldn't find anything. I do not have a 3d printer so can't really experiment on my own, which means that when I am going to order a 3d print I want to get it as good as possible. So, my question:</p> <p>Do quality of geometry matters when 3d printing? Will 3d printer only print quads, or ngons are fine? Are there shapes to avoid?</p> <p>Cheers :) M.</p>
<p>There are a lot of factors to 3D printing parts that work and fit together. </p> <p>A lot of it will be discovered by trial and error, but let's try to put you on the right path. </p> <p>First your material is what matters the most. Specifically their coefficient of thermal expansion, i.e. how much can the plastic change when heat is applied. PLA's coefficient is low compared to ABS, for example. Which is why the MakerBot can print without a heated bed, but it cannot print ABS with any success.</p> <p>Here is a <a href="http://omnexus.specialchem.com/polymer-properties/properties/coefficient-of-linear-thermal-expansion" rel="nofollow noreferrer">list of coefficient of thermal expansions</a> by material.</p> <p>What you want to do next is to print out a few test items and see for yourself. Below is an example of reality vs. expectation. As you can see the circle shrinks. It will never expand. So you will always make it bigger than you need. It is also good to note in this example below that the block itself is Larger than expected. The best solution is to not expect high tolerances and build a lot of flex into your designs.</p> <p><a href="https://i.stack.imgur.com/v0e4Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v0e4Q.png" alt="Example of thermal expansion"></a></p> <p>Generally you want the hole size larger. If I wanted a 4 mm minimum hole, then I would likely make it 5+ mm.</p> <p>The best thing you can do is print out a tray and document how different the sizes are. Also, do the same with a print of various peg sizes. Below is an example of such a tray.</p> <p><a href="https://i.stack.imgur.com/1jmQn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1jmQn.png" alt="Example of a print of various holes"></a></p> <ul> <li><p>Also, you might want to look into other materials such as Nylon and Carbon fiber.</p></li> <li><p>A great source of more tips. Here is a great tutorial, <a href="http://www.shapeways.com/tutorials/designing_mechanical_parts_3d_printing_the_whoosh" rel="nofollow noreferrer">Designing Mechanical Parts - The Whoosh Machine by shapeways</a>, on designing parts.</p></li> <li><p>A <a href="http://reprap.org/wiki/Lubrication" rel="nofollow noreferrer">RepRap Wiki article</a> on different lubricants in regards to 3D printers. Most people use silicon lube for parts to my knowledge. Again, it depends on your material. </p></li> </ul> <p>Images taken from this link, <a href="https://innovationstation.utexas.edu/tip-design/" rel="nofollow noreferrer">The Innovation Station - Tips for Designing 3D Printed Parts</a>.</p>
<p>I can't attest to the empirical data laid out in the first answer, but I've had to deal with a lot of components printed in two parts to be connected via design-incorporated channels. I always found that, as a reference, a box of width and length 0.98" will slide securely, but freely, into a square channel of width and length 1".</p>
463
<p>I've been interacting with Amazon S3 through <a href="https://addons.mozilla.org/en-US/firefox/addon/3247" rel="noreferrer">S3Fox</a> and I can't seem to delete my buckets. I select a bucket, hit delete, confirm the delete in a popup, and... nothing happens. Is there another tool that I should use?</p>
<p>It is finally possible to delete all the files in one go using the new Lifecycle (expiration) rules feature. You can even do it from the AWS console.</p> <p>Simply right click on the bucket name in AWS console, select "Properties" and then in the row of tabs at the bottom of the page select "lifecycle" and "add rule". Create a lifecycle rule with the "Prefix" field set blank (blank means all files in the bucket, or you could set it to "a" to delete all files whose names begin with "a"). Set the "Days" field to "1". That's it. Done. Assuming the files are more than one day old they should all get deleted, then you can delete the bucket.</p> <p>I only just tried this for the first time so I'm still waiting to see how quickly the files get deleted (it wasn't instant but presumably should happen within 24 hours) and whether I get billed for one delete command or 50 million delete commands... fingers crossed!</p>
<p>Use the amazon web managment console. With Google chrome for speed. Deleted the objects a lot faster than firefox (about 10 times faster). Had 60 000 objects to delete.</p>
4,693
<p>We're experimenting with various ways to throttle user actions in a <strong>given time period</strong>:</p> <ul> <li>Limit question/answer posts</li> <li>Limit edits</li> <li>Limit feed retrievals</li> </ul> <p>For the time being, we're using the Cache to simply insert a record of user activity - if that record exists if/when the user does the same activity, we throttle.</p> <p>Using the Cache automatically gives us stale data cleaning and sliding activity windows of users, but how it will scale could be a problem.</p> <p>What are some other ways of ensuring that requests/user actions can be effectively throttled (emphasis on stability)?</p>
<p>Here's a generic version of what we've been using on Stack Overflow for the past year:</p> <pre><code>/// &lt;summary&gt; /// Decorates any MVC route that needs to have client requests limited by time. /// &lt;/summary&gt; /// &lt;remarks&gt; /// Uses the current System.Web.Caching.Cache to store each client request to the decorated route. /// &lt;/remarks&gt; [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class ThrottleAttribute : ActionFilterAttribute { /// &lt;summary&gt; /// A unique name for this Throttle. /// &lt;/summary&gt; /// &lt;remarks&gt; /// We'll be inserting a Cache record based on this name and client IP, e.g. "Name-192.168.0.1" /// &lt;/remarks&gt; public string Name { get; set; } /// &lt;summary&gt; /// The number of seconds clients must wait before executing this decorated route again. /// &lt;/summary&gt; public int Seconds { get; set; } /// &lt;summary&gt; /// A text message that will be sent to the client upon throttling. You can include the token {n} to /// show this.Seconds in the message, e.g. "Wait {n} seconds before trying again". /// &lt;/summary&gt; public string Message { get; set; } public override void OnActionExecuting(ActionExecutingContext c) { var key = string.Concat(Name, "-", c.HttpContext.Request.UserHostAddress); var allowExecute = false; if (HttpRuntime.Cache[key] == null) { HttpRuntime.Cache.Add(key, true, // is this the smallest data we can have? null, // no dependencies DateTime.Now.AddSeconds(Seconds), // absolute expiration Cache.NoSlidingExpiration, CacheItemPriority.Low, null); // no callback allowExecute = true; } if (!allowExecute) { if (String.IsNullOrEmpty(Message)) Message = "You may only perform this action every {n} seconds."; c.Result = new ContentResult { Content = Message.Replace("{n}", Seconds.ToString()) }; // see 409 - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict; } } } </code></pre> <p>Sample usage:</p> <pre><code>[Throttle(Name="TestThrottle", Message = "You must wait {n} seconds before accessing this url again.", Seconds = 5)] public ActionResult TestThrottle() { return Content("TestThrottle executed"); } </code></pre> <p>The ASP.NET Cache works like a champ here - by using it, you get automatic clean-up of your throttle entries. And with our growing traffic, we're not seeing that this is an issue on the server.</p> <p>Feel free to give feedback on this method; when we make Stack Overflow better, you get your <a href="https://stackoverflow.blog/2009/05/31/the-stack-overflow-trilogy/">Ewok fix</a> even faster :)</p>
<p>Since the highly voted answers to this question are too old, I am sharing the latest solution which worked for me.</p> <p>I tried using the Dynamic IP restrictions as given in an <a href="https://stackoverflow.com/a/584689/3085520">answer</a> on this page but when I tried to use that extension, I found that this extension has been discontinued by Microsoft and on the <a href="https://www.iis.net/downloads/microsoft/dynamic-ip-restrictions" rel="nofollow noreferrer">download page</a> they have clearly written the below message.</p> <pre><code>Microsoft has discontinued the Dynamic IP Restrictions extension and this download is no longer available. </code></pre> <p>So I researched further and found that the Dynamic IP Restrictions is now by default included in IIS 8.0 and above. The below information is fetched from the Microsoft Dynamic IP Restrictions page.</p> <p>In IIS 8.0, Microsoft has expanded the built-in functionality to include several new features:</p> <ul> <li>Dynamic IP address filtering, which allows administrators to configure their server to block access for IP addresses that exceed the specified number of requests.</li> <li>The IP address filtering features now allow administrators to specify the behavior when IIS blocks an IP address, so requests from malicious clients can be aborted by the server instead of returning HTTP 403.6 responses to the client.</li> <li>IP filtering now feature a proxy mode, which allows IP addresses to be blocked not only by the client IP that is seen by IIS but also by the values that are received in the x-forwarded-for HTTP header</li> </ul> <p>For step by step instructions to implement Dynamic IP Restrictions, please visit the below link:</p> <p><a href="https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions</a></p> <p>I hope it helps someone stuck in a similar problem.</p>
5,412
<p>This question may require migration to Meta.SE, as it could be a site-wide "bug", but I thought that I would test the waters here, to see if there is an obvious explanation.</p> <p>I noticed that a question of mine had been modified, on April 16, by "Song Khmer" <strike>in the <a href="https://3dprinting.stackexchange.com/unanswered">unanswered questions list</a>, when sorted by votes</strike><sup>1</sup>:</p> <blockquote> <p><a href="https://i.stack.imgur.com/nY7mi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nY7mi.png" alt="Modification listed"></a></p> </blockquote> <p>However, when checking the <a href="https://3dprinting.stackexchange.com/posts/3015/revisions">revision history</a>, the April 16 edit, by <em>Song Khmer</em>, is not shown. The last modification was the "https everywhere" edit, three days prior:</p> <blockquote> <p><a href="https://i.stack.imgur.com/p5B9M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p5B9M.png" alt="No apparent modification"></a></p> </blockquote> <p>I've not noticed the behaviour before. What is going on? Is it a bug, or something really obvious that I can't see? </p> <p>Was it a rejected edit? If the latter, then should it really be shown in the Unanswered question list? Shouldn't the modifications listed in the Unanswered questions list, actually only be accepted modifications/edits?</p> <hr> <p><sup>1</sup> The unanswered list, and the sorting, are irrelevant to the actual issue.</p>
<p>Regarding the "invisible modification", there is technically a modification made multiple times by the user <strong>Song Khmer</strong> (now destroyed). This user was posting nonsense to your question by copying text from your question and posting it as an answer.</p> <p>The reason you probably did not see this in the revision history is:</p> <p>1) it wasn't a direct edit to your question</p> <p>2) I believe only moderators can see deleted posts.</p> <p><a href="https://i.stack.imgur.com/2VAiLs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2VAiLs.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/2VAiL.png" rel="nofollow noreferrer">click here for full view</a> of deleted posts</p> <p>I'm pretty sure that anytime someone posts an answer or edits your question, the post raises the modified flag. In this case, when the user was posting answers it would properly flag the post. But, the flag remained even after the answers were deleted (there were 3 answers).</p>
<p>The Stack Exchange network is undergoing a transition to HTTPS for its sites, including 3D Printing SE.</p> <p>This edit (from Community, it looks like), was probably scripted from SE Staff in attempt to fix content on Questions and Answers. Ultimately, I don't think this is worth migrating the SE Meta.</p>
40
<p>I have a 15x15 cm heating resistor from my current printer (printing area: 12x12 cm).</p> <p>I would like to switch to a glass bed and to rework my printer to increase the printing area to 20 cm (22x22 cm glass plate).</p> <p>Would it be possible to use the old heating resistor placed only in the centre? this way I would have a smaller heated bed for ABS and a bigger one for PLA.</p> <p>Would the glass crack due to non uniform heating? This is because glass has a conductivity of less than 5 W/mK, therefore the hot area will stay hot and basically never really spread the heat to the surrounding area. So the frame will be cold and the center hot, causing stresses.</p> <p>Related: <a href="https://engineering.stackexchange.com/questions/31842/how-much-an-unevenly-heated-glass-plate-bows">https://engineering.stackexchange.com/questions/31842/how-much-an-unevenly-heated-glass-plate-bows</a></p>
<p>If you're using borosilicate glass (aka pyrex) then it won't crack. You can get squares of ~20x20 cheaply off aliexpress.</p> <p>If you're using window glass, picture frame class etc then you might have issues with cracking, it will depend on lots of factors like the wattage of your heater and the temperature of the room.</p> <p>Your biggest problem will be that the bed heats very non-uniformly, which is unlike to give good print adhesion. I'd suggest a sheet of aluminium underneath the glass if possible, it will allow much more even heating. </p>
<p>The glass will be taking up the heat to slowly cover its full area. That means two things:</p> <ol> <li>it will not crack as there is no thermal shock</li> <li>it will put more pressure on the heater as there will be bigger heat absorption, so in an edge case, you could end-up with not getting a required temperature on the glass surface and/or the heating process will be very slow.</li> </ol> <p>In that case, I personally will try that out and then if I have an issue with getting proper temperature, then I will buy a new heater.</p> <hr> <p>A comment regarding heat expansion:</p> <p>my glass is about 20mm longer than the bed and it is warm during the printing process. The 'breaking' stress is connected with temperature shock (an immediate temp change), not a relatively slow heating process. However, borosilicate glass also known as Pyrex (TM) expands very little. Much less than most metals. This is why it doesn't break when exposed to sudden hot and cold changes. So in short words - check tea lighter under your tea-pot and see how te heat is comming out from the centre</p> <p><a href="http://glassproperties.com/expansion/ExpansionMeasurement.htm" rel="nofollow noreferrer">source</a></p>
881
<p>I'm using jquery ajax to post updates back to my server. I'm concerned about making sure I have put in place appropriate measures so that only my AJAX calls can post data.</p> <p>My stack is PHP on Apache against a MySQL backend.</p> <p>Advice greatly appreciated!</p>
<p>Any request that the AJAX calls in your pages can make can also be made by someone outside of the application. If done right, you will not be able to tell if they were made as part of an AJAX call from your webapp or by hand/other means.</p> <p>There are two scenarios I can think of which you might be talking about when you say you want to make sure that only your AJAX calls can post data: either you don't want a malicious user to be able to post data that interferes with another user's data or you actually want to restrict the posts to being in the "flow" of a multi-request operation. </p> <p>If you are concerned with the first case (someone posting malicious data to/as another user) the solution is the same whether you are using AJAX or not -- you just have to authenticate the user through whatever means is necessary -- usually via session cookie.</p> <p>If you are concerned with the second case, then you are going to have to do something like issue a unique token at each step of the process, and store the expected token on the server side. Then when a request is made, check that there is a corresponding entry on the server side for the action that is being taken and that the expected tokens match and that that token has not been used yet. If there is no, you reject the request, if there is, then you mark that token as used and process the request.</p> <p>If what you are concerned about is something other than one of these two scenarios then the answer will depend on more specifics than you have provided.</p>
<p>Use sessions to ensure that any Ajax posts are done in an authenticated context. Think of your Ajax code as just another client to your server, it becomes easier to tackle authentication issues that way.</p>
5,932
<p>The RoR tutorials posit one model per table for the ORM to work. My DB schema has some 70 tables divided conceptually into 5 groups of functionality (eg, any given table lives in one and only one functional group, and relations between tables of different groups are minimised.) So: should I design a model per conceptual group, or should I simply have 70 Rails models and leave the grouping 'conceptual'? Thanks!</p>
<p>I cover this in one of my large apps by just making sure that the tables/models are conceptually grouped by name (with almost 1:1 table-model relationship). Example:</p> <pre><code>events event_types event_groups event_attendees etc... </code></pre> <p>That way when I'm using TextMate or whatever, the model files are nicely grouped together by the alpha sort. I have 80 models in this app, and it works well enough to keep things organised.</p>
<p>There may be a small number of cases where you can use the Rails standard single-table-inheritance model. Perhaps all of the classes in one particular functional grouping have the same fields (or nearly all the same). In that case, take advantage of the DRYness STI offers. When it doesn't make sense, though, use class-per-table.</p> <p>In the class-per-table version, you can't easily pull common functionality into a base class. Instead, pull it into a module. A hierarchy like the following might prove useful:</p> <pre><code>app/models/admin/base.rb - module Admin::Base, included by all other Admin::xxx app/models/admin/user.rb - class Admin::User, includes Admin::Base app/models/admin/group.rb - class Admin::Group, includes Admin::Base </code></pre>
8,800
<p>Can anyone recommend software or a .NET library that will check for bounced emails and the reason for the bounce? I get bounced emails into a pop3 account that I can read then.</p> <p>I need it to keep my user database clean from invalid email addresses and want to automate this (mark user as invalid email).</p>
<p>I have done a great deal of work handling bounce emails and there different types. If you want to be absolutely sure that the email your looking at is indeed a bounce of a specific kind I highly recommend getting a good filter. I have worked with <a href="http://www.boogietools.com/" rel="noreferrer">Boogie Tools</a> and it has worked very well. It lets you know what kind of bounce it is, Hard, Soft, Transient or if its even someone trying to unsubscribe. It has a muliple API's including .Net and I found it quite easy to get working. </p>
<p>Thanks for the answer, great! I did some research myself and found <a href="http://www.advancedintellect.com/product.aspx?listnanny" rel="nofollow noreferrer">ListNanny</a> - also super simple to use and tells you the type of bounce. Will write some proof of concept and see which one I like better...</p>
2,884
<p>Let's say that on the C++ side my function takes a variable of type <code>jstring</code> named <code>myString</code>. I can convert it to an ANSI string as follows:</p> <pre><code>const char* ansiString = env-&gt;GetStringUTFChars(myString, 0); </code></pre> <p>is there a way of getting</p> <p><code>const wchar_t* unicodeString =</code> ...</p>
<p>If this helps someone... I've used this function for an Android project:</p> <pre><code>std::wstring Java_To_WStr(JNIEnv *env, jstring string) { std::wstring value; const jchar *raw = env-&gt;GetStringChars(string, 0); jsize len = env-&gt;GetStringLength(string); const jchar *temp = raw; while (len &gt; 0) { value += *(temp++); len--; } env-&gt;ReleaseStringChars(string, raw); return value; } </code></pre> <p>An improved solution could be (Thanks for the feedback):</p> <pre><code>std::wstring Java_To_WStr(JNIEnv *env, jstring string) { std::wstring value; const jchar *raw = env-&gt;GetStringChars(string, 0); jsize len = env-&gt;GetStringLength(string); value.assign(raw, raw + len); env-&gt;ReleaseStringChars(string, raw); return value; } </code></pre>
<p>Just use env->GetStringChars(myString, 0); Java pass Unicode by it's nature</p>
9,356
<p>I'm new to 3D Printing. I've created this star from Blender3d. As far as I know, most printers require a flat bottom.</p> <p>As you can see (blue line is Z-axis, red line is X-axis, green line Y-axis), the star doesn't have any flat sides or points.</p> <p><a href="https://i.stack.imgur.com/Mh6Bw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Mh6Bw.png" alt="enter image description here"></a></p> <p>There's a hole in the middle of the star. <a href="https://i.stack.imgur.com/V4a6C.png" rel="noreferrer"><img src="https://i.stack.imgur.com/V4a6C.png" alt="enter image description here"></a></p> <p>Is there a printer (brand/model) that can print this object that doesn't have any flat bottom or sides having a hole that goes through in the middle? Any workarounds to print this object?</p>
<p>Typical FDM desktop 3D printers might struggle with this model as it requires you to either print large overhangs and use support structure (when printed laying down), or lacks a natural flat bottom surface to get good print adhesion (when printed upright). A couple of suggestions:</p> <ol> <li><p>Some FDM printers are great at printing support, and some even allow you to print dissolvable support structure. If you find one of these, you are home safe.</p></li> <li><p>You could split the model in two, print those parts separately, and then glue them together afterwards. This is quite common for complex models, and allows you to print your model on even basic FDM printers. Tom's answer illustrates this well.</p></li> </ol> <p>There are naturally other 3D printer technologies too (SLA, resin etc.), but I have no practical experience with these myself, and leave it up to others to give you a good answer regarding these.</p>
<p>Typical FDM desktop 3D printers might struggle with this model as it requires you to either print large overhangs and use support structure (when printed laying down), or lacks a natural flat bottom surface to get good print adhesion (when printed upright). A couple of suggestions:</p> <ol> <li><p>Some FDM printers are great at printing support, and some even allow you to print dissolvable support structure. If you find one of these, you are home safe.</p></li> <li><p>You could split the model in two, print those parts separately, and then glue them together afterwards. This is quite common for complex models, and allows you to print your model on even basic FDM printers. Tom's answer illustrates this well.</p></li> </ol> <p>There are naturally other 3D printer technologies too (SLA, resin etc.), but I have no practical experience with these myself, and leave it up to others to give you a good answer regarding these.</p>
313
<p>I was thinking about obfuscating a commercial .Net application. But is it really worth the effort to select, buy and use such a tool? Are the obfuscated binaries really safe from reverse engineering?</p>
<p>You may not have to buy a tool - Visual Studio.NET comes with a community version of Dotfuscator. Other free obfuscation tools <a href="http://twit88.com/blog/2007/09/15/free-net-obfuscation-tools/" rel="noreferrer">are listed here</a>, and they may meet your needs.</p> <p>It's possible that the obfuscated binaries aren't safe from reverse engineering, just like it's possible that your bike lock might be breakable/pickable. However, it's often the case that a small inconvenience is enough to deter would be code/bicycle thieves.</p> <p>Also, if ever it comes time to assert your rights to a piece of code in court, having been seen to make an effort to protect it (by obfuscating it) may give you extra points. :-)</p> <p>You do have to consider the downsides, though - it can be more difficult to use reflection with obfuscated code, and if you're using something like log4net to generate parts of log lines based on the name of the class involved, these messages can become much more difficult to interpret.</p>
<p>Yes, we do. We use BitHelmet obfuscator. It's new, but it works really well.</p>
9,664
<p>Suppose you have two seperate ASP.NET Web Application projects that both need to use a common MasterPage.</p> <p>What's the best way to share the MasterPage across projects without having to duplicate code? Preferably without having to resort to source control or file system hacks.</p>
<p>I have trying to accomplish the same thing. I look into a couple of solutions but I think using a virtual directory is probably the best way to share master pages. </p> <p>Here are a couple sources that you can look at. </p> <ul> <li><a href="https://blogs.msdn.microsoft.com/shahpiyush/2007/03/09/sharing-master-pages-amongst-applications-by-embedding-it-in-a-dll/" rel="nofollow noreferrer">Sharing Master Pages amongst Applications by Embedding it in a Dll</a></li> <li><a href="https://msdn.microsoft.com/en-us/library/aa992039.aspx" rel="nofollow noreferrer">Sharing Master Pages in Visual Studio</a></li> <li><a href="http://www.odetocode.com/articles/450.aspx" rel="nofollow noreferrer">ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps </a></li> </ul> <p>The third bullets near the end the article tells you of possible ways you can share Masterpages also.</p>
<p>Use <a href="http://msdn.microsoft.com/en-us/library/aa365680%28VS.85%29.aspx" rel="nofollow noreferrer">a symbolic link</a>:</p> <blockquote> <p>A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target. Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.</p> </blockquote>
5,075
<p>I have a process in Linux that's getting a segmentation fault. How can I tell it to generate a core dump when it fails?</p>
<p>This depends on what shell you are using. If you are using bash, then the ulimit command controls several settings relating to program execution, such as whether you should dump core. If you type</p> <pre><code>ulimit -c unlimited </code></pre> <p>then that will tell bash that its programs can dump cores of any size. You can specify a size such as 52M instead of unlimited if you want, but in practice this shouldn't be necessary since the size of core files will probably never be an issue for you.</p> <p>In tcsh, you'd type</p> <pre><code>limit coredumpsize unlimited </code></pre>
<p>By default you will get a core file. Check to see that the current directory of the process is writable, or no core file will be created.</p>
3,859
<p>I've acquired all the parts to build a Reprap Prusa i3 rework, the only missing part is the frame. </p> <p>I'm in doubt between a MDF cut (cheaper) or acrylic (more expensive), of course a cheaper one is my preferred option until I see any disadvantage on making it of wood. </p> <p>I thought about variables like heat and humidity and the possibility of expansion/contraction of the frame, is this a valid concern? Will I have more precision buying the acrylic one or is it irrelevant?</p>
<p>Generally speaking, MDF will weather OK. In areas of high humidity you might experience warpage, but you can mitigate that by sealing the surface with paint or varnish. However you will probably find that of the two materials, acrylic will be more stable over a few years.</p>
<p>I want to add the following to the already direct and very good answer of @Dani Epstein. It does not answer your question, but hopefully may help many people who are reading the question when choosing between the two materials.</p> <p>Acrylic is less stable and will probably wear off faster than a well-built MDF frame for a 3D printer! I will address the points separately.</p> <ol> <li>An MDF frame has much(!) more mass than acrylic, which will reduce vibrations immediately. Almost more important, a box frame, as typical for the Prusa i3 for example, stabilizes itself intrinsically more by its 'redundant wall' design (don't beat me up over the wording here, I didn't find a better way to describe the property that results from the towers.)<br> Compare these two images taken from <a href="http://reprap.org/wiki/Prusa_i3" rel="noreferrer">reprap wiki Prusa i3</a>: <a href="https://i.stack.imgur.com/h4rDp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/h4rDp.jpg" alt="boxframe (from reprap-wiki)"></a> <a href="https://i.stack.imgur.com/PkWVF.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/PkWVF.jpg" alt="metal frame (from reprap-wiki)"></a> You will probably not find an acrylic frame with this design. Shear stress as produced by the moving carriages, as well as z-wobble from the rods should theoretically be much less.</li> <li>The acrylic might not wear by 'natural causes' since it is not a biologic material as wood is, but it will wear much faster due to handling the material, maintenance and human errors. The material is very brittle. You can find lots of reports on the web where the frame cracked or broke during setup. Here is my favorite example from someone with a lot of experience (1:20-2:30): <a href="https://www.youtube.com/watch?v=wkkVk8c8XoU" rel="noreferrer">https://www.youtube.com/watch?v=wkkVk8c8XoU</a></li> <li>Acrylic is a bad choice in terms of its mechanical properties: It is soft (I found low tensile strength as a number to compare in the given database), has lots of thermal expansion (5 times higher than stainless steel) and melts at 160 C (so beware of anything touching your hotend). Feel free to compare it to other materials here (no MDF or plywood in that database, though ;-) ): <a href="http://www.goodfellow.com/E/Polymethylmethacrylate.html" rel="noreferrer">http://www.goodfellow.com/E/Polymethylmethacrylate.html</a></li> </ol> <p>This altogether makes acrylic a very bad choice for a 3d printer frame material in my opinion. Choose MDF or plywood, you can make it look cool by painting it, too.</p>
95
<p>I set up a website to use SqlMembershipProvider as written on <a href="http://msdn.microsoft.com/en-us/library/ms998347.aspx" rel="nofollow noreferrer">this page</a>.</p> <p>I followed every step. I have the database, I modified the Web.config to use this provider, with the correct connection string, and the authentication mode is set to Forms. Created some users to test with.</p> <p>I created a Login.aspx and put the Login control on it. Everything works fine until the point that a user can log in. </p> <p>I call Default.aspx, it gets redirected to Login.aspx, I enter the user and the correct password. No error message, nothing seems to be wrong, but I see again the Login form, to enter the user's login information. However if I check the cookies in the browser, I can see that the cookie with the specified name exists.</p> <p>I already tried to handle the events by myself and check, what is happening in them, but no success.</p> <p>I'm using VS2008, Website in filesystem, SQL Express 2005 to store aspnetdb, no role management, tested with K-Meleon, IE7.0 and Chrome.</p> <p>Any ideas?</p> <p><strong>Resolution:</strong> After some mailing with Rob we have the ideal solution, which is now the accepted answer.</p>
<p>I have checked the code over in the files you have sent me (thanks again for sending them through).</p> <p><strong>Note: I have not tested this since I have not installed the database etc..</strong></p> <p>However, I am pretty sure this is the issue.</p> <p>You need to set the <em>MembershipProvider</em> Property for your ASP.NET controls. Making the definitions for them:</p> <pre><code>&lt;asp:Login ID=&quot;Login1&quot; runat=&quot;server&quot; MembershipProvider=&quot;MySqlMembershipProvider&quot;&gt; &lt;LayoutTemplate&gt; &lt;!-- template code snipped for brevity --&gt; &lt;/LayoutTemplate&gt; &lt;/asp:Login&gt; </code></pre> <p>And..</p> <pre><code>&lt;asp:CreateUserWizard ID=&quot;CreateUserWizard1&quot; runat=&quot;server&quot; MembershipProvider=&quot;MySqlMembershipProvider&quot;&gt; &lt;WizardSteps&gt; &lt;asp:CreateUserWizardStep runat=&quot;server&quot; /&gt; &lt;asp:CompleteWizardStep runat=&quot;server&quot; /&gt; &lt;/WizardSteps&gt; &lt;/asp:CreateUserWizard&gt; </code></pre> <p>This then binds the controls to the Membership Provider with the given name (which you have specified in the Web.Config.</p> <p>Give this a whirl in your solution and let me know how you get on. I hope this works for you :)</p> <h3>Edit</h3> <p>I should also add, I know you shouldn't need to do this as the default provider is set, but I <em>have</em> had problems in the past with this.. I ended up setting them all to manual and all worked fine.</p>
<p>Have you checked that the redirect path is being sent to the login form? Off my head I think it is <strong>ReturnURL</strong>?</p>
8,735
<p>I know that default cron's behavior is to send normal and error output to cron's owner local email box.</p> <p>Is there other ways to get theses results (for example to send it by email to a bunch of people, to store them somewhere, and so on) ?</p>
<p>You could chuck file redirection onto either the command shown or the actual command in the crontab for both stdout and stderr - like <code>command &gt; /tmp/log.txt 2&gt;&amp;1</code> .</p> <p>If you want several users to receive this log, you could insert a <code>MAILTO=nameofmailinglist</code> at the top of you cron file.</p>
<p>The cron line is just like any other unix command line so you can redirect output to another program. Ie.</p> <pre><code>* * * * * /path/my/command &gt; /my/email/script 2&amp;&gt;1 </code></pre>
6,496
<p>Is there a one line function call that quits the program and displays a message? I know in Perl it's as simple as:</p> <pre><code>die("Message goes here") </code></pre> <p>I'm tired of typing this:</p> <pre><code>puts "Message goes here" exit </code></pre>
<p>The <code>abort</code> function does this. For example:</p> <pre><code>abort("Message goes here") </code></pre> <p>Note: the <code>abort</code> message will be written to <code>STDERR</code> as opposed to <code>puts</code> which will write to <code>STDOUT</code>.</p>
<p>I've never heard of such a function, but it would be trivial enough to implement...</p> <pre><code>def die(msg) puts msg exit end </code></pre> <p>Then, if this is defined in some .rb file that you include in all your scripts, you are golden.... just because it's not built in doesn't mean you can't do it yourself ;-)</p>
4,920
<p>I started using rafts more often, to get better results with complex or fragile parts, but my Ender 3 consistently under-extrudes the initial outside line of the raft (for the first inch or two, where extrusion starts). </p> <p>It is often very thin and does not adhere. This often leads to problems with the following pattern of raft layer 1 curling up (ABS) as it does not meet the edge line (due to the 1-2 inch gap in the perimeter).</p> <p>Skirts avoid this problem by getting the flow going, but rafts only print a single outer line.</p> <ol> <li>Is it possible to specify more than one outer line on a raft in Ultimaker Cura?</li> <li>Is it possible to add a skirt to a print that has a raft (or at least some initial printing to get the flow going)?</li> <li>Is it possible to add some initial G-code that will extrude a line, say from near the start position to the start of the print?</li> </ol> <p><img src="https://i.stack.imgur.com/zqaay.jpg" alt="example of problem"></p>
<p>In Ultimaker Cura you can select only one of the the build plate adhesion options skirt, brim or raft. You cannot select multiple options. </p> <p>There is no option available in Ultimaker Cura to increase the outline count of the raft bed adhesion structure. Basically the raft exists of a line support structure as can be seen in the figure below. <a href="https://i.stack.imgur.com/33dg0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/33dg0.png" alt="Ultimaker raft support structure layout"></a> The line around the lines should be considered "the skirt", so if the nozzle is not properly primed (not sufficient molten filament available), you need to properly prime the nozzle prior to printing.</p> <p>To prime the nozzle, you need to add some extrusion of filament in your start G-code.</p> <p>Personally, I like the style of Ultimaker where prior to printing, a puddle of filament is deposited priming the nozzle adequately. Basically you need to move to a position where you like to deposit filament:</p> <pre><code> G1 X10 Y10 Z2 </code></pre> <p>Then you need to extrude material</p> <pre><code> G1 F125 G1 E10 G1 Z3 E5 </code></pre> <p>After that you can even <a href="/a/6356/5740">wipe</a> the nozzle.</p> <p>Another option (that requires some copy/pasting from your side and would not be a recommended practice) that is possible is slicing the model with a skirt (with a sufficient distance to stay away from the raft position) instead of a raft and look at the generated G-code and copy the skirt deposition codes into the raft G-code file. You do need to take care of the proper length of the extruder when the skirt followed by the raft, so you need to use <code>G92 Exx.xx</code> where xx.xx is the actual length of the filament start for the raft. </p>
<p>It's not necessarily the case that the apparent underextrusion of a small portion of your raft is the root cause. ABS is notorious for shrinkage and peeling. As a start, you should have a full enclosure so as to maintain a warm environment while printing. </p> <p>It's also quite possible that your bed is slightly off-level or a few microns low for the first layer, either of which can cause adhesion problems. </p> <p>Yes, it's pretty much trivial to add a few lines of gcode to extrude prior to the "official" raft -- or you could just toss a fake small object into your slicer to extend the raft over both the real and the fake parts. </p> <p>FWIW, with a little care I've found a wide brim outperforms a raft for almost anything I print</p>
1,083
<p>How should I load files into my Java application?</p>
<p><strong>The short answer</strong></p> <p>Use one of these two methods:</p> <ul> <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getResource(java.lang.String)" rel="noreferrer"><code>Class.getResource(String)</code></a></li> <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String)" rel="noreferrer"><code>Class.getResourceAsStream(String)</code></a></li> </ul> <p>For example:</p> <pre><code>InputStream inputStream = YourClass.class.getResourceAsStream("image.jpg"); </code></pre> <p>--</p> <p><strong>The long answer</strong></p> <p>Typically, one would not want to load files using absolute paths. For example, don’t do this if you can help it:</p> <pre><code>File file = new File("C:\\Users\\Joe\\image.jpg"); </code></pre> <p>This technique is not recommended for at least two reasons. First, it creates a dependency on a particular operating system, which prevents the application from easily moving to another operating system. One of Java’s main benefits is the ability to run the same bytecode on many different platforms. Using an absolute path like this makes the code much less portable.</p> <p>Second, depending on the relative location of the file, this technique might create an external dependency and limit the application’s mobility. If the file exists outside the application’s current directory, this creates an external dependency and one would have to be aware of the dependency in order to move the application to another machine (error prone).</p> <p>Instead, use the <code>getResource()</code> methods in the <code>Class</code> class. This makes the application much more portable. It can be moved to different platforms, machines, or directories and still function correctly.</p>
<pre><code>public static String loadTextFile(File f) { try { BufferedReader r = new BufferedReader(new FileReader(f)); StringWriter w = new StringWriter(); try { String line = reader.readLine(); while (null != line) { w.append(line).append("\n"); line = r.readLine(); } return w.toString(); } finally { r.close(); w.close(); } } catch (Exception ex) { ex.printStackTrace(); return ""; } } </code></pre>
2,837
<p>My gut feel is that document based web services are preferred in practice - is this other peoples experience? Are they easier to support? (I noted that SharePoint uses Any for the "document type" in its WSDL interface, I guess that makes it Document based). </p> <p>Also - are people offering both WSDL and Rest type services now for the same functionality? WSDL is popular for code generation, but for front ends like PHP and Rails they seem to prefer rest.</p>
<p>Document versus RPC is only a question if you are using SOAP Web Services which require a service description (<a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" rel="noreferrer">WSDL</a>). RESTful web services do not not use WSDL because the service can't be described by it, and the feeling is that REST is simpler and easier to understand. Some people have proposed <a href="http://en.wikipedia.org/wiki/Web_Application_Description_Language" rel="noreferrer">WADL</a> as a way to describe REST services.</p> <p>Languages like Python, Ruby and PHP make it easier to work with REST. the WSDL is used to generate C# code (a web service proxy) that can be easily called from a static language. This happens when you add a <em>Service Reference</em> or <em>Web Reference</em> in Visual Studio.</p> <p>Whether you provide SOAP or REST services depends on your user population. Whether the services are to be used over the internet or just inside your organization affects your choice. SOAP may have some features (WS-* standards) that work well for B2B or internal use, but suck for an internet service.</p> <p>Document/literal versus RPC for SOAP services are described on this <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/" rel="noreferrer">IBM DevelopWorks article</a>. Document/literal is generally considered the best to use in terms of interoperability (Java to .NET etc). As to whether it is easier to support, that depends on your circumstances. My personal view is that people tend to make this stuff more complicated than it needs to be, and REST's simpler approach is superior.</p>
<p>BiranLy's answer is excellent. I would just like to add that document-vs-RPC can come down to implementation issues as well. We have found Microsoft to be Document-preferring, while our Java-based libraries were RPC-based. Whatever you choose, make sure you know what other potential clients will assume as well.</p>
2,745
<p>I'm having a &quot;minor&quot; stringing issue, where I'm only getting stringing in helpers/support and infill area.</p> <p>Background: Calibrating printer with 1 roll of PLA. Still getting minimal stringing, but mainly, stringing in helpers/support and infill areas. Tried different temps, but didn't seem to affect this.</p> <p>Suspect some kind of slicer optimization settings? I mean, it's logical to not care about how pretty supports &amp; infill look.</p> <p>I would like to understand why this is happening. Please point me to the right direction. Thanks in advance.</p> <p>Example photo: Outside in: brim, shell/wall, support, brim. From <a href="https://www.thingiverse.com/thing:4512926" rel="nofollow noreferrer">Thingiverse</a>.</p> <p><a href="https://i.stack.imgur.com/hEX6f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hEX6f.jpg" alt="Photo" /></a></p>
<p>If the problem occurs in or immediately following printing of support material, it's probably Cura's <em>Limit Support Retractions</em> option, which defaults to on. This is probably the single worst default Cura has, and it causes all sorts of problems - surface defects, difficult-to-remove support, underextrusion, etc. - due to basically skipping all (necessary!) retractions while printing support.</p> <p>If the problem occurs in infill area, it's probably <em>Combing</em>. Lowering <em>Max Comb Distance With No Retract</em> to something very low (150-200% of the nozzle width, so like 0.8 mm) should make this problem go away, but at some nontrivial cost to print time. If you make this change, you almost surely need <em>Zig-zaggify Infill</em> enabled if you want to avoid very high cost to print time and excessive retractions.</p>
<p>It would be great if you could add an image showing the stringing that occurs on the filled and helper/support part of the print. It's quite difficult to visualise what is happening/your problem.</p> <p>I would assume that the density/fill of the print will be different for infill versus helper/support parts of the print. As a result, there are more gaps in the helper/support parts and stringing can more easily occur between them.</p> <p>Have you tried enabling z-hop/retraction to prevent further stringing?</p>
1,862
<p>I admit I know enough about COM and IE architecture only to be dangerous. I have a working C# .NET ActiveX control similar to this:</p> <pre><code>using System; using System.Runtime.InteropServices; using BrowseUI; using mshtml; using SHDocVw; using Microsoft.Win32; namespace CTI { public interface CTIActiveXInterface { [DispId(1)] string GetMsg(); } [ComVisible(true), ClassInterface(ClassInterfaceType.AutoDual)] public class CTIActiveX : CTIActiveXInterface { /*** Where can I get a reference to SHDocVw.WebBrowser? *****/ SHDocVw.WebBrowser browser; public string GetMsg() { return "foo"; } } } </code></pre> <p>I registered and created a type library using regasm:</p> <pre><code>regasm CTIActiveX.dll /tlb:CTIActiveXNet.dll /codebase </code></pre> <p>And can successfully instantiate this in javascript:</p> <pre><code>var CTIAX = new ActiveXObject("CTI.CTIActiveX"); alert(CTIAX.GetMsg()); </code></pre> <p>How can I get a reference to the client site (browser window) within CTIActiveX? I have done this in a BHO by implementing IObjectWithSite, but I don't think this is the correct approach for an ActiveX control. If I implement any interface (I mean COM interface like IObjectWithSite) on CTIActiveX when I try to instantiate in Javascript I get an error that the object does not support automation.</p>
<p>First, your interface needs ComVisible(true) in order to be seen by the calling script (this is probably causing the error). </p> <p>Second, add a .NETreference in your project to "Microsoft.mshtml". This will import the COM interfaces for various IE-related things (windows, HTML documents, etc.)</p> <p>Then, you need to add a property of type IHtmlDocument2 to your interface:</p> <pre><code>IHtmlDocument2 Document { set; } </code></pre> <p>...implement it in your class:</p> <pre><code>public IHtmlDocument2 Document { set { _doc = value;} } </code></pre> <p>...call it from script</p> <pre><code>CTIAX.Document = document; </code></pre> <p>...once you have stored a reference to the document, you can use it at will to get to the window, other frames, or any part of the HTML DOM that you wish.</p>
<p>There a simple and cleaner way to do it:</p> <pre><code>public void GetBrowser() { ShellWindows m_IEFoundBrowsers = new ShellWindows(); foreach (InternetExplorer Browser in m_IEFoundBrowsers) { webBrowser = (SHDocVw.WebBrowser) Browser; // do what you want ... } } </code></pre>
9,762
<p>I have an stl with multiple parts that I want to split up. Cura 15 had an option to "split object into parts" but I can't find that in cura 2.4. Did it get removed?</p>
<p>I don't think this feature was implemented at all with Cura v2.x. </p> <p>As the developers say on the v2.1 release, "Cura has been completely reengineered". </p> <p>Finding proper changelog documentation appears to be pretty hard because they have not posted any actual changelogs except the "user friendly viewable" changelogs which only list additions of new features but don't display what everything they changed between each version of their application.</p> <p>Here is the most complete changelog I could find. I do not see any mention of this feature. <a href="https://ultimaker.com/en/products/cura-software/release-notes" rel="noreferrer">https://ultimaker.com/en/products/cura-software/release-notes</a> </p> <p>Going through the Cura 2 manual or the Cura 2.1 FAQ, also does not mention this feature. <a href="https://ultimaker.com/en/resources/20406-installation-cura-2-1" rel="noreferrer">https://ultimaker.com/en/resources/20406-installation-cura-2-1</a> </p> <p>Furthermore, searching around for version 2 "split objects" lead to forum posts of people suggesting to use some other software to achieve this specific task. If you decide to go this route, I recommend Meshmixer from Autodesk to manipulate your models and then export to STL and import them to Cura either as a whole new position set up or separate model files where you can change them there as you need to (meshmixer allows for object repositioning around a defined build plate so you can just import the whole assembly into cura and then print).</p> <p>It might also be worth to put in a feature request on the UM forums.</p>
<p>I think they removed it because it was inefficient (pretty slow). Still, I just started 3D printing and was a bit disappointed a seemingly easy task needed an other software (Meshmixer) to be achieved.</p>
546
<p>There's plenty of them out there but none of them do what I would like them to do.</p> <p>Most of them crash when opening a file or simply corrupt the data. Many don't run at all. It seems to me that most were written 3-4 years ago for AS2 .sols and no longer work with FP9/AS3 sols. I'd attempt to write my own using AIR but I can't find a new spec of the byte format.</p> <p>There's an explanation of the file format here: <a href="http://sourceforge.net/docman/display_doc.php?docid=27026&amp;group_id=131628" rel="noreferrer">http://sourceforge.net/docman/display_doc.php?docid=27026&amp;group_id=131628</a></p> <p>and another here: <a href="http://sourceforge.net/docman/display_doc.php?docid=27026&amp;group_id=131628" rel="noreferrer">http://sourceforge.net/docman/display_doc.php?docid=27026&amp;group_id=131628</a></p> <p>but it looks as though both of these docs are a good 4 years old (pre-FP9) and as I'm not skilled or experienced in file formats, writing a new one, especially without an updated spec, is seeming like less and less of a viable option. </p> <p>Ideally I'd like one that can not only read the .sol, but edit and save new values also.</p> <p>Thanks!</p>
<p>Use <a href="http://blog.coursevector.com/minerva" rel="noreferrer">minerva</a>. I've tried it, it works with every .sol I open it with.</p>
<p>I'm confused, isn't the best editor for Flash 9 shared objects... Flash? It already has methods for loading, editing and saving them.</p> <hr> <p>So make the editor and put it on your website. You won't get any security errors from flash, and then just throw a password around it so regular people can't edit their .sol files.</p> <hr> <p>Yes, they are restricted by domain, so it'd have to live on the publishers sites. If you have hundreds of clients, that might be an issue, but if you have 3 or 4... It's certainly easier than coding your own file format parser.</p>
8,965
<p>I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is it? How do I use it?</p>
<p>You could use <a href="http://msdn.microsoft.com/en-us/library/system.string.split.aspx" rel="noreferrer" title="String.Split method msdn reference">String.Split method</a>.</p> <pre><code>class ExampleClass { public ExampleClass() { string exampleString = "there is a cat"; // Split string on spaces. This will separate all the words in a string string[] words = exampleString.Split(' '); foreach (string word in words) { Console.WriteLine(word); // there // is // a // cat } } } </code></pre> <p>For more information see <a href="http://www.dotnetperls.com/split" rel="noreferrer" title="C# Split String Examples by Sam Allen">Sam Allen's article about splitting strings in c#</a> (Performance, Regex)</p>
<p>If you are using C# 3.5 you could write an extension method to System.String that does the splitting you need. You then can then use syntax:</p> <pre><code>string.SplitByMyTokens(); </code></pre> <p>More info and a useful example from MS here <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb383977.aspx</a></p>
9,580
<p>In Java, say you have a class that wraps an <code>ArrayList</code> (or any collection) of objects. </p> <p>How would you return one of those objects such that the caller will not see any future changes to the object made in the ArrayList? </p> <p>i.e. you want to return a deep copy of the object, but you don't know if it is cloneable.</p>
<p>Turn that into a spec:<br> -that objects need to implement an interface in order to be allowed into the collection Something like <code>ArrayList&lt;ICloneable&gt;()</code></p> <p>Then you can be assured that you always do a deep copy - the interface should have a method that is guaranteed to return a deep copy. </p> <p>I think that's the best you can do. </p>
<p>I suppose it is an ovbious answer:</p> <p>Make a requisite for the classes stored in the collection to be cloneable. You could check that at insertion time or at retrieval time, whatever makes more sense, and throw an exception.</p> <p>Or if the item is not cloneable, just fail back to the return by reference option.</p>
4,962
<p>We are about to get a canned package in that has been modified to our needs. I'm part of the team setup to prepare tests for it. It has an Oracle back end and I believe it's written in C++ .NET.</p> <p>My question is what free or open source testing tools would you recommend.</p> <p>Thanks</p> <p>Ken</p>
<p>For regression testing of our applications I use a free tool called AutoHotKey <a href="http://www.autohotkey.com/" rel="nofollow noreferrer">http://www.autohotkey.com/</a>. It is simple, batch configurable, and can work for virtually any application you have. Not exactly designed for black box testing, but a good free tool to add to your toolbox.</p> <p>While there are a few good commercial applications for black box testing of applications (HoloDeck <a href="http://www.sisecure.com/holodeck/index.shtml" rel="nofollow noreferrer">http://www.sisecure.com/holodeck/index.shtml</a>, Cenzic Hailstorm <a href="http://www.cenzic.com/" rel="nofollow noreferrer">http://www.cenzic.com/</a>), the only open source applications that I know about only test network security (Spike <a href="http://www.immunitysec.com/resources-freesoftware.shtml" rel="nofollow noreferrer">http://www.immunitysec.com/resources-freesoftware.shtml</a>, OWASP WebScarab <a href="http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project" rel="nofollow noreferrer">http://www.owasp.org/index.php/Category:OWASP_WebScarab_Project</a>, and Nikto <a href="http://www.cirt.net/nikto2" rel="nofollow noreferrer">http://www.cirt.net/nikto2</a>)</p>
<p>What do you expect from such a tool? I don't know of any tool that can arbitrarily test any piece of software.</p>
6,323
<p>As my first project, I'm trying to design a holder for glass vials, for a scientific application. The photo below shows the latest design iteration, and also shows the problem with it:</p> <p><a href="https://i.stack.imgur.com/7vqSam.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/7vqSam.jpg" alt="vial holder"></a></p> <p>As you can see, one of the clips that's meant to hold the vial in place has broken off. This happened after inserting the vial once or twice.</p> <p>I think I understand the reason for this. It's because I'm printing in the orientation shown below, in order to avoid the need for supports. (This will be more important later, when I scale it up to an array of many holders.) This means that it's relying on the strength in the z dimension, which is much weaker than in the other two directions, because it relies on the cohesion between the layers.</p> <p><a href="https://i.stack.imgur.com/aOyctm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/aOyctm.jpg" alt="enter image description here"></a></p> <p>My question is whether I can do anything about this by changing the design of the clips, without abandoning my hope of support-free printing. I don't care at all what the design looks like, except that as much of the vial as possible needs to be visible from the front. I'm printing in ABS.</p> <p>I have tried varying the thickness of the clips. Thinner ones don't break as easily, but they are a bit floppy and aren't very good at keeping the vial vertical. The ones shown are the thickest I've tried - I'm afraid that if they're too thick they won't bend at all. (The vial is supposed to be inserted from the front rather than the top.)</p> <p><strong>Edit</strong> just as an update, here's what it looks like using John Biddle's suggestion, which works perfectly:</p> <p><a href="https://i.stack.imgur.com/w3qeG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/w3qeG.png" alt="enter image description here"></a></p>
<p>It looks like those clips are thin and need to bend pretty far to let the vial out. Try to make the clips thicker, but with a smaller clip to retain the vial so that it doesn't have to bend as much. </p> <p>This is what I'm thinking, in beautiful MS-PAINT form:<br> <a href="https://i.stack.imgur.com/evTyz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/evTyz.png" alt="enter image description here"></a></p>
<p>If you don't want your clip to break, you'll have to engineer in some form of flexibility in a strong part of your design. For example, right now it looks like the bases of the clips are sitting rather solidly on the underlying surface such that it can't move. I'd suggest that instead it might be better to have two clips attach separately to the bottom using a "post", and have each post attached to the solid part of the base with a piece of plastic whose horizontal cross-section is a somewhat-rounded accordion-style double zig-zag.</p> <p>From the top: <a href="https://i.stack.imgur.com/cIUa8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cIUa8.png" alt="Top view"></a></p> <p>Having multiple "pleats" will mean that each degree that the clips flex outward will only require each pleat to flex a fraction of a degree. You'd have to play around to find out what number of pleats would give a suitable degree of stiffness and flexibility, but if the printer renders the design by drawing the zig zags, stresses should be concentrated in the directions where the material is strongest.</p>
225
<p>Using a thermoplastic MDF printer with a 0.4mm extruder nozzle, I frequently have trouble with the nozzle getting clogged.</p> <p>I am not sure what's causing the clog, but my guesses are dust and/or burnt filament (from leaving the hot end on without extruding).</p> <p>What can I do to prevent, or at least minimize, the extruder nozzle getting clogged?</p> <p>Bonus question: What other common causes of clogs are there? (ie what should I watch out for besides dust and leaving the hot end on?)</p>
<p>Different types of hotends and extruders can lead to different problems associated with clogging. Based on my personal experience the leading causes of clogs and jams are the following</p> <ol> <li>Foreign material in the nozzle (dirt, dust, low quality filament)</li> <li>Mixing materials in the hotend (running ABS at 220 then switching to PLA without purging the nozzle)</li> <li>Excessive retraction or "heat soak" in PLA (PLA expands when heated if your retraction is set to high you can actually push the expanded PLA high enough that it cools down and can no longer flow)</li> </ol> <p>To solve these issues I recommend using one type of filament, preferably decent quality (typically $40 per kg), if you swap materials be sure to completely purge your nozzle of the higher temperature material. Set your retraction as low as you can trying to minimize ooze (try .4 mm for all metal hotend or 2-3 mm for makerbot style). To minimize carbonized plastic in your hotend don't leave your hotend's heater on for extended periods of time. One way to keep dust from accumulating on your filament is to cover your rolls when you aren't using them, I personally use hairnets, you can buy a 12 pack for a couple of dollars and they last for a long time.</p>
<p>First, you don't.</p> <p>To reduce the likelyhood, use good plastics without contaminations. </p> <p>Do not over heat the plastic, causes faster carbon build up.</p> <p>Buy hand drills, mini drills to clear it.</p> <p>Don't switch materials around a lot. Low temp plastic residue will cook when you switch to high temp plastic. Again carbon.</p> <p>Last will come to your extruder is self. Use a hardened extruder tip, less likely to wear. All metal should help a lot too, PTEF tubes often get baked in a jam situation.</p> <p>Or do what I do. I use a giant 1mm nozzle. I have printed at least 20 lbs of plastic on the same nozzle.</p> <p>The other solutions say put oil etc.. I will just say that is not a great idea. First you will have terrible bed adhesion, second it just seems wrong. Not to mention it will be out of the extruder within one KG?. The only time its okay to use oil is if you have a bowden setup.</p>
132
<h3>Update: Solved, with code</h3> <p><a href="https://stackoverflow.com/questions/18585/why-cant-you-bind-the-size-of-a-windows-form-to-applicationsettings#19056">I got it working, see my answer below for the code...</a></p> <h3>Original Post</h3> <p>As Tundey pointed out in <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c#18456">his answer</a> to my <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c">last question</a>, you can bind nearly everything about a windows forms control to ApplicationSettings pretty effortlessly. So is there really no way to do this with form Size? <a href="http://www.codeproject.com/KB/cs/UserSettings.aspx" rel="nofollow noreferrer">This tutorial</a> says you need to handle Size explicitly so you can save RestoreBounds instead of size if the window is maximized or minimized. However, I hoped I could just use a property like:</p> <pre><code>public Size RestoreSize { get { if (this.WindowState == FormWindowState.Normal) { return this.Size; } else { return this.RestoreBounds.Size; } } set { ... } } </code></pre> <p>But I can't see a way to bind this in the designer (Size is notably missing from the PropertyBinding list).</p>
<p>I finally came up with a Form subclass that solves this, once and for all. To use it:</p> <ol> <li>Inherit from RestorableForm instead of Form.</li> <li>Add a binding in (ApplicationSettings) -> (PropertyBinding) to WindowRestoreState.</li> <li>Call Properties.Settings.Default.Save() when the window is about to close.</li> </ol> <p>Now window position and state will be remembered between sessions. Following the suggestions from other posters below, I included a function ConstrainToScreen that makes sure the window fits nicely on the available displays when restoring itself.</p> <h3>Code</h3> <pre><code>// Consider this code public domain. If you want, you can even tell // your boss, attractive women, or the other guy in your cube that // you wrote it. Enjoy! using System; using System.Windows.Forms; using System.ComponentModel; using System.Drawing; namespace Utilities { public class RestorableForm : Form, INotifyPropertyChanged { // We invoke this event when the binding needs to be updated. public event PropertyChangedEventHandler PropertyChanged; // This stores the last window position and state private WindowRestoreStateInfo windowRestoreState; // Now we define the property that we will bind to our settings. [Browsable(false)] // Don't show it in the Properties list [SettingsBindable(true)] // But do enable binding to settings public WindowRestoreStateInfo WindowRestoreState { get { return windowRestoreState; } set { windowRestoreState = value; if (PropertyChanged != null) { // If anybody's listening, let them know the // binding needs to be updated: PropertyChanged(this, new PropertyChangedEventArgs("WindowRestoreState")); } } } protected override void OnClosing(CancelEventArgs e) { WindowRestoreState = new WindowRestoreStateInfo(); WindowRestoreState.Bounds = WindowState == FormWindowState.Normal ? Bounds : RestoreBounds; WindowRestoreState.WindowState = WindowState; base.OnClosing(e); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (WindowRestoreState != null) { Bounds = ConstrainToScreen(WindowRestoreState.Bounds); WindowState = WindowRestoreState.WindowState; } } // This helper class stores both position and state. // That way, we only have to set one binding. public class WindowRestoreStateInfo { Rectangle bounds; public Rectangle Bounds { get { return bounds; } set { bounds = value; } } FormWindowState windowState; public FormWindowState WindowState { get { return windowState; } set { windowState = value; } } } private Rectangle ConstrainToScreen(Rectangle bounds) { Screen screen = Screen.FromRectangle(WindowRestoreState.Bounds); Rectangle workingArea = screen.WorkingArea; int width = Math.Min(bounds.Width, workingArea.Width); int height = Math.Min(bounds.Height, workingArea.Height); // mmm....minimax int left = Math.Min(workingArea.Right - width, Math.Max(bounds.Left, workingArea.Left)); int top = Math.Min(workingArea.Bottom - height, Math.Max(bounds.Top, workingArea.Top)); return new Rectangle(left, top, width, height); } } } </code></pre> <h3>Settings Bindings References</h3> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.settingsbindableattribute.aspx" rel="noreferrer">SettingsBindableAttribute</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" rel="noreferrer">INotifyPropertyChanged</a></li> </ul>
<p>Well I have had a quick play with this and you are correct, while there is no way to directly <em>bind</em> the size of the form to AppSettings, you can add your own values and change the size on load.</p> <p>I would perhaps recommend that if this is a common feature, you subclass Form and make it automatically prob the App.Config for the forms size settings.</p> <p>(Or you could roll your own file.. Get it to query an Xml file "formname.settings.xml" or something? - thinking out loud!)..</p> <p>Heres what I had (very rough, no error checking etc).</p> <h2>App.Config</h2> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;appSettings&gt; &lt;add key ="FormHeight" value="500" /&gt; &lt;add key ="FormWidth" value="200"/&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <h2>Form Code</h2> <pre><code> private void Form1_Load(object sender, EventArgs e) { string height = ConfigurationManager.AppSettings["FormHeight"]; int h = int.Parse(height); string width = ConfigurationManager.AppSettings["FormWidth"]; int w = int.Parse(width); this.Size = new Size(h, w); } </code></pre>
3,912
<p>Trying to find some simple SQL Server PIVOT examples. Most of the examples that I have found involve counting or summing up numbers. I just want to pivot some string data. For example, I have a query returning the following.</p> <pre><code>Action1 VIEW Action1 EDIT Action2 VIEW Action3 VIEW Action3 EDIT </code></pre> <p>I would like to use PIVOT (if even possible) to make the results like so:</p> <pre><code>Action1 VIEW EDIT Action2 VIEW NULL Action3 VIEW EDIT </code></pre> <p>Is this even possible with the PIVOT functionality?</p>
<p>Remember that the MAX aggregate function will work on text as well as numbers. This query will only require the table to be scanned once.</p> <pre><code>SELECT Action, MAX( CASE data WHEN 'View' THEN data ELSE '' END ) ViewCol, MAX( CASE data WHEN 'Edit' THEN data ELSE '' END ) EditCol FROM t GROUP BY Action </code></pre>
<p>I had a situation where I was parsing strings and the first two positions of the string in question would be the field names of a healthcare claims coding standard. So I would strip out the strings and get values for F4, UR and UQ or whatnot. This was great on one record or a few records for one user. But when I wanted to see hundreds of records and the values for all usersz it needed to be a PIVOT. This was wonderful especially for exporting lots of records to excel. The specific reporting request I had received was "every time someone submitted a claim for Benadryl, what value did they submit in fields F4, UR, and UQ. I had an OUTER APPLY that created the ColTitle and the value fields below</p> <pre><code>PIVOT( min(value) FOR ColTitle in([F4], [UR], [UQ]) ) </code></pre>
4,408
<p>I have tried both of :</p> <pre><code>ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes'); </code></pre> <p>and also :</p> <pre><code>php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes" </code></pre> <p>in the .htaccess file.</p> <p>Both methods actually <strong>do work</strong> but only intermittently. That is, they will work fine for about 37 pages requests and then fail about 42 pages requests resulting in an require() call to cause a fatal error effectively crashing the site.</p> <p>I'm not even sure where to begin trying to find out what is going on!</p> <hr> <p>@<a href="https://stackoverflow.com/questions/41836/setting-include-path-in-php-intermittently-fails-why#41877">cnote</a></p> <blockquote> <p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p> </blockquote> <p>The in script version was originally </p> <pre><code>ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'classes'); </code></pre> <p>and thus the .:.: was coming from the existing path:</p> <pre><code>ini_get('include_path') </code></pre> <p>I tried removing it anyway and the problem persists.</p>
<p>It turned out the issue was related to a PHP bug in 5.2.5</p> <p>Setting an "admin_flag" for include_path caused the include path to be empty in some requests, and Plesk sets an admin_flag in the default config for something or other. An update of PHP solved the issue.</p> <p><a href="http://bugs.php.net/bug.php?id=43677" rel="nofollow noreferrer">http://bugs.php.net/bug.php?id=43677</a></p>
<p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p>
6,321
<p>I have a simple webform that will allow unauthenticated users to input their information, including name. I gave the name field a limit of 50 characters to coincide with my database table where the field is <code>varchar(50)</code>, but then I started to wonder.</p> <p>Is it more appropriate to use something like the <code>Text</code> column type or should I limit the length of the name to something reasonable?</p> <p>I'm using SQL Server 2005, in case that matters in your response.</p> <p><strong>EDIT:</strong> I did not see <a href="https://stackoverflow.com/questions/20958/list-of-standard-lengths-for-database-fields">this broader question</a> regarding similar issues.</p>
<p><a href="http://webarchive.nationalarchives.gov.uk/20100407120701/http://cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards.aspx" rel="noreferrer">UK Government Data Standards Catalogue</a> suggests 35 characters for each of Given Name and Family Name, or 70 characters for a single field to hold the Full Name.</p>
<p>The average first name is about 6 letters. That leaves 43 for a last name. :) Seems like you could probably shorten it if you like.</p> <p>The main question is how many rows do you think you will have? I don't think varchar(50) is going to kill you until you get several million rows.</p>
5,035
<p>I've tried to do this several times with no luck. After reading <a href="https://stackoverflow.com/questions/1451/what-is-the-best-way-to-handle-multiple-permission-types#1477">this post</a>, it made me interested in doing this again. So can anyone tell me why the following doesn't work?</p> <pre><code>&lt;?php $guest = 1; $editor = 2; $admin = 4; $user = $editor; if( $user == ($editor | $admin) ) { echo "Test"; } ?&gt; </code></pre>
<p>Use the bitwise OR operator (|) to set bits, use the AND operator (&amp;) to check bits. Your code should look like this:</p> <pre><code>&lt;?php $guest = 1; $editor = 2; $admin = 4; $user = $editor; if( $user &amp; ($editor | $admin) ) { echo "Test"; } ?&gt; </code></pre> <p>If you don't understand binary and exactly what the bitwise operators do, you should go learn it. You'll understand how to do this much better.</p>
<p>In my opinion this doesn't scale well. I haven't actually tried using it on a large scale project, but a CMS sounds way to complicated to use this on.</p>
3,787
<p>I have a Question class:</p> <pre><code>class Question { public int QuestionNumber { get; set; } public string Question { get; set; } public string Answer { get; set; } } </code></pre> <p>Now I make an ICollection of these available through an ObjectDataSource, and display them using a Repeater bound to the DataSource. I use <strong>&lt;%#Eval("Question")%></strong> to display the Question, and I use a TextBox and <strong>&lt;%#Bind("Answer")%></strong> to accept an answer.</p> <p>If my ObjectDataSource returns three Question objects, then my Repeater displays the three questions with a TextBox following each question for the user to provide an answer.</p> <p>So far it works great.</p> <p>Now I want to take the user's response and put it back into the relevant Question classes, which I will then persist.</p> <p>Surely the framework should take care of all of this for me? I've used the Bind method, I've specified a DataSourceID, I've specified an Update method in my ObjectDataSource class, but there seems no way to actually kickstart the whole thing.</p> <p>I tried adding a Command button and in the code behind calling MyDataSource.Update(), but it attempts to call my Update method with no parameters, rather than the Question parameter it expects.</p> <p>Surely there's an easy way to achieve all of this with little or no codebehind?</p> <p>It seems like all the bits are there, but there's some glue missing to stick them all together.</p> <p>Help!</p> <p>Anthony</p>
<p>You have to handle the postback event (button click or whatever) then enumerate the repeater items like this:</p> <pre><code>foreach(RepeaterItem item in rptQuestions.Items) { //pull out question var question = (Question)item.DataItem; question.Answer = ((TextBox)item.FindControl("txtAnswer")).Text; question.Save() ? &lt;--- not sure what you want to do with it } </code></pre>
<p>Then what's the point in the Bind method (as opposed to the Eval method) if I have to bind everything back up manually on postback?</p>
7,573
<p>I wrote a piece of code to convert PHP's striplashes into valid Python [backslash] escapes:</p> <pre><code>cleaned = stringwithslashes cleaned = cleaned.replace('\\n', '\n') cleaned = cleaned.replace('\\r', '\n') cleaned = cleaned.replace('\\', '') </code></pre> <p>How can I condense it? </p>
<p>Not totally sure this is what you want, but..</p> <pre><code>cleaned = stringwithslashes.decode('string_escape') </code></pre>
<p>Python has a built-in escape() function analogous to PHP's addslashes, but no unescape() function (stripslashes), which in my mind is kind of ridiculous.</p> <p>Regular expressions to the rescue (code not tested):</p> <pre><code>p = re.compile( '\\(\\\S)') p.sub('\1',escapedstring) </code></pre> <p>In theory that takes anything of the form \\(not whitespace) and returns \(same char)</p> <p>edit: Upon further inspection, Python regular expressions are broken as all hell;</p> <pre><code>&gt;&gt;&gt; escapedstring 'This is a \\n\\n\\n test' &gt;&gt;&gt; p = re.compile( r'\\(\S)' ) &gt;&gt;&gt; p.sub(r"\1",escapedstring) 'This is a nnn test' &gt;&gt;&gt; p.sub(r"\\1",escapedstring) 'This is a \\1\\1\\1 test' &gt;&gt;&gt; p.sub(r"\\\1",escapedstring) 'This is a \\n\\n\\n test' &gt;&gt;&gt; p.sub(r"\(\1)",escapedstring) 'This is a \\(n)\\(n)\\(n) test' </code></pre> <p>In conclusion, what the hell, Python.</p>
3,437
<p>One of the articles I really enjoyed reading recently was <a href="http://blog.last.fm/2008/08/01/quality-control" rel="nofollow noreferrer">Quality Control by Last.FM</a>. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't believe in Log Monitoring, why?<br> I'm looking for a mix of opinion slash experience here I guess.</p>
<p>Usually you'll use an <a href="http://www.google.com/search?q=HTTPHandler+ASP.NET&amp;spell=1" rel="noreferrer">HTTP Handler</a> for this. Given a request for...</p> <blockquote> <p><a href="http://www.yoursite.com/sitemap.axd" rel="noreferrer">http://www.yoursite.com/sitemap.axd</a></p> </blockquote> <p>...your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other method is up to the HTTP Handler implementation.</p> <p>Here's roughly what it would look like:</p> <pre><code>void IHttpHandler.ProcessRequest(HttpContext context) { // // Important to return qualified XML (text/xml) for sitemaps // context.Response.ClearHeaders(); context.Response.ClearContent(); context.Response.ContentType = "text/xml"; // // Create an XML writer // XmlTextWriter writer = new XmlTextWriter(context.Response.Output); writer.WriteStartDocument(); writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); // // Now add entries for individual pages.. // writer.WriteStartElement("url"); writer.WriteElementString("loc", "http://www.codingthewheel.com"); // use W3 date format.. writer.WriteElementString("lastmod", postDate.ToString("yyyy-MM-dd")); writer.WriteElementString("changefreq", "daily"); writer.WriteElementString("priority", "1.0"); writer.WriteEndElement(); // // Close everything out and go home. // result.WriteEndElement(); result.WriteEndDocument(); writer.Flush(); } </code></pre> <p>This code can be improved but that's the basic idea.</p>
<p>Custom handler to generate the sitemap. </p>
3,077
<p>Is the ZIP compression that is built into Windows XP/Vista/2003/2008 able to be scripted at all? What executable would I have to call from a BAT/CMD file? or is it possible to do it with VBScript?</p> <p>I realize that this is possible using <a href="http://en.wikipedia.org/wiki/WinZip" rel="noreferrer">WinZip</a>, <a href="http://en.wikipedia.org/wiki/7-Zip" rel="noreferrer">7-Zip</a> and other external applications, but I'm looking for something that requires no external applications to be installed.</p>
<p>There are VBA methods to <a href="http://www.rondebruin.nl/win/s7/win001.htm" rel="noreferrer">zip</a> and <a href="http://www.rondebruin.nl/win/s7/win002.htm" rel="noreferrer">unzip</a> using the windows built in compression as well, which should give some insight as to how the system operates. You may be able to build these methods into a scripting language of your choice.</p> <p>The basic principle is that within windows you can treat a zip file as a directory, and copy into and out of it. So to create a new zip file, you simply make a file with the extension <code>.zip</code> that has the right header for an empty zip file. Then you close it, and tell windows you want to copy files into it as though it were another directory.</p> <p>Unzipping is easier - just treat it as a directory.</p> <p>In case the web pages are lost again, here are a few of the relevant code snippets:</p> <h1>ZIP</h1> <pre><code>Sub NewZip(sPath) 'Create empty Zip File 'Changed by keepITcool Dec-12-2005 If Len(Dir(sPath)) &gt; 0 Then Kill sPath Open sPath For Output As #1 Print #1, Chr$(80) &amp; Chr$(75) &amp; Chr$(5) &amp; Chr$(6) &amp; String(18, 0) Close #1 End Sub Function bIsBookOpen(ByRef szBookName As String) As Boolean ' Rob Bovey On Error Resume Next bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing) End Function Function Split97(sStr As Variant, sdelim As String) As Variant 'Tom Ogilvy Split97 = Evaluate("{""" &amp; _ Application.Substitute(sStr, sdelim, """,""") &amp; """}") End Function Sub Zip_File_Or_Files() Dim strDate As String, DefPath As String, sFName As String Dim oApp As Object, iCtr As Long, I As Integer Dim FName, vArr, FileNameZip DefPath = Application.DefaultFilePath If Right(DefPath, 1) &lt;&gt; "\" Then DefPath = DefPath &amp; "\" End If strDate = Format(Now, " dd-mmm-yy h-mm-ss") FileNameZip = DefPath &amp; "MyFilesZip " &amp; strDate &amp; ".zip" 'Browse to the file(s), use the Ctrl key to select more files FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xl*), *.xl*", _ MultiSelect:=True, Title:="Select the files you want to zip") If IsArray(FName) = False Then 'do nothing Else 'Create empty Zip File NewZip (FileNameZip) Set oApp = CreateObject("Shell.Application") I = 0 For iCtr = LBound(FName) To UBound(FName) vArr = Split97(FName(iCtr), "\") sFName = vArr(UBound(vArr)) If bIsBookOpen(sFName) Then MsgBox "You can't zip a file that is open!" &amp; vbLf &amp; _ "Please close it and try again: " &amp; FName(iCtr) Else 'Copy the file to the compressed folder I = I + 1 oApp.Namespace(FileNameZip).CopyHere FName(iCtr) 'Keep script waiting until Compressing is done On Error Resume Next Do Until oApp.Namespace(FileNameZip).items.Count = I Application.Wait (Now + TimeValue("0:00:01")) Loop On Error GoTo 0 End If Next iCtr MsgBox "You find the zipfile here: " &amp; FileNameZip End If End Sub </code></pre> <h1>UNZIP</h1> <pre><code>Sub Unzip1() Dim FSO As Object Dim oApp As Object Dim Fname As Variant Dim FileNameFolder As Variant Dim DefPath As String Dim strDate As String Fname = Application.GetOpenFilename(filefilter:="Zip Files (*.zip), *.zip", _ MultiSelect:=False) If Fname = False Then 'Do nothing Else 'Root folder for the new folder. 'You can also use DefPath = "C:\Users\Ron\test\" DefPath = Application.DefaultFilePath If Right(DefPath, 1) &lt;&gt; "\" Then DefPath = DefPath &amp; "\" End If 'Create the folder name strDate = Format(Now, " dd-mm-yy h-mm-ss") FileNameFolder = DefPath &amp; "MyUnzipFolder " &amp; strDate &amp; "\" 'Make the normal folder in DefPath MkDir FileNameFolder 'Extract the files into the newly created folder Set oApp = CreateObject("Shell.Application") oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname).items 'If you want to extract only one file you can use this: 'oApp.Namespace(FileNameFolder).CopyHere _ 'oApp.Namespace(Fname).items.Item("test.txt") MsgBox "You find the files here: " &amp; FileNameFolder On Error Resume Next Set FSO = CreateObject("scripting.filesystemobject") FSO.deletefolder Environ("Temp") &amp; "\Temporary Directory*", True End If End Sub </code></pre>
<p>There are both zip and unzip executables (as well as a boat load of other useful applications) in the UnxUtils package available on SourceForge (<a href="http://sourceforge.net/projects/unxutils" rel="nofollow noreferrer">http://sourceforge.net/projects/unxutils</a>). Copy them to a location in your PATH, such as 'c:\windows', and you will be able to include them in your scripts.</p> <p>This is not the perfect solution (or the one you asked for) but a decent work-a-round.</p>
5,009
<p>I've written a database generation script in <a href="http://en.wikipedia.org/wiki/SQL" rel="noreferrer">SQL</a> and want to execute it in my <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Adobe AIR</a> application:</p> <pre><code>Create Table tRole ( roleID integer Primary Key ,roleName varchar(40) ); Create Table tFile ( fileID integer Primary Key ,fileName varchar(50) ,fileDescription varchar(500) ,thumbnailID integer ,fileFormatID integer ,categoryID integer ,isFavorite boolean ,dateAdded date ,globalAccessCount integer ,lastAccessTime date ,downloadComplete boolean ,isNew boolean ,isSpotlight boolean ,duration varchar(30) ); Create Table tCategory ( categoryID integer Primary Key ,categoryName varchar(50) ,parent_categoryID integer ); ... </code></pre> <p>I execute this in Adobe AIR using the following methods:</p> <pre><code>public static function RunSqlFromFile(fileName:String):void { var file:File = File.applicationDirectory.resolvePath(fileName); var stream:FileStream = new FileStream(); stream.open(file, FileMode.READ) var strSql:String = stream.readUTFBytes(stream.bytesAvailable); NonQuery(strSql); } public static function NonQuery(strSQL:String):void { var sqlConnection:SQLConnection = new SQLConnection(); sqlConnection.open(File.applicationStorageDirectory.resolvePath(DBPATH)); var sqlStatement:SQLStatement = new SQLStatement(); sqlStatement.text = strSQL; sqlStatement.sqlConnection = sqlConnection; try { sqlStatement.execute(); } catch (error:SQLError) { Alert.show(error.toString()); } } </code></pre> <p>No errors are generated, however only <code>tRole</code> exists. It seems that it only looks at the first query (up to the semicolon- if I remove it, the query fails). Is there a way to call multiple queries in one statement?</p>
<p>I wound up using this. It is a kind of a hack, but it actually works pretty well. </p> <p>The only thing is you have to be very careful with your semicolons. : D</p> <pre><code>var strSql:String = stream.readUTFBytes(stream.bytesAvailable); var i:Number = 0; var strSqlSplit:Array = strSql.split(";"); for (i = 0; i &lt; strSqlSplit.length; i++){ NonQuery(strSqlSplit[i].toString()); } </code></pre>
<p>What about making your delimiter something a little more complex like ";\n" which would not show up all that often. You just have to ensure when creating the file you have a line return or two in there. I end up putting two "\n\n" into the creation of my files which works well.</p>
2,250
<p>Should you ever use protected member variables? What are the the advantages and what issues can this cause?</p>
<blockquote> <p>Should you ever use protected member variables? </p> </blockquote> <p>Depends on how picky you are about hiding state. </p> <ul> <li>If you don't want any leaking of internal state, then declaring all your member variables private is the way to go. </li> <li>If you don't really care that subclasses can access internal state, then protected is good enough.</li> </ul> <p>If a developer comes along and subclasses your class they may mess it up because they don't understand it fully. With private members, other than the public interface, they can't see the implementation specific details of how things are being done which gives you the flexibility of changing it later.</p>
<p>For detailed info on .Net access modifiers <a href="https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-1027680.html" rel="nofollow noreferrer">go here</a></p> <p>There are no real advantages or disadvantages to protected member variables, it's a question of what you need in your specific situation. In general it is accepted practice to declare member variables as private and enable outside access through properties. Also, some tools (e.g. some O/R mappers) expect object data to be represented by properties and do not recognize public or protected member variables. But if you know that you want your subclasses (and ONLY your subclasses) to access a certain variable there is no reason not to declare it as protected.</p>
5,763
<p>Unit testing and ASP.NET web applications are an ambiguous point in my group. More often than not, good testing practices fall through the cracks and web applications end up going live for several years with no tests. </p> <p>The cause of this pain point generally revolves around the hassle of writing UI automation mid-development. </p> <p>How do you or your organization integrate best TDD practices with web application development?</p>
<p>Unit testing will be achievable if you <strong>separate your layers</strong> appropriately. As Rob Cooper implied, <em>don't put any logic in your WebForm other than logic to manage your presentation</em>. All other stuff logic and persistence layers should be kept in separate classes and then you can test those individually.</p> <p>To test the GUI some people like <a href="http://selenium.openqa.org/" rel="noreferrer">selenium</a>. Others complain that is a pain to set up.</p>
<p>There have been tries on getting Microsoft's free UI Automation (included in .NET Framework 3.0) to work with web applications (ASP.NET). A german company called Artiso happens to have written a blog entry that explains how to achieve that (<a href="http://www.artiso.com/ProBlog/PermaLink,guid,1a01608b-e5fa-4ad9-8c4f-f672a69c3537.aspx" rel="nofollow noreferrer">link</a>).</p> <p>However, their blogpost also links an MSDN Webcasts that explains the UI Automation Framework with winforms and after I had a look at this, I noticed you need the AutomationId to get a reference to the respecting controls. However, in web applications, the controls do not have an AutomationId. </p> <p>I asked Thomas Schissler (Artiso) about this and he explained that this was a major drawback on InternetExplorer. He referenced an older technology of Microsoft (<a href="http://msdn.microsoft.com/en-us/library/ms971310.aspx" rel="nofollow noreferrer">MSAA</a>) and was hoping himself that IE8 will do this better.</p> <p>However, I was also giving Watin a try and it seems to work pretty well. I even liked Wax, which allows to implement simple testcases via Microsoft Excel worksheets.</p>
3,913
<p>I currently print with a .4mm nozzle on my extruder, and my prints seem to come out fairly accurate; would I see much of a difference if I went to a .3mm?</p> <p>What are the pros and cons of larger and smaller nozzle sizes?</p>
<p>1) Smaller nozzle advantage: sharper "corners" (higher X and Y resolution)</p> <p>2) Larger nozzle advantage: faster 3d printing (because you can print the shell faster as each perimeter can be thicker so you'll need less perimeters to be printed to get the same shell thickness. Same true for infill).</p> <p>3) Smaller nozzle disadvantage (varies, debatable): higher risk of clogging. There are of course other factors which can result in clogging, but this can also affect it as even finer particles in less quality filament can get stuck now.</p> <p>4) Smallel nozzle disadvantage: since less plastic can come out at a given duration of time, it means less speedy printing of larger layer heights, if at all possible.</p> <p>I feel like I should get back to (1) and explain why it is so. When companies market their 3d printer they usually talk about the layer height (the Z resolution) completely ignoring the X and Y. This makes sense for marketing. Luckily it is not hard to explain what is usually left out and what is important for one of the answers to your question on what are advantages of smaller nozzles:</p> <p>The Z resolution depends on two main things: 1) The stepper motor driver accuracy of your 3d printer's motherboard. Pretty much all are the same now. Claiming your 3d printer can print at 20 micron layer height doesn't say anything, pretty much any 3d printed today can. 2) Nozzle/extruder quality, nozzle diameter. The latter surprisingly does not determine much. Because of how FFF/FMD 3d printing works, the perimeters of your 3d print can be way thinner than your nozzle diameter. This might sound odd but there's a simple explanation: the molten plastic coming out of the hotend is squished and stretched when the head moves. Because it is stretched, it can be made thinner as you increase how much it is squished. There's not much experimentation done on this and available online, only from personal experience I can say I can print perimeters 50% thinner than my 3mm nozzle. So I suppose if you wanted thinner perimeters than that, you would need to swap to a thinner nozzle. Why would you want thinner perimeters? To get sharper corners or in other words better X and Y resolution for your 3d prints which is ignored by most unlike the overstated "layer height" (Z resolution). Here's an illustration to help you visualize how fatter perimeters and less sharp corners/edges on your 3d model result in "lower X/Y resolution" (the illustration is a 2d cutout, viewed from the top):</p> <p><a href="https://i.stack.imgur.com/E9Q38.png" rel="noreferrer"><img src="https://i.stack.imgur.com/E9Q38.png" alt="enter image description here"></a></p>
<p>My understanding is that the only difference is your range that your layer height can be. For example, the optimal layer heights for a 0.4mm nozzle fall between 0.1-0.3mm. So, we can assume a smaller nozzle will yield a lower range. Keep in mind that varying sizes in the nozzle could produce complications more prominently than with a standard size. Things such as ooze, clogging, and filament backup may occur with a smaller nozzle size if your slicing engine is not setup correctly.</p>
187
<p>My scheduled reports in SQL server won't run. I checked the logs and found the job that was failing. The error message in the log was:</p> <blockquote> <p>'EXECUTE AS LOGIN' failed for the requested login 'NT AUTHORITY\NETWORK SERVICE'. The step failed. </p> </blockquote> <p>I'm using SQL authentication for the report so it shouldn't be issues with the permissions to the data. No sheduled reports on the server will run.</p>
<p>I found the answer here: <a href="http://www.themssforum.com/SVCS/Unable-execute/" rel="nofollow noreferrer">http://www.themssforum.com/SVCS/Unable-execute/</a></p> <p>Apperently there was something wrong with the login for 'NT AUTHORITY\NETWORK SERVICE' and it wouldn't run the jobs it owned properly. Anyone understand why this might have happened?</p>
<p>Can you check the permissions for your Network Service account? Specifically make sure they have the "Act as part of the OS" permission. If I'm reading the error message correctly, it looks like the NT AUTHORITY\NETWORK SERVICE account failed to execute as a logged on user. It doesn't look like it ever got to the query, looks like it's failing in the Windows authentication portion, so never gets to the SQL authentication piece.</p> <p>You might also check the Security Event Log in Windows. If it is an authentication problem, there might be additional information logged by the OS.</p>
3,537
<p>Will I have to pay again? I have about 9 months left before renewal but my current provider doesn't offer many options / control panels.</p> <p>Update: thanks for everyone's help - I've finally completed this now.</p> <p>I had to:</p> <ul> <li>Ask my old registrar to "Unlock" the domain</li> <li>Ask my old registrar to set the admin email address of the domain to my email</li> <li>Ask my old registrar for the "authcode"</li> <li>For the rest I just followed GoDaddy's instructions</li> </ul> <p>What a pain in the a**</p>
<p>This is how it works Lets say you have 9 more months for your current domain to expire you transfer the domain to GoDaddy (or to any other decent Registrar) you will be charged the price (little more or equal) to the price of booking a new domain BUT, you will have the domain for 9 months + one year (or the no. of years you paid godaddy for)</p> <p>So, you choose to transfer the domain and pay USD9.99 (for a year), you will have the domains for 1 year + 9 months</p>
<p>There is a domain transfer procedure. It's kind of complex, since it's intended to keep people from stealing domains by transferring them to another registrar (like happened to <a href="http://en.wikipedia.org/wiki/Sex.com" rel="nofollow noreferrer">sex.com</a> back in the 90's). GoDaddy does a good job of talking you through it (I've transferred a domain to them in the past). Of course, you're going to have to pay them to register the domain for you (though they occasionally offer discounts on domain transfers).</p>
9,907
<p>I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency properties which have become vestigial and can be a little confusing when using <em>IntelliSense</em> or using the classes in a visual designer.</p> <p>These classes are all controls that are written to be compiled for either WPF or Silverlight 2.0. I know about <code>ICustomTypeDescriptor</code> and <code>ICustomPropertyProvider</code>, but I'm pretty certain those can't be used in Silverlight. </p> <p>It's not as much a functional issue as a usability issue. What should I do?</p> <p><strong>Update</strong></p> <p>Some of the properties that I would really like to hide come from ancestors that are not my own and because of a specific tool I'm designing for, I can't do member hiding with the <code>new</code> operator. (I know, it's ridiculous)</p>
<p>Override them like Michael Suggests <a href="https://stackoverflow.com/questions/1528/#1533">above</a> and to prevent folks from using the overridden (sp?) methods, mark them as obsolete:</p> <pre><code>[Obsolete("These are not supported in this class.", true)] public override void dontcallmeanymore() { } </code></pre> <p>If the second parm is set to true, a compiler error will be generated if anyone tries to call that method and the string in the first parm is the message. If parm2 is false only a compiler warning will be generated.</p>
<p>You can use an interface</p> <pre><code> public static void Main() { NoRemoveList&lt;string&gt; testList = ListFactory&lt;string&gt;.NewList(); testList.Add(" this is ok "); // not ok //testList.RemoveAt(0); } public interface NoRemoveList&lt;T&gt; { T this[int index] { get; } int Count { get; } void Add(T item); } public class ListFactory&lt;T&gt; { private class HiddenList: List&lt;T&gt;, NoRemoveList&lt;T&gt; { // no access outside } public static NoRemoveList&lt;T&gt; NewList() { return new HiddenList(); } } </code></pre>
2,388
<p>I am working on localization for a asp.net application that consists of several projects.</p> <p>For this, there are some strings that are used in several of these projects. Naturally, I would prefer to have only one copy of the resource file in each project.</p> <p>Since the resource files don't have an namespace (at least as far as I can tell), they can't be accessed like regular classes.</p> <p>Is there any way to reference resx files in another project, within the same solution?</p>
<p>You can just create a class library project, add a resource file there, and then refer to that assembly for common resources.</p>
<p>Some useful advice on how to manage a situation like this is available here:</p> <p><a href="http://www.codeproject.com/KB/dotnet/Localization.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/dotnet/Localization.aspx</a></p>
6,010
<p>Has anyone used <a href="http://www.ayende.com/Blog/archive/2007/09/03/Rhino-Igloo-ndash-MVC-Framework-for-Web-Forms.aspx" rel="nofollow noreferrer">Rhino igloo</a> in a non-trivial project? I am curious if it's worth, what are its drawbacks, does it enhance testability a lot, is it easy to use. How would you compare it to a pure MVC framework (ASP.NET MVC)? Please share the experience.</p>
<p>If you want, you can translate this VB.Net code to C#. The theory here is that you change the size of a tab in the control.</p> <pre><code>Private Declare Function SendMessage _ Lib "user32" Alias "SendMessageA" _ (ByVal handle As IntPtr, ByVal wMsg As Integer, _ ByVal wParam As Integer, ByRef lParam As Integer) As Integer Private Sub SetTabStops(ByVal ctlTextBox As TextBox) Const EM_SETTABSTOPS As Integer = &amp;HCBS Dim tabs() As Integer = {20, 40, 80} SendMessage(ctlTextBox.Handle, EM_SETTABSTOPS, _ tabs.Length, tabs(0)) End Sub </code></pre> <p>I converted a version to C# for you, too. Tested and working in VS2005.</p> <p>Add this using statement to your form: </p> <pre><code>using System.Runtime.InteropServices; </code></pre> <p>Put this right after the class declaration:</p> <pre><code> private const int EM_SETTABSTOPS = 0x00CB; [DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr h, int msg, int wParam, int[] lParam); </code></pre> <p>Call this method when you want to set the tabstops:</p> <pre><code> private void SetTabStops(TextBox ctlTextBox) { const int EM_SETTABSTOPS = 203; int[] tabs = { 100, 40, 80 }; SendMessage(textBox1.Handle, EM_SETTABSTOPS, tabs.Length, tabs); } </code></pre> <p>To use it, here is all I did:</p> <pre><code> private void Form1_Load(object sender, EventArgs e) { SetTabStops(textBox1); textBox1.Text = "Hi\tWorld"; } </code></pre>
<p>Don't the text boxes allow HTML usage? If that is the case, just use HTML to format the text into a table. Otherwise, try adding the text to a datagrid and then adding that to the form.</p>
9,782
<p>The product-group I work for is currently using gcc 3.4.6 (we know it is ancient) for a large low-level c-code base, and want to upgrade to a later version. We have seen performance benefits testing different versions of gcc 4.x on all hardware platforms we tested it on. We are however <em>very</em> scared of c-compiler bugs (for a good reason historically), and wonder if anyone has insight to which version we should upgrade to.</p> <p>Are people using 4.3.2 for large code-bases and feel that it works fine?</p>
<p>The best quality control for gcc is the linux kernel. GCC is the compiler of choice for basically all major open source C/C++ programs. A released GCC, especially one like 4.3.X, which is in major linux distros, should be pretty good.</p> <p>GCC 4.3 also has better support for optimizations on newer cpus.</p>
<p>If you are interested in OpenMP then you will need to move to gcc 4.2 or greater. We are using 4.2.2 on a code base of around 5M lines and are not having any problems with it.</p>
5,238
<p>I have a MemoryStream with the contents of a Font File (.ttf) and I would like to be able to create a FontFamily WPF object from that stream <strong>WITHOUT</strong> writing the contents of the stream to disk. I know this is possible with a System.Drawing.FontFamily but I cannot find out how to do it with System.Windows.Media.FontFamily.</p> <p>Note: I will only have the stream, so I can't pack it as a resource in the application and because of disk permissions issues, will not be able to write the font file to disk for reference as &quot;content&quot;</p> <p><strong>UPDATE:</strong></p> <p>The <a href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.fontfamily?view=netframework-4.6.1" rel="nofollow noreferrer">API docs</a> how describe how an application resource can be used, though it is not clear to me whether that is an Embedded resource in the assembly or a file on disk.</p> <blockquote> <p>You can use a base URI value when you reference a font that is packaged as part of the application. For example, the base URI value can be a &quot;pack://application&quot; URI, which lets you reference fonts that are packaged as application resources. The following code example shows a font reference that is composed of a base URI value and a relative URI value.</p> </blockquote>
<p>There is a similar question <a href="https://stackoverflow.com/questions/44912480/c-sharp-wpf-how-to-load-a-fontfamily-from-a-byte-array">here</a>, which contains a supposed solution by converting a System.Drawing.FontFamily to a WPF font family, all in memory without any file IO:</p> <pre><code>public static void Load(MemoryStream stream) { byte[] streamData = new byte[stream.Length]; stream.Read(streamData, 0, streamData.Length); IntPtr data = Marshal.AllocCoTaskMem(streamData.Length); // Very important. Marshal.Copy(streamData, 0, data, streamData.Length); PrivateFontCollection pfc = new PrivateFontCollection(); pfc.AddMemoryFont(data, streamData.Length); MemoryFonts.Add(pfc); // Your own collection of fonts here. Marshal.FreeCoTaskMem(data); // Very important. } public static System.Windows.Media.FontFamily LoadFont(int fontId) { if (!Exists(fontId)) { return null; } /* NOTE: This is basically how you convert a System.Drawing.FontFamily to System.Windows.Media.FontFamily, using PrivateFontCollection. */ return new System.Windows.Media.FontFamily(MemoryFonts[fontId].Families[0].Name); } </code></pre> <p>This seems to use the <code>System.Drawing.PrivateFontCollection</code>(<a href="https://learn.microsoft.com/en-us/dotnet/api/system.drawing.text.privatefontcollection?view=dotnet-plat-ext-5.0" rel="nofollow noreferrer">^</a>) to add a <code>System.Drawing.Font</code> created from a <code>MemoryStream</code> and then use the <code>Families[0].Name</code> of that font to pass into the <code>System.Windows.Media.FontFamily</code> constructor. I assume the family name would then be a URI to the instance of that font in the PrivateFontCollection but you'd probably have to try it out.</p>
<p>The best approach I could think of, was to save the oldFont to a temp directory, and immediately load it using the newFont constructor that accepts a uri.</p>
6,616