instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>Which of the following is better code in c# and why?</p>
<pre><code>((DateTime)g[0]["MyUntypedDateField"]).ToShortDateString()
</code></pre>
<p>or</p>
<pre><code>DateTime.Parse(g[0]["MyUntypedDateField"].ToString()).ToShortDateString()
</code></pre>
<p>Ultimately, is it better to cast or to parse?</p>
|
<p>If g[0]["MyUntypedDateField"] is really a DateTime object, then the cast is the better choice. If it's not really a DateTime, then you have no choice but to use the Parse (you would get an InvalidCastException if you tried to use the cast)</p>
|
<p>As @Brian R. Bondy pointed it depends on implementation of <strong>g[0]["MyUntypedDateField"]</strong>. Safe practice is to use <strong>DateTime.TryParse</strong> and <strong>as</strong> operator. </p>
| 8,701
|
<p>I've recently had a need to do a bit of lisp editing and I found the nifty Ready Lisp package for OS X, which is great, except Aquamacs automatically uses a proportional font (which is idiotic, IMHO) and I want to change it to a monospace font. However, I'm not really much of an EMACS user, and the preferences menu in Aquamacs is less than clear on where and how one might make such a change. </p>
|
<p>This is what I have in my .emacs for OS X:</p>
<pre><code>(set-default-font "-apple-bitstream vera sans mono-medium-r-normal--0-0-0-0-m-0-mac-roman")
</code></pre>
<p>Now, I'm not sure Bitstream Vera comes standard on OS X, so you may have to either download it or choose a different font. You can search the X font names by running <code>(x-list-fonts "searchterm")</code> in an ELisp buffer (e.g. <code>*scratch*</code> - to run it, type it in and then type <code>C-j</code> on the same line).</p>
|
<p>Fast forward a decade, for recent Aquamacs like ver 3.3 please see the nice solution for setting a fixed-width by default at <a href="https://emacs.stackexchange.com/questions/45135/change-permanently-font-size-in-aquamacs">https://emacs.stackexchange.com/questions/45135/change-permanently-font-size-in-aquamacs</a></p>
<p>Here's the relevant bit for those who are REALLY impatient but please go upvote that answer, user @nega deserves credit here</p>
<pre><code>(when window-system
(setq initial-frame-alist nil) ;; Undo Aquamacs forced defaults
(setq default-frame-alist nil) ;; Undo Aquamacs forced defaults
(aquamacs-autoface-mode -1) ;; Use one face (font) everywhere
(set-frame-font "Menlo-12") ;; Set the default font to Menlo size 12
;;(set-default-font "Menlo-12") ;; This would do the same.
)
</code></pre>
| 8,598
|
<p>Programming in vim I often go search for something, yank it, then go back to where I was, insert it, modify it.</p>
<p>The problem is that after I search and find, I need to MANUALLY find my way back to where I was.</p>
<p>Is there an automatic way to go back to where I was when I initiated my last search?</p>
|
<p><kbd>Ctrl</kbd>+<kbd>O</kbd> takes me to the previous location. Don't know about location before the search.</p>
<p>Edit: Also, <kbd>`</kbd><kbd>.</kbd> will take you to the last change you made.</p>
|
<p>The simplest way is to set a mark, with <code>m[letter]</code>, then go back to it with <code>'[letter]</code></p>
| 7,747
|
<p>Every project invariably needs some type of reporting functionality. From a foreach loop in your language of choice to a full blow BI platform. </p>
<blockquote>
<p>To get the job done what tools, widgets, platforms has the group used with success, frustration and failure?</p>
</blockquote>
|
<p>For knocking out fairly "run of the mill" reports, SQL Reporting Services is really quite impressive.</p>
<p>For complicated analysis, loading the data (maybe pre-aggregated) into an Excel Pivot table is usually adequate for most users.</p>
<p>I've found you can spend a lot of time (and money) building a comprehensive "ad-hoc" reporting suite and after the first month or two of "wow factor", 99% of the reports generated will be the same report with minor differences in a fixed set of parameters.</p>
<p>Don't accept when a user says they want "ad-hoc" reports without specifying what goals and targets their looking for. They are just fishing and they need to actually spend as much time on THINKING about THEIR reporting requirements as YOU would have to spend BUILDING their solution.</p>
<p>I've spent too much time building the "the system that can report everything" and for it to become out of date or out of favour before it was finished. Much better to get the quick wins out of the way as quick as possible and then spend time "systemising" the most important reports.</p>
|
<p>I'm the CTO at Windward and I do believe that <a href="http://www.windwardreports.com/" rel="nofollow">Windward Reports</a> is by far both the easiest to use and you can do more with it than any other reporting - and both traits are for the same reason, you design your reports in Word, Excel, & PowerPoint.</p>
<p>As to the generated reports, it's fast, it's rock solid, and incorporating it into your program can be as little as 3 lines of code.</p>
| 3,946
|
<p>I need to be able to quickly convert an image (inside a rails controller) so that the hosting company using managing our application can quickly test at any time to ensure that rmagick is not only successfully installed, but can be called throgh the rails stiack, what is the quickest clean code I can use to do this?</p>
|
<pre><code>require 'RMagick'
image = Magick::Image.new(110, 30){ self.background_color = 'white' }
image.write('/tmp/test.jpg')
</code></pre>
|
<p>I'd log on to the server and try out your code in script/console. This will still go through the rails stack, but will allow you to quickly check that your code works the way you expect and that RMagick and ImageMagick are correctly installed without having to deploy anything.</p>
<p>When the time comes to write your actual code, I'd suggest putting the image conversion code inside a model, so you can call it outside the context of a controller.</p>
| 9,625
|
<p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" rel="nofollow noreferrer">ASP.NET Login Controls</a> and <a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" rel="nofollow noreferrer">Forms Authentication</a> for membership/credentials for an ASP.NET web application.</p>
<p>I've got two roles:</p>
<ul>
<li>Users</li>
<li>Administrators</li>
</ul>
<p>I want pages to be viewable by four different groups:</p>
<ul>
<li>Everyone <em>(Default, Help)</em></li>
<li>Anonymous <em>(CreateUser, Login, PasswordRecovery)</em></li>
<li>Users <em>(ChangePassword, DataEntry)</em></li>
<li>Administrators <em>(Report)</em></li>
</ul>
<p>Expanding on the example in the <a href="http://www.asp.net/learn/videos/video-45.aspx" rel="nofollow noreferrer">ASP.NET HOW DO I Video Series: Membership and Roles</a>, I've put those page files into such folders:</p>
<p><img src="https://i.stack.imgur.com/Ps7sm.gif" alt="Visual Studio Solution Explorer"></p>
<p>And I used the ASP.NET Web Site Administration Tool to set up access rules for each folder.</p>
<p>It works but seems kludgy to me and it creates issues <a href="https://stackoverflow.com/questions/33089/how-do-i-use-aspnet-login-controls-when-my-loginaspx-is-not-at-the-root-of-my-a">when Login.aspx is not at the root</a> and with the <a href="https://stackoverflow.com/questions/33166/how-do-i-keep-my-loginaspx-pages-returnurl-parameter-from-overriding-my-aspnet">ReturnUrl parameter</a> of Login.aspx.</p>
<p>Is there a better way to do this? Is there perhaps a simple way I can set permissions at the page level rather than at the folder level?</p>
|
<p>This works for me in Java 1.5 - I stripped out specific exceptions for readability.</p>
<pre><code>import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import java.io.ByteArrayInputStream;
public Document loadXMLFromString(String xml) throws Exception
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new ByteArrayInputStream(xml.getBytes()));
}
</code></pre>
|
<p>To manipulate XML in Java, I always tend to use the Transformer API:</p>
<pre><code>import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
public static Document loadXMLFrom(String xml) throws TransformerException {
Source source = new StreamSource(new StringReader(xml));
DOMResult result = new DOMResult();
TransformerFactory.newInstance().newTransformer().transform(source , result);
return (Document) result.getNode();
}
</code></pre>
| 5,330
|
<p>I've have observed that when the printer is finishing a layer, the flow of plastic through the nozzle starts fading out as it comes closer to the point of layer change.</p>
<p>As an example, let's say that I'm printing the first layer of a cube. The nozzle first prints the perimeters ok. Then it begins to print the inner part, beginning from one corner and finishing on the opposite one. As the nozzle comes closer to the finishing corner, the flow of plastic diminishes, resulting in the lines of the filament to touching each other. </p>
<p>Maybe it's not a big deal, but it's annoying because it's stopping the part of having a very nice first layer and finish.</p>
<p>My setup is:</p>
<ul>
<li>Anet A6 running Marlin 1.1.8</li>
<li>Bed auto leveling before each print</li>
<li>Slic3r Prusa Edition, latest release (as of 20 January 2018)</li>
<li>PETG from Das Filament</li>
</ul>
<p>I tried disabling all "retract" settings but the issue persists.</p>
<p>I'm beginning to think that this could be a software bug (Slic3r), but before I submit it to GitHub, I'd like to be sure.</p>
<p>Any opinion is welcome!</p>
|
<p>If you think it is a slicing problem, look at the G-code. You might want to arrange for the infill to be orthogonal to the axes, but it ought to be easy enough to calculate the ratio between printhead motion and the extruder. G-code is just text, and fairly easy to make sense of. The <a href="http://reprap.org/wiki/G-code" rel="nofollow noreferrer">RepRap</a> wiki has a good reference to the commands, and all you care about are X-Y movement, and E movement.</p>
<p>An alternative explanation might be that your extruder is struggling with the extrusion rate, and after continuous extrusion is failing to heat the filament fast enough to melt. The layer change could be providing a sufficient respite that walls start off OK on the next layer. Also check (in the G-code) that the speed of walls and infill is the same.</p>
|
<p>The Prusa Slic3r edition has <a href="http://manual.slic3r.org/expert-mode/fighting-ooze" rel="nofollow noreferrer">specific help references</a> in the manual that may be of value to you. One of the entries that catches my eye is the line marked "Retract on layer change" which appears to be just as you are describing. You've noted that you've disabled all retract settings, perhaps overlooking the check box?</p>
<p>The above linked document also refers to a print setting that prevents retract of filament when not crossing perimeters. This again appears relevant to your difficulties.</p>
<p>Your post says "resulting in the lines of the filament to touching each other." I expect you mean "not touching each other" but I do not wish to correct/edit your post if I am incorrect in this understanding.</p>
| 795
|
<p>How does one convert an image from one color profile to another (screen to printer, or scanner to screen). In Visual C++ you would use the function in ICM.h, is there a managed way to do this with GDI+?</p>
<p>I need to use GDI+, not WPF. I'd prefer to have a managed solution, but if it is not available, I guess PInkvoke will have to suffice.</p>
|
<p>There are a number of solutions.</p>
<ol>
<li>For GDI+, <a href="https://web.archive.org/web/20090224151626/http://support.microsoft.com/kb/317825/" rel="nofollow noreferrer">check out this article at MSDN</a> (HOW TO: Use GDI+ and Image Color Management to Adjust Image Colors).</li>
<li>For WPF (.NET 3.0), see the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.color.colorcontext(VS.85).aspx" rel="nofollow noreferrer">System.Windows.Media</a> namespace. There are a number of different classes, such as the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapencoder.aspx" rel="nofollow noreferrer">BitmapEncoder</a>, that have the concept of a <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.colorcontext.aspx" rel="nofollow noreferrer">ColorContext</a>, which "Represents the International Color Consortium (ICC) or Image Color Management (ICM) color profile that is associated with a bitmap image."</li>
</ol>
<p>Both of these seem pretty complex, so there's always the option of buying somebody else's code. Atalasoft's <a href="http://www.atalasoft.com/products/dotimage/photopro/default.aspx" rel="nofollow noreferrer">DotImage Photo Pro</a> has ICC profile setting capabilities built in. The code is expensive; a dev license is almost 2k. But based on their participation in the dotnet community, I'd give them a whirl.</p>
|
<p>You should take a look at <a href="http://www.littlecms.com/" rel="nofollow noreferrer">Lcms</a>. Its a colour management system, fairly complete, but written in C. you can use pinvoke, but I would recommend Managed C++ wrapper. I am actually currently working on a managed wrapper around the engine (just the basics, colour profile conversion, lab readings). I can post a link to the code after i am complete. It may be a week or so though.</p>
| 5,918
|
<p>Is there a way to implement a singleton object in C++ that is:</p>
<ol>
<li>Lazily constructed in a thread safe manner (two threads might simultaneously be the first user of the singleton - it should still only be constructed once).</li>
<li>Doesn't rely on static variables being constructed beforehand (so the singleton object is itself safe to use during the construction of static variables).</li>
</ol>
<p>(I don't know my C++ well enough, but is it the case that integral and constant static variables are initialized before any code is executed (ie, even before static constructors are executed - their values may already be "initialized" in the program image)? If so - perhaps this can be exploited to implement a singleton mutex - which can in turn be used to guard the creation of the real singleton..)</p>
<hr>
<p>Excellent, it seems that I have a couple of good answers now (shame I can't mark 2 or 3 as being <strong>the answer</strong>). There appears to be two broad solutions:</p>
<ol>
<li>Use static initialisation (as opposed to dynamic initialisation) of a POD static variable, and implementing my own mutex with that using the builtin atomic instructions. This was the type of solution I was hinting at in my question, and I believe I knew already.</li>
<li>Use some other library function like <a href="http://opengroup.org/onlinepubs/007908799/xsh/pthread_once.html" rel="noreferrer">pthread_once</a> or <a href="http://www.boost.org/doc/libs/1_33_1/doc/html/call_once.html" rel="noreferrer">boost::call_once</a>. These I certainly didn't know about - and am very grateful for the answers posted.</li>
</ol>
|
<p>Basically, you're asking for synchronized creation of a singleton, without using any synchronization (previously-constructed variables). In general, no, this is not possible. You need something available for synchronization.</p>
<p>As for your other question, yes, static variables which can be statically initialized (i.e. no runtime code necessary) are guaranteed to be initialized before other code is executed. This makes it possible to use a statically-initialized mutex to synchronize creation of the singleton.</p>
<p>From the 2003 revision of the C++ standard:</p>
<blockquote>
<p>Objects with static storage duration (3.7.1) shall be zero-initialized (8.5) before any other initialization takes place. Zero-initialization and initialization with a constant expression are collectively called static initialization; all other initialization is dynamic initialization. Objects of POD types (3.9) with static storage duration initialized with constant expressions (5.19) shall be initialized before any dynamic initialization takes place. Objects with static storage duration defined in namespace scope in the same translation unit and dynamically initialized shall be initialized in the order in which their definition appears in the translation unit.</p>
</blockquote>
<p>If you <em>know</em> that you will be using this singleton during the initialization of other static objects, I think you'll find that synchronization is a non-issue. To the best of my knowledge, all major compilers initialize static objects in a single thread, so thread-safety during static initialization. You can declare your singleton pointer to be NULL, and then check to see if it's been initialized before you use it.</p>
<p>However, this assumes that you <em>know</em> that you'll use this singleton during static initialization. This is also not guaranteed by the standard, so if you want to be completely safe, use a statically-initialized mutex.</p>
<p>Edit: Chris's suggestion to use an atomic compare-and-swap would certainly work. If portability is not an issue (and creating additional temporary singletons is not a problem), then it is a slightly lower overhead solution.</p>
|
<p>I suppose saying don't do this because it's not safe and will probably break more often than just initializing this stuff in <code>main()</code> isn't going to be that popular.</p>
<p>(And yes, I know that suggesting that means you shouldn't attempt to do interesting stuff in constructors of global objects. That's the point.)</p>
| 2,860
|
<p>In SQL Server 2005 I have an "id" field in a table that has the "Is Identity" property set to 'Yes'. So, when an Insert is executed on that table the "id" gets set automatically to the next incrementing integer. Is there an easy way when the Insert is executed to get what the "id" was set to without having to do a Select statement right after the Insert?</p>
<blockquote>
<p>duplicate of:<br>
<a href="https://stackoverflow.com/questions/42648/best-way-to-get-identity-of-inserted-row">Best way to get identity of inserted row?</a></p>
</blockquote>
|
<p>In .Net at least, you can send multiple queries to the server in one go. I do this in my app:</p>
<pre><code>command.CommandText = "INSERT INTO [Employee] (Name) VALUES (@Name); SELECT SCOPE_IDENTITY()";
int id = (int)command.ExecuteScalar();
</code></pre>
<p>Works like a charm.</p>
|
<p>This is probably the best working solution I found for SQL Server..
<a href="https://stackoverflow.com/questions/17993606/sql-server-return-the-value-of-identity-column-after-insert-statement">Sql Server return the value of identity column after insert statement</a></p>
| 7,889
|
<p>How can I check <code>file permissions</code>, without having to run operating system specific command via <code>passthru()</code> or <code>exec()</code>?</p>
|
<p>Use <a href="http://php.net/fileperms" rel="noreferrer">fileperms()</a> function</p>
<pre><code>clearstatcache();
echo substr(sprintf('%o', fileperms('/etc/passwd')), -4);
</code></pre>
|
<p>What do you want to do by checking file permissions?</p>
<p>When writing secure code, it's almost always incorrect to "check, then do" anything. The reason is that between the checking whether you can do something and actually doing it, the state of the system could change such that doing it would have a different result.</p>
<p>For example, if you check whether a file exists before writing one, don't check whether you wrote the file successfully (or don't check in a detailed-enough fashion), and then later depend on the contents of the file you wrote, you could actually be reading a file written by an attacker.</p>
<p>So instead of checking file permissions, just do whatever it was you were going to do if the permissions check succeeded, and handle errors gracefully.</p>
| 3,995
|
<p>In a installation of WebSphere Application Server with Network Deployment, a node is:</p>
<ol>
<li>a physical machine</li>
<li>an instance of operative system</li>
<li>a logical set of WAS instances that is independent of physical machine or OS instance</li>
</ol>
|
<p>Basically,<br>
<br>
A <b>server</b> is a runtime environment, a process of execution.<br>
A <b>node</b> is a grouping of servers that share common configuration. It is a physical machine.<br>
A <b>cell</b> is a grouping of nodes into a sigle administrative domain. For websphere, it mean that if you group several servers within a cell, then you can administer them with one Websphere admin console<br>
<br>
Hope this helps!<br></p>
|
<p>A Cell is a virtual unit that is built of a Deployment Manager and one or more Nodes. A Node is another virtual unit that is built of a Node Agent and one or more Server instances.</p>
<p><a href="http://itdevworld.wordpress.com/2009/05/03/websphere-concepts-cell-node-cluster-server/" rel="nofollow">Here</a> you can find more details including a diagram.</p>
| 2,677
|
<p>When using a browser to transform XML (Google Chrome or IE7) is it possible to pass a parameter to the XSLT stylesheet through the URL?</p>
<p>example:</p>
<p><strong>data.xml</strong></p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<root>
<document type="resume">
<author>John Doe</author>
</document>
<document type="novella">
<author>Jane Doe</author>
</document>
</root>
</code></pre>
<p><strong>sample.xsl</strong></p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="html" />
<xsl:template match="/">
<xsl:param name="doctype" />
<html>
<head>
<title>List of <xsl:value-of select="$doctype" /></title>
</head>
<body>
<xsl:for-each select="//document[@type = $doctype]">
<p><xsl:value-of select="author" /></p>
</xsl:for-each>
</body>
</html>
</<xsl:stylesheet>
</code></pre>
|
<p>You can generate the XSLT server-side, even if the transformation is client-side.</p>
<p>This allows you to use a dynamic script to handle the parameter.</p>
<p>For example, you might specify:</p>
<pre><code><?xml-stylesheet type="text/xsl"href="/myscript.cfm/sample.xsl?paramter=something" ?>
</code></pre>
<p>And then in myscript.cfm you would output the XSL file, but with dynamic script handling the query string parameter (this would vary depending on which scripting language you use).</p>
|
<p>You can generate the XSLT server-side, even if the transformation is client-side.</p>
<p>This allows you to use a dynamic script to handle the parameter.</p>
<p>For example, you might specify:</p>
<pre><code><?xml-stylesheet type="text/xsl"href="/myscript.cfm/sample.xsl?paramter=something" ?>
</code></pre>
<p>And then in myscript.cfm you would output the XSL file, but with dynamic script handling the query string parameter (this would vary depending on which scripting language you use).</p>
| 9,156
|
<p>Has anyone had any luck with printing multi-colored prints with the Palette 2 on an Ender 3? If so, what is your steps/mm for the Ender 3 and your flow rate in whatever slicer you are using? I currently have my flow rate at 100 % and my steps/mm at 104.4, and I believe this is what is causing my Palette 2 to not produce accurate results.</p>
<hr>
<p><strong>About the Palette 2</strong></p>
<p><a href="https://www.mosaicmfg.com/products/palette-2" rel="nofollow noreferrer">Palette 2</a> is a separate device providing one multi color filament out of multiple single color filaments.</p>
<p>As the Ender 3 does not support multi-colour printing, that's why I'm using the Palette 2. It allows any printer to print in multi color as it adds multi color printing to single extruder printers. </p>
|
<p>On this thread, <a href="https://support.mosaicmfg.com/hc/en-us/community/posts/360021788573-Does-anyone-tried-Palette-2-0-on-Creality-Ender-3-or-Ender-3-Pro-" rel="nofollow noreferrer">Does anyone tried Palette 2.0 on Creality Ender 3 or Ender 3 Pro?</a>, there are a couple of useful links:</p>
<ul>
<li><p>There is a video, albeit for the CR-10<sup>1</sup>, but that should be of help: <a href="https://www.youtube.com/watch?v=5DuGGmxKv94" rel="nofollow noreferrer">YouTube - Setup Guide: Creality CR-10 with Palette 2</a>;</p></li>
<li><p>In addition, this Facebook group, <a href="https://www.facebook.com/groups/mosaic.users/" rel="nofollow noreferrer">Mosaic Palette, Palette+, Palette 2 (Pro) Users</a>, apparently has some users who have paired their Ender 3 with the Palette 2.</p></li>
</ul>
<p>However, <em>with respect to your question about the flow rate and steps/mm</em>, there isn't much info out there about that, and no one seems to have experienced similar issues, but your issue <em>might</em> have something to do with profiles - which, as you haven't mentioned them in your question, it is hard to know if that might be the issue or not. </p>
<p>In the same thread, <a href="https://support.mosaicmfg.com/hc/en-us/community/posts/360021788573/comments/360002849734" rel="nofollow noreferrer">this post</a>, states:</p>
<blockquote>
<p>I use it with the Ender 3. There is a profile in Canvas and Chroma for it also. </p>
</blockquote>
<p>This link here, <a href="https://support.mosaicmfg.com/hc/en-us/articles/360012415733-Chroma-for-Palette-2" rel="nofollow noreferrer">Chroma for Palette 2</a>, states that <em>after</em> using Cura, you then need to load the G-code file into Chroma v3.1, after having selected the appropriate <strong>profile</strong>. However, if you use Canvas, then there is no need for Cura nor Chroma, as Canvas can slice. This link goes through the whole process for Benchy.</p>
<hr>
<p>At the risk of repetition, the process for preparing the print, post-slicing, is also given here, from <a href="https://3dprintingcanada.com/blogs/news/multicolor-3d-printing-with-chroma-on-the-creality-ender-3" rel="nofollow noreferrer">Multicolor 3D Printing How To: Using the Mosaic Palette+ with the Creality Ender 3</a>, albeit slightly different from the link above:</p>
<blockquote>
<h3>Setting Up Chroma:</h3>
<p>When you load up Chroma, you’ll be presented with a blank canvas ready
to be filled with your 3D creations. In the top left corner, make
sure that you have the <strong>Ender 3</strong> selected from the drop down menu.
After this you can click <strong>Load Print</strong>. From there you’ll be presented
with your gcode files that you have on your computer. </p>
<p>In this example we will be selecting the <code>butterfly-1.gcode</code> file, and
clicking <strong>Open</strong>. From here Chroma will be compiling and arranging the
settings for the gcode file to be displayed. This might take a minute
or more.</p>
<h3>Selecting Your Colors:</h3>
<p>Once the loading is completed, you will be presented with the 3D
rendering of our butterfly! This butterfly will be in 4 randomly
selected colors by default, but we will be changing this next! To
change the colors, navigate to the top of the screen where you will
see 4 colored circles, and drop down arrows along with each circle.
These circles represent the colors of each tool head.</p>
<p>To change the color, click on the <strong>Tool Head Colored Circle</strong>, and your
options for color will appear, we’re going to select <strong>Black</strong> for our
first color. After this, you will want to select the <strong>Default PLA
Settings</strong> by clicking the <strong>Drop Down Arrow</strong> to the right of the first
<strong>Tool Head Colored Circle</strong>. </p>
<p>As we make these changes you will notice that the 3D rendering of our
butterfly will change to our corresponding colors. Repeat this
process for the remaining 3 Tool Heads, remember to use the <strong>Default
PLA Settings</strong> for each Tool Head.</p>
<h3>Saving Your Project:</h3>
<p>After you have selected all your colors, you will click <strong>Save for
Printer</strong> in the top right corner of Chroma. From there, name your
file, and click <strong>Save</strong>. You will be then presented with a loading bar
as Chroma prepares our 2 output files. One of the files will be an
adjusted gcode file that has added the purge tower we just modified,
and the other file will be a file that goes straight to the Mosaic
Palette+.</p>
<h3>Printing Your Project:</h3>
<p>Once the files are ready, you will be presented with a screen that
says “Ready to Print!”. On this screen you will be presented with the
files you have created for your project, which for us are the
<code>butterfly-1.msf</code> which goes to the Mosaic Palette+ and the
<code>butterfly-1.msf.gcode</code> file which is your newly created gcode file.<br>
You will also be presented with “Materials Used” for the project,
“Number of Splices” for the project, and “Number of Pings” for the
project.</p>
<p>After this, you will need to turn your Creality Ender 3 on if it isn’t
already. After making sure that you have all your <strong>components set up
and assembled correctly</strong>, then it is safe to begin the printing
process.</p>
<p>Depending on your specific project will determine how long the
printing process takes. But once your printing process is complete
you will be presented with your <strong>beautiful multicolored 3D butterfly</strong>
(or whatever your project was)! After printing is finished, you
should let the project cool before you attempt to remove it from the
tray. Once it has cooled you can now gently pry the project off of the
tray.</p>
</blockquote>
<hr>
<h3>Footnotes</h3>
<p><sup>1</sup> The CR-10 is, on a broader level, an Ender-3 with 2 lead screws and a slightly different board.</p>
|
<p>The guide is at <a href="https://support.mosaicmfg.com/hc/en-us/articles/360011124234-Getting-Started-With-Palette-2-Setup-to-Printing-" rel="nofollow noreferrer">Getting Started With Palette 2 (Setup to Printing)</a>, which includes guides to use the correct slicer software and swapping <a href="https://support.mosaicmfg.com/hc/en-us/articles/360010073234-Firmware-Update" rel="nofollow noreferrer">the firmware</a>. </p>
<p>The latter part may be a little bit of an ordeal on the Ender3 as there is no bootloader on it - however, it is not apparent from the instruction, whether this would be an issue or not - it seems to be a fairly simple process.</p>
<blockquote>
<ol>
<li><p>Open your Palette 2 package and remove your Palette 2 unit and USB cable. Connect your Palette 2 to your computer.</p>
<p>To help the updater recognize the port for your Palette, try
unplugging other USB devices.</p></li>
<li><p>Download our Firmware Installer for your operating system. </p>
<p>Latest Palette Firmware V. 4.2.3 (Mar 14, 2019)</p>
<ul>
<li>Windows (x32 or x64) <a href="https://s3.amazonaws.com/mosaic-resources/p2fwup/latest/Palette+2+Firmware+Updater+Setup+1.1.2.exe" rel="nofollow noreferrer">Download</a></li>
<li>macOS <a href="https://s3.amazonaws.com/mosaic-resources/p2fwup/latest/Palette+2+Firmware+Updater-1.1.2.dmg" rel="nofollow noreferrer">Download</a></li>
<li>Linux (x64, Tested on Ubuntu 16.04) <a href="https://s3.amazonaws.com/mosaic-resources/p2fwup/latest/Palette+2+Firmware+Updater-1.1.2.dmg" rel="nofollow noreferrer">Download</a><sup>1</sup> </li>
</ul></li>
<li><p>Follow the on-screen instructions and click "Install Latest"</p></li>
<li><p>Once the firmware is updated, you will receive the <em>Success</em> message, and you can unplug your unit from your computer.</p></li>
</ol>
<hr>
<p><sup>1</sup> For Linux users, please refer to this <a href="https://support.mosaicmfg.com/hc/en-us/articles/115004996014-Enabling-USB-Serial-Port-Permissions-on-Linux" rel="nofollow noreferrer">support article</a>.</p>
</blockquote>
| 1,269
|
<p>So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state?</p>
<p>The biggest things I use global state (as I understand it) for is managing key pieces of information between our development, acceptance, and production environments. For example, I have a static class named "Globals" with a static member called "DBConnectionString." When the application loads, it determines which connection string to load, and populates Globals.DBConnectionString. I load file paths, server names, and other information in the Globals class.</p>
<p>Some of my functions rely on the global variables. So, when I test my functions, I have to remember to set certain globals first or else the tests will fail. I'd like to avoid this.</p>
<p>Is there a good way to manage state information? (Or am I understanding global state incorrectly?)</p>
|
<p>Dependency injection is what you're looking for. Rather than have those functions go out and look for their dependencies, inject the dependencies into the functions. That is, when you call the functions pass the data they want to them. That way it's easy to put a testing framework around a class because you can simply inject mock objects where appropriate.</p>
<p>It's hard to avoid some global state, but the best way to do this is to use factory classes at the highest level of your application, and everything below that very top level is based on dependency injection.</p>
<p>Two main benefits: one, testing is a heck of a lot easier, and two, your application is much more loosely coupled. You rely on being able to program against the interface of a class rather than its implementation.</p>
|
<p>An example of dependency injection in an MVC setting, here goes:</p>
<p>index.php</p>
<pre><code>$container = new Container();
include_file('container.php');
</code></pre>
<p>container.php</p>
<pre><code>container.add("database.driver", "mysql");
container.add("database.name","app");
</code></pre>
<p>...</p>
<pre><code>$container.add(new Database($container->get('database.driver', "database.name")), 'database');
$container.add(new Dao($container->get('database')), 'dao');
$container.add(new Service($container->get('dao')));
$container.add(new Controller($container->get('service')), 'controller');
$container.add(new FrontController(),'frontController');
</code></pre>
<p>index.php continues here:</p>
<pre><code>$frontController = $container->get('frontController');
$controllerClass = $frontController->getController($_SERVER['request_uri']);
$controllerAction = $frontController->getAction($_SERVER['request_uri']);
$controller = $container->get('controller');
$controller->$action();
</code></pre>
<p>And there you have it, the controller depends on a service layer object which depends on
a dao(data access object) object which depends on a database object with depends on the
database driver, name etc</p>
| 6,611
|
<p>Which scenarios, areas of an application/system, etc. are best suited for 'classic' state based testing versus using mock objects?</p>
|
<p>You should be using mocks for dependencies. I don't think that its an either-or; Usually you will create mocks for dependencies, set expectations (whether it is calls or state) on them, then run the unit under test. Then you would check its state, and verify the expectations on the mocks, afterwards.</p>
|
<p>Its a matter of style.. Mockist vs Classic TDDers.<br>
Personally.. I'd go testing real classes as far as possible. Tone down on Mocks as much as possible; only to decouple things like IO (filesystems, DB Connections, network), Third party components, etc. things that are slow/difficult to get under test. </p>
| 7,860
|
<ul>
<li>What is it?</li>
<li>How do I implement connection pooling with MS SQL?</li>
<li>What are the performance ramifications when</li>
<ul>
<li>Executing many queries one-after-the other (i.e. using a loop with 30K+ iterations calling a stored procedure)?</li>
<li>Executing a few queries that take a long time (10+ min)?</li>
</ul>
<li>Are there any best practices?</li>
</ul>
|
<p>Connection pooling is a mechanism to re-use connections, as establishing a new connection is slow.</p>
<p>If you use an MSSQL connection string and System.Data.SqlClient then you're already using it - in .Net this stuff is under the hood most of the time.</p>
<p>A loop of 30k iterations might be better as a server side cursor (look up T-SQL cursor statements), depending on what you're doing with each step outside of the sproc.</p>
<p>Long queries are fine - but be careful calling them from web pages as Asp.Net isn't really optimised for long waits and some connections will cut out. </p>
|
<p>Your question was also partially answered by <a href="https://stackoverflow.com/questions/8223/connection-pooling-in-netmssql">this thread</a>. A search would have revealed this.. The definition of Connection Pooling, of which a <a href="http://www.google.com/search?q=connection+pooling" rel="nofollow noreferrer">Google</a> would have answered with the first hit being <a href="http://en.wikipedia.org/wiki/Connection_pool" rel="nofollow noreferrer">this</a>..</p>
<p>Which would leave just the best practices, which I think would have been a good question :)</p>
<p>+1 to <a href="https://stackoverflow.com/questions/9228/adonet-connection-pooling-ms-sql#9233">Keith's Answer</a>. He has hit the nail right on the head.</p>
<p>Just a polite reminder from the FAQ:</p>
<blockquote>
<p>You've searched the internet before
asking your question, and you come to
us armed with research and information
about your question ... right?</p>
</blockquote>
| 3,063
|
<p>As I understand it, anything created with an <strong>alloc</strong>, <strong>new</strong>, or <strong>copy</strong> needs to be manually released. For example:</p>
<pre><code>int main(void) {
NSString *string;
string = [[NSString alloc] init];
/* use the string */
[string release];
}
</code></pre>
<p>My question, though, is wouldn't this be just as valid?:</p>
<pre><code>int main(void) {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
NSString *string;
string = [[[NSString alloc] init] autorelease];
/* use the string */
[pool drain];
}
</code></pre>
|
<p>Yes, your second code snippit is perfectly valid.</p>
<p>Every time -autorelease is sent to an object, it is added to the inner-most autorelease pool. When the pool is drained, it simply sends -release to all the objects in the pool.</p>
<p>Autorelease pools are simply a convenience that allows you to defer sending -release until "later". That "later" can happen in several places, but the most common in Cocoa GUI apps is at the end of the current run loop cycle.</p>
|
<p>Yes and no. You would end up releasing the string memory but "leaking" the NSAutoreleasePool object into memory by using drain instead of release if you ran this under a garbage collected (not memory managed) environment. This "leak" simply makes the instance of NSAutoreleasePool "unreachable" like any other object with no strong pointers under GC, and the object would be cleaned up the next time GC runs, which could very well be directly after the call to <code>-drain</code>:</p>
<blockquote>
<p>drain</p>
<p>In a garbage collected environment, triggers garbage collection if memory allocated since last collection is greater than the current threshold; otherwise behaves as release.
...
In a garbage-collected environment, this method ultimately calls <code>objc_collect_if_needed</code>.</p>
</blockquote>
<p>Otherwise, it's similar to how <code>-release</code> behaves under non-GC, yes. As others have stated, <code>-release</code> is a no-op under GC, so the only way to make sure the pool functions properly under GC is through <code>-drain</code>, and <code>-drain</code> under non-GC works exactly like <code>-release</code> under non-GC, and arguably communicates its functionality more clearly as well. </p>
<p>I should point out that your statement "anything called with new, alloc or init" should not include "init" (but should include "copy"), because "init" doesn't allocate memory, it only sets up the object (constructor fashion). If you received an alloc'd object and your function only called init as such, you would not release it:</p>
<pre><code>- (void)func:(NSObject*)allocd_but_not_init
{
[allocd_but_not_init init];
}
</code></pre>
<p>That does not consume any more memory than it you already started with (assuming init doesn't instantiate objects, but you're not responsible for those anyway).</p>
| 9,113
|
<p>We have an ASP.NET application that manages it's own User, Roles and Permission database and we have recently added a field to the User table to hold the Windows domain account. </p>
<p>I would like to make it so that the user doesn't have to <strong>physically</strong> log in to our application, but rather would be automatically logged in based on the currently logged in Windows domain account DOMAIN\username. We want to authenticate the Windows domain account against our own User table. </p>
<p>This is a piece of cake to do in Windows Forms, is it possible to do this in Web Forms?</p>
<p>I don't want the user to be prompted with a Windows challenge screen, I want our system to handle the log in.</p>
<p><strong>Clarification</strong>: We are using our own custom Principal object.</p>
<p><strong>Clarification</strong>: Not sure if it makes a difference or not, but we are using IIS7.</p>
|
<p>I did pretty much exactly what you want to do a few years ago. Im trying to find some code for it, though it was at a previous job so that code is at home.</p>
<p>I do remember though i used <a href="http://msdn.microsoft.com/en-us/library/ms998360.aspx" rel="nofollow noreferrer">this article</a> as my starting point. You set up the LDAP provider so you can actually run a check of the user vs the LDAP. One thing to make sure of if you try the LDAP approach. In the setting file where you set up the LDAP make sure LDAP is all caps, if it is not it will not resolve.</p>
|
<p>You can use <code>System.Threading.Thread.CurrentPrincipal</code>.</p>
| 7,765
|
<p>Is it "acceptable" to have an <strong>ASP.Net 2.0</strong> application without the BLL (Business Logic Layer) as the following?</p>
<ol>
<li>SQL Server Data Storage & Stored Procedures</li>
<li>Data Link Layer (Strongly Typed Table Adapters) connecting to Stored Procs</li>
<li>Presentation Layer ASPX Pages with Code behind and ObjectDataSource for connection straight to the DLL</li>
</ol>
<p>Is a BLL always preferable, even if business logic is entirely validatable in the presentation's code behind? What are the potential drawbacks for not using a BLL?</p>
|
<p>It's acceptable as long as you understand the consequences. The main reason you'd have a BLL is to re-use that logic elsewhere throughout your application.</p>
<p>If you have all that validation logic in the presentation code, you're really making it difficult to re-use elsewhere within your application.</p>
|
<p>If the application is a general one, then the business logic layer can be used in complete other applications too. Like, I normally use my CMS related BLL classes in other applications.</p>
| 2,634
|
<p>I have a WPF application in VS 2008 with some web service references. For varying reasons (max message size, authentication methods) I need to manually define a number of settings in the WPF client's app.config for the service bindings.</p>
<p>Unfortunately, this means that when I update the service references in the project we end up with a mess - multiple bindings and endpoints. Visual Studio creates new bindings and endpoints with a numeric suffix (ie "Service1" as a duplicate of "Service"), resulting in an invalid configuration as there may only be a single binding per service reference in a project.</p>
<p>This is easy to duplicate - just create a simple "Hello World" ASP.Net web service and WPF application in a solution, change the maxBufferSize and maxReceivedMessageSize in the app.config binding and then update the service reference.</p>
<p>At the moment we are working around this by simply undoing checkout on the app.config after updating the references but I can't help but think there must be a better way!</p>
<p>Also, the settings we need to manually change are:</p>
<pre><code><security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
</code></pre>
<p>and:</p>
<pre><code><binding maxBufferSize="655360" maxReceivedMessageSize="655360" />
</code></pre>
<p>We use a service factory class so if these settings are somehow able to be set programmatically that would work, although the properties don't seem to be exposed.</p>
|
<p>Create a .Bat file which uses svcutil, for proxygeneration, that has the settings that is right for your project. It's fairly easy. Clicking on the batfile, to generate new proxyfiles whenever the interface have been changed is easy.</p>
<p>The batch can then later be used in automated builds. Then you only need to set up the app.config (or web.config) once. We generally separate the different configs for different environments, such as dev, test prod.</p>
<p>Example (watch out for linebreaks):</p>
<pre><code>REM generate meta data
call "SVCUTIL.EXE" /t:metadata "MyProject.dll" /reference:"MyReference.dll"
REM making sure the file is writable
attrib -r "MyServiceProxy.cs"
REM create new proxy file
call "SVCUTIL.EXE" /t:code *.wsdl *.xsd /serializable /serializer:Auto /collectionType:System.Collections.Generic.List`1 /out:"MyServiceProxy.cs" /namespace:*,MY.Name.Space /reference:"MyReference.dll"
</code></pre>
<p>:)</p>
<p>//W</p>
|
<p>Somehow I prefer using svcutil.exe directly than to use the "Add Service Reference" feature of Visual Studio :P This is what we're doing on our WCF projects.</p>
| 9,445
|
<p>This question is related to <a href="https://stackoverflow.com/questions/43324/can-i-put-an-aspnet-session-id-in-a-hidden-form-field">this one</a>, though I think I was a little too long-winded there to really get a good answer. I'll keep this brief.</p>
<p>I'm working on a web handler (ashx) that accepts a form post from an aspx page. When the handler receives this form post, in order to do what it needs to do, it needs to know the user who is logged in (User.Identity.Name), but I can't rely on cookies being sent by the browser.</p>
<p>I know I can get the Session.SessionID and place it in a hidden form field, but once my handler receives the form post, how can I use that SessionID to figure out the logged-in user's identity?</p>
<p>I'm using the StateServer mode for session state.</p>
|
<p>I think you can do it be implementing the <a href="http://www.hanselman.com/blog/GettingSessionStateInHttpHandlersASHXFiles.aspx" rel="nofollow noreferrer">IReadOnlySessionState</a> interface on your HttpHandler</p>
|
<p>In an HttpHandler or HttpModule implementation, you cannot always access session from the BeginRequest event. There is another event you can handle, called OnAcquireRequestState. If you write your code in that event, then HttpContext.Current.Session will not be null.</p>
| 7,938
|
<p>I am trying to delete several rows from a MySQL 5.0.45 database:</p>
<pre><code>delete from bundle_inclusions;
</code></pre>
<p>The client works for a while and then returns the error:</p>
<pre><code>Lock wait timeout exceeded; try restarting transaction
</code></pre>
<p>It's possible there is some uncommitted transaction out there that has a lock on this table, but I need this process to trump any such locks. How do I break the lock in MySQL?</p>
|
<p>I agree with Erik; TRUNCATE TABLE is the way to go. However, if you can't use that for some reason (for example, if you don't <em>really</em> want to delete every row in the table), you can try the following options:</p>
<ul>
<li>Delete the rows in smaller batches (e.g. DELETE FROM bundle_inclusions WHERE id BETWEEN ? and ?)</li>
<li>If it's a MyISAM table (actually, this may work with InnoDB too), try issuing a LOCK TABLE before the DELETE. This should guarantee that you have exclusive access.</li>
<li>If it's an InnoDB table, then <em>after</em> the timeout occurs, use SHOW INNODB STATUS. This should give you some insight into why the lock acquisition failed.</li>
<li>If you have the SUPER privilege you could try SHOW PROCESSLIST ALL to see what other connections (if any) are using the table, and then use KILL to get rid of the one(s) you're competing with.</li>
</ul>
<p>I'm sure there are many other possibilities; I hope one of these help.</p>
|
<p>Guessing: truncate table bundle_inclusions</p>
| 9,026
|
<p>I'm interested in designing & 3D printing as a hobby (e.g. printing chess sets, small toys for family etc.)</p>
<p>Conducting a Google search has brought up a range of small, cheap printers, but beyond that I don't know how to differentiate them.</p>
<p>E.g. selling points include:</p>
<ul>
<li>"liquid light-sensitive resin"</li>
<li>"partially assembled" with "very few parts and minor configuration"</li>
<li>"Wi-Fi enabled"</li>
</ul>
<p>My question is, <strong>which features are going to benefit a small-scale, new enthusiast to 3D printing?</strong></p>
<p>PS. The software I intend to use is Windows 10 3D design</p>
<p>PPS. I'm not a graphic designer by any means, just a new enthusiast.</p>
|
<p>Here are few things to consider from my point of view</p>
<hr>
<p><strong>Printing technology</strong></p>
<p>The first thing that you need to take into account is printing technology. The most common[citation needed] right now is Fused Filament Fabrication. "Liquid light-sensitive resin" is being used in Stereolitography and Digital Light Processing - the SLA printers I found are less common and more expensive than FFF ones.</p>
<hr>
<p><strong>Price</strong></p>
<p>Need to decide on budget. You can buy printer for 60k USD and 400 USD. Quality is somehow linked to price but that's not a rule. You can buy a shitty printer for a lot of money.</p>
<hr>
<p><strong>Printing area</strong></p>
<p>Bigger allows you to print bigger things. You need to ask yourself how big things you really want to print. Remember that 3d printing is quite slow process - how often you will want to print big things that will take 60hrs+ to finish?</p>
<hr>
<p><strong>Printing materials</strong></p>
<p>What kind of materials you want to print with? Some materials will need higher temperatures so check the max hot-end temperature, some will require heated bed.</p>
<hr>
<p><strong>Assembled or DIY kit</strong></p>
<p>You can usually get kits for self-assembly cheaper than Ready-To-Print machines. However, it will require additional skills (i.e. soldering), tools and time to assemble. I am not sure if I would buy DIY kit for commercial use, but as an enthusiast I immensely enjoyed putting my Rostock Max together.</p>
<hr>
<p><strong>Reviews and reputation</strong></p>
<p>It is generally safe to buy printer that already has some users. Beware of new magical Kickstarter printers which will "change the 3d printing forever".
Reddit /r/3dprinting suggests that your new printer should meet 3 criteria:</p>
<ul>
<li>Printer passes the youtube test - has lots of youtube evidence that this particular printer is working.</li>
<li>Printer is out of the pre-order phase. This means that all pre-orders have been delivered.</li>
<li>Printer has a reputation of working well among current users.</li>
</ul>
<p>I found it to be a very good set of rules.</p>
<hr>
<p><strong>Upgrade capabilities</strong></p>
<p>That's very user-dependent, but this point is very important to me. I want to be able to change and improve certain parts of my printer. Check if you can switch the extruder, replace the hot-end etc. </p>
<hr>
<p><strong>Support</strong></p>
<p>I think one of the most important points. See if you can find a forum for your printer and how active community is. It will be immensely helpful if something goes wrong (and it will).
Also, company support is very important. What will happen if you need a replacement part or your printer will stop working altogether?</p>
<hr>
<p>This list is definitely not complete.
There are many more things that might be taken into account like configuration (delta or XY), multiple extruders, closed cases etc.</p>
|
<p>One of the biggest questions you should ask yourself is: What is your end goal? </p>
<ol>
<li><p>Is it to get your printer and immediately print something (pre-assembled). </p></li>
<li><p>Is it to learn about 3d printing by constructing a kit, encountering all kinds of potential issues getting it working, then once it is working getting everything all dialed in and then getting good prints. </p></li>
</ol>
<p>The 2nd option requires less initial investment but may take considerable time and frustration. (I did this 6 months ago)</p>
| 122
|
<p>As one of those people that never got around to properly learning design (or having no talent for it), the design seems to be the step always holding me back. It's not a problem for rich-clients, as the standard GUI toolkits provide some acceptable ways to design a good-looking interface, but the web is another story. </p>
<p>Question: Does anyone know of a high-quality framework for designing the interface of web applications? I'm thinking of standard snippets of html for an adequate set of controls (the standard html controls plus maybe navigations, lists, forms) and style sheets to give it an acceptable, modern look. If such a thing existed, it could even support themes in the way wordpress, drupal etc. allow it.</p>
<p>I know of the yahoo yui, but that's mostly javascript, though their grid css is a step in the right direction. </p>
|
<p>Try the <a href="http://www.extjs.com/products/extjs/" rel="noreferrer">samples on ExtJs</a>.
I find them immensely useful in working out the UI. (trees, panels, modals, etc etc)</p>
|
<p>Check out <a href="http://jacanasoftware.com" rel="nofollow noreferrer">http://jacanasoftware.com</a>. Their templates feature multi level tabs, clean css, it validates, and the CSS won't mess with your controls. I highly recommend them.</p>
| 6,972
|
<p>I am creating an application for a Windows Mobile computer. The catch is that the device (<a href="http://www.motorola.com/business/v/index.jsp?vgnextoid=d4397b103d175110VgnVCM1000008406b00aRCRD" rel="nofollow noreferrer">Motorola MC17</a>) does not have a touch screen or universal keys - there are only six programmable hardware keys. <a href="http://en.wikipedia.org/wiki/Fitts%27s_law" rel="nofollow noreferrer">Fitt's law</a> is not applicable here, most Microsoft guidelines are also moot. For now I'm mimicking Nokia's S60 keyboard layout as close as possible, since it's the most popular phone platform among my target audience.</p>
<p><img src="https://i.stack.imgur.com/jsDo2.jpg" alt="Motorola MC17"/></p>
<p>Are there any guidelines for creating a simple, discoverable user interface on such a constrained device? What fonts and colours should I use to make my UI readable? How do I measure if the items on-screen are big enough? What conventions should I follow?</p>
|
<p>Last time I checked, you could use the <a href="http://developers.sugarcrm.com/tutorials/Customizing_Sugar/4/" rel="nofollow noreferrer">module builder</a> to extend the interface. From 5.0 (or maybe 4.x) on, Sugar added all those APIs, which should enable you to extend SugarCRM without hacking it in and losing it with the next upgrade.</p>
<p>Hope that helps!</p>
|
<p>Basically, the Account name should be a related field in your new invoices module (base the module creation on something like QUOTES that has similar fields. Once you create the module (so simple you can almost guess your way through it in the ADMIN section) and the fields you like (using Studio) just add the RELATED field Account Name and the sub-panel will be established in your ACCOUNTS module and the invoice will magically populate, especially if you re-install them using the import feature from a CSV file (spreadsheet).</p>
| 5,856
|
<p>In an application that I'm writing I have some code like this:</p>
<pre><code>NSWorkspace* ws = [NSWorkspace sharedWorkspace];
NSString* myurl = @"http://www.somewebsite.com/method?a=%d";
NSURL* url = [NSURL URLWithString:myurl];
[ws openURL:url];
</code></pre>
<p>The main difference being that <em>myurl</em> comes from somewhere outside my control. Note the %d in the URL which isn't entirely correct and means that URLWithString fails, returning <em>nil</em>.</p>
<p>What is the "correct" way of handling this? Do I need to parse the string and properly encode the arguments? Or is there some clever method in Cocoa that does all the hard work for me?</p>
|
<p>I'm not sure if this is exactly what you're looking for, but there is a method in NSString that will sanitize a URL:</p>
<p><a href="https://developer.apple.com/documentation/foundation/nsstring/1415058-stringbyaddingpercentescapesusin" rel="nofollow noreferrer">stringByAddingPercentEscapesUsingEncoding:</a></p>
|
<p>Unfortunately you need to be smarter than what is provided by Apple :</p>
<pre><code>stringByAddingPercentEscapesUsingEncoding:
</code></pre>
<p>This will escape all invalid URL characters so that "http://foo.com/hey%20dude/", which is valid, becomes "http://foo.com/hey%2520dud/", which is not what we want. </p>
<p>According to apple documentation : <a href="http://developer.apple.com/library/mac/documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html#//apple_ref/c/func/CFURLCreateStringByAddingPercentEscapes" rel="nofollow">http://developer.apple.com/library/mac/documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html#//apple_ref/c/func/CFURLCreateStringByAddingPercentEscapes</a></p>
<p>I made an NSURL category which does the right thing and works with odd string such as ones with partial encoding (i.e. "http://foo.com/hey dude/i%20do%20it/").</p>
<p>Here is the code:</p>
<pre><code>@interface NSURL (SmartEncoding)
+ (NSURL *)smartURLWithString:(NSString *)str;
@end
@implementation NSURL (SmartEncoding)
+ (NSURL *)smartURLWithString:(NSString *)str
{
CFStringRef preprocessed = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (CFStringRef)str, CFSTR(""), kCFStringEncodingUTF8);
if (!preprocessed)
preprocessed = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (CFStringRef)str, CFSTR(""), kCFStringEncodingASCII);
if (!preprocessed)
return [NSURL URLWithString:str];
CFStringRef sanitized = CFURLCreateStringByAddingPercentEscapes(NULL, preprocessed, NULL, NULL, kCFStringEncodingUTF8);
CFRelease(preprocessed);
NSURL *result = (NSURL*)CFURLCreateWithString(NULL, sanitized, NULL);
CFRelease(sanitized);
return [result autorelease];
}
@end
</code></pre>
<p>It works fine with UTF8 string encoded and ASCII ones.</p>
| 6,791
|
<p>Is it realistic or thought neccesary to develop a plugin/feature for this site, to automatically add a small info-box about a thingiverse link? An example of this is Apple's 3D touch technology. In theory, the plugin could recogize thingiverse links in questions and answers, replace the link with an image and the author/name of the project.</p>
<p>I'm also volunteering myself to help with this if there's interest. (Experience with Thingiverse API)</p>
|
<p>Typically, it's a better idea to wait before you try to get this kind of thing integrated.</p>
<p>Enthusiasm is great in a private beta, but for the early stages, direct that enthusiasm towards the Q&A. That's what'll get this site on its feet and into a successful public beta.</p>
<p>When the site's more stable and running nicely, then if there's a need (or want) for a plugin like this then the discussion about it can be had.</p>
<p>(On a tangent - if such a plugin is going to happen, it may well be down to SE's developers to get it done, which might make getting assistance from the people on this site difficult.)</p>
|
<h3>Technological issues</h3>
<p>Stack Exchange works hard for its communities, but there is a limit. If thingiverse changes its API (which it can, and does, do at any time without notice) then anything we build on it has to be modified, and users will be very whiny until it's fixed.</p>
<p>If we choose to integrate model viewing or any sort of API integration with an outside service, we will have to make sure the service provides some sort of legacy guarantee minimal API that won't change, and then we will only be able to use that. </p>
<h3>Political issues</h3>
<p>I would be very uncomfortable endorsing a closed source, commercial service on this site. There are many communities within the world of 3D printing that are very unhappy with makerbot, thingiverse, and their parent company, and encouraging users to use this service may result in pushing away some very valuable experts within the reprap world.</p>
<h3>Looking to the future</h3>
<p>If we integrate any sort of model library or model viewer, I strongly suggest we choose an open source project the community can heartily endorse. We may link to outside models, but the core API should be servable by stack exchange without license or much maintenance so 1) we don't have to deal with API changes messing us up, 2) we don't rely on outside services that may change their terms of use or API, 3) we don't have to form complicated contract bound relationships with 3rd parties just to get the guarantees we'd need to convince Stack Exchange to invest in a new feature, and 4) we don't become too politically involved such that we disenfranchise users who may have very strong feelings about this subject.</p>
<h3>Wait and see</h3>
<p>This is the early beta. Let's find out what people link to in questions before dedicating resources to improving the links/plug-ins/oneboxes. It may be that thingiverse objects are linked to frequently, and that it would add value to the site to improve that experience, but it's also just as likely that thingiverse turns out to be infrequently linked and the effort spent now would essentially have been wasted. Let's wait until we have tens of thousands of questions so we can properly evaluate what the community actually uses and needs.</p>
| 6
|
<p>I have an application that displays an image inside of a Windows Forms <code>PictureBox</code> control. The <code>SizeMode</code> of the control is set to <code>Zoom</code> so that the image contained in the <code>PictureBox</code> will be displayed in an aspect-correct way regardless of the dimensions of the <code>PictureBox</code>.</p>
<p>This is great for the visual appearance of the application because you can size the window however you want and the image will always be displayed using its best fit. Unfortunately, I also need to handle mouse click events on the picture box and need to be able to translate from screen-space coordinates to image-space coordinates.</p>
<p>It looks like it's easy to translate from screen space to control space, but I don't see any obvious way to translate from control space to image space (i.e. the pixel coordinate in the source image that has been scaled in the picture box).</p>
<p>Is there an easy way to do this, or should I just duplicate the scaling math that they're using internally to position the image and do the translation myself?</p>
|
<p>Depending on the scaling, the relative image pixel could be anywhere in a number of pixels. For example, if the image is scaled down significantly, pixel 2, 10 could represent 2, 10 all the way up to 20, 100), so you'll have to do the math yourself and take full responsibility for any inaccuracies! :-)</p>
|
<p>Depending on the scaling, the relative image pixel could be anywhere in a number of pixels. For example, if the image is scaled down significantly, pixel 2, 10 could represent 2, 10 all the way up to 20, 100), so you'll have to do the math yourself and take full responsibility for any inaccuracies! :-)</p>
| 2,494
|
<p>I was trying to print parts for a small CD-ROM drive based plotter based on this thing <a href="https://www.thingiverse.com/thing:3521286" rel="nofollow noreferrer">https://www.thingiverse.com/thing:3521286</a></p>
<p>But as tolerances are very small and need to match the existing parts, I realized that my printed parts are actually a little bigger, I made a test with a part like this:</p>
<pre><code> _ _
/ \ / \
\ .------------------------. ___
| [O]________________[O] | ^
| | | | |
| | | | |
| | | | |
| | |<--- 62mm ---->| | | |
| | | | 70mm
| | | | |
| | | | |
| | | | |
| | | | |
_| [O]________________[O] | _v_
/ '------------------------' \
\ _ / \ _ /
Side View:
[X] [X]
___[XXXXXXXXXXXXXXXXXXXXXXXX]____
</code></pre>
<p>A squared and mouse-eared frame with two protruding 4mm cubes on each corner with inner distances of 62mm and outer of 70mm between each adjacent cubes.</p>
<p>I discovered that, after measuring many times and averaging distances, my model printed 0.227..% larger.</p>
<p>I've heard of shrinkage factor for ABS or Nylon, and people compensate scaling their models while slicing.</p>
<p>But what about PLA?</p>
<p>Im using:</p>
<ul>
<li>Anet A8</li>
<li>Stock marlin firmware (not the Anet one)</li>
<li>Flashforge natural PLA 1.75mm</li>
<li>0.4mm Nozzle</li>
<li>0.2mm layer height</li>
<li>0.4mm line width</li>
<li>210ºC extrusion temp</li>
<li>60ºC Bed temp</li>
<li>40mm/s print speed</li>
<li>Fusion 360, Cura 2.7 or 4.3 and Octoprint.</li>
</ul>
<p>The printed model is pretty flat, has no curvatures or artifacts either.</p>
<p><strong><em>Would this be an error of constants on my printer a known artifact from PLA?</em></strong></p>
|
<p><a href="https://3dprinting.stackexchange.com/questions/6968/slicer-line-width-vs-extrusion-multiplier-for-layer-adhesion">You are not taking into account die swell</a>.</p>
<p>When printing with a 3D printer hot plastic is forced through a nozzle, which leads to the expansion of the material. The result is, that with 0.4 mm nozzle and 0.4 mm intended line width, the material will actually deposit some fraction of a millimeter wider. In your test case, that is 0.22%. If you'd print a double-sized test piece, I expect 0.11%, and in case of a half-sized 0.44% - in other words, it is a static offset.</p>
<p>Because of this, it is usually better to demand wider lines than the nozzle is, forcing the die swell effect to become negligible in the wider line. I managed this with about 110% of the nozzle width on my machines.</p>
<p>Further Reading: <a href="https://3dprinting.stackexchange.com/questions/6965/why-is-it-conventional-to-set-line-width-nozzle-diameter">Why is it conventional to set line width > nozzle diameter?</a></p>
|
<p>There are several ways to try and adjust for this effect of squashing the material, which is ultimately about having enough space for the material you lay down.</p>
<p>As mentioned:
You can try to pre-scale models (not very effective as a general solution because it is a function of the model and how many adjacent layers your material is forcing)</p>
<p>You can up the line width.</p>
<p>If your software allows, you can input a slightly larger filament diameter to lay a bit less material. (Wanted to stress this one as it's been pretty useful for me)</p>
<p>If you are intentionally undershooting the volume by some percentage via the filament diameter, it may help to play with the layer height to control the end result of the line's cross section.</p>
<p>I've had good results with a combination of the latter three (basically comes down to calibrating the printer to get settings for your desired material spool, and level of detail -> sizes of line and layer for the print)</p>
| 1,488
|
<p>How do I park a Bluetooth connection? I'm trying to communicate with dozens of Bluetooth devices, and the time to re-establish a connection is unacceptable. I've read that you can park connections, but not found anything that answers how to do this.</p>
|
<p>I know that you can park a connection if it's on the MS Bluetooth stack. There is a nice API you can use called 32feet.Net. It lets you set the socket options. Here's a quick link to the <a href="http://community.inthehand.com/library/InTheHand.Net.Bluetooth.BluetoothSocketOptionNameMembers.html" rel="nofollow noreferrer">documentation</a>. I hope it helps.</p>
|
<p>Parking mode is one of connected state mode, explained in the core Bluetooth spec, right from early 1.1 or so. Please follow up with various sniff modes as well, including the newer ones such as sniff sub rating. Other than park modes, you have hold modes as well.</p>
| 9,012
|
<p>The following code writes no data to the back buffer on Intel integrated video cards,for example, on a MacBook. On ATI cards, such as in the iMac, it draws to the back buffer. The width and height are correct (and 800x600 buffer) and m_PixelBuffer is correctly filled with 0xAA00AA00.</p>
<p>My best guess so far is that there is something amiss with needing glWindowPos set. I do not currently set it (or the raster position), and when I get GL_CURRENT_RASTER_POSITION I noticed that the default on the ATI card is 0,0,0,0 and the Intel it's 0,0,0,1. When I set the raster pos on the ATI card to 0,0,0,1 I get the same result as the Intel card, nothing drawn to the back buffer. Is there some transform state I'm missing? This is a 2D application so the view transform is a very simple glOrtho.</p>
<pre><code>glDrawPixels(GetBufferWidth(), GetBufferHeight(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, m_PixelBuffer);
</code></pre>
<p>Any more info I can provide, please ask. I'm pretty much an OpenGL and Mac newb so I don't know if I'm providing enough information.</p>
|
<p>I've always had problems with OpenGL implementations from Intel, though I'm not sure that's your problem this time. I think you're running into some byte-order issues. Give this a read and feel free to experiment with different constants for packing and color order.</p>
<p><a href="http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/universal_binary_tips/chapter_5_section_25.html" rel="nofollow noreferrer">http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/universal_binary_tips/chapter_5_section_25.html</a></p>
<p>I know it's OSX guide, you can probably find similar OpenGL articles on other sites for other platforms. This should be applicable.</p>
|
<blockquote>
<p>I've always had problems with OpenGL
implementations from Intel</p>
</blockquote>
<p>This is kind of what I'm worried about, but I have a hard time believing they'd screw up something as basic as glDrawPixels, and also, since I can "duplicate" the problem by changing the raster position vector, it makes me think it's my fault and I'm missing something basic.</p>
<blockquote>
<p>I think you're running into some
byte-order issues</p>
</blockquote>
<p>That was my first inclination, and I've tried packing differently, with no result. I also tried packing the buffer with values that would present a usable alpha if swizzled, with no result. This is why I'm barking up the raster pos tree, but I'm still honestly not 100% sure. Note that I'm targeting only Intel Macs if that makes a difference.</p>
<p>Thanks for the link, it was a good read, and good to tuck away for future reference. I'd upmod but I can't until I get 3 more rep points :)</p>
| 4,524
|
<p>I have a page with many forms in panels and usercontrols, and a requiredfield validator I just added to one form is preventing all of my other forms from submitting. what's the rule that I'm not following?</p>
|
<p>Are you using ValidationGroups? Try assigning each control with a validation group as well as the validator that you want to use. Something like:</p>
<pre><code><asp:TextBox ID="txt1" ValidationGroup="Group1" ruant="server" />
<asp:RequiredFieldValidator ID="rfv1" ... ValidationGroup="Group1" />
</code></pre>
<p>Note, if a button doesn't specify a validation group it will validate all controls that aren't assigned to a validation group.</p>
|
<p>You should be setting ValidationGroup property to a different value for each group of elements. Your validator's ValidationGroup must only be same with the control that submit its form.</p>
| 5,564
|
<p>I've come across a few different applications that monitor my usage while on the computer, but what have you used, and like? whether it be writing down your activities in a composition notbook or install an app that reports silently to a server? what do you like?</p>
|
<p>For explicit time tracking for projects I use <a href="http://slimtimer.com" rel="nofollow noreferrer">SlimTimer</a>. I also run <a href="http://www.rescuetime.com/" rel="nofollow noreferrer">RescueTime</a> to track my time implicitly, but I end up not looking at that data very often.</p>
|
<p>I prefer writing the times down using pen and paper. That way you can more fairly weigh things that would have been miscalculated if you were recording them with a stopwatch or timer.</p>
<p>If you start on something and have to get up for a few minutes, a timer may count that toward your working time had you neglected to stop or pause the timer. The good-old pen and paper are going to more accurately show which tasks you focused most of your time and energy on...not just the ones that you started earliest and ended latest. It may not be 100% accurate, but neither is the timer if you don't use it properly.</p>
<p>I have used both in the past, and find that there are problems with both, but I prefer the pen and paper method.</p>
| 9,893
|
<p>My Anet A8 frame are broken. I find frame project <a href="https://www.thingiverse.com/thing:2263216" rel="nofollow noreferrer">AM8 - Metal Frame for Anet A8</a>. I like it but I can't find aluminum extrusion needed, like this: <a href="https://us.misumi-ec.com/vona2/detail/110302684350/?Inch=0&CategorySpec=00000042730%3A%3A20x40" rel="nofollow noreferrer">MiSUMi - Aluminum Extrusion - 5 series, Base 20, 20mm x 40mm</a>.</p>
<p>Maybe somebody knows where I can buy it in Ukraine? Or maybe another frame options?</p>
|
<p>There are lots of online sources for T-slot aluminum extrusions from <a href="https://www.ebay.com/" rel="nofollow noreferrer">ebay</a> to <a href="https://www.mcmaster.com/#t-slotted-framing/=18c9twv" rel="nofollow noreferrer">McMaster</a>. If you want more options do a <a href="https://www.google.com/search?q=t-slot%20aluminum%20extrusion&rlz=1C1GNAM_enUS688US688&oq=t-slot%20a&aqs=chrome.2.69i57j0l5.6487j0j7&sourceid=chrome&ie=UTF-8" rel="nofollow noreferrer">Google Search</a>. </p>
<p><a href="https://i.stack.imgur.com/OSerK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OSerK.jpg" alt="enter image description here"></a></p>
|
<p>Not precisely cheap, but if you look on aliExpress for <em>AM8 3D Printer Extrusion Metal Frame</em> you will find kits build precisely for moving Anet A8 to aluminium frame</p>
| 643
|
<p>I have a database with names in it such as John Doe etc. Unfortunately some of these names contain quotes like Keiran O'Keefe. Now when I try and search for such names as follows:</p>
<pre><code>SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe'
</code></pre>
<p>I (understandably) get an error.</p>
<p>How do I prevent this error from occurring. I am using Oracle and PLSQL.</p>
|
<p>The escape character is ', so you would need to replace the quote with two quotes.</p>
<p>For example,</p>
<p><code>SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe'</code></p>
<p>becomes</p>
<p><code>SELECT * FROM PEOPLE WHERE SURNAME='O''Keefe'</code></p>
<p>That said, it's probably incorrect to do this yourself. Your language may have a function to escape strings for use in SQL, but an even better option is to use parameters. Usually this works as follows.</p>
<p>Your SQL command would be : </p>
<p><code>SELECT * FROM PEOPLE WHERE SURNAME=?</code></p>
<p>Then, when you execute it, you pass in "O'Keefe" as a parameter.</p>
<p>Because the SQL is parsed before the parameter value is set, there's no way for the parameter value to alter the structure of the SQL (and it's even a little faster if you want to run the same statement several times with different parameters).</p>
<p>I should also point out that, while your example just causes an error, you open youself up to a lot of other problems by not escaping strings appropriately. See <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/SQL_injection</a> for a good starting point or the following classic <a href="http://xkcd.com/327/" rel="nofollow noreferrer">xkcd comic</a>.</p>
<p><img src="https://imgs.xkcd.com/comics/exploits_of_a_mom.png" alt="alt text"></p>
|
<p>Found in under 30s on Google...</p>
<p><a href="http://www.orafaq.com/wiki/SQL_FAQ#How_does_one_escape_special_characters_when_writing_SQL_queries.3F" rel="nofollow noreferrer">Oracle SQL FAQ</a></p>
| 4,944
|
<p>I want to take a screenshot via a python script and unobtrusively save it.</p>
<p>I'm only interested in the Linux solution, and should support any X based environment.</p>
|
<p>This works without having to use scrot or ImageMagick.</p>
<pre><code>import gtk.gdk
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
print "The size of the window is %d x %d" % sz
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
if (pb != None):
pb.save("screenshot.png","png")
print "Screenshot saved to screenshot.png."
else:
print "Unable to get the screenshot."
</code></pre>
<p>Borrowed from <a href="http://ubuntuforums.org/showpost.php?p=2681009&postcount=5" rel="noreferrer">http://ubuntuforums.org/showpost.php?p=2681009&postcount=5</a></p>
|
<p>Try it:</p>
<pre><code>#!/usr/bin/python
import gtk.gdk
import time
import random
import socket
import fcntl
import struct
import getpass
import os
import paramiko
while 1:
# generate a random time between 120 and 300 sec
random_time = random.randrange(20,25)
# wait between 120 and 300 seconds (or between 2 and 5 minutes)
print "Next picture in: %.2f minutes" % (float(random_time) / 60)
time.sleep(random_time)
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
print "The size of the window is %d x %d" % sz
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
ts = time.asctime( time.localtime(time.time()) )
date = time.strftime("%d-%m-%Y")
timer = time.strftime("%I:%M:%S%p")
filename = timer
filename += ".png"
if (pb != None):
username = getpass.getuser() #Get username
newpath = r'screenshots/'+username+'/'+date #screenshot save path
if not os.path.exists(newpath): os.makedirs(newpath)
saveas = os.path.join(newpath,filename)
print saveas
pb.save(saveas,"png")
else:
print "Unable to get the screenshot."
</code></pre>
| 9,499
|
<p>Since there are no header sections for user controls in asp.net, user controls have no way of knowing about stylesheet files. So css classes in the user controls are not recognized by visual studio and produces warnings. How can I make a user control know that it will relate to a css class, so if it is warning me about a non-existing css class, it means that the class really do not exist?</p>
<p>Edit: Or should I go for a different design like exposing css classes as properties like "HeaderStyle-CssClass" of GridView?</p>
|
<p>Here's what I did:</p>
<pre><code><link rel="Stylesheet" type="text/css" href="Stylesheet.css" id="style" runat="server" visible="false" />
</code></pre>
<p>It fools Visual Studio into thinking you've added a stylesheet to the page but it doesn't get rendered.</p>
<hr>
<p>Here's an even more concise way to do this with multiple references;</p>
<pre><code><% if (false) { %>
<link rel="Stylesheet" type="text/css" href="Stylesheet.css" />
<script type="text/javascript" src="js/jquery-1.2.6.js" />
<% } %>
</code></pre>
<p>As seen in <a href="http://haacked.com/archive/2008/11/21/combining-jquery-form-validation-and-ajax-submission-with-asp.net.aspx" rel="noreferrer">this blog post</a> from Phil Haack.</p>
|
<p>You Can use <code>CSS</code> direct in <code>userControl</code>.</p>
<p>Use this in <code>UserControl</code>:</p>
<pre><code> <head>
<title></title>
<style type="text/css">
.wrapper {
margin: 0 auto -142px;
/* the bottom margin is the negative value of the footer's height */
}
</style>
</head>
</code></pre>
<p>This will work.</p>
| 5,459
|
<h2>How do you find the phone numbers in 50,000 HTML pages?<br><br></h2>
<blockquote>
<h3>Jeff Attwood posted 5 Questions for programmers applying for jobs:</h3>
<p>In an effort to make life simpler for phone screeners, I've put together
this list of Five Essential Questions
that you need to ask during an SDE
screen. They won't guarantee that your
candidate will be great, but they will
help eliminate a huge number of
candidates who are slipping through
our process today.</p>
<p><strong>1) Coding</strong> The candidate has to write
some simple code, with correct syntax,
in C, C++, or Java.</p>
<p><strong>2) OO design</strong> The candidate has to
define basic OO concepts, and come up
with classes to model a simple
problem.</p>
<p><strong>3) Scripting and regexes</strong> The
candidate has to describe how to find
the phone numbers in 50,000 HTML
pages.</p>
<p><strong>4) Data structures</strong> The candidate has
to demonstrate basic knowledge of the
most common data structures.</p>
<p><strong>5) Bits and bytes</strong> The candidate has
to answer simple questions about bits,
bytes, and binary numbers.</p>
<p>Please understand: what I'm looking
for here is a total vacuum in one of
these areas. It's OK if they struggle
a little and then figure it out. It's
OK if they need some minor hints or
prompting. I don't mind if they're
rusty or slow. What you're looking for
is candidates who are utterly
clueless, or horribly confused, about
the area in question.</p>
<p><strong><a href="http://www.codinghorror.com/blog/archives/001042.html" rel="noreferrer">>>> The Entirety of Jeff´s Original Post <<<</a></strong></p>
</blockquote>
<p><br>
<strong>Note:</strong> Steve Yegge originally posed the Question.</p>
|
<pre><code>egrep "(([0-9]{1,2}.)?[0-9]{3}.[0-9]{3}.[0-9]{4})" . -R --include='*.html'
</code></pre>
|
<p>Here's why phone interview coding questions don't work: </p>
<p>phone screener: how do you find the phone numbers in 50,000 HTML pages?</p>
<p>candidate: hang on one second (covers phone) hey (roommate/friend/etc who's super good at programming), how do you find the phone numbers in 50,000 HTML pages?</p>
<p>Save the coding questions for early in the in-person interview, and make the interview questions more personal, i.e. "I'd like details about the last time you solved a problem using code". That's a question that will beg follow-ups to their details and it's a lot harder to get someone else to answer it for you without sounding weird over the phone.</p>
| 7,118
|
<p>What code do you need to add in PHP to automatically have the browser download a file to the local machine when a link is visited?</p>
<p>I am specifically thinking of functionality similar to that of download sites that prompt the user to save a file to disk once you click on the name of the software?</p>
|
<p>Send the following headers before outputting the file:</p>
<pre><code>header("Content-Disposition: attachment; filename=\"" . basename($File) . "\"");
header("Content-Type: application/octet-stream");
header("Content-Length: " . filesize($File));
header("Connection: close");
</code></pre>
<p><a href="https://stackoverflow.com/users/486/grom">@grom</a>: Interesting about the 'application/octet-stream' MIME type. I wasn't aware of that, have always just used 'application/force-download' :)</p>
|
<p>my code works for txt,doc,docx,pdf,ppt,pptx,jpg,png,zip extensions and I think its better to use the actual MIME types explicitly.</p>
<pre><code>$file_name = "a.txt";
// extracting the extension:
$ext = substr($file_name, strpos($file_name,'.')+1);
header('Content-disposition: attachment; filename='.$file_name);
if(strtolower($ext) == "txt")
{
header('Content-type: text/plain'); // works for txt only
}
else
{
header('Content-type: application/'.$ext); // works for all extensions except txt
}
readfile($decrypted_file_path);
</code></pre>
| 6,221
|
<p>In my specific example, I'm dealing with a drop-down, e.g.:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><select name="foo" id="bar">
<option disabled="disabled" selected="selected">Select an item:</option>
<option>an item</option>
<option>another item</option>
</select></code></pre>
</div>
</div>
</p>
<p>Of course, that's pretty nonsensical, but I'm wondering whether any strict behaviour is defined. Opera effectively rejects the 'selected' attribute and selects the next item in the list. All other browsers appear to allow it, and it remains selected.</p>
<p><strong>Update:</strong> To clarify, I'm specifically interested in the initial selection. I'm dealing with one of those 'Select an item:'-type drop-downs, in which case the first option is really a label, and an action occurs <code>onchange()</code>. This is <em>fairly</em> well 'progressively enhanced', in that a submit button is present, and only removed via JavaScript. If the "select..." option were removed, whatever then were to become the first item would not be selectable. Are we just ruling out <code>onchange</code> drop downs altogether, or should the "select..." option be selectable, just with no effect?</p>
|
<p>The HTML specs are a bit vague (ie. completely lacking) with regard to this odd combination. They do say that a form element with the disabled attribute set should not be successful, so it really <em>can't</em> be selected.</p>
<p>The browser may well render it so that it looks selected, but it shouldn't show up in the POSTed data. Looks like Opera's got it right to me.</p>
|
<blockquote>
<p>Are we just ruling out 'onchange' drop
downs altogether, or should the
"select..." option be selectable, just
with no effect?</p>
</blockquote>
<p>"onchange" drop-downs are frowned upon by more standards-obsessed types.</p>
<p>I would typically do some client-side validation. "Please select an item from the drop down" kind of thing. i.e.</p>
<blockquote>
<p>should the "select..." option be selectable, just with no effect?</p>
</blockquote>
<p>So I just said "Yes" to your A or B question. :/ Sorry!</p>
| 7,239
|
<ol>
<li>You have multiple network adapters.</li>
<li>Bind a UDP socket to an local port, without specifying an address.</li>
<li>Receive packets on one of the adapters.</li>
</ol>
<p>How do you get the local ip address of the adapter which received the packet?</p>
<p>The question is, "What is the ip address from the receiver adapter?" not the address from the sender which we get in the </p>
<pre><code>receive_from( ..., &senderAddr, ... );
</code></pre>
<p>call.</p>
|
<p>You could enumerate all the network adapters, get their IP addresses and compare the part covered by the subnet mask with the sender's address.</p>
<p>Like:</p>
<pre><code>IPAddress FindLocalIPAddressOfIncomingPacket( senderAddr )
{
foreach( adapter in EnumAllNetworkAdapters() )
{
adapterSubnet = adapter.subnetmask & adapter.ipaddress;
senderSubnet = adapter.subnetmask & senderAddr;
if( adapterSubnet == senderSubnet )
{
return adapter.ipaddress;
}
}
}
</code></pre>
|
<pre>
ssize_t
recvfrom(int socket, void *restrict buffer, size_t length, int flags,
struct sockaddr *restrict address, socklen_t *restrict address_len);
ssize_t
recvmsg(int socket, struct msghdr *message, int flags);
[..]
If address is not a null pointer and the socket is not connection-oriented, the
source address of the message is filled in.
</pre>
<p>Actual code:</p>
<p><code>
int nbytes = recvfrom(sock, buf, MAXBUFSIZE, MSG_WAITALL, (struct sockaddr *)&bindaddr, &addrlen);</p>
<p>fprintf(stdout, "Read %d bytes on local address %s\n", nbytes, inet_ntoa(bindaddr.sin_addr.s_addr));
</code></p>
<p>hope this helps.</p>
| 4,975
|
<p>I have seen some photos of aluminum based Prusa i3 printers, and I like to know the numbers and the specs of the profiles? Also I want to know Is the first pic strong enough for reliable printer or I must use the second(respect to profiles I mean).</p>
<p><a href="https://i.stack.imgur.com/JcgdB.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/JcgdB.jpg" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/qjfBM.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qjfBM.jpg" alt="enter image description here"></a></p>
|
<p>They are 2020 (20mm x 20mm) T-slot extrusions. They should not be confused with V-slot extrusions, which are similar to T-slot, but have a 45-degree slot profile to accommodate V-slot wheels.</p>
<p>If you are contemplating a new build, I would recommend using V-slot. Note that T-slot and V-slot come in a number of sizes (in multiples of 20mm). A 2040 profile is 20mm x 40mm, and will have two slots on the wider sides. Other sizes are available, such as 2060, 2080, 4040, and even C-shaped profiles.</p>
<p>You may want to use 2040 profiles for greater rigidity, especially if you are contemplating a large build volume.</p>
<p>Note that there are imperial as well as metric T-slot profiles. RepRap uses metric profiles.</p>
<p><a href="http://reprap.org/wiki/T-Slot" rel="nofollow noreferrer">ReRap Wiki: T-slot</a></p>
<p><a href="http://openbuildspartstore.com/linear-rail/" rel="nofollow noreferrer">OpenBuilds: V-slot</a></p>
|
<p>It can really depend on where you are in the world. A few years ago, I was unable to obtain standard V-slot (& T-nut) 2020 extrusion, at a reasonable price, and so I ended up using an extrusion from a local supplier instead, and managed to obtain 6 m of extrusion for only $15!</p>
<p>My aluminium extrusion has this profile, which has V-Slot style grooves. </p>
<p><a href="https://i.stack.imgur.com/Vzce3.jpg" rel="nofollow noreferrer" title="2020 Aluminium Extrusion BKK#2"><img src="https://i.stack.imgur.com/Vzce3.jpg" alt="2020 Aluminium Extrusion BKK#2" title="2020 Aluminium Extrusion BKK#2"></a></p>
<p>Also, it uses simple, and <em>cheap</em>, M5 nuts, rather than T-nuts, which are much more expensive (comparatively)</p>
<p>Please see <a href="https://engineering.stackexchange.com/questions/13471/will-standard-m5-t-slot-nuts-fit-these-different-2020-aluminium-extrusions">Will standard M5 T-slot nuts fit these different 2020 aluminium extrusions?</a>, for more information.</p>
<p>You can also use 1515, depending on the size of the printer... if you have a larger printer design then you can always double up and use two adjacent lengths of 1515 to effectively have 3015 (or 2040 - if using two pieces of 2020). Basically use whatever is available and cheap, it isn't necessary to pay a lot of money, just to have the perfect extrusion profile. Remember that you are designing/building the printer yourself, so you will have some leeway. Other sizes that may be available to use are 2525, 2040, 3030, 3060, etc.. </p>
<p>However, if you are using 3D printed parts for the frame (such as the end or corner pieces), then you may be restricted in what type of extrusion that you can use, by the printed parts themselves and what type of extrusion they will fit. However, if you are only using aluminium parts for the frame (including aluminium corner brackets/braces) then you <em>should be</em> OK.</p>
| 750
|
<p>How do you resolve a domain name to an IP address with .NET/C#?</p>
|
<pre><code>using System.Net;
foreach (IPAddress address in Dns.GetHostAddresses("www.google.com"))
{
Console.WriteLine(address.ToString());
}
</code></pre>
|
<p>Try using the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.net.dns" rel="nofollow noreferrer">System.Net.Dns</a> class</p>
| 2,679
|
<p>Am looking for a regression test framework where I can add tests to.. Tests could be any sort of binaries that poke an application..</p>
|
<p>This really depends on what you're trying to do, but one of the features of the new <a href="http://search.cpan.org/dist/Test-Harness/" rel="nofollow noreferrer">Test::Harness</a> (disclaimer: I'm the original author and still a core developer) is that if your tests output TAP (the Test Anything Protocol), you can use Test::Harness to run test suites written in multiple languages. As a result, you don't have to worry about getting "locked in" to a particular language because that's all your testing software supports. In one of my talks on the subject, I even give an example of a test suite written in Perl, C, Ruby, and HTML (yes, HTML -- you'd have to see it).</p>
|
<p>You did not indicate what language you are working in, but the xUnit family is available for a lot of different languages.</p>
<p>/Allan</p>
| 9,505
|
<p>I am using Cura for slicing, and OctoPrint for the actual printing.</p>
<p>On small pieces with roughly one square cm of surface area prints over about 6 mm have a risk of coming off at 60 °C.</p>
<p>In fact, I have had to use 71 °C so it stick properly. However, I don't want the print bed that hot all the time. I would like to try a different number of layers at different bed temperatures till I get it right.</p>
<p>Gradually, over the course of 1-3 mm, for the bed temperature to decrease back to 60 °C to save on electricity. Possibly even 50 °C as the layers get higher.</p>
<p>Cura only support the initial layer having a different temperature and that isn't enough.</p>
<p>Apparently you can have custom user events with <a href="https://docs.octoprint.org/en/latest/events/index.html" rel="nofollow noreferrer">OctoPrint</a>, one of them being <strong>ZChange</strong> which is great.</p>
<pre><code>{__currentZ}: the current Z position of the head if known, -1 if not available
</code></pre>
<p>I need on the ZChange event to check the <code>__currentZ</code> and execute an<code>M140</code> with a temperature varying with layer height. Normally I would use a simple <code>if</code> command or etc., but how do I implement this here.</p>
<p>However, its seems you can execute a command or a G-code.</p>
<p>I can't seem to find any examples where I can test the Z height in layers or mm and execute a different temperature for different layers.</p>
<p>An additional problem is the increased temps cause the model to melt so that the opening is smaller nearest to the glass than most of the rest of the model.</p>
<p>I am height of the raft, which helps, but I am hoping for a compromise. </p>
<p>The print bed shouldn't need to be 70 °C for the whole vertical height of the model.</p>
<p>Any suggestions?</p>
|
<p><strong>The actual problem you are facing is bed adhesion</strong>, the proposed solution (in your question) shouldn't be the preferred solution to get your parts to stick to the plate/glass as plastic shrinks as it cools down. Note that a 5 °C temperature drop after the first layer usually isn't a problem, but larger temperature differences or shutting off the heat completely will cause your parts to come off the glass.</p>
<p>Note that PLA requires a temperature of about 60 °C (for adhesion as this is close to the glass temperature where the plastic is soft; however, note that PLA can be printed on cold bed surfaces on suitable bed surfaces). The slate of glass is an insulator, so it is perfectly possible that you need to set the bed at a higher temperature to get 60 °C at the surface of the glass plate. When the lower layer deforms the bed temperature is too high.</p>
<p>As you are using Cura, there is a plugin available called TweakAtZ, nowadays this is a default plugin. How to use this is described in <a href="/a/7346/">this anser</a> (on question <a href="/q/7345">"How does one use a heat tower?"</a>); instead of changing the hotend temperature you will need to modify the bed temperature instead (using <code>M140</code>).</p>
<p><strong>To solve the actual problem</strong>, you need to prepare the glass by cleaning it properly, use a level bed with a correct initial nozzle to bed distance for <code>Z=0</code> (usually thickness of a plain paper sheet A4/Letter) and an adhesive like hairspray, glue stick or a dedicated adhesion spray like 3DLAC or Dimafix. I'm using 3DLAC for several years (for PLA and PETG; Dimafix is supposed to be more sticky at higher temperatures, so for ABS for instance) and never had any problems with adhesion on properly levelled beds. See <a href="/a/4045">this answer</a> for another user's experience.</p>
<p>An OctoPrint solution using event as you suggest is not recommended. This is the config.yaml, e.i. the configuration of the print server, not a print instance option file. Furthermore, there are yet no plugins that can handle additional code when the head reaches a certain (layer)height. This is pretty tricky if you use Z position detection when the head also can hop, such code should be inserted by the slicer instead.</p>
<hr>
<p><em>Related to your question are the answers on question: <a href="/q/10683">"Why keep the bed heated after initial layer(s) with PLA (or PETG)?"</a>.</em></p>
|
<ul>
<li>You can manually edit the file. Look for the line that has the Z height of your choice, and insert the temp change g-code right above it.</li>
<li>Upgrade to a real slicer like Simplify3D with has an options to set a heater temp at different layers.</li>
<li>Preheat the bed before you print, then print with a bed temp set lower than the temp you preheated at. This will give the illusion of a temp change.</li>
</ul>
<p><em>(I for one turn off my bed after the first layer, when I'm printing PLA. I also don't have proper cooling (at this time), my environment is humid (59.9%) and the ambient air temp is 31C.) - just for context</em></p>
| 1,549
|
<p>We've been developing a windows based application using Java for a while now, but NOW we want to make a mac port and have to reverse of code from Java 6 and Java 5. Is there any easy way to do this rather than re-coding Java 6 specific code? We'd like to keep our code up to date.</p>
|
<p>Apple released Java 6 on the latest version of OS X. What features are you using specifically from Java6 that aren't in java5? </p>
|
<p>You might be able to backport the additional libraries from Java 6 to Java 5, but I imagine it would be rather more trouble that it's worth. Intel Macs with 64-bit processors (so not the original Intel Mac Mini) running Leopard have Java 6, so perhaps you could just target them?</p>
| 3,862
|
<p>Suppose that I have a form that contains three 10 fields: field1..field10. I store the form data in one or more database tables, probably using 10 database columns. </p>
<p>Now suppose a few months later that I want to add 3 more fields. And in the future I may add/delete fields from this form based on changing requirements. If I have a database column per form field, then I would have to make the corresponding changes to the database each time I change the form. This seems like a maintenance headache. There must be a more sophisticated way.</p>
<p>So my question is, how do I design a data model that is loosely coupled with my UI? A concrete use case is a CRM system that is extensible/customizable by users. </p>
|
<p>You could abstract fields to a separate table so that they are many-to-many to the Form table:</p>
<h2>Form</h2>
<p><strong>ID</strong><br/>
Name<br/>
etc.</p>
<h2>Field</h2>
<p><strong>ID</strong><br/>
Label<br/>
Value</p>
<h2>FormField</h2>
<p><strong>FormID</strong><br/>
<strong>FieldID</strong></p>
|
<p>My team came up with a solution for this when I worked for Quest Computing on AIMS (www.totalaims.com). In summary we added maintenance screens that allowed the administrator to add metadata and also as a result add fields to the database in certain tables. The fields were also added to their own maintenance and search screens automatically. We built this on top of the OpenACS. You can find out more at www.openacs.org - search for "flexbase" or "dynfields" or look here www.project-open.org/doc/intranet-dynfield/ . This worked quite well - them main downside being a side effect of the main upside i.e. that addition of fields could be done by non-DBAs and as a result performance could easily be compromised. </p>
| 5,214
|
<p>When modelling for 3D printing, can I distinguish somehow the type of infill in various areas of the model? Say there may be some areas in the model where I want 100% infill (maximum strength) but some areas where the infill can be less (maybe 25%).</p>
<p>I am new to 3D printing, doing my first model (enclosure for electronics - camera module). Using tinkercad.com only so far. Places where 100% infill is wanted are usually walls of the case and "threads" for the bolts but I want to make the enclosure as stiff as possible as a whole so I am thinking about using some sparse infill in the "free space" inside of the enclosure (so that it does not break so easily when it falls to the ground etc). I just do not know how to define this within the model.</p>
|
<p>To achieve additional localised stiffness, you can also insert small voids (gaps) inside the model. These become double thickness walls once sliced and can be used to support things like screw holes.</p>
<p>See the 'negative' parts used with a cube, and the sliced result here:
<a href="https://i.stack.imgur.com/eULwV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eULwV.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/z7uzX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z7uzX.png" alt="enter image description here"></a></p>
|
<p>I found out I misunderstood some principles of designing/modelling for 3D printing.</p>
<p>I designed my object for 100% infill which is not really necessary. It turned out that one does not mostly have to take care of the infill % and just model the object for example as solid 3D cube and the printing service will then take care of it to print well, hopefully slicing it well for printing and choosing the correct infill percentage.</p>
<p>So instead of designing a "hollow" cube with 3mm thick walls filled with 100% infill and free space inside, one can design a solid cube and the printing service will then print it "somehow" - they may make the walls only 1 mm thick but fill the inside of the cube with 10% infill which may work just fine for final object stiffness etc.</p>
| 1,050
|
<p>I've got an interesting design question. I'm designing the security side of our project, to allow us to have different versions of the program for different costs and also to allow Manager-type users to grant or deny access to parts of the program to other users. Its going to web-based and hosted on our servers.</p>
<p>I'm using a simple Allow or Deny option for each 'Resource' or screen.</p>
<p>We're going to have a large number of resources, and the user will be able to set up many different groups to put users in to control access. Each user can only belong to a single group.</p>
<p>I've got two approaches to this in mind, and was curious which would be better for the SQL server in terms of performance.</p>
<p><strong>Option A</strong>
The presence of an entry in the access table means access is allowed. This will not need a column in the database to store information. If no results are returned, then access is denied.</p>
<p>I think this will mean a smaller table, but would queries search the whole table to determine there is no match?</p>
<p><strong>Option B</strong>
A bit column is included in the database that controls the Allow/Deny. This will mean there is always a result to be found, and makes for a larger table.</p>
<p>Thoughts?</p>
|
<p>If it's only going to be Allow/Deny, then a simple linking table between Users and Resources would work fine. If there is an entry keyed to the User-Resource in the linking table, allow access.</p>
<pre><code>UserResources
-------------
UserId FK->Users
ResourceId FK->Resources
</code></pre>
<p>and the sql would be something like </p>
<pre><code>if exists (select 1 from UserResources
where UserId = @uid and ResourceId=@rid)
set @allow=1;
</code></pre>
<p>With a clustered index on (UserId and ResourceId), the query would be blindingly fast even with millions of records.</p>
|
<p>B. It allows for much better checks whether the data is complete (for example, when you add an allowable/deniable feature).</p>
<p>Also, table size should only be a consideration for tables that you know will contain many records (as in, 100,000+). You even taking the time to type the table size consideration into this question already cost more than the extra hard drive space it would take.</p>
| 4,338
|
<p>I'm going to be implementing a <code>PHP/mySQL</code> setup to store credit card information.</p>
<p>It seems like <code>AES_ENCRYPT/AES_DECRYPT</code> is the way to go,</p>
<p><strong>but I'm still confused on one point:</strong></p>
<p><strong>How do I keep the encryption key secure?</strong></p>
<p>Hardwiring it into my PHP scripts (which will live on the same server as the db) seems like a major security hole.</p>
<p><strong>What's the "best practice" solution here?</strong></p>
|
<p>You should think long and hard about whether you REALLY need to keep the CC#. If you don't have a great reason, DON'T! Every other week you hear about some company being compromised and CC#'s being stolen. All these companies made a fatal flaw - they kept too much information. Keep the CC# until the transaction clears. After that, delete it.</p>
<p>As far as securing the server, the best course of action is to secure the hardware and use the internal system socket to MySQL, and make sure to block any network access to the MySQL server. Make sure you're using both your system permissions and the MySQL permissions to allow as little access as needed. For some scripts, you might consider write-only authentication. There's really no encryption method that will be foolproof (as you will always need to decrypt, and thus must store the key). This is not to say you shouldn't - you can store your key in one location and if you detect system compromise you can destroy the file and render the data useless.</p>
|
<p>I agree, but don't the cc if you don't need too. But if you really have too, make sure the file that have it is not accessible on the web. You can write a binary that would return the key. This way it's not store in clear text. But if your server is compromise it's still easy to get it. </p>
| 7,947
|
<p>I'm trying to figure out how to detect the type of credit card based purely on its number. Does anyone know of a definitive, reliable way to find this?</p>
|
<p>The credit/debit card number is referred to as a <strong>PAN</strong>, or <em>Primary Account Number</em>. The first six digits of the PAN are taken from the <strong>IIN</strong>, or <em>Issuer Identification Number</em>, belonging to the issuing bank (IINs were previously known as BIN — Bank Identification Numbers — so you may see references to that terminology in some documents). These six digits are subject to an international standard, <a href="http://en.wikipedia.org/wiki/ISO/IEC_7812" rel="noreferrer">ISO/IEC 7812</a>, and can be used to determine the type of card from the number.</p>
<p>Unfortunately the actual ISO/IEC 7812 database is not publicly available, however, there are unofficial lists, both commercial and free, including <a href="http://en.wikipedia.org/wiki/Bank_card_number" rel="noreferrer">on Wikipedia</a>.</p>
<p>Anyway, to detect the type from the number, you can use a regular expression like the ones below: <a href="http://www.regular-expressions.info/creditcard.html" rel="noreferrer">Credit for original expressions</a></p>
<p><strong>Visa:</strong> <code>^4[0-9]{6,}$</code> Visa card numbers start with a 4.</p>
<p><strong>MasterCard:</strong> <code>^5[1-5][0-9]{5,}|222[1-9][0-9]{3,}|22[3-9][0-9]{4,}|2[3-6][0-9]{5,}|27[01][0-9]{4,}|2720[0-9]{3,}$</code> Before 2016, MasterCard numbers start with the numbers 51 through 55, <strong>but this will only detect MasterCard credit cards</strong>; there are other cards issued using the MasterCard system that do not fall into this IIN range. In 2016, they will add numbers in the range (222100-272099).</p>
<p><strong>American Express:</strong> <code>^3[47][0-9]{5,}$</code> American Express card numbers start with 34 or 37.</p>
<p><strong>Diners Club:</strong> <code>^3(?:0[0-5]|[68][0-9])[0-9]{4,}$</code> Diners Club card numbers begin with 300 through 305, 36 or 38. There are Diners Club cards that begin with 5 and have 16 digits. These are a joint venture between Diners Club and MasterCard and should be processed like a MasterCard.</p>
<p><strong>Discover:</strong> <code>^6(?:011|5[0-9]{2})[0-9]{3,}$</code> Discover card numbers begin with 6011 or 65.</p>
<p><strong>JCB:</strong> <code>^(?:2131|1800|35[0-9]{3})[0-9]{3,}$</code> JCB cards begin with 2131, 1800 or 35.</p>
<p>Unfortunately, there are a number of card types processed with the MasterCard system that do not live in MasterCard’s IIN range (numbers starting 51...55); the most important case is that of Maestro cards, many of which have been issued from other banks’ IIN ranges and so are located all over the number space. As a result, <strong>it may be best to assume that any card that is not of some other type you accept must be a MasterCard</strong>.</p>
<p><strong>Important</strong>: card numbers do vary in length; for instance, Visa has in the past issued cards with 13 digit PANs and cards with 16 digit PANs. Visa’s documentation currently indicates that it may issue or may have issued numbers with between 12 and 19 digits. <strong>Therefore, you should not check the length of the card number, other than to verify that it has at least 7 digits</strong> (for a complete IIN plus one check digit, which should match the value predicted by <a href="http://en.wikipedia.org/wiki/Luhn_algorithm" rel="noreferrer">the Luhn algorithm</a>).</p>
<p>One further hint: <strong>before processing a cardholder PAN, strip any whitespace and punctuation characters from the input</strong>. Why? Because it’s typically <em>much</em> easier to enter the digits in groups, similar to how they’re displayed on the front of an actual credit card, i.e.</p>
<pre><code>4444 4444 4444 4444
</code></pre>
<p>is much easier to enter correctly than</p>
<pre><code>4444444444444444
</code></pre>
<p>There’s really no benefit in chastising the user because they’ve entered characters you don't expect here.</p>
<p><strong>This also implies making sure that your entry fields have room for <em>at least</em> 24 characters, otherwise users who enter spaces will run out of room.</strong> I’d recommend that you make the field wide enough to display 32 characters and allow up to 64; that gives plenty of headroom for expansion.</p>
<p>Here's an image that gives a little more insight:</p>
<p><strong>UPDATE (2016):</strong> Mastercard is to implement new BIN ranges starting <a href="http://achpayment.net/" rel="noreferrer">Ach Payment</a>.</p>
<p><img src="https://i.stack.imgur.com/Cu7PG.jpg" alt="Credit Card Verification" /></p>
|
<p>The regular expression rules that match the <a href="http://www.techrecite.com/credit-card-validation-regex-script-in-php-using-luhn-algorithm/" rel="nofollow">respective card vendors</a>:</p>
<ul>
<li><code>(4\d{12}(?:\d{3})?)</code> for VISA.</li>
<li><code>(5[1-5]\d{14})</code> for MasterCard.</li>
<li><code>(3[47]\d{13})</code> for AMEX.</li>
<li><code>((?:5020|5038|6304|6579|6761)\d{12}(?:\d\d)?)</code> for Maestro.</li>
<li><code>(3(?:0[0-5]|[68][0-9])[0-9]{11})</code> for Diners Club.</li>
<li><code>(6(?:011|5[0-9]{2})[0-9]{12})</code> for Discover.</li>
<li><code>(35[2-8][89]\d\d\d{10})</code> for JCB.</li>
</ul>
| 9,836
|
<p>I have a 3018 Pro CNC and being trying cutting a contour of a simple circular part:</p>
<p><a href="https://i.stack.imgur.com/w3mDe.png" rel="nofollow noreferrer" title="Screenshot of Fusion 360 model and route"><img src="https://i.stack.imgur.com/w3mDe.png" alt="Screenshot of Fusion 360 model and route" title="Screenshot of Fusion 360 model and route" /></a></p>
<p>G-code:</p>
<pre><code>(TestKnobContour)
(T1 D=1 CR=0 - ZMIN=-3 - flat end mill)
G90 G94
G17
G21
G90
(2D Contour1)
Z15
S5000 M3
G54
G0 X10.8 Y0.1
Z15
G1 Z5 F10.0
Z1 F10.0
Z-2.9
X10.792 Z-2.938 F10.0
X10.771 Z-2.971
X10.738 Z-2.992
X10.7 Z-3
X10.6
X10.562 Y0.092
X10.529 Y0.071
X10.508 Y0.038
X10.5 Y0
G2 X9.851 Y-3.634 I-10.5 J0
G1 Z-2.75
G2 X8.983 Y-5.436 I-9.851 J3.634
G1 Z-3 F10.0
G2 X3.301 Y-9.968 I-8.983 J5.436 F10.0
G1 Z-2.75
G2 X1.351 Y-10.413 I-3.301 J9.968
G1 Z-3 F10.0
G2 X-5.735 Y-8.795 I-1.351 J10.413 F10.0
G1 Z-2.75
G2 X-7.299 Y-7.548 I5.735 J8.795
G1 Z-3 F10.0
G2 X-10.452 Y-1 I7.299 J7.548 F10.0
G1 Z-2.75
G2 X-10.452 Y1 I10.452 J1
G1 Z-3 F10.0
G2 X-7.299 Y7.548 I10.452 J-1 F10.0
G1 Z-2.75
G2 X-5.735 Y8.795 I7.299 J-7.548
G1 Z-3 F10.0
G2 X1.351 Y10.413 I5.735 J-8.795 F10.0
G1 Z-2.75
G2 X3.301 Y9.968 I-1.351 J-10.413
G1 Z-3 F10.0
G2 X8.983 Y5.436 I-3.301 J-9.968 F10.0
G1 Z-2.75
G2 X9.851 Y3.634 I-8.983 J-5.436
G1 Z-3 F10.0
G2 X10.5 Y0 I-9.851 J-3.634 F10.0
G1 X10.508 Y-0.038
X10.529 Y-0.071
X10.562 Y-0.092
X10.6 Y-0.1
X10.7
X10.738 Z-2.992
X10.771 Z-2.971
X10.792 Z-2.938
X10.8 Z-2.9
G0 Z15
M5
X0 Y0 Z0
M30
</code></pre>
<p>Candle shows that everything is fine for this G-code:</p>
<p><a href="https://i.stack.imgur.com/jZ4p3.png" rel="nofollow noreferrer" title="Screenshot of Candle software"><img src="https://i.stack.imgur.com/jZ4p3.png" alt="Screenshot of Candle software" title="Screenshot of Candle software" /></a></p>
<p>However, I am getting weird results (see top right):</p>
<p><a href="https://i.stack.imgur.com/76m5S.jpg" rel="nofollow noreferrer" title="Photo of milled circles with irregularities"><img src="https://i.stack.imgur.com/76m5S.jpg" alt="Photo of milled circles with irregularities" title="Photo of milled circles with irregularities" /></a></p>
<p>What can I do for troubleshooting?</p>
|
<p>I've ran the code on my own CNC machine. I slightly adapted the code as my machine doesn't understand the movement without the instruction code:</p>
<pre><code>Z1 F10.0
Z-2.9
X10.792 Z-2.938 F10.0
X10.771 Z-2.971
X10.738 Z-2.992
X10.7 Z-3
X10.6
X10.562 Y0.092
X10.529 Y0.071
X10.508 Y0.038
X10.5 Y0
</code></pre>
<p>is changed to</p>
<pre><code>G1 Z1 F10.0
G1 Z-2.9
G1 X10.792 Z-2.938 F10.0
G1 X10.771 Z-2.971
G1 X10.738 Z-2.992
G1 X10.7 Z-3
G1 X10.6
G1 X10.562 Y0.092
G1 X10.529 Y0.071
G1 X10.508 Y0.038
G1 X10.5 Y0
etc...
</code></pre>
<p>As I used an engraver bit, I made sure the depth was touching the wood (engraving) when running at the lowest depth. The contour it drew was a perfect circle.</p>
<p><a href="https://i.stack.imgur.com/aYvdw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aYvdw.jpg" alt="enter image description here" /></a></p>
<p>The code is therefor working as it should (carve a circle, in the photo above, the circle started at the hole in the top left and followed a clockwise path), the result from your milling exercise shows that the final segment of the circle is not giving you a circle segment, instead the milling path is sort of straight. I've seen such paths where the steppers are not powerful enough to mill through the material. As a result they skip steps, and in this case it results in a sort of straight path. You should try running a dry run (in air), or in softer material (this will determine if the code is producing a cirlce in your machine as well), and add more passes to milling the knob (for the final product).</p>
|
<p>Parts of the circle are at different heights. When I rendered your 30 or so actual G1 and G2 lines, here's what I got. It looks like a circle from above, but form the sde you can see depth changes. What are those coordinate lines with no G0 ot G1 or G2 or G3 command for?</p>
<p><a href="https://i.stack.imgur.com/fbVWo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fbVWo.png" alt="Top view" /></a></p>
<p><a href="https://i.stack.imgur.com/EctYT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EctYT.png" alt="Angled view" /></a></p>
<p>=============================</p>
<p>Okay, here's a simple gcode I just made by hand do to something similar. Granted, I used all nice round numbers, but this is an example of what I think you're looking for. You'll have to change it as needed; perhaps more paths if your tool is less wide; more iterations at deeper depths, or even different coordinates. Enjoy.</p>
<p><a href="https://i.stack.imgur.com/ZT0gD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZT0gD.png" alt="Screenshot of Rendering and Gcode" /></a></p>
<pre><code>G0 X30 Y30 ; move to start XY
M3 T12 S50 ; spindle on 50%
G1 Z-0.5 E1 ; down to depth1
G2 X50 Y50 J20.0 E1 ; arc
G1 X30 Y30 E1 ; corner
G1 X30 Y35 E1 ; move inward
G2 X45 Y50 J15 E1 ; arc
G1 X30 Y35 E1 ; corner
G1 X30 Y40 E1 ; move inward
G2 X40 Y50 J10 E1 ; arc
G1 X30 Y40 ; corner
G1 X30 Y45 ; move inward
G2 X35 Y50 J5 E1 ; arc
G1 X30 Y45 E1 ; corner
G1 X30 Y50 E1 ; move inward
G0 Z 10 ; move up to clear
M3 T12 S0 ; spindle off
</code></pre>
<p>=================================</p>
<p>Or, if I've made a mistake and you want simple circles:</p>
<p><a href="https://i.stack.imgur.com/pPuvg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pPuvg.png" alt="Screenshot of circles rendered and gcode" /></a></p>
<pre><code>G0 X30 Y30 ; move to start XY
M3 T12 S50 ; spindle on 50%
G1 Z-0.5 E1 ; down to depth1
G2 X30 Y30 J20.0 E1 ; arc
G1 X30 Y35 E1 ; move inward
G2 X30 Y35 J15 E1 ; arc
G1 X30 Y40 E1 ; move inward
G2 X30 Y40 J10 E1 ; arc
G1 X30 Y45 ; move inward
G2 X30 Y45 J5 E1 ; arc
G1 X30 Y50 E1 ; move inward
G0 Z 10 ; move up to clear
M3 T12 S0 ; spindle off
</code></pre>
| 2,081
|
<p>How can I vary the infill percentage for different layer heights of my model?</p>
<p>Context: The bottom part of my model needs about 20% infill. The geometry of the top part of the model (mostly cones of various sizes) prints well with 0% infill and is of course a lot faster to print if I can specify this.</p>
|
<p><em>Your question is very similar to <a href="https://3dprinting.stackexchange.com/questions/6522/different-infill-in-the-same-part">Different infill in the same part</a> and <a href="https://3dprinting.stackexchange.com/questions/7019/using-multiple-infill-types-within-one-model">Using multiple infill types within one model [duplicate]</a>. The difference is that you specifically ask for Slic3r and a variation in layer height infill percentage.</em></p>
<hr>
<p>Actually <a href="https://3dprinting.stackexchange.com/a/6523/5740">this answer</a> describes using "helper volumes" in Ultimaker Cura to set different properties for certain parts of the model <em>(<strong>UPDATE</strong>: that answer now includes also Slic3r instructions)</em>, but it appears that this answer is very much applicable to Slic3r also. Please read <a href="http://slic3r.org/blog/modifier-meshes" rel="nofollow noreferrer">this</a> posting. Quoting from the reference:</p>
<blockquote>
<p>Finally, I fired Slic3r up and loaded the main part, then clicked on
Settings... and then hit Load modifier... I loaded the new volume as a
modifier mesh and I applied 100% solid infill...
<br></p>
</blockquote>
<p>Secondly, <a href="https://3dprinting.stackexchange.com/a/6527/5740">this</a> answer where 2 different infill percentage sliced models are manually combined at a certain height may also work for you (this is a perfect valid solution for Slic3r, but requires some editing skills).</p>
<p>Basically, although you request for a solution for a slicer other than already described in other questions, boils down to a similar answer, the only difference is the implementation in Slic3r is called differently. </p>
<hr>
<p>To do this in <strong>Slic3r</strong> see <a href="http://manual.slic3r.org/advanced/modifier-mesh" rel="nofollow noreferrer">this reference</a>.</p>
<p>The blog describes the use of a simple volume (the green volume loaded from an STL file). After loading:</p>
<blockquote>
<p>Right-clicking on the main part brought up the object settings menu.
From there, clicking "Load Modifier" and selecting the previously
saved model adds it to the part as a modifier.</p>
<p>The green "+" was selected and "Fill Density" was added to modifier
list and set to 100%.</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/llvIG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/llvIG.jpg" alt="Part with box for alternative mesh infill"></a></p>
<p><a href="https://i.stack.imgur.com/EslBH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EslBH.jpg" alt="enter image description here"></a>
This shows that the functionality in Slic3r is very similar to the functionality in Ultimaker Cura.</p>
|
<p>Let's assume the model is 75mm high; the bottom portion (which needs 20% infill) is 40mm, and the top portion (which needs 0% infill) is 35mm.</p>
<ul>
<li>Load your model into Slic3r.</li>
<li>Be sure your default fill is 20%.</li>
<li>Right click on the model, and select Settings.</li>
<li>Click "Load Generic".</li>
<li>Select Slab. This represents a cube which is the same X,Y dimensions of your model.</li>
<li>Specify H=35 (the height of the slab) and Initial Z=40 (where the base of slab starts).</li>
<li>This creates a new part for your object. Select it and click "+" to add a new setting.</li>
<li>Select Infill/Fill Density and set it to 0%.</li>
</ul>
<p>As a result of this, the bottom part of your model (which is not enclosed in the slab) will print at the default fill setting of 20%, and the top part of your model (which is enclosed in the slab) will print with 0% fill.</p>
<p>You can verify this by slicing and looking at the preview. You will see the base with your default infill, and the top with no infill. The slic3r docs mentions several other ways to <a href="http://manual.slic3r.org/advanced/modifier-mesh" rel="nofollow noreferrer">customize parameters</a> for your model.</p>
| 1,051
|
<p>I'm trying to use Groovy to create an interactive scripting / macro mode for my application. The application is OSGi and much of the information the scripts may need is not know up front. I figured I could use GroovyShell and call eval() multiple times continually appending to the namespace as OSGi bundles are loaded. GroovyShell maintains variable state over multiple eval calls, but not class definitions or methods.</p>
<p>goal: Create a base class during startup. As OSGi bundles load, create derived classes as needed. </p>
|
<p>I am not sure about what you mean about declared classes not existing between evals, the following two scripts work as expected when evaled one after another:</p>
<pre><code>class C {{println 'hi'}}
new C()
</code></pre>
<p>... </p>
<pre><code>new C()
</code></pre>
<p>However methods become bound to the class that declared them, and GroovyShell creates a new class for each instance. If you do not need the return value of any of the scripts and they are truly scripts (not classes with main methods) you can attach the following to the end of every evaluated scrips.</p>
<pre><code>Class klass = this.getClass()
this.getMetaClass().getMethods().each {
if (it.declaringClass.cachedClass == klass) {
binding[it.name] = this.&"$it.name"
}
}
</code></pre>
<p>If you depend on the return value you can hand-manage the evaluation and run the script as part of your parsing (warning, untested code follows, for illustrative uses only)...</p>
<pre><code>String scriptText = ...
Script script = shell.parse(scriptText)
def returnValue = script.run()
Class klass = script.getClass()
script.getMetaClass().getMethods().each {
if (it.declaringClass.cachedClass == klass) {
shell.context[it.name] = this.&"$it.name"
}
}
// do whatever with returnValue...
</code></pre>
<p>There is one last caveat I am sure you are aware of. Statically typed variables are not kept between evals as they are not stored in the binding. So in the previous script the variable 'klass' will not be kept between script invocations and will disappear. To rectify that simply remove the type declarations on the first use of all variables, that means they will be read and written to the binding.</p>
|
<p>This might be what you are looking for?</p>
<p>From <a href="https://rads.stackoverflow.com/amzn/click/com/1932394842" rel="nofollow noreferrer" rel="nofollow noreferrer">Groovy in Action</a></p>
<pre><code>def binding = new Binding(x: 6, y: 4)
def shell = new GroovyShell(binding)
def expression = '''f = x * y'''
shell.evaluate(expression)
assert binding.getVariable("f") == 24
</code></pre>
<p>An appropriate use of Binding will allow you to maintain state?</p>
| 6,751
|
<p>I have an absolutely positioned <code>div</code> that I want to show when the user clicks a link. The <code>onclick</code> of the link calls a js function that sets the display of the div to block (also tried: "", <code>inline</code>, <code>table-cell</code>, <code>inline-table</code>, etc). This works great in IE7, not at all in every other browser I've tried (FF2, FF3, Opera 9.5, Safari).</p>
<p>I've tried adding alerts before and after the call, and they show that the display has changed from <code>none</code> to <code>block</code> but the <code>div</code> does not display.</p>
<p>I can get the <code>div</code> to display in FF3 if I change the display value using Firebug's HTML inspector (but not by running javascript through Firebug's console) - so I know it's not just showing up off-screen, etc.</p>
<p>I've tried everything I can think of, including:</p>
<ul>
<li>Using a different doctype (XHTML 1, HTML 4, etc)</li>
<li>Using visibility visible/hidden instead of display block/none</li>
<li>Using inline javascript instead of a function call</li>
<li>Testing from different machines</li>
</ul>
<p>Any ideas about what could cause this?</p>
|
<p>Since setting the properties with javascript never seemed to work, but setting using Firebug's inspect did, I started to suspect that the javascript ID selector was broken - maybe there were multiple items in the DOM with the same ID? The source didn't show that there were, but looping through all divs using javascript I found that that was the case. Here's the function I ended up using to show the popup:</p>
<pre><code>function openPopup(popupID)
{
var divs = getObjectsByTagAndClass('div','popupDiv');
if (divs != undefined && divs != null)
{
for (var i = 0; i < divs.length; i++)
{
if (divs[i].id == popupID)
divs[i].style.display = 'block';
}
}
}
</code></pre>
<p>(utility function getObjectsByTagAndClass not listed)</p>
<p>Ideally I'll find out why the same item is being inserted multiple times, but I don't have control over the rendering platform, just its inputs.</p>
<p>So when debugging issues like this, <strong>remember to check for duplicate IDs in the DOM, which can break getElementById</strong>.</p>
<p>To everyone who answered, thanks for your help!</p>
|
<p>There is an annoying display error on Firefox 3.5 but not on IE7 or Firefox 2.0.9</p>
<p>I have 3 DIV's position absolute - the first with plain text; the second with a CSS menu (sucklefish type with UL and LI) and the third ditto. The third will not display at all even though the coding has been checked and found to be perfect with W3C's HTML validator.</p>
<p>As a temporary measure, I have merged the second and third DIV's contents.</p>
<p>Things must be bad at Mozilla when IE7 and FF2 display OK but not FF 3.5</p>
| 3,159
|
<p>I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be able to display foreign key lookups in a databound DataGridView. </p>
<p>An example of the sort of relationship is that I have a table of OrderLines. Orderlines have a foreign key relationship to Products and Products in turn have a foreign key relationship to ProductTypes. </p>
<p>I'd like to have a databound DataGridView where each row represents an orderline, displaying the line's product and producttype.</p>
<p>Users can add or edit orderlines direct to the grid and choose the product for the order line from a comboBoxColumn - this should then update the producttype column, showing the producttype for the selected product, in the same row.</p>
<p>The closest to a good fit that I've found so far is to introduce a domain object representing an orderline then bind the DataGridView to a collection of these orderlines. I then add properties to the orderline object that expose the product and the producttype, and raise relevant notifypropertychanged events to keep everything up to date. In my orderline repository I can then wire up the mappings between this orderline object and the three tables in my database.</p>
<p>This works for the databinding side of things, but having to hand code all that OR-mapping in the repository seems bad. I thought nHibernate would be able to help with this wiring up but am struggling with the mappings through all the foreign keys - they seem to work ok (the foreignkey lookup for an orderline's product creates the correct product object based on the foreign key) until I try to do the databinding, I can't get the databound id columns to update my product or producttype objects.</p>
<p>Is my general approach even in the right ballpark? If it is, what is a good solution to the mapping problem?</p>
<p>Or, is there a better solution to databinding rows including foreign key lookups that I haven't even considered?</p>
|
<p>I think the problem you're having is that when you are binding to a grid, it is not enough to support INotifyPropertyChanged, but you have to fire the ListChanged events in your <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.ibindinglist.aspx" rel="nofollow noreferrer">IBindingList</a> implementation and make sure that you override and return true for the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.ibindinglist.supportschangenotification.aspx" rel="nofollow noreferrer">SupportsChangeNotification</a> property. If you don't return true for this, the grid won't look for it to know if the data has changed.</p>
<p>In .NET 2.0+, you can create a generic collection using the <a href="http://msdn.microsoft.com/en-us/library/ms132679.aspx" rel="nofollow noreferrer">BindingList</a> class, this will take care of most of the nastiness (just don't forget to override and return true for the SupportsChangeNotification property).</p>
<p>If the class you use for data binding has a property that is a collection (such as IBindingList or BindingList), then you can bind the foreign key grid to that property directly. When you configure the bindings in the Forms designer, just select the collection property as the data source for the grid. It should "just work". The only sneaky part is making sure that you handle empty or null collections the right way.</p>
|
<p>Here's a good "How Do I" video that demonstrates data binding:</p>
<p><a href="http://windowsclient.net/learn/video.aspx?v=52579" rel="nofollow noreferrer">http://windowsclient.net/learn/video.aspx?v=52579</a></p>
| 4,933
|
<p>Say you have an entity like a vehicle that you are capturing detailed information about. The car you want to capture is painted red, black and white. The front tires are Bridgestone 275/35-18 and the rear tires are 325/30-19. And sometimes you can have just two tires (yes this would be considered a motorcycle which is a type of vehicle) and sometimes 18 tires that could all be different. Then there are some fields that are always single valued like engine size (if we let our imaginations run wild we can think of multi-engined vehicles but I am trying to keep this simple). </p>
<p>Our current strategy for dealing with this is to have a table for each of the fields that can have multiple values. This will spawn a large number of tables (we have a bunch of different entities with this requirement) and smells a little bad. Is this the best strategy and if not, what would be better?</p>
|
<p>If it's a possibility for your app, you might want to look into <a href="http://incubator.apache.org/couchdb/" rel="nofollow noreferrer">couchdb</a>.</p>
|
<p>You're describing a <a href="http://en.wikipedia.org/wiki/Star_schema" rel="nofollow noreferrer">Star Schema</a>. I think its fairly standard practice in your kind of case</p>
<p>Edit: Actually your schema is slightly modified from the Star Schema, you use the primary key of the fact table in each of the dimension tables to join on so you can have multiple paint colors etc. Either way I think it's a fine way to deal with your entity. You may go one step further and normalize the dimension tables and then you'd have a <a href="http://en.wikipedia.org/wiki/Snowflake_schema" rel="nofollow noreferrer">Snowflake Schema</a></p>
| 9,147
|
<p>I am implementing a quite simple state-machine order processing application. It is a e-commerce application with a few twists. The users of the application will not be editing workflows by themselves.</p>
<p>Microsoft claims that asp.net and Windows Workflow is possible to combine. How hard is it to install and maintain a combination of asp.net and Windows Workflow? I would be keeping the workflow state in sql-server.</p>
<p>Is it easier for me to roll my own state machine code or is Windows Workflow the right tool for the job? </p>
|
<p>Asp.net and WF get along just fine, and WF doesn't add much maintenance overhead.</p>
<p>Whether or not this is the right design for you depends a lot on your needs. If you have a lot of event driven actions then WF might be worthwhile, otherwise the overhead of rolling your own tracking would probably add less complexity to the system.</p>
<p>WF is reasonably easy to work with so I'd suggest working up a prototype and experimenting with it.</p>
<p>Also, in my opinion, based on your requirements, I doubt WF would be the right solution for you.</p>
|
<p>If your state machine is very simple, then I would say that you should just roll your own. You have more control over everything. You can deal with persistence on your own terms and not worry about how they do it.</p>
<p>WF does look pretty cool though, but I think that it's power probably lies in the fact that it is easy to tie it into frameworks like CRM and Sharepoint. If you are going to use these in your application, then I would definitely consider using WF.</p>
<p>Full disclosure: I am definitely not a WF expert.</p>
| 9,269
|
<p>Occasionally, while printing, my <em>y</em> axis will slip and the layer will, from that point forward, be shifted, ruining the print.</p>
<p>What might be the causes of an axis slipping? I have tried cooling the motor which seemed to have been getting warm, and the belts are not too tight.</p>
<p>This does not happen with every print, and seems to be an intermittent problem. </p>
<p>My printer is a MendelMax RepRap, and the <em>y</em> axis is my moving bed.</p>
|
<p>In my experience, the most common reason for positional offset during printing, is the <em>motor skipping steps due to physical impact</em>. </p>
<p>Your stepper motors do not give <em>positional feedback</em> to your printer. So, if you forcefully move your motor during print, then the printer will not notice, and simply pretend it never happened.</p>
<p>In particular, the motor could skip steps if:</p>
<ul>
<li>Your nozzle collides with erroneous extrusions (e.g. blobs) during print.</li>
<li>Your speed settings (jerk and acceleration) are too high for the mass (inertia) of the parts moved by the y-axis motor.</li>
</ul>
<p>Smaller collisions and nozzle drag at high speed (e.g. during travel) could also cause this problem, since the strength of stepper motors is <a href="https://www.google.no/search?q=stepper%20motor%20strength%20curve%20NEMA%2017&espv=2&biw=1396&bih=805&source=lnms&tbm=isch&sa=X&ved=0ahUKEwifiuvOwN3KAhXBGCwKHUWHDPgQ_AUIBygB#imgrc=ZBI28Gp2zjb3oM%3A" rel="noreferrer">reduced at high speeds</a>.</p>
|
<p>My Y axis runs on a channel and I believe there was some grit or metal flakes in the channel left over from manufacturing. The wheels in the channel got stuck on the debris and caused the belt to slip. It made a horrible grinding noise when this happened.</p>
<p>So I blew out the channel with pressurized air and tested all the wheels.</p>
<p>I'll update if necessary as I test my fix with longer (taller) prints.</p>
<p><em>Update</em></p>
<p>Actually, the print had messed up g-code. The gcode file was corrupted.</p>
| 184
|
<p>I've created a model for executing worker tasks in a server application using a thread pool associated with an IO completion port such as shown in the posts below:</p>
<p><a href="http://weblogs.asp.net/kennykerr/archive/2008/01/03/parallel-programming-with-c-part-4-i-o-completion-ports.aspx" rel="noreferrer">http://weblogs.asp.net/kennykerr/archive/2008/01/03/parallel-programming-with-c-part-4-i-o-completion-ports.aspx</a></p>
<p><a href="http://blogs.msdn.com/larryosterman/archive/2004/03/29/101329.aspx" rel="noreferrer">http://blogs.msdn.com/larryosterman/archive/2004/03/29/101329.aspx</a></p>
<p>Are there any classes in boost that can help with this programming model?</p>
|
<p>Not really, at least, not last time I looked. I mean, boost::thread_group might make things marginally tidier in places, but not so as would make much of a difference, I don't think.</p>
<p>Boost's thread support seems marginally useful when writing something that's cross-platform, but given that what you're writing is going to be Win32-specific anyway (due to the use of IOCPs) there doesn't really seem to be much benefit from that.</p>
|
<p><a href="http://www.cs.wustl.edu/~schmidt/ACE.html" rel="nofollow noreferrer">ACE</a> has some reactors that you can use to model things around your IOCPs. Some of these could have been added to boost, but boost makes building them pretty easy. </p>
| 5,773
|
<p>So my company stores alot of data in a foxpro database and trying to get around the performance hit of touching it directly I was thinking of messaging anything that can be done asynchronously for a snappier user experience. I started looking at <a href="http://activemq.apache.org/" rel="noreferrer">ActiveMQ</a> but don't know how well C# will hook with it. Wanting to hear what all of you guys think.</p>
<p>edit : It is going to be a web application. Anything touching this foxpro is kinda slow (probably because the person who set it up 10 years ago messed it all to hell, some of the table files are incredibly large). We replicate the foxpro to sql nightly and most of our data reads are ok being a day old so we are focusing on the writes. plus the write affects a critical part of the user experience (purchasing), we store it in sql and then just message to have it put into foxpro when it can. I wish we could just get rid of the foxpro, unfortunately the company doesn't want to get rid of a very old piece of software they bought that depends on it.</p>
|
<p>ActiveMQ works well with C# using the Spring.NET integrations and NMS. A post with some links to get you started in that direction <a href="http://thefreakparade.com/2008/04/15/two-message-exchange-patterns-using-activemq-and-nms-via-springnet/" rel="noreferrer">is here</a>. Also consider using MSMQ (The System.Messaging namespace) or a .NET based asynchronous messaging solution, with <a href="http://thefreakparade.com/2008/06/03/esbs-for-the-microsoft-net-platform/" rel="noreferrer">some options here</a>.</p>
|
<p>Sorry if this isn't what you are asking for...
Have you considered some sort of cache behind the scenes that acts a bit like the "bucket system" when using asynchronous sockets in c/c++ using winsock? Basicly, it works by accepting requests, and sends an immediate response back to the web app, and when it finally gets around to finding your record, it updates it on the app via AJAX or any other technology of your choice. Since I'm not a C# programmer I can't provide any specific example. Hope this helps!</p>
| 2,625
|
<p>Does javascript use immutable or mutable strings? Do I need a "string builder"?</p>
|
<p>They are immutable. You cannot change a character within a string with something like <code>var myString = "abbdef"; myString[2] = 'c'</code>. The string manipulation methods such as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim" rel="noreferrer"><code>trim</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice" rel="noreferrer"><code>slice</code></a> return new strings.</p>
<p>In the same way, if you have two references to the same string, modifying one doesn't affect the other</p>
<pre><code>let a = b = "hello";
a = a + " world";
// b is not affected
</code></pre>
<p>However, I've always heard what Ash mentioned in his answer (that using Array.join is faster for concatenation) so I wanted to test out the different methods of concatenating strings and abstracting the fastest way into a StringBuilder. I wrote some tests to see if this is true (it isn't!).</p>
<p>This was what I believed would be the fastest way, though I kept thinking that adding a method call may make it slower...</p>
<pre><code>function StringBuilder() {
this._array = [];
this._index = 0;
}
StringBuilder.prototype.append = function (str) {
this._array[this._index] = str;
this._index++;
}
StringBuilder.prototype.toString = function () {
return this._array.join('');
}
</code></pre>
<p>Here are performance speed tests. All three of them create a gigantic string made up of concatenating <code>"Hello diggity dog"</code> one hundred thousand times into an empty string.</p>
<p>I've created three types of tests</p>
<ul>
<li>Using <code>Array.push</code> and <code>Array.join</code></li>
<li>Using Array indexing to avoid <code>Array.push</code>, then using <code>Array.join</code></li>
<li>Straight string concatenation</li>
</ul>
<p>Then I created the same three tests by abstracting them into <code>StringBuilderConcat</code>, <code>StringBuilderArrayPush</code> and <code>StringBuilderArrayIndex</code> <a href="http://jsperf.com/string-concat-without-sringbuilder/5" rel="noreferrer">http://jsperf.com/string-concat-without-sringbuilder/5</a> Please go there and run tests so we can get a nice sample. Note that I fixed a small bug, so the data for the tests got wiped, I will update the table once there's enough performance data. Go to <a href="http://jsperf.com/string-concat-without-sringbuilder/5" rel="noreferrer">http://jsperf.com/string-concat-without-sringbuilder/5</a> for the old data table.</p>
<p>Here are some numbers (Latest update in Ma5rch 2018), if you don't want to follow the link. The number on each test is in 1000 operations/second (<strong>higher is better</strong>)</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Browser</th>
<th>Index</th>
<th>Push</th>
<th>Concat</th>
<th>SBIndex</th>
<th>SBPush</th>
<th>SBConcat</th>
</tr>
</thead>
<tbody>
<tr>
<td>Chrome 71.0.3578</td>
<td>988</td>
<td>1006</td>
<td>2902</td>
<td>963</td>
<td>1008</td>
<td>2902</td>
</tr>
<tr>
<td>Firefox 65</td>
<td>1979</td>
<td>1902</td>
<td>2197</td>
<td>1917</td>
<td>1873</td>
<td>1953</td>
</tr>
<tr>
<td>Edge</td>
<td>593</td>
<td>373</td>
<td>952</td>
<td>361</td>
<td>415</td>
<td>444</td>
</tr>
<tr>
<td>Exploder 11</td>
<td>655</td>
<td>532</td>
<td>761</td>
<td>537</td>
<td>567</td>
<td>387</td>
</tr>
<tr>
<td>Opera 58.0.3135</td>
<td>1135</td>
<td>1200</td>
<td>4357</td>
<td>1137</td>
<td>1188</td>
<td>4294</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Findings</strong></p>
<ul>
<li><p>Nowadays, all evergreen browsers handle string concatenation well. <code>Array.join</code> only helps IE 11</p>
</li>
<li><p>Overall, Opera is fastest, 4 times as fast as Array.join</p>
</li>
<li><p>Firefox is second and <code>Array.join</code> is only slightly slower in FF but considerably slower (3x) in Chrome.</p>
</li>
<li><p>Chrome is third but string concat is 3 times faster than Array.join</p>
</li>
<li><p>Creating a StringBuilder seems to not affect perfomance too much.</p>
</li>
</ul>
<p>Hope somebody else finds this useful</p>
<p><strong>Different Test Case</strong></p>
<p>Since @RoyTinker thought that my test was flawed, I created a new case that doesn't create a big string by concatenating the same string, it uses a different character for each iteration. String concatenation still seemed faster or just as fast. Let's get those tests running.</p>
<p>I suggest everybody should keep thinking of other ways to test this, and feel free to add new links to different test cases below.</p>
<p><a href="http://jsperf.com/string-concat-without-sringbuilder/7" rel="noreferrer">http://jsperf.com/string-concat-without-sringbuilder/7</a></p>
|
<p>JavaScript strings are indeed immutable.</p>
| 7,416
|
<p>Now that most of the major browsers support full page zoom (at present, the only notable exception being Google Chrome), are liquid or elastic layouts no longer needed? Is the relative pain of building liquid/elastic layouts worth the effort? Are there any situations where a liquid layout would still be of benefit? Is full page zoom the real solution it at first appears to be?</p>
|
<p>Yes, because there are a vast variety of screens out there commonly ranging from 15" to 32".
There is also some variation in what people consider a "comfortable" font size.
All of which adds up to quite a range of sizes that your content will need to fit into.</p>
<p>If anything, liquid layout is becoming even more necessary as we scale up to huge monitors, and down to cellphone devices.</p>
|
<p>Liquid layouts can cause usability problems, though.</p>
<p>Content containers that become too wide become exceptionally difficult to read.</p>
<p>Many blogs have fixed width content containers specifically for this reason.</p>
<p>Alternatively, you can create multi-column content containers so that you get an effect like a newspaper, with its multiple columns of thin containers of text. This can be difficult to do, though.</p>
| 8,767
|
<p>The overall goal is to create a print of the liberty bell. No clapper is needed. The support beam is not needed. I am just looking to mimic the outside shape of the bell. After an application of Google-fu I found this image. It has been cleaned up and cropped a bit.</p>
<p><a href="https://i.stack.imgur.com/HTg2W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HTg2W.png" alt="enter image description here"></a></p>
<p>In OpenScad the surface function was applied to the png to generate a height model. I subtracted out a few cubes, and eventually got it down to a layer of about .1 height.</p>
<p>My Evil (pun intended) plan is to get it down to a 2d model. Then by shifting a copy of model from itself, and subtracting the two. That should leave just the curve. Then rotate_extrude the curve to generate the actual bell at the desired thickness.</p>
<p>I see the problem coming. If the model is layered down to zero height it will vanish. Leaving me nothing to rotate.</p>
<p>So on to the question.</p>
<p><strong>Is there any tool or technique to turn the image into a 2d openscad object or failing that is there another way to approach the problem?</strong></p>
<p><a href="https://i.stack.imgur.com/0joh6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0joh6.jpg" alt=""></a> </p>
<p>The direction that fred pointed me at is viable. I didn't use the actual image shown here, but a manually generated one from OpenScad. As a proof of concept the technique works well.</p>
|
<p>As you are already familiar with OpenSCAD, consider to use the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/3D_to_2D_Projection" rel="nofollow noreferrer">projection() function</a> to accomplish your goal.</p>
<p>If you allow for an interpretation that one can cast a shadow of the part on a surface below, it becomes a 2D representation of the part. This is effectively how projection works in OpenSCAD.</p>
<p>Note that the part image below is centered in x, y, z and the cut/projection action takes place at the z = 0 plane:</p>
<p><a href="https://i.stack.imgur.com/7USA0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7USA0.png" alt="sample model image"></a></p>
<p>When the function is applied to this model, the result is a non-contiguous 2d image:</p>
<p><a href="https://i.stack.imgur.com/COw50.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/COw50.png" alt="projected cut image"></a></p>
<p>When the cut parameter is ignored or set to false, the image which results is effectively an orthogonal shadow of the entire object, rather than a selected slice:</p>
<p><a href="https://i.stack.imgur.com/ffOe7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ffOe7.png" alt="flat shadow image"></a></p>
<p>It gets better, of course. In OpenSCAD, the translate, rotate and scale functions apply. One can tip a model over, resize it, spin it around, combine with the cut parameter and get any combination of 2d image from the original model:</p>
<p><a href="https://i.stack.imgur.com/cU1sN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cU1sN.png" alt="rotated model image"></a></p>
<p><a href="https://i.stack.imgur.com/HlXSF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HlXSF.png" alt="shadow rotated model"></a></p>
<p>It's important to note that OpenSCAD does provide non-zero thickness to these projections when rendered, or maybe when previewed. I always get those two swapped around. As your objective is a 2D result, you may be able to select from PNG (save as image) or Export as DXF or SVG.</p>
<p>Re-reading your post, I also missed part of a more useful answer. Once you have the profile you desire, you can use the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion" rel="nofollow noreferrer">rotate_extrude function</a> on the profile you generate. Despite the non-zero thickness, it uses the zero-thickness aspect to create the model from that function.</p>
<p>That aspect of the answer is left as an exercise for the reader, as the options are many and results can be complex.</p>
|
<p>You could have done that with OpenSCAD, there are instructions for extruding. </p>
<p>Personally, I'd just do a 1 altitude copy with
<a href="http://www.thingiverse.com/thing:1981938" rel="nofollow noreferrer">Image 2 STL 2 Heightmap Mesh Converter Generator</a>, then rotate in OpenSCAD. It's called <code>rotate_extrude()</code> and is used for seashells.</p>
<p>In MeshLab you can use <em>Laplacian Smooth</em> to depixelate/antialias it.</p>
| 566
|
<p>I'm trying to get some stats on how many of the visitors to our website have Silverlight enabled browsers. </p>
<p>We currently use Google Analytics for the rest of our stats so ideally we'd like to just add 'Silverlight enabled' tracking in with the rest of our Google Analytics stats. But if it has to get written out to a DB etc then so be it. </p>
<p>Nikhil has <a href="http://www.nikhilk.net/Silverlight-Analytics.aspx" rel="nofollow noreferrer">some javascript</a> to Silverlight tracking to Google Analytics. I have tried this code but Google Analytics doesn't pick it up.</p>
<p>Does anyone have any other ideas/techniques?</p>
|
<p>In case you missed it, there's a link to a more detailed article as well in the comments: <a href="http://blogs.msdn.com/jeffwilcox/archive/2007/10/01/using-google-analytics-with-rich-managed-web-applications-in-silverlight.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/jeffwilcox/archive/2007/10/01/using-google-analytics-with-rich-managed-web-applications-in-silverlight.aspx</a></p>
<p>Edit: As David pointed out, this article covers the reverse scenario more (how to write your silverlight app so that it plays well with Analytics).</p>
|
<p>I think you answered it yourself. The page you are linking to does just that: detect which version of Silverlight the user has (not if s/he installs it). From the page:</p>
<blockquote>
<p>After a little poking around, I found that Google Analytics has support for reporting a user-defined field.</p>
</blockquote>
<p>...</p>
<blockquote>
<p>Basically this detects the presence of Silverlight, and if its available, it records the version as the value of the user-defined field. Now your analytics reports will have one of three values: "(not set)", "Silverlight/1.0" or "Silverlight/2.0".</p>
</blockquote>
| 5,820
|
<p>Debugging asp.net websites/web projects in visual studio.net 2005 with Firefox is loads slower
than using IE.</p>
<p>I've read something somewhere that there is a way of fixing this but i can't for the life of me find it again.</p>
<p>Does anyone know what i'm on about and can point me in the right direction please?</p>
<p>Cheers
John</p>
<h2>edit</h2>
<p>sorry rob i haven't explained myself very well(again). I prefer Firefox for debugging (firebug etc)</p>
<p>hitting F5 when debugging with IE the browser launches really quickly and clicking around my web application is almost instant and when a breakpont is hit i get to my code straight away with no delays.</p>
<p>hitting F5 when debugging with FireFox the browser launches really slowly (ok i have plugins that slow FF loading) but clicking around my web application is really really slow and when a breakpoint is hit it takes ages to break into code.</p>
<p>i swear i've read something somewhere that there is a setting in Firefox (about:config maybe?) that when changed to some magic setting sorts all this out.</p>
|
<p>bingo. found the <a href="http://dotnetslackers.com/ASP_NET/re-122146_Speeding_Up_FireFox_When_Using_the_ASP_NET_Development_Server_from_Localhost.aspx" rel="noreferrer">article</a> i read before. </p>
<p>i just changed my network.dns.ipv4OnlyDomains property in about:config to localhost. restarted firefox and now firefox performs the same as IE when debugging asp.net with visual studio (2005).</p>
<p>hope this helps anyone else that has the same problem.</p>
|
<p>Are you serious? One of the main reasons I stick to Firefox is because its so much nicer to develop with..</p>
<p>The live source update is awesome (view source > change code > rebuild > F5 in source)...</p>
<p>What is actually "slow".. I mean, the some browsers tend to be slower at rendering, but I dont see how it affects your debug time? As soon as the request is made, and your breakpoint is hit in the code, it stops?</p>
| 4,460
|
<p>What JavaScript keywords (function names, variables, etc) are reserved?</p>
|
<p>Here is my poem, which includes all of the reserved keywords in JavaScript, and is dedicated to those who remain honest in the moment, and not just try to score:</p>
<pre class="lang-none prettyprint-override"><code>Let this long package float,
Goto private class if short.
While protected with debugger case,
Continue volatile interface.
Instanceof super synchronized throw,
Extends final export throws.
Try import double enum?
- False, boolean, abstract function,
Implements typeof transient break!
Void static, default do,
Switch int native new.
Else, delete null public var
In return for const, true, char
…Finally catch byte.
</code></pre>
|
<p>benc's answer is excellent, but for my two cents, I like the w3schools' page on this:</p>
<p><a href="http://www.w3schools.com/js/js_reserved.asp" rel="nofollow">http://www.w3schools.com/js/js_reserved.asp</a></p>
<p>In addition to listing the keywords reserved by the standard, it also has a long list of keywords you <em>should</em> avoid in certain contexts; for example, not using the name <code>alert</code> when writing code to be run in a browser. It helped me figure out why certain words were highlighting as keywords in my editor even though I knew they weren't keywords.</p>
| 4,585
|
<p>I'm currently trying to build a personal website to create a presence on the web for myself. My plan is to include content such as my resume, any projects that I have done on my own and links to open source projects that I have contributed to, and so on. However, I'm not sure which approach would be better from a perspective of "advertising" myself, since that what this site does, especially since I am a software developer.</p>
<p>Should I use an out-of-the-box system and extend it as needed, with available modules and custom modules where needed or should I custom build a site and all of its features as I need them? Does a custom site look better in the eyes of a potential employer who might visit my site?</p>
|
<p>I've toyed with this idea in the past but I don't think it's really a good idea for a number of reasons. Firstly, there are a number of places that can take care of most of this without you needing to do the work or maintenance. Just signing up for a linkedIn account for example will allow you to get most of your needs catered for in this regard. You can create your resume there and bio information etc and make it publicly viewable. The other issue with your "own site" is that if you don't update it often, the information gets stale, and worse yet, people have no reason to go back because <em>"nothing has changed"</em> - and that's not much of an <em>advert</em> for you is it?</p>
<p>Now that I've said all that, I'll make another recommendation. Why not start a blog instead?! If you've got decent experience, why not share that. I'd be willing to bet that this will be the <em>best</em> advert for your skills because:</p>
<ol>
<li>It's always updated (if you post often)</li>
<li>It's not like you're <em>looking</em> for work doing it - but your (future) employer, or their developers will check it out anyway to get a better insight into your character.</li>
<li>Putting something on your resume doesn't mean you can do it. I'm not saying that you'd lie about your skills :-), but there's no argument about your ability when you're writing articles about the stuff, getting comments and feedback, and better yet, learning <em>EVEN MORE</em> about your passions.</li>
</ol>
<p>Best of all - you can run your blog from your chosen domain and also point to your resume that is stored in linkedIn. Just an idea...</p>
<p>That's my two pennys worth on that - hope it helps you come to a decision!</p>
|
<p>I have come to see that the best way to advertise yourself is to put quality content out there. If you write about the technology that you have experience in, maybe create a few tutorials, and if you do all that often enough, that shows some authority in your chosen field of work.</p>
<p>This alone is one of the best advertisements. However, you also want to show passion. And online, that can be shown through how meticulously your site is done (it doesn't have to be a super great UI or something), but it should be neat, clean, and professional. It doesn't matter if its out of the box, or custom designed.</p>
<p>Either way, you will have to work hard to make it look good.</p>
| 3,120
|
<p>I have a usercontrol that has several public properties. These properties automatically show up in the properties window of the VS2005 designer under the "Misc" category. Except two of the properties which are enumerations don't show up correctly.</p>
<p>The first on uses the following enum:</p>
<pre><code>public enum VerticalControlAlign
{
Center,
Top,
Bottom
}
</code></pre>
<p>This does not show up in the designer <em>at all.</em></p>
<p>The second uses this enum:</p>
<pre><code>public enum AutoSizeMode
{
None,
KeepInControl
}
</code></pre>
<p>This one shows up, but the designer seems to think it's a bool and only shows True and False. And when you build a project using the controls it will say that it can't convert type bool to AutoSizeMode.</p>
<p>Also, these enums are declared globably to the Namespace, so they are accessible everywhere.</p>
<p>Any ideas?</p>
|
<p>I made a little test with your problem (I'm not sure if I understood it correctly), and these properties shows up in the designer correctly, and all enums are shown appropriately. If this isn't what you're looking for, then please explain yourself further. </p>
<p>Don't get hang up on the _Ugly part thrown in there. I just used it for a quick test.</p>
<pre><code>using System.ComponentModel;
using System.Windows.Forms;
namespace SampleApplication
{
public partial class CustomUserControl : UserControl
{
public CustomUserControl()
{
InitializeComponent();
}
/// <summary>
/// We're hiding AutoSizeMode in UserControl here.
/// </summary>
public new enum AutoSizeMode { None, KeepInControl }
public enum VerticalControlAlign { Center, Top, Bottom }
/// <summary>
/// Note that you cannot have a property
/// called VerticalControlAlign if it is
/// already defined in the scope.
/// </summary>
[DisplayName("VerticalControlAlign")]
[Category("stackoverflow.com")]
[Description("Sets the vertical control align")]
public VerticalControlAlign VerticalControlAlign_Ugly
{
get { return m_align; }
set { m_align = value; }
}
private VerticalControlAlign m_align;
/// <summary>
/// Note that you cannot have a property
/// called AutoSizeMode if it is
/// already defined in the scope.
/// </summary>
[DisplayName("AutoSizeMode")]
[Category("stackoverflow.com")]
[Description("Sets the auto size mode")]
public AutoSizeMode AutoSizeMode_Ugly
{
get { return m_autoSize; }
set { m_autoSize = value; }
}
private AutoSizeMode m_autoSize;
}
}
</code></pre>
|
<p>Some things to try (designer mode in VS2005 I have found to be somewhat flaky):</p>
<ol>
<li>Open your web.config and add: <code>batch="false"</code> to your <code><compilation></code> tag.</li>
<li><p>Try setting defaults to your enums:</p>
<pre><code>public enum VerticalControlAlign
{
Center = 0,
Top = 1,
Bottom = 2
}
</code></pre></li>
</ol>
| 8,961
|
<p>I want to see all the different ways you can come up with, for a factorial subroutine, or program. The hope is that anyone can come here and see if they might want to learn a new language.</p>
<h2>Ideas:</h2>
<ul>
<li>Procedural</li>
<li>Functional</li>
<li>Object Oriented</li>
<li>One liners</li>
<li>Obfuscated</li>
<li>Oddball</li>
<li>Bad Code</li>
<li><a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29" rel="nofollow noreferrer">Polyglot</a></li>
</ul>
<p>Basically I want to see an example, of different ways of writing an algorithm, and what they would look like in different languages.</p>
<p>Please limit it to one example per entry.
I will allow you to have more than one example per answer, if you are trying to highlight a specific style, language, or just a well thought out idea that lends itself to being in one post.</p>
<p>The only real requirement is it must find the factorial of a given argument, in all languages represented.</p>
<h1>Be Creative!</h1>
<h2>Recommended Guideline:</h2>
<pre>
# Language Name: Optional Style type
- Optional bullet points
Code Goes Here
Other informational text goes here
</pre>
<p>I will ocasionally go along and edit any answer that does not have decent formatting.</p>
|
<h1>Polyglot: 5 languages, all using bignums</h1>
<p>So, I wrote a polyglot which works in the three languages I often write in, as well as one from my other answer to this question and one I just learned today. It's a standalone program, which reads a single line containing a nonnegative integer and prints a single line containing its factorial. Bignums are used in all languages, so the maximum computable factorial depends only on your computer's resources.</p>
<ul>
<li><b>Perl</b>: uses built-in bignum package. Run with <code>perl FILENAME</code>.</li>
<li><b>Haskell</b>: uses built-in bignums. Run with <code>runhugs FILENAME</code> or your favorite compiler's equivalent.</li>
<li><b>C++</b>: requires GMP for bignum support. To compile with g++, use <code>g++ -lgmpxx -lgmp -x c++ FILENAME</code> to link against the right libraries. After compiling, run <code>./a.out</code>. Or use your favorite compiler's equivalent.</li>
<li><b>brainf*ck</b>: I wrote some bignum support in <a href="https://stackoverflow.com/questions/23930/factorial-algorithms-in-different-languages/432010#432010">this post</a>. Using <a href="http://aminet.net/package.php?package=dev/lang/brainfuck-2.lha" rel="nofollow noreferrer">Muller's classic distribution</a>, compile with <code>bf < FILENAME > EXECUTABLE</code>. Make the output executable and run it. Or use your favorite distribution.</li>
<li><b>Whitespace</b>: uses built-in bignum support. Run with <code>wspace FILENAME</code>.</li>
</ul>
<p><i>Edit:</i> added Whitespace as a fifth language. Incidentally, do <em>not</em> wrap the code with <code><code></code> tags; it breaks the Whitespace. Also, the code looks much nicer in fixed-width.</p>
<pre>char //# b=0+0{- |0*/; #>>>>,----------[>>>>,--------
#define	a/*#--]>>>>++<<<<<<<<[>++++++[<------>-]<-<<<
#Perl	><><><>	 <> <> <<]>>>>[[>>+<<-]>>[<<+>+>-]<->
#C++	--><><>	<><><><	> < > <	+<[>>>>+<<<-<[-]]>[-]
#Haskell >>]>[-<<<<<[<<<<]>>>>[[>>+<<-]>>[<<+>+>-]>>]
#Whitespace	>>>>[-[>+<-]+>>>>]<<<<[<<<<]<<<<[<<<<
#brainf*ck > < ]>>>>>[>>>[>>>>]>>>>[>>>>]<<<<[[>>>>*/
exp; ;//;#+<<<<-]<<<<]>>>>+<<<<<<<[<<<<][.POLYGLOT^5.
#include <gmpxx.h>//]>>>>-[>>>[>>>>]>>>>[>>>>]<<<<[>>
#define	eval int	main()//>+<<<-]>>>[<<<+>>+>->
#include <iostream>//<]<-[>>+<<[-]]<<[<<<<]>>>>[>[>>>
#define	print std::cout	<< // >	<+<-]>[<<+>+>-]<<[>>>
#define	z std::cin>>//<< +<<<-]>>>[<<<+>>+>-]<->+++++
#define c/*++++[-<[-[>>>>+<<<<-]]>>>>[<<<<+>>>>-]<<*/
#define	abs int $n //><	<]<[>>+<<<<[-]>>[<<+>>-]]>>]<
#define	uc mpz_class fact(int	$n){/*<<<[<<<<]<<<[<<
use bignum;sub#<<]>>>>-]>>>>]>>>[>[-]>>>]<<<<[>>+<<-]
z{$_[0+0]=readline(*STDIN);}sub fact{my($n)=shift;#>>
#[<<+>+>-]<->+<[>-<[-]]>[-<<-<<<<[>>+<<-]>>[<<+>+>+*/
uc;if($n==0){return 1;}return $n*fact($n-1);	}//;#
eval{abs;z($n);print fact($n);print("\n")/*2;};#-]<->
'+<[>-<[-]]>]<<[<<<<]<<<<-[>>+<<-]>>[<<+>+>-]+<[>-+++
-}--	<[-]]>[-<<++++++++++<<<<-[>>+<<-]>>[<<+>+>-++
fact 0	= 1 -- ><><><><	> <><><	]+<[>-<[-]]>]<<[<<+ +
fact	n=n*fact(n-1){-<<]>>>>[[>>+<<-]>>[<<+>+++>+-}
main=do{n<-readLn;print(fact n)}-- +>-]<->+<[>>>>+<<+
{-x<-<[-]]>[-]>>]>]>>>[>>>>]<<<<[>+++++++[<+++++++>-]
<--.<<<<]+written+by+++A+Rex+++2009+.';#+++x-}--x*/;}
</pre>
|
<h1>Haskell : Functional - Tail Recursive</h1>
<pre><code>factorial n = factorial' n 1
factorial' 0 a = a
factorial' n a = factorial' (n-1) (n*a)
</code></pre>
| 4,372
|
<p>I was given a C++ project that was compiled using MS Visual Studio .net 2003 C++ compiler, and a .mak file that was used to compile it. I am able to build it from the command line using nmake project.mak, but the compiler complains that afxres.h was not found. I did a little searching around and the afxres.h is in the Visual Studio directory in an includes file. Where am I supposed to specify to nmake where to look for this header file?</p>
|
<p>There should be an icon in your Start menu under Programs that opens a cmd.exe instance with all the correct MSVS environment variables set up for command line building.</p>
|
<p>Another option is running the appropriate <code>vars</code> batch file from a regular command prompt. The name and location varies from version to version. For VS2003, I believe it's</p>
<p><code>C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat</code></p>
| 5,591
|
<p>I'm working on a messaging/notification system for our products. Basic requirements are:</p>
<ul>
<li>Fire and forget</li>
<li>Persistent set of messages, possibly updating, to stay there until the sender says to remove them</li>
</ul>
<p>The libraries will be written in C#. Spring.NET just released a milestone build with lots of nice messaging abstraction, which is great - I plan on using it extensively. My basic question comes down to the question of message brokers. My architecture will look something like app -> message broker queue -> server app that listens, dispatches all messages to where they need to go, and handles the life cycle of those long-lived messages -> message broker queue or topic -> listening apps.</p>
<p>Finally, the question: Which message broker should I use? I am biased towards <a href="http://activemq.apache.org" rel="noreferrer">ActiveMQ</a> - We used it on our last project and loved it. I can't really think of a single strike against it, except that it's Java, and will require java to be installed on a server somewhere, and that might be a hard sell to some of the people that will be using this service. The other option I've been looking at is MSMQ. I am biased against it for some unknown reason, and it also doesn't seem to have great multicast support.</p>
<p>Has anyone used MSMQ for something like this? Any pros or cons, stuff that might sway the vote one way or the other?</p>
<p>One last thing, we are using .NET 2.0.</p>
|
<p>I'm kinda biased as I work on <a href="http://activemq.apache.org" rel="noreferrer">ActiveMQ</a> but pretty much all of benefits listed for MSMQ above also apply to ActiveMQ really. </p>
<p>Some more benefits of ActiveMQ include</p>
<ul>
<li>great support for <a href="http://activemq.apache.org/cross-language-clients.html" rel="noreferrer">cross language client access and multi protocol support</a> </li>
<li>excellent support for <a href="http://activemq.apache.org/enterprise-integration-patterns.html" rel="noreferrer">enterprise integration patterns</a></li>
<li>a ton of <a href="http://activemq.apache.org/features.html" rel="noreferrer">advanced features</a> like <a href="http://activemq.apache.org/exclusive-consumer.html" rel="noreferrer">exclusive queues</a> and <a href="http://activemq.apache.org/message-groups.html" rel="noreferrer">message groups</a></li>
</ul>
<p>The main downside you mention is that the ActiveMQ broker is written in Java; but you can run it on IKVM as a .net assembly if you really want - or run it as a windows service, or compile it to a DLL/EXE via GCJ. MSMQ may or may not be written in .NET - but it doesn't really matter much how its implemented right?</p>
<p>Irrespective of whether you choose MSMQ or ActiveMQ I'd recommend at least considering using the <a href="http://activemq.apache.org/nms/" rel="noreferrer">NMS API</a> which as you say is integrated great into Spring.NET. There is an MSMQ implementation of this API as well as implementations for TibCo, ActiveMQ and STOMP which will support any other JMS provider via <a href="http://stomp.codehaus.org/StompConnect" rel="noreferrer">StompConnect</a>.</p>
<p>So by choosing NMS as your API you will avoid lockin to any proprietary technology - and you can then easily switch messaging providers at any point in time; rather than locking your code all into a proprietary API</p>
|
<p>I suggest you have a look at TIBCO Enterprise Messaging Service - EMS, which is a high performance messaging product that supports multicasting, routing, supports JMS specification and provides enterprise wide features including your requirements suchas fire-forget and message persistence using file/database using shared state.</p>
<p>As a reference, FEDEX runs on TIBCO EMS
as its messaging infrastructure.</p>
<p><a href="http://www.tibco.com/software/messaging/enterprise_messaging_service/default.jsp" rel="nofollow noreferrer">http://www.tibco.com/software/messaging/enterprise_messaging_service/default.jsp</a></p>
<p>There are lot other references if i provide, you'd really be surprised.</p>
| 5,285
|
<p>I want to plug in my drivers from the printer into my Raspberry Pi. I want to control the printer's axes by sending G-code directly from the Raspberry Pi command line (if possible) to the drivers.</p>
<p>Is that possible and if yes does anyone know how? As I stated above without using any 3rd party program/software.</p>
|
<p>A very dumb, simple way to send GCODE to your printer from the terminal can be achieved with:<br />
<code>echo "gcode here" > /dev/ttyS0</code><br />
/dev/ttyS0 can vary, It may be /dev/ttyACM0, /dev/ttyUSB0, or any similar with a different number.</p>
<p>You can figure out which path is correct for your printer with the command <code>ls /dev/tty*</code> and comparing the results with your printer plugged in and unplugged, Whichever device pops up new should be your printer.<br />
As well, Some printers may appear in <code>/dev/serial/by-id/</code> instead of <code>/dev/tty*</code>, so if you can't find your printer normally, try <code>ls /dev/serial/by-id/</code> instead.</p>
<p>If this doesn't seem to work, you may need to change the serial settings using the command <code>sudo stty -f /dev/ttyS0 115200</code>, replacing /dev/ttyS0 and 115200 to the device path and printer baud rate respectively.</p>
<p>If you are looking for a more bi-directional solution, you can use the command <code>screen</code>, which is usually installed by default. You can use it like this:<br />
<code>screen /dev/ttyS0 115200</code> and exit by Control+A, then pressing D<br />
Another solution would be the <code>pronsole</code> utility from Printrun/Pronterface, which can be installed using <code>sudo apt install printrun</code> and invoked with <code>pronsole.py</code> and you can then connect to your printer with the syntax<br />
<code>connect /dev/ttyS0 115200</code> or simply <code>connect</code>, as pronsole has the ability to autoconnect to your printer. Exit with the <code>exit</code> command.</p>
|
<p>You can send the data to the serial port using <code>echo</code>, but you'll have to use <code>cat</code> to get the response.</p>
| 1,999
|
<p>What Firefox add-ons do you use that are useful for programmers?</p>
|
<p>I guess it's silly to mention Firebug -- doubt any of us could live without it. Other than that I use the following (only listing dev-related):</p>
<ul>
<li>Console<sup>2</sup>: next-generation error console</li>
<li>DOM inspector: as the title might indicate, allows you to browse the DOM</li>
<li>Edit Cookies: change cookies on the fly</li>
<li>Execute JS: ad-hoc Javascript execution</li>
<li>IE Tab: render a page in IE</li>
<li>Inspect This: brings the selected object into the DOM inspector</li>
<li>JSView: display linked javascript and CSS</li>
<li>LORI (Life of Request Info): shows how long it takes to render a page</li>
<li>Measure IT: a popup ruler. </li>
<li>URL Params: shows GET and POST variables</li>
<li>Web Developer: a myriad of tools for the web developer</li>
</ul>
|
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferrer">Web Developer</a> for web development. <a href="https://addons.mozilla.org/en-US/firefox/addon/1730" rel="nofollow noreferrer">Scribefire</a> if you're a blogger-progammer</p>
| 5,702
|
<p>I am looking for a tool that can detect malicious requests (such as obvious SQL injection gets or posts) and will immediately ban the IP address of the requester/add to a blacklist. I am aware that in an ideal world our code should be able to handle such requests and treat them accordingly, but there is a lot of value in such a tool even when the site is safe from these kinds of attacks, as it can lead to saving bandwidth, preventing bloat of analytics, etc.</p>
<p>Ideally, I'm looking for a cross-platform (<code>LAMP/.NET</code>) solution that sits at a higher level than the technology stack; perhaps at the web-server or hardware level. I'm not sure if this exists, though.</p>
<p>Either way, I'd like to hear the community's feedback so that I can see what my options might be with regard to implementation and approach.</p>
|
<p>Your almost looking at it the wrong way, no 3party tool that is not aware of your application methods/naming/data/domain is going to going to be able to perfectly protect you.</p>
<p>Something like SQL injection prevention is something that has to be in the code, and best written by the people that wrote the SQL, because they are the ones that will know what should/shouldnt be in those fields (unless your project has very good docs)</p>
<p>Your right, this all has been done before. You dont quite have to reinvent the wheel, but you do have to carve a new one because of a differences in everyone's axle diameters.</p>
<p>This is not a drop-in and run problem, you really do have to be familiar with what exactly SQL injection is before you can prevent it. It is a sneaky problem, so it takes equally sneaky protections.</p>
<p>These 2 links taught me far more then the basics on the subject to get started, and helped me better phrase my future lookups on specific questions that weren't answered.</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/SQL_injection" rel="nofollow noreferrer">SQL injection</a></li>
<li><a href="http://www.unixwiz.net/techtips/sql-injection.html" rel="nofollow noreferrer">SQL Injection Attacks by Example</a></li>
</ul>
<p>And while this one isnt quite a 100% finder, it will "show you the light" on existing problem in your existing code, but like with webstandards, dont stop coding once you pass this test.</p>
<ul>
<li><a href="http://www.securitycompass.com/exploitme.shtml" rel="nofollow noreferrer">Exploit-Me</a></li>
</ul>
|
<p>Interesting how this is being implemented years later by google and them removing the URL all together in order to prevent XSS attacks and other malicious acitivites</p>
| 2,367
|
<p>I have a WiFi module that only needs two wires connection to work. These are RX and TX pins connected to Arduino or the CR-10S printer board but I don't know if there is any physical or software UARTs TX and RX pins. My goal is to add a Wifi support to the CR-10S printer. Since this is not Arduino and the pins are not labeled, it's hard to tell which TX and RX pins are not being used.</p>
<p>In the image of my motherboard below, any port or pin with line pointing to is considered as being used by the printing software so I can't used them.</p>
<p><a href="https://i.stack.imgur.com/gGGeo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gGGeo.jpg" alt="CR-10S printer control board"></a></p>
<p>There are still ports or pins that are not used. Can any one tell if there is a TX and RX pin that is not being used from the image above? I need them to communicate with the printer wirelessly. </p>
|
<p>You are looking for a capacitor that must be connected to Pin 4 of the LM2596.</p>
<p>Maybe you could provide a better picture of that area so we could see the different tracks on the board.</p>
<p>The LM2596 is in the center of the right side of the board (it is also labeled with LM2596D). The pins should be counted from top to bottom (in your picture)</p>
<p>My guess is, the Elko you are looking for is connected to C31, and you must look for the positive pin.</p>
<p><a href="https://i.stack.imgur.com/1h1U6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1h1U6.png" alt="LM2596 Wiring"></a></p>
<p>In this wiring diagram Cout is the capacitor you are looking for. The SMD Parts R1, R2 and CFF should be R31, R32 and C31 in your picture.</p>
<p>With the corresponging measurements I would say you do not need to replace the capacitors. </p>
<p>In comparison to the old board your board already has the "fix" implemented. </p>
|
<h1>You are looking at the wrong board</h1>
<p>Your board might on the surface look like a Creality v 2.0 board, and is indeed from the same family of boards. After trying to discern the parts and finally resorting to google image search, I almost had to maniacally laugh:</p>
<p>The currently latest version is the <a href="https://www.creality3d.shop/products/mainboard-upgraded-replacement-controller-board-latest-v2-1-version-motherboard-for-creality-cr-10s-s4-s5-3d-printer" rel="nofollow noreferrer">Creality 2.1</a>, but your board clearly is a pre 2.0 board, as the 2.0 and 2.1 are quite similar, almost identical in the areas in question. According to the standard nomenclature, a 2.X board should be a full new engineering or vastly re-engineered board. So I looked up a Creality 1.X board - And indeed, it looks somewhat closer to a CR-10 motherboard in the area around the black capacitor, but that is marked 150/151. So it is <a href="https://www.creality3d.shop/collections/accessories/products/creality-cr-10-motherboard" rel="nofollow noreferrer">not a Creality 1.1.2 / 1.1.3</a>, also known as "CR-10" board.</p>
<p>My best guess (Confirmed by OP and <a href="https://www.th3dstudio.com/knowledge-base/creality-cr-10-and-cr-10s-models-what-printer-do-you-have/" rel="nofollow noreferrer">this</a>) is, that your board is an intermediate step between the Creality 1.1.x Board for the CR-10 and the <em>new</em> CR-10S 2.0/2.1, so by nomenclature a <em>proto-2.0</em>. Among Makers, it is called "original CR-10S" at times. Your numbers should thus be read from this board:</p>
<p><a href="https://i.stack.imgur.com/Zgh0z.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zgh0z.jpg" alt="Original CR10S Board" /></a></p>
<p>There is a 100/35V/UT Capacity in the indicated spot in both the green and black renditions.</p>
| 1,099
|
<p>I've been taking a look at some different products for .NET which propose to speed up development time by providing a way for business objects to map seamlessly to an automatically generated database. I've never had a problem writing a data access layer, but I'm wondering if this type of product will really save the time it claims. I also worry that I will be giving up too much control over the database and make it harder to track down any data level problems. Do these type of products make it better or worse in the already tough case that the database and business object structure must change?</p>
<p>For example:
<a href="http://www.devexpress.com/Products/NET/ORM/" rel="nofollow noreferrer">Object Relation Mapping from Dev Express</a></p>
<p>In essence, is it worth it? Will I save "THAT" much time, effort, and future bugs?</p>
|
<p>I have used SubSonic and EntitySpaces. Once you get the hang of them, I beleive they can save you time, but as complexity of your app and volume of data grow, you may outgrow these tools. You start to lose time trying to figure out if something like a performance issue is related to the ORM or to your code. So, to answer your question, I think it depends. I tend to agree with Eric on this, high volume enterprise apps are not a good place for general purpose ORMs, but in standard fare smaller CRUD type apps, you might see some saved time.</p>
|
<p>There are lots of choices of ORMs. Linq to Sql, nHibernate. For pure object databases there is db4o.</p>
<p>It depends on the application, but for a high volume enterprise application, I would not go this route. You need more control of your data.</p>
| 4,840
|
<p>I would like to create a database backed interactive AJAX webapp which has a custom (specific kind of events, editing) calendaring system. This would involve quite a lot of JavaScript and AJAX, and I thought about Google Web Toolkit for the interface and Ruby on Rails for server side.</p>
<p>Is Google Web Toolkit reliable and good? What hidden risks might be if I choose Google Web Toolkit? Can one easily combine it with Ruby on Rails on server side? Or should I try to use directly a JavaScript library like jQuery?</p>
<p>I have no experience in web development except some HTML, but I am an experienced programmer (c++, java, c#), and I would like to use only free tools for this project.</p>
|
<p>RoR is actually one of the things the GWT is made to work well with, as long as you're using REST properly. It's in the Google Web Toolkit Applications book, and you can see a demo from the book using this kind of idea <a href="http://www.gwtapps.com/?page_id=33" rel="noreferrer">here</a>. That's not to say that you won't have any problems, but I think the support is definitely out there for it.</p>
<p>There's a neat project for making RoR/GWT easy that you can find <a href="http://code.google.com/p/gwt-on-rails/" rel="noreferrer">here</a> (MIT license). I haven't had a chance to try it out yet, but it looks like a good amount of thought has been put into it. One catch is that it looks like it hasn't been fully tested with 2.1 Rails yet, just 2.0, so you may run into a few (probably minor and fixable) errors.</p>
|
<p>You could also consider <a href="http://grails.org/" rel="nofollow noreferrer">Grails</a> ("Groovy on Rails") which gives you the benefits of a Rails framework and the use of the Java VM.</p>
| 5,067
|
<p>I'd like to automate TortoiseSVN as part of a commit process.
Specifically I'd like to dynamically create a log entry for the commit dialog.</p>
<p>I know that I can launch the commit dialog either from the commandline or by right clicking on a folder and selecting svncommit.</p>
<p>I'd like to use the start commit hook to setup a log entry.
I thought this worked by passing an entry file name in the MESSAGEFILE variable but when I add a hook script it cannot see this variable (hook launched successfully after right clicking and choosing svncommit).</p>
<p>When I try using the commandline I use the /logmsgfile parameter but it seems to have no effect.</p>
<p>I'm using tortoisesvn 1.5.3.</p>
|
<p>Looks like it was my own misunderstanding of the the API that caused by a problem.</p>
<p>Solution:<br>
1) I've added a start commit hook script to TortoiseSVN using the hooks gui in the settings area of the right click menu.</p>
<p>2) The script receive 3 pieces of information: PATH MESSAGEFILE CWD<br>
For details see: <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-bugtracker.html" rel="nofollow noreferrer" title="Manual">Manual</a><br>
These are passed as command line arguements to the script - for some reason I had thought they were set as temporary environmental variables.</p>
<p>My script then simply opens the file specified by the second arguement and adds in the custom text.</p>
<p>When the commit dialog comes up the custom text is there.</p>
<p>3) Best of all if tortoisesvn is launched from a script directly into the commit dialog:<br>
e.g. [ tortoiseproc /command:commit /path:. /closeonend:1 ]<br>
The hooks are still called.</p>
|
<p>If you just need a static template, set the tsvn:logtemplate property.</p>
<p>For dynamic generation, the /logmsgfile parameter does work, but it seems to need the full path. A batch file that looks like the following might work for you.</p>
<pre><code>GenerateLogMsg.exe > tmp.msg
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:commit /path:. /logmsgfile:"C:\Documents and Settings\User\My Documents\Visual Studio Projects\Project\tmp.msg"
</code></pre>
| 8,346
|
<p>I hope this question does not come off as broad as it may seem at first. I am designing a software application that I would like to be both cross-platform and modular. I am still in the planning phase and can pick practically any language and toolset.</p>
<p>This makes things harder, not easier, because there are seemingly so many ways of accomplishing both of the goals (modularity, platform agnosticism).</p>
<p>My basic premise is that security, data storage, interaction with the operating system, and configuration should all be handled by a "container" application - but most of the other functionality will be supplied through plug-in modules. If I had to describe it at a high level (without completely giving away my idea), it would be a single application that can do many different jobs, all dedicated to the same goal (there are lots of disparate things to do, but all the data has to interact and be highly available).</p>
<p>I find myself wrestling with not so much how to do it (I can think of lots of ways), but which method is best.</p>
<p>For example, I know that Eclipse practically embodies what I am describing, but I find Java applications in general (and Eclipse is no exception) to be too large and slow for what I need. Ditto desktop apps written Python and Ruby (which are excellent languages!)</p>
<p>I don't mind recompiling the code base for different platforms as native exectables. Yet, C and C++ have their own set of issues.</p>
<p>As a C# developer, I have a preference for managed code, but I am not at all sold on Mono, yet (I could be convinced).</p>
<p>Does anyone have any ideas/experiences/ specific favorite frameworks to share?</p>
|
<p>Just to cite an example: for .NET apps there are the CAB (Composite Application Block) and the Composite Application Guidance for WPF. Both are mainly implementations of a set of several design patterns focused on modularity and loose coupling between components similar to a plug-in architecture: you have an IOC framework, MVC base classes, a loosely coupled event broker, dynamic loading of modules and other stuff.</p>
<p>So I suppose that kind of pattern infrastructure is what you are trying to find, just not specifically for .NET. But if you see the CAB as a set of pattern implementations, you can see that almost every language and platform has some form of already built-in or third party frameworks for individual patterns. </p>
<p>So my take would be:</p>
<ol>
<li>Study (if you are not familiar with) some of those design patterns. You could take as an example the CAB framework for WPF documentation: <a href="http://msdn.microsoft.com/en-us/library/cc707841.aspx" rel="nofollow noreferrer">Patterns in the Composite Application Library</a></li>
<li>Design your architecture thinking on which of those patterns you think would be useful for what you want to achieve <b>first without thinking in specific pattern implementations or products</b>.</li>
<li>Once you have your 'architectural requirements' defined more specifically, look for individual frameworks that help accomplish each one of those patterns/features for the language you decide to use and put together your own application framework based on them.</li>
</ol>
<p>I agree that the hard part is to make all this platform independent. I really cannot think on any other solution to choose a mature platform independent language like Java.</p>
|
<p>With my limited Mono experience I can say I'm quite sold on it. The fact that there is active development and a lot of ongoing effort to bring it up to spec with the latest .Net technologies is encouraging. It is incredibly useful to be able to use existing .Net skills on multiple platforms. I had similar issues with performance when attempting to accomplish some basic tasks in Python + PyGTK -- maybe they can be made to perform in the right hands but it is nice to not have to worry about performance 90% of the time.</p>
| 5,360
|
<p>I specifically want to test </p>
<ul>
<li>calibration</li>
<li>tolerances</li>
<li>precision</li>
<li>accuracy</li>
</ul>
<p>I'm having trouble with Print in Place models and I'm trying to find out if there's something I can do to improve my print quality. </p>
<p>The printer I am using is a Kossel clone, specifically a FLSUN QQ and assume FDM printing.</p>
|
<p>This is a fairly open ended subject, but the different calibration/test models can be broken down into a few different groups. Although there are a few common 'standards', as soon as you get to looking at a specific parameter, you will need to look for something that is a good match for your problem (not everything on thingiverse is really 'useful), and work out how to use it for your adjustments. Ultimately, the specific model you're working on is the best test - and it may also be that this model is not optimal in some way.</p>
<p>Here is a print from my own test model which shows the slicer not handling my model very well, partly because the model doesn't respect the filament dimensions. It also shows how a variety of print details can be captured in a small (20 min) print.
<a href="https://i.stack.imgur.com/xXK9zm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xXK9zm.jpg" alt="Small Tower Tester by tsh2"></a></p>
<h2>Basic Calibration</h2>
<p>This is a step that you might be tempted to skip on a non-diy printer, since it mainly focuses on the construction. The <a href="https://www.thingiverse.com/thing:1278865" rel="nofollow noreferrer">basic 20mm calibration cube</a> (just a square) can be used to test that your printer is dimensionally accurate, and is also one way to check your extruder steps/mm (extrusion is variable, x/y steps generally only change when the belt skips).
You can also use bigger shapes if you suspect that there are drive problems, and <a href="https://www.thingiverse.com/thing:2664146" rel="nofollow noreferrer">bed leveling</a> might come into this group too, where you could use a one or two layer print.</p>
<h2>Test Parts</h2>
<p>These are small parts that might once have been considered hard to print, but now seem to be a standard reference for a 'good' print. Most people who have been printing for a while have a collection of <a href="http://www.3dbenchy.com" rel="nofollow noreferrer">benchie</a> and <a href="https://www.3dhubs.com/hub-academy/your-first-order-marvin-test-print" rel="nofollow noreferrer">marvin</a> prints. You might use these to quickly test a new filament, although the benchie is borderline large.</p>
<p><a href="https://i.stack.imgur.com/6Q9H0m.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Q9H0m.jpg" alt="Marvin"></a>
<a href="https://i.stack.imgur.com/SMa9wm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SMa9wm.jpg" alt="Benchie"></a></p>
<h2>Detail calibration</h2>
<p>Depending what you want to focus on, there will be different things you can use. Temperature calibration towers, overhang and bridging tests, ripple tests (for acceleration), fan tests, etc. This is an area where finding a 'good' test part can be hard. You would want to make sure that the previous two classes of test show good all round performance (or have identified a specific problem) first, before trying this sort of test.</p>
<p>For the print-in-place example, you might need to check extrusion/ooze/coasting, as well as checking linearity and orthogonality (it's no use if a circular part turns out to be more like a diamond with rounded corners). You also need to make sure your first layer is good, without a rim or warping.</p>
<h2>Torture tests</h2>
<p>I put this in a group on it's own because it may not be as useful for tuning a printer as some of the others. This is a little bit more about showing off how good your printer is tuned - and is the origin of the benchie and marvin type models, just with the difficulty turned up a notch or two. Some print-in-place models might fit into this category.</p>
|
<p>The best place to start looking is to go to <a href="http://www.thingiverse.com" rel="nofollow noreferrer">Thingiverse</a> and search on '<a href="https://www.thingiverse.com/search?q=benchmark" rel="nofollow noreferrer">benchmark</a>'. There are a great many models there intended to test various aspects of printing. In fact you could search for example '<a href="https://www.thingiverse.com/search?q=calibration%20benchmark" rel="nofollow noreferrer">calibration benchmark</a>' or '<a href="http://www.thingiverse.com/search?q=calibration%20test" rel="nofollow noreferrer">calibration test</a>' and get more specific examples.</p>
<p>Actually, <a href="https://www.thingiverse.com/nebogipfel/collections/benchmarks" rel="nofollow noreferrer">here</a> is a collection I just made today of the benchmarks I thought most promising. Disclaimer: I haven't tried them yet!</p>
| 975
|
<p>I've got a System.Generic.Collections.List(Of MyCustomClass) type object.</p>
<p>Given integer varaibles pagesize and pagenumber, how can I query only any single page of MyCustomClass objects?</p>
|
<p>If you have your linq-query that contains all the rows you want to display, this code can be used:</p>
<pre><code>var pageNum = 3;
var pageSize = 20;
query = query.Skip((pageNum - 1) * pageSize).Take(pageSize);
</code></pre>
<p>You can also make an extension method on the object to be able to write</p>
<pre><code>query.Page(2,50)
</code></pre>
<p>to get the first 50 records of page 2. If that is want you want, the information is on the <a href="http://solidcoding.blogspot.com/2007/11/paging-with-linq.html" rel="noreferrer">solid code blog.</a></p>
|
<p>Hi There is a wicked thing called PagedList which i got when watching a Rob Conery Screen Cast. </p>
<p><a href="http://blog.wekeroad.com/2007/12/10/aspnet-mvc-pagedlistt/" rel="noreferrer">http://blog.wekeroad.com/2007/12/10/aspnet-mvc-pagedlistt/</a></p>
<p>It has all the Skip and Take stuff built in.</p>
<p>All you do is call</p>
<pre><code>var query = from item in DB.Table
where item.Field == 1
orderby item.Field2
select item;
PagedList<MyType> pagedList = query.ToPagedList(pageIndex, pageSize);
</code></pre>
<p>Hope it helps.. I'm using it now and it works ok for linq to entities. With Linq to entities you have to perform an Orderby before you can use Skip and Take.</p>
| 4,144
|
<p>Has anyone found a useful solution to the DesignMode problem when developing controls?</p>
<p>The issue is that if you nest controls then DesignMode only works for the first level. The second and lower levels DesignMode will always return FALSE.</p>
<p>The standard hack has been to look at the name of the process that is running and if it is "DevEnv.EXE" then it must be studio thus DesignMode is really TRUE.</p>
<p>The problem with that is looking for the ProcessName works its way around through the registry and other strange parts with the end result that the user might not have the required rights to see the process name. In addition this strange route is very slow. So we have had to pile additional hacks to use a singleton and if an error is thrown when asking for the process name then assume that DesignMode is FALSE.</p>
<p>A nice clean way to determine DesignMode is in order. Acually getting Microsoft to fix it internally to the framework would be even better!</p>
|
<p>Revisiting this question, I have now 'discovered' 5 different ways of doing this, which are as follows:</p>
<pre><code>System.ComponentModel.DesignMode property
System.ComponentModel.LicenseManager.UsageMode property
private string ServiceString()
{
if (GetService(typeof(System.ComponentModel.Design.IDesignerHost)) != null)
return "Present";
else
return "Not present";
}
public bool IsDesignerHosted
{
get
{
Control ctrl = this;
while(ctrl != null)
{
if((ctrl.Site != null) && ctrl.Site.DesignMode)
return true;
ctrl = ctrl.Parent;
}
return false;
}
}
public static bool IsInDesignMode()
{
return System.Reflection.Assembly.GetExecutingAssembly()
.Location.Contains("VisualStudio"))
}
</code></pre>
<p>To try and get a hang on the three solutions proposed, I created a little test solution - with three projects: </p>
<ul>
<li>TestApp (winforms application), </li>
<li>SubControl (dll) </li>
<li>SubSubControl (dll)</li>
</ul>
<p>I then embedded the SubSubControl in the SubControl, then one of each in the TestApp.Form.</p>
<p>This screenshot shows the result when running.
<img src="https://i.stack.imgur.com/pylfS.png" alt="Screenshot of running"></p>
<p>This screenshot shows the result with the form open in Visual Studio:</p>
<p><img src="https://i.stack.imgur.com/4cgxt.png" alt="Screenshot of not running"></p>
<p>Conclusion: It would appear that <em>without reflection</em> the only one that is reliable <em>within</em> the constructor is LicenseUsage, and the only one which is reliable <em>outside</em> the constructor is 'IsDesignedHosted' (by <a href="https://stackoverflow.com/questions/34664/designmode-with-controls/2693338#2693338">BlueRaja</a> below)</p>
<p>PS: See ToolmakerSteve's comment below (which I haven't tested): "Note that <a href="https://stackoverflow.com/a/2693338/199364">IsDesignerHosted</a> answer has been updated to include LicenseUsage..., so now the test can simply be if (IsDesignerHosted). An alternative approach is <a href="https://stackoverflow.com/a/2849244/199364">test LicenseManager in constructor and cache the result</a>."</p>
|
<p>I had to fight this problem recently in Visual Studio 2017 when using nested UserControls. I combine several of the approaches mentioned above and elsewhere, then tweaked the code until I had a decent extension method which works acceptably so far. It performs a sequence of checks, storing the result in static boolean variables so so each check is only performed at most only once at run time. The process may be overkill, but it is keeping the code from executing in studio. Hope this helps someone.</p>
<pre><code> public static class DesignTimeHelper
{
private static bool? _isAssemblyVisualStudio;
private static bool? _isLicenseDesignTime;
private static bool? _isProcessDevEnv;
private static bool? _mIsDesignerHosted;
/// <summary>
/// Property <see cref="Form.DesignMode"/> does not correctly report if a nested <see cref="UserControl"/>
/// is in design mode. InDesignMode is a corrected that property which .
/// (see https://connect.microsoft.com/VisualStudio/feedback/details/553305
/// and https://stackoverflow.com/a/2693338/238419 )
/// </summary>
public static bool InDesignMode(
this Control userControl,
string source = null)
=> IsLicenseDesignTime
|| IsProcessDevEnv
|| IsExecutingAssemblyVisualStudio
|| IsDesignerHosted(userControl);
private static bool IsExecutingAssemblyVisualStudio
=> _isAssemblyVisualStudio
?? (_isAssemblyVisualStudio = Assembly
.GetExecutingAssembly()
.Location.Contains(value: "VisualStudio"))
.Value;
private static bool IsLicenseDesignTime
=> _isLicenseDesignTime
?? (_isLicenseDesignTime = LicenseManager.UsageMode == LicenseUsageMode.Designtime)
.Value;
private static bool IsDesignerHosted(
Control control)
{
if (_mIsDesignerHosted.HasValue)
return _mIsDesignerHosted.Value;
while (control != null)
{
if (control.Site?.DesignMode == true)
{
_mIsDesignerHosted = true;
return true;
}
control = control.Parent;
}
_mIsDesignerHosted = false;
return false;
}
private static bool IsProcessDevEnv
=> _isProcessDevEnv
?? (_isProcessDevEnv = Process.GetCurrentProcess()
.ProcessName == "devenv")
.Value;
}
</code></pre>
| 5,498
|
<p>What's the most efficient way to resize large images in PHP?</p>
<p>I'm currently using the <a href="http://en.wikipedia.org/wiki/GD_Graphics_Library" rel="noreferrer">GD</a> function imagecopyresampled to take high resolution images, and cleanly resize them down to a size for web viewing (roughly 700 pixels wide by 700 pixels tall).</p>
<p>This works great on small (under 2 MB) photos and the entire resize operation takes less than a second on the server. However, the site will eventually service photographers who may be uploading images up to 10 MB in size (or images up to 5000x4000 pixels in size).</p>
<p>Doing this kind of resize operation with large images tends to increase the memory usage by a very large margin (larger images can spike the memory usage for the script past 80 MB). Is there any way to make this resize operation more efficient? Should I be using an alternate image library such as <a href="http://en.wikipedia.org/wiki/ImageMagick" rel="noreferrer">ImageMagick</a>?</p>
<p>Right now, the resize code looks something like this</p>
<pre><code>function makeThumbnail($sourcefile, $endfile, $thumbwidth, $thumbheight, $quality) {
// Takes the sourcefile (path/to/image.jpg) and makes a thumbnail from it
// and places it at endfile (path/to/thumb.jpg).
// Load image and get image size.
$img = imagecreatefromjpeg($sourcefile);
$width = imagesx( $img );
$height = imagesy( $img );
if ($width > $height) {
$newwidth = $thumbwidth;
$divisor = $width / $thumbwidth;
$newheight = floor( $height / $divisor);
} else {
$newheight = $thumbheight;
$divisor = $height / $thumbheight;
$newwidth = floor( $width / $divisor );
}
// Create a new temporary image.
$tmpimg = imagecreatetruecolor( $newwidth, $newheight );
// Copy and resize old image into new image.
imagecopyresampled( $tmpimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height );
// Save thumbnail into a file.
imagejpeg( $tmpimg, $endfile, $quality);
// release the memory
imagedestroy($tmpimg);
imagedestroy($img);
</code></pre>
|
<p>People say that ImageMagick is much faster. At best just compare both libraries and measure that.</p>
<ol>
<li>Prepare 1000 typical images.</li>
<li>Write two scripts -- one for GD, one
for ImageMagick.</li>
<li>Run both of them a few times.</li>
<li>Compare results (total execution
time, CPU and I/O usage, result
image quality).</li>
</ol>
<p>Something which the best everyone else, could not be the best for you.</p>
<p>Also, in my opinion, ImageMagick has much better API interface.</p>
|
<p>I suggest that you work something along these lines:</p>
<ol>
<li>Perform a getimagesize( ) on the uploaded file to check image type and size</li>
<li>Save any uploaded JPEG image smaller than 700x700px in to the destination folder "as-is"</li>
<li>Use GD library for medium size images (see this article for code sample: <a href="http://salman-w.blogspot.com/2008/10/resize-images-using-phpgd-library.html" rel="nofollow noreferrer">Resize Images Using PHP and GD Library</a>)</li>
<li>Use ImageMagick for large images. You can use ImageMagick in background if you prefer.</li>
</ol>
<p>To use ImageMagick in background, move the uploaded files to a temporary folder and schedule a CRON job that "convert"s all files to jpeg and resizes them accordingly. See command syntax at: <a href="http://www.imagemagick.org/script/command-line-processing.php" rel="nofollow noreferrer">imagemagick-command line processing</a></p>
<p>You can prompt the user that file is uploaded and scheduled to be processed. The CRON job could be scheduled to run daily at a specific interval. The source image could be deleted after processing to assure that an image is not processed twice.</p>
| 3,376
|
<p>I have a habit of keeping my variable usage to a bare minimum. So I'm wondering if there is any advantage to be gained by the following:</p>
<pre><code>$query = $mysqli->query('SELECT * FROM `people` ORDER BY `name` ASC LIMIT 0,30');
// Example 1
$query = $query->fetch_assoc();
// Example 2
$query_r = $query->fetch_assoc();
$query->free();
</code></pre>
<p>Now if I'm right Example 1 should be more efficient as <code>$query</code> is <code>unset</code> when I reassign it which should free any memory associated with it. However there is a method (<code>MySQLi_Result::free()</code>) which frees associated memory - is this the same thing?</p>
<p>If I don't call <code>::free()</code> to free any memory associated with the result but <code>unset</code> it by reassigning the variable am I doing the same thing? I don't know how to log this sort of thing - does anyone have some ideas?</p>
|
<p>The <a href="http://us2.php.net/manual/en/mysqli-result.free.php" rel="noreferrer">manual</a> seems to suggest that you should still be using <code>free()</code> to release the memory. I believe the reasoning is that <code>free()</code> is freeing the memory in <em>MySQL</em>, not in PHP. Since PHP can't garbage-collect for MySQL, you need to call <code>free()</code>.</p>
|
<p>Example 1 <strong>dissociates</strong> the $query variable from the MySQL result. The MySQL result still exists in memory, and will continue to exist and waste memory until garbage collection occurs.</p>
<p>Example 2 <strong>frees</strong> the MySQL result immediately, releasing the used resources.</p>
<p>However, since PHP pages are generally short-lived with small result-sets, the memory saved is trivial. You will not notice a slowdown unless you leave <strong>a ton</strong> of results in memory over a long period of time on pages that run for a long time.</p>
<p>Brian,
PHP <em>can</em> garbage collect the MySQL result, it just doesn't happen immediately.
The result lives in PHP's memory pool, not in the MySQL server's.</p>
<p>(the locality of memory when using unbuffered queries is slightly different, but they're so rarely used in PHP as to not be worth mentioning) </p>
| 4,606
|
<p>I want to 3d print my own icing smoothers, but I'm not sure if its safe to have plastic from a 3D printer in contact with cake icing. Is there any harm in this?</p>
|
<p>Only certain plastics are safe enough to be used to contain or manipulate food. ABS and PET-G are such materials. The 3d printing process however is not food safe because, it creates crevices in the printed part into which bacteria and other contaminants can cling to. A printed part would need to be coated in a silicone rubber to render the surface both inert (can't grow anything) and smooth (no crevices). Further, the type of plastic you use must be able to be sterilized in boiling water. PLA softens in boiling water. PET-G variants can as well (think clear plastic bottles). This is why most food handing utensils are either glass or stainless steel.</p>
<p>If you are going to use a 3d printing process to produce parts that are to be used for food, you also have to consider containment from the machine itself. The brass nozzle, the teflon tube, the extruder gears etc. The filament itself may not have come from the factory as clean as it would need to be to be used around food. </p>
<p>If you are able to coat the heat resistant part in silicone and you only use it a few times (ensuring that it is properly washed and sterile) then it can be used for food prep purposes.</p>
<p>There is a difference between food grade and safe for contact with food.</p>
<blockquote>
<p>Acrylonitrile/butadiene/styrene copolymer identified in this section may be safely used as an article or component of articles intended for use with all foods, except those containing alcohol, under conditions of use E, F, and G described in table 2 of 176.170(c) of this chapter.</p>
</blockquote>
<p><a href="https://www.accessdata.fda.gov/scripts/cdrh/cfdocs/cfcfr/CFRSearch.cfm?fr=177.1020" rel="nofollow noreferrer">Abstract from: https://www.accessdata.fda.gov/scripts/cdrh/cfdocs/cfcfr/CFRSearch.cfm?fr=177.1020</a></p>
|
<p>As mentioned, FDM 3D printed parts are flawed for food service and prep use regardless of the material, because of the small gaps between lines where bacteria can grow, and because your printer isn't used in a way to keep it from introducing contaminants into otherwise clean material.</p>
<p>However, there are some ways around this.</p>
<h3>Single-use</h3>
<p>I'm pretty comfortable using my printer to make items for <strong>one time use</strong>. If I wanted an icing smoother with a fancy shape for a special cake that I'm not likely to need again soon, I'd go ahead and do that. I would apply all the icing at one time, and then I'd <em>discard the piece</em>, rather than try to clean and save it. Also note that I'm not talking about a commercial kitchen; this would be for a cake I'd eat myself with friends, rather than sell.</p>
<p>The big thing I've done this way so far (I've had my printer less than a year) is make shaped cookie cutters. I'll print the cutters, use them, and then throw them away. If I want the same shape again some time, I'll re-print.</p>
<h3>Lining</h3>
<p>The other thing you can do with food prep items is print them with the intent to use liners. For example, <a href="https://www.thingiverse.com/thing:1782268" rel="nofollow noreferrer">here is a 3D-printable taco train</a>, where a train car has grooves to hold tacos (yum!). It wouldn't be good to put a taco directly in here, but you could use napkins or similar food-safe liner to separate the 3D part from the food. In the case of the icing smoother, you might be able to print the part and wrap it in aluminum foil.</p>
| 1,241
|
<p>I would like the version property of my application to be incremented for each build but I'm not sure on how to enable this functionality in Visual Studio (2005/2008). I have tried to specify the AssemblyVersion as 1.0.* but it doesn't get me exactly what I want. </p>
<p>I'm also using a settings file and in earlier attempts when the assembly version changed my settings got reset to the default since the application looked for the settings file in another directory. </p>
<p>I would like to be able to display a version number in the form of 1.1.38 so when a user finds a problem I can log the version they are using as well as tell them to upgrade if they have an old release.</p>
<p>A short explanation of how the versioning works would also be appreciated. When does the build and revision number get incremented?</p>
|
<p>With the "Built in" stuff, you can't, as using 1.0.* or 1.0.0.* will replace the revision and build numbers with a coded date/timestamp, which is usually also a good way. </p>
<p>For more info, see the <a href="http://msdn2.microsoft.com/en-us/library/c405shex(vs.80).aspx" rel="noreferrer">Assembly Linker</a> Documentation in the /v tag.</p>
<p>As for automatically incrementing numbers, use the AssemblyInfo Task:</p>
<p><a href="http://code.msdn.microsoft.com/AssemblyInfoTaskvers" rel="noreferrer">AssemblyInfo Task</a></p>
<p>This can be configured to automatically increment the build number.</p>
<p>There are 2 Gotchas:</p>
<ol>
<li>Each of the 4 numbers in the Version string is limited to 65535. This is a Windows Limitation and unlikely to get fixed.
<ul>
<li><a href="http://blogs.msdn.com/msbuild/archive/2007/01/03/why-are-build-numbers-limited-to-65535.aspx" rel="noreferrer">Why are build numbers limited to 65535?</a></li>
</ul></li>
<li>Using with with Subversion requires a small change:
<ul>
<li><a href="http://www.andrewconnell.com/blog/archive/2006/08/29/4078.aspx" rel="noreferrer">Using MSBuild to generate assembly version info at build time (including SubVersion fix)</a></li>
</ul></li>
</ol>
<p>Retrieving the Version number is then quite easy:</p>
<pre><code>Version v = Assembly.GetExecutingAssembly().GetName().Version;
string About = string.Format(CultureInfo.InvariantCulture, @"YourApp Version {0}.{1}.{2} (r{3})", v.Major, v.Minor, v.Build, v.Revision);
</code></pre>
<hr>
<p>And, to clarify: In .net or at least in C#, the build is actually the THIRD number, not the fourth one as some people (for example Delphi Developers who are used to Major.Minor.Release.Build) might expect.</p>
<p>In .net, it's Major.Minor.Build.Revision.</p>
|
<p>If you want an auto incrementing number that updates each time a compilation is done, you can use <a href="http://testdox.wordpress.com/versionupdater/" rel="nofollow noreferrer">VersionUpdater</a> from a pre-build event. Your pre-build event can check the build configuration if you prefer so that the version number will only increment for a Release build (for example).</p>
| 2,307
|
<p><strong>Before you put duplicate from this <a href="https://3dprinting.stackexchange.com/questions/147/which-are-the-food-safe-materials-and-how-do-i-recognize-them">Which are the food-safe materials and how do I recognize them?</a> please read</strong> </p>
<p>I need to know if <a href="http://store.printm3d.com/#filaments_head_scroll" rel="nofollow noreferrer">this 3D Ink™ (PLA Filament) </a>is food safe<a href="https://i.stack.imgur.com/lNh2d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lNh2d.png" alt="this "></a></p>
|
<p>In general, PLA is known as a "food safe" filament, especially <strong><em>Natural PLA</em></strong>. However, filament suppliers have different processes that may detriment the food safe quality.</p>
<p>Doing a little digging, I found <a href="https://printm3d.com/solutions/article.php?id=47" rel="noreferrer">an article on the M3D site</a> which mentions the following about their filament</p>
<blockquote>
<p>All of our products, including our filaments are made from 100% non-toxic components and considered generally safe under normal use. They are not considered a chemical, or a hazardous material by OSHA standards. Therefore, OSHA defines it as an "article" and does not require MSDS sheets. You can see more information about that here: <a href="http://www.ilpi.com/msds/faq/partb.html#article" rel="noreferrer">http://www.ilpi.com/msds/faq/partb.html#article</a></p>
</blockquote>
<p>So, without contacting M3D directly to acquire an MSDS (or asking if its food safe), you will not find one online.</p>
<p><a href="https://pinshape.com/blog/3d-printing-food-safe/" rel="noreferrer">Here</a> is an article on a few tips for printing food safe objects as well. In a nut shell, don't 3D print food handling objects with crevasses, using uranium, or intend to put in the oven (a.k.a common sense).</p>
|
<p>In general no filament is safe as the printing process leaves "nooks and cranies" between the layers where germs can gain a foothold.</p>
<p>For food safe, I would advise:</p>
<ul>
<li>print with white filament</li>
<li>use an acetone vapor bath to smooth and melt many of the "nooks and cranies" away.</li>
<li>Use a spray polyurathane and coat with 3-4 layers to reduce the evil "nooks and cranies" even more.</li>
</ul>
<p>At that point it it should be dishwasher safe and food safe.</p>
| 256
|
<p>I've got my brand new VS2008 and decided to convert my main solution from VS2005. One of the projects is a SQL2005 reporting services project. Now that I've converted I cannot load it in VS2008. Is there anyway around this? </p>
<p>My problem is that my solution is a hybrid and has websites libraries and reports in there.
Separating it out breaks the logic the solution entity.</p>
|
<p>As you have guessed, the baseAddresses element is completely ignored when hosting in IIS. The service's base address is determined by the web site & virtual directory into which your wcf service is placed.</p>
<p>Even when self-hosting, baseAddresses is not required. It is merely a convenience that avoids you having to enter a full address for each endpoint. If it is present, the endpoints can have relative addresses (relative to the base address, that is).</p>
|
<p>base address required for selfhosting. IIS/WAS hosts ignores the base address.</p>
| 8,014
|
<p>I am working with an open-source UNIX tool that is implemented in C++, and I need to change some code to get it to do what I want. I would like to make the smallest possible change in hopes of getting my patch accepted upstream. Solutions that are implementable in standard C++ and do not create more external dependencies are preferred.</p>
<p>Here is my problem. I have a C++ class -- let's call it "A" -- that currently uses fprintf() to print its heavily formatted data structures to a file pointer. In its print function, it also recursively calls the identically defined print functions of several member classes ("B" is an example). There is another class C that has a member std::string "foo" that needs to be set to the print() results of an instance of A. Think of it as a to_str() member function for A.</p>
<p>In pseudocode:</p>
<pre><code>class A {
public:
...
void print(FILE* f);
B b;
...
};
...
void A::print(FILE *f)
{
std::string s = "stuff";
fprintf(f, "some %s", s);
b.print(f);
}
class C {
...
std::string foo;
bool set_foo(std::str);
...
}
...
A a = new A();
C c = new C();
...
// wish i knew how to write A's to_str()
c.set_foo(a.to_str());
</code></pre>
<p>I should mention that C is fairly stable, but A and B (and the rest of A's dependents) are in a state of flux, so the less code changes necessary the better. The current print(FILE* F) interface also needs to be preserved. I have considered several approaches to implementing A::to_str(), each with advantages and disadvantages:</p>
<ol>
<li><p>Change the calls to fprintf() to sprintf()</p>
<ul>
<li>I wouldn't have to rewrite any format strings</li>
<li>print() could be reimplemented as: fprint(f, this.to_str());</li>
<li>But I would need to manually allocate char[]s, merge a lot of c strings , and finally convert the character array to a std::string</li>
</ul></li>
<li><p>Try to catch the results of a.print() in a string stream</p>
<ul>
<li>I would have to convert all of the format strings to << output format. There are hundreds of fprintf()s to convert :-{</li>
<li>print() would have to be rewritten because there is no standard way that I know of to create an output stream from a UNIX file handle (though <a href="http://synflood.at/blog/index.php?/archives/456-One-word-of-warning-about-stdio_filebuf.html" rel="nofollow noreferrer">this guy says it may be possible</a>).</li>
</ul></li>
<li><p>Use Boost's string <a href="http://www.boost.org/doc/libs/1_36_0/libs/format/doc/format.html" rel="nofollow noreferrer">format library</a></p>
<ul>
<li>More external dependencies. Yuck.</li>
<li>Format's syntax is different enough from printf() to be annoying: </li>
</ul>
<p>printf(format_str, args) -> cout << boost::format(format_str) % arg1 % arg2 % etc</p></li>
<li><p>Use Qt's <a href="https://doc.qt.io/qt-5/qstring.html#asprintf%3E" rel="nofollow noreferrer">QString::asprintf()</a></p>
<ul>
<li>A different external dependency.</li>
</ul></li>
</ol>
<p>So, have I exhausted all possible options? If so, which do you think is my best bet? If not, what have I overlooked?</p>
<p>Thanks.</p>
|
<p>I am using #3: the boost string format library - but I have to admit that I've never had any problem with the differences in format specifications.</p>
<p>Works like a charm for me - and the external dependencies could be worse (a very stable library)</p>
<p>Edited: adding an example how to use boost::format instead of printf:</p>
<pre><code>sprintf(buffer, "This is a string with some %s and %d numbers", "strings", 42);
</code></pre>
<p>would be something like this with the boost::format library:</p>
<pre><code>string = boost::str(boost::format("This is a string with some %s and %d numbers") %"strings" %42);
</code></pre>
<p>Hope this helps clarify the usage of boost::format </p>
<p>I've used boost::format as a sprintf / printf replacement in 4 or 5 applications (writing formatted strings to files, or custom output to logfiles) and never had problems with format differences. There may be some (more or less obscure) format specifiers which are differently - but I never had a problem.</p>
<p>In contrast I had some format specifications I couldn't really do with streams (as much as I remember)</p>
|
<p>Is this about serialization? Or printing proper?
If the former, consider boost::serialization as well. It's all about "recursive" serialization of objects and sub-object.</p>
| 9,512
|
<p>I'm trying to print a cylinder with Flashprint. Problem is, that the .stl file i created (with OpenSCAD) is totally ruined once loaded into Flashprint. With ruined I mean the round outline is now with spikes and steps everywhere. And by loaded I mean directly after loading, not even creating the .gx files. The output of OpenSCAD looks fine, also in other stl viewers I tried.</p>
<p>I figured out the problem occurs more when using certain number of fragments ($fn). If its very small, loading works better. But for numbers that make it acutally look like a round circle (eg 50), Flashprint is unable to load them correctly it seems.</p>
<p>It's obvious that its no slicing or printing problem, but simply a loading one, since the shown object (which does not look any round) also prints the way it is shown in flashprint before slicing.</p>
<p>Does someone know a way to load a cylinder with flashprint correctly, or do I have to switch to different software? I already installed some but am unfamiliar with the printer settings which I do not know in detail. I really though a cylinder should'nt be too complex for any 3D software.</p>
<p>Here is the OpenSCAD Code for Cylinder, just create .stl and load into Flashprint to reproduce the Error:</p>
<pre><code>rotate_extrude($fn=70)
translate([0, 0])
square([20,2]);
</code></pre>
<p>See also this image (tried native cylinder code, problem remains the same however):
<a href="https://i.stack.imgur.com/v6qkG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v6qkG.png" alt=""></a></p>
|
<p>From an electrical standpoint, a two-phase stepper motors (what most 3D printers use) works the same backwards and forwards, the phase just reverses. If you are stalling on only one direction, I would look to see if you have a mechanical bind in that direction. Generally a wiring issue will cause the motor to either not run at all or to run in the wrong direction.</p>
<p>A few things you can check:</p>
<ol>
<li>Decouple the motors from their mechanical load and confirm that they all run correctly when they aren't driving a load. If you can't do that, disconnect them all then connect a spare motor to each cable one-at-a-time.</li>
<li>Turn each of the axis with your hand and make sure it turns smoothly throughout the entire range in both directions. Note: Some times a binding issue is acceleration related - a loose frame or coupling can cause this.</li>
<li>Monitor the supply voltage to make sure that one of the motors is not pulling the supply down causing all the others to stall.</li>
</ol>
|
<p>Sounds like you are configured for NC switches but are using NO switches, causing them to invert their reported state. Issue a <strong>M119</strong> command and see if the endstop statuses are correct when none are triggered.</p>
| 775
|
<p>Is there any difference between a binary semaphore and mutex or are they essentially the same?</p>
|
<p>They are <strong>NOT</strong> the same thing. They are used for different purposes!<br>
While both types of semaphores have a full/empty state and use the same API, their usage is very different. </p>
<p><strong>Mutual Exclusion Semaphores</strong><br>
Mutual Exclusion semaphores are used to protect shared resources (data structure, file, etc..). </p>
<p>A Mutex semaphore is "owned" by the task that takes it. If Task B attempts to semGive a mutex currently held by Task A, Task B's call will return an error and fail.</p>
<p>Mutexes always use the following sequence: </p>
<pre>
- SemTake
- Critical Section
- SemGive</pre>
<p>Here is a simple example:</p>
<pre>
Thread A Thread B
Take Mutex
access data
... Take Mutex <== Will block
...
Give Mutex access data <== Unblocks
...
Give Mutex
</pre>
<p><strong>Binary Semaphore</strong><br>
Binary Semaphore address a totally different question: </p>
<ul>
<li>Task B is pended waiting for something to happen (a sensor being tripped for example).</li>
<li>Sensor Trips and an Interrupt Service Routine runs. It needs to notify a task of the trip.</li>
<li>Task B should run and take appropriate actions for the sensor trip. Then go back to waiting.</li>
</ul>
<pre><code>
Task A Task B
... Take BinSemaphore <== wait for something
Do Something Noteworthy
Give BinSemaphore do something <== unblocks
</code></pre>
<p>Note that with a binary semaphore, it is OK for B to take the semaphore and A to give it.<br>
Again, a binary semaphore is NOT protecting a resource from access. The act of Giving and Taking a semaphore are fundamentally decoupled.<br>
It typically makes little sense for the same task to so a give and a take on the same binary semaphore.</p>
|
<p>Almost all of the above said it right. Let me also try my bit to clarify if somebody still has a doubt.</p>
<ul>
<li>Mutex -> used for serialization</li>
<li>Semaphore-> synchronization.</li>
</ul>
<p>Purpose of both are different however, same functionality could be achieved through both of them with careful programming.</p>
<p>Standard Example-> producer consumer problem.</p>
<pre><code>initial value of SemaVar=0
Producer Consumer
--- SemaWait()->decrement SemaVar
produce data
---
SemaSignal SemaVar or SemaVar++ --->consumer unblocks as SemVar is 1 now.
</code></pre>
<p>Hope I could clarify.</p>
| 8,831
|
<p>Here's what I use:</p>
<pre><code>SELECT CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME)
</code></pre>
<p>I'm thinking there may be a better and more elegant way.</p>
<p>Requirements:</p>
<ul>
<li>It has to be as fast as possible (the less casting, the better).</li>
<li>The final result has to be a <code>datetime</code> type, not a string.</li>
</ul>
|
<p><strong>SQL Server 2008 and up</strong></p>
<p>In SQL Server 2008 and up, of course the fastest way is <code>Convert(date, @date)</code>. This can be cast back to a <code>datetime</code> or <code>datetime2</code> if necessary.</p>
<p><strong>What Is Really Best In SQL Server 2005 and Older?</strong></p>
<p>I've seen inconsistent claims about what's fastest for truncating the time from a date in SQL Server, and some people even said they did testing, but my experience has been different. So let's do some more stringent testing and let everyone have the script so if I make any mistakes people can correct me.</p>
<p><strong>Float Conversions Are Not Accurate</strong></p>
<p>First, I would stay away from converting <code>datetime</code> to <code>float</code>, because it does not convert correctly. You may get away with doing the time-removal thing accurately, but I think it's a bad idea to use it because it implicitly communicates to developers that this is a safe operation and <strong>it is not</strong>. Take a look:</p>
<pre><code>declare @d datetime;
set @d = '2010-09-12 00:00:00.003';
select Convert(datetime, Convert(float, @d));
-- result: 2010-09-12 00:00:00.000 -- oops
</code></pre>
<p>This is not something we should be teaching people in our code or in our examples online.</p>
<p>Also, it is not even the fastest way!</p>
<p><strong>Proof – Performance Testing</strong></p>
<p>If you want to perform some tests yourself to see how the different methods really do stack up, then you'll need this setup script to run the tests farther down:</p>
<pre><code>create table AllDay (Tm datetime NOT NULL CONSTRAINT PK_AllDay PRIMARY KEY CLUSTERED);
declare @d datetime;
set @d = DateDiff(Day, 0, GetDate());
insert AllDay select @d;
while @@ROWCOUNT != 0
insert AllDay
select * from (
select Tm =
DateAdd(ms, (select Max(DateDiff(ms, @d, Tm)) from AllDay) + 3, Tm)
from AllDay
) X
where Tm < DateAdd(Day, 1, @d);
exec sp_spaceused AllDay; -- 25,920,000 rows
</code></pre>
<p>Please note that this creates a 427.57 MB table in your database and will take something like 15-30 minutes to run. If your database is small and set to 10% growth it will take longer than if you size big enough first.</p>
<p>Now for the actual performance testing script. Please note that it's purposeful to not return rows back to the client as this is crazy expensive on 26 million rows and would hide the performance differences between the methods.</p>
<p><strong>Performance Results</strong></p>
<pre><code>set statistics time on;
-- (All queries are the same on io: logical reads 54712)
GO
declare
@dd date,
@d datetime,
@di int,
@df float,
@dv varchar(10);
-- Round trip back to datetime
select @d = CONVERT(date, Tm) from AllDay; -- CPU time = 21234 ms, elapsed time = 22301 ms.
select @d = CAST(Tm - 0.50000004 AS int) from AllDay; -- CPU = 23031 ms, elapsed = 24091 ms.
select @d = DATEDIFF(DAY, 0, Tm) from AllDay; -- CPU = 23782 ms, elapsed = 24818 ms.
select @d = FLOOR(CAST(Tm as float)) from AllDay; -- CPU = 36891 ms, elapsed = 38414 ms.
select @d = CONVERT(VARCHAR(8), Tm, 112) from AllDay; -- CPU = 102984 ms, elapsed = 109897 ms.
select @d = CONVERT(CHAR(8), Tm, 112) from AllDay; -- CPU = 103390 ms, elapsed = 108236 ms.
select @d = CONVERT(VARCHAR(10), Tm, 101) from AllDay; -- CPU = 123375 ms, elapsed = 135179 ms.
-- Only to another type but not back
select @dd = Tm from AllDay; -- CPU time = 19891 ms, elapsed time = 20937 ms.
select @di = CAST(Tm - 0.50000004 AS int) from AllDay; -- CPU = 21453 ms, elapsed = 23079 ms.
select @di = DATEDIFF(DAY, 0, Tm) from AllDay; -- CPU = 23218 ms, elapsed = 24700 ms
select @df = FLOOR(CAST(Tm as float)) from AllDay; -- CPU = 29312 ms, elapsed = 31101 ms.
select @dv = CONVERT(VARCHAR(8), Tm, 112) from AllDay; -- CPU = 64016 ms, elapsed = 67815 ms.
select @dv = CONVERT(CHAR(8), Tm, 112) from AllDay; -- CPU = 64297 ms, elapsed = 67987 ms.
select @dv = CONVERT(VARCHAR(10), Tm, 101) from AllDay; -- CPU = 65609 ms, elapsed = 68173 ms.
GO
set statistics time off;
</code></pre>
<p><strong>Some Rambling Analysis</strong></p>
<p>Some notes about this. First of all, if just performing a GROUP BY or a comparison, there's no need to convert back to <code>datetime</code>. So you can save some CPU by avoiding that, unless you need the final value for display purposes. You can even GROUP BY the unconverted value and put the conversion only in the SELECT clause:</p>
<pre><code>select Convert(datetime, DateDiff(dd, 0, Tm))
from (select '2010-09-12 00:00:00.003') X (Tm)
group by DateDiff(dd, 0, Tm)
</code></pre>
<p>Also, see how the numeric conversions only take slightly more time to convert back to <code>datetime</code>, but the <code>varchar</code> conversion almost doubles? This reveals the portion of the CPU that is devoted to date calculation in the queries. There are parts of the CPU usage that don't involve date calculation, and this appears to be something close to 19875 ms in the above queries. Then the conversion takes some additional amount, so if there are two conversions, that amount is used up approximately twice.</p>
<p>More examination reveals that compared to <code>Convert(, 112)</code>, the <code>Convert(, 101)</code> query has some additional CPU expense (since it uses a longer <code>varchar</code>?), because the second conversion back to <code>date</code> doesn't cost as much as the initial conversion to <code>varchar</code>, but with <code>Convert(, 112)</code> it is closer to the same 20000 ms CPU base cost.</p>
<p>Here are those calculations on the CPU time that I used for the above analysis:</p>
<pre><code> method round single base
----------- ------ ------ -----
date 21324 19891 18458
int 23031 21453 19875
datediff 23782 23218 22654
float 36891 29312 21733
varchar-112 102984 64016 25048
varchar-101 123375 65609 7843
</code></pre>
<ul>
<li><p><em>round</em> is the CPU time for a round trip back to <code>datetime</code>.</p></li>
<li><p><em>single</em> is CPU time for a single conversion to the alternate data type (the one that has the side effect of removing the time portion).</p></li>
<li><p><em>base</em> is the calculation of subtracting from <code>single</code> the difference between the two invocations: <code>single - (round - single)</code>. It's a ballpark figure that assumes the conversion to and from that data type and <code>datetime</code> is approximately the same in either direction. It appears this assumption is not perfect but is close because the values are all close to 20000 ms with only one exception.</p></li>
</ul>
<p>One more interesting thing is that the base cost is nearly equal to the single <code>Convert(date)</code> method (which has to be almost 0 cost, as the server can internally extract the integer day portion right out of the first four bytes of the <code>datetime</code> data type).</p>
<p><strong>Conclusion</strong></p>
<p>So what it looks like is that the single-direction <code>varchar</code> conversion method takes about 1.8 μs and the single-direction <code>DateDiff</code> method takes about 0.18 μs. I'm basing this on the most conservative "base CPU" time in my testing of 18458 ms total for 25,920,000 rows, so 23218 ms / 25920000 = 0.18 μs. The apparent 10x improvement seems like a lot, but it is frankly pretty small until you are dealing with hundreds of thousands of rows (617k rows = 1 second savings).</p>
<p>Even given this small absolute improvement, in my opinion, the <code>DateAdd</code> method wins because it is the best combination of performance and clarity. The answer that requires a "magic number" of <code>0.50000004</code> is going to bite someone some day (five zeroes or six???), plus it's harder to understand.</p>
<p><strong>Additional Notes</strong></p>
<p>When I get some time I'm going to change <code>0.50000004</code> to <code>'12:00:00.003'</code> and see how it does. It is converted to the same <code>datetime</code> value and I find it much easier to remember.</p>
<p>For those interested, the above tests were run on a server where @@Version returns the following:</p>
<blockquote>
<p>Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86) Jul 9 2008 14:43:34 Copyright (c) 1988-2008 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)</p>
</blockquote>
|
<p>SQL2005: I recommend cast instead of dateadd. For example,</p>
<pre><code>select cast(DATEDIFF(DAY, 0, datetimefield) as datetime)
</code></pre>
<p>averagely about 10% <em>faster</em> on my dataset, than</p>
<pre><code>select DATEADD(DAY, DATEDIFF(DAY, 0, datetimefield), 0)
</code></pre>
<p>(and casting into smalldatetime was faster still)</p>
| 2,489
|
<p>Has anybody used the MS Project Gantt chart control in C#?
If yes, can you share some resources regarding this?</p>
|
<p>You could also check <a href="http://DlhSoft.com/GanttChart" rel="nofollow noreferrer">Gantt Chart Library</a> for WPF or Windows Forms, they do not require Microsoft Project installed on the client computer, but provide similar UI for project and related Gantt Charts.</p>
|
<p>My company decided to buy the Infragistics NetAdvantage for .NET. We will be using their Gantt control.</p>
<p>Thanks for your answers.</p>
| 4,208
|
<p>If I set temperature say 220 °C, printer heats up to it and it only varies +/- 0.5 °C under non operating condition. But if I start a print, there's a shift of +/- 15 °C.</p>
<p>I've already auto tuned PID parameters and when I run <code>M503</code>, the printer shows the updated PID values.</p>
<p><a href="https://i.stack.imgur.com/w8SCE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w8SCE.png" alt="Octoprint temperature graph showing hotend temperature drops" /></a></p>
<p>What could be the reason?</p>
<p>Electronics details:</p>
<ul>
<li>Firmware used: Marlin</li>
<li>Controller board: Printrboard rev D</li>
</ul>
|
<p>There could be a number of reasons for that behaviour:</p>
<p>Please check following items:</p>
<ol>
<li>part blower/fan cools down the nozzle - stop the fan</li>
<li>material is extruded at high speed and takes the heat</li>
<li>loose thermistor (when the move occurs as it moves a bit internally) </li>
<li>the power supply unit voltage varies - so temperature reading varies as well - measure voltage and see if there are significant drops</li>
<li>nozzle heater and thermistor cables can be loose as well (check screw terminals)</li>
<li>bed heater connection cables having not a good connection (check screw terminals)</li>
</ol>
|
<p>Can you also show a "power output" graph (or something like that, which show PWD duty cycle output to the hot end)?</p>
<p>Have you noted any relation between temperature raise and fall and the printing position?</p>
<p>Looking at graph I can only suggest the heating is suddenly stops and then the same sudden resumes.
It looks like you have a loose wire connection to the heater. When head is starting to move, it makes disturbance for the wiring, so heater occasionally stops to work.
There are usual two weak points: first it is where cable is connected to the board. Check is connector heated? Are any noises/sparks from there?
Another part: it is just at the point where wires going into the hot end. If wires are not secured to the printing head, then during printing those place experiences a lot of bending, which makes it weaker over the time.</p>
| 917
|
<p>I'm trying to squeeze a little better quality out of my time lapses generated by OctoPrint.</p>
<p>I'm using the Raspberry Pi Camera Module V2 with a Pi 3. I've already edited the Octopi config to get 720p resolution, but the encoding during time lapse rendering is horrific. Blocky as hell.</p>
<p>Right now the encoding is set up at 5000k.
What am I doing wrong here?</p>
|
<p>You can learn a lot just by reading the forums. I'll just list a few that are quite popular...</p>
<p><a href="http://forums.reprap.org/" rel="nofollow">Reprap Forums</a> - Has a ton of information on DIY printers including build logs and posts dealing with many issues.</p>
<p><a href="http://www.soliforum.com" rel="nofollow">Soliforum</a> - Large user base with lots of information. Not sure what it's standing is now that Solidoodle is gone but I'm sure the forum will stick around.</p>
<p><a href="http://forum.seemecnc.com/" rel="nofollow">SeeMeCNC</a> - Support forum for SeeMeCNC, has a lot of information for Delta printers and also other printers.</p>
<p>There aren't many books that I know of...Make magazine has done a few issues on 3D printing that you could try to obtain. I'm not sure what your idea of building a printer is, do you want to design your own or follow someone's instructions and put one together? Designing one would require some basic hardware and engineering knowledge.</p>
<p>All that said, the best learning experience would be buying a kit and learning as you go. You'll never read in a book what you will learn from having your own printer.</p>
|
<p>ADDITIVE MANUFACTURING TECHNOLOGIES
3D Printing, Rapid Prototyping, and
Direct Digital Manufacturing</p>
<p>Springer</p>
<p>I think its a perfect book. A lot of details to all technologies.
*Beware there is math and physics involved.</p>
<p><a href="https://i.stack.imgur.com/52f1O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/52f1O.jpg" alt="enter image description here"></a></p>
| 272
|
<p>How can I poll disk activity in Applescript? Check to see if disk X is being read, written, or idle every N seconds and do something.</p>
|
<p>In general, polling is less efficient than being notified when something happens. Additionally, if you're checking whether something is reading from a disk, you will probably be accessing said disk yourself, possibly influencing what you're trying to observe.</p>
<p>Since 10.5, OSX includes something called the File System Events framework, which provides course-grained notifications of changes to the file system. The problem in your case is that this is Objective-C only. Apple has some nice <a href="http://developer.apple.com/documentation/Darwin/Conceptual/FSEvents_ProgGuide/" rel="nofollow noreferrer" title="FSEvents Programming Guide">documentation</a> about this API.</p>
<p>Fortunately, there is also the <code>call method</code> AppleScript command. This allows you to work with Objective-C objects from within AppleScript. Here's the <a href="http://developer.apple.com/documentation/AppleScript/Conceptual/StudioBuildingApps/chapter04/chapter_4_section_2.html#//apple_ref/doc/uid/20001251-TPXREF175" rel="nofollow noreferrer" title="call method reference">documentation</a> on that.</p>
<p>I have no experience with either, hence the documentation references. Hopefully, this should get you going.</p>
|
<p>You could run the terminal command iostat periodically. You'd have to parse the results into a form you could digest.</p>
<p>If you know enough about various UNIX command line tools, I'd suggest iostat piping the output to awk or sed to extract just the information you want.</p>
| 9,032
|
<p>All of my completed prints come out with rough edges. What are some methods for removing rough edges from 3D prints? Also, are there any ways to reduce rough edges on prints? For reference, I use a FlashForge Adventurer 3 and PLA filament.</p>
|
<ol>
<li>To remove unwanted residual material:</li>
</ol>
<ul>
<li>You can scrape with a knife</li>
<li>Use sand paper</li>
<li>use files</li>
<li>Very fine sandpaper or files can smooth out the rough surfaces left from filing or sanding.</li>
<li>Dremel tools tend to be aggressive. They tend to melt the surface if too fast. Buffing wheels are probably the most useful on a Dremel. Dremel tools are good for cutting.</li>
</ul>
<ol start="2">
<li><p>A deburring tool can remove sharp edges such as parts of the brim that don't want to come loose. However, it's not unusually to need to scrape off flat surfaces as well.</p>
</li>
<li><p>If you want to smooth out the surfaces left from layers, you can:</p>
</li>
</ol>
<ul>
<li>Carefully use a heat gun or heat from other soldering tools; not spending too long in one spot. The difficulty with using heat is most prints have fill rather than being solid; so, with only two or three outside layers, it's easy to get the surface to deform into the fill. Also the print material will tend to stick to solid surfaces hot enough to melt the material.</li>
<li>Use acetone on ABS. Don't breath the fumes or dissolve your print.</li>
<li>Paint the surface as the comment from user77232</li>
</ul>
|
<p>There are several different ways you can go about doing this</p>
<ol>
<li>You could calibrate your printer/software better that way so the slicer can make better gcode files that are best fit for you printer</li>
<li>Take a lighter to the edge and scrape everything off, this really helps for if your print gets really stringy, this balls all of the strings up and you can scrape if off</li>
<li>Use sandpaper, a file, or any type of abrasive tool to scrape the edge to get it smoother and flatter</li>
<li>Some filaments melt with acetone, so if your printing with that, this would be a good solution for you as well.</li>
</ol>
<p>Here is a good video for every type of filament: <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiy0KWuu9bwAhXyKDQIHf6iDasQwqsBMAt6BAgIEAE&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DvSwumoSlZTo&usg=AOvVaw1L7WcqmbsJ5OBhzp5CT8lH" rel="nofollow noreferrer">https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiy0KWuu9bwAhXyKDQIHf6iDasQwqsBMAt6BAgIEAE&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DvSwumoSlZTo&usg=AOvVaw1L7WcqmbsJ5OBhzp5CT8lH</a></p>
| 1,932
|
<p>The plastic glide rail on which my refrigerator vegetable drawer (bin) traveled recently broke.</p>
<p>The rail was part of a large plastic shelf, which is no longer available for purchase.</p>
<p>I'm thinking about 3D printing a new glide rail and attaching it (somehow) to the existing shelf.</p>
<p>Can 3D printing be used for this task to make the repair any easier or more successful to complete than simply cutting a piece of plastic and (again, somehow) affixing it to the shelf?</p>
<p>Note that the glide rail needs to be somehow attached to the shelf at a 90 degree angle. I keep using the word "somehow" because I haven't figured out how to make that magic happen yet.</p>
|
<blockquote>
<p>Can 3D printing be used for this task to make the repair any easier or more successful to complete than simply cutting a piece of plastic and (again, somehow) affixing it to the shelf?</p>
</blockquote>
<p><strong>Yes.</strong> 3D printed parts can be plenty strong enough to handle the kind of load you're considering. You'll need to create a 3D model of the part you want it a CAD program, which is something that takes some practice if you don't already know how to do it, so it may or may not be easier <em>for you</em> than milling the from a plastic blank.</p>
<p>One advantage that 3D printing brings with it is the ability to iterate rapidly on your design: you can model and print the part that you think will work, try it out, adjust your model to incorporate what you learn from the first try, and print new versions until you get it just right. If the existing shelf is broken in some irregular way, for example, you can design a new part that mates tightly with the broken edge of the part you have.</p>
<blockquote>
<p>The rail was part of a large plastic shelf, which is no longer available for purchase.</p>
</blockquote>
<p>Perhaps you've already looked, but there are a great many parts suppliers online. If you have the part number, be sure to look beyond just what the manufacturer can supply -- it's very likely that someone out there has the part you need.</p>
|
<p>If you have powder plastic then I believe it will be easier for you to 3D print the shelf, resulting in smooth finish and high load capacity.</p>
<p>Powder plastics offer the benefits of increased utilization rate and easy production process. Also, the excessive amount of powder can be eliminated at the finish production process and may be reused in the subsequent printing procedure. For <a href="https://www.emergenresearch.com/industry-report/3d-printing-plastic-market" rel="nofollow noreferrer">plastic powder materials</a>, powders may perform the function of supporting the part, letting added freedom and flexibility in design.</p>
| 1,782
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.