instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I'm writing a utility for myself, partly as an exercise in learning C# Reflection and partly because I actually want the resulting tool for my own use.</p> <p>What I'm after is basically pointing the application at an assembly and choosing a given class from which to select properties that should be included in an exported HTML form as fields. That form will be then used in my ASP.NET MVC app as the beginning of a View.</p> <p>As I'm using Subsonic objects for the applications where I want to use, this should be reasonable and I figured that, by wanting to include things like differing output HTML depending on data type, Reflection was the way to get this done.</p> <p>What I'm looking for, however, seems to be elusive. I'm trying to take the DLL/EXE that's chosen through the OpenFileDialog as the starting point and load it:</p> <pre><code>String FilePath = Path.GetDirectoryName(FileName); System.Reflection.Assembly o = System.Reflection.Assembly.LoadFile(FileName); </code></pre> <p>That works fine, but because Subsonic-generated objects actually are full of object types that are defined in Subsonic.dll, etc., those dependent objects aren't loaded. Enter:</p> <pre><code>AssemblyName[] ReferencedAssemblies = o.GetReferencedAssemblies(); </code></pre> <p>That, too, contains exactly what I would expect it to. However, what I'm trying to figure out is how to load those assemblies so that my digging into my objects will work properly. I understand that if those assemblies were in the GAC or in the directory of the running executable, I could just load them by their name, but that isn't likely to be the case for this use case and it's my primary use case.</p> <p>So, what it boils down to is how do I load a given assembly and all of its arbitrary assemblies starting with a filename and resulting in a completely Reflection-browsable tree of types, properties, methods, etc.</p> <p>I know that tools like Reflector do this, I just can't find the syntax for getting at it. </p>
<p>Couple of options here:</p> <ol> <li>Attach to <code>AppDomain.AssemblyResolve</code> and do another <code>LoadFile</code> based on the requested assembly.</li> <li>Spin up another <code>AppDomain</code> with the directory as its base and load the assemblies in that <code>AppDomain</code>.</li> </ol> <p>I'd highly recommend pursuing option 2, since that will likely be cleaner and allow you to unload all those assemblies after. Also, consider loading assemblies in the reflection-only context if you only need to reflect over them (see <code>Assembly.ReflectionOnlyLoad</code>).</p>
<p>I worked out <a href="https://stackoverflow.com/users/5380/kent-boogaart">Kent Boogaart</a>'s second option. Essentially I had to:</p> <p>1.) Implement the <code>ResolveEventHandler</code> in a separate class, inheriting from <code>MarshalByRefObject</code> and adding the <code>Serializable</code> attribute.</p> <p>2.) Add the current <code>ApplicationBase</code>, essentially where the event handler's dll is, to the <code>AppDomain</code> <code>PrivateBinPath</code>.</p> <p>You can find the code on <a href="https://github.com/mathume/ResolveDependencies" rel="nofollow noreferrer">github</a>.</p>
8,377
<p>I've got a table that is supposed to track days and costs for shipping product from one vendor to another. We (brilliantly :p) stored both the shipping vendors (FedEx, UPS) with the product handling vendors (Think... Dunder Mifflin) in a "VENDOR" table. So, I have three columns in my SHIPPING_DETAILS table that all reference VENDOR.no. For some reason MySQL isn't letting me define all three as foreign keys. Any ideas?</p> <pre><code>CREATE TABLE SHIPPING_GRID( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique ID for each row', shipping_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the shipping vendor (vendors_type must be 3)', start_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the vendor being shipped from', end_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to the VENDOR.no for the vendor being shipped to', shipment_duration INT(1) DEFAULT 1 COMMENT 'Duration in whole days shipment will take', price FLOAT(5,5) NOT NULL COMMENT 'Price in US dollars per shipment lbs (down to 5 decimal places)', is_flat_rate TINYINT(1) DEFAULT 0 COMMENT '1 if is flat rate regardless of weight, 0 if price is by lbs', INDEX (shipping_vendor_no), INDEX (start_vendor_no), INDEX (end_vendor_no), FOREIGN KEY (shipping_vendor_no) REFERENCES VENDOR (no), FOREIGN KEY (start_vendor_no) REFERENCES VENDOR (no), FOREIGN KEY (end_vendor_no) REFERENCES VENDOR (no) ) TYPE = INNODB; </code></pre> <p><em>Edited to remove double primary key definition...</em></p> <hr> <p>Yeah, unfortunately that didn't fix it though. Now I'm getting:</p> <blockquote> <p>Can't create table './<em>REMOVED MY DB NAME</em>/SHIPPING_GRID.frm' (errno: 150)</p> </blockquote> <p>Doing a phpinfo() tells me this for mysql:</p> <blockquote> <p>Client API version 5.0.45</p> </blockquote> <p>Yes, the VENDOR.no is type int(6).</p>
<p>You defined the primary key twice. Try:</p> <pre><code>CREATE TABLE SHIPPING_GRID( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique ID for each row', shipping_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the shipping vendor (vendors_type must be 3)', start_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the vendor being shipped from', end_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to the VENDOR.no for the vendor being shipped to', shipment_duration INT(1) DEFAULT 1 COMMENT 'Duration in whole days shipment will take', price FLOAT(5,5) NOT NULL COMMENT 'Price in US dollars per shipment lbs (down to 5 decimal places)', is_flat_rate TINYINT(1) DEFAULT 0 COMMENT '1 if is flat rate regardless of weight, 0 if price is by lbs', INDEX (shipping_vendor_no), INDEX (start_vendor_no), INDEX (end_vendor_no), FOREIGN KEY (shipping_vendor_no) REFERENCES VENDOR (no), FOREIGN KEY (start_vendor_no) REFERENCES VENDOR (no), FOREIGN KEY (end_vendor_no) REFERENCES VENDOR (no) ) TYPE = INNODB; </code></pre> <p>The VENDOR primary key must be INT(6), and both tables must be of type InnoDB.</p>
<p>I ran the code here, and the error message showed (and it is right!) that you are setting <em>id</em> field twice as primary key.</p>
2,809
<p>Has the introduction of the .net framework made raw programming in COM and DCOM redundant ? </p> <p>(Except for using some COM+ services, e.g. for transaction management through the System.EnterpriseServices namespace)</p>
<p>Not yet, because the OS is still unmanaged.</p> <p>If MS finally do what their labs have been talking about for years and produce a fully managed OS then it will.</p> <p>That OS won't be backwards compatible though. They would have to produce managed versions of Office, IE, etc first. They will have to produce a virtual machine to run unmanaged apps.</p> <p>The pain would be something similar to the move from Mac OS9 to OSX.</p>
<p>.NET has been deliberately designed to replace COM (and, consequently, DLL Hell) so while .NET applications still can access COM components, all new development are encouraged to move to .NET except if you have a very good reason to stick with COM.</p>
5,449
<p>I need to know the application's ProductCode in the Installer.OnCommitted callback. There doesn't seem to be an obvious way of determining this.</p>
<p>You can avoid hardcoding your product code, using /productCode=[ProductCode] in your CustomActionData property.</p>
<p>The MSI function MsiGetProperty can be used to get the name of the ProductCode property. I don't know if that would work in this case, since I've never created a .NET installer.</p>
8,615
<p>I'm implementing a document server. Currently, if two users open the same document, then modify it and save the changes, the document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this problem:</p> <p>The first is to lock the document when it is opened by someone the first time, and unlock it when it is closed. But if the network connection to the server is suddenly interrupted, the document would stay in a forever-locked state. The obvious solution is to send regular pings to the server. If the server doesn't receive K pings in a row (K > 1) from a particular client, documents locked by this client are unlocked. If that client re-appears, documents are locked again, if someone hadn't already locked them. This could also help if the client application (running in web browser) is terminated unexpectedly, making it impossible to send a 'quitting, unlock my documents' signal to the server.</p> <p>The second is to store multiple versions of the same document saved by different users. If changes to the document are made in rapid succession, the system would offer either to merge versions or to select a preferred version. To optimize storage space, only document diffs should be kept (just like source control software).</p> <p>What method should I choose, taking into consideration that the connection to the server might <em>sometimes</em> be slow and unresponsive? How should the parameters (ping interval, rapid succession interval) be determined?</p> <p>P.S. Unfortunately, I can't store the documents in a database.</p>
<p>My suggestion would be something like your first one. When the first user (Bob) opens the document, he acquires a lock so that other users can only read the current document. If the user saves the document while he is using it, he keeps the lock. Only when he exits the document, it is unlocked and other people can edit it. </p> <p>If the second user (Kate) opens the document while Bob has the lock on it, Kate will get a message saying the document is uneditable but she can read it until it the lock has been released.</p> <p>So what happens when Bob acquires the lock, maybe saves the document once or twice but then exits the application leaving the lock hanging? </p> <p>As you said yourself, requiring the client with the lock to send pings at a certain frequency is probably the best option. If you don't get a ping from the client for a set amount of time, this effectively means his client is not responding anymore. If this is a web application you can use javascript for the pings. The document that was last saved releases its lock and Kate can now acquire it. </p> <p>A ping can contain the name of the document that the client has a lock on, and the server can calculate when the last ping for that document was received.</p>
<p>Currently documents are published by a limited group of people, each of them working on a separate subject. So, the inconvenience introduced by locks is minimized. People mostly extend existing documents and correct mistakes in them.</p> <p>Speaking about the pessimistic model, the 'left client connected for N days' scenario could be avoided by setting lock expire date to, say, one day before lock start date. Because documents edited are by no means mission critical, and are modified by multiple users quite rarely, that could be enough.</p> <p>Now consider the optimistic model. How should the differences be detected, if the documents have some regular (say, hierarchical) structure? If not? What are the chances of successful automatic merge in these cases?</p> <p>The situation becomes more complicated, because some of the documents (edited by the 'admins' user group) contain important configuration information (document global index, user roles, etc.). To my mind, locks are more advantageous for precisely this kind of information, because it's not changed on everyday basis. So some hybrid solution might be acceptable.</p> <p>What do you think?</p>
3,107
<p>Suppose I've found a &ldquo;text&rdquo; somewhere in open access (say, on public network share). I have no means to contact the author, I even don't know who is the author.</p> <p>What can I legally do with such &ldquo;text&rdquo;?</p> <p><strong>Update:</strong> I am not going to publish that &ldquo;text&rdquo;, but rather learn from it myself.</p> <p><strong>Update:</strong> So, if I ever see an anonymous code, article, whatever, shouldn't I even open it, because otherwise I'd copy its contents to my brain?</p>
<p>IANAL: There is no license. The original author (whoever it may be) retains copyright and all the rights associated with it, and has not granted any explicit license to anyone to do anything with their work. Please do check with an actual lawyer versed in copyright, though, since it seems like there should be a way to use the text in your particular circumstances and (s)he would likely know what that way is.</p> <p>UPDATE: Copyright is chiefly concerned with (re)distribution; if you can read it, you're free to learn from it, although the <a href="http://en.wikipedia.org/wiki/Digital_Millennium_Copyright_Act" rel="nofollow noreferrer">DMCA</a> places legal restrictions on what steps you can take to be able to read it, e.g., you aren't supposed to use <a href="http://en.wikipedia.org/wiki/DeCSS" rel="nofollow noreferrer">DeCSS</a> to read subtitles since that is a "circumvention of access control".</p>
<p>As far as I <em>know</em> (without any legal training) - if you list the text or code or whathaveyou as "anonymous", you're OK. </p> <p>I believe that by listing it as anonymous you're indicating you do not know where it came from, but you're admitting you didn't create it as original work.</p> <p>Extending from that, you should be open to the actual author being able to prove they are the author, and changing your usage to reflect their name/license/copyright/whatever.</p> <p>You should check with an Intellectual Property lawyer for details and corrections to my understanding.</p>
9,623
<p>I have a project group that contains a project I'm working on as well as some related component and packages. I prefer to keep the database links active during design-time. </p> <p>I know how to write the code which would change the database file location, but in this case, I'm just using <code>".\data"</code> instead, for various design-time reasons. Unfortunately, using a relative folder means that Delphi needs to be "pointing" to the same folder that the project is in.</p> <p>I'd like to be able to force the folder location to a different root, without using the "Save As" feature. Does anyone happen to know where the Delphi IDE retrieves that info?</p>
<p>I have some projects in delphi7, Delphi2009, Delphi2010 and DelphiXE4 and also my project are not stored in my document. I force the save/default like this:</p> <p>Tools > Options > Environment Options > Default project</p> <p>for Delphi 2010 => U:\Projects\Rad Studio 2010\Projects</p>
<p>Tools -> Options -> Environment Options -> Environment Variables - BDSProjectsDir</p>
3,598
<p>How would I get the <code>here</code> and <code>and here</code> to be on the right, on the same lines as the lorem ipsums? See the following:</p> <pre class="lang-none prettyprint-override"><code>Lorem Ipsum etc........here blah....................... blah blah.................. blah....................... lorem ipsums.......and here </code></pre>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="position: relative; width: 250px;"&gt; &lt;div style="position: absolute; top: 0; right: 0; width: 100px; text-align:right;"&gt; here &lt;/div&gt; &lt;div style="position: absolute; bottom: 0; right: 0; width: 100px; text-align:right;"&gt; and here &lt;/div&gt; Lorem Ipsum etc &lt;br /&gt; blah &lt;br /&gt; blah blah &lt;br /&gt; blah &lt;br /&gt; lorem ipsums &lt;/div&gt;</code></pre> </div> </div> </p> <p>Gets you pretty close, although you may need to tweak the "top" and "bottom" values.</p>
<p>The first line would consist of 3 <code>&lt;div&gt;</code>s. One outer that contains two inner <code>&lt;div&gt;</code>s. The first inner <code>&lt;div&gt;</code> would have <code>float:left</code> which would make sure it stays to the left, the second would have <code>float:right</code>, which would stick it to the right.</p> <pre><code>&lt;div style="width:500;height:50"&gt;&lt;br&gt; &lt;div style="float:left" &gt;stuff &lt;/div&gt;&lt;br&gt; &lt;div style="float:right" &gt;stuff &lt;/div&gt; </code></pre> <p>... obviously the inline-styling isn't the best idea - but you get the point.</p> <p>2,3, and 4 would be single <code>&lt;div&gt;</code>s.</p> <p>5 would work like 1.</p>
9,129
<p>I have started printing with PETG so I can create objects that won't deform if I leave them in my car.</p> <p>My first prints look good, but have strings of material coming off the print in places.</p> <p>What should I try to prevent that? </p> <p>I haven't had this problem with PLA. </p>
<p>I've had similar experiences switching from PLA to PETG, and haven't gotten it fully figured out yet.</p> <p>From what I know so far, to reduce petg strings:</p> <ul> <li>Increase retraction</li> <li>Lower temperature</li> </ul>
<p>I've had similar experiences switching from PLA to PETG, and haven't gotten it fully figured out yet.</p> <p>From what I know so far, to reduce petg strings:</p> <ul> <li>Increase retraction</li> <li>Lower temperature</li> </ul>
671
<p>I have really strange problem. Thing is that my print (first layer) started ok, not good nor perfect but ok and everything was going well but then all of a sudden, near the end of a print, quality drops drastically. I'm not really sure but I think this happened because of under extrusion. I'm not so good with English so here are pictures of finished print and some more details.</p> <p><img src="https://imgur.com/avASUsS.jpg" alt="enter image description here"></p> <p><img src="https://i.imgur.com/wRd9e5Y.jpg" alt="enter image description here"></p> <p>I'm using custom build Delta printer with RepRap and Repetier firmware, CURA for slicing and Repetier-host for printing.</p> <p>Slicing parameters in CURA are:<br> - ABS 250&nbsp;&deg;C hotend and 70&nbsp;&deg;C heatbed<br> - Layer height 0.2&nbsp;mm (initial layer 0.18)<br> - Printing speed 50&nbsp;mm/s (30&nbsp;mm/s outer walls)<br> - Infill 40&nbsp;%<br> - Extrusion multiplayer 0.96 (96&nbsp;%) </p> <p>Do anyone have any ideas? What this can be? How can I fix this?</p>
<blockquote> <p>Do anyone have any ideas? What this can be? How can I fix this?</p> </blockquote> <p>At least judging from the pictures, that <em>does</em> seem like under-extrusion. Some ideas for further investigating the issue.</p> <p><strong>The problem may be due to the gcode being wrong</strong>. In this case, your printer is merely executing correctly... the wrong commands. To check if this is the case:</p> <ul> <li>The easiest, but inconclusive way, would be to re-slice a model that fails <em>consistently</em>, with a different slicer. If the second print came out good, than you would know that the problem is with the slicer. This method is <em>inconclusive</em> because you wouldn't not if the gcode is bad or if it simply happens that your printer cannot print well that specific sequence of commands (which may still be emitted by the other slicer under different conditions).</li> <li>The more conclusive analysis would be to look at the gcode of a failed print where the fail happens between two geometrical identical layers. This seem to be the case for the print in the picture, btw. You should then compare the gcode of the layer that printed good with that of the layer that printed poorly. If the gcode differs... then you positively know the slicer doesn't work as it should.</li> </ul> <p><strong>The problem may be due to a mechanical fault with the printer</strong>. Here the only idea I have to offer is overheating of the steppers and/or their controllers. This may in turn make the extruder servo skip some steps and therefore extrude less filament. If you perform the conclusive test above, you will know if this is the case.</p> <p><strong>The problem may be due to a firmware bug</strong>. This is difficult to investigate, my only suggestion would be: upgrade to the latest and greatest, if you haven't done it already.</p> <p><strong>The problem may be filament-related</strong>. This could be a number of things, but since the problem seems to happen at towards the end of the print, and your are printing at relatively high temp, an idea could be that too much heat reaches the cold end of the extruder, interfering with its extrusion. The easiest test here would simply be to re-print a failed print with a different filament. In your case I would suggest some PLA, just to decrease the temperature and change the chemical composition too.</p> <p>These are more or less all shots in the dark, but - together with asking here - it would be what I would do to debug, had I the same problem. Keep up posted! :)</p>
<p>You can try to reduce your retractions (try setting it to half what it is now and try again)</p> <p>If your retraction is too big you can pull hot plastic into the cold area of the hotend and create a partial clog - this happened to me yesterday when I tried to intentionally print with way too much retraction to make demonstration photos for the retraction test model I uploaded to thingiverse.</p> <p><em>note/disclaimer: that model I talked about above is <a href="https://www.thingiverse.com/thing:2753088" rel="nofollow noreferrer">here</a>, I'm the author of that model</em></p>
786
<p>As part of a larger web-app (using CakePHP), I'm putting together a simple blog system. The relationships are exceedingly simple: each User has a Blog, which has many Entries, which have many Comments.</p> <p>An element I'd like to incorporate is a list of "Popular Entries." Popular Entries have been defined as those with the most Comments in the last month, and ultimately they need to be ordered by the number of recent Comments.</p> <p>Ideally, I'd like the solution to stay within Cake's Model data-retrieval apparatus (<code>Model-&gt;find()</code>, etc.), but I'm not sanguine about this.</p> <p>Anyone have a clever/elegant solution? I'm steeling myself for some wild SQL hacking to make this work...</p>
<p>Heh, I was just about to come back with essentially the same answer (using Cake's Model::find):</p> <pre><code>$this-&gt;loadModel('Comment'); $this-&gt;Comment-&gt;find( 'all', array( 'fields' =&gt; array('COUNT(Comment.id) AS popularCount'), 'conditions' =&gt; array( 'Comment.created &gt;' =&gt; strtotime('-1 month') ), 'group' =&gt; 'Comment.blog_post_id', 'order' =&gt; 'popularCount DESC', 'contain' =&gt; array( 'Entry' =&gt; array( 'fields' =&gt; array( 'Entry.title' ) ) ) )); </code></pre> <p>It's not perfect, but it works and can be improved on.</p> <p>I made an additional improvement, using the Containable behaviour to extract the Entry data instead of the Comment data.</p>
<p>You probably want a <strong>WHERE</strong> clause to get just last 30 days comments:</p> <pre><code>SELECT entry-id, count(id) AS c FROM comment WHERE comment_date + 30 &gt;= sysdate GROUP BY entry-id ORDER BY c DESC </code></pre>
7,612
<p>Does anyone know of a web based IDE (Like VS, Eclipse, IDEA)?</p> <p>Besides <a href="http://ecco.sourceforge.net/" rel="noreferrer">ECCO</a>?</p>
<p><a href="http://shiftedit.net/" rel="noreferrer">ShiftEdit Web Based IDE</a></p>
<p>Try <a href="http://phpanywhere.net" rel="nofollow noreferrer">PHPAnywhere.net</a></p>
6,217
<p>I'm trying to use “rusage” statistics in my program to get data similar to that of the <a href="http://en.wikipedia.org/wiki/Time_%28Unix%29" rel="nofollow noreferrer">time</a> tool. However, I'm pretty sure that I'm doing something wrong. The values seem about right but can be a bit weird at times. I didn't find good resources online. Does somebody know how to do it better?</p> <p>Sorry for the long code.</p> <pre><code>class StopWatch { public: void start() { getrusage(RUSAGE_SELF, &amp;m_begin); gettimeofday(&amp;m_tmbegin, 0); } void stop() { getrusage(RUSAGE_SELF, &amp;m_end); gettimeofday(&amp;m_tmend, 0); timeval_sub(m_end.ru_utime, m_begin.ru_utime, m_diff.ru_utime); timeval_sub(m_end.ru_stime, m_begin.ru_stime, m_diff.ru_stime); timeval_sub(m_tmend, m_tmbegin, m_tmdiff); } void printf(std::ostream&amp; out) const { using namespace std; timeval const&amp; utime = m_diff.ru_utime; timeval const&amp; stime = m_diff.ru_stime; format_time(out, utime); out &lt;&lt; "u "; format_time(out, stime); out &lt;&lt; "s "; format_time(out, m_tmdiff); } private: rusage m_begin; rusage m_end; rusage m_diff; timeval m_tmbegin; timeval m_tmend; timeval m_tmdiff; static void timeval_add(timeval const&amp; a, timeval const&amp; b, timeval&amp; ret) { ret.tv_usec = a.tv_usec + b.tv_usec; ret.tv_sec = a.tv_sec + b.tv_sec; if (ret.tv_usec &gt; 999999) { ret.tv_usec -= 1000000; ++ret.tv_sec; } } static void timeval_sub(timeval const&amp; a, timeval const&amp; b, timeval&amp; ret) { ret.tv_usec = a.tv_usec - b.tv_usec; ret.tv_sec = a.tv_sec - b.tv_sec; if (a.tv_usec &lt; b.tv_usec) { ret.tv_usec += 1000000; --ret.tv_sec; } } static void format_time(std::ostream&amp; out, timeval const&amp; tv) { using namespace std; long usec = tv.tv_usec; while (usec &gt;= 1000) usec /= 10; out &lt;&lt; tv.tv_sec &lt;&lt; '.' &lt;&lt; setw(3) &lt;&lt; setfill('0') &lt;&lt; usec; } }; // class StopWatch </code></pre>
<p>What is the purpose of:</p> <pre><code>while (usec &gt;= 1000) usec /= 10; </code></pre> <p>I gather that you want the most significant three digits of the usec; in that case, the most straightforward way I can think of is to divide usec by 1000, and be done with that.</p> <p>Test cases:</p> <ul> <li>999999 ⇒ 999</li> <li>99999 ⇒ 999 (should be 099)</li> <li>9999 ⇒ 999 (should be 009)</li> <li>999 ⇒ 999 (should be 000)</li> </ul>
<p>I think there's probably a bug somewhere in your composition of sec and usec. I can't really say what exactly without knowing the kinds of errors you're seeing. A rough guess would be that usec can never be > 999999, so you're relying on overflow to know when to adjust sec. It could also just be a problem with your duration output format.</p> <p>Anyway. Why not store the utime and stime components as float seconds rather than trying to build your own rusage on output? I'm pretty sure the following will give you proper seconds. </p> <pre><code>static int timeval_diff_ms(timeval const&amp; end, timeval const&amp; start) { int micro_seconds = (end.tv_sec - start.tv_sec) * 1000000 + end.tv_usec - start.tv_usec; return micro_seconds; } static float timeval_diff(timeval const&amp; end, timeval const&amp; start) { return (timeval_diff_ms(end, start)/1000000.0f); } </code></pre> <p>If you want to decompose this back into an rusage, you can always int-div and modulo.</p>
4,395
<p>Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them <strong>ALL THE TIME</strong>.</p> <p>I am pretty sure this is grounded in some historical context where this was once the case. Now, I'm not advocating that Stored Procs are not needed, but I want to know in what cases stored procedures are necessary in modern databases such as MySQL, SQL Server, Oracle, or &lt;<em>Insert_your_DB_here</em>&gt;. Is it overkill to have ALL access through stored procedures?</p>
<blockquote> <p><strong>NOTE</strong> that this is a general look at stored procedures not regulated to a specific DBMS. Some DBMS (and even, different versions of the same DBMS!) may operate contrary to this, so you'll want to double-check with your target DBMS before assuming all of this still holds.</p> <p>I've been a Sybase ASE, MySQL, and SQL Server DBA on-and off since for almost a decade (along with application development in C, PHP, PL/SQL, C#.NET, and Ruby). So, I have no particular axe to grind in this (sometimes) holy war.</p> </blockquote> <p>The historical performance benefit of stored procs have generally been from the following (in no particular order):</p> <ul> <li>Pre-parsed SQL</li> <li>Pre-generated query execution plan</li> <li>Reduced network latency</li> <li>Potential cache benefits</li> </ul> <p><strong>Pre-parsed SQL</strong> -- similar benefits to compiled vs. interpreted code, except on a very micro level. </p> <p><em>Still an advantage?</em> Not very noticeable at all on the modern CPU, but if you are sending a single SQL statement that is VERY large eleventy-billion times a second, the parsing overhead can add up.</p> <p><strong>Pre-generated query execution plan</strong>. If you have many JOINs the permutations can grow quite unmanageable (modern optimizers have limits and cut-offs for performance reasons). It is not unknown for very complicated SQL to have distinct, measurable (I've seen a complicated query take 10+ seconds just to generate a plan, before we tweaked the DBMS) latencies due to the optimizer trying to figure out the "near best" execution plan. Stored procedures will, generally, store this in memory so you can avoid this overhead.</p> <p><em>Still an advantage?</em> Most DBMS' (the latest editions) will cache the query plans for INDIVIDUAL SQL statements, greatly reducing the performance differential between stored procs and ad hoc SQL. There are some caveats and cases in which this isn't the case, so you'll need to test on your target DBMS.</p> <p>Also, more and more DBMS allow you to provide optimizer path plans (abstract query plans) to significantly reduce optimization time (for both ad hoc and stored procedure SQL!!).</p> <blockquote> <p><strong>WARNING</strong> Cached query plans are not a performance panacea. Occasionally the query plan that is generated is sub-optimal. For example, if you send <code>SELECT * FROM table WHERE id BETWEEN 1 AND 99999999</code>, the DBMS may select a full-table scan instead of an index scan because you're grabbing every row in the table (so sayeth the statistics). If this is the cached version, then you can get poor performance when you later send <code>SELECT * FROM table WHERE id BETWEEN 1 AND 2</code>. The reasoning behind this is outside the scope of this posting, but for further reading see: <a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/frcqupln.mspx" rel="noreferrer">http://www.microsoft.com/technet/prodtechnol/sql/2005/frcqupln.mspx</a> and <a href="http://msdn.microsoft.com/en-us/library/ms181055.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms181055.aspx</a> and <a href="http://www.simple-talk.com/sql/performance/execution-plan-basics/" rel="noreferrer">http://www.simple-talk.com/sql/performance/execution-plan-basics/</a></p> <p>"In summary, they determined that supplying anything other than the common values when a compile or recompile was performed resulted in the optimizer compiling and caching the query plan for that particular value. Yet, when that query plan was reused for subsequent executions of the same query for the common values (‘M’, ‘R’, or ‘T’), it resulted in sub-optimal performance. This sub-optimal performance problem existed until the query was recompiled. At that point, based on the @P1 parameter value supplied, the query might or might not have a performance problem."</p> </blockquote> <p><strong>Reduced network latency</strong> A) If you are running the same SQL over and over -- and the SQL adds up to many KB of code -- replacing that with a simple "exec foobar" can really add up. B) Stored procs can be used to move procedural code into the DBMS. This saves shuffling large amounts of data off to the client only to have it send a trickle of info back (or none at all!). Analogous to doing a JOIN in the DBMS vs. in your code (everyone's favorite WTF!)</p> <p><em>Still an advantage?</em> A) Modern 1Gb (and 10Gb and up!) Ethernet really make this negligible. B) Depends on how saturated your network is -- why shove several megabytes of data back and forth for no good reason?</p> <p><strong>Potential cache benefits</strong> Performing server-side transforms of data can potentially be faster if you have sufficient memory on the DBMS and the data you need is in memory of the server.</p> <p><em>Still an advantage?</em> Unless your app has shared memory access to DBMS data, the edge will always be to stored procs.</p> <p>Of course, no discussion of Stored Procedure optimization would be complete without a discussion of parameterized and ad hoc SQL.</p> <p><strong>Parameterized / Prepared SQL</strong><br> Kind of a cross between stored procedures and ad hoc SQL, they are embedded SQL statements in a host language that uses "parameters" for query values, e.g.:</p> <pre><code>SELECT .. FROM yourtable WHERE foo = ? AND bar = ? </code></pre> <p>These provide a more generalized version of a query that modern-day optimizers can use to cache (and re-use) the query execution plan, resulting in much of the performance benefit of stored procedures.</p> <p><strong>Ad Hoc SQL</strong> Just open a console window to your DBMS and type in a SQL statement. In the past, these were the "worst" performers (on average) since the DBMS had no way of pre-optimizing the queries as in the parameterized/stored proc method.</p> <p><em>Still a disadvantage?</em> Not necessarily. Most DBMS have the ability to "abstract" ad hoc SQL into parameterized versions -- thus more or less negating the difference between the two. Some do this implicitly or must be enabled with a command setting (SQL server: <a href="http://msdn.microsoft.com/en-us/library/ms175037.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms175037.aspx</a> , Oracle: <a href="http://www.praetoriate.com/oracle_tips_cursor_sharing.htm" rel="noreferrer">http://www.praetoriate.com/oracle_tips_cursor_sharing.htm</a>).</p> <p><strong>Lessons learned?</strong> Moore's law continues to march on and DBMS optimizers, with every release, get more sophisticated. Sure, you can place every single silly teeny SQL statement inside a stored proc, but just know that the programmers working on optimizers are very smart and are continually looking for ways to improve performance. Eventually (if it's not here already) ad hoc SQL performance will become indistinguishable (on average!) from stored procedure performance, so any sort of <em>massive</em> stored procedure use ** solely for "performance reasons"** sure sounds like premature optimization to me.</p> <p>Anyway, I think if you avoid the edge cases and have fairly vanilla SQL, you won't notice a difference between ad hoc and stored procedures.</p>
<p>Reduced network traffic -- SP are generally worse then Dynamic SQL. Because people don't create a new SP for every select, if you need just one column you are told use the SP that has the columns they need and ignore the rest. Get an extra column and any less network usage you had just went away. Also you tend to have a lot of client filtering when SP are used.</p> <p>caching -- MS-SQL does not treat them any differently, not since MS-SQL 2000 may of been 7 but I don't remember.</p> <p>permissions -- Not a problem since almost everything I do is web or have some middle application tier that does all the database access. The only software I work with that have direct client to database access are 3rd party products that are designed for users to have direct access and are based around giving users permissions. And yes MS-SQL permission security model SUCKS!!! (have not spent time on 2008 yet) As a final part to this would like to see a survey of how many people are still doing direct client/server programming vs web and middle application server programming; and if they are doing large projects why no ORM.</p> <p>Separation -- people would question why you are putting business logic outside of middle tier. Also if you are looking to separate data handling code there are ways of doing that without putting it in the database.</p> <p>Ability to edit -- What you have no testing and version control you have to worry about? Also only a problem with client/server, in the web world not problem.</p> <p>Find the table -- Only if you can identify the SP that use it, will stick with the tools of the version control system, agent ransack or visual studio to find.</p> <p>Optimization -- Your DBA should be using the tools of the database to find the queries that need optimization. Database can tell the DBA what statements are talking up the most time and resources and they can fix from there. For complex SQL statements the programmers should be told to talk to the DBA if simple selects don't worry about it.</p> <p>SQL injection attacks -- SP offer no better protection. The only thing they get the nod is that most of them teach using parameters vs dynamic SQL most examples ignore parameters.</p>
8,464
<p>We are migrating our works repository so I want to do a cull of all the unreferenced files that exist in the source tree before moving it into the nice fresh (empty) repository.</p> <p>So far I have gone through by hand and found all the unreferenced files that I know about but I want to find out if I have caught them all. One way would be to manually move the project file by file to a new folder and see what sticks when compiling. That will take all week, so I need an automated tool.</p> <p>What do people suggest?</p> <p>Clarifications:<br> 1) It is C++.<br> 2) The files are mixed. I am looking for files that have been superseded by others but have left to rot in the repository - for instance file_iter.h is not referenced by any other file in the program but remains in the repository just in case someone wants to compile a version from 1996! Now we are moving to a fresh repository we can safely junk all the files that are no longer used.<br> 3) Lint only finds unused includes - not unused files (I have the 7.5 manual in front of me).</p>
<p>You've tagged this post with <strong>c++</strong>, so I'm assuming that's the language in question. If that's the only thing that's in the repository then it shouldn't be too hard to grep all files in the repository for each filename to give you a good starting point. If the repository contains other files (metadata, support files, resources, etc) then you're probably going to need to do it manually.</p>
<p>A static source code analysis tool like lint might do the job. They will tell you if a piece of code will never be called.</p>
7,465
<p>Ok, so my method in my webservice requires a type to be passed, it is called in the ServiceMethod property of the AutoCompleteExtender, I am fuzzy about how I should do that so I called it like this:</p> <pre><code>ServiceMethod="DropDownLoad&lt;&lt;%=(typeof)subCategory%&gt;&gt;" </code></pre> <p>where subCategory is a page property that looks like this:</p> <pre><code>protected SubCategory subCategory { get { var subCategory = NHibernateObjectHelper.LoadDataObject&lt;SubCategory&gt;(Convert.ToInt32(Request.QueryString["SCID"])); return subCategory; } } </code></pre>
<p>I dont' think calling a Generic Method on a webservice is possible.</p> <p>If you look at the service description of two identical methods, one generic, one not:</p> <pre><code>[WebMethod] public string[] GetSearchList(string prefixText, int count) { } [WebMethod] public string[] GetSearchList2&lt;T&gt;(string prefixText, int count) { } </code></pre> <p>They are identical. It appears that both SOAP 1.x and HTTP POST do not allow this type of operation.</p>
<p>I dont' think calling a Generic Method on a webservice is possible.</p> <p>If you look at the service description of two identical methods, one generic, one not:</p> <pre><code>[WebMethod] public string[] GetSearchList(string prefixText, int count) { } [WebMethod] public string[] GetSearchList2&lt;T&gt;(string prefixText, int count) { } </code></pre> <p>They are identical. It appears that both SOAP 1.x and HTTP POST do not allow this type of operation.</p>
6,651
<p>Recently (in 2017) there was <a href="https://m.box.com/shared_item/https%3A%2F%2Fumich.box.com%2Fs%2Fn9cvs27ckehdr64gzv5igtmboykymgk6" rel="nofollow noreferrer">a paper</a> that got some publicity by researchers who are using a B spline algorithm to reduce vibrations in 3D printers. But before them, a B Spline implementation seems to have been first been made open-source by an alias named DeepSoic <a href="https://hackaday.io/project/7045-splinetravel" rel="nofollow noreferrer">here</a>. I would like to be able to print faster using the method described in the <a href="https://3dprint.com/195734/um-update-algorithm/" rel="nofollow noreferrer">research paper</a>, through post-processing G-code. I'm pretty sure these two sources use basically the same technique but I could be misunderstanding things.</p> <p>Basically instead of stopping and starting for travel moves, speed changes are done in a curvy fashion, so the head never stops and the printer never shakes. This makes the print smoother and also faster. I think printing 10 times faster is something that is really awesome once you try it. Laser cutting relies on cubic splines for a different reason; to create curves in space. But it seems like these techniques are doing something unique to to 3D printing -- using them to adjust head acceleration/de-acceleration to create smoother movement arcs of the print head. Since laser cutters have a constant head movement, this technique wouldn't help them much.</p> <p>The downside seems to be that it makes way more G-code commands, overloading the USB port, since it's sending all the points on a curve so quickly. I'm assuming a smart person today would really only use it through an SD card (which has disadvantages) or if they bought a 3D printer with a free Wi-Fi module thrown in (which also has disadvantages). Maybe a high baud rate helps.</p> <p>I was wondering if there are any more established ways to use this obviously extremely important and beneficial and simple algorithm. Initially I was thinking that this is obviously something that should be added as a checkbox in a slicer, and not something to be implemented in Marlin. But after writing this post I realized that a Marlin implementation would allow you to use this technique over USB, but only if the slicer steedleaders are also using its special G-codes for this optimization. I don't care if it's a post-processing technique like the research paper's or a special Marlin-friendly version, I just want to use this technique even if I have to use this Huawei Wi-Fi module.</p> <p>Basically I would like to know the best way to get started using this technique through a slicer or other software.</p> <hr /> <p>I think there is a miscommunication between users of CNC laser cutters and users of 3D printers. In laser cutting the arcs are used to define the path of the cut, which would be equivalent to filament extrusion. In laser cutting, the motion of the laser itself is constant. But in 3D printing, arcs can be used to smooth the speed of the printhead as it moves across the perimeter, and then to infill. It is using arcs for controlling the head well which isn't a problem in laser cutting. Since it's about the head movement, and not the model itself, I don't see how the STL file really matters.</p> <p>It's really about using an arc to set head speed (a first derivative of position). Not anything about the shape of the model (which would just be position). At least that's my interpretation.</p> <p>The Wi-Fi module is interesting because it receives an IP address from my router, then my router stops listing it as a connected device. But it still connected, because I can access it wirelessly. I am going to look into it more once I can fix some other problems with this dual-head. But so far there's a reason to think it might be backdoored.</p>
<p><em>I would have liked to answer linking to credible official sources, but I cannot add references either on direct B-spline printing. So I'm writing down my thoughts. I've familiarized myself in B-splines to understand what they are and read into the 2 references given by the OP.</em></p> <hr /> <p>Basically, the printer software only allows printing of straight lines. Yes I know we can give orders to the printer to print a curve (using <code>G2</code> or <code>G3</code>), but these eventually will be converted to printing straight lines. There is no ready made printer firmware available to print cubic curves directly to my knowledge. If it would be possible, these curves should eventually be translated into smaller straight lines by the firmware of timed stepper rotational output. These extra calculations would demand a considerable effort of the printer board processor, most probably far more an 8-bit processor would be able to handle.</p> <p>Comparing the <a href="https://m.box.com/shared_item/https%3A%2F%2Fumich.box.com%2Fs%2Fn9cvs27ckehdr64gzv5igtmboykymgk6" rel="nofollow noreferrer">paper released in 2017</a> to the <a href="https://hackaday.io/project/7045-splinetravel" rel="nofollow noreferrer">G-code pre-processing software</a> reveals that although both seem to refer to B-spline techniques, they are implemented differently. For example, the pre-processing software aims to reduce the linear travel moves by replacing these with B-spline curves (and not affect the actual print object), while the paper focuses on the optimization of the actual printing curves being optimized by B-spline curves (also using a pre-processor). Both eventually would need to create a multitude of small straight lines to have the printer be able to actually print the object as there is no 3D printing firmware solution to print curves. Do note that the method in the paper has been <a href="https://3dprint.com/195734/um-update-algorithm/" rel="nofollow noreferrer">questioned by the RepRap community</a>, which demonstrated that they could print the same object way faster than the B-spline optimized example. Furthermore, do note that the Marlin community is probably moving in that direction as can be seen from e.g. <a href="https://github.com/MarlinFirmware/Marlin/issues/8308" rel="nofollow noreferrer">this feature request</a> and <a href="http://marlinfw.org/meta/gcode/" rel="nofollow noreferrer">this G-code meta overview</a>; G-code instruction <code>G5</code>.</p> <p>So, both methods rely on pre-processing G-codes by identification of sliced coordinate (print) moves, translation into Bézier/B-spline curves for (print) moves, which eventually are translated into normal <code>G0/G1</code> (print) moves. It does not appear that the Marlin community/developers are aiming to implement Bézier or B-spline curves soon. This implies that if you want to pursuit printing B-splines, you need to make your own pre-processor, or dive into Marlin C++ development; an 8-bit based printer board would not be sufficient indeed like the OP mentioned, up-scaling to 32-bit or interfacing with USB might be the only solution.</p>
<p>In more practical terms, you could design the part so that the corners are rounded (also known as fillets). This will help keep the print head moving and would prevent the sudden stop and start effect that causes "jerking". Further 8 bit controllers tend to get saturated when reading large amounts of g-code from the sd card or the serial port. Upgrading to a 32 bit controller will prevent that kind of jerking.</p> <p>Both of these methods pale in comparison to just speeding up the print. Upgrading the hardware to be faster (various methods exist) would yield more of a reduced time than trying to optimize the g-code (in my humble opinion). Delta printers have the potential to be the fastest type of FDM printer, assuming that you could get the filament to melt fast enough.</p>
1,401
<p>I'm developing a Linux application that has its own file format. I want my app to open when you double-click on those files.</p> <p>How can I register a file extension and associate it with my application on Linux? I'm looking for a way that is standard (works with GNOME and KDE based systems) and can be done automatic when my program is installed or run for the first time.</p>
<p>Use <code>xdg-utils</code> from <a href="http://portland.freedesktop.org/wiki/" rel="noreferrer">freedesktop.org Portland</a>.</p> <p>Register the icon for the MIME type:</p> <pre class="lang-sh prettyprint-override"><code>xdg-icon-resource install --context mimetypes --size 48 myicon-file-type.png x-application-mytype </code></pre> <p>Create a configuration file (<a href="http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html" rel="noreferrer">freedesktop Shared MIME documentation</a>):</p> <pre><code>&lt;?xml version=&quot;1.0&quot;?&gt; &lt;mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'&gt; &lt;mime-type type=&quot;application/x-mytype&quot;&gt; &lt;comment&gt;A witty comment&lt;/comment&gt; &lt;comment xml:lang=&quot;it&quot;&gt;Uno Commento&lt;/comment&gt; &lt;glob pattern=&quot;*.myapp&quot;/&gt; &lt;/mime-type&gt; &lt;/mime-info&gt; </code></pre> <p>Install the configuration file:</p> <pre class="lang-sh prettyprint-override"><code>xdg-mime install mytype-mime.xml </code></pre> <p>This gets your files recognized and associated with an icon. <a href="http://portland.freedesktop.org/xdg-utils-1.0/xdg-mime.html" rel="noreferrer"><code>xdg-mime default</code></a> can be used for associating an application with the MIME type after you get a <a href="http://portland.freedesktop.org/xdg-utils-1.0/xdg-desktop-menu.html" rel="noreferrer"><code>.desktop</code></a> file installed.</p>
<p>This is all existing answers combined, completed and corrected into a single bash script.</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/bash set -e # stop on error APP=my-app EXT=my-app COMMENT=Comment EXEC=/usr/bin/my-app LOGO=./logo.png xdg-icon-resource install --context mimetypes --size 48 $LOGO application-x-$APP echo &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt; &lt;mime-info xmlns=\&quot;http://www.freedesktop.org/standards/shared-mime-info\&quot;&gt; &lt;mime-type type=\&quot;application/x-$APP\&quot;&gt; &lt;comment&gt;$COMMENT&lt;/comment&gt; &lt;icon name=\&quot;application-x-$APP\&quot;/&gt; &lt;glob pattern=\&quot;*.$EXT\&quot;/&gt; &lt;/mime-type&gt; &lt;/mime-info&gt;&quot; &gt; $APP-mime.xml xdg-mime install $APP-mime.xml rm $APP-mime.xml update-mime-database $HOME/.local/share/mime echo &quot;[Desktop Entry] Name=$APP Exec=$EXEC %U MimeType=application/x-$APP Icon=application-x-$APP Terminal=false Type=Application Categories= Comment=$COMMENT &quot;&gt; $APP.desktop desktop-file-install --dir=$HOME/.local/share/applications $APP.desktop rm $APP.desktop update-desktop-database $HOME/.local/share/applications xdg-mime default $APP.desktop application/x-$APP </code></pre>
5,078
<p>How can I correctly clean the lacquer from bed printer?</p> <p>I have used some ethylic alcohol (ethanol) to help cleaning</p> <p>But what is the best way to do it?</p> <p><img src="https://i.stack.imgur.com/56zTH.jpg" alt="enter image description here"></p>
<p>The Ender 3 does not come with a lacquered surface at all.The bed should have a rough build surface that is a clone of the BuildTak build surface. It is <em>intended</em> to be rough and satin-gloss in its native state. I do not remember if there was a thin protective plastic foil on my Ender-3 bed on delivery, but if there was, it should have been removed during assembly.</p> <p>A BuildTak surface can be easily cleaned with isopropyl or ethyl alcohol of grease and fingerprints. The odd discoloration at the edges seems to be a layer of grease and dust, which can be easily cleaned away by soaking it in Isopropyl alcohol and then wiped with a microfiber cloth.</p> <p>If the bed surface is destroyed by chipping holes into it, sanding it or otherwise ruining it (like melting plastic rap into it), you will need to replace it. Replacement surfaces come about 5 bucks on Amazon. Doing this, you might find <a href="https://3dprinting.stackexchange.com/questions/7960/how-to-clean-up-my-buildpate-for-a-new-build-surface">How to clean up my buildpate for a new build surface?</a> helpful.</p>
<p>The "lacquer" you are referring to is assumed to be the discoloured parts of the heat bed, not the original surface layer of the heat bed. The discoloured parts of the heatbed are most probably caused by residue build-up.</p> <p>If this residue build-up is caused by depositing a print adhesive containing PolyVinylPyrrolidone (glue stick ingredient) or PolyVinylAcetate (hairspray or 3D print spray ingredient), you can simply wash is of with water using a wet hand-warm towel or a sponge. Both constituents are dissolvable in water.</p> <p>I do this frequently on non-removable aluminium heat beds (using moist kitchen towel) or removable glass bed (rinse off in the sink).</p>
1,516
<p>In Visual Studio 2005, whenever I would view a file in the main editor, the Solution Explorer would find and highlight that file. Some time ago, this stopped working and the Solution Explorer would do nothing.</p> <p>This has become quite a pain since following a chain of "Go To Definition"s can lead you all over your solution. Where is the setting to turn this back on?</p>
<p>Click on the Tools → Options menu. Select the Projects and Solutions → General option page.</p> <p>Make sure "Track active item in Solution Explorer" is checked. That should do it.</p>
<p>Tools->Options->Project and Solutions->General</p> <p>Check the box "Track Active Item in Solution Explorer"</p>
5,107
<p>I have a library that reads/writes to a USB-device using CreateFile() API. The device happens to implement the HID-device profile, such that it's compatible with Microsoft's HID class driver.</p> <p>Some other application installed on the system is opening the device in read/write mode with no share mode. Which prevents my library (and anything that consumes it) from working with the device. I suppose that's the rub with being an HID-compatible device -- other driver software (mice, controllers, PHIDGETS, etc) can be uncooperative. </p> <p>Anyway, the device file path is of the form: </p> <pre> 1: "\\?\hid#hpqremhiddevice&col01#5&21ff20e7&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". 2: "\\?\hid#vid_045e&pid_0023#7&34aa9ece&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". 3: "\?\hid#vid_056a&pid_00b0&col01#6&5b05f29&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". </pre> <p>And I'm trying to open it using code, like:</p> <pre><code>// First, open it with minimum permissions, this device may not be ours. // we'll re-open it later in read/write hid_device_ref = CreateFile( device_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); </code></pre> <p>I've considered a tool like FileMon or Process Monitor from SysInternals. But I can't seem to get it to report usage on device file handles like the one listed above.</p>
<p>Have you tried the tool called <a href="http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx" rel="nofollow noreferrer">handle</a> from sysinternals?</p> <p>Anyway, neither windows does this (display the name of the application that locked the device): when you try to eject an USB device, Windows just says that the device is currently in use and cannot be remove right now.</p>
<p>Cool - I'll try those options, as they're probably better defaults given my intentions. Unfortunately, I know my device is there and I'll eventually need read/write access later on (once I inspect the descriptors and have verifed it is infact my device).</p> <p>Which means that my real goal IS to know what's using it, so I can inform the customer/user: &quot;Hey man, 'iexplore.exe' is currently using your SuperWidget device. You'll have to close that down in order to use SuperWidget application.&quot; (if not at the application-level, then at least at the phone support level.)</p> <p>I forgot to mention that the windows error reported by GetLastError() is:</p> <blockquote> <p>0x20. The process cannot access the file because it is being used by another process.</p> </blockquote> <p>(So your sharing alternatives will probably get the file open, assuming no FILE_SHARE_NONE on behalf of the other process).</p> <p>[edit]</p> <blockquote> <p>Yeah, it's painful alright. I have seen mice and keyboards get locked by whatever Windows uses to read from them. I've also seen a lot of people have trouble inside a VM like Paralells on OS X, where the HID class driver has the device open exclusively preventing the VM from using standard USB requests.</p> <p>I've seen some code that recreates what <em>ProcessMonitor</em> does. Maybe SysInternals is just electing to ignore device handles, but the same method (or a slight variation) can be employed here to determine the PID.</p> <p><strong>Mike</strong></p> </blockquote>
4,319
<p>There are several types of objects in a system, and each has it's own table in the database. A user should be able to comment on any of them. How would you design the comments table(s)? I can think of a few options:</p> <ol> <li>One comments table, with a FK column for each object type (ObjectAID, ObjectBID, etc)</li> <li>Several comments tables, one for each object type (ObjectAComments, ObjectBComments, etc)</li> <li>One generic FK (ParentObjectID) with another column to indicate the type ("ObjectA")</li> </ol> <p>Which would you choose? Is there a better method I'm not thinking of?</p>
<p>@palmsey</p> <p>Pretty much, but the variation on that pattern that I've seen most often gets rid of <code>ObjectAID</code> et al. <code>ParentID</code> becomes both the PK and the FK to <code>Parents</code>. That gets you something like:</p> <ul> <li><p><code>Parents</code></p> <ul> <li><code>ParentID</code></li> </ul></li> <li><p><code>ObjectA</code></p> <ul> <li><code>ParentID</code> (FK and PK)</li> <li><code>ColumnFromA NOT NULL</code></li> </ul></li> <li><p><code>ObjectB</code></p> <ul> <li><code>ParentID</code> (FK and PK)</li> <li><code>ColumnFromB NOT NULL</code></li> </ul></li> </ul> <p><code>Comments</code> would remain the same. Then you just need to constrain ID generation so that you don't accidentally wind up with an <code>ObjectA</code> row and an <code>ObjectB</code> row that both point to the same <code>Parents</code> row; the easiest way to do that is to use the same sequence (or whatever) that you're using for <code>Parents</code> for <code>ObjectA</code> and <code>ObjectB</code>.</p> <p>You also see a lot of schemas with something like:</p> <ul> <li><code>Parents</code> <ul> <li><code>ID</code></li> <li><code>SubclassDiscriminator</code></li> <li><code>ColumnFromA (nullable)</code></li> <li><code>ColumnFromB (nullable)</code></li> </ul></li> </ul> <p>and <code>Comments</code> would remain unchanged. But now you can't enforce all of your business constraints (the subclasses' properties are all nullable) without writing triggers or doing it at a different layer.</p>
<p>@Hank Gay</p> <p>So something like:</p> <ol> <li>ObjectA <ul> <li>ObjectAID</li> <li>ParentID</li> </ul></li> <li>ObjectB <ul> <li>ObjectBID</li> <li>ParentID</li> </ul></li> <li>Comments <ul> <li>CommentID</li> <li>ParentID</li> </ul></li> <li>Parents <ul> <li>ParentID</li> </ul></li> </ol>
6,110
<p>I'm looking for a good way to enumerate all the Video codecs on a Windows XP/Vista machine.</p> <p>I need present the user with a set of video codecs, including the compressors and decompressors. The output would look something like</p> <pre> Available Decoders DiVX Version 6.0 XVID Motion JPEG CompanyX's MPEG-2 Decoder Windows Media Video **Available Encoders** DiVX Version 6.0 Windows Media Video </pre> <p>The problem that I am running into is that there is no reliable way to to capture all of the decoders available to the system. For instance:</p> <ol> <li>You can enumerate all the decompressors using DirectShow, but this tells you nothing about the compressors (encoders).</li> <li>You can enumerate all the Video For Windows components, but you get no indication if these are encoders or decoders.</li> <li>There are DirectShow filters that may do the job for you perfectly well (Motion JPEG filter for example), but there is no indication that a particular DirectShow filter is a "video decoder".</li> </ol> <p>Has anyone found a generalizes solution for this problem using any of the Windows APIs? Does the Windows Vista <a href="http://en.wikipedia.org/wiki/Media_Foundation" rel="nofollow noreferrer">Media Foundation API</a> solve any of these issues?</p>
<p>This is best handled by DirectShow.</p> <p>DirectShow is currently a part of the platform SDK.</p> <pre><code>HRESULT extractFriendlyName( IMoniker* pMk, std::wstring&amp; str ) { assert( pMk != 0 ); IPropertyBag* pBag = 0; HRESULT hr = pMk-&gt;BindToStorage(0, 0, IID_IPropertyBag, (void **)&amp;pBag ); if( FAILED( hr ) || pBag == 0 ) { return hr; } VARIANT var; var.vt = VT_BSTR; hr = pBag-&gt;Read(L"FriendlyName", &amp;var, NULL); if( SUCCEEDED( hr ) &amp;&amp; var.bstrVal != 0 ) { str = reinterpret_cast&lt;wchar_t*&gt;( var.bstrVal ); SysFreeString(var.bstrVal); } pBag-&gt;Release(); return hr; } HRESULT enumerateDShowFilterList( const CLSID&amp; category ) { HRESULT rval = S_OK; HRESULT hr; ICreateDevEnum* pCreateDevEnum = 0; // volatile, will be destroyed at the end hr = ::CoCreateInstance( CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, reinterpret_cast&lt;void**&gt;( &amp;pCreateDevEnum ) ); assert( SUCCEEDED( hr ) &amp;&amp; pCreateDevEnum != 0 ); if( FAILED( hr ) || pCreateDevEnum == 0 ) { return hr; } IEnumMoniker* pEm = 0; hr = pCreateDevEnum-&gt;CreateClassEnumerator( category, &amp;pEm, 0 ); // If hr == S_FALSE, no error is occured. In this case pEm is NULL, because // a filter does not exist e.g no video capture devives are connected to // the computer or no codecs are installed. assert( SUCCEEDED( hr ) &amp;&amp; ((hr == S_OK &amp;&amp; pEm != 0 ) || hr == S_FALSE) ); if( FAILED( hr ) ) { pCreateDevEnum-&gt;Release(); return hr; } if( hr == S_OK &amp;&amp; pEm != 0 ) // In this case pEm is != NULL { pEm-&gt;Reset(); ULONG cFetched; IMoniker* pM = 0; while( pEm-&gt;Next(1, &amp;pM, &amp;cFetched) == S_OK &amp;&amp; pM != 0 ) { std::wstring str; if( SUCCEEDED( extractFriendlyName( pM, str ) ) { // str contains the friendly name of the filter // pM-&gt;BindToObject creates the filter std::wcout &lt;&lt; str &lt;&lt; std::endl; } pM-&gt;Release(); } pEm-&gt;Release(); } pCreateDevEnum-&gt;Release(); return rval; } </code></pre> <p>The following call enumerates all video compressors to the console :</p> <pre><code>enumerateDShowFilterList( CLSID_VideoCompressorCategory ); </code></pre> <p>The MSDN page <a href="http://msdn.microsoft.com/en-us/library/ms783347(VS.85).aspx" rel="noreferrer">Filter Categories</a> lists all other 'official' categories.</p> <p>I hope that is a good starting point for you.</p>
<p>Another point I forgot.</p> <p>The Windows Media Foundation is a toolkit for using WMV/WMA. It does not provide all things that DirectShow supports. It is really only a SDK for Windows Media. There are bindings in WMV/WMA to DirectShow, so that you can use WM* files/streams in DirectShow applications.</p>
5,041
<p>If you are working in PHP (or I guess any programming language) and using subversion as your source control, is there a way to take your project (for example):</p> <blockquote> <p>C:\Projects\test\.svn<br> C:\Projects\test\docs\<br> C:\Projects\test\faq.php<br> C:\Projects\test\guestbook.php<br> C:\Projects\test\index.php<br> C:\Projects\test\test.php</p> </blockquote> <p>and build/copy/whatever it so it weeds out certain files and becomes:</p> <blockquote> <p>C:\Projects\test\faq.php<br> C:\Projects\test\guestbook.php<br> C:\Projects\test\index.php</p> </blockquote> <p>automatically? I'm getting tired of making a branch, and then going through the branch and deleting all of the ".svn" folders, the docs directory, and my prototyping files.</p> <p>I know I could probably use a .bat file to only copy the specific files I want, but I was hoping there was some way with subversion to sort of pseudo ignore a file, to where it will still version it, but where you could make a snapshot of the project that ignores the files you told it to pseudo ignore.</p> <p>I know I read online somewhere about some functionality that at least lets you copy without the .svn folders, but I can't find it now.</p>
<p>If you use TortoiseSVN, you can use the export feature to automatically strip out all of the .svn files. I think other svn things have the same feature.</p> <p>Right click the root project folder, then select <code>TortoiseSVN &gt; Export</code>, and tell it where you want the <code>.svn</code> free directory.</p>
<p>Ok, so my final solution is this:</p> <p>Use the export command to export to a folder called "export" in the same directory as a file called "deploy.bat", then I run the deploy script (v1 stands for version 1, which is what version I am currently on in this project) This script utilizes 7-Zip, which I have placed on my system path so I can use it as a command line utility:</p> <pre><code>rem replace the v1 directory with the export directory rd /s /q v1 move /y export\newIMS v1 rd /s /q export rem remove the prepDocs directory from the project rd /s /q v1\prepDocs rem remove the scripts directory from the project rd /s /q v1\scripts rem remove individual files from project del v1\.project rem del v1\inc\testLoad.html rem del v1\inc\testInc.js SET /P version=Please enter version number: rem zip the file up with 7-Zip and name it after whatever version number the user typed in. 7z a -r v%version%.zip v1 rem copy everything to the shared space ready for deployment xcopy v%version%.zip /s /q /y /i "Z:\IT\IT Security\IT Projects\IMS\v%version%.zip" xcopy v1 /s /q /y /i "Z:\IT\IT Security\IT Projects\IMS\currentVersion" rem keep the window open until user presses any key PAUSE </code></pre> <p>I didn't have time to check out the SyncToy solution, so don't take this as me rejecting that method. I just knew how to do this, and didn't have time to check that one out (under a time crunch right now).</p> <p>Sources:</p> <p><a href="http://commandwindows.com/command2.htm" rel="nofollow noreferrer">http://commandwindows.com/command2.htm</a><br> <a href="http://www.ss64.com/nt/" rel="nofollow noreferrer">http://www.ss64.com/nt/</a></p>
2,771
<p>An instance of class A instantiates a couple of other objects, say for example from class B:</p> <pre><code>$foo = new B(); </code></pre> <p>I would like to access A's public class variables from methods within B.</p> <p>Unless I'm missing something, the only way to do this is to pass the current object to the instances of B:</p> <pre><code>$foo = new B($this); </code></pre> <p>Is this best practice or is there another way to do this?</p>
<p>That looks fine to me, I tend to use a rule of thumb of "would someone maintaining this understand it?" and that's an easily understood solution.</p> <p>If there's only one "A", you could consider using the registry pattern, see for example <a href="http://www.phppatterns.com/docs/design/the_registry" rel="nofollow noreferrer">http://www.phppatterns.com/docs/design/the_registry</a></p>
<p>Similar to what Paul said, if there's only one A, you can implement that as a singleton. You can then pass the instance of A as an argument to the constructor (aggregation), with a setter method (essentially aggregation again), or you can set this relationship directly in the constructor (composition).</p> <p>However, while singletons are powerful, be wary of implementing them with composition. It's nice to think that you can do it that way and get rid of a constructor argument, but it also makes it impossible to replace A with something else without a code rewrite. Peronsally, I'd stick with aggregation, even if using a singleton</p> <pre><code>$foo = new B( A::getInstance() ); </code></pre>
8,758
<p>I am getting back into a bit more .NET after a few-years of not using it full-time and am wondering what the good unit testing packages are these days.</p> <p>I'm familiar with NUnit (a few years ago) and have played briefly around with <a href="https://en.wikipedia.org/wiki/IronRuby" rel="nofollow noreferrer">IronRuby</a>, with the goal of getting something like <a href="https://en.wikipedia.org/wiki/RSpec" rel="nofollow noreferrer">RSpec</a> going, but I don't know much beyond that.</p> <p>I realize I could google for this and call it a day, but I believe I'm likely to get a better and more informed response from asking a question here :-)</p> <p>Suggestions?</p>
<p>There are so many it's crazy. Crazy good, I guess.</p> <ul> <li>For the conservative types (me), <a href="http://www.nunit.org/" rel="nofollow noreferrer"><strong>NUnit</strong></a> is still available and still more than capable.</li> <li>For the Microsoft-types, <a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx" rel="nofollow noreferrer"><strong>MSTest</strong></a> is adequate, but it is slow and clunky compared to NUnit. It also lacks code coverage without paying the big bucks for the pricey versions of Visual Studio.</li> <li>There's also <a href="http://www.mbunit.com/About.aspx" rel="nofollow noreferrer"><strong>MbUnit</strong></a>. It's like NUnit, but it has nifty features like RowTest (run the same test with different parameters) and Rollback (put the database back like you found it after a test).</li> <li>And finally, <a href="http://www.codeplex.com/xunit" rel="nofollow noreferrer"><strong>xUnit.net</strong></a> is the trendy option with some attitude.</li> <li>Oh, and <a href="http://testdriven.net/" rel="nofollow noreferrer"><strong>TestDriven.NET</strong></a> will give you IDE integration for both NUnit and MbUnit.</li> </ul> <p>I'm sure they're all just fine. I'd steer away from MSTest though, unless you just enjoy the convenience of having everything in one IDE out of the box.</p> <p><a href="http://www.hanselminutes.com/default.aspx?showID=130" rel="nofollow noreferrer">Scott Hanselman</a> has a podcast on this very topic.</p>
<p>I like <a href="http://www.mbunit.com/" rel="nofollow noreferrer">MbUnit</a>, er, <a href="http://www.gallio.org/" rel="nofollow noreferrer">Gallio</a>. Most importantly to me is having good tools support inside Visual Studio. For that I use <a href="http://www.jetbrains.com/resharper/index.html" rel="nofollow noreferrer">Resharper</a>, which has an <a href="http://code.google.com/p/mbunit-resharper/" rel="nofollow noreferrer">MbUnit test runner</a>. A lot of folks seem to like <a href="http://www.testdriven.net/overview.aspx" rel="nofollow noreferrer">TestDriven.NET</a> as their test runner as well.</p>
2,406
<p>What is the best solution for converting WAV files to WMA (and vice versa) in C#? I have actually implemented this once already using the Windows Media Encoder SDK, but having to distribute Windows Media Encoder with my application is cumbersome to say the least. The Windows Media Format SDK has large sections of the API marked as deprecated. It looks like there might be some DirectX Media Objects (DMOs) I could use from the Windows SDK, but there would be an awful lot of interop to write.</p> <p>I am wondering if there perhaps is a good managed wrapper for an unmanaged library that can perform the conversions. It would need a license that allows it to be distributed as part of a closed source commercial application.</p>
<p>I haven't tried it personally (so not sure if it's the 'best' solution), but <a href="http://www.codeproject.com/KB/audio-video/WmaCompressor.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/audio-video/WmaCompressor.aspx</a> looks like it should meet your requirements...</p>
<p>You might look at <a href="http://www.mitov.com" rel="nofollow noreferrer">www.mitov.com</a>. There are some libraries there that may help. You'll need to buy a copy to ship in a commercial product, I believe, but I think it's a reasonable price.</p>
8,984
<p>I need to send hundreds of newsletters, but would like to check first if email exists on server. It's called <a href="http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol" rel="noreferrer">SMTP</a> validation, at least I think so, based on my research on Internet. </p> <p>There's several libraries that can do that, and also a page with open-source code in <a href="http://en.wikipedia.org/wiki/Active_Server_Pages" rel="noreferrer">ASP Classic</a> (<a href="http://www.coveryourasp.com/ValidateEmail.asp#Result3" rel="noreferrer">http://www.coveryourasp.com/ValidateEmail.asp#Result3</a>), but I have hard time reading ASP Classic, and it seems that it uses some third-party library... </p> <p>Is there some code for SMTP validation in C#, and/or general explanation of how it works?</p>
<p>Be aware that most MTAs (Mail Transfer Agent) will have the VRFY command turned off for spam protection reasons, they'll probably even block you if you try several RCPT TO in a row (see <a href="http://www.spamresource.com/2007/01/whatever-happened-to-vrfy.html" rel="noreferrer">http://www.spamresource.com/2007/01/whatever-happened-to-vrfy.html</a>). So even if you find a library to do that verification, it won't be worth a lot. Ishmaeel is right, the only way to really find out, is sending an email and see if it bounces or not.</p> <p>@Hrvoje: Yes, I'm suggesting you monitor rejected emails. BUT: not all the bounced mails should automatically end up on your "does not exist"-list, you also have to differentiate between temporary (e.g. mailbox full) and permanent errors.</p>
<p>You may need this <a href="http://www.componentsoft.net/component/emailvalidator.net/" rel="nofollow noreferrer">Email Validator component for .NET</a></p> <p>Here is the code example:</p> <pre><code> // Create a new instance of the EmailValidator class. EmailValidator em = new EmailValidator(); em.MessageLogging += em_MessageLogging; em.EmailValidated += em_EmailValidationCompleted; try { string[] list = new string[3] { "test1@testdomain.com", "test2@testdomain.com", "test3@testdomain.com" }; em.ValidateEmails(list); } catch (EmailValidatorException exc2) { Console.WriteLine("EmailValidatorException: " + exc2.Message); } </code></pre>
4,707
<p>I have two otherwise-identical machines (called &quot;Lefty&quot; and &quot;Righty&quot;), so I have a baseline to compare. I am running Marlin 2.0.7.2 on both machines. They are Creality CR-10 printers with BTT SKR e3 Mini v1.2 boards, with Marlin I compiled myself. Both machines are (as far as I know!) running the same exact firmware binary.</p> <p>When running <strong>the same G-code</strong> on both printers, Lefty prints fine. But, Righty fires the plastic through -- I need to set the flow rate to 50 % (!) to be correct. I have checked the esteps, both are identical at 415, and this produces 39.5 mm of 40 mm commanded when bumped through 1 mm at a time via the extrusion menu, even on Righty. The XY movement on both machines is 100 % correct.</p> <p>Volumetric extrusion is disabled in the firmware on both machines, and disabled in the slicer. Both machines are running TMC2209 drivers, set to Spread Spectrum at 650 mA for the extruder. Both machines are set to 1250 accel. The steppers are rated for 1 A, and they are not skipping steps.</p> <p>The machines were working side-by-side perfectly until I killed Righty's stepper driver with static, and replaced the board. No other hardware was modified.</p> <p>Why do both machines behave the same with identical G-code, until extrusion moves? Why does Righty try and extrude nearly double what it should be, only during printing, when Lefty works perfectly?</p>
<p>Annoyingly, this went away with a replacement board. I don't have a better fix.</p>
<p>For both machines did you compare extruder's (E) steps/mm setting in Marlin and possibly stored in EPROM (so check from the LCD in Configuration&gt;Advanced settings) ?</p> <p>Also stepper motors ... I believe they are exactly of the same type? There are 1.8 degree and 0.9 degree stepper motors on the market - so exactly doubled flow could be related to rotation. Also the stepper driver board may be configured for mcrostepping (<a href="https://www.creality.com/blog-detail/10-v2-vs-cr-10-tmc2208-moto-driver-silence-print" rel="nofollow noreferrer">e.g. full steps agains half steps</a>), and this may equally influence the behavior. (I do not have CR-10, so I cannot advice in more details.)</p>
1,821
<p>I'm writing an application that on some stage performs low-level disk operations in Linux environment. The app actually consists of 2 parts, one runs on Windows and interacts with a user and another is a linux part that runs from a LiveCD. User makes a choice of Windows drive letters and then a linux part performs actions with corresponding partitions. The problem is finding a match between a Windows drive letter (like C:) and a linux device name (like /dev/sda1). This is my current solution that I rate as ugly:</p> <ul> <li><p>store partitions information (i.e. drive letter, number of blocks, drive serial number etc.) in Windows in some pre-defined place (i.e. the root of the system partition).</p></li> <li><p>read a list of partitions from /proc/partitions. Get only those partitions that has major number for SCSI or IDE hard drives and minor number that identifies them as real partitions and not the whole disks.</p></li> <li><p>Try to mount each of them with either ntfs or vfat file systems. Check whether the mounted partition contains the information stored by Windows app.</p></li> <li><p>Upon finding the required information written by the Windows app make the actual match. For each partition found in /proc/partitions acquire drive serial number (via HDIO_GET_IDENTITY syscall), number of blocks (from /proc/partitions) and drive offset (/sys/blocks/drive_path/partition_name/start), compare this to the Windows information and if this matches - store a Windows drive letter along with a linux device name. </p></li> </ul> <p>There are a couple of problems in this scheme:</p> <ul> <li><p>This is ugly. Writing data in Windows and then reading it in Linux makes testing a nightmare.</p></li> <li><p>linux device major number is compared only with IDE or SCSI devices. This would probably fail, i.e. on USB or FireWire disks. It's possible to add these types of disks, but limiting the app to only known subset of possible devices seems to be rather bad idea.</p></li> <li><p>looks like HDIO_GET_IDENTITY works only on IDE and SATA drives.</p></li> <li><p>/sys/block hack may not work on other than IDE or SATA drives.</p></li> </ul> <p>Any ideas on how to improve this schema? Perhaps there is another way to determine windows names without writing all the data in windows app?</p> <p>P.S. The language of the app is C++. I can't change this.</p>
<p>Partitions have UUIDs associated with them. I don't know how to find these in Windows but in linux you can find the UUID for each partition with:</p> <blockquote> <p>sudo vol_id -u device (e.g. /dev/sda1)</p> </blockquote> <p>If there is an equivilent function in Windows you could simply store the UUIDs for whatever partition they pick then iterate through all known partitions in linux and match the UUIDs.</p> <p><strong>Edit:</strong> This may be a linux-only thing, and it may speficially be the volid util that generates these from something (instead of reading off meta-data for the drive). Having said that, there is nothing stopping you getting the source for volid and checking out what it does.</p>
<p>You need to either mark the drive in some way (e.g. write a file etc.), or find some identifier that is only associated with that particular drive.</p> <p>It is very hard, almost impossible to figure out what letter Windows would assign to a particular drive partition, without actually running Windows. This is because Windows always associates the drive that it is run from with C:. Which could be any drive, if you have more than one operating system installed. Windows also allows you to choose what drive letter it will try first, for a specific partition, causing further problems.</p> <p>It would be a whole lot easier to do the GUI stuff inside Linux, than to try this mixed Window/Linux solution. I'm not say don't try it this way, what I am saying is there are very many possible pitfalls with this approach. I'm sure I don't even know about all of them.</p> <p>Another option would be to see if you could actually do the Linux part, inside of Windows. If you are a very good Windows programmer, you can actually get access to the raw file-system. There are probably just as many pitfalls with this approach, because Windows will be running while all of this is in operation.</p> <p>So to re-iterate I would see if you could do everything from within Linux, if you can. It's just a whole lot simpler in the long run.</p>
3,948
<p>I maintain an ms-access application splitted to frontend and backend files. The frontend file is in the users conputers. The backend file is in a shared folder in the server.</p> <p>What is the lowest permissions required? can I give some of the users only read-only permissions in that folder? (or hide it from them in some other way) but still enable them to view the data?</p> <p>How should I give the best security to the data file and to the folder containing it?</p>
<p>Unfortunately, the lock file (ldb) must be created, updated and deleted. If a user with insufficient permissions opens the database, it will be locked for all other users, therefore all your users need Read/Write/Delete permissions on the back-end.</p> <p>EDIT #1 The lock file must be created every time the database is opened, this includes via linked tables, and deleted when the database is closed. If a lock file exits and the database is closed, it indicates a problem has occurred. You will also run into problems with compact and repair if it is run with insufficient permissions.</p> <p>Edit #2 Security for Access is quite a large subject and depends to a great extent on your environment and requirements, for the back-end, it ranges from a database password, which is tissue thin, but quite suitable for most offices, to Access security, which can be complicated and has been dropped in 2007. Here is a link <a href="http://support.microsoft.com/kb/207793" rel="nofollow noreferrer">http://support.microsoft.com/kb/207793</a> for a download for the Microsoft Access Security FAQ for versions &lt; 2007. Information on security for 2007 can be found here <a href="http://www.microsoft.com/technet/security/guidance/clientsecurity/2007office/default.mspx" rel="nofollow noreferrer">http://www.microsoft.com/technet/security/guidance/clientsecurity/2007office/default.mspx</a>.</p>
<p>Yes - it resolves down to file access permissions as well as read/write. You can't execute any type of data update stuff (you'll get "operation requires an updateable query") unless the user supplies credentials that allow them to write, or you allow write on the file.</p> <p>Running a query requires only read access.</p>
9,532
<p>I have been looking at getting some painters tape to use on the glass plate for better print adhesion, and everything I read suggests the <em>blue</em> painters tape, such as this:</p> <p><a href="https://i.stack.imgur.com/WNCHm.jpg" rel="noreferrer" title="Blue painters tape"><img src="https://i.stack.imgur.com/WNCHm.jpg" alt="Blue painters tape" title="Blue painters tape"></a></p> <p>However, this white tape is considerably cheaper:</p> <p><a href="https://i.stack.imgur.com/Kp92s.jpg" rel="noreferrer" title="White painters tape"><img src="https://i.stack.imgur.com/Kp92s.jpg" alt="White painters tape" title="White painters tape"></a></p> <p>This looks like normal masking tape to me.</p> <p>Is masking tape ok, or is the blue painter's tape preferable? If the latter, then why is that so? What is so special about the blue tape? Is it a different material?</p>
<h1>read first</h1> <p>When you use painters tape, you need to level your printer <strong>with</strong> the tape applied. You need to relevel if you change the tape type.</p> <h1>Basics</h1> <p>It's not <em>any</em> blue tape that printers love. There are basically two factors that make a tape useful:</p> <ul> <li>It has to stick during printing.</li> <li>Its surface has to allow the filament to stick to it.</li> </ul> <p>Let's look at some <a href="https://www.youtube.com/watch?time_continue=2&amp;v=GIEaOdKVCO8" rel="nofollow noreferrer">different tapes</a> and their suitability - from my own experience.</p> <h2>ScotchBlue</h2> <p>The <em>original</em> blue tape is actually <a href="https://www.scotchblue.com/3M/en_US/scotchblue/" rel="nofollow noreferrer">ScotchBlue</a> for delicate surfaces by 3M. It has a good surface to stick to and at the same time an adhesive that does not degrade to unsuitability by heating. The delicate surface one is just as good as the all surfaces type. But don't use the outdoor type, it is sealed too much.</p> <h2>FrogTape</h2> <p><a href="https://www.frogtape.com/" rel="nofollow noreferrer">FrogTape</a> has an adhesive that has no problems with heating, the surface is sometimes a little smoother. Its green variant is about as useful as ScotchBlue, while the yellow variant is easier to remove - which can be an issue when the printhead is not calibrated correctly.</p> <h2>Generic painters tape</h2> <p><em>Generic</em> painters tape is a can of worms - there are so many different ones it is hard to describe. I have had very good off-yellow rolls from the dollar store of the 'fine surface' type - as in the tape had a fine surface - and their adhesive was good and didn't degrade too much under heat. The followup roll was a little thinner of material and released under heat so it can be a hit and miss - it's ok for starting out though.</p> <p>I also tried a roll of UHU painters tape of the <em>easy remove</em> type and it was <em>horrible</em>, as it didn't want to stick after the nozzle went over it once even on an unheated bed.</p> <h2>Generic blue colored tape</h2> <p>I even tried two blue colored tapes from different dollar/hobby stores. One was ok-ish and had a similar result as the good dollar store tape in look, but left a blue shadow on the base of the print after two or three prints. The other was showing similar behavior to other mild-adhesive/easy peel tapes.</p> <h2>Conclusion</h2> <p>It's not <em>color</em> that matters, it is the <em>formulation</em>. If you must use blue tape, spend the extra bucks for quality. Some bloggers <a href="https://3dprinting-blog.com/61-trying-out-different-kinds-of-tapes-for-3d-printing-on/" rel="nofollow noreferrer">compared other tapes</a>, tested <a href="http://www.3dprinterprices.net/kapton-tape-vs-blue-painters-tape/" rel="nofollow noreferrer">ScotchBlue vs Kapton</a>, <a href="https://all3dp.com/2/3d-printer-tape-the-best-tape-for-better-adhesion/" rel="nofollow noreferrer">discussed the benefits of either</a>, <a href="http://www.desiquintans.com/bluetape" rel="nofollow noreferrer">discussed the ScotchBlue tape in depth</a>.</p> <p>While in general, I prefer to print on the surface of my (blue) BuildTak (clone), I occasionally whip out painters tape on an unheated surface for very delicate prints: I remove the print together with the tape from the surface, which allows better handling. Sacrificing a layer of tape only costs some cents after all while breaking a print is hours and filament for much more money wasted.</p>
<p>The second image isn't exactly painter's tape. Both images are types of masking tape, but the common manila/cream-colored masking tape vs the blue or green painter's tape <em>typically</em> has three features that make it less desirable for bed adhesion:</p> <ol> <li>Stronger glue holding the tape to the bed, that will make it harder to change later.</li> <li>Narrower strips, so it's harder and takes longer to place the tape on the bed.</li> <li>Thicker, softer material. This is <em>good</em> for filament adhesion, but bad for separating from the filament after the print and accurately leveling the bed.</li> </ol> <p>Again: those are only typical arrangements. You can get blue painters tape at the same narrow width as manila masking tape, and you can get wider or thin manila tape. It's more a matter of what you'll commonly find for sale, and in all probability the manila/cream-colored tape will work just fine.</p>
1,318
<p>How can I get <a href="http://search.cpan.org/perldoc?LWP" rel="noreferrer">LWP</a> to verify that the certificate of the server I'm connecting to is signed by a trusted authority and issued to the correct host? As far as I can tell, it doesn't even check that the certificate claims to be for the hostname I'm connecting to. That seems like a major security hole (especially with the recent DNS vulnerabilities).</p> <p><strong>Update:</strong> It turns out what I really wanted was <code>HTTPS_CA_DIR</code>, because I don't have a ca-bundle.crt. But <code>HTTPS_CA_DIR=/usr/share/ca-certificates/</code> did the trick. I'm marking the answer as accepted anyway, because it was close enough.</p> <p><strong>Update 2:</strong> It turns out that <code>HTTPS_CA_DIR</code> and <code>HTTPS_CA_FILE</code> only apply if you're using Net::SSL as the underlying SSL library. But LWP also works with IO::Socket::SSL, which will ignore those environment variables and happily talk to any server, no matter what certificate it presents. Is there a more general solution?</p> <p><strong>Update 3:</strong> Unfortunately, the solution still isn't complete. Neither Net::SSL nor IO::Socket::SSL is checking the host name against the certificate. This means that someone can get a legitimate certificate for some domain, and then impersonate any other domain without LWP complaining.</p> <p><strong>Update 4:</strong> <a href="http://search.cpan.org/dist/libwww-perl/" rel="noreferrer">LWP 6.00</a> finally solves the problem. See <a href="https://stackoverflow.com/questions/74358/how-can-i-get-lwp-to-validate-ssl-server-certificates#5329129">my answer</a> for details.</p>
<p>This long-standing security hole has finally been fixed in version 6.00 of <a href="https://metacpan.org/release/libwww-perl" rel="noreferrer">libwww-perl</a>. Starting with that version, by default <a href="https://metacpan.org/pod/LWP::UserAgent" rel="noreferrer">LWP::UserAgent</a> verifies that HTTPS servers present a valid certificate matching the expected hostname (unless <code>$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}</code> is set to a false value or, for backwards compatibility if that variable is not set at all, either <code>$ENV{HTTPS_CA_FILE}</code> or <code>$ENV{HTTPS_CA_DIR}</code> is set).</p> <p>This can be controlled by the new <a href="https://metacpan.org/pod/LWP::UserAgent#ssl_opts" rel="noreferrer">ssl_opts</a> option of LWP::UserAgent. See that link for details on how the Certificate Authority certificates are located. But <strong>be careful</strong>, the way LWP::UserAgent used to work, if you provide a <code>ssl_opts</code> hash to the constructor, then <strong><code>verify_hostname</code> defaulted to 0</strong> instead of 1. (<a href="https://rt.cpan.org/Public/Bug/Display.html?id=67947" rel="noreferrer">This bug</a> was fixed in LWP 6.03.) To be safe, always specify <code>verify_hostname =&gt; 1</code> in your <code>ssl_opts</code>.</p> <p>So <code>use LWP::UserAgent 6;</code> should be sufficient to have server certificates validated.</p>
<p>Just perform execute the following command in Terminal: <strong>sudo cpan install Mozilla::CA</strong></p> <p>It should solve it.</p>
9,999
<p>I'm using the Marlin firmware (1.1.0-RC7 - 31 July 2016) for a 3d printer. Currently the printing is not perfect due to slight inaccuracies in movements along the x and y axis. I'm trying to change the feedrate for speed along the xy axis whilst the printer is in operation to make sure the printer stops on time and prints accurately.</p> <p>I have some code for controlling the feedrate but the problem is that I'm not sure where I am supposed make these adjustments. In the configuration.h file I see this code: (lines 742 and 753 )</p> <pre><code>/*line 742*/ #define HOMING_FEEDRATE_XY (50*60) /*line 753*/ #define DEFAULT_MAX_FEEDRATE {300, 300, 5, 25} // (mm/sec) </code></pre> <p>I'm probably misunderstanding something but it seems like this sets the feedrate to a default value which is the same as the maximum. </p> <p>If the feedrate changes during printing I'm guessing it would be done in Marlin_main.cpp but I'm not sure which part it actually changes. Can someone point me in the right direction here? </p>
<p>You can change the <em>maximum</em> allowable feedrate in Configuration.h, but the actual feedrate that is used isn't determined by your firmware. The feedrate is specified in the G-Code file. A command like</p> <pre><code>G0 X10.0 Y15.0 Z3.0 F9000 </code></pre> <p>indicates a move to (10,15,3) at a feedrate of 9000 mm/min. If F is not specified, the last used feedrate is used.</p> <p>You just have to provide the appropriate G-code commands with the feedrate you want in them. There's no reason to modify the firmware to get a different feedrate.</p>
<p>You have the lines to adjust the feed rate. The first one (line 742) is relevant to the maximum feed rate XY while homing (not during printing). I think this is not an issue in your particular case and you may leave it as it is.</p> <p>The second one (line 753) is the feed rate while printing for XY. Particularly the numbers in the brackets refers to ( X, Y, Z, E). If your printer is moving it may affect XY more than Z and E. So you may try to adjust the first two numbers.</p> <p>Due to the very specific situation is impossible to give you a feed rate based on calculation because you are dealing with external accelerations caused by the mobile situation. You will need to try and adjust it until you get right.</p> <p>Another setting that may also help you to compensate the external acceleration, if any, is the acceleration of those two axes.You should find two lines like these:</p> <pre> #define DEFAULT_MAX_ACCELERATION {1500,1500,50,250} #define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves </pre> <p>However the acceleration of the axes may impact on the quality of the printing.</p>
419
<p>I recently came across an issue with Windows 2003 (apparently it also exists in other versions too), where if an SSL/TLS server is requesting client certificate authentication and it has more than 16KB of trusted certificate DNs, Internet Explorer (or any other app that uses schannel.dll) is unable to complete the SSL handshake. (In a nutshell, the server breaks the message into chunks of 2^14 bytes, as per RFC 2246 sec. 6.2.1, but Schannel wasn't written to support that. I've gotten confirmation from Microsoft support that this is a flaw in Schannel and that they're considering fixing it in a future release.)</p> <p>So I'm trying to find a way to easily parse through my trusted certificates (I use Apache as my server, so all of them are in PEM format) to get the total ASN.1-format length of the DNs (which is how they get sent over the wire during the handshake), and thereby see if I'm getting too close to the limit. I haven't yet been able to find a way to do this, though: the OpenSSL asn1parse function comes close, but it doesn't seem to provide a way to get the ASN.1 sequence for just the issuer name, which is what I need.</p> <p>Any suggestions?</p>
<p>Since ASN.1 is self describing, it's fairly easy to write an ASN.1 parser. As you probably know, ASN.1 data contains a tree of values, where each value type is identified by a globally assigned OID (Object ID). You can find a free ASN.1 decoder with source code at: <a href="http://www.geocities.co.jp/SiliconValley-SanJose/3377/asn1JS.html" rel="nofollow noreferrer"><a href="http://www.geocities.co.jp/SiliconValley-SanJose/3377/asn1JS.html" rel="nofollow noreferrer">http://www.geocities.co.jp/SiliconValley-SanJose/3377/asn1JS.html</a></a>. It;'s written in javascript so you can play with it directly in your browser.</p> <p>As to your exact question - I would:</p> <ol> <li>Use the supplied parser, find another one or write my own</li> <li>Find the OID of trusted DNs (check the specification or simply decode a certificate using the supplied ASN.1 decoder page)</li> <li>Combine the two above to extract the size of trusted DNs inside a certificate.</li> </ol>
<p>openssl asn1parse will do it, but you'll need to do some manual parsing to figure out where the issuer sequence begins. Per RFC 5280, it's the 4th item in the TBSCertificate sequence (potentially 3rd if it's a v1 certificate), immediately following the signature algorithm. In the following example:</p> <pre><code> 0:d=0 hl=4 l= 621 cons: SEQUENCE 4:d=1 hl=4 l= 470 cons: SEQUENCE 8:d=2 hl=2 l= 3 cons: cont [ 0 ] 10:d=3 hl=2 l= 1 prim: INTEGER :02 13:d=2 hl=2 l= 1 prim: INTEGER :02 16:d=2 hl=2 l= 13 cons: SEQUENCE 18:d=3 hl=2 l= 9 prim: OBJECT :sha1WithRSAEncryption 29:d=3 hl=2 l= 0 prim: NULL 31:d=2 hl=2 l= 64 cons: SEQUENCE 33:d=3 hl=2 l= 11 cons: SET 35:d=4 hl=2 l= 9 cons: SEQUENCE 37:d=5 hl=2 l= 3 prim: OBJECT :countryName 42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :US 46:d=3 hl=2 l= 26 cons: SET 48:d=4 hl=2 l= 24 cons: SEQUENCE 50:d=5 hl=2 l= 3 prim: OBJECT :organizationName 55:d=5 hl=2 l= 17 prim: PRINTABLESTRING :Test Certificates 74:d=3 hl=2 l= 21 cons: SET 76:d=4 hl=2 l= 19 cons: SEQUENCE 78:d=5 hl=2 l= 3 prim: OBJECT :commonName 83:d=5 hl=2 l= 12 prim: PRINTABLESTRING :Trust Anchor 97:d=2 hl=2 l= 30 cons: SEQUENCE 99:d=3 hl=2 l= 13 prim: UTCTIME :010419145720Z 114:d=3 hl=2 l= 13 prim: UTCTIME :110419145720Z 129:d=2 hl=2 l= 59 cons: SEQUENCE </code></pre> <p>the Issuer DN starts at offset 31 and has a header-length of two and a value length of 64, for a total length of 66 bytes. This isn't so easy to script, of course...</p>
9,786
<h3>TL;DR</h3> <p>I need a complete list of fasteners (bolts, nuts and washers) for the <em>Sintron Kossel</em>.</p> <hr /> <p>Has anyone bought this kit, and knows the answer, or knows where this is documented?</p> <p>A complete list would be great, but in particular, I need the dimensions (M2.5/3/4/5? and length) and quantity of the bolts (and nuts) which:</p> <ul> <li>fasten the PCB mounted mechanical switches to the PLA rectangular end stop spacers/holders, and;</li> <li>fasten the PCB mounted mechanical switches and the PLA rectangular end stop spacers/holders to the extruded 2020 aluminium.</li> </ul> <p>I have:</p> <ul> <li>Searched the web, but to no avail;</li> <li>Read the <a href="http://www.ebay.co.uk/itm/Sintron-3D-Printer-Kossel-Mini-Full-Set-w-Auto-level-for-RepRap-Rostock-Delta-/181845082062" rel="nofollow noreferrer">product page</a>, which states only &quot;screws and nuts provided&quot;;</li> <li>Contacted <a href="http://www.ebay.co.uk/usr/sintron_tech_usa" rel="nofollow noreferrer">Sintron</a>, but not had an answer;</li> <li>Obtained the <a href="https://www.dropbox.com/s/iifhhmistuwfja1/Kossel%20mini%20instrution%20by%20sintron%20technology_v2.pdf?dl=0" rel="nofollow noreferrer">Sintron build manual</a> but there is no list contained therein, nor contains details about the fasteners relating to the endstops, and;</li> <li>Obtained the <a href="http://www.robotdigg.com/upload/pdf/2a823cc8a8dcff9da99cce92710cc745.pdf" rel="nofollow noreferrer">Blomker manual</a>, from which the Sintron manual is copied, but that also has no list (as well as not being relevant with respect to the endstops).</li> </ul> <p><strong>Note that I am only interested in the fasteners <em>specifically for the Sintron Kossel</em> and not the Kossel in general.</strong> The Sintron uses the PCB mounted mechanical switches (with four holes), and not the simple barebones mechanical switches (with two holes), and uses 2020 aluminium<sup>1</sup>, not 1515 OpenBeam:</p> <p><a href="https://i.stack.imgur.com/Lr1BU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lr1BU.png" alt="Endstops and PCB mounted mechanical switches for the Sintron Kossel" /></a></p> <p>Why? Because I purchased only the 3D printed parts from Sintron, and I am sourcing the rest of the parts cheaply, either locally or from Chinese suppliers on eBay.</p> <hr /> <p><sup>1</sup> In my particular case, there is an additional complication. The profile of the non-standard/non-&quot;European&quot; 2020 extrusion that I am using, does <em>not</em> take T-Nuts, only M5 hexagonal nuts (it is unbelievably difficult to find the standard 2020 extrusion in Bangkok). Combine that with the fact that the Sintron kit uses only M3 nuts and <em>not</em> M5 (I only discovered this <em>after</em> purchasing the printed parts kit (see the email from Sintron, in my answer below) - not through lack of research, but because there <em>is</em> no available list of fasteners), then I have the problem of finding a nut to use (see <a href="https://engineering.stackexchange.com/questions/15628/fat-hexagonal-m3-nuts-with-outer-diameter-greater-than-6-mm">Fat hexagonal M3 nuts, with outer diameter greater than 6 mm</a>).</p> <p>Here is a photo</p> <p><a href="https://i.stack.imgur.com/UgSHu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UgSHu.jpg" alt="Four pieces of 2020 Aluminium extrusion" /></a></p>
<p>After examining the guide (<a href="https://gr33nonline.files.wordpress.com/2017/05/kossel-mini-instrution-by-sintron-technology_v2.pdf" rel="nofollow noreferrer">Kossel mini instrution by sintron technology_v2</a>) and the printed parts kit, I came up with an 99.9% complete parts list. The lists relating to the effector and autoprobe mount maybe slightly incorrect:</p> <pre><code>##Parts List ###Listed by Printer part/section: ####Fasteners #####BOTTOM VERTEX (QUANTITY = 3) For each: 10 x M3 x 8 mm 10 x M3 nut (T-nut) #####TOP VERTEX (QUANTITY = 3) For each: 5 x M3 x 8 mm 5 x M3 nut (T-nut) 1 x M3 x 35 mm 1 x M3 nut 1 x M3 washer #####IDLERS (QUANTITY = 3) For each: 1x M3 x 25 mm 4x M3 Washers 1 x M3 Nut 2x F623ZZ #####MOTORS (QUANTITY = 3) For each: 2 x grub 4 x M3 x 8 mm 1 x 16T/20T GT2 pulley #####EFFECTOR 6 x M3 nyloc nuts 6 x M3 x 25 mm 4 (5?) x M3 x 16 mm &lt;&lt;==, or 2 (3?) x M3 x 16 mm &lt;&lt;== 2 x M3 x 20 mm &lt;&lt;== For the auto probe, if mounting the autoprobe directly on to a collar, above the hotend, and not on to the flange on the Sintron PLA collar 4 (5?) x M3 nuts &lt;&lt;== 2 x M3 x 8 mm &lt;&lt;== fan mounted to Sintron PLA collar 2 x M3 nuts &lt;&lt;== 1 x PC4-M6 Note: Some additional bolts are required for the mounting of the hotend. It is unclear what these are. See link. #####VERTICAL CARRIAGES (QUANTITY = 3) For each: 2 x M3 x 20 mm #####ROLLER CARRIAGES (QUANTITY = 3) For each: 2 x M3 x 10 mm 1 x M3 x 25 mm 3 x M3 nuts 3 x M6 x 25 mm 3 x M6 nut 2 x M6 washer (optional) #####ENDSTOPS (QUANTITY = 3) For each: 1 x M3 x 8 mm &lt;&lt;== 1 x M3 nut (T-nut) 3 x M3 x 8 mm &lt;&lt;== 3 x M3 nut #####SPOOL 6 x 625-2RS Bearing (or 625zz) 5 x M5 x 20 mm 1 x M5 x 25 mm 6 x M5 nut 6 x M5 washer (or 7 x M5 washer – there is a discrepancy between the kit (7) and the manual (6)) 3 x M3 x 8 mm ? 3 x M3 nut (T-nut) #####EXTRUDER 1 x M3 x 40 mm 1 x M3 x 8 mm 1 x M3 x ?? mm &lt;&lt;== 2 x M3 nut (T-nut) 1 x PC4-01 #####AUTOPROBE Note: This is optional 2 x M2.5 x 12 mm 1 x M2.5 x 12 mm 2 x M3 x 8 mm &lt;&lt;== If mounting the autoprobe on to the flange of the Sintron PLA collar (if mounting directly on to a collar, above the hotend, then these are not required, and 2 x M3 x 20 mm replace 2 x M3 x 16 mm on the effector) 2 x M3 nuts &lt;&lt;== If mounting the autoprobe on to the flange of the Sintron PLA collar (if mounting directly on to a collar, above the hotend, then these are not required) Safety Pin 2.5 mm Spring 23.5mm Terminal Block 1.5mm Allen key Note: Some additional bolts are required for the mounting of the autoprobe, as well as the hotend. It is unclear what these are. #####GLASS BED 3 x M3 x 8 mm ? 1 x M3 x 20 mm 4 x M3 nut (T-nut) #####RAMPS Note: This is optional, as mounting on the top will interfere with the spool 2 x M3 x 35 mm 2 x M3 nuts 2 x M3 nuts (T-nut) ###Total Parts: ####Fasteners #####BOLTS Size, Length, Quantity M3, 25, (1×3)+(6)+(1×3) = 3+6+3 = 12 M3, 8, (10×3)+(5×3)+(4×3)+(4x3)+(3)+(1)+(2)+(3) = 30+15+12+12+3+1+2+3 = 78 M3, 16, 5 M3, 20, (2×3)+(1)+(2) = 6+1+2 = 9 M3, 10, (2×3) = 6 M3, 35, 3 M3, 40, 1 M6, 25, (3×3) = 9 M5, 20, 5 M5, 25, 1 M2.5, 12, 3 #####GRUB SCREWS Size, Quantity ?, (2×3) = 6 #####NUTS Size, Quantity M5, 6 M6, (3×3) = 9 — EITHER M3, (10×3)+(5×3)+(1x3)+(1×3)+(5+2)+(3×3)+(1×3)+(3×3)+(3)+(2)+(2)+(4) = 30+15+3+7+9+3+9+3+2+2+4 = 90 OR M3, (1×3) + (1×3) + (5+2) + (3×3) + (3×3) + (2) = 3+7+9+9+2 = 33 and M3 T-slot nut, (10×3) + (5×3) + (1×3) + (3) + (2) + (4) = 30+15+3+3+2+4 = 57 — #####NYLOC NUTS Size, Quantity M3, 6 #####WASHERS Size, Quantity M3, (1x3)+(4×3) = 15 M6, (2×3) = 6 M5, 6 (or 7) ####Bearings Size, Quantity F623zz, 6 625-2RS, 6 OR 625zz, 6 ####Printed Parts TBD ####Structural 3 x 2020 x 750/600 mm 9 x 2020 x 360/240 mm ####Electronics 1 x Arduino Mega 2560 1 x RAMPS 1.4 5 x Stepper drivers 3 x PCB mounted mechanical switch 3 x Stepper motors 1 x Extruder stepper ####Belts 3 x 16T/20T GT2 Pulley GT2 belt (5 meters) ####Other Parts Safety Pin 2.5 mm Spring 23.5mm Terminal Block 1.5mm Allen key 9 x Delrin wheels 9 x 696zz bearings 1 x PC4-M6 1 x PC4-01 ###Uncertainties The fasteners required for the following parts is, as yet, unclear Effector/Hotend mount Autoprobe mount Additional Extruder holder screwpoint ###Assumptions Hotbed frame mounts (assumed to be M3 x 8 mm) Spool frame mounts (assumed to be M3 x 8 mm) Endstops (four M3 x 8 mm are used, not just one) </code></pre> <p>See also <a href="https://gr33nonline.wordpress.com/2017/06/01/kossel-sintron-parts-list/" rel="nofollow noreferrer">Kossel - Sintron parts list</a>.</p> <hr> <p>I have a <em>partial</em> answer from the suppliers:</p> <blockquote> <p>Hi </p> <p>Good Day !</p> <p>thanks for your contact.</p> <p>we use M3 bolts + T-nuts .</p> <p>i suppose the problem is , you don't have T-nuts , right ?</p> <p>T-nuts is used for 2020 extrusion.</p> <p>with warm regards.</p> <p>james</p> </blockquote> <p>I replied for a clarification of the length required:</p> <blockquote> <p>Many thanks for the reply.</p> <p>I have two types of 2020 extrusion, with differing profiles: one that takes T-Nuts, and; one that takes regular hexagonal M5 nuts.</p> <p>For the T-nut extrusion I have both M3 and M5 T-nuts.</p> <p>However, the second type of 2020 extrusion takes regular M5 nuts. Regular M3 nuts will not stay in place, unless I can find some M3 nuts with a larger outer diameter, greater than 7 mm.</p> <p>With respect to the M3 bolts, what are the lengths required? Are two lengths used? One length to secure the endstop switch and holder to the 2020 extrusion, and then another length to secure the remaining three holes? Looking at the diagram in your build guide, it seems as if only one bolt is used to secure the endstop switch and holder to the frame, is that correct? Are any other bolts used to secure the PCB mounted switch the the endstop holders.</p> <p>I thank you in advance.</p> <p>Best regards</p> </blockquote> <p>I followed this up with a second email</p> <blockquote> <p>Hi again James,</p> <p>Following on from my previous reply.</p> <p>Firstly, I have found that flanged M3 nuts will work perfectly, in the extrusion that will not accept T-Nuts.</p> <p>Secondly, what I really am looking for is a list of the lengths (and dimensions) of the bolts used throughout the Sintron build. In particular the endstop bolts. Rather than having to iteratively deduce each bolt, a list of the bolts used would be very handy.</p> <p>I thank you again in advance for your kind consideration.</p> <p>Best regards,</p> </blockquote> <p>I received a second reply from Sintron</p> <blockquote> <p>Hello Friend.</p> <p>for endstop . it's M3*8mm . </p> <p>i am collecting the list of them for you soon.</p> <p>thanks.</p> <p>james</p> </blockquote> <hr>
<p>I found two lists for the Kossel mini (the documents you referenced are for a mini, so that is what I am assuming you got). One as a <a href="https://docs.google.com/spreadsheets/d/1s_ekMab3iavE6ohXIHZImjlCRGyXr9UWbBqC8XOGF_M/pub?output=html" rel="nofollow noreferrer">Google Doc</a> and one as an <a href="http://www.tridprinting.com/BOM/Kossel-Mini/" rel="nofollow noreferrer">order sheet</a> </p> <p>Both seem to list all the fasteners.</p> <p>Here is a Sintron mini <a href="https://www.aliexpress.com/store/product/SINTRON-Kossel-Mini-Prime-Line-Roller-Carriage-Wheel-696ZZ-Bearing-linear-rail-MGN12/114769_32427917085.html" rel="nofollow noreferrer">carriage assembly</a> and it lists the hardware included</p> <p>I found an ebay listing for the Sintron 2020 Rails. The recommended screws are M3x20mm and here is the infor on the required t-nuts.<a href="https://i.stack.imgur.com/Hjohn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hjohn.png" alt="enter image description here"></a></p> <p>Happy building.</p>
615
<p>When learning a new programming language, one of the possible roadblocks you might encounter is the question whether the language is, by default, <em>pass-by-value or pass-by-reference</em>.</p> <p>So here is my question to all of you, in your favorite language, <em>how</em> is it actually done? And what are the <em>possible pitfalls</em>?</p> <p>Your favorite language can, of course, be anything you have ever played with: <a href="http://www.ruby-lang.org/en/" rel="noreferrer">popular</a>, <a href="http://www.devtopics.com/a-obscure-programming-language-of-the-month/" rel="noreferrer">obscure</a>, <a href="http://en.wikipedia.org/wiki/Brainfuck" rel="noreferrer">esoteric</a>, <a href="http://www.nvidia.com/object/cuda_get.html" rel="noreferrer">new</a>, <a href="http://en.wikipedia.org/wiki/FORTRAN" rel="noreferrer">old</a>...</p>
<p>Here is my own contribution for the <a href="http://en.wikipedia.org/wiki/Java_(programming_language)" rel="nofollow noreferrer">Java programming language</a>.</p> <p>first some code:</p> <pre><code>public void swap(int x, int y) { int tmp = x; x = y; y = tmp; } </code></pre> <p>calling this method will result in this:</p> <pre><code>int pi = 3; int everything = 42; swap(pi, everything); System.out.println("pi: " + pi); System.out.println("everything: " + everything); "Output: pi: 3 everything: 42" </code></pre> <p>even using 'real' objects will show a similar result:</p> <pre><code>public class MyObj { private String msg; private int number; //getters and setters public String getMsg() { return this.msg; } public void setMsg(String msg) { this.msg = msg; } public int getNumber() { return this.number; } public void setNumber(int number) { this.number = number; } //constructor public MyObj(String msg, int number) { setMsg(msg); setNumber(number); } } public static void swap(MyObj x, MyObj y) { MyObj tmp = x; x = y; y = tmp; } public static void main(String args[]) { MyObj x = new MyObj("Hello world", 1); MyObj y = new MyObj("Goodbye Cruel World", -1); swap(x, y); System.out.println(x.getMsg() + " -- "+ x.getNumber()); System.out.println(y.getMsg() + " -- "+ y.getNumber()); } "Output: Hello world -- 1 Goodbye Cruel World -- -1" </code></pre> <p>thus it is clear that Java passes its parameters <strong>by value</strong>, as the value for <em>pi</em> and <em>everything</em> and the <em>MyObj objects</em> aren't swapped. be aware that "by value" is the <em>only way</em> in java to pass parameters to a method. (for example a language like c++ allows the developer to pass a parameter by reference using '<strong>&amp;</strong>' after the parameter's type)</p> <p>now the <strong>tricky part</strong>, or at least the part that will confuse most of the new java developers: (borrowed from <a href="http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html" rel="nofollow noreferrer">javaworld</a>)<br> Original author: Tony Sintes</p> <pre><code>public void tricky(Point arg1, Point arg2) { arg1.x = 100; arg1.y = 100; Point temp = arg1; arg1 = arg2; arg2 = temp; } public static void main(String [] args) { Point pnt1 = new Point(0,0); Point pnt2 = new Point(0,0); System.out.println("X: " + pnt1.x + " Y: " +pnt1.y); System.out.println("X: " + pnt2.x + " Y: " +pnt2.y); System.out.println(" "); tricky(pnt1,pnt2); System.out.println("X: " + pnt1.x + " Y:" + pnt1.y); System.out.println("X: " + pnt2.x + " Y: " +pnt2.y); } "Output X: 0 Y: 0 X: 0 Y: 0 X: 100 Y: 100 X: 0 Y: 0" </code></pre> <p><em>tricky</em> successfully changes the value of pnt1! This would imply that Objects are passed by reference, this is not the case! A correct statement would be: <strong>the <em>Object references</em> are passed by value.</strong> </p> <p>more from Tony Sintes: </p> <blockquote> <p>The method successfully alters the value of pnt1, even though it is passed by value; however, a swap of pnt1 and pnt2 fails! This is the major source of confusion. In the main() method, pnt1 and pnt2 are nothing more than object references. When you pass pnt1 and pnt2 to the tricky() method, Java passes the references by value just like any other parameter. This means the references passed to the method are actually copies of the original references. Figure 1 below shows two references pointing to the same object after Java passes an object to a method.</p> </blockquote> <p><a href="https://i.stack.imgur.com/EXPyo.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EXPyo.gif" alt="figure 1"></a><br> <sub>(source: <a href="http://www.javaworld.com/javaworld/javaqa/2000-05/images/03-qa-0512-pass2b.gif" rel="nofollow noreferrer">javaworld.com</a>)</sub> </p> <p><strong>Conclusion</strong> or a long story short:</p> <ul> <li>Java passes it parameters <strong>by value</strong></li> <li><em>"by value"</em> is the <strong>only way</strong> in java to pass a parameter to a method</li> <li>using <em>methods from the object</em> given as parameter <strong>will alter</strong> the object as the references point to the original objects. (if that method itself alters some values)</li> </ul> <p>useful links: </p> <ul> <li><a href="http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html" rel="nofollow noreferrer">http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html</a></li> <li><a href="http://www.ibm.com/developerworks/java/library/j-passbyval/" rel="nofollow noreferrer">http://www.ibm.com/developerworks/java/library/j-passbyval/</a></li> <li><a href="http://www.ibm.com/developerworks/library/j-praxis/pr1.html" rel="nofollow noreferrer">http://www.ibm.com/developerworks/library/j-praxis/pr1.html</a></li> <li><a href="http://javadude.com/articles/passbyvalue.htm" rel="nofollow noreferrer">http://javadude.com/articles/passbyvalue.htm</a></li> </ul>
<p>By default, ANSI/ISO C uses either--it depends on how you declare your function and its parameters.</p> <p>If you declare your function parameters as pointers then the function will be pass-by-reference, and if you declare your function parameters as not-pointer variables then the function will be pass-by-value.</p> <pre><code>void swap(int *x, int *y); //&lt; Declared as pass-by-reference. void swap(int x, int y); //&lt; Declared as pass-by-value (and probably doesn't do anything useful.) </code></pre> <p>You can run into problems if you create a function that returns a pointer to a non-static variable that was created within that function. The returned value of the following code would be undefined--there is no way to know if the memory space allocated to the temporary variable created in the function was overwritten or not.</p> <pre><code>float *FtoC(float temp) { float c; c = (temp-32)*9/5; return &amp;c; } </code></pre> <p>You could, however, return a reference to a static variable or a pointer that was passed in the parameter list.</p> <pre><code>float *FtoC(float *temp) { *temp = (*temp-32)*9/5; return temp; } </code></pre>
2,423
<p>I think the best part of flash is the possibility to create not squared user interfaces, so I like the idea to create desktop apps using flash. I know AIR is for that but it doesn't allow real access to OperatingSystem apis and dlls and the commercial options are kind of difficult to customize.</p>
<p>You can try ScreenweaverHX:</p> <p><a href="http://haxe.org/com/libs/swhx" rel="nofollow noreferrer">http://haxe.org/com/libs/swhx</a></p> <p>It's the Haxe-based successor of the old Screenweaver. However, it's not as simple as the old version used to be. Most likely you need to take a look to the basics of Haxe and Neko, the 2 technologies it's based on.</p> <p>There's another project on top of SWHX that it's called HippoHX. It aims to "complete" SWHX providing that extra functionality you might miss (simple ActionScript APIs and a GUI). However, it's in its early stages:</p> <p><a href="http://hippohx.com" rel="nofollow noreferrer">http://hippohx.com</a></p> <p>DISCLAIMER: I'm the owner of HippoHX, so my point is obviously biased.</p> <p>As far as I know SWHX is the only Open Source alternative at this point.</p>
<p>Try flajector. it's powerfull converter from flash to exe. You can to develop your application using AIR. And then you can convert it into desktop application .exe</p>
9,501
<p>I'm getting all learned up about binding in WPF. I'm having a lot of trouble debugging the parse errors in my xaml, though. Can somebody pretty please tell me what's wrong with this little piece? :</p> <pre><code>&lt;Border Name="TrackBackground" Margin="0" CornerRadius="2" Grid.Row="1" Grid.Column="1" Background="BlanchedAlmond" BorderThickness="1" Height="{TemplateBinding Height}"&gt; &lt;Canvas Name="PART_Track" Background="DarkSalmon" Grid.Row="1" Grid.Column="1"&gt; &lt;Thumb Name="ThumbKnob" Height="{Binding ElementName=Part_Track, Path=Height, Mode=OneWay}" /&gt; &lt;/Canvas&gt; &lt;/Border&gt; </code></pre> <p>It's the databinding that breaks. I get an <code>InvalidAttributeValue</code> exception for ThumbKnob.Height when I try to run this. I know I must be missing something fundamental. So fill me in, stackers, and my gratitude will be boundless.</p> <hr> <p>Changing the ElementName didn't help. There must me something else I'm not getting.</p> <p>I should mention that I'm testing this in Silverlight. The exact message I'm getting out of Internet Explorer is:</p> <p><code>XamlParseException: Invalid attribute value for property Height.</code></p> <p>This whole thing is inside a ControlTemplate. I'm making a slider control just to teach myself the concepts.</p>
<p>The ElementName property on a Binding is not supported in Silverlight.</p> <p>You will notice, if you go into the code behind or inspect the Binding object in class explorer, it doesn't have a property named ElementName.</p>
<p>First of all its a matter of casing...</p> <p>Change <pre><code>Part_Track</code></pre> to <pre><code>PART_Track</code></pre> which will fix your binding error..</p> <p>But I do not think that this is what you are trying to do..</p> <p>You could use a Grid instead of a canvas, and the Thumb will size automatically. Canvas does not really have a height, for it does not really care about the height of its children...</p> <p>Hope this helps...</p>
2,936
<p>I want to upload some of my works to <a href="http://www.thingiverse.com/">Thingiverse</a> without making my real name public (displaying it on the profile page).</p> <p>I think it is OK to register my name to the site unless the make it public, and it is required by the terms to provide truthful and accurate information.</p> <p>I tried creating an account on the site, but I deleted it because I couldn't find the way to hide my name (set another one) from the profile page in a short time.</p> <p>I see some accounts that doesn't seem showing their real name (for example, their name on profile equals to their account ID, or at least not in two parts: first and last name as required on registration), so I guess this is archivable.</p> <p>examples:</p> <ul> <li><a href="http://www.thingiverse.com/Darkcheops/about">http://www.thingiverse.com/Darkcheops/about</a></li> <li><a href="http://www.thingiverse.com/ruaridh/about">http://www.thingiverse.com/ruaridh/about</a></li> <li><a href="https://www.thingiverse.com/Torleif/about">https://www.thingiverse.com/Torleif/about</a></li> </ul> <p>How can I set my name for profile page on Thingiverse after registration and logging in?</p>
<p>To change your displayed name (as opposed to username) in Thingiverse:</p> <ol> <li>Go to your profile page</li> <li>Click "Edit Profile" on the info column on the left</li> <li>At the top, next to "Thingiverse Settings" is another link/tab called "Makerbot Settings". Click that.</li> <li>Change the First Name and Last Name fields, and save.</li> </ol> <p>Note that neither First nor Last Name is required; if neither is provided, your username will be displayed in place of your display name.</p>
<p>You can put whatever name you want in when you make an account - You decide what your name is, people go by pseudonyms in 'real life' all the time, this is perfectly acceptable. There are actually very few places where you have a legal obligation to provide your name as it appears on your birth certificate. Opening a Thingiverse account is not one of them.</p> <p>To answer the other part of your question, yes, it is possible to change the name displayed after you have created your account. I would be surprised if they bother to actually keep an archive of past names though.</p>
193
<p>Does anyone know <strong>IF</strong>, <strong>WHEN</strong> or <strong>HOW</strong> I can get <a href="https://memcached.org/" rel="noreferrer">Memcached</a> running on a Windows 64bit environment? </p> <p>I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net MVC solution with SQL Server DB, the OS is either going to be Windows Server 2003 or (hopefully!) 2008.</p> <p>I know that this could spill over into a debate regarding 32bit vs 64bit on servers, but let's just say that my preference is 64bit and that I have some <a href="https://blogs.technet.microsoft.com/mscom/2005/09/26/running-microsoft-com-on-64-bitthe-dependencies-the-goodness-the-gotchas/" rel="noreferrer">very</a> <a href="https://blog.codinghorror.com/64-bit-desktop-vs-64-bit-server/" rel="noreferrer">good</a> reasons.</p> <p>So far, I've tried a number of options and found a <a href="http://blog.rakeshxp.com/2007/09/running-memcached-on-windows.html" rel="noreferrer">bit</a> of <a href="http://www.splinedancer.com/memcached-win32/" rel="noreferrer">help</a> related to getting this up on a 32bit machine (and succeeded I might add), but since the original <a href="http://jehiah.cz/projects/memcached-win32/" rel="noreferrer">Windows port</a> is Win32 specific, this is hardly going to help when installing as a service on x64. It also has a dependency on the <a href="https://libevent.org/" rel="noreferrer">libevent</a> for which I can only get a Win32 compiled version.</p> <p>I suspect that simply loading all this up in C++ and hitting "compile" (for 64bit) wouldn't work, not least because of the intricate differences in 32 and 64bit architectures, but I'm wondering if anyone is working on getting this off the ground? Unfortunately, my expertise lie in managed code (C#) only, otherwise I would try and take this on myself, but I can't believe I'm the only guy out there trying to get <a href="https://memcached.org/" rel="noreferrer">memcached</a> running on a 64 bit Windows server....am I?</p> <hr> <p>Update</p> <p><strong>Yes I'm afraid I'm still looking for an answer to this - all my efforts (with my pathetic C++ skills) to make a stable build have failed - I've trashed one server and 3 VM's just trying it out so now I turn to the real experts. Is anyone planning on porting this to 64bit? Or are you really suggesting that I use MS Velocity instead? I shudder at the thought.</strong></p> <hr> <p>Update: @Lars - I do use Enyim actually - it's very good, but what you're referring to is a client, rather than the server part.</p> <p>@DannySmurf - I've only been able to install it as a service on a 32 bit OS. 64 bit OS rejects the installation of this Win32 service. Of course yes, lots of Win32 code works seamlessly on x64 architecture, hence you can run 32bit apps (like Office for instance) or games on Vista/XP 64 etc, but this doesn't translate directly when it comes to services. I'm no expert, I suspect that it has to do with the syncs or eventing that services need to subscribe to, and I suspect that 64 and 32 don't play nicely. I'm happy to be corrected on any of this, but to answer your question - yes I have tried.</p> <p>@OJ - thanks very much for the straight-forward response. I thought as much, but wasn't sure if anyone else had suggestions or had already gone down this route. Maybe when StackOverflow is LIVE, then more people will respond and let me know if this is something being looked into, and although I can try and compile it myself - I simply can't "trust" (with my C++ experience level) that it would provide "Enterprise Level" reliability in such a crucial component of large scalable solutions. I think it would need educated intervention rather than my unsanitised experimental approach before I could be confident. One little oversight on my part, could bring the site down. Oh well... till next time.</p>
<p>North Scale labs have released a build of memcached 1.4.4 for Windows x64:</p> <p><a href="http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available" rel="noreferrer">http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available</a></p> <p><a href="http://labs.northscale.com/memcached-packages/" rel="noreferrer">http://labs.northscale.com/memcached-packages/</a></p> <p>UPDATE: they have recently released Memcached Server - still FREE but enhanced distro with clustering, web-based admin/stats UI etc. (I'm not related to them in any way) Check it out at <a href="http://northscale.com/products/memcached.html" rel="noreferrer">http://northscale.com/products/memcached.html</a> and download at: <a href="http://www.northscale.com/download.php?a=d" rel="noreferrer">http://www.northscale.com/download.php?a=d</a></p> <p>UPDATE 2: NorthScale Memcached is no longer available as a standalone download. Now they have made it part of their commercial No-SQL DB offering called Membase. It can be configured to run in Memcached-only mode (i.e. without persistence) and there's a 100% free version too. Check it out here: <a href="http://www.membase.org/downloads" rel="noreferrer">http://www.membase.org/downloads</a></p> <p>UPDATE 3: MemBase has slept with CouchDB and produced a hybrid product offering, called CouchBase. They still do offer a free "Community" version at <a href="http://www.couchbase.com/download" rel="noreferrer">http://www.couchbase.com/download</a> </p>
<p>Are you sure that the 32-bit version doesn't just run on 64-bit Windows, without modification? Most things do.</p> <p>Failing that, have you actually tried just compiling it for 64-bit? A brief scan of a few Google Groups etc where people asked this same question suggests that that may be exactly the solution to this. I think you're probably overestimating the difference between 32-bit and 64-bit Windows (at least as far as compiling a native application goes).</p>
3,038
<p>At my university most of my classes have been in Java. I have also recently learned C# (and the Visual Studio environment) at a summer internship. Now I'm taking an Intro to Computer Graphics class and the grad student teaching the class prefers us to use C++ to access the OpenGL bindings via GLUT.</p> <p>Does anyone have any good resources on how to make a good transition from Java/C# to C++? Obviously pointers are going to be a big issue, but any other things I should be looking out for? Any tutorials, guides, etc. would be very helpful!</p> <p>Thanks!</p>
<p>Yeah, I got bit by the same bug. The university tended to lean on Java, and then allowed you to choose the language you wanted to work with during projects.</p> <p>The best way is to just jump in. Start small, take baby steps, and just Google things that confuse you when you get there. Also find projects that have released their source code. See how they structure their programs. Basically, just tinker with concepts. There is plenty of information around the web.</p> <p>Make it fun and grab a <a href="https://rads.stackoverflow.com/amzn/click/com/1598633600" rel="noreferrer" rel="nofollow noreferrer">C++ game development book</a> so it doesn't become mind numbing too quickly. </p> <p>Here's some places that I found useful while learning</p> <p><a href="http://www.cprogramming.com/" rel="noreferrer">http://www.cprogramming.com/</a></p> <p><a href="http://www.wikipedia.com" rel="noreferrer">http://www.wikipedia.com</a></p> <p><a href="http://www.cplusplus.com/" rel="noreferrer">http://www.cplusplus.com/</a></p>
<p>You will need a completely differnt feeling for memory handling. Also think about freeing everything you don't need anymore. In Java and C# you just let go of your objects and the memory gets tidy up for you - you can't do that in CPP</p>
3,977
<p><em>An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</em></p> <p>Hello I am new on developing on SQL Server 2005. I've worked for several years with SQL Server 2000, but after doing the usual stuff I do to connect to the server I get this exception on the web server.</p> <p>There are several links on google that point me to possible solutions, but none of them have solved my problem. I've made changes on a "Surface Area whatever..." dialog (What the hell is that??? Why does SQL Server has changed so much??? It seems so complicated now). </p> <p>I have ensured that SQL Server 2005 is configured properly to allow incoming connections on the instance of database server. I also have selected <em>Automatic</em> as the Startup type to start SQL Server Browser service automatically every time system starts. And no, there is no firewall running.</p> <p>I've tried changing the connection string to connect using a port, to connect using the IP, to connect using the instance name...</p> <p>Nothing seems to work, I'm still getting the same error. Any hint?</p> <p>Answering the questions that people have made: Yes, I can connect using management studio from a different computer. Yes, I'm sure it's configured to accept local and remote TCP/IP and named pipes. Yes, I restarted the server.</p> <p>I am using Mixed mode security, which I already enabled. I already enabled the sa user. I am able to connect to the database using a .udl file, and I've checked that my connection string is OK. I can connect to the database using DBArtisan and SQL Server client tools. I can do that both on the server and on a different machine. Even with all that...</p> <p>The website is still unable to connect.</p> <p>New update... I've been struggling all day with this problem, and still haven't found out the cause. It seems that the error message I posted is a generic error that .net gives when it's not able to connect. I placed trash on the connection string (typing servers that don't exist) and I still get the same error.</p> <p>These are some of the connection strings I've used on the server:</p> <p>connectionString="Integrated Security=SSPI; Data Source=SERVER; Initial Catalog=db; Network Library=DBMSSOCN;"</p> <p>connectionString="Data Source=SERVER; Initial Catalog=db; User ID=sa; Password=xxxxx;"</p> <p>connectionString="Data Source=SERVER\MSSQLSERVER; Initial Catalog=db; User ID=sa; Password=xxxxx;"</p> <p>I tried to register the sql server instance using some strange command, I found that here: <a href="http://kb.discountasp.net/article.aspx?id=1041" rel="nofollow noreferrer">http://kb.discountasp.net/article.aspx?id=1041</a> To do that I used the aspnet_regsql.exe tool. It's still not working...</p> <p>I also know that the server has the latest version of MDAC installed on it. The only thing that I'm suspicious on is that the server has two Database engines: SERVER and server\sqlexpress</p> <p>Does that has something to do with the problem?</p>
<blockquote> <p>The only thing that I'm suspicious on is that the server has two Database engines: SERVER and server\sqlexpress</p> </blockquote> <p>I think this is the source of the problem. Which one do you intend to connect to? You need to specify the "instance" you are connecting to.</p> <p>Assuming you intend to connect to the SERVER instance, you connection string should then look like this (assuming the default instance name):</p> <p>Data Source=<strong>YOURSERVER\MSSQLSERVER</strong>; Initial Catalog=db; User ID=sa; Password=xxxxx;</p> <p>Or for sql express the connection string looks like this: Data Source=<strong>YOURSERVER\sqlexpress</strong>; Initial Catalog=db; User ID=sa; Password=xxxxx;</p>
<p>Can you connect to the SQL Server via Management Studio from a different machine? This might help you narrow down whether it is the SQL Server configuration or you connection string configuration.</p>
8,929
<p>I faced some problem with my 3D printer device. It seems the bed warms up without any problem, however, the hotend does not warm up! </p> <p>Could you please help me identify what the problem is? </p>
<p>I really hope the extruder doesn't warm up as this would be a problem with your stepper motor :)</p> <p>I'm sure you mean the hotend doesn't heat up. This could be a number of things but i would start to double check the pinout in your code vs the pins on your mainboard and measure if it gives 12v/24v (depending on your PSU) output.</p> <p>There's a lot more info required to properly help you. What board are you using? What OS are you using? Marlin or something else? Share the relevant code of the OS for the hotend config/pinout potentially share pictures of your wiring</p>
<p>First, I want to make sure if your hotend is really not heating up. If you are saying the numbers are not showing (like when it is heating, the number on display or octoprint says 0/180) this could be a Thermistor problem. Check to make sure if your hot end is heating up by putting a paper or filament under it. DO NOT touch with your hand.</p> <p>Second, If your hotend is truly not heating up, then several things can be happening.</p> <ol> <li>Your hotend is wired wrong. Make sure your board is correctly wired. </li> <li>Your hotend is dead. Change to different hotend and see if it works.</li> <li>Your hotend is not getting enough power. </li> </ol>
1,573
<p>I have been running my i3 MK3 for about 12 hours now and the motor on the extruder is fairly hot, not too hot to touch but I'd guess its about 60c on the outside. Is this within normal operating temperatures or should I let it cool down before starting more prints?</p>
<p>The maximum operating temperature can be found in the specifications of your steppers. Usually the ambient temperature operating conditions are limited to 50 &deg;C with a maximum operating temperature in the range of 70 - 100 &deg;C. For instance, the steppers I use are limited to a temperature of 80 &deg;C. It is however advised to keep this temperature lower, e.g. to max. 60 &deg;C to prolong the life. Do note that very high temperatures could be a problem for "self-printed" stepper mounts of the wrong material (materials with a low glass transition temperature).</p> <p>To answer your question: "Yes, steppers may get hot, but if you want them to get too hot is up to the mounting system and how long you want to use them."</p>
<p>I've run my Prusa3D i3m3s for 50 hour prints. My motors get hot-ish but on my instance of the machine, they are not too hot.</p>
1,076
<p>In the following snippet:</p> <pre><code>public class a { public void otherMethod(){} public void doStuff(String str, InnerClass b){} public void method(a){ doStuff("asd", new InnerClass(){ public void innerMethod(){ otherMethod(); } } ); } } </code></pre> <p>Is there a keyword to refer to the outer class from the inner class? Basically what I want to do is <code>outer.otherMethod()</code>, or something of the like, but can't seem to find anything.</p>
<p>In general you use <code>OuterClassName.this</code> to refer to the enclosing instance of the outer class.</p> <p>In your example that would be <code>a.this.otherMethod()</code></p>
<pre><code>OuterClassName.this.outerClassMethod(); </code></pre>
8,116
<p>Say I'm building an ASP.Net class that inherits from <code>IHttpHandler</code>, should I wire this up to a URL ending in <code>.ashx</code>, or should I use the <code>.axd</code> extension? </p> <p>Does it matter as long as there's no naming conflict?</p>
<p>Ahh.. ScottGu says it doesn't matter, but .ashx is slightly better because there's less chance of a conflict with things like trace.axd and others. That's why the flag went up in my head that .ashx might be better.</p> <p><a href="http://forums.asp.net/t/964074.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/964074.aspx</a></p>
<p>Out in "the wild", .ashx are definitely the most popular extension.</p>
7,690
<p>How would you reccommend handling RSS Feeds in ASP.NET MVC? Using a third party library? Using the RSS stuff in the BCL? Just making an RSS view that renders the XML? Or something completely different?</p>
<p>Here is what I recommend:</p> <ol> <li>Create a class called RssResult that inherits off the abstract base class ActionResult.</li> <li>Override the ExecuteResult method.</li> <li>ExecuteResult has the ControllerContext passed to it by the caller and with this you can get the data and content type.</li> <li><p>Once you change the content type to rss, you will want to serialize the data to RSS (using your own code or another library) and write to the response.</p></li> <li><p>Create an action on a controller that you want to return rss and set the return type as RssResult. Grab the data from your model based on what you want to return.</p></li> <li><p>Then any request to this action will receive rss of whatever data you choose.</p></li> </ol> <p>That is probably the quickest and reusable way of returning rss has a response to a request in ASP.NET MVC.</p>
<p>I got this from Eran Kampf and a Scott Hanselman vid (forgot the link) so it's only slightly different from some other posts here, but hopefully helpful and copy paste ready as an example rss feed.</p> <p><a href="http://achadwick.com/Blog/Result/MVC%20RSS%20Feed" rel="nofollow noreferrer">From my blog</a></p> <p><a href="http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/" rel="nofollow noreferrer">Eran Kampf</a></p> <pre><code>using System; using System.Collections.Generic; using System.ServiceModel.Syndication; using System.Web; using System.Web.Mvc; using System.Xml; namespace MVC3JavaScript_3_2012.Rss { public class RssFeed : FileResult { private Uri _currentUrl; private readonly string _title; private readonly string _description; private readonly List&lt;SyndicationItem&gt; _items; public RssFeed(string contentType, string title, string description, List&lt;SyndicationItem&gt; items) : base(contentType) { _title = title; _description = description; _items = items; } protected override void WriteFile(HttpResponseBase response) { var feed = new SyndicationFeed(title: this._title, description: _description, feedAlternateLink: _currentUrl, items: this._items); var formatter = new Rss20FeedFormatter(feed); using (var writer = XmlWriter.Create(response.Output)) { formatter.WriteTo(writer); } } public override void ExecuteResult(ControllerContext context) { _currentUrl = context.RequestContext.HttpContext.Request.Url; base.ExecuteResult(context); } } } </code></pre> <p>And the Controller Code....</p> <pre><code> [HttpGet] public ActionResult RssFeed() { var items = new List&lt;SyndicationItem&gt;(); for (int i = 0; i &lt; 20; i++) { var item = new SyndicationItem() { Id = Guid.NewGuid().ToString(), Title = SyndicationContent.CreatePlaintextContent(String.Format("My Title {0}", Guid.NewGuid())), Content = SyndicationContent.CreateHtmlContent("Content The stuff."), PublishDate = DateTime.Now }; item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri("http://www.google.com")));//Nothing alternate about it. It is the MAIN link for the item. items.Add(item); } return new RssFeed(title: "Greatness", items: items, contentType: "application/rss+xml", description: String.Format("Sooper Dooper {0}", Guid.NewGuid())); } </code></pre>
3,302
<p>I was wondering if anyone here had some experience writing this type of script and if they could give me some pointers.</p> <p>I would like to modify this <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="nofollow noreferrer">script</a> to validate that the check-in file does not have a Carriage Return in the EOL formatting. The EOL format is CR LF in Windows and LF in Unix. When a User checks-in code with the Windows format. It does not compile in Unix anymore. I know this can be done on the client side but I need to have this validation done on the server side. To achieve this, I need to do the following:</p> <p>1) Make sure the file I check is not a binary, I dont know how to do this with svnlook, should I check the mime:type of the file? The <a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html" rel="nofollow noreferrer">Red Book</a> does not indicate this clearly or I must have not seen it.</p> <p>2) I would like to run the <a href="http://linux.about.com/od/commands/l/blcmdl1_dos2uni.htm" rel="nofollow noreferrer">dos2unix</a> command to validate that the file has the correct EOL format. I would compare the output of the dos2unix command against the original file. If there is a diff between both, I give an error message to the client and cancel the check-in.</p> <p>I would like your comments/feedback on this approach.</p>
<p>I think you can avoid a commit hook script in this case by using the <code>svn:eol-style</code> property as described in the SVNBook:</p> <ul> <li><p><a href="http://svnbook.red-bean.com/en/1.7/svn.advanced.props.file-portability.html#svn.advanced.props.special.eol-style" rel="nofollow noreferrer">End-of-Line Character Sequences</a></p></li> <li><p><a href="http://svnbook.red-bean.com/en/1.7/svn.ref.properties.html" rel="nofollow noreferrer">Subversion Properties</a></p></li> </ul> <p>This way SVN can worry about your line endings for you.</p> <p>Good luck!</p>
<p>What exactly are you trying to do?</p> <p>Of course, there are numerous places to learn about svn pre-commit hooks (e.g. <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="nofollow noreferrer"> here </a>, <a href="http://www.windley.com/archives/2008/08/using_a_precommit_hook_to_check_puppet_syntax.shtml" rel="nofollow noreferrer"> here</a>, and in the <a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html" rel="nofollow noreferrer">Red Book</a>) but it depends what you're trying to do and what is available on your system. </p> <p>Can you be more specific? </p>
7,103
<p>I need to extract data from a .mpp file on the network and combine it with other data from several different databases. The application can be written in Perl, VB6, VB.net or C# but must be easily scheduled from a Windows based server.</p> <p>What would you recommend to extract the MS Project data with no user intervention? </p> <p>Is there any ODBC drivers available for MS Project? </p> <p>Are there any modules (for Perl, VB, VB.net or C#) for opening a .mpp and reading activity data?</p>
<p>I would recommend using MPXJ (<a href="http://mpxj.sf.net" rel="nofollow noreferrer">mpxj.sf.net</a>) to extract data from Microsoft Project files. Don't be put off by the fact that it was originally a Java library - the current release of MPXJ includes native .net dlls as well as the original Java JAR file, thanks to the magic of IKVM.</p> <p>Disclaimer: I maintain MPXJ.</p>
<p>I have the same need. Here is what I found so far. There is an OLEDB provider for microsoft projects, up to version MP 2007. If Google it, there are enough sites quoting the connection string, but here is the one quote:</p> <pre><code>oConn.Open "Provider=Microsoft.Project.OLEDB.9.0;" &amp; _ "Project Name=c:\somepath\myProject.mpp" </code></pre> <p>The problem with this approach seems to be that you have to install MS Project on the server. It is nuisance in any case, and an impossibility for me using hosting environtment.</p> <p>So you are down to parsing .mpp. MPXJ is an excellent library as one commenter above suggests, and I can afford to wait, so I am waiting for them to release .NET version. If you are resolved to get it done, get the code and see what they are doing. Other then in their source code/comments there is no (to my knowledge) documentation of the format.</p>
5,973
<p>Ok, I've seen a few posts that <em>mention</em> a few other posts about not using SP wikis because they suck.</p> <p>Since we are looking at doing our wiki <em>in</em> SP, I need to know why we shouldn't do it for a group of 6 automation-developers to document the steps in various automated processes and the changes that have to be made from time to time.</p>
<p>The default wiki included with Sharepoint doesn't support common wiki features well at all. There is no way to edit a single section of a page, and no way to link directly to a particular section on another page. The backend is in HTML so you lose the ability to edit in plaintext using simple syntax. The diff feature can't span multiple versions. Poor cross browser support of WYSIWYG editing. No way to auto-insert a table of contents...</p> <p>There are, however, other wiki add-ins for Sharepoint which I can't categorically dismiss, for instance <a href="http://www.atlassian.com/software/confluence/" rel="nofollow noreferrer">Confluence</a> makes an <a href="http://www.atlassian.com/sharepoint/" rel="nofollow noreferrer">add-in for Sharepoint</a>. I haven't evaluated this software myself, and Confluence is somewhat expensive ($1,200 for 25 user license) although if you are already on Sharepoint I sense large corporate coffers :P. There also appear to be some free add-ins like <a href="http://www.codeplex.com/CKS/Wiki/View.aspx?title=Enhanced%20Wiki%20Edition&amp;referringTitle=Home" rel="nofollow noreferrer">CKS Enhanced Wiki</a> but that appears to have a lot of the same problems mentioned above.</p>
<p>My company rolled out sharepoint recently, and I have to say my user experience was <strong><em>Very Bad</em></strong>. And I'm not just saying I was apprehensive to using it: I went in with an open mind and tried it, and many things just felt like they didn't really work right.</p> <p>The reasons Luke mentioned more or less cover it. </p> <p>Why wouldn't you consider using something else like <a href="http://www.screwturn.eu/Default.aspx?AspxAutoDetectCookieSupport=1" rel="nofollow noreferrer">Screwturn Wiki</a> which <a href="http://www.codinghorror.com/blog/archives/001098.html" rel="nofollow noreferrer">Jeff donated</a> to a short while ago? I haven't used Screwturn myself, but it is free and open source, and may be a faster lightweight solution for what you need.</p>
3,258
<p>Does any one know how the event handler manages the posted events?</p> <p>In my app i have two threads (<em>guiThread</em> and <em>computationThread</em>). After an exception is thrown I call <code>postEvent(..)</code> to an existing dialog. The Qt-Event-Handler holds this one back until the dialog is closed. </p> <hr> <p>Sorry my question is a bit cloudy. I will write it more exactly, if I have time left. I found a work around. But for me the problem is still interesting.</p>
<p>As mentionned in the Qt documentation about <a href="http://doc.qt.io/qt-4.8/qcoreapplication.html#postEvent" rel="nofollow noreferrer">QCoreApplication::postEvent</a> :</p> <blockquote> <p>When control returns to the main event loop, all events that are stored in the queue will be sent using the notify() function. </p> </blockquote> <p>...which explains why the Qt Event Handler holds the event until the dialog is closed. </p> <p>If I understand correctly what you want to do, I would try using <a href="http://doc.qt.io/qt-4.8/qcoreapplication.html#sendEvent" rel="nofollow noreferrer">sendEvent</a>.</p>
<p>As others already wrote, I believe this behavior is caused by the fact that the dialog starts its own event loop.</p> <p>If you use Qt4, you can try using <a href="http://doc.qt.io/qt-4.8/threads-qobject.html#signals-and-slots-across-threads" rel="nofollow noreferrer">queued signal/slot connections</a> as an alternative to posting events.</p>
7,607
<p>It's about PHP but I've no doubt many of the same comments will apply to other languages.</p> <p>Simply put, what are the differences in the different types of loop for PHP? Is one faster/better than the others or should I simply put in the most readable loop?</p> <pre><code>for ($i = 0; $i &lt; 10; $i++) { # code... } foreach ($array as $index =&gt; $value) { # code... } do { # code... } while ($flag == false); </code></pre>
<p>For loop and While loops are entry condition loops. They evaluate condition first, so the statement block associated with the loop won't run even once if the condition fails to meet </p> <p>The statements inside this for loop block will run 10 times, the value of $i will be 0 to 9;</p> <pre><code>for ($i = 0; $i &lt; 10; $i++) { # code... } </code></pre> <p>Same thing done with while loop:</p> <pre><code>$i = 0; while ($i &lt; 10) { # code... $i++ } </code></pre> <p>Do-while loop is exit-condition loop. It's guaranteed to execute once, then it will evaluate condition before repeating the block</p> <pre><code>do { # code... } while ($flag == false); </code></pre> <p>foreach is used to access array elements from start to end. At the beginning of foreach loop, the internal pointer of the array is set to the first element of the array, in next step it is set to the 2nd element of the array and so on till the array ends. In the loop block The value of current array item is available as $value and the key of current item is available as $index.</p> <pre><code>foreach ($array as $index =&gt; $value) { # code... } </code></pre> <p>You could do the same thing with while loop, like this </p> <pre><code>while (current($array)) { $index = key($array); // to get key of the current element $value = $array[$index]; // to get value of current element # code ... next($array); // advance the internal array pointer of $array } </code></pre> <p>And lastly: <a href="http://www.php.net/download-docs.php" rel="noreferrer">The PHP Manual</a> is your friend :)</p>
<p>I use the first loop when iterating over a conventional (indexed?) array and the foreach loop when dealing with an associative array. It just seems natural and helps the code flow and be more readable, in my opinion. As for do...while loops, I use those when I have to do more than just flip through an array.</p> <p>I'm not sure of any performance benefits, though.</p>
4,282
<p>I didn't have any printer-related problem for the past 6 months, but now all of a sudden my Prusa MK3S stopped extruding during printing.</p> <p>This is very strange as I can easily load\unload filament and control the step motor via Settings\Move axis\Extruder. When I did so, the filament got extruded normally.</p> <p>However, when I try to print something or do First Layer Calibration, nothing comes out of the nozzle. I tried changing the Live Z (maybe nozzle too low) and it didn't help. I once managed to extrude <em>something</em> by increasing the temperature and the flow (in the printer's menu) to a ridiculous value of 999. Obviously, this isn't the best way to solve the problem.</p> <p>Is there an easy way to fix this? I only had this problem yesterday and with some midrange-priced PETG</p> <p>Edit: I tried different filaments, default slicer profiles, reinstalling slicer (prusa slicer) and drivers. None of these methods really helped.</p>
<ol> <li><p>It doesn't seem to be heat creep. See <a href="https://3dprinting.stackexchange.com/questions/15629/what-are-ways-to-avoid-heat-creep">What are ways to avoid heat creep?</a></p> </li> <li><p>Have you measured the actually temperature of the heater block? You may have a failing sensor (thermistor) or sensor circuitry. Optically is the best way to measure. The least expensive way is with multimeters that come with a temperature sensor, such as a thermocouple (lowest cost about $20 U.S.).</p> </li> </ol>
<p>As it turned out, rebuilding the extruder actually helped. I took it apart to the point where both fans were loose as well as the extruder motor and the hotend. I didn't find anything wrong after a quick look so I put it all back together.</p> <p>Then i ran the first layer calibration and for some reason it worked. I know it's neither the most satisfying solution, nor the most informative one, so sorry about that. Either way, thank you for the suggestions, I still have no idea what caused the problem.</p> <p>That being said, I hypothesize that something was wrong with the hotend. That is because when I had this probem, molten filament wouldn't exit the heated nozzle on its own. Now when I heat up the hotend, the filament comes out (without the motor working)</p>
1,976
<p>There are a couple of things that I am having a difficult time understanding with regards to developing custom components in JSF. For the purposes of these questions, you can assume that all of the custom controls are using valuebindings/expressions (not literal bindings), but I'm interested in explanations on them as well.</p> <ol> <li>Where do I set the value for the valuebinding? Is this supposed to happen in decode? Or should decode do something else and then have the value set in encodeBegin?</li> <li>Read from the Value Binding - When do I read data from the valuebinding vs. reading it from submittedvalue and putting it into the valuebinding? </li> <li>When are action listeners on forms called in relation to all of this? The JSF lifecycle pages all mention events happening at various steps, but its not completely clear to me when just a simple listener for a commandbutton is being called</li> </ol> <p>I've tried a few combinations, but always end up with hard to find bugs that I believe are coming from basic misunderstandings of the event lifecycle.</p>
<p>There is a pretty good diagram in the <a href="http://java.sun.com/javaee/javaserverfaces/download.html" rel="noreferrer">JSF specification</a> that shows the request lifecycle - essential for understanding this stuff.</p> <p>The steps are:</p> <ul> <li><strong>Restore View</strong>. The UIComponent tree is rebuilt.</li> <li><strong>Apply Request Values</strong>. Editable components should implement EditableValueHolder. This phase walks the component tree and calls the <em>processDecodes</em> methods. If the component isn't something complex like a UIData, it won't do much except call its own <em>decode</em> method. The <em>decode</em> method doesn't do much except find its renderer and invokes its <em>decode</em> method, passing itself as an argument. It is the renderer's job to get any submitted value and set it via <em>setSubmittedValue</em>.</li> <li><strong>Process Validations</strong>. This phase calls <em>processValidators</em> which will call <em>validate</em>. The <em>validate</em> method takes the submitted value, converts it with any converters, validates it with any validators and (assuming the data passes those tests) calls <em>setValue</em>. This will store the value as a local variable. While this local variable is not null, it will be returned and not the value from the value binding for any calls to <em>getValue</em>.</li> <li><strong>Update Model Values</strong>. This phase calls <em>processUpdates</em>. In an input component, this will call <em>updateModel</em> which will get the <em>ValueExpression</em> and invoke it to set the value on the model.</li> <li><strong>Invoke Application</strong>. Button event listeners and so on will be invoked here (as will navigation if memory serves).</li> <li><strong>Render Response</strong>. The tree is rendered via the renderers and the state saved.</li> <li>If any of these phases fail (e.g. a value is invalid), the lifecycle skips to Render Response.</li> <li>Various events can be fired after most of these phases, invoking listeners as appropriate (like value change listeners after Process Validations).</li> </ul> <p>This is a somewhat simplified version of events. Refer to the specification for more details.</p> <p>I would question why you are writing your own UIComponent. This is a non-trivial task and a deep understanding of the JSF architecture is required to get it right. If you need a custom control, it is better to create a concrete control that extends an exisiting UIComponent (like HtmlInputText does) with an equivalent renderer.</p> <p>If contamination isn't an issue, there is an open-source JSF implementation in the form of Apache MyFaces.</p>
<p>The best article I've found is <a href="http://blogs.steeplesoft.com/jsf-component-writing-check-list/" rel="nofollow noreferrer">Jsf Component Writing</a>, as for 2 where do I read the value for a value binding in your component you have a getter that looks like this</p> <pre><code> public String getBar() { if (null != this.bar) { return this.bar ; } ValueBinding _vb = getValueBinding("bar"); return (_vb != null) ? (bar) _vb.getValue(getFacesContext()) : null; } </code> </pre> <p>how did this get into the getValueBinding? In your tag class setProperties method</p> <pre><code> if (bar!= null) { if (isValueReference(bar)) { ValueBinding vb = Util.getValueBinding(bar); foo.setValueBinding("bar", vb); } else { throw new IllegalStateException("The value for 'bar' must be a ValueBinding."); } } </code></pre>
5,355
<p>So I've looked at <a href="http://mjtemplate.org/examples/freebase/names.html?name=%EB%A1%9C%EB%A7%88&amp;lang=ko" rel="nofollow noreferrer">this use</a> of the <a href="http://freebase.com" rel="nofollow noreferrer">freebase</a> API and I was really impressed with the translations of the name that it found. IE Rome, Roma, Rom, Rzym, Rooma,로마, 罗马市. This is because I have a database of some 5000+ location names and I would very much like all French, German or Korean translations for these English names.</p> <p>The problem is I spent about two hours clicking around freebase, and could find no way to get a view of city/location names in a different language mapped to English. So I'd love it if someone who understands what freebase is and how it's organized could get me a link to that view which theoretically I could then export.</p> <p>Also I just wanted to share this question because I'm totally impressed with freebase and think if people haven't looked at it they should.</p>
<p>I'll second the vote for <a href="http://www.telerik.com" rel="nofollow noreferrer">Telerik</a>. Their controls for the most part &quot;just work&quot; and their support has been excellent. I primarily use their forums and I still receive a response within a day (unlike some other vendors who barely seem to notice that they've even got a forum).</p> <p>It also feels like they've actually spent time trying out a lot of the ways customer's will use their controls. The documentation and support reflects it. They aren't perfect, though. One issue that they had in the past, and that they've addressed in the latest releases (what they were calling their &quot;Prometheus&quot; controls, now just &quot;Rad Controls for ASP.NET AJAX&quot;) is the performance of the controls. In previous releases they were definitely a bit sluggish (I'm thinking specifically of their RadGrid and RadEditor). Now they're noticeably faster (esp. the RadEditor - it loads MUCH faster).</p> <p>Overall I wouldn't think twice of recommending them.</p>
<p><a href="http://www.componentart.com" rel="nofollow noreferrer">ComponentArt</a> has some pretty cool controls. You might want to check out <a href="http://www.telerik.com" rel="nofollow noreferrer">Telerik</a> as well. Both companies offer pretty easy to use controls that look nice.</p>
5,357
<p>I need a list of integers from 1 to x where x is set by the user. I could build it with a for loop eg assuming x is an integer set previously:</p> <pre><code>List&lt;int&gt; iList = new List&lt;int&gt;(); for (int i = 1; i &lt;= x; i++) { iList.Add(i); } </code></pre> <p>This seems dumb, surely there's a more elegant way to do this, something like the <a href="http://au2.php.net/manual/en/function.range.php" rel="noreferrer">PHP range method</a></p>
<p>If you're using .Net 3.5, <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.range.aspx" rel="noreferrer">Enumerable.Range</a> is what you need.</p> <blockquote> <p>Generates a sequence of integral numbers within a specified range.</p> </blockquote>
<p>Here is a short method that returns a List of integers.</p> <pre><code> public static List&lt;int&gt; MakeSequence(int startingValue, int sequenceLength) { return Enumerable.Range(startingValue, sequenceLength).ToList&lt;int&gt;(); } </code></pre>
7,170
<p>I am using a Visual Studio project with custom build script/batch file (ala make, ant, etc.).</p> <p>When the build is run from the command line we have placed colored highlighting on various output lines.</p> <p>However, when built via Visual Studio (2005 in my case) the output window does not show the color anymore.</p> <p>Is this possible? I am quite happy to put specific code into the build script if required.</p>
<p>If you don't want to go with the pro version of the VSCommands plug-in, there is a free one called VSColorOutput, which does just that. I've worked with it a bit, does what it says.</p> <p>See <a href="http://coolthingoftheday.blogspot.com/2011/12/vscoloroutput-visual-studio-output.html" rel="noreferrer">http://coolthingoftheday.blogspot.com/2011/12/vscoloroutput-visual-studio-output.html</a> or look it up in the extension gallery.</p>
<p>The problem isn't with your build scripts, but with Visual Studio not supporting <a href="http://en.wikipedia.org/wiki/ANSI_escape_code" rel="noreferrer">ANSI control codes</a> to change the color.</p>
7,245
<p>It seems like the generation of SQL scripts from the SQL Server Management Studio is terribly slow. I think that the old Enterprise Manager could run laps around the newer script generation tool. I've seen a few posts here and there with other folks complaining about the speed, but I haven't seen much offered in the way of alternatives.</p> <p>Is there a low-cost/free tool for scripting an entire SQL Server 2005 database that will perform better that SSMS? It would be hard to do worse. </p>
<p>See the <a href="http://www.codeplex.com/sqlhost/Wiki/View.aspx?title=Database%20Publishing%20Wizard" rel="nofollow noreferrer">Database Publishing Wizard</a> that is part of the <strong>SQL Server Hosting Toolkit</strong>. It generates a single SQL file for both schema and data.</p>
<p>I don't know what is "terribly slow" for you, but I have a decent performance with SQL 2005 Management Studio. In either case, <a href="http://www.red-gate.com/" rel="nofollow noreferrer">RedGate</a> products are very cool. Unfortunately they are not free.</p>
5,121
<p>I'm developing a C# application that uses a handful of XML files and some classes in System.Xml. A coworker insists on adding the MSXML6 redistributable to our install, along with the .NET framework but I don't think the .NET framework uses or needs MSXML in anyway. I am well aware that using MSXML from .NET is not supported but I suppose its theoretically possible for System.Xml itself to wrap MSXML at a low level. I haven't found anything definitive that .NET has its own implementation but neither can I find anything to suggest it needs MSXML. </p> <p>Help me settle the debate. Does System.Xml use MSXML?</p>
<p>System.Xml doesn't use MSXML6. They are seperate xml processing engines. See post here: <a href="https://web.archive.org/web/20120203153429/http://blogs.msdn.com/b/stan_kitsis/archive/2005/09/20/472185.aspx" rel="nofollow noreferrer">MSXML 6.0 vs. System.Xml: Schema handling differences</a></p>
<p>I think it's needed for some MsSql-XML functionality, but System.Xml is in the core framework.</p> <p>You should test your installer on a fresh machine anyway, just to be sure.</p>
3,364
<h3>TL;DR</h3> <p>Is ABS a better material to use for structural parts of a 3D printer, as opposed to PLA?</p> <hr /> <p>I have been looking at various suppliers of printed parts for a <a href="http://reprap.org/wiki/Wilson_TS#Wilson_II" rel="noreferrer">Wilson II</a>, on eBay.</p> <p><a href="http://www.ebay.co.uk/itm/252871697915" rel="noreferrer">One supplier</a> supplies all of the parts printed in ABS, whereas <a href="http://www.ebay.co.uk/itm/182099145671" rel="noreferrer">another supplier</a> provides the structural parts, which form part of the frame, in PLA, and the remaining (non-structural) parts in ABS. The second supplier states the following:</p> <blockquote> <p>This kit is printed in two materials, the structural parts are printed on high-quality PLA to provide the necessary rigidity, and the others in premium ABS.</p> </blockquote> <p>MJRice, who developed the printer, also supplies <a href="https://www.tindie.com/products/mjrice/reprap-wilson-ii-plastic-parts-kit/" rel="noreferrer">the printed parts</a>, which are made of PLA.</p> <p>Is PLA really a better choice for structural components? A quick google lead me to <a href="http://www.digitaltrends.com/cool-tech/abs-vs-pla-3d-printing-materials-comparison/" rel="noreferrer">ABS or PLA: Which 3D printing filament should you use?</a></p> <blockquote> <p><strong>ABS is going to give your projects better structural integrity and will be more suited to mechanical use</strong> given the material can better withstand the elements, but it will also require specific types of printers and printing surfaces. On the flip side, PLA will give you more precise prints and better aesthetic quality, as well as more flexibility with printing conditions if you can do without the <strong>strength and resilience of ABS</strong>.</p> </blockquote> <p>Another link, <a href="https://groups.google.com/forum/#!topic/makerbot/JiPjCMt0-Bc" rel="noreferrer">What's stronger? PLA or ABS?</a>, also implies that ABS is stronger than PLA:</p> <blockquote> <p>The strongest ABS is stronger than the strongest PLA</p> </blockquote> <p>and</p> <blockquote> <p>ABS is much less brittle than PLA</p> </blockquote> <p>although warpage could be an issue...</p> <blockquote> <p>I choose ABS for it's strength over PLA. <em>I would love to avoid the warpage/shrinkage problems of ABS</em>.</p> </blockquote> <p>Heat seems to affect PLA more than ABS (obviously, due to the lower melting point),</p> <blockquote> <p>FWIW, I know a guy who had a reprap using PLA-printed parts. He was taking his machine around to do demos and he left it in the car mid-day once. It melted the parts enough that prints were coming out very poorly even after his best effort at recalibrating the machine.</p> </blockquote> <p>and as I am in Thailand, my room gets up to 50°C some days (it is unbearable), I wonder if that would be cause for concern?</p> <p>So, from the above nuggets of information, wouldn't ABS be a better choice? I am surely missing something, as both the second supplier, <em>and</em> MJRice, use PLA.</p>
<p>To answer the main question "Is ABS better for structural parts of a 3D printer as opposed to PLA".</p> <p>The answer, unfortunately is it depends.</p> <p>ABS has lower yield and ultimate strengths compared to PLA. This means that at room temperatures, ABS is weaker than PLA. However the difference between yield and ultimate for ABS is much larger than PLA, meaning that ABS parts will deform, noticeably so before breaking. This <em>can</em> be a good thing. If your ABS part is highly loaded, you may want to be able to inspect it for overloading. The plastic deformation that occurs in ABS may be sufficient for you to identify, and modify your parts before a catastrophic failure. With PLA though since the two strengths are quite close, your part would more than likely fail completely without any warning or deformation before it. So in terms of strength, it's a design consideration. Would you rather have a slightly weaker part that shows signs of load failure, or is a catastrophic failure acceptable. There are use cases where either may be better.</p> <p>As Ecnerwal pointed out, PLA has a lower Tg (glass transition temperature) compared to ABS. If your printed parts are going on a 3D printer and aren't sufficiently isolated from the hot parts (print bed or extruder) then you may end up having some localized deformation. That being said, the extruder is generally pretty localized and likely won't cause you too many issues assuming you're using any of the already available 3D printer designs out there, same for the print bed. However by the sounds of it your 'room' temperature is a fair bit higher than here in North America, by a factor of almost 2! This <em>could</em> cause you some issues if you're printing parts in the high heat with PLA. Your best option would be ABS, but even with it's higher Tg (roughly 90C if I remember correctly) you may still run into issues. </p> <p>The warping and shrinkage issues mentioned in the question seem to be more about parts being built by a 3D printer. Once the parts are built warpage and shrinkage are essentially a non-issue unless you've heated parts back to within their melting temperatures.</p> <p>Depending on where you're getting your plastic parts, there may be a third option. By the sounds of it you're looking at building your own printer. You may be able to get the STL files of the printed parts you need and then have someone print them for you in a stronger material such as Nylon. </p> <p>Assuming alternative materials aren't an option I would personally suggest going with ABS for your use case. My reasoning is purely due to the potential operating temperatures. While 50C is below the Tg for PLA it's getting very close.</p>
<p>Actually, Both PLA and ABS could use for structural parts. PLA has high strength and is brittleness. ABS has better thermal resistance and durable. <a href="https://ecoreprap.com/pla-vs-abs/" rel="nofollow noreferrer">PLA and ABS</a> are the main types of 3D printing material, each has cons and pros.</p> <p>If you want to choose which type, you need to know the detailed application.</p>
584
<p>Is there anyone working solo and using fogbugz out there? I'm interested in personal experience/overhead versus paper.</p> <p>I am involved in several projects and get pretty hammered with lots of details to keep track of... Any experience welcome.</p> <p>(Yes I know Mr. Joel is on the stackoverflow team... I still want good answers :)</p>
<p>I use it, especially since the hosted Version of FugBugz <a href="https://stackoverflow.com/questions/3180/anyone-soloing-using-fogbugz#3581">is free for up to 2 people</a>. I found it a lot nicer than paper as I'm working on multiple projects, and my paper tends to get rather messy once you start making annotations or if you want to re-organize and shuffle tasks around, mark them as complete only to see that they are not complete after all...</p> <p>Plus, the Visual Studio integration is really neat, something paper just cannot compete with. Also, if you lay the project to rest for 6 months and come back, all your tasks and notes are still there, whereas with paper you may need to search all the old documents and notes again, if you did not discard it.</p> <p>But that is just the point of view from someone who is not really good at staying organized :-) If you are a really tidy and organized person, paper may work better for you than it does for me.</p> <p>Bonus suggestion: Run Fogbugz on a second PC (or a small Laptop like the eeePC) so that you always have it at your fingertips. The main problem with Task tracking programs - be it FogBugz, Outlook, Excel or just notepad - is that they take up screen space, and my two monitors are usually full with Visual Studio, e-Mail, Web Browsers, some Notepads etc.</p>
<p>Yea FogBugz is great for process-light, quick and easy task management. It seems especially well suited for soloing, where you don't need or want a lot of complexity in that area. </p> <p>By the way, if you want to keep track of what you're doing at the computer all day, check out TimeSprite, which integrates with FogBugz. It's a Windows app that logs your active window and then categorizes your activity based on the window title / activity type mappings you define as you go. (You can also just tell it what you're working on.) And if you're a FogBugz user, you can associate your work with a FogBugz case, and it will upload your time intervals for that case. This makes accurate recording of elapsed time pretty painless and about as accurate as you can get, which in turn improves FogBugz predictive powers in its evidence-based scheduling. Also, when soloing, I find that such specific logging of my time keeps me on task, in the way a meandering manager otherwise might. (I'm not affiliated with TimeSprite in any way.)</p>
2,536
<p>I have a LARGE piece of glass (36"x26") that I will soon be printing on using my newly build MPCNC machine. It is capable of printing about 34"x34"x10".</p> <p>Anyway, I have had GREAT success printing on heated glass that is sprayed lightly with hairspray using PLA and being able to EASILY remove my prints after the glass has cooled. I attribute this to the slight expansion and contraction that occurs when glass is heated and cooled. This would weaken the cohesion of the PLA print to the glass.</p> <p>I have another posting where I asked how to heat this LARGE glass bed. However, there weren't any feasable (inexpensive and easy) solutions to heat the glass. So, now with cold glass, what are some good strategies for removing large 3d printed objects without breaking them or the glass?</p>
<p>Because you will be printing on unheated glass, you will be using some form of adhesive material. If you use an off-the-shelf glue stick, you will likely find it is water soluble. If the bed is removable, immersing it in warm water for a relaxing soak will provide easier model removal. </p> <p>I don't have experience with various tapes, so will avoid recommendations regarding masking tapes or similar material.</p> <p>Thermal cycling will also provide release. Not a heat gun, as that will break the glass, but a hair dryer applied to the underside near the model, then cooling. Repeat until it releases.</p> <p>I have used the Fleks3D print plate on my Flux Delta printer in the past, and it releases "like magic" but I don't think they make monster sheets of your printer size. I had also purchased a pair of 20" square Fleks3D plates for a similarly sized printer that never materialized. I'd be happy to sell you the pair, but I think they are too small for your full plate.</p> <p>It has been said that one can use sand-blasted acrylic, which I believe is the construction of the aforementioned Fleks3D plates. If you have access to 1/8" or 3mm acrylic and can apply a uniform blast of abrasive, you may be able to construct your own easy-release build plate.</p> <p>It is practical to consider to use a raft for your large builds. Rafts are useful for small items, to provide a greater bonding surface and avoid release, but it also provides a "wedging" location for your release tool. You can more easily slice away the middle of the raft and deal with a thinner layer after the model is completely freed.</p> <p>EDIT ADD: If the bed is not removable, one can build a dam around the model with clay to hold the water for dissolving the glue.</p>
<p>3M Blue decorators tape works well for me. You can get it in different widths. I find giving it a little sand paper rub before each print helps corners to stay down and improves first layer print. I replace about every 10 prints depending on the importance of the print.</p>
374
<p>C++ seems to be rather grouchy when declaring templates across multiple files. More specifically, when working with templated classes, the linker expect all method definitions for the class in a single compiler object file. When you take into account headers, other declarations, inheritance, etc., things get really messy. </p> <p>Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files?</p>
<blockquote> <p>Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files?</p> </blockquote> <p>Yes; don't.</p> <p>The C++ spec permits a compiler to be able to "see" the entire template (declaration <em>and</em> definition) at the point of instantiation, and (due to the complexities of any implementation) most compilers retain this requirement. The upshot is that #inclusion of any template header must also #include any and all source required to instantiate the template.</p> <p>The easiest way to deal with this is to dump everything into the header, inline where posible, out-of-line where necessary.</p> <p>If you really regard this as an unacceptable affront, a common option is to split the template into the usual header/implementation pair, and then #include the implementation file at the end of the header.</p> <p>C++'s "export" feature may or may not provide another workaround. The feature is poorly supported and poorly defined; although it in principle should permit some kind of separate compilation of templates, it doesn't necessarily obviate the demand that the compiler be able to see the entire template body.</p>
<p>When/if your compiler supports C++0x, the <code>extern</code> keyword can be used to separate template declarations from definitions.</p> <p>See <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Extern_template" rel="nofollow noreferrer">here</a> for a brief explanation.</p> <p>Also, section 6.3, "The Separation Model," of <em>C++ Templates: The Complete Guide</em> by David Vandevoorde and Nicolai M. Josuttis describes other options.</p> <p><img src="https://i.stack.imgur.com/fD0vx.gif" alt="alt text"></p>
5,666
<p>What command checks if a directory exists or not within a Bash shell script?</p>
<p>To check if a directory exists:</p> <pre><code>if [ -d &quot;$DIRECTORY&quot; ]; then echo &quot;$DIRECTORY does exist.&quot; fi </code></pre> <p>To check if a directory does not exist:</p> <pre><code>if [ ! -d &quot;$DIRECTORY&quot; ]; then echo &quot;$DIRECTORY does not exist.&quot; fi </code></pre> <hr /> <p>However, as <a href="https://stackoverflow.com/users/1438/jon-ericson">Jon Ericson</a> points out, subsequent commands may not work as intended if you do not take into account that a symbolic link to a directory will also pass this check. E.g. running this:</p> <pre><code>ln -s &quot;$ACTUAL_DIR&quot; &quot;$SYMLINK&quot; if [ -d &quot;$SYMLINK&quot; ]; then rmdir &quot;$SYMLINK&quot; fi </code></pre> <p>Will produce the error message:</p> <pre class="lang-none prettyprint-override"><code>rmdir: failed to remove `symlink': Not a directory </code></pre> <p>So symbolic links may have to be treated differently, if subsequent commands expect directories:</p> <pre><code>if [ -d &quot;$LINK_OR_DIR&quot; ]; then if [ -L &quot;$LINK_OR_DIR&quot; ]; then # It is a symlink! # Symbolic link specific commands go here. rm &quot;$LINK_OR_DIR&quot; else # It's a directory! # Directory command goes here. rmdir &quot;$LINK_OR_DIR&quot; fi fi </code></pre> <hr /> <p>Take particular note of the double-quotes used to wrap the variables. The reason for this is explained by 8jean <a href="https://stackoverflow.com/a/67458/102401">in another answer</a>.</p> <p>If the variables contain spaces or other unusual characters it will probably cause the script to fail.</p>
<p>From script file <em>myScript.sh</em>:</p> <pre><code>if [ -d /home/ec2-user/apache-tomcat-8.5.5/webapps/Gene\ Directory ]; then echo "Directory exists!" echo "Great" fi </code></pre> <p><em>Or</em></p> <pre><code>if [ -d '/home/ec2-user/apache-tomcat-8.5.5/webapps/Gene Directory' ]; then echo "Directory exists!" echo "Great" fi </code></pre>
8,459
<p>I have an Excel Spreadsheet like this</p> <pre> id | data for id | more data for id id | data for id id | data for id | more data for id | even more data for id id | data for id | more data for id id | data for id id | data for id | more data for id </pre> <p>Now I want to group the data of one id by alternating the background color of the rows</p> <pre> var color = white for each row if the first cell is not empty and color is white set color to green if the first cell is not empty and color is green set color to white set background of row to color </pre> <p>Can anyone help me with a macro or some VBA code</p> <p>Thanks</p>
<p>I use this formula to get the input for a conditional formatting:</p> <pre><code>=IF(B2=B1,E1,1-E1)) [content of cell E2] </code></pre> <p>Where column B contains the item that needs to be grouped and E is an auxiliary column. Every time that the upper cell (B1 on this case) is the same as the current one (B2), the upper row content from column E is returned. Otherwise, it will return 1 minus that content (that is, the outupt will be 0 or 1, depending on the value of the upper cell).</p> <p><img src="https://i.stack.imgur.com/H6WP0.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/sE57q.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/4hadL.png" alt="enter image description here"></p>
<p>I use this rule in Excel to format alternating rows:</p> <ol> <li>Highlight the rows you wish to apply an alternating style to.</li> <li>Press "Conditional Formatting" -> New Rule</li> <li>Select "Use a formula to determine which cells to format" (last entry)</li> <li>Enter rule in format value: <strong><code>=MOD(ROW(),2)=0</code></strong></li> <li>Press "Format", make required formatting for alternating rows, eg. Fill -> Color.</li> <li>Press OK, Press OK.</li> </ol> <p>If you wish to format alternating columns instead, use <strong><code>=MOD(COLUMN(),2)=0</code></strong></p> <p>Voila!</p>
4,665
<p>I have this wing design that I want to print:</p> <p><a href="https://i.stack.imgur.com/EF87K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EF87K.png" alt="wing"></a></p> <p>You can notice that its walls have a thickness, which is 1.0&nbsp;mm. I want to print it so that the perimeters are inside that thickness. Here is the wing sliced with 1 perimeter and 0% infill:</p> <p><a href="https://i.stack.imgur.com/MvFDx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MvFDx.png" alt="wing detail"></a></p> <p>You can notice a gap between the perimeters. That gap is what I want filled and not the perimeters in the image. With 0 perimeters and 100% infill I got this zig-zagged line:</p> <p><a href="https://i.stack.imgur.com/U048S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U048S.png" alt="Zigzag filled gap between perimeters"></a></p> <p>I want the gap to be filled; but, I don't want it to be zig-zagged like in the image. I want it to be smooth like the perimeters in the other image.</p> <p>Basically I want a smooth infill that goes around the curves just like the perimeters. The reason why I don't want to print both the perimeters and the infill is because I want to save as much weight a possible as this is a wing of a model plane that must fly, so the lighter it is the more efficient it will be.</p> <p>Any ideas how I can slice this?</p> <p>The images are screenshots in Slic3r, but I can use Cura as well. This is just a test slice. The wing model is not finished yet.</p>
<p>I found a great solution!</p> <p>In Cura, there is a setting under <strong>Shell</strong> called <strong>Horizontal Expansion</strong>. What this does is it controls the distance between the two perimeters. A negative value in this field will make them come closer together, thus removing the gap between them.</p> <p><a href="https://i.stack.imgur.com/tRWQU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tRWQU.png" alt="Horizontal Expansion settings dialog"></a></p> <p>I found that -0.1 is the perfect value for 1 mm thick walls like the ones in my design. So I set it to -0.1, then set the infill to 100% because in some spots the thickness is a little bit more than 1 mm, so the infill closes the gaps in those places. Here is the result:</p> <p><a href="https://i.stack.imgur.com/nZ7fD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nZ7fD.png" alt="Image of Solid perimeters"></a></p> <p>You can see the perimeters are now sticking to each other and there is no gap between them. The result estimated weight is 71 g, which is a quite good reduction from the estimated 92 g when not using horizontal expansion.</p>
<p>Consider to create a test print using the settings you've presented in the sliced output rendering. It could be something as small as a 4 or 5 mm tall cross section, enough to get clear of the bed and establish a stable base. You may find that your goal is achieved.</p> <p>Also consider that a common nozzle diameter is 0.4 mm and with an extrusion multiplier, you may not reach a clean integer combination. That is to say, a 0.4 mm nozzle and a 1.05 extrusion factor results in (theoretically) a build thickness of 0.42 mm. Take two of those and you have 0.84, but three of them are 1.26 mm.</p> <p>You can increase number of wall thicknesses or reduce them as needed to avoid infill or the attempt by the printer to create infill. It may be necessary to adjust your model parameters to achieve a clean combination.</p> <p>I know that Slic3r supports concentric infill, which will effectively trace the walls rather than turn them into zig-zag shapes. On a base layer, having such a pattern may make for a weaker layer, but you can adjust so many things in that respect that you should be able to accomplish your objective.</p> <p>Experimentation is useful in a situation such as this. What Slic3r shows you isn't necessarily what will hit the bed.</p>
618
<p>I've been trying to find a 3D printer filament which would not release any chemicals if in contact with heated water for a substantial amount of time. So far, I've easily ruled out both PLA and ABS, as they're not considered food safe from what I can find. I have found PETG filament, which seems to be food safe. </p> <p>My question is: "Is there's anything special you'd have to do to make sure the print is food safe, or as in my case, to make sure it's safe for usage in a mug?".</p> <p>I will be using a steel extruder as brass ones may contain lead.</p>
<p>Many manufactures list their filaments as being food safe, but I would not treat this as "gospel truth". Apparently, the FDA considers PETG to be safe for food contact, but they are probably thinking about injection-moulded and vacuum-formed parts. Unfortunately, an initial search of the FDA's website did not yield any definitive information.</p> <p>Even if a particular filament is genuinely food safe, that does not mean that a 3D-printed part made from it will be food safe, since there will be an abundance of nooks and crannies where bacteria can lodge and reproduce. You would have to sterilise a utensil before and after every use to be absolutely safe.</p> <p>Anyway, good luck with making a water-tight mug with an FDM printer. You will probably have to seal it to make it water-tight, and then it will be the food-safety of the sealant that you will need to worry about. I would give it a miss, if I were you (at least, for other people's use). Items intended for one-time use would be OK, I suppose.</p>
<p>As far as PET-based filaments go, most of them are FDA approved. So yes, "food safe". It's the process of 3D printing that ruins that. all the little layers trap just about everything and are hard to clean. If you wanted to boil your part, that might work, but you'd be better off buying a food-safe coating spray for your parts.</p>
1,213
<p>I'm working with a fairly simple database, from a Java application. We're trying to insert about 200k of text at a time, using the standard JDBC mysql adapter. We intermittently get a <code>com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column error.</code></p> <p>The column type is <code>longtext</code>, and database collation is <code>UTF-8</code>. The error shows up using both <code>MyISAM</code> and <code>InnoDB</code> table engines. Max packet size has been set ot 1 GB on both client and server sides, so that shouldn't be causing a problem, either.</p>
<p>Check that your UTF-8 data is all 3-byte Unicode. If you have 4-byte characters (legal in Unicode and Java, illegal in MySQL 5), it can throw this error when you try to insert them. This is an <a href="http://bugs.mysql.com/bug.php?id=25666" rel="noreferrer">issue that should be fixed</a> in MySQL 6.0.</p>
<p>I just hit this problem and solved it by removing all the non-standard ascii characters in my text (following the UTF-8 advice above).</p> <p>I had the problem on a Debian 4, Java 5 system; but the same code worked fine with Ubuntu 9.04, Java 6. Both run MySql 5.</p>
9,878
<p>Every few days VS2008 decides to get mad at me and fails to generate a designer file claiming it cannot find the file specified and that it's missing an assembly. Here's the scenario:</p> <p>The aspx page has a reference to a custom user control (inheriting UserControl) which references another assembly in the backend. There are many other references to this "missing" assembly in other places in code which don't throw errors. rebuilding, updating the source to the clean copy, shouting at the computer, punching the screen, etc all fail to work.</p> <p>Any suggestions? This is quite annoying.</p>
<p>We've had similar problems before, unfortunately I don't remember the exact solution. </p> <p>If your using a "Web Site" project (no project file) then start by checking that both your page and your control both set the ClassName property in the first line of your aspx/ascx file and that you specify the full name of the class including the namespace. </p> <p>Example:</p> <blockquote> <p>&lt;@Control Language="VB" AutoEventWireup="false" ClassName="YourProjectName.YourUserControl" Inherits="YourProjectName.YourUserControl" CodeFile="YourUserControl.ascx.vb" %></p> </blockquote> <p>Many times not setting all of these will still work but you will get odd compiler errors and behavior in VS.</p> <p>If you using a Web Site Application project try deleting the designer file manually and then right click on your project and choose "Convert from Web Application." This will should recreate the designer file for you.</p> <p>My only other suggestion would be to recreate the page and/or the user control from scratch. </p>
<p>You might try archiving a template of a new file with its designer equivalent. If VS coughs then you can do an "Add Existing" option with the file you already have. </p> <p>It seems, however, to be an issue with your installation of VS2008 so you might try reinstalling it. </p>
5,277
<p>I'm considering using <a href="https://en.wikipedia.org/wiki/Category_6_cable" rel="noreferrer">CAT6</a> cables to connect my printer's extruder assembly to the control board. They seem like an elegant solution, but I've read conflicting opinions online on whether or not this would be feasible.</p> <p>I would like to know if CAT6 cables can handle the required current, whether I should be worried about electromagnetic interference or other problems, and how I should pair up the wires. Cable length would be 30cm max.</p> <p>Here are the relevant parts:</p> <ol> <li><a href="http://e3d-online.com/Heater-Cartridge-12v-40w" rel="noreferrer">E3D heater cartridge</a> (2 wires)</li> <li><a href="http://e3d-online.com/E3D-v6/Spares/Thermistor-Cartridge" rel="noreferrer">E3D thermistor cartridge</a> (2 wires)</li> <li><a href="http://e3d-online.com/E3D-v6/Spares/30x30x10mm-12v-DC-Fan" rel="noreferrer">30mm hotend fan</a> (2 wires)</li> <li><a href="https://printrbot.com/shop/auto-leveling-probe-2" rel="noreferrer">Z-axis auto-leveling probe</a> (3 wires)</li> <li><a href="https://docs.google.com/spreadsheets/d/1Q6nW_lToPZe6Kou6VbDMoQ3sFleCJ02XV0y4piXL_Fg/pubhtml" rel="noreferrer">NEMA 17 extruder motor</a> (4 wires)</li> <li><a href="https://www.amazon.co.uk/gp/product/B00MJUD1DW" rel="noreferrer">50mm part cooling fan</a> (2 wires)</li> </ol> <p><strong>[cable A]</strong> I imagine I would use one CAT6 cable for parts 1-4, which form a logical unit (and in the future I might combine them into a removable module). I've been given to understand that power for the fan can be spliced from the z-probe or heater cartridge, so 8 wires should be enough.</p> <p><strong>[cable B]</strong> I would use a second CAT6 cable for parts 5 and 6. There will be two spare wires, so I could potentially double the bandwidth for the motor.</p>
<p>The ampacity question is not completely answerable because CAT6 does not specify wire gauge, so the current limit will depend on the specific gauge you get. CAT6 can be anywhere from 22 AWG to 24 AWG, and depending on who you ask this can be good for as much as 7A or as little as 0.5A. Given that you will have a bunch of wires in a bundle, this may cause them to heat up more than if they were in free air. For the steppers (1-2A) a single wire should suffice, but for the heater (around 3-4A) you might want to double up.</p> <p>EMI will likely not cause any problems regardless of how you wire things up. CAT6 cables have the wires twisted in pairs of 2. Some people recommend to take advantage of these pairs: the +12V and GND of the heater should use a pair, each of the two coils of the steppers should have their own separate pairs. The reasoning behind this is that with equal current flowing in opposite directions in each wire of the pair, the generated electromagnetic fields will cancel out.</p> <p>Twisted pairs are usually used when dealing with multiple pairs of wires that are carrying high frequency signals that might affect each other. The main concern for crosstalk in this application is if the stepper motor might cause the endstop to be erroneously triggered, but this is only a concern during homing when the feedrate (and thus frequency of the signal) is low anyways.</p>
<p>CAT6 cable by itself is not a problem, it is typically 23 AWG solid core wire which can take you to 4A just fine. The real problem comes from the connectors you use. CAT6 usually goes hand in hand with 8p8c ethernet connectors which only have contacts rated to 500mA.</p> <p>Also typically CAT6 cable is meant to be stationary (hence the solid core wires), so I'd go for something stranded. <a href="https://www.mcmaster.com/#standard-electrical-wire/=15d9c3w" rel="nofollow noreferrer">McMaster sells some nice cheap cabling</a> that fits your needs, and it's actually meant for moving platforms like a CNC machine.</p>
441
<p>Is there anyplace where one can download a virtual machine containing a working install of some Linux distro with Globus Toolkit and some development tools (Java) for testing purposes? A real deployment of a grid is more complicated but I just need something portable, for development.</p>
<p>I am not sure whether I understood your intentions correctly, but let's see if this one helps.</p> <pre><code>public class TypedProperty&lt;T&gt; : Property where T : IConvertible { public T TypedValue { get { return (T)Convert.ChangeType(base.Value, typeof(T)); } set { base.Value = value.ToString();} } } </code></pre>
<pre><code>public class TypedProperty&lt;T&gt; : Property { public T TypedValue { get { return (T)(object)base.Value; } set { base.Value = value.ToString();} } } </code></pre> <p>I using converting via an object. It is a little bit simpler.</p>
3,008
<p>I am learning to write a debug visualizer in vs2008 C#. But keep getting the error saying that MyDebugVisualizer dll can't be loaded when I am in debug mode and click the magnifying glass icon.</p> <p>My app project is referencing the visualizer project. Before the type definition I have:</p> <p>[DebuggerVisualizer(typeof(MyVisualizer))] [Serializable]</p> <p>I tried putting the visualizer dll in: C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers or C:\Documents and Settings\zlee\My Documents\Visual Studio 2008\Visualizers</p> <p>Is there something else missing?</p>
<p>In <strong>ZFC</strong>, either the axiom of foundation [as mentioned] or the axiom (scheme) of comprehension will prohibit this. The first, for obvious reasons; the second, since it basically says that for given <em>z</em> and first-order property <em>P</em>, you can construct { <em>x</em> ∈ <em>z</em> : <em>P</em>(<em>x</em>) }, but to generate the Russell set, you would need <em>z</em> = <em>V</em> (the class of all sets), which is not a set (i.e. cannot be generated from any of the given axioms).</p> <p>In New Foundations (<strong>NF</strong>), "<em>x</em> ∉ <em>x</em>" is not a stratified formula, and so again we cannot define the Russell set. Somewhat amusingly, however, <em>V</em> <em>is</em> a set in <strong>NF</strong>.</p> <p>In von Neumann--Bernays--Gödel set theory (<strong>NBG</strong>), the class <em>R</em> = { <em>x</em> : <em>x</em> is a set and <em>x</em> ∉ <em>x</em> } is definable. We then ask whether <em>R</em> ∈ <em>R</em>; if so, then also <em>R</em> ∉ <em>R</em>, giving a contradiction. Thus we must have <em>R</em> ∉ <em>R</em>. But there is no contradiction here, since for any given class <em>A</em>, <em>A</em> ∉ <em>R</em> implies either <em>A</em> ∈ <em>A</em> or <em>A</em> is a proper class. Since <em>R</em> ∉ <em>R</em>, we must simply have that <em>R</em> is a proper class.</p> <p>Of course, the class <em>R</em> = { <em>x</em> : <em>x</em> ∉ <em>x</em> }, without the restriction, is simply not definable in <strong>NBG</strong>.</p> <p>Also of note is that the above procedure is formally constructable as a proof in <strong>NBG</strong>, whereas in <strong>ZFC</strong> one has to resort to meta-reasoning.</p>
<p>The question is ill-posed in the standard <a href="http://en.wikipedia.org/wiki/Zermelo-Fraenkel_set_theory" rel="nofollow noreferrer">ZFC</a> (Zermelo-Fraenkel + axiom of Choice) set theory because the object thus defined is not a set.</p> <p>Since (again, assuming standard ZFC) your <em>class</em> {x : x\not\in x} is not a set, the answer becomes no, it's not an element of itself (even as a class) since only sets can be elements of classes or sets.</p> <p>By the way, as soon as you agree to the <a href="http://en.wikipedia.org/wiki/Axiom_of_foundation" rel="nofollow noreferrer">axiom of foundation</a>, no set can be an element of itself.</p> <p>Of course the nice thing about math is you can choose whichever axioms you want :) but believing in paradoxes is just weird.</p>
5,581
<p>What's the best way to do the semantic equivalent of the traditional sleep() system call from within an Informix SPL routine? In other words, simply "pause" for N seconds (or milliseconds or whatever, but seconds are fine). I'm looking for a solution that does <em>not</em> involve linking some new (perhaps written by me) C code or other library into the Informix server. This has to be something I can do purely from SPL. A solution for IDS 10 or 11 would be fine.</p> <p>@RET - The "obvious" answer wasn't obvious to me! I didn't know about the SYSTEM command. Thank you! (And yes, I'm the guy you think I am.)</p> <hr> <p>Yes, it's for debugging purposes only. Unfortunately, CURRENT within an SPL will always return the same value, set at the entry to the call:</p> <blockquote><p><i>"any call to CURRENT from inside the SPL function that an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement invokes returns the value of the system clock when the SPL function starts."</i></p> &mdash;<a href="http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.sqls.doc/sqls1011.htm" rel="nofollow noreferrer">IBM Informix Guide to SQL</a></p></blockquote> <p>Wrapping CURRENT in its own subroutine does not help. You do get a different answer on the first call to your wrapper (provided you're using YEAR TO FRACTION(5) or some other type with high enough resolution to show the the difference) but then you get that same value back on every single subsequent call, which ensures that any sort of loop will never terminate.</p>
<p>There must be some good reason you're not wanting the obvious answer: <code>SYSTEM "sleep 5"</code>. If all you're wanting is for the SPL to pause while you check various values etc, here are a couple of thoughts (all of which are utter hacks, of course):</p> <ol> <li>Make the TRACE FILE a named pipe (assuming Unix back-end), so it blocks until you choose to read from it, or</li> <li>Create another table that your SPL polls for a particular entry from a WHILE loop, and insert said row from elsewhere (horribly inefficient)</li> <li>Make SET LOCK MODE your friend: execute "SET LOCK MODE TO WAIT n" and deliberately requery a table you're already holding a cursor open on. You'll need to wrap this in an EXCEPTION handler, of course.</li> </ol> <p>Hope that is some help (and if you're the same JS of Ars and Rose::DB fame, it's the least I could do ;-)</p>
<p>I assume that you want this "pause" for debugging purposes, otherwise think about it, you'll always have some better tasks to do for your server than sleep ...</p> <p>A suggestion: Maybe you could get CURRENT, add it a few seconds ( let mytimestamp ) then in a while loop select CURRENT while CURRENT &lt;= mytimestamp . I've no informix setup around my desk to try it, so you'll have to figure the correct syntax. Again, do not put such a hack on a production server. You've been warned :D</p>
2,752
<p>Prompted by discussion in comments of a recent question whether PLA is suitable for parts that need to be in contact with acetone, I did some casual experiments and found that my clear/&quot;natural&quot; 3D Solutech PLA is mostly but not entirely resistant to acetone, while my blue Hatchbox PLA is quickly softened and deformed by it. This got me wondering: how do you go about finding PLA that's <strong>actually PLA</strong> (and nothing else)? Just &quot;clear/natural&quot; in product description does not seem to suffice.</p> <p>I know this is close to a shopping question, so please make suggestions on how it could be improved if it's too close. It'd be great if there were keywords that worked, but an answer is probably going to be more along the lines of how to go about inquiring with manufacturers or where to find places where manufacturers might advertise that their products as pure.</p>
<p>There's only two ways to make sure it is pure PLA without color and additives:</p> <ul> <li>Make it yourself. Order PLA-pellets for manufacturing and put them into a filament extrusion machine</li> <li>Contact your manufacturer and ask them to do the above for you.</li> </ul> <p>Note though that the pure PLA might have undesirable attributes for pritability that are fought with fillers and additives.</p>
<p>If acetone resistance is what you are after, try PETG:</p> <p>&quot;While the chemical resistance of PETG is one of its most desirable characteristics, it is also one of the reasons why smoothing PETG prints is challenging. Since dissolving PETG with a solvent, smoothing via solvent application (like acetone smoothing for ABS) is not a very good option.&quot; See 2. Chemical Resistance in <a href="https://3dinsider.com/how-to-smooth-petg-prints/" rel="nofollow noreferrer">https://3dinsider.com/how-to-smooth-petg-prints/</a></p>
1,690
<p>Instead of returning a common string, is there a way to return classic objects? If not: what are the best practices? Do you transpose your object to xml and rebuild the object on the other side? What are the other possibilities? </p>
<p>As mentioned, you can do this in .net via serialization. By default all native types are serializable so this happens automagically for you.</p> <p>However if you have complex types, you need to mark the object with the [Serializable] attribute. The same goes with complex types as properties.</p> <p>So for example you need to have:</p> <pre><code>[Serializable] public class MyClass { public string MyString {get; set;} [Serializable] public MyOtherClass MyOtherClassProperty {get; set;} } </code></pre>
<p>As others have said, it is possible. However, if both the service and client use an object that has the exact same domain behavior on both sides, you probably didn't need a service in the first place. </p>
3,299
<p>Setting up an integration server, I’m in doubt about the best approach regarding using multiple tasks to complete the build. Is the best way to set all in just one big-job or make small dependent ones?</p>
<p>You definitely want to break up the tasks. Here is a nice example of CruiseControl.NET configuration that has different targets (tasks) for each step. It also uses a common.build file which can be shared among projects with little customization.</p> <p><a href="http://code.google.com/p/dot-net-reference-app/source/browse/#svn/trunk" rel="nofollow noreferrer">http://code.google.com/p/dot-net-reference-app/source/browse/#svn/trunk</a></p>
<p>I would definitely break down the jobs. Chances are you're likely to make changes in the builds, and it'll be easier to track down issues if you have smaller tasks instead of searching through one monolithic build.</p> <p>You should be able to create one big job from the smaller pieces, anyways.</p>
4,978
<p>I have a couple CSS files with overlapping CSS selectors that I'd like to programmatically merge (as in not just appending one file to the end of the other). Is there any tool to do this online? or a Firefox extension perhaps?</p>
<p>I found <a href="http://zamez.org/factorcss" rel="noreferrer">Factor CSS</a> - complete with source code, but I think it does way more than I'd need. I really just want to combine CSS blocks that have the same selectors. I'll check out the source code and see if it can be converted to something usable as a TextMate bundle. That is, unless someone else manages to get to it before me.</p> <p>EDIT: Even better - here's <a href="http://sixrevisions.com/css/css_code_optimization_formatting_validation/" rel="noreferrer">a list of web-based tools for checking/formatting/optimizing css</a>.</p>
<p>I wrote a Perl utility to do this several years ago.</p> <p>As well as merging one or more stylesheets into a single coherent sorted output (complete with comments to show which file(s) each property appeared in, and warnings when a property has conflicting values), you can also <em>selectively</em> search or merge based on the selector, the property or both. </p> <p>These are handled intelligently so that, for example, if you search for the property <code>font</code> you also get <code>font-size</code>, <code>font-weight</code> etc (still presented inside CSS blocks with the relevant selectors that they were taken from). Likewise, selector searching tries to Do The Right (ie generally most useful) Thing. If you search for, say, the element <code>a</code>, it will match any block whose selector is <code>a</code>, <code>a:hover</code>, <code>a.extlink</code>, <code>a#mylink</code>, <code>.foo a</code>, <code>#bar a</code>, <code>p a</code>, <code>pre &gt; a</code>, <code>a + p</code>, <code>a img</code>... (the last two don't <em>directly</em> affect the styling of the <code>a</code> itself but of an adjacent or descendent element, which it is often useful to know about in such a search), without matching <code>#a</code>, <code>.a</code>, etc. Of course this behaviour is optional, you can also search for an exact selector. Or a regex. </p> <p>Apart from perl itself the only dependency is <a href="http://search.cpan.org/search?query=css%3A%3Atiny&amp;mode=module" rel="nofollow">CSS::Tiny</a></p> <p>It's free software, and you can get it here: <a href="http://src.qolc.net/cat/software/cssmerge" rel="nofollow">cssmerge</a> </p>
3,744
<p>I'm developing an Excel 2007 add-in using Visual Studio Tools for Office (2008). I have one sheet with several ListObjects on it, which are being bound to datatables on startup. When they are bound, they autosize correctly.</p> <p>The problem comes when they are re-bound. I have a custom button on the ribbon bar which goes back out to the database and retrieves different information based on some criteria that the user inputs. This new data comes back and is re-bound to the ListObjects - however, this time they are not resized and I get an exception:</p> <blockquote> <p>ListObject cannot be bound because it cannot be resized to fit the data. The ListObject failed to add new rows. This can be caused because of inability to move objects below of the list object.</p> <blockquote> <p>Inner exception: "Insert method of Range class failed"<br> Reason: Microsoft.Office.Tools.Excel.FailureReason.CouldNotResizeListObject</p> </blockquote> </blockquote> <p>I was not able to find anything very meaningful on this error on Google or MSDN. I have been trying to figure this out for a while, but to no avail.</p> <p>Basic code structure:</p> <pre><code>//at startup DataTable tbl = //get from database listObj1.SetDataBinding(tbl); DataTable tbl2 = //get from database listObj2.SetDataBinding(tbl2); //in buttonClick event handler DataTable tbl = //get different info from database //have tried with and without unbinding old source listObj1.SetDataBinding(tbl); &lt;-- exception here DataTable tbl2 = //get different info from database listObj2.SetDataBinding(tbl2); </code></pre> <p>Note that this exception occurs even when the ListObject is shrinking, and not only when it grows.</p>
<p>If anyone else is having this problem, I have found the cause of this exception. ListObjects will automatically re-size on binding, as long as they do not affect any other objects on the sheet. Keep in mind that ListObjects can only affect the Ranges which they wrap around.</p> <p>In my case, the list object which was above the other one had fewer columns than the one below it. Let's say the top ListObject had 2 columns, and the bottom ListObject had 3 columns. When the top ListObject changed its number of rows, it had no ability to make any changes to the third column since it wasn't in it's underlying Range. This means that it couldn't shift any cells in the third column, and so the second ListObject couldn't be properly moved, resulting in my exception above.</p> <p>Changing the positions of the ListObjects to place the wider one above the smaller one works fine. Following the logic above, this now means that the wider ListObject can shift all of the columns of the second ListObject, and since there is nothing below the smaller one it can also shift any cells necessary. The reason I wasn't having any trouble on the initial binding is that both ListObjects were a single cell.</p> <p>Since this is not optimal in my case, I will probably use empty columns or try to play around with invisible columns if that's possible, but at least the cause is now clear.</p>
<p>Just an idea of something to try to see if it gives you more info: Try resizes the list object before the exception line and see if that also throws an exception. If not, try and resize the range object to the new size of the DataTable.</p> <p>You say that this happens when the ListObject shrinks and grows. Does it also happen if the ListObject remains the same size?</p>
4,083
<p>When I try to create a SQL Server Login by saying</p> <pre><code>CREATE LOGIN [ourdomain\SQLAccessGroup] FROM WINDOWS; </code></pre> <p>I get this error</p> <blockquote> <p>The server principal 'ourdomain\SQLAccessGroup' already exists.</p> </blockquote> <p>However, when I try this code</p> <pre><code>DROP LOGIN [ourdomain\SQLAccessGroup] </code></pre> <p>I get this error</p> <blockquote> <p>Cannot drop the login 'ourdomain\SQLAccessGroup', because it does not exist or you do not have permission.</p> </blockquote> <p>The user that I am executing this code as is a sysadmin. Additionally, the user <code>ourdomain\SQLAccessGroup</code> does not show up in this query</p> <pre><code>select * from sys.server_principals </code></pre> <p>Does anyone have any ideas?</p>
<p>We are still struggling to understand the <em>HOW</em> of this issue, but it seems that [ourdomain\SQLAccessGroup] was aliased by a consultant to a different user name (this is part of an MS CRM installation). We finally were able to use some logic and some good old SID comparisons to determine who was playing the imposter game.</p> <p>Our hint came when I tried to add the login as a user to the database (since it supposedly already existed) and got this error:</p> <pre><code>The login already has an account under a different user name. </code></pre> <p>So, I started to examine each DB user and was able to figure out the culprit. I eventually tracked it down and was able to rename the user and login so that the CRM install would work. I wonder if I can bill them $165.00 an hour for my time... :-)</p>
<p>This happened to me when I installed SQL Server using a Windows username and then I renamed the computer name and the Windows username from Windows. SQL server still has the old "Computername\Username" in its node of Server->Security->Logins.</p> <p>The solution is to go to Server->Security-><strong>Logins</strong> and right-click -> <strong>rename</strong> the old Windows user and use the new <strong>MachineName\Username</strong>.</p>
4,136
<p>How can I change default <a href="http://msdn.microsoft.com/en-us/library/3a7hkh29.aspx" rel="nofollow noreferrer">Generate Method Stub</a> behavior in Visaul Studio to generate method with body</p> <pre><code>throw new NotImplementedException(); </code></pre> <p>instead of </p> <pre><code>throw new Exception("The method or operation is not implemented."); </code></pre>
<p>Taken from: <a href="http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx" rel="noreferrer">http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx</a></p> <blockquote> <p>Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types that is not included is NotImplementedException. </p> </blockquote> <p>You can change the generated code by editing the code snippet file: <strong>C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Refactoring\MethodStub.snippet</strong> and changing the Declarations section to the following:</p> <pre><code> &lt;Declarations&gt; &lt;Literal Editable="true"&gt; &lt;ID&gt;signature&lt;/ID&gt; &lt;Default&gt;signature&lt;/Default&gt; &lt;/Literal&gt; &lt;Literal&gt; &lt;ID&gt;Exception&lt;/ID&gt; &lt;Function&gt;SimpleTypeName(global::System.NotImplementedException)&lt;/Function&gt; &lt;/Literal&gt; &lt;/Declarations&gt; </code></pre>
<p>There's another reason: FxCop catches instances of anybody throwing 'Exception' and flags it, but throwing instances of 'NotImplementedException' is acceptable.</p> <p>I actually like the default behavior, because it does have this differentiation. NotImplementedException is not a temporary exception to be thrown while you're working your way through your code. It implies "I mean it, I'm <em>really</em> not going to implement this thing". If you leave the codegen the way it is, it's easy for you to differentiate in the code the "I will come back to this later" bits from "I've decided not to do this" bits.</p>
6,803
<p>Is there a way to take over the Entity Framework class builder? I want to be able to have my own class builder so i can make some properties to call other methods upon materialization or make the entity classes partial.</p>
<p>Actually they are already in partial classes. See <a href="http://msdn.microsoft.com/en-us/library/bb738612.aspx" rel="nofollow noreferrer">MSDN</a></p>
<p>I'll add that not only can you can tack on your own class <strong>partial classes</strong> to those emitted by the Entity Framework, but you can also write out all the <strong>partial methods</strong> created by the generated code.</p> <p>IE. There'll be a lot of partial method code which get called but the method itself in the generated code isn't really implemented. For that you can write a partial method to catch events when properties change and such. It's not a terrible way to handle some business rules.</p>
6,046
<p>I've written (most of) an application in Flex and I am concerned with protecting the source code. I fired up a demo of <a href="http://www.flash-decompiler.com/" rel="noreferrer">Trillix swf decompiler</a> and opened up the swf file that was installed to my Program Files directory. I saw that all of the actionscript packages I wrote were there. I'm not too concerned with the packages, even though there is a substantial amount of code, because it still seems pretty unusable without the mxml files. I think they are converted to actionscript, or atleast I hope. However, I would still like to explore obfuscation.</p> <p>Does anyone have any experience with Flash / Actionscript 3 / Flex obfuscators? Can you recommend a good product?</p>
<p>Here's what I would do.</p> <ul> <li><p>Compile your application to a SWF file. Then encrypt the SWF using AES.</p></li> <li><p>Make a "wrapper" application that loads the encrypted SWF into a ByteArray using URLLoader</p></li> <li><p>Use the <a href="http://code.google.com/p/as3crypto/" rel="noreferrer">as3crypto</a> library to decrypt the swf at runtime.</p></li> <li><p>Once decrypted, use Loader.loadBytes to load the decrypted swf into the wrapper application.</p></li> </ul> <p>This will make it a lot harder to get your code. Not impossible, but harder.</p> <p>For AIR applications you could leave the SWF encrypted when delivering the application to the end-user. Then you could provide a registration key that contains the key used to decrypt the SWF.</p> <p>Also, here is a link to an AS3 obfuscator. I am not sure how well it works though. <a href="http://www.ambiera.com/irrfuscator/index.html" rel="noreferrer">http://www.ambiera.com/irrfuscator/index.html</a></p>
<p>I recently released an iOS and Android game using Flash. I looked around the internet for a good free program to protect the source code in my SWF and couldn't find anything so I wrote one. It's still in development and it's "use at your own risk" but it worked for me.</p> <p>It's released on github. Check it out and let me know what you think.</p> <p><a href="https://github.com/Teesquared/flasturbate" rel="nofollow">https://github.com/Teesquared/flasturbate</a></p> <p>I uploaded a windows binary but I recommend you follow the instructions to build it yourself if you want to give it a try.</p> <p>This obfuscator works directly on the SWF file. It currently only renames symbols but it is built on a framework that could support altering bytecodes in the future.</p>
2,678
<p>What is the difference between <a href="http://msdn.microsoft.com/en-us/library/9a6a2sxy.aspx" rel="noreferrer"><code>Math.Floor()</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.math.truncate.aspx" rel="noreferrer"><code>Math.Truncate()</code></a> in .NET?</p>
<p><code>Math.Floor</code> rounds down, <code>Math.Ceiling</code> rounds up, and <code>Math.Truncate</code> rounds towards zero. Thus, <code>Math.Truncate</code> is like <code>Math.Floor</code> for positive numbers, and like <code>Math.Ceiling</code> for negative numbers. Here's the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.math.truncate" rel="noreferrer">reference</a>.</p> <p>For completeness, <code>Math.Round</code> rounds to the nearest integer. If the number is exactly midway between two integers, then it rounds towards the even one. <a href="https://learn.microsoft.com/en-us/dotnet/api/system.math.round" rel="noreferrer">Reference.</a></p> <p>See also: <a href="https://stackoverflow.com/questions/14/whats-the-difference-between-math-floor-and-math-truncate-in-c/580252#580252">Pax Diablo's answer</a>. Highly recommended!</p>
<p>Truncate drops the decimal point.</p>
2,235
<p>I currently have a class and I'm trying to create an easy GUI to create a collection of this class. Most of the attributes of this class are strings. However, one of the attributes I want the user to be able to set is an Enum. Therefore, I would like the user interface, to have a dropdownlist for this enum, to restrict the user from entering a value that is not valid. Currently, I am taking the initial list of objects, adding them to a DataTable and setting the DataSource of my DataGridView to the table. Works nicely, even creates a checkbox column for the one Boolean property. But, I don't know how to make the column for the enum into a dropdownlist. I am using C# and .NET 2.0.</p> <p>Also, I have tried assigning the DataSource of the DataGridView to the list of my objects, but when I do this, it doesn't help with the enum and I'm unable to create new rows in the DataGridView, but I am definitely not bound to using a DataTable as my DataSource, it was simply the option I have semi-working.</p>
<p>I do not know if that would work with a DataGridView column but it works with ComboBoxes:</p> <pre><code>comboBox1.DataSource = Enum.GetValues(typeof(MyEnum)); </code></pre> <p>and:</p> <pre><code>MyEnum value = (MyEnum)comboBox1.SelectedValue; </code></pre> <p>UPDATE: It works with DataGridView columns too, just remember to set the value type.</p> <pre><code>DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn(); col.Name = "My Enum Column"; col.DataSource = Enum.GetValues(typeof(MyEnum)); col.ValueType = typeof(MyEnum); dataGridView1.Columns.Add(col); </code></pre>
<p>Or, if you need to do some filtering of the enumerator values, you can loop through <code>Enum.GetValues(typeof(EnumeratorName))</code> and add the ones you want using:</p> <pre><code>dataGridViewComboBoxColumn.Items.Add(EnumeratorValue) </code></pre> <p>As an aside, rather than using a DataTable, you can set the DataSource of the DataGridView to a BindingSource object, with the DataSource of the BindingSource object set to a <code>BindingList&lt;Your Class&gt;</code>, which you populate by passing an <code>IList</code> into the constructor.</p> <p>Actually, I'd be interested to know from anyone if this is preferable to using a DataTable in situations where you don't already have one (i.e. it is returned from a database call).</p>
8,038
<p>I'm having some issues with my Prusa i3 prints. I'm trying to print the default beer opener print that came with the Prusa's memory card but the infill will break causing clogging and now allowing the print to finish. I've attached a picture of one of the failed prints.</p> <p><a href="https://i.stack.imgur.com/JNPn4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JNPn4.jpg" alt="enter image description here"></a></p> <p>I've checked Prusa's website and tried tightening the extruder gears and made sure the gears are clean. I'm using the PLA sent with the printer (1.75&nbsp;mm) and with a default G-code file so I'm fairly sure it is a hardware issue, but I'm not sure what the issue could be. </p> <p><a href="https://blog.prusaprinters.org/7-problems-affecting-quality-of-3d-prints/" rel="nofollow noreferrer">Here is the link</a> that I've used to help me troubleshoot.</p>
<p>If you carbonize the filament or other particles that are clogging the nozzle, then you will never get them clean. In my experience, it's not worth cleaning the nozzle with anything other than cleaning filament. If that doesn't work then change the nozzle. Heating the metal nozzle with a torch will change the temper of the material. I used to try cleaning with a soldering iron; which was to no avail.</p> <p>Purchase a dozen brass nozzles and save your self the headache. Either that or a good quality set of stainless steel ones. They are easier to clean with the cleaning filament and aren't ablated by the filament as quickly, allowing for better dimensional accuracy over multiple prints.</p> <p><a href="https://i.stack.imgur.com/2OhXB.jpg" rel="nofollow noreferrer">https://www.amazon.com/eSUN-CLEANING-Filament-Printers-Cleaning/dp/B00MVIYNFW/</a></p> <p><a href="https://i.stack.imgur.com/2OhXB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2OhXB.jpg" alt="eSun Cleaning Filament"></a></p>
<p>If you can get the torch hot enough and you carbonise/burn the filament properly, it may work. You still need to do a cold pull to remove as many residues as you can, but if you heated it enough, the residuals maybe won't stick too much to the nozzle.</p> <p>You already have the butane, try and tell us.</p>
1,629
<p>When developing a desktop application in .NET, is it possible to not require the .NET Framework? Is developing software in .NET a preferred way to develop desktop applications? What is the most used programming language that software companies use to develop desktop applications?</p> <p>Is the requirement of the .NET Framework just assumed based on the Windows OS you have installed hence why they list Windows OS version requirements?</p>
<p>You can still develop applications for the windows desktop using C/C++, eliminating the requirement to the .NET framework, but you'll need to make sure the necessary libraries are already on the system or installed.</p> <p>The nice thing about the .NET framework is that Windows XP SP2 and Vista has the 3.0 framework runtime installed by default.</p> <p>In a lot of ways, this is Microsoft's "development standard" and has been that way for a while. This allows you to not worry about having a bunch of libraries tacked onto your application. If you're sticking to all of the .NET provided libraries, you wind up only have to worry about deploying your executable, which is a big headache reliever. When you have a bunch of libraries you have to deploy as well, then you start to run into hassles when you write updates, because you have to make sure those updates are pushed out in your existing installer and to all the existing installed apps out there.</p> <p>As for "preferred", that always tends to ruffle feathers at times, but there are more and more .NET developers wanted for the web and the desktop at the job hunt sites I tend to visit. 8^D</p> <p>EDIT: Many thanks to Orion for pointing out my confusion on the frameworks. You get 3.0 "out the gate if you're on XP SP2 or Vista. Everything else is going to require a simple download or run of Windows Update.</p>
<p>It is possible not to require the .NET Framework; there are some companies that sell (for thousands of dollars, mind you) solutions that will allow you to do this. These are complete hacks, however, and not supported by Microsoft.</p> <p>How you develop desktop applications (ie, using .NET or not) depends on your requirement. There isn't a preferred way.</p> <p>Most used language is probably C#.</p>
3,236
<p>How do you rewrite this in Linq?</p> <pre><code>SELECT Id, Name FROM TableA WHERE TableA.Id IN (SELECT xx from TableB INNER JOIN Table C....) </code></pre> <p>So in plain english, I want to select Id and Name from TableA where TableA's Id is in a result set from a second query.</p>
<pre><code>from a in TableA where (from b in TableB join c in TableC on b.id equals c.id where .. select b.id) .Contains(a.Id) select new { a.Id, a.Name } </code></pre>
<p>There is no out of box support for IN in LINQ. You need to join 2 queries.</p>
6,761
<p>So I bought a prusa i3 kit from a company called folger tech off of ebay. I've built it and even printed out a few parts, but I noticed that a lot of noise seemed to be happening only while the x-axis motor was moving the extruder. Then I noticed if I put my finger lightly on the plastic part of the x-carriage I could dampen the vibrations and pretty much eliminate the noise I noticed. Then I took apart that part of the printer and examined everything and all I could notice that seemed to be loose was that nut that allows the z motor to push up the x carriage. I don't know if I got a bad nut, or a bad screw, or is it's just supposed to be this way? I thought it was kind of a weird way to build things with a screw turning a nut, because I thought that it would bind up. But now I'm wondering if that is why it was so loose fitting (to reduce friction)? So does it need to be that way? Or could I get a different nut? Or is there some better way to go about fixing this issue? Or perhaps it's not even an issue.. idk.</p>
<p>It's probably intentional. Threaded rods are almost never perfectly straight. If the nut is rigidly coupled to the carriage, then the slightest deviation in the screw will either cause it to bind up or appear as artifacts (e.g. z-wobble) in the print. By making the nut slightly loose, it can move around a bit to compensate for wobble. See e.g. <a href="http://www.thingiverse.com/thing:20147" rel="nofollow">this design</a> and <a href="http://www.thingiverse.com/thing:3057" rel="nofollow">this design</a> for how this is commonly implemented in other printers.</p>
<p>I do not agree with the answer of Tom.</p> <p>In a proper design, the nut is supposed NOT to be loose, especially in the Z-direction. All options of the nut to move can cause imprecise layer heights and Z-wobble. There is also the possibility to introduce Z-wobble by bent rods and good contact of the nut. However, Z-wobble is not what I want to address.</p> <p>Yes, to me, it seems possible that your rod or your nut (or both) are looser than they are supposed to be. However, I don't know the exact design of your printer. Usually there is some play along the axis, but hardly any perpendicular to it. Typically this can introduce a <a href="https://en.wikipedia.org/wiki/Hysteresis" rel="nofollow noreferrer">hysteresis (wikipedia link)</a> in the placement of the X-carriage. There is a nifty design against this, which most likely should also help you to get rid of your noise: <a href="http://www.thingiverse.com/thing:694575" rel="nofollow noreferrer">Thingverse: Z-axis anti backlash for Prusa i3</a>. </p> <p><strong>First</strong>, however, you should check the following:</p> <ul> <li>Are both your Z-axis drives set to the same height, or is just one of them doing the work (which would be very rare, by the nature of the design)?</li> <li>Is your nut lose in the X-carriage? While the nut should not be lose itself, it should be totally fixed in the X-carriage (again: typically, but I don't know the FolgerTech approach).</li> <li>Try other nuts from the hardware store to be sure whether you have a faulty nut or not.</li> <li>While you're there you can connect a threaded rod with nuts there to gain experience what the typical degree of freedom in this union is.</li> </ul>
235
<p>I would like to give a class a unique ID every time a new one is instantiated. For example with a class named Foo i would like to be able to do the following</p> <pre><code>dim a as New Foo() dim b as New Foo() </code></pre> <p>and a would get a unique id and b would get a unique ID. The ids only have to be unique over run time so i would just like to use an integer. I have found a way to do this BUT (and heres the caveat) I do NOT want to be able to change the ID from anywhere. My current idea for a way to implement this is the following:</p> <pre><code>Public Class test Private Shared ReadOnly _nextId As Integer Private ReadOnly _id As Integer Public Sub New() _nextId = _nextId + 1 _id = _nextId End Sub End Class </code></pre> <p>However this will not compile because it throws an error on _nextId = _nextId + 1 I don't see why this would be an error (because _Id is also readonly you're supposed to be able to change a read only variable in the constructor.) I think this has something to do with it being shared also. Any solution (hopefully not kludgy hehe) or an explanation of why this won't work will be accepted. The important part is i want both of the variables (or if there is a way to only have one that would even be better but i don't think that is possible) to be immutable after the object is initialized. Thanks!</p>
<p>This design is vulnerable to multithreading issues. I'd strongly suggest using Guids for your IDs (Guid.NewGuid()). If you absolutely must use ints, check out the <a href="http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx" rel="nofollow noreferrer">Interlocked</a> class. You can wrap all incrementing and Id logic up in a base class so that you're only accessing the ID generator in one location.</p>
<p>It's likely throwing an error because you're never initializing _nextId to anything. It needs to have an initial value before you can safely add 1 to it.</p>
8,944
<p>I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed?</p> <pre><code>CREATE TABLE dbo.Profiles ( UserName varchar(100) NOT NULL, LastUpdate datetime NOT NULL CONSTRAINT DF_Profiles_LastUpdate DEFAULT (getdate()), FullName varchar(50) NOT NULL, Birthdate smalldatetime NULL, PageSize int NOT NULL CONSTRAINT DF_Profiles_PageSize DEFAULT ((10)), CONSTRAINT PK_Profiles PRIMARY KEY CLUSTERED (UserName ASC), CONSTRAINT FK_Profils_Users FOREIGN KEY (UserName) REFERENCES dbo.Users (UserName) ON UPDATE CASCADE ON DELETE CASCADE ) </code></pre>
<p>I agree with the others -- set a default value of GetDate() on the LastUpdate column and then use a trigger to handle any updates.</p> <p>Just something simple like this:</p> <pre><code>CREATE TRIGGER KeepUpdated on Profiles FOR UPDATE, INSERT AS UPDATE dbo.Profiles SET LastUpdate = GetDate() WHERE Username IN (SELECT Username FROM inserted) </code></pre> <p>If you want to get really fancy, have it evaluate what's being changed versus what's in the database and only modify LastUpdate if there was a difference.</p> <p>Consider this...</p> <ul> <li><p><strong>7am</strong> - User 'jsmith' is created with a last name of 'Smithe' (oops), LastUpdate defaults to 7am</p></li> <li><p><strong>8am</strong> - 'jsmith' emails IT to say his name is incorrect. You immediately perform the update, so the last name is now 'Smith' and (thanks to the trigger) LastUpdate shows 8am</p></li> <li><p><strong>2pm</strong> - Your slacker coworker finally gets bored with StumbleUpon and checks his email. He sees the earlier message from 'jsmith' regarding the name change. He runs: <em>UPDATE Profiles SET LastName='Smith' WHERE Username='jsmith'</em> and then goes back to surfing MySpace. The trigger doesn't care that the last name was already 'Smith', however, so LastUpdate now shows 2pm.</p></li> </ul> <p>If you just blindly change LastUpdate whenever an update statement runs, it's TECHNICALLY correct because an update did happen, but it probably makes more sense to actually compare the changes and act accordingly. That way, the 2pm Update statement by the coworker would still run, but LastUpdate would still show 8am.</p> <p>--Kevin</p>
<p>My suggestion would be to create a stored procedure which defaults the lastUpdate to getdate(). </p> <p>I've tried to avoid triggers in the past because pre-SQL2005 locating and editing them was a pain in the rump. Especially for developers who are new to your project. </p> <p>Also add that as the default value for your column definition.</p>
5,663
<p>Is there any Visual Studio Express plug ins for source versioning? I am starting a project on my own and only have the Express version of Visual Studio 2008.</p>
<p>Short answer: No.</p> <p>The Express editions support neither the Add-Ins nor Source Control providers (SCC plug-ins). While there are ways to make this work, they are undocumented, violate the license and <a href="http://weblogs.asp.net/nunitaddin/archive/2007/05/31/microsoft-vs-testdriven-net-31-may-2007.aspx" rel="noreferrer">have caused legal trouble before…</a></p>
<p>I don't think there are any plugins for Express versions of VS. Googling 'Jamie Cansdale' is the canonical reference for this issue.</p>
5,069
<p>We deployed a live, fresh, swanky site using preview 3 including rigorous stress testing. </p> <p>Page Output caching was our saviour and afforded us the ability to meet our performance contractual requirements.</p> <p>My question is, is there a difference between action <code>OutputCacheFilter</code> and page output caching?</p> <p>Is the action output caching faster than page output caching?</p>
<p>Internally, the OutputCacheAttribute (aka output cache filter) uses the same internal mechanism as <a href="http://msdn.microsoft.com/en-us/library/hdxfb6cy.aspx" rel="nofollow noreferrer">page output caching</a> (aka the @OutputCache directive).</p> <p>Therefore, it's not any faster than page output caching. However, with MVC, you really can't use page output caching via the @OutputCache directive in MVC because we render the view (aka page) <strong>after</strong> the action runs. So you would gain very little benefit.</p> <p>With the output cache filter, it does the correct thing and does not execute the action code if the result is in the output cache. Hope that helps. :)</p>
<p>Just be aware that there currently is a bug if you call Html.RenderAction(..) on an Action that is marked to be cached. Instead of the specific action being cached, the entire page gets cached. I reported this on codeplex already and it seems to be a known issue: <a href="http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2062" rel="nofollow noreferrer">Calling &lt;% HTML.RenderAction&lt;...>(...); %> to an Action with [OutputCache(..)] causes entire page to cache.</a></p>
3,187
<p>I can't seem to understand the margins that Cura uses or how to fix them for my machine. Look at this:</p> <p><a href="https://i.stack.imgur.com/5oD0d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5oD0d.png" alt="Screenshot of Cura, depicting large grey area"></a></p> <p>I can't seem to tweak the stuff under machine settings to anything that does this better:</p> <p><a href="https://i.stack.imgur.com/FEd5k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FEd5k.png" alt="Screenshot of settings"></a></p> <p>Maybe a bit of dup of <a href="https://3dprinting.stackexchange.com/questions/645/cura-not-allowing-full-print-area-to-used">Cura not allowing full print area to used</a>, but I think my case is a lot worse and can't be explained by skirts.</p>
<p>I had mistakenly left the setting "one at a time" in print sequence. This meaning the printhead needs a lot of room since it will go back and forth in z.</p> <p>Cura allocates this extra space even if there's only one object.</p>
<p>That looks like you've got the "brim" set to a very wide value. I know you said it's not explained by skirts --which, as Greenonline pointed out, is not the same as a brim--, but you didn't post that setting. At the same time, make sure you don't have a 'raft' set up. </p> <p>One other possibility is that your source file actually contains a very large first layer. Try looking at the STL file in Meshlab or Meshmixer to see what's actually there.</p>
612
<p>I am the owner of a pretty Anycubic Mega I3 and it was very cool to own it. </p> <p>However, now I have several problems when printing with it. It clicks all along, at high or low temperature, at 5&nbsp;mm above the plate, and the result is very disgusting. It is the same with the basic black PLA, or with other PLA from ICE-Filaments but I can't do anything. </p> <p>I use Cura and I've reset it several times, using the defaults options or not.</p> <p>Here are two examples of some prints (normal cube): </p> <p><a href="https://cdn.discordapp.com/attachments/380420138920574986/455045425636835338/Snapchat-1209640225.jpg" rel="noreferrer">example 1</a> </p> <p><a href="https://i.stack.imgur.com/rSqA2.jpg" rel="noreferrer" title="First example of poorly printed cube"><img src="https://i.stack.imgur.com/rSqA2.jpg" alt="First example of poorly printed cube" title="First example of poorly printed cube"></a></p> <p>and <a href="https://cdn.discordapp.com/attachments/380420138920574986/455045425636835340/Snapchat-27434386.jpg" rel="noreferrer">Example 2</a></p> <p><a href="https://i.stack.imgur.com/hb1dJ.jpg" rel="noreferrer" title="Second example of poorly printed cube"><img src="https://i.stack.imgur.com/hb1dJ.jpg" alt="Second example of poorly printed cube" title="Second example of poorly printed cube"></a></p>
<p>I redid the print in order to reply to some questions posed in the answer of @kdtop. The print started but the output was not consistent and sometimes stopped. The temperature is 195°C and sometimes 'drop' to 194°C. First I pushed the new real so that the extruder did not need to pull so much. When this did not solve the problem I changed the temperature to 200°C. Now the output became consistent and my print finished. It was not as good as the one that I did with my previous filament. The top was not as neatly closed. Only the last 2 layers covered more or less for 100% the surface (perhaps 200°C is too high for this?).</p> <p>For me the solution is to higher the temperature to 200°C (or perhaps 205°C).</p>
<p>My slicer (Cura-lulzbot) has a setting for initial printing temp, and then printing temp after the first few layers. Is it possible that your temp is initially OK, but then drops too low? Does your printer have a readout that shows the current temp? Is the temp still OK when it stops?</p> <p>It sounds like you are printing a sample cube, so I assume not too large. Could you simulate this by just directly command your printer to extrude 500 mm of filament, or longer? Then see if it clogs. That would tell you if it was a physical problem with your printer instead of some change specified by the G-code for a sliced print. </p>
927
<p>From time to time I see an enum like the following:</p> <pre><code>[Flags] public enum Options { None = 0, Option1 = 1, Option2 = 2, Option3 = 4, Option4 = 8 } </code></pre> <p>I don't understand what exactly the <code>[Flags]</code> attribute does.</p> <p>Anyone have a good explanation or example they could post?</p>
<p>The <code>[Flags]</code> attribute should be used whenever the enumerable represents a collection of possible values, rather than a single value. Such collections are often used with bitwise operators, for example:</p> <pre><code>var allowedColors = MyColor.Red | MyColor.Green | MyColor.Blue; </code></pre> <p>Note that the <code>[Flags]</code> attribute <strong>doesn't</strong> enable this by itself - all it does is allow a nice representation by the <code>.ToString()</code> method:</p> <pre><code>enum Suits { Spades = 1, Clubs = 2, Diamonds = 4, Hearts = 8 } [Flags] enum SuitsFlags { Spades = 1, Clubs = 2, Diamonds = 4, Hearts = 8 } ... var str1 = (Suits.Spades | Suits.Diamonds).ToString(); // "5" var str2 = (SuitsFlags.Spades | SuitsFlags.Diamonds).ToString(); // "Spades, Diamonds" </code></pre> <p>It is also important to note that <code>[Flags]</code> <strong>does not</strong> automatically make the enum values powers of two. If you omit the numeric values, the enum will not work as one might expect in bitwise operations, because by default the values start with 0 and increment. </p> <p>Incorrect declaration:</p> <pre><code>[Flags] public enum MyColors { Yellow, // 0 Green, // 1 Red, // 2 Blue // 3 } </code></pre> <p>The values, if declared this way, will be Yellow = 0, Green = 1, Red = 2, Blue = 3. This will render it useless as flags.</p> <p>Here's an example of a correct declaration:</p> <pre><code>[Flags] public enum MyColors { Yellow = 1, Green = 2, Red = 4, Blue = 8 } </code></pre> <p>To retrieve the distinct values in your property, one can do this:</p> <pre><code>if (myProperties.AllowedColors.HasFlag(MyColor.Yellow)) { // Yellow is allowed... } </code></pre> <p>or prior to .NET 4:</p> <pre><code>if((myProperties.AllowedColors &amp; MyColor.Yellow) == MyColor.Yellow) { // Yellow is allowed... } if((myProperties.AllowedColors &amp; MyColor.Green) == MyColor.Green) { // Green is allowed... } </code></pre> <p><strong>Under the covers</strong></p> <p>This works because you used powers of two in your enumeration. Under the covers, your enumeration values look like this in binary ones and zeros:</p> <pre><code> Yellow: 00000001 Green: 00000010 Red: 00000100 Blue: 00001000 </code></pre> <p>Similarly, after you've set your property <em>AllowedColors</em> to Red, Green and Blue using the binary bitwise OR <code>|</code> operator, <em>AllowedColors</em> looks like this:</p> <pre><code>myProperties.AllowedColors: 00001110 </code></pre> <p>So when you retrieve the value you are actually performing bitwise AND <code>&amp;</code> on the values:</p> <pre><code>myProperties.AllowedColors: 00001110 MyColor.Green: 00000010 ----------------------- 00000010 // Hey, this is the same as MyColor.Green! </code></pre> <p><strong>The None = 0 value</strong></p> <p>And regarding the use of <code>0</code> in your enumeration, quoting from MSDN:</p> <pre><code>[Flags] public enum MyColors { None = 0, .... } </code></pre> <blockquote> <p>Use None as the name of the flag enumerated constant whose value is zero. <strong>You cannot use the None enumerated constant in a bitwise AND operation to test for a flag because the result is always zero.</strong> However, you can perform a logical, not a bitwise, comparison between the numeric value and the None enumerated constant to determine whether any bits in the numeric value are set. </p> </blockquote> <p>You can find more info about the flags attribute and its usage at <a href="http://msdn.microsoft.com/en-us/library/system.flagsattribute.aspx" rel="noreferrer">msdn</a> and <a href="http://msdn.microsoft.com/en-us/library/ms229062.aspx" rel="noreferrer">designing flags at msdn</a></p>
<ul> <li><p>Flags are used when an enumerable value represents a collection of enum members.</p> </li> <li><p>here we use bitwise operators, | and &amp;</p> </li> <li><p>Example</p> <pre><code> [Flags] public enum Sides { Left=0, Right=1, Top=2, Bottom=3 } Sides leftRight = Sides.Left | Sides.Right; Console.WriteLine (leftRight);//Left, Right string stringValue = leftRight.ToString(); Console.WriteLine (stringValue);//Left, Right Sides s = Sides.Left; s |= Sides.Right; Console.WriteLine (s);//Left, Right s ^= Sides.Right; // Toggles Sides.Right Console.WriteLine (s); //Left </code></pre> </li> </ul>
2,987
<p>What are the pros and cons of using table aliases in SQL? I personally try to avoid them, as I think they make the code less readable (especially when reading through large where/and statements), but I'd be interested in hearing any counter-points to this. When is it generally a good idea to use table aliases, and do you have any preferred formats?</p>
<p>Table aliases are a necessary evil when dealing with highly normalized schemas. For example, and I'm not the architect on this DB so bear with me, it can take 7 joins in order to get a clean and complete record back which includes a person's name, address, phone number and company affiliation. </p> <p>Rather than the somewhat standard single character aliases, I tend to favor short word aliases so the above example's SQL ends up looking like: </p> <pre><code>select person.FirstName ,person.LastName ,addr.StreetAddress ,addr.City ,addr.State ,addr.Zip ,phone.PhoneNumber ,company.CompanyName from tblPeople person left outer join tblAffiliations affl on affl.personID = person.personID left outer join tblCompany company on company.companyID = affl.companyID </code></pre> <p>... etc</p>
<p>Aliases are required when joining tables with columns that have identical names.</p>
3,222
<p>Is the following safe?</p> <p>I am new to threading and I want to delegate a time consuming process to a separate thread in my C++ program. Using the boost libraries I have written code something like this:</p> <p>thrd = new boost::thread(boost::bind(&amp;myclass::mymethod, this, &amp;finished_flag);</p> <p>Where finished_flag is a boolean member of my class. When the thread is finished it sets the value and the main loop of my program checks for a change in that value. I assume that this is okay because I only ever start one thread, and that thread is the only thing that changes the value (except for when it is initialised before I start the thread) So is this okay, or am I missing something, and need to use locks and mutexes, etc</p>
<p>You never mentioned the type of finished_flag...</p> <p>If it's a straight <strong>bool</strong>, then it might work, but it's certainly bad practice, for several reasons. First, some compilers will cache the reads of the <em>finished_flag</em> variable, since the compiler doesn't always pick up the fact that it's being written to by another thread. You can get around this by declaring the <strong>bool</strong> <strong>volatile</strong>, but that's taking us in the wrong direction. Even if reads and writes are happening as you'd expect, there's nothing to stop the OS scheduler from interleaving the two threads half way through a read / write. That might not be such a problem here where you have one read and one write op in separate threads, but it's a good idea to start as you mean to carry on.</p> <p>If, on the other hand it's a thread-safe type, like a <a href="http://msdn.microsoft.com/en-us/library/efk30beh(VS.71).aspx" rel="nofollow noreferrer">CEvent in MFC</a> (or <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/thread/synchronization.html#thread.synchronization.condvar_ref" rel="nofollow noreferrer">equivilent in boost</a>) then you should be fine. This is the best approach: use thread-safe synchronization objects for inter-thread communication, even for simple flags.</p>
<p>Having the thread set a flag (or signal an event) before it exits is a race condition. The thread has not necessarily returned to the OS yet, and may still be executing. </p> <p>For example, consider a program that loads a dynamic library (pseudocode):</p> <pre><code>lib = loadLibrary("someLibrary"); fun = getFunction("someFunction"); fun(); unloadLibrary(lib); </code></pre> <p>And let's suppose that this library uses your thread:</p> <pre><code>void someFunction() { volatile bool finished_flag = false; thrd = new boost::thread(boost::bind(&amp;myclass::mymethod, this, &amp;finished_flag); while(!finished_flag) { // ignore the polling loop, it's besides the point sleep(); } delete thrd; } void myclass::mymethod() { // do stuff finished_flag = true; } </code></pre> <p>When <code>myclass::mymethod()</code> sets <code>finished_flag</code> to <code>true</code>, <code>myclass::mymethod()</code> hasn't returned yet. At the very least, it still has to execute a "return" instruction of some sort (if not much more: destructors, exception handler management, etc.). If the thread executing <code>myclass::mymethod()</code> gets pre-empted before that point, <code>someFunction()</code> will return to the calling program, and the calling program will unload the library. When the thread executing <code>myclass::mymethod()</code> gets scheduled to run again, the address containing the "return" instruction is no longer valid, and the program crashes.</p> <p>The solution would be for <code>someFunction()</code> to call <code>thrd-&gt;join()</code> before returning. This would ensure that the thread has returned to the OS and is no longer executing.</p>
5,433
<p>My question is pertaining to the best practice for accessing a child object's parent. So let's say a class instantiates another class, that class instance is now referenced with an object. From that child object, what is the best way to reference back to the parent object? Currently I know of a couple ways that I use often, but I'm not sure if A) there is a better way to do it or B) which of them is the better practice</p> <p>The first method is to use getDefinitionByName, which would not instantiate that class, but allow access to anything inside of it that was publicly declared.</p> <pre><code>_class:Class = getDefinitionByName("com.site.Class") as Class; </code></pre> <p>And then reference that variable based on its parent to child hierarchy.<br> Example, if the child is attempting to reference a class that's two levels up from itself:</p> <pre><code>_class(parent.parent).function(); </code></pre> <p>This seems to work fine, but you are required to know the level at which the child is at compared to the level of the parent you are attempting to access.</p> <p>I can also get the following statement to trace out [object ClassName] into Flash's output.</p> <pre><code>trace(Class); </code></pre> <p>I'm not 100% on the implementation of that line, I haven't persued it as a way to reference an object outside of the current object I'm in.</p> <p>Another method I've seen used is to simply pass a reference to this into the class object you are creating and just catch it with a constructor argument</p> <pre><code>var class:Class = new Class(this); </code></pre> <p>and then in the Class file</p> <pre><code>public function Class(objectRef:Object) { _parentRef = objectRef; } </code></pre> <p>That reference also requires you to step back up using the child to parent hierarchy though.</p> <p>I could also import that class, and then use the direct filepath to reference a method inside of that class, regardless of its the parent or not.</p> <pre><code>import com.site.Class; com.site.Class.method(); </code></pre> <p>Of course there the parent to child relationship is irrelevant because I'm accessing the method or property directly through the imported class.</p> <p>I just feel like I'm missing something really obvious here. I'm basically looking for confirmation if these are the correct ways to reference the parent, and if so which is the most ideal, or am I over-looking something else?</p>
<p>It's generally good to have the class as it's own instance and reduce tight coupling to something else (as in this case, it's parent). If you do something like parent.doSomething() it's not possible to use that class in container that doesn't have the doSometing() method. I think it's definitely better to pass in whatever the class may need and then inside the class it doesn't have to do any parent.parent etc anymore.</p> <p>With this if you in the future want to change the structure, it's very easy to just pass in a new reference; the implementation of the child class doesn't have to change at all.</p> <p>The third alternative you have here is also very different, it's accessing a class level static method (you don't have to type the whole class path when accessing that method), not an instance method as in the first two.</p>
<p>If these objects are in the DisplayList, then you have some more options. If I have a ParentClass and a ChildClass, in the child class, you seem to be able to access the parent if you cast the request as the ParentClass. e.g. </p> <pre><code>ParentClass(parent).parentFunction(); </code></pre> <p>I know for sure it works if the ParentClass is the Document Class. As the Document Class is always the first item in the display list, this works:</p> <pre><code>ParentClass(stage.getChildAt(0)).parentFunction(); </code></pre> <p>In my case, they were both members of the same package, so I did not even need to import anything. I haven't tested it in all circumstances, but it worked when I needed it to.</p> <p>Of course 'parent' and 'getChild...' only work if these objects are in the DisplayList, but that's been good enough for me.</p>
8,486
<p>I'm looking to print this item:</p> <blockquote> <p><a href="https://www.thingiverse.com/thing:4274950" rel="nofollow noreferrer">https://www.thingiverse.com/thing:4274950</a></p> </blockquote> <p>I want to lay it flat on the bed, 90° to how it's shown on Thingiverse. The problem is there's the one little corner on the end of the piece. When placed flat, this corner makes one side of arch. During the print, this section will build up to have much more material up in the air over a relatively small contact point, until the archway is connected. </p> <p>I'm worried the section will shake loose from the bed. Is it possible to tell Cura to put a brim around just this section, and not the whole piece?</p> <p>If I have to, I can edit the model the include 0.13 mm thick section there as part of the file. But I'd prefer to slice for this.</p>
<p>I don't know a way to do that with Cura without breaking it up into multiple parts with different settings for each, but what about just enabling supports? You'd only get a very small amount of support material and it would act similarly to a brim to keep the small part from detaching.</p>
<p>I would enable supports using "Touching Build Plate", and then place a support blocker over the portion that you don't want supports added to.</p>
1,630