instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>How can I start an interactive console for Perl, similar to the <code>irb</code> command for Ruby or <code>python</code> for Python?</p>
|
<p>You can use the perl debugger on a trivial program, like so:</p>
<pre><code>perl -de1
</code></pre>
<p>Alternatively there's <a href="http://search.cpan.org/~sukria/perlconsole-0.4/perlconsole" rel="noreferrer"><em>Alexis Sukrieh</em>'s Perl Console</a> application, but I haven't used it.</p>
|
<p>You can do it online (like many things in life) here:</p>
<p><a href="https://www.tutorialspoint.com/execute_perl_online.php" rel="nofollow noreferrer">https://www.tutorialspoint.com/execute_perl_online.php</a></p>
| 9,939
|
<p>We often hear/read that one should avoid dynamic casting. I was wondering what would be 'good use' examples of it, according to you?</p>
<p>Edit:</p>
<p>Yes, I'm aware of <a href="https://stackoverflow.com/questions/28002/regular-cast-vs-staticcast-vs-dynamiccast">that other thread</a>: it is indeed when reading one of the first answers there that I asked my question!</p>
|
<p>This recent thread gives an example of where it comes in handy. There is a base Shape class and classes Circle and Rectangle derived from it. In testing for equality, it is obvious that a Circle cannot be equal to a Rectangle and it would be a disaster to try to compare them. While iterating through a collection of pointers to Shapes, dynamic_cast does double duty, telling you if the shapes are comparable and giving you the proper objects to do the comparison on.</p>
<p><a href="https://stackoverflow.com/questions/301959/vector-iterator-not-dereferencable">Vector iterator not dereferencable</a></p>
|
<p>My current toy project uses dynamic_cast twice; once to work around the lack of multiple dispatch in C++ (it's a visitor-style system that could use multiple dispatch instead of the dynamic_casts), and once to special-case a specific subtype.</p>
<p>Both of these are acceptable, in my view, though the former at least stems from a language deficit. I think this may be a common situation, in fact; most dynamic_casts (and a great many "design patterns" in general) are workarounds for specific language flaws rather than something that aim for.</p>
| 4,773
|
<p>I would like to use <code>as</code> and <code>is</code> as members of an enumeration. I know that this is possible in VB.NET to write it like this:</p>
<pre><code>Public Enum Test
[as] = 1
[is] = 2
End Enum
</code></pre>
<p>How do I write the equivalent statement in C#?
The following code does not compile:</p>
<pre><code>public enum Test
{
as = 1,
is = 2
}
</code></pre>
|
<p>Prefixing reserved words in C# is done with @.</p>
<pre><code>public enum Test
{
@as = 1,
@is = 2
}
</code></pre>
|
<p>It does seem like a bad idea though - like setting FIVE to equal 6.</p>
<p>Why not just use a predetermined prefix so that te names are unique and future maintainers of your code understand what you are doing?</p>
| 4,495
|
<p>SharePoint 2007 (both Moss and Wss) exposes document libraries via web dav, allowing you to create documents via essentially file system level activities (e.g. saving documents to a location).</p>
<p>SharePoint also seems to expose lists via the same web dav interface, as directories but they are usually empty. Is it possible to create or manipulate a list item somehow via this exposure?</p>
|
<p>In short: No. </p>
<p>Longer answer: Kinda. Any item stored in sharepoint is in a list, including files. But not all lists have files. A document library is a list with each element being a file+metadata. Other lists (like announcments) are just metadata. Only lists that contain files are exposed via webdav, and even then you are limited to mucking around with the file - there is no way to use webdav (afaik) to edit the metadata.</p>
<p>Hope this helps.</p>
<p>Oisin.</p>
|
<p>Agreed. The only thing exposed to webdav is a list item's attachment (or a library's documents). Even if you bring up a file's properties in explorer, there's no options for list data.</p>
<p>If you're working with Office 2007 documents, you can create a <a href="http://msdn.microsoft.com/en-us/library/ms550037.aspx" rel="nofollow noreferrer">document information panel</a> that can be tied into sharepoint.</p>
| 9,838
|
<p>It finally started to annoy me enough to ask this question: how do I do a basic diff between two revisions of a file in CVS? Usually I want to compare the latest revision and some random old one. I'm using the Eclipse CVS plugin. When I use "compare with->Another branch or version..." from the selected file's (latest revision from HEAD or another branch) context menu, I get a list of branches, tags and dates but not revisions. Usually I have just created a date which I know is far enough in the past so I can compare the needed revisions but I thought that there must be a better way.</p>
|
<p>The answer is to show the file's history using context menu->Team->Show history, then choose two revisions and context menu for the selection->compare with each other.</p>
|
<p>There seems to be two main ways:</p>
<p><strong>context menu->Team->Show history</strong></p>
<p>which shows a linear history and you can select and compare between them, however it can be very bloated and hard to read when your project has lots of branches / tags. Personally i have found it less useful than:</p>
<p><strong>context menu->Team->Show Commit history</strong></p>
<p>Which seems to show the history of what has been committed to the specific branch/tag you are on. You can do it per file or per folder. The output is very similar but i find it clearer. You can click on a commit date and it will show you all the files (that you are interested in) that were committed on that date.</p>
<p>If you double click the file, it will then bring up another menu so that you can compare it with another file in the commit history </p>
<p><strong>EDIT</strong>
(i find if you double click the "other" file, it doesn't do anything, you need to click "OK" in the dialogue, which seems silly to me. This might be effected by the fact I have the beyond compare 3 plug in, im not sure if it behaves the same without it)
<strong>EDIT</strong></p>
<p>There is also a little button in the top right of the commit history window that allows you to switch to history view (but i always find it easy to read than the normal history view if i do it this way round) </p>
<p>Both should show you the comment added when committed and you should try and read about the differences between the but personally I haven't and its only form personal experience that i prefer commit history.</p>
<p>I apologize for not giving formal descriptions of each, this is purely from my personal experience of using them, i have not actually researched them both yet myself...</p>
| 9,715
|
<p>Is there a plugin for targetting .NET 1.1 with VS 2008?</p>
|
<p>Try using ClearType, not Standard font smoothing. </p>
<p>It's in Display properties, Appearance, Effects.</p>
|
<p>Could it be a problem with the color combination? Some fonts look really ugly on high contrast combinations with a black background.</p>
<p>Also, can you see the difference in the fonts in any other application?</p>
<p>Which font is it?</p>
| 6,648
|
<p>I have a case where a VB.Net winforms app needs to play WMV files from across the network. The user running the app cannot be given direct access to the network share. Through impersonation, I can see that the files exist (without impersonation, File.Exists returns false for the files on the network share). When I then try to load the file into a Windows Media Player control, the control just remains black. I have deduced that when the Windows Media Player control is loaded into memory, it is running on a separate unmanaged thread than the .Net managed thread. Is there any way to pass that security token from the managed thread to the unmanaged thread? Am I missing something completely?</p>
|
<p>Have you tried using <a href="http://msdn.microsoft.com/en-us/library/system.appdomain.setthreadprincipal.aspx" rel="nofollow noreferrer"><code>SetThreadPrincipal</code></a> method off <code>AppDomain</code>?</p>
<p>Example:</p>
<p><code>IPrinicipal userPrincipal = new MyCustomPrincipal();</code></p>
<p><code>AppDomain currentDomain = AppDomain.CurrentDomain;</code></p>
<p><code>currentDomain.SetThreadPrincipal(userPrincipal);</code></p>
<p>You mentioned in your question, that WMV seems to run unmanaged, so if that premise is correct, this really shouldn't work (see my second answer).</p>
|
<p>I suppose you tried using </p>
<pre><code>[DllImport("advapi32.dll", SetLastError=true)]
public static extern int LogonUser(string pszUsername, string pszDomain, string pszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
</code></pre>
<p>to log in the network share.</p>
<p>In my experience it doesn't care about threads.</p>
<p>I can show you a usage example if you think it can be useful at all. Kind of a long shot to mention it here.</p>
| 8,885
|
<p>Has anyone successfully implemented a Java based solution that uses Microsoft SQL Server 2005 Reporting Services? Reporting Services comes with a set of Web Services that allow you to control the creation of a report, execution of a report, etc and I am just starting development on a POC of this integration. A couple of choices I have yet to make is whether I want to use Axis2 for the wsdl-to-java functionality or use WebLogic's clientgen (wsdl 2 java) solution. I guess I can also use JAX-WS and wsimport. Before I dive into this, I wanted to see if anyone was doing this successfully with one of the many options available. </p>
<p>In the past, I've had a few issues on how null/blank/empty's are handled between .NET and Java web-services and I just wanted to see if this had come up as an issue with SSRS and Java integration. Thanks</p>
|
<p>My experience with RS would lead me to suggest you go with just about anything else. I think the web services portion would work fine but I'd be concerned about how RS manages memory and how many reports you need to be running at once before making any decisions. I'm fighting with memory management problems today with RS and even on top of the line hardware it's hard to run large reports (large number of rows returned and a wide result set).</p>
<p>That being said if you think RS can handle your usage then it might be good. The development environment is sort of nice and it's easy to understand and lay out reports. The table layout paradigm it has is pretty good.</p>
|
<p>we've successfully implemented that: JBoss 5 -> IIS proxy -> MS Reporting Services 2008 (via webservice).</p>
<p>There are few pitfalls: MS RS 2008 does not support 'Anonymous' access anymore (2005 does), and does enforce using NTLM authentication. That is still a challenge in Java world, there is no good NTLM library available.</p>
<p>To overcome that, we've implemented trivial proxy (IIS7 + ashx) that does NTLM authentication on RS (user/password hardcoded) and allows Anonymous access for JBoss (by simply rewriting http response).</p>
<p>Works ok :)</p>
<p>Cheers
P</p>
| 9,372
|
<p>I've used a WordPress blog and a Screwturn Wiki (at two separate jobs) to store private, company-specific KB info, but I'm looking for something that was created to be a knowledge base. Specifically, I'd like to see:</p>
<ul>
<li>Free/low cost</li>
<li>Simple method for users to subscribe to KB (or just sections) to get updates</li>
<li>Ability to do page versioning/audit changes</li>
<li>Limit access to certain pages for certain users</li>
<li>Very simple method of posting/editing articles</li>
<li>Very simple method of adding images to articles</li>
<li>Excellent (fast, accurate) searching abilities</li>
<li>Ability to rate and comment on articles</li>
</ul>
<p>I liked using the Wordpress blog because it allowed me to use <a href="http://get.live.com/" rel="noreferrer">Live Writer</a> to add/edit articles and images, but it didn't have page versioning (that I could see).</p>
<p>I like using Screwturn wiki because of it's ability to track article versions, and I like it's clean look, but some non-technical people balk at the input and editing.</p>
|
<p>I second Luke's answer.</p>
<p>I can Recommend <a href="http://www.atlassian.com/software/confluence/" rel="noreferrer">Confluence</a> and here is why:
I tested extensively many commercial and free Wiki based solutions. Not a single one is a winner on all accounts, including confluence. Let me try to make your quest a little shorter by summarizing what I have learned to be a pain and what is important:</p>
<ul>
<li>WYSIWYG is a most have feature for the Enterprise. A wiki without it, skip it</li>
<li>Saying that, in reality, WYSIWYG doesn't work perfectly. It is more of a feature you must have to get the casual users not be afraid of the monster, and start using it. But you and anyone that wants to seriously create content, will very quickly get used to the wiki markup. it is faster and more reliable. </li>
<li>You need good permissions controls (who can see, edit etc' a page). confluence has good, but I have my complaints (to complicated to be put here)</li>
<li>You will want a good <em>export</em> feature. Most will give you a single page "PDF" export, but you need much more. For example, lets say you have an FAQ, you want to export the entire FAQ right? will that work? </li>
<li>Macros: you want a community creating macros. You asked for example about the ability to <strong>rate</strong> pages, here is a <a href="http://confluence.atlassian.com/display/CONFEXT/Rate+Macro" rel="noreferrer">link</a> to a Macro for Confluence that lets you do that</li>
<li>Structure: you want to be able to say that a page is a child of a different page, and be able to browse the data. The wikipedia model, of orphaned pages with no sturcture will not work in the Enterprise. (think FAQ, you want to have a hierarchy no?)</li>
<li>Ability to <em>easily</em> attache picture to be embedded in the body of the page/article. In confluence, you need to upload the image and then can embed it, it could be a little better (CTR+V) but I guess this is easy enough for 80% of the users.</li>
</ul>
<p>At the end of the day, remember that a Wiki will be valuable to you the more flexible it is. It needs to be a "blank" canvas, and your imagination is then used to "build" the application. In Confluence, I found 3 different "best practices" on how to create a FAQ. That means I can implement MANY things. </p>
<p>Some examples (I use my Wiki for)</p>
<ul>
<li>FAQ: any error, problem is logged. Used by PS and ENG. reduced internal support time dramatically</li>
<li>Track account status: I implemetned sophisticated "dashboard" that you can see at a glance which customer is at what state, the software version they have, who in the company 'owns" the custoemr etc'</li>
<li>Product: all documentation, installation instructions, the "what's new" etc</li>
<li>Technical documentation, DB structure and what the tables mean </li>
<li>HR: contact list, Document repository </li>
</ul>
<p>My runner up (15 month ago) was free <a href="http://wiki.developer.mindtouch.com/Deki_Wiki" rel="noreferrer">Deki_Wiki</a>, time has passed, so I don't know if this would be still my runner up.</p>
<p>good luck!</p>
|
<p>We've been using a combination of </p>
<ul>
<li>TWiki</li>
<li>OpenGrok for the codebase</li>
<li>usenet</li>
<li>LotusNotes based system</li>
</ul>
<p>As long as there is a google search appliance pointed at these things I think it's ok to have any or many versions as long as people use them</p>
| 2,474
|
<p>I am stress testing a .NET web application. I did this for 2 reasons: I wanted to see what performance was like under real world conditions and also to make sure we hadn't missed any problems during testing. We had 30 concurrent users in the application using it as they would during the normal course of their jobs. Most users had multiple windows of the application open.</p>
<ul>
<li>10 Users: Not bad</li>
<li>20 Users: Slowing down </li>
<li>30 Users: Very, very slow but no timeouts</li>
</ul>
<p>It was loaded on the production server. It is a virtual server with a 2.66G Hz Xeon processor and 2 GB of RAM. We are using Win2K3 SP2. We have .NET 1.1 and 2.0 loaded and are using SQLExpress SP1.</p>
<p>We rechecked the indexes on all of the tables afterword and they were all as they should be.</p>
<p>How can we improve our application's performance?</p>
|
<p>This is just something that I thought of, but check to see how much memory SQL Server is using when you have 20+ users - one of the limitations of the Express version is that it is <a href="http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx" rel="nofollow noreferrer">limited to 1GB of RAM</a>. So it might just be a simple matter of there not being enough memory available to to server due to the limitations of Express.</p>
|
<p>Update: Looks like SQL Server express is not the problem as they were using the same product in previous version of the application. I think your next step is in identifying the bottlenecks. If you are sure it is in the database layer, I would recommend taking a profiler trace and bringing down the execution time of the most expensive queries.</p>
<p>This is another link I use for collecting statistics from SQL Server Dynamic Management Views (DMVs) and related Dynamic Management Functions (DMFs). Not sure if we can use in the Express edition.
<a href="http://msdn.microsoft.com/en-us/magazine/cc135978.aspx" rel="nofollow noreferrer">Uncover Hidden Data to Optimize Application Performance</a>.</p>
<hr>
<p>Are you using SQL Server Express for a web app? As far as I know, it has some limitations for production deployment.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms144275.aspx" rel="nofollow noreferrer">SQL Server Express</a> is free and can be redistributed by ISV's (subject to agreement). <strong>SQL Server Express is</strong> <strong>ideal for learning and building desktop and small server applications</strong>. This edition is the best choice for independent software vendors, non-professional developers, and hobbyists building client applications. If you need more advanced database features, SQL Server Express can be seamlessly upgraded to more sophisticated versions of SQL Server.</p>
| 8,352
|
<p>I need to keep the files & folders on two Windows-based, non-domain machines synchronized across a public network. </p>
<p>I was thinking rsync over SSH - but I was wondering if there is a simpler solution? Any possibility of using the sync framework over SFTP/SCP/SSH? </p>
<p>Or I'm open to better ideas?</p>
|
<p>Figured I'd post what I finally went with - WinSCP - <a href="http://winscp.net" rel="nofollow noreferrer">http://winscp.net</a></p>
<p>Connects via GUI to an SFTP server + supports Local/Remote/Both synchronization + scriptable with command-line/batch interface.</p>
|
<p>You could set up shared folders over a secure VPN with <a href="http://www.hamachi.cc" rel="nofollow noreferrer">Hamachi</a>, then use a folder syncing app to sync them up.</p>
| 4,516
|
<p>I've been thinking about alternatives to support materials for FDM printers, such as multi axis printers, dual head with soluble support material or printing in a gel/liquid which traps the material in place. Then it occurred to me that it might be possible to use the surface tension of a liquid to act as support material, same way small objects an insect can float on water even though they are heavier than water. This would also work great for cooling the extruded material. NOTE, we are still using a base plate like any other FDM printer, the only difference is that we have a water surface on the build plate which act as support material for large overhangs/steep angles. Everything is still attached to the build plate itself. We are not just printing stand alone parts on the surface of the water.</p>
<p>After some highly scientific testing (Dropping an extruded string of PLA and placing a thin printed PLA part on the top of water) I've concluded that it is very feasible to float PLA on the surface tension of water. See picture for refence: <a href="https://i.stack.imgur.com/hikJO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hikJO.jpg" alt="PLA floating on surface tension"></a></p>
<p>As you can see the floating structure is not at all trivial, it has both smooth round shapes and many sharp corners and holes in it, it was still extremely simple to get floating (I could drop it in from a height of 5 cm and it would still not break the surface tension).
I also tried my best to investigate the effects of having structures underneath which might mess up the surface tension by placing larger PLA parts under the floating ring and trying to sink the ring by touching the underside and corners without any success at sinking the floating part. The only way I could get this part to sink was to push it down under water. Even if the surface tension was only broken half way along the ring the ring would still float. If you are thinking that the ring acted as a boat, that is not the case. I made sure to fill the small indents with water so that there were no pockets of air keeping it afloat.</p>
<p>An even more encouraging result was another ring which was much thicker than it was wide. It still managed to float from the surface tension on the top side of the structure while the rest of it was submerged, accurately mimicking how the structure would actually be in the water during printing. See picture:
<a href="https://i.stack.imgur.com/CPQSH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CPQSH.jpg" alt="Floating PLA ring thick "></a></p>
<p>While this ring much easier to sink it was very resistant to being moved around. Again, basically the only way to sink it was to push it down under water, though as soon as the surface tension was broken on one side the whole ring quickly sank.</p>
<p>All this leads me to my question: Does anyone know of a 3D printer which uses the surface tension of water as support material?</p>
<p>I've searched around some on the web and I have not really found anything at all on the matter. I can foresee many potential problems (such as the extruder moving unsupported lines to the side when changing direction, layer adhesion, enclosed areas not filling with water etc) but the potential to print without support and only have to worry about keeping the newly extruded material in place could open up a lot of potential.</p>
<p>UPDATE: I also tried 60 degree Celsius water (In case you need hot water to help with layer adhesion) and the surface tension still was able to float the thicker ring piece, though it felt like the surface tension was weaker.</p>
|
<h1>It's not feasible as described with normal FDM technology.</h1>
<p>FDM bases on depositing material in a single path. This needs the deposited material to stay at the same XY coordinates for subsequent paths. And exactly here is where a floating piece fails: a free-floating piece is by its very definition unrestricted in XY, and would move to follow the nozzle.</p>
<p>There are is also a whole plethora of factors that make this idea not feasible with the standard technology, meaning you'll have to develop the whole process, not just recombine two ideas. This means, you need to solve the following issues:</p>
<h2>Heatsink Water</h2>
<p>The extruded plastic needs to stay close to the melting point for some time, so it can fuse and bond with the lines next to them. However, water is known to be a very good method to get the heat away from items, as each liter of water can take about 4.1 MJ and only heat by one Kelvin. PLA on the other hand only stores about <a href="https://www.makeitfrom.com/material-properties/Polylactic-Acid-PLA-Polylactide" rel="nofollow noreferrer">1.8 MJ per Kilogram and Kelvin</a>.</p>
<p>As a back of the envelope calculation, the temperature differential between room temperature and printing temperature PLA is about 180 Kelvin. Each gram of PLA is equivalent to 319.8 mm of filament (assuming a density of 1.3 g/cm³) or an extruded line of 9.6 kilometer length of 0.4 mm width and 0.2 mm height! That one gram contains about 324 Joules of energy that will be dispersed to the room temperature as it cools down. The water vat would not even get measurably warmer from sucking those few joules from a whole print!</p>
<p>While this could be, in the right setup, be used to rapidly cool the print and <em>solidify</em> it in shape, the result of the rapid healing will most likely also impact print quality negatively, as cross-layer bonding is reduced.</p>
<h2>Separator water</h2>
<p>It is a well-known trick in creating polymer fibers to extrude underwater, as the water not only cools (see above) but also acts as a separator between the fibers, for the very short timeframe they are still malleable. This would also strike when printing into the water - there'll be a water layer in between the deposited filament, which would need to either get pressed out or cooked out before any cross-extrusion bonding can occur. As a result, just extruding into the water should result in a print that has almost no sturdiness, and might fall apart on touch.</p>
<h2>Floating</h2>
<p>Water has a density of 1 g/cm³. PLA has a density of 1.3 g/cm³. So a solid chunk of PLA sinks. But we don't print solid, we include air. Not just a few percent but infill is usually below 20 %. I have just printed a cube. After smoothing the surface by sanding, the cube is 29,7x29.9x29.9 mm. It has 3 parameters, 20% infill, 5 top and bottom layers with 0.2 mm layer height and comes to 11 grams. 11 g/26.55 cm³=0.41 g/cm³. Or in other words: the cube would float, about 40 % under the water surface, 60 % above the surface. The print would be, as a result, quickly break the water surface and get no support from the water at all.</p>
<h2>Submerging the bed?</h2>
<p>The main issue of a free-floating object (position) might be mitigated if there was a bed that would be submerged, but one would open a new can of worms, that might be even worse: the volume of the print and the accuracy of pumps.</p>
<p>As the print goes on - quality be dammed - the print grows in volume. However, it doesn't grow entirely linear, depending on two factors:</p>
<ul>
<li>Is the print happening on/below the water surface? Then we will include water in the print. The volumetric growth of the print is in this case just the deposited filament. You'll need an overflow to compensate for the print growing and keep the water level in position.</li>
<li>Is the print happening <em>just above</em> the surface of the water? then the displaced volume grows according to the depth of the print in the water. This would mitigate most of the problems from water preventing cross-bonding and causing floating, and even use the heatsink properties more beneficial, as any filament starting to sag will be stopped. It also would prevent water from being encased in the print. However, it does not use surface tension. Also, you'll need an overflow system to keep the water level steady.</li>
</ul>
|
<p>I just had the same idea and googled it. My idea was to submerge the whole print platform in the water and lower it down so that the water level and the current layer line are always at the same height. Maybe a pump would be required to counteract the plastic displacing water. Completely floating parts of the print could have a tower with three contact points underneath to keep them in place without having to lift the whole structure.</p>
| 1,536
|
<p>I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example:</p>
<pre><code>declare @value decimal(18,2)
set @value = 123.456
</code></pre>
<p>This will automatically round <code>@value</code> to be <code>123.46</code>, which is good in most cases. However, for this project, I don't need that. Is there a simple way to truncate the decimals I don't need? I know I can use the <code>left()</code> function and convert back to a decimal. Are there any other ways?</p>
|
<pre><code>select round(123.456, 2, 1)
</code></pre>
|
<pre><code>select convert(int,@value)
</code></pre>
| 6,567
|
<p>Is there an easy way to return data to web service clients in JSON using java? I'm fine with servlets, spring, etc.</p>
|
<p>To me, <a href="http://xstream.codehaus.org/json-tutorial.html" rel="noreferrer">the best Java <-> JSON parser is XStream</a> (yes, I'm really talking about json, not about xml). XStream already deals with circular dependencies and has a simple and powerful api where you could write yours drivers, converters and so on.</p>
<p>Kind Regards</p>
|
<p>For RESTful web services in Java, also check out the <a href="http://www.restlet.org/" rel="nofollow noreferrer">Restlet API</a> which provides a very powerful and flexible abstraction for REST web services (both server and client, in a container or standalone), and also integrates nicely with Spring and JSON.</p>
| 8,203
|
<p><strong>Edit</strong>: Solved, there was a trigger with a loop on the table (read my own answer further below).</p>
<hr>
<p>We have a simple delete statement that looks like this:</p>
<pre><code>DELETE FROM tablename WHERE pk = 12345
</code></pre>
<p>This just hangs, no timeout, no nothing.</p>
<p>We've looked at the execution plan, and it consists of many lookups on related tables to ensure no foreign keys would trip up the delete, but we've verified that none of those other tables have any rows referring to that particular row.</p>
<p>There is no other user connected to the database at this time.</p>
<p>We've run DBCC CHECKDB against it, and it reports 0 errors.</p>
<p>Looking at the results of <em><code>sp_who</code></em> and <em><code>sp_lock</code></em> while the query is hanging, I notice that my spid has plenty of PAG and KEY locks, as well as the occasional TAB lock.</p>
<p>The table has 1.777.621 rows, and yes, pk is the primary key, so it's a single row delete based on index. There is no table scan in the execution plan, though I notice that it contains something that says <em>Table Spool (Eager Spool)</em>, but says Estimated number of rows 1. Can this actually be a table-scan in disguise? It only says it looks at the primary key column.</p>
<p>Tried DBCC DBREINDEX and UPDATE STATISTICS on the table. Both completed within reasonable time.</p>
<p>There is unfortunately a high number of indexes on this particular table. It is the core table in our system, with plenty of columns, and references, both outgoing and incoming. The exact number is 48 indexes + the primary key clustered index.</p>
<p>What else should we look at?</p>
<p>Note also that this table did not have this problem before, this problem occured suddently today. We also have many databases with the same table setup (copies of customer databases), and they behave as expected, it's just this one that is problematic.</p>
|
<p>One piece of information missing is the number of indices on the table you are deleting the data from. As SQL Server uses the Primary Key as a pointer in every index, any change to the primary index requires updating every index. Though, unless we are talking a high number, this shouldn't be an issue.</p>
<p>I am guessing, from your description, that this is a primary table in the database, referenced by many other tables in FK relationships. This would account for the large number of locks as it checks the rest of the tables for references. And, if you have cascading deletes turned on, this could lead to a delete in table a requiring checks several tables deep.</p>
|
<p>Ok, this is embarrasing.</p>
<p>A collegue had added a trigger to that table a while ago, and the trigger had a bug. Although he had fixed the bug, the trigger had never been recreated for that table.</p>
<p>So the server was actually doing nothing, it just did it a huge number of times.</p>
<p>Oh well...</p>
<p>Thanks for the eyeballs to everyone who read this and pondered the problem.</p>
<p>I'm going to accept Josef's answer, as his was the closest, and indirectly thouched upon the issue with the cascading deletes.</p>
| 7,994
|
<p>I'm reading through head first design patterns at the moment and while the book is excellent I also would like to see how these are actually used in the real world.</p>
<p>If you know of a good example of design pattern usage (preferably in a OSS program so we can have a look :) then please list it below.</p>
|
<p>An ah-ha moment for me for the observer pattern was to realize how closely associated it is with events. Consider a Windows program that needs to acheive loosely communications between two forms. That can easily be accomplished with the observer pattern.</p>
<p>The code below shows how Form2 fires an event and any other class registered as an observer get its data. </p>
<p>See this link for a great patterns resource:
<a href="http://sourcemaking.com/design-patterns-and-tips" rel="nofollow noreferrer">http://sourcemaking.com/design-patterns-and-tips</a></p>
<p>Form1's code:</p>
<pre><code>namespace PublishSubscribe
{
public partial class Form1 : Form
{
Form2 f2 = new Form2();
public Form1()
{
InitializeComponent();
f2.PublishData += new PublishDataEventHander( DataReceived );
f2.Show();
}
private void DataReceived( object sender, Form2EventArgs e )
{
MessageBox.Show( e.OtherData );
}
}
}
</code></pre>
<p>Form2's code</p>
<pre><code>namespace PublishSubscribe
{
public delegate void PublishDataEventHander( object sender, Form2EventArgs e );
public partial class Form2 : Form
{
public event PublishDataEventHander PublishData;
public Form2()
{
InitializeComponent();
}
private void button1_Click( object sender, EventArgs e )
{
PublishData( this, new Form2EventArgs( "data from form2" ) );
}
}
public class Form2EventArgs : System.EventArgs
{
public string OtherData;
public Form2EventArgs( string OtherData )
{
this.OtherData = OtherData;
}
}
}
</code></pre>
|
<p>Composite is used extensively in UI. Components can be leaf components e.g. buttons and labels or composites e.g. panels, that can contain other leaf or composite components. From the point of view of the client, all components are treated the same, which greatly simplifies the client code.</p>
| 5,682
|
<p>I would like to execute an OS command from my ruby script but I want to add an argument from a ruby variable.</p>
<p>I know that's possible by using keyword <em>system</em> like that :</p>
<pre><code>#!/usr/bin/env ruby
directory = '/home/paulgreg/'
system 'ls ' + directory
</code></pre>
<p>but is that possible by using the "backquotes or backticks syntax" ?
(I mean by using that syntax : <code>ls</code>)</p>
|
<p>No, that will just concatenate the output from <code>ls</code> and the contents of <code>directory</code>.</p>
<p>But you can do this:</p>
<pre><code>#!/usr/bin/env ruby
directory = '/home/paulgreg/'
`ls #{directory}`
</code></pre>
|
<p>Nick is right, but there is no need to assemble the args piecewise:</p>
<pre><code>directory = '/Volumes/Omg a space/'
system('/bin/ls', directory)
</code></pre>
| 6,295
|
<p>Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type</p>
<pre><code>sudo vi filename
</code></pre>
<p>Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a while ago, but now I can't find it.</p>
|
<p><code>%</code> is replaced with the current file name, thus you can use:</p>
<pre><code>:w !sudo tee %
</code></pre>
<p>(<code>vim</code> will detect that the file has been changed and ask whether you want to it to be reloaded. Say yes by choosing <code>[L]</code> rather than OK.)</p>
<p>As a shortcut, you can define your own command. Put the following in your <code>.vimrc</code>:</p>
<pre><code>command W w !sudo tee % >/dev/null
</code></pre>
<p>With the above you can type <code>:W<Enter></code> to save the file. Since I wrote this, I have found a nicer way (in my opinion) to do this:</p>
<pre><code>cmap w!! w !sudo tee >/dev/null %
</code></pre>
<p>This way you can type <code>:w!!</code> and it will be expanded to the full command line, leaving the cursor at the end, so you can replace the <code>%</code> with a file name of your own, if you like.</p>
|
<p>A quick hack you can consider is doing a chmod on the file you're editing, save with vim, and then chmod back to what the file was originally.</p>
<pre><code>ls -l test.file (to see the permissions of the file)
chmod 777 test.file
[This is where you save in vim]
chmod xxx test.file (restore the permissions you found in the first step)
</code></pre>
<p>Of course I don't recommend this approach in a system where you're worried about security, as for a few seconds anyone can read/change the file without you realizing.</p>
| 2,340
|
<p>I want to create a regexp in Emacs that matches exactly 3 digits. For example, I want to match the following:</p>
<pre><code>123
345
789
</code></pre>
<p>But not</p>
<pre><code>1234
12
12 23
</code></pre>
<p>If I use <code>[0-9]+</code> I match any single string of digits. I thought <code>[0-9]{3}</code> would work, but when tested in re-builder it doesn't match anything.</p>
|
<p>If you're entering the regex interactively, and want to use <code>{3}</code>, you need to use backslashes to escape the curly braces. If you don't want to match any part of the longer strings of numbers, use <code>\b</code> to match word boundaries around the numbers. This leaves:</p>
<pre><code>\b[0-9]\{3\}\b
</code></pre>
<p>For those wanting more information about <code>\b</code>, see <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Backslash.html#Regexp-Backslash" rel="noreferrer">the docs</a>:</p>
<blockquote>
<p>matches the empty string, but only at the beginning or end of a word. Thus, <code>\bfoo\b</code>
matches any occurrence of <code>foo</code> as a separate word.
<code>\bballs?\b</code> matches <code>ball</code> or <code>balls</code> as a separate word.
<code>\b</code> matches at the beginning or end of the buffer regardless of what text appears next to it. </p>
</blockquote>
<p>If you do want to use this regex from elisp code, as always, you must escape the backslashes one more time. For example:</p>
<pre><code>(highlight-regexp "\\b[0-9]\\{3\\}\\b")
</code></pre>
|
<p>It's pretty simple:</p>
<pre><code>[0-9][0-9][0-9]
</code></pre>
| 9,495
|
<p>I'm using Excel VBA to a write a UDF. I would like to overload my own UDF with a couple of different versions so that different arguments will call different functions. </p>
<p>As VBA doesn't seem to support this, could anyone suggest a good, non-messy way of achieving the same goal? Should I be using Optional arguments or is there a better way?</p>
|
<p>Declare your arguments as <code>Optional Variants</code>, then you can test to see if they're missing using <code>IsMissing()</code> or check their type using <code>TypeName()</code>, as shown in the following example:</p>
<pre><code>Public Function Foo(Optional v As Variant) As Variant
If IsMissing(v) Then
Foo = "Missing argument"
ElseIf TypeName(v) = "String" Then
Foo = v & " plus one"
Else
Foo = v + 1
End If
End Function
</code></pre>
<p>This can be called from a worksheet as <strong>=FOO()</strong>, <strong>=FOO(<em>number</em>)</strong>, or <strong>=FOO("<em>string</em>")</strong>.</p>
|
<p>VBA is messy. I'm not sure there is an easy way to do fake overloads:</p>
<p>In the past I've either used lots of Optionals, or used varied functions. For instance </p>
<pre><code>Foo_DescriptiveName1()
Foo_DescriptiveName2()
</code></pre>
<p>I'd say go with Optional arguments that have sensible defaults unless the argument list is going to get stupid, then create separate functions to call for your cases.</p>
| 8,999
|
<p>I'm building a listing/grid control in a <code>Flex</code> application and using it in a <code>.NET</code> web application. To make a really long story short I am getting XML from a webservice of serialized objects. I have a page limit of how many things can be on a page. I've taken a data grid and made it page, sort across pages, and handle some basic filtering. </p>
<p>In regards to paging I'm using a Dictionary keyed on the page and storing the XML for that page. This way whenever a user comes back to a page that I've saved into this dictionary I can grab the XML from local memory instead of hitting the webservice. Basically, I'm caching the data retrieved from each call to the webservice for a page of data.</p>
<p>There are several things that can expire my cache. Filtering and sorting are the main reason. However, a user may edit a row of data in the grid by opening an editor. The data they edit could cause the data displayed in the row to be stale. I could easily go to the webservice and get the whole page of data, but since the page size is set at runtime I could be looking at a large amount of records to retrieve.</p>
<p>So let me now get to the heart of the issue that I am experiencing. In order to prevent getting the whole page of data back I make a call to the webservice asking for the completely updated record (the editor handles saving its data).</p>
<p>Since I'm using custom objects I need to serialize them on the server to XML (this is handled already for other portions of our software). All data is handled through XML in e4x. The cache in the Dictionary is stored as an XMLList.</p>
<p><strong>Now let me show you my code...</strong></p>
<pre><code>var idOfReplacee:String = this._WebService.GetSingleModelXml.lastResult.*[0].*[0].@Id;
var xmlToReplace:XMLList = this._DataPages[this._Options.PageIndex].Data.(@Id == idOfReplacee);
if(xmlToReplace.length() > 0)
{
delete (this._DataPages[this._Options.PageIndex].Data.(@Id == idOfReplacee)[0]);
this._DataPages[this._Options.PageIndex].Data += this._WebService.GetSingleModelXml.lastResult.*[0].*[0];
}
</code></pre>
<p>Basically, I get the id of the node I want to replace. Then I find it in the cache's Data property (<code>XMLList</code>). I make sure it exists since the filter on the second line returns the <code>XMLList</code>.</p>
<p>The problem I have is with the delete line. I cannot make that line delete that node from the list. The line following the delete line works. I've added the node to the list.</p>
<p>How do I replace or delete that node (meaning the node that I find from the filter statement out of the .Data property of the cache)???</p>
<p>Hopefully the underscores for all of my variables do not stay escaped when this is posted! otherwise <code>this.&#95 == this</code>._</p>
|
<p>Thanks for the answers guys.</p>
<p>@Theo:
I tried the replace several different ways. For some reason it would never error, but never update the list.</p>
<p>@Matt:
I figured out a solution. The issue wasn't coming from what you suggested, but from how the delete works with Lists (at least how I have it in this instance).</p>
<p>The Data property of the _DataPages dictionary object is list of the definition nodes (was arrived at by a previous filtering of another XML document).</p>
<pre><code><Models>
<Definition Id='1' />
<Definition Id='2' />
</Models>
</code></pre>
<p>I ended up doing this little deal:</p>
<pre><code>//gets the index of the node to replace from the same filter
var childIndex:int = (this._DataPages[this._Options.PageIndex].Data.(@Id == idOfReplacee)[0]).childIndex();
//deletes the node from the list
delete this._DataPages[this._Options.PageIndex].Data[childIndex];
//appends the new node from the webservice to the list
this._DataPages[this._Options.PageIndex].Data += this._WebService.GetSingleModelXml.lastResult.*[0].*[0];
</code></pre>
<p>So basically I had to get the index of the node in the XMLList that is the Data property. From there I could use the delete keyword to remove it from the list. The += adds my new node to the list.</p>
<p>I'm so used to using the ActiveX or Mozilla XmlDocument stuff where you call "SelectSingleNode" and then use "replaceChild" to do this kind of stuff. Oh well, at least this is in some forum where someone else can find it. I do not know the procedure for what happens when I answer my own question. Perhaps this insight will help someone else come along and help answer the question better!</p>
|
<p>I don't immediately see the problem, so I can only venture a guess. The <code>delete</code> line that you've got is looking for the first item <em>at the top level</em> of the list which has an attribute "Id" with a value equal to <code>idOfReplacee</code>. Ensure that you don't need to dig deeper into the XML structure to find that matching id.</p>
<p>Try this instead:</p>
<pre><code>delete (this._DataPages[this._Options.PageIndex].Data..(@Id == idOfReplacee)[0]);
</code></pre>
<p>(Notice the extra '.' after <code>Data</code>). You could more easily debug this by setting a breakpoint on the second line of the code you posted, and ensure that the XMLList looks like you expect.</p>
| 3,213
|
<p>I am developing console application in .Net and I want to change a behavior a little based on information that application was started from cmd.exe or from explorer.exe. Is it possible?</p>
|
<pre><code>Process this_process = Process.GetCurrentProcess();
int parent_pid = 0;
using (ManagementObject MgmtObj = new ManagementObject("win32_process.handle='" + this_process.Id.ToString() + "'"))
{
MgmtObj.Get();
parent_pid = Convert.ToInt32(MgmtObj["ParentProcessId"]);
}
string parent_process_name = Process.GetProcessById(parent_pid).ProcessName;
</code></pre>
|
<p>The <a href="http://msdn.microsoft.com/en-us/library/ms682489(VS.85).aspx" rel="nofollow noreferrer">CreateToolhelp32Snapshot Function</a> has a Process32First method that will allow you to read a <a href="http://msdn.microsoft.com/en-us/library/ms684839(VS.85).aspx" rel="nofollow noreferrer">PROCESSENTRY32 Structure</a>. The structure has a property that will get you the information you want:</p>
<blockquote>
<p><strong>th32ParentProcessID</strong> - The identifier
of the process that created this
process (its parent process).</p>
</blockquote>
<p>This article will help you get started using the ToolHelpSnapshot function:</p>
<p><a href="http://www.codeproject.com/KB/cs/IsApplicationRunning.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/IsApplicationRunning.aspx</a></p>
| 7,699
|
<p>Is there an algorithm or some heuristic to decide whether digital audio data is <a href="http://en.wikipedia.org/wiki/Clipping_(audio)#Digital_clipping" rel="nofollow noreferrer">clipping</a>?</p>
|
<p>The simple answer is that if any sample has the maximum or minimum value (-32768 and +32767 respectively for 16 bit samples), you can consider it clipping. This isn't stricly true, since that value may actually be the correct value, but there is no way to tell whether +32767 really should have been +33000.</p>
<p>For a more complicated answer: There is such a thing as sample counting clipping detectors that require x consecutive samples to be at the max/min value for them to be considered clipping (where x may be as high as 7). The theory here is that clipping in just a few samples is not audible.</p>
<p>That said, there is audio equipment that clips quite audible even at values below the maximum (and above the minimum). Typical advice is to master music to peak at -0.3 dB instead of 0.0 dB for this reason. You might want to consider any sample above that level to be clipping. It all depends on what you need it for.</p>
|
<p>What Adam said. You could also add some logic to detect maximum amplitude values over a period of time and only flag those, but the essence is to determine if/when the signal hits the maximum amplitude.</p>
| 7,637
|
<p>Does anyone have a decent algorithm for calculating axis minima and maxima? </p>
<p>When creating a chart for a given set of data items, I'd like to be able to give the algorithm: </p>
<ul>
<li>the maximum (y) value in the set </li>
<li>the minimum (y) value in the set </li>
<li>the number of tick marks to appear on the axis </li>
<li>an optional value that <strong>must</strong> appear as a tick (e.g. zero when showing +ve and -ve values)</li>
</ul>
<p>The algorithm should return</p>
<ul>
<li>the largest axis value </li>
<li>the smallest axis value (although that could be inferred from the largest, the interval size and the number of ticks)</li>
<li>the interval size </li>
</ul>
<p>The ticks should be at a regular interval should be of a "reasonable" size (e.g. 1, 3, 5, possibly even 2.5, but not any more sig figs). </p>
<p>The presence of the optional value will skew this, but without that value the largest item should appear between the top two tick marks, the lowest value between the bottom two. </p>
<p>This is a language-agnostic question, but if there's a C#/.NET library around, that would be smashing ;) </p>
|
<p>OK, here's what I came up with for one of our applications. Note that it doesn't deal with the "optional value" scenario you mention, since our optional value is always 0, but it shouldn't be hard for you to modify.</p>
<p>Data is continually added to the series so we just keep the range of y values up to date by inspecting each data point as its added; this is very inexpensive and easy to keep track of. Equal minimum and maximum values are special cased: a spacing of 0 indicates that no markers should be drawn.</p>
<p>This solution isn't dissimilar to Andrew's suggestion above, except that it deals, in a slightly kludgy way with some arbitrary fractions of the exponent multiplier.</p>
<p>Lastly, this sample is in C#. Hope it helps.</p>
<pre><code> private float GetYMarkerSpacing()
{
YValueRange range = m_ScrollableCanvas.
TimelineCanvas.DataModel.CurrentYRange;
if ( range.RealMinimum == range.RealMaximum )
{
return 0;
}
float absolute = Math.Max(
Math.Abs( range.RealMinimum ),
Math.Abs( range.RealMaximum ) ),
spacing = 0;
for ( int power = 0; power < 39; ++power )
{
float temp = ( float ) Math.Pow( 10, power );
if ( temp <= absolute )
{
spacing = temp;
}
else if ( temp / 2 <= absolute )
{
spacing = temp / 2;
break;
}
else if ( temp / 2.5 <= absolute )
{
spacing = temp / 2.5F;
break;
}
else if ( temp / 4 <= absolute )
{
spacing = temp / 4;
break;
}
else if ( temp / 5 <= absolute )
{
spacing = temp / 5;
break;
}
else
{
break;
}
}
return spacing;
}
</code></pre>
|
<p>I can recommend the following:</p>
<ul>
<li>Set a visually appealing minimum number of major lines. This will depend on the nature of the data that you're presenting and the size of the plot you're doing, but 7 is a pretty good number</li>
<li>Choose the exponent and the multiplier based on a progression of 1, 2, 5, 10, etc. that will give you at least the minimum number of major lines. (ie. (max-min)/(scale x 10^exponent) >= minimum_tick_marks)</li>
<li>Find the minimum integer multiple of your exponent and multiplier that fits within your range. This will be the first major tick. The rest of the ticks are derived from this.</li>
</ul>
<p>This was used for an application that allowed arbitrary scaling of data an seemed to work well.</p>
| 7,487
|
<p>I was in the process of printing a 16 hour print, but I must have failed to copy the G-code correctly, because the print stopped after 107 of 223 layers. Looking at the G-code, It also stops there. </p>
<p>However, I had the full G-code on my computer, and decided to try and resume the print from layer 108. It seemed to work, with the exception of a little excess extrusion at a single point in the beginning, but after three layers, i noticed that it wasn't extruding anymore. I am not completely positive that it isn't due to nozzle jamming, but I have a strong feeling that the problem is the G-code itself, as it does extrude some plastic just before printing starts.</p>
<p>Here are the first lines of my manually edited G-code. Can anyone see why I get the blob in the beginning, or why I don't get anything at all later on? Or does it look good, and my problem is probably the nozzle? </p>
<pre><code>;FLAVOR:UltiGCode
;TIME:60308
;MATERIAL:119047
;MATERIAL2:0
;NOZZLE_DIAMETER:0.400000
;NOZZLE_DIAMETER2:0.400000
;MTYPE:PLA
;Layer count: 222
;LAYER:109
G0 F9000 X208.213 Y107.948 Z16.610
;TYPE:FILL
G1 F3600 X210.390 Y105.771 E4104.65185
G0 F9000 X210.390 Y103.170
G1 F3600 X168.331 Y61.111 E4107.77457
G0 F9000 X167.074 Y61.111
G1 F3600 X120.237 Y107.949 E4111.25208
G0 F9000 X121.695 Y107.949
G1 F3600 X74.857 Y61.111 E4114.72962
G0 F9000 X73.600 Y61.111
G1 F3600 X26.763 Y107.948 E4118.20709
</code></pre>
|
<p>According to the RepRap.org <a href="http://reprap.org/wiki/G-code" rel="nofollow noreferrer">list of G-Code commands</a>, see <strong><a href="http://reprap.org/wiki/G-code#G0_.26_G1:_Move" rel="nofollow noreferrer">G0 & G1: Move</a></strong>:</p>
<blockquote>
<p>The <code>Ennn</code> command is <em>The amount to extrude between the starting point and ending point</em>. </p>
</blockquote>
<p>However, according to <strike><a href="https://github.com/daid/Cura/issues/385" rel="nofollow noreferrer">this</a></strike> a discussion, that is now deleted from GitHub, about the Cura slicing engine:</p>
<p>The <strong>E</strong> values are in <em>absolute mode</em>, so perhaps the firmware is attempting to move the stepper motor to the absolute position (which is almost 50% through your print). This may lead to clogging or skipping depending on how hot your extruder is at that point.</p>
<p>As a last resort, you can perform a Boolean subtract on your model of the section that's already printed and re-slice the model to print the remaining bit. Then glue, or ABS weld, the remaining piece to the main print. I've done this in the past, it's not super glamorous, but it gets the job done if the part doesn't require a lot of structural integrity.</p>
<p><strong>I was incorrect with the following statements with regard to the Cura slicing engine:</strong> </p>
<p><s>It's been a while since I've looked at 3D printer G-Code, but from what I remember, <strong>E</strong> values can be the bane of any manually written G-Code. Usually the slicing engine generates the <strong>E</strong> value as an incremental step value throughout the G-Code (at least this was true for Skeinforge and early MakerWare, please verify this). So, if the value is incremental and depending on the controller, this value could be lost or corrupt if a new print is initialized.</p>
<p>I would hope, that if you're using a slicing engine's <em>custom G-Code</em> input, that the software would be able to compensate situations like this and reformat your provided G-Code to match the value of <strong>E</strong> or any similar command.</s></p>
|
<p>Is the hotend temperature set correctly? If you only preheat the hotend but then turn it off, it will behave exactly as you described (while you're above <code>EXTRUDE_MINTEMP</code> it will behave normally, but once the temperature drops too low it will continue doing the XYZ-moves, but stop extruding). Perhaps you need to add a <code>M109</code> command to set the temperature properly.</p>
<p><a href="https://3dprinting.stackexchange.com/questions/850/no-extrusion-when-trying-to-resume-failed-print-with-manually-edited-gcode/851#851">In his answer</a>, tbm0115 mentions absolute and relative coordinates. Whether absolute or relative coordinates are used is set using the <code>G90</code>/<code>G91</code> commands and will always be the same for all axes (XYZ and E). He also mentions that:</p>
<blockquote>
<p>so perhaps the firmware is attempting to move the stepper motor to the absolute position (which is almost 50% thru your print). This may lead to clogging or skipping depending on how hot your extruder is at that point.</p>
</blockquote>
<p>This shouldn't happen, as extremely long extrude moves are ignored by Marlin. When the printer encounters</p>
<pre><code>G1 F3600 X210.390 Y105.771 E4104.65185
</code></pre>
<p>it performs only the XYZ-part of the move, but doesn't move the extruder (assuming the printer was reset and the current extruder position is 0). However, it does update the internal value for the extruder position, so the next move happens normally. Perhaps missing the initial extrude segment isn't a big deal, but if you want the print to resume perfectly where you left off, you should add a <code>G92</code> command to the beginning to initialize the extruder position correctly, for example:</p>
<pre><code>G92 E4104.4
</code></pre>
<p>(but the exact value depends on the last extruder position in the previous layer).</p>
| 230
|
<p>I have a protocol that requires a length field up to 32-bits, and it must be
generated at runtime to describe how many bytes are in a given packet.</p>
<p>The code below is kind of ugly but I am wondering if this can be refactored to
be slightly more efficient or easily understandable. The problem is that the
code will only generate enough bytes to describe the length of the packet, so
less than 255 bytes = 1 byte of length, less than 65535 = 2 bytes of length
etc...</p>
<pre><code>{
extern char byte_stream[];
int bytes = offset_in_packet;
int n = length_of_packet;
/* Under 4 billion, so this can be represented in 32 bits. */
int t;
/* 32-bit number used for temporary storage. */
/* These are the bytes we will break up n into. */
unsigned char first, second, third, fourth;
t = n & 0xFF000000;
/* We have used AND to "mask out" the first byte of the number. */
/* The only bits which can be on in t are the first 8 bits. */
first = t >> 24;
if (t) {
printf("byte 1: 0x%02x\n",first );
byte_stream[bytes] = first; bytes++;
write_zeros = 1;
}
/* Now we shift t so that it is between 0 and 255. This is the first, highest byte of n. */
t = n & 0x00FF0000;
second = t >> 16;
if (t || write_zeros) {
printf("byte 2: 0x%02x\n", second );
byte_stream[bytes] = second; bytes++;
write_zeros = 1;
}
t = n & 0x0000FF00;
third = t >> 8;
if ( t || write_zeros) {
printf("byte 3: 0x%02x\n", third );
byte_stream[bytes] = third; bytes++;
write_zeros = 1;
}
t = n & 0x000000FF;
fourth = t;
if (t || write_zeros) {
printf("byte 4: 0x%02x\n", fourth);
byte_stream[bytes] = fourth; bytes++;
}
}
</code></pre>
|
<p>You should really use a fixed-width field for your length.</p>
<ul>
<li>When the program on the receiving end has to read the length field of your packet, how does it know where the length stops?</li>
<li>If the length of a packet can potentially reach 4 GB, does a 1-3 byte overhead really matter?</li>
<li>Do you see how complex your code has already become? </li>
</ul>
|
<p>Try this loop:</p>
<pre><code>{
extern char byte_stream[];
int bytes = offset_in_packet;
int n = length_of_packet; /* Under 4 billion, so this can be represented in 32 bits. */
int t; /* 32-bit number used for temporary storage. */
int i;
unsigned char curByte;
for (i = 0; i < 4; i++) {
t = n & (0xFF000000 >> (i * 16));
curByte = t >> (24 - (i * 8));
if (t || write_zeros) {
printf("byte %d: 0x%02x\n", i, curByte );
byte_stream[bytes] = curByte;
bytes++;
write_zeros = 1;
}
}
}
</code></pre>
| 5,538
|
<p>I was wondering; which logging libraries for Delphi do you prefer?</p>
<ul>
<li><a href="http://www.raize.com/devtools/codesite/" rel="noreferrer">CodeSite</a></li>
<li><a href="http://www.gurock.com/products/smartinspect/" rel="noreferrer">SmartInspect</a></li>
<li><a href="http://log4delphi.sourceforge.net/" rel="noreferrer">Log4Delphi</a></li>
<li><a href="http://tracetool.sourceforge.net/" rel="noreferrer">TraceFormat</a></li>
</ul>
<p>Please try to add a reasoning why you prefer one over the other if you've used more than one.</p>
<p>I'll add suggestions to this question to keep things readable.</p>
|
<p>I've used Codesite and it has been fantastic. On one project, a word-processor, I could easily output a million debug lines, all structured, and Codesite helped greatly with its auto-collapsing indented output. For any task where you have to know what really is happening "underneath" a process that can't be interrupted by user interaction, Codesite is really good. I recommend it heartily.</p>
|
<p>I am looking into Codesite as well. I built my own in the past but I really like the featrues in Codesite. The Raize componenets are very well written and always quality stuff.</p>
| 9,859
|
<p>How do I write code where a company icon appears on the left side next to the URL address in the browser's address bar?</p>
|
<p>You are looking for a <a href="https://stackoverflow.com/questions/6642/preferred-way-to-use-favicons#6645">Favicon</a>.</p>
|
<p>load a file on the webserver called <a href="https://stackoverflow.com/favicon.ico">favicon.ico</a></p>
| 3,135
|
<p>I have a collection of classes that inherit from an abstract class I created. I'd like to use the abstract class as a factory for creating instances of concrete implementations of my abstract class. </p>
<p>Is there any way to hide a constructor from all code except a parent class.</p>
<p>I'd like to do this basically</p>
<pre><code>public abstract class AbstractClass
{
public static AbstractClass MakeAbstractClass(string args)
{
if (args == "a")
return new ConcreteClassA();
if (args == "b")
return new ConcreteClassB();
}
}
public class ConcreteClassA : AbstractClass
{
}
public class ConcreteClassB : AbstractClass
{
}
</code></pre>
<p>But I want to prevent anyone from directly instantiating the 2 concrete classes. I want to ensure that only the MakeAbstractClass() method can instantiate the base classes. Is there any way to do this?</p>
<p><strong>UPDATE</strong><br>
I don't need to access any specific methods of ConcreteClassA or B from outside of the Abstract class. I only need the public methods my Abstract class provides. I don't really need to prevent the Concrete classes from being instantiated, I'm just trying to avoid it since they provide no new public interfaces, just different implementations of some very specific things internal to the abstract class.</p>
<p>To me, the simplest solution is to <a href="https://stackoverflow.com/questions/20185/is-there-a-way-to-make-a-constructor-only-visible-to-a-parent-class-in-c#20200">make child classes as samjudson mentioned</a>. I'd like to avoid this however since it would make my abstract class' file a lot bigger than I'd like it to be. I'd rather keep classes split out over a few files for organization.</p>
<p>I guess there's no easy solution to this...</p>
|
<p>You can make the sub classes child classes, something like this:</p>
<pre><code>public abstract class AbstractClass
{
public static AbstractClass MakeAbstractClass(string args)
{
if (args == "a")
return new ConcreteClassA();
if (args == "b")
return new ConcreteClassB();
}
private class ConcreteClassA : AbstractClass
{
}
private class ConcreteClassB : AbstractClass
{
}
}
</code></pre>
<p><a href="https://stackoverflow.com/questions/20185/is-there-a-way-to-make-a-constructor-only-visible-to-a-parent-class-in-c#20220">@Vaibhav</a> This does indeed mean that the classes are also hidden. But this is as far as I am aware the only way to completely hide the constructor.</p>
<p>Edit: As others have mentioned the same thing can be accomplished using Reflection, which might actually be closer to what you would like to be the case - for example the above method replies on the concrete classes being inside the same file as the Abstract class, which probably isn't very convenient. Having said that this way is a nice 'Hack', and good if the number and complexity of the concrete classes is low.</p>
|
<p>What you need to do is this to prevent the default constructor to be create. The internal can be change to public if the classes are not in the same assembly.</p>
<pre><code>public abstract class AbstractClass{
public static AbstractClass MakeAbstractClass(string args)
{
if (args == "a")
return ConcreteClassA().GetConcreteClassA();
if (args == "b")
return ConcreteClassB().GetConcreteClassB();
}
}
public class ConcreteClassA : AbstractClass
{
private ConcreteClassA(){}
internal static ConcreteClassA GetConcreteClassA(){
return ConcreteClassA();
}
}
public class ConcreteClassB : AbstractClass
{
private ConcreteClassB(){}
internal static ConcreteClassB Get ConcreteClassB(){
return ConcreteClassB();
}
}
</code></pre>
| 4,053
|
<p>I have built an MSI that I would like to deploy, and update frequently. Unfortunately, when you install the MSI, and then try to install a newer version of the same MSI, it fails with a message like "Another version of this product is already installed. Installation of this version cannot continue..." appears. The MSI was built with a Visual Studio 2008 Setup Project. I have tried setting the "Remove Previous Versions" property to both true and false, in an effort to just make newer versions overwrite the older install, but nothing has worked. At a previous company I know I did not have this problem with installers built by Wise and Advanced Installer. Is there a setting I am missing? Or is my desired functionality not supported by the VS 2008 Setup Project?</p>
|
<p>I have built numerous MSIs with VS 2005 Pro that do this correctly.</p>
<p>Are you sure that the 'Version' property of the <strong>deployment project</strong> has been incremented? This property is independent of the version of the assemblies in the application, and this is the error message you will see if the Version property of the MSI is the same as it was for the one you are trying to overwrite.</p>
|
<p>Had the same problem when going from XP to Win7. To solve it I had to set DetectNewerInstalledVersion to False. Also, as mentioned by others, you need to inc the version of the setup project.</p>
<p>Good luck.</p>
| 6,183
|
<p>Under FreeCAD, I sketched on the face of a solid as follows :</p>
<p><a href="https://i.stack.imgur.com/Qe4nu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qe4nu.png" alt="sketch"></a></p>
<p>My problem is, when I use "Pad a selected sketch", the solid created comprises also the original solid.</p>
<p><a href="https://i.stack.imgur.com/pHI59.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pHI59.png" alt="created solid"></a></p>
<p>It prevents me, for instance, to get the difference with the first one.</p>
<p>Any idea what may be causing this? How to prevent it?</p>
<p>MyFreeCAD config:</p>
<pre><code>OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
</code></pre>
|
<p>Ok, I got help on <a href="http://forum.freecadweb.org/viewtopic.php?f=3&t=19756" rel="nofollow noreferrer">this forum thread</a></p>
<p>Using <code>Part Extrude</code> instead of <code>Pad a selected sketch</code> on the sketch will create an independent solid.</p>
<p>It also turns out that, instead of creating the second solid to do a boolean difference, the good way to "cut" my solid is using the <code>PartDesign Pocket</code> tool.</p>
|
<p>If you just select the face, and pad the face (versus padding the solid), you should not have this problem. </p>
| 483
|
<p>I have a file that I want to include in Python but the included file is fairly long and it'd be much neater to be able to split them into several files but then I have to use several include statements.</p>
<p>Is there some way to group together several files and include them all at once?</p>
|
<ol>
<li>Put files in one folder. </li>
<li>Add __init__.py file to the folder. Do necessary imports in __init__.py</li>
<li><p>Replace multiple imports by one:</p>
<p>import folder_name </p></li>
</ol>
<p>See <a href="http://docs.python.org/tut/node8.html#SECTION008400000000000000000" rel="nofollow noreferrer">Python Package Management</a></p>
|
<p>Yes, take a look at the "6.4 Packages" section in <a href="http://docs.python.org/tut/node8.html" rel="nofollow noreferrer">http://docs.python.org/tut/node8.html</a>:</p>
<p>Basically, you can place a bunch of files into a directory and add an __init__.py file to the directory. If the directory is in your PYTHONPATH or sys.path, you can do "import directoryname" to import everything in the directory or "import directoryname.some_file_in_directory" to import a specific file that is in the directory.</p>
<blockquote>
<p>The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as "string", from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later. </p>
</blockquote>
| 7,641
|
<p>We have an existing C++ application that we are going to gradually replace with a new Java-based system. Until we have completely reimplemented everything in Java we expect the C++ and Java to have to communicate with each other (RMI, SOAP, messaging, etc - we haven't decided).</p>
<p>Now my manager thinks we'll need the Java and C++ sides to participate in the same Oracle DB transaction. This is related to, but different from the usual distrbuted transaction problem of having a single process co-ordinate 2 transactional resources, such as a DB and a message queue.</p>
<p>I think propagating a transaction across processes is a terrible idea from a performance and stability point-of-view, but I am still going to be asked for a solution.</p>
<p>I am familiar with XA transactions and I've done some work with the JBoss Transaction Manager, but my googling hasn't turned up anything good on propagating an XA transaction between 2 processes.</p>
<p>We are using Spring on the Java side and their documentation explicitly states they do not provide any help with transaction propagation.</p>
<p>We are not planning on using a traditional Java EE server (for example: IBM Websphere), which may have support for propagation (not that I can find any definitive documentation).</p>
<p>Any help or pointers on solutions is greatly appreciated.</p>
|
<p>There is <a href="http://laurentschneider.com/wordpress/2008/08/read-uncommitted.html" rel="noreferrer">an example on Laurent Schneider's blog</a> of using the DBMS_XA package inside Oracle to permit multiple sessions to work in the same transaction. So it would be possible to have Java and C++ sessions participating in the same transaction without needing any sort of additional coordinator. </p>
<p>Alternately, you might consider using Workspace Manager. That was originally designed to support extremely long-running transactions (i.e. manipulating lots of spatial data for a proposed development). Essentially, you can create a workspace, which in your case would be roughly equivalent to a named transaction. Both the Java and C++ code could enter that workspace (from separate sessions) and both could manipulate and commit data in that workspace. When the transaction was complete, you could then merge the workspace to the LIVE workspace, which is equivalent to doing a commit in a normal transaction.</p>
<p>On the other hand, I would strongly agree with your initial assessment that coordinating transactions between processes is very likely to be a bad idea from a performance, stability, simplicity, and maintenance standpoint. On the other hand, it may well be a legitimate business requirement depending on how the C++ code is going to be retired (i.e. whether it is possible to replace code in such a way that transactions can be either exclusively Java or exclusively C++)</p>
|
<p>I believe JBoss Transaction Manager supports 2pc tx propagation across web service calls. You could, I suppose integrate your systems that way, but the performance would stink.</p>
| 6,563
|
<p>I'd like to attach a piece I printed out of PLA to a small titanium rod. I've previously used Superglue (cyanoacrylate) to glue PLA pieces to each other with great success, but the problem is that if you don't apply it perfectly cleanly, it leaves very noticeable stains on the PLA.</p>
<p>Can anyone recommend a good glue for this application that won't leave stains like that? </p>
|
<p>I've been a fan of epoxies for unusual adhesion problems. I found on <a href="https://rads.stackoverflow.com/amzn/click/B000FW6322" rel="nofollow noreferrer">Amazon a product with titanium</a> in the name, but there's a caution regarding polypropylene plastics. </p>
<p><a href="https://i.stack.imgur.com/DfKGn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DfKGn.jpg" alt="titanium epoxy"></a></p>
<p>PLA is not of that family of plastic, which gives it a good chance of success. Epoxy is typically more viscous than cyanoacrylates, giving you a bit more control of the application, but also creating the need for care with "ooze-out."</p>
<p>The big glue company, Gorilla, also makes an <a href="https://rads.stackoverflow.com/amzn/click/B001Z3C3AG" rel="nofollow noreferrer">epoxy</a> that includes plastic and metal in the adhesion listing.</p>
<p><a href="https://i.stack.imgur.com/Y1OTc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y1OTc.jpg" alt="gorilla epoxy"></a></p>
<p>As PLA is somewhat sensitive to heat, one would consider that fast-cure epoxies generate more heat than slow-cure epoxy, but the amounts you'll be using are not likely to create enough for concern.</p>
|
<p>A glue gun would IMO work very well, and you can use transparent (or almost transparent) glue sticks to minimize ugly looking stains.</p>
<p>Things glued together usually break before the glue (in my experience) and it's cheap, you can get one for $10 with some glue sticks. It's fun too, I glue everything since I bought one :-)</p>
| 812
|
<p>I've encountered the term "multi-agent computing" as of late, and I don't quite get what it is. I've read a book about it, but that didn't answer the fundamental question of what an agent was.</p>
<p>Does someone out there have a pointer to some reference which is clear and concise and answers the question without a load of bullshit/marketing speak? I want to know if this is something I should familiarise myself, or whether it's some crap I can probably ignore, because I honestly can't tell.</p>
|
<p>A multi-agent system is a concept borrowed from AI. It's almost like a virtual world where you have agents that are able to observe, communicate, and react. To give an example, you might have a memory allocation agent that you have to ask for memory and it decides whether or not to give it to you. Or you might have an agent that monitors a web server and restarts it if it hangs. The main goal behind multiagent systems is to have a more Smalltalk-like communication system between different parts of the system in order to get everything to work together, as opposed to more top-down directives that come from a central program.</p>
|
<p>You can find a concentration of white papers concerning agents <a href="http://recursionsw.com/About_Us/wp_mobileagents.html" rel="nofollow noreferrer">here</a>.</p>
| 5,623
|
<p>I've been tasked with updating a series of applications which are performance critical VB.NET apps that essentially just monitor and return networking statistics. I've only got three requirements: <em>convert it to C#, make it fast, and make it stable</em></p>
<p>One caveat is that we <em>"may"</em> migrate from a .NET platform to linux <em>"soon"</em></p>
<p>I will be responsible for maintaining these apps in the future so I'd like to do this right. I have decided to refactor these apps according to the MVP pattern so that I can properly unit test the hell out of this bad boy. But I was also thinking since I was using MVP that I could also do the computationally expensive stuff in native C/C++ code while the GUI would be done with .NET forms, or Qt or whatever.</p>
<p>questions: </p>
<ol>
<li><p>does it make sense to do a GUI in winforms but the expensive stuff in native, unmanaged C/C++ ?</p></li>
<li><p>any recommendations for a good cross platform windowing kit that would fit for the scenario described above?</p></li>
</ol>
|
<p>First off, I would put some time into trying out a few <a href="http://www.google.com/search?q=VB.NET+to+C%23+converter&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a" rel="nofollow noreferrer">VB.NET to C# converters</a>. You're basically porting syntax, and there's no reason to do that by hand if you don't have to. Sure, you might have to clean up what comes out of the converter, but that's way better than a by-hand conversion.</p>
<p>Now, as for your questions:</p>
<blockquote>
<p>1) does it make sense to do a GUI in winforms but the expensive stuff in native, unmanaged C/C++ ?</p>
</blockquote>
<p>Not yet. Wait until you've done the conversion, and then find out where you're actually spending your time. There's no reason to jump into mixing C/C++ with C# until you find out that it's necessary. You may find that dropping into unsafe C# is sufficient. Even that may be unnecessary. You might just need to optimize algorithms. Find out what your bottlenecks are and <em>then</em> decide how to fix them.</p>
<blockquote>
<p>2) any recommendations for a good cross platform windowing kit that would fit for the scenario described above? </p>
</blockquote>
<p>I'd be looking into <a href="http://www.mono-project.com" rel="nofollow noreferrer">mono</a> for sure. That's really the best you can do if you're going with C#. It's pretty much either mono or another rewrite in another language when/if you move to Linux.</p>
|
<p><strong>I might be misunderstanding the issue</strong>, but if it is a network monitoring system, why isn't it written as a "dedicated" Windows service? </p>
<p>VB.NET shouldn't be much slower than C#. I'm not 100% certain if there is any big differences in the generated IL-code, but the only advantage (and justifiable reason to rewrite it in C#) I could think of (except that C# have a nicer syntax and some other goodies) is the use of unsafe code block that could speed things up a little.</p>
| 3,119
|
<p>Someone please correct me if I'm wrong, but parsing a yyyy/MM/dd (or other specific formats) dates in C# <strong>should</strong> be as easy as </p>
<pre><code>DateTime.ParseExact(theDate, "yyyy/MM/dd");
</code></pre>
<p>but no, C# forces you to create an IFormatProvider.</p>
<p>Is there an app.config friendly way of setting this so I don't need to do this each time?</p>
<pre><code>DateTime.ParseExact(theDate, "yyyy/MM/dd", new CultureInfo("en-CA", true));
</code></pre>
|
<p>The IFormatProvider argument can be null.</p>
|
<p>//Convert date to MySql compatible format</p>
<p>DateTime DateValue = Convert.ToDateTime(datetimepicker.text);</p>
<p>string datevalue = DateValue.ToString("yyyy-MM-dd");</p>
| 9,023
|
<p>Say I have three files (template_*.txt):</p>
<ul>
<li>template_x.txt</li>
<li>template_y.txt</li>
<li>template_z.txt</li>
</ul>
<p>I want to copy them to three new files (foo_*.txt). </p>
<ul>
<li>foo_x.txt </li>
<li>foo_y.txt </li>
<li>foo_z.txt</li>
</ul>
<p>Is there some simple way to do that with one command, e.g. </p>
<p><code>cp --enableAwesomeness template_*.txt foo_*.txt</code></p>
|
<pre>
for f in template_*.txt; do cp $f foo_${f#template_}; done
</pre>
|
<p>Yet another way to do it:</p>
<pre><code>$ ls template_*.txt | sed -e 's/^template\(.*\)$/cp template\1 foo\1/' | ksh -sx
</code></pre>
<p>I've always been impressed with the ImageMagick <a href="http://www.imagemagick.org/script/convert.php" rel="nofollow noreferrer">convert</a> program that does what you expect with image formats:</p>
<pre><code>$ convert rose.jpg rose.png
</code></pre>
<p>It has a sister program that allows batch conversions:</p>
<pre><code>$ mogrify -format png *.jpg
</code></pre>
<p>Obviously these are limited to image conversions, but they have interesting command line interfaces.</p>
| 4,598
|
<p>Background: At my company we are developing a bunch applications that are using the same core dll's. These dll's are using Spring.net's IoC-container to wire things up (auto-wiring). All applications are using the same spring configuration file, and this configuration file points to many classes in many different dll's. But not all application needs functionality from every dll. But because of the way IoC-containers works, all dll's is loaded for Spring.net to examine the types and check what interfaces they implement and so on.</p>
<p>Core question: I understand that it's better to just load the dll's you really use. But is it really bad for memory usage just to load a managed dll? Or is it first then you are using classes in the dll and they are getting JIT'ed that the most memory are used?</p>
|
<p>If none of the code from the assembly is ever used, then eventually the pages from that assembly will be moved from memory into the page file in favour of actively used pages. In which case, the overall long-term effect is likely to be minor. Although, there will be a negative effect on startup time.</p>
|
<p>of course loading dll's w/o using them causes slower startup time due to reading the assembly from disk and evidence/security checks. But if memory is your concern you at least can be sure, you won't waste more memory than the size of your assemblies if you really don't use any types within. Of course if those types are specified in the spring configuration, at least those types get loaded into memory and their static initializer (if any) will be executed. In rare cases this might be an issue. JITing is done on by the CLR on a per-method basis, so methods you do not use won't waste cpu+memory.</p>
<p>In any case you may split your configuration files into partitions e.g. by putting all object definitions of module A into file moduleA.config, all definitions of module B into file moduleB.config and specify only those modules for your particular application that are really needed.</p>
<p>hth,
Erich</p>
<p>P.S.: I'd also like to suggest you post Spring for .NET relevant questions to our <a href="http://forum.springframework.net/" rel="nofollow noreferrer">community forums</a> - it is more likely to get your questions answered there.</p>
| 9,550
|
<p>I'm asking this question purely from a usability <code>standpoint</code>!</p>
<p>Should a website <code>expand/stretch</code> to fill the viewing area when you resize a browser window?</p>
<p>I know for sure there are the obvious cons:</p>
<ul>
<li>Wide columns of text are hard to read.</li>
<li>Writing html/css using percents can be a pain.</li>
<li>It makes you vulnerable to having your design stretched past it's limits if an image is too wide, or a block of text is added that is too long. <strong>(see it's a pain to code the html/css</strong>).</li>
</ul>
<p>The only Pro I can think of is that users who use the font-resizing that is built into their browser won't have to deal with columns that are only a few words long, with a body of <code>white-space</code> on either side.</p>
<p>However, I think that may be a browser problem more than anything else (Firefox 3 allows you to zoom <strong>everything</strong> instead of just the text, which comes in handy all the time)</p>
<p><strong>edit</strong>: I noticed stack overflow is fixed width, but coding horror resizes. It seems Jeff doesn't have a strong preference either way.</p>
|
<p>Raw HTML does just that. Are you changing your data so that it doesn't render so good in random sized windows?</p>
<p>In the olden days, everyone had VGA screens. Now, that resolution is most uncommon. Who knows what resolutions are going to be common in the future? And why expect a certain minimum width or height?</p>
<p>From a usability viewpoint, demanding a certain resolution from your users is just going to create a degraded experience for anyone not using that resolution. Another thing that comes from this is what <em>is</em> fixed width? I've seen plenty of fixed size windows (popups) that just don't render right because my fonts are different from the designer's.</p>
|
<p>Paragraph widths larger than your display make a web site completely unusable. You have to jiggle the horizontal scrollbar back and forth for every single line you read. I'm doing a web design subject at university and the textbook calls the designs which adapt to your screen width <i>fluid layout</i>.<p>
I'm designing my big class project using fluid layout, it's a bit more trouble than fixed width. I suspect none of the other students will use it, the markers won't notice and none of the professional sites we're imitating are fluid either.</p>
| 4,700
|
<p>I'm trying to compile over 100 java classes from different packages from a clean
directory (no incremental compiles) using the following ant tasks:</p>
<pre><code><target name="-main-src-depend">
<depend srcdir="${src.dir}"
destdir="${bin.dir}"
cache="${cache.dir}"
closure="true"/>
</target>
<target name="compile" depends="-main-src-depend"
description="Compiles the project.">
<echo>Compiling</echo>
<javac target="${javac.target}"
source="${javac.source}"
debug="${javac.debug}"
srcdir="${src.dir}"
destdir="${bin.dir}">
<classpath>
<path refid="runtime.classpath"/>
<path refid="compile.classpath"/>
</classpath>
</javac>
</target>
</code></pre>
<p>However, the first time I run the compile task I always get a StackOverflowException. If I run the task again the compiler does an incremental build and everything works fine. This is undesirable since we are using <a href="http://cruisecontrol.sourceforge.net/" rel="noreferrer">CruiseControl</a> to do an automatic daily build and this is causing false build failures.</p>
<p>As a quick-and-dirty solution I have created 2 separate tasks, compiling portions of the project in each. I really don't think this solution will hold as more classes are added in the future, and I don't want to be adding new compile tasks every time we hit the "compile limit".</p>
|
<blockquote>
<p>It will be nice to know; what can
cause or causes a StackOverflowError
during compilation of Java code?</p>
</blockquote>
<p>It is probable that evaluating the long expression in your java file consumes lots of memory and because this is being done in conjunction with the compilation of other classes, the VM just runs out of stack space. Your generated class is perhaps pushing the legal limits for its contents. See chapter <a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#88659" rel="nofollow noreferrer">4.10 Limitations of the Java Virtual Machine</a> in <a href="http://java.sun.com/docs/books/jvms/" rel="nofollow noreferrer">The Java Virtual Machine Specification, Second Edition</a>.</p>
<p><strong>Fix 1: refactor the class</strong></p>
<p>Since your class is being generated, this might not be an option. Still, it is worth looking at the options your class generation tool offers to see if it can produce something less troublesome.</p>
<p><strong>Fix 2: increase the stack size</strong></p>
<p>I think <a href="https://stackoverflow.com/questions/16935/ants-javac-tasks-throws-stackoverflowexception#16982">Kieron</a> has one solution when he mentions the -Xss argument. <a href="http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html" rel="nofollow noreferrer">javac</a> takes a number of non-standard arguments that will vary between versions and compiler vendors.</p>
<p>My compiler:</p>
<pre><code>$ javac -version
javac 1.6.0_05
</code></pre>
<p>To list all the options for it, I'd use these commands:</p>
<pre><code>javac -help
javac -X
javac -J-X
</code></pre>
<p>I <em>think</em> the stack limit for javac is 512Kb by default. You can increase the stack size for this compiler to 10Mb with this command:</p>
<pre><code>javac -J-Xss10M Foo.java
</code></pre>
<p>You might be able to pass this in an Ant file with a <em>compilerarg</em> element nested in your <em>javac</em> task.</p>
<pre><code><javac srcdir="gen" destdir="gen-bin" debug="on" fork="true">
<compilerarg value="-J-Xss10M" />
</javac>
</code></pre>
|
<p>That's quite odd, 100 classes really isn't that many. What is the compiler doing when the stack overflows? Is there a useful stack trace generated? What happens if you run <code>javac</code> directly on the command line instead of thorugh ant?</p>
<p>One possible workaround is to simply increase the size of the stack using the <code>-Xss</code> argument to the JVM; either to the JVM running <code>ant</code> or by setting <code>fork="true"</code> and a <code><compilerarg></code> on the <code><javac></code> task. Actually now that I think of it, does the problem go away just putting in the <code>fork="true"</code>?</p>
| 3,762
|
<p>How can I insert compilation timestamp information into an executable I build with Visual C++ 2005? I want to be able to output something like this when I execute the program:</p>
<blockquote>
<p>This build XXXX was compiled at dd-mm-yy, hh:mm.</p>
</blockquote>
<p>where date and time reflect the time when the project was built. They should not change with each successive call of the program, unless it's recompiled.</p>
|
<p>Though not your exact format, <strong>DATE</strong> will be of the format Mmm dd yyyy, while <strong>TIME</strong> will be of the format hh:mm:ss. You can create a string like this and use it in whatever print routine makes sense for you:</p>
<pre><code>const char *buildString = "This build XXXX was compiled at " __DATE__ ", " __TIME__ ".";
</code></pre>
<p>(Note on another answer: <strong>TIMESTAMP</strong> only spits out the modification date/time of the source file, not the build date/time.)</p>
|
<p>Visual C++ also supports <code>__TIMESTAMP__</code> which is almost exactly what you need. That being said, the tough part about build timestamps is keeping them up to date, that means compiling the file in which <code>__TIMESTAMP__</code> is used on every rebuild. Not sure if there's a way to set this up in Visual C++ though.</p>
| 4,537
|
<p>Being new to 3D printing, I started using Cura (which came with my Ender 3v2) to slice models I found on Thingiverse. I know that there are other slicers and have heard positive things about PrusaSlicer.</p>
<p>I know that settings will have different names, but I am asking more about the setup. What things, settings, etc. should I be aware of when using PrusaSlicer? Will I need to re-calibrate anything in PrusaSlicer?</p>
|
<p>Basically all slicers work very similarly, it is a matter of preference, being accustomed, or wanting to use a certain (set of) features. Their job is to prepare the object to be sliced in layers to be executed by the printer you use. For every slicer to work properly, you need to configure the printer settings correctly.</p>
<p>Basically, all slicers have the following basic settings:</p>
<ul>
<li>Printer settings,<br> <em>these contain information on the printer like build volume, origin, heated bed, nr. of extruders (and what filament diameter is used), scripts, etc.</em></li>
<li>filament settings,<br><em>these contain e.g. information on the print and bed temperature</em></li>
<li>print settings<br><em>these contain all parameters you use in your normally used slicer, these can be hundreds of options like speeds, accelerations, layer height, nr. of walls, etc.</em>
<ul>
<li>some of the movement profile settings (like acceleration, jerk, max-speed) might be handled as a <em>printer</em> setting by some slicers and as a <em>print</em> one by different slicers. In the end, some of these are dependant on the printer's construction.</li>
</ul>
</li>
</ul>
<p>Printer dimensions and layout, filament diameter, and start and end G-code scripts are the things to look for. The rest is straightforward, you need to specify material and object slice settings as you would normally do.</p>
|
<p>PrusaSlicer already has pre-tuned profiles for the Ender 3 v2 in the Configuration Assistant. It also has tuned print settings from SUPERDETAIL (0.08 mm layer height) to SUPERDRAFT (0.28 mm layer height) so it shouldn't be too hard to set up.</p>
| 1,897
|
<p>I'm looking to 3D print a structure that won't deform in high heat, up to about 220 °C. The filament itself can be 3D printed all the way up to about 380 °C. </p>
<p>PEI seems like it could be a viable option. I found some <a href="https://www.matterhackers.com/store/l/3dxtech-thermax-pei-175mm-05kg/sk/MHCFSNUC?rcode=GAT9HR&gclid=CjwKCAjwqZPrBRBnEiwAmNJsNsqaaSEcWYtaTv1rIwDKuWgI9xCyinqDgV7bYUUO3zX7-pIA0gDPSBoCclYQAvD_BwE" rel="nofollow noreferrer">here</a>. This PEI filament specifies the glass transition temperature at 217 °C.</p>
<p>Would this filament work? Are there any other types of materials that would fulfill this engineering requirement?</p>
|
<p>Your expected operating temperature exceeds the glass transition temperature by 3 °C. This implies that the structure will become weak and can deform under load. </p>
<p>Note that you cannot simply print PEI on a normal machine, it requires a special high temperature capable printer with hot end temperatures up to 400 °C and heated bed over 120 °C up to 160 °C, furthermore it will need a heated chamber (up to about 80 °C) which requires special care to cooling and placement of electronics and motors.</p>
<p>Not having specified what kind of structure you require, you could look into steel.</p>
|
<p>An easier but less simple solution might be to make a PLA 'pattern' that is the right size and shape, then use that to cast your item in aluminium (melting point ~ 660C) using the 'investment' or 'lost PLA' process.<br>
Links:-
<a href="https://www.instructables.com/id/3D-Printed-Lost-PLA-Investment-Casting-Aluminium/" rel="nofollow noreferrer">https://www.instructables.com/id/3D-Printed-Lost-PLA-Investment-Casting-Aluminium/</a>
<div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/qxj5eUkAFUI?start=0"></iframe>
</div></div></p>
| 1,449
|
<p>A Monoprice Maker Select V2, upgraded incrementally with a <a href="https://store.micro-swiss.com/products/all-metal-hotend-with-slotted-cooling-block-for-wanhao-i3" rel="nofollow noreferrer">Micro Swiss all metal hot-end</a>, machined lever, and <a href="https://www.wanhaouk.com/products/extruder-drive-gear" rel="nofollow noreferrer">D4 extruder gear</a>, systematically fails to produce complete prints, as seen below:</p>
<p><a href="https://i.stack.imgur.com/fQC1C.png" rel="nofollow noreferrer" title="Incomplete prints"><img src="https://i.stack.imgur.com/fQC1C.png" alt="Incomplete prints" title="Incomplete prints"></a></p>
<p>The following observations can be made.</p>
<ul>
<li><p>The nozzle clog appears at different heights/elapsed times, so it does not seem to be because of heat creep, which ought to take the same time to take effect, each time.</p></li>
<li><p>All the clogs so far have been easy to clear manually, once the hotend has been made accessible.</p></li>
<li><p>The filament (1.75 mm PLA) is quite new, has only been sitting on the spool at the top of the printer, seems regular in density, is not visibly damaged etc.</p></li>
<li><p>In the original configuration, before the upgrading, the printer worked fine for some months.</p></li>
</ul>
<p>One possible explanation might be inconsistent temperature in the extruder, but the display does not show any great variation.</p>
<p>Any other theories? These latest prints were made at 210 °C.</p>
<hr>
<p>The nozzle clogging was verified, each time, by trying to extrude using the printer controls; and then cleaned manually by taking off the "cold end" part, heating the extruder, and pressing the remaining filament out by hand.</p>
<p>Not so long ago the nozzle was cleaned with ethyl acetate and a needle, so I do not believe carbon build-up is the explanation.</p>
<p>Cura settings:</p>
<p><a href="https://i.stack.imgur.com/0b6Tz.png" rel="nofollow noreferrer" title="Cura settings"><img src="https://i.stack.imgur.com/0b6Tz.png" alt="Cura settings" title="Cura settings"></a></p>
|
<p>The Micro Swiss hotend uses an all metal hotend. These type of hotends are more difficult to operate considering they do not have a Teflon liner that shields the filament from heat exchange from the cold end (the Teflon/PTFE tube acts as an insulator). From <a href="https://www.proto-pasta.com/blogs/how-to/avoid-clogs-with-pla-composites-and-all-metal-hotends" rel="nofollow noreferrer">this article</a>:</p>
<blockquote>
<p>Jams and clogs are often from a combination of excessive heat and
non-optimal material flow. This effect is worsened by poorly cooled
<strong>all-metal hot ends, high torque extruder gears</strong>, small nozzles/layers,
slow printing speeds, too thin first layer, and excessive retraction.</p>
</blockquote>
<p>The bold faced text in the quote sums up what is causing this. A smaller gear requires more force/torque as the arm i.e. the radius is smaller.</p>
<p>The article describes what steps you could do to alleviate the problem. Of all the suggestions, <em>"<strong>Minimize retraction</strong>"</em>, seems a possible candidate for you to look into considering the posted print settings. As this is a heat related problem it is advised to also <em><strong>increase your printing speeds</strong></em>, these are pretty low (30 mm/s for slow and 60 mm/s for normal printing) and also <em><strong>check the cooling of the "cold end"</strong></em> (the fan that cools the radiator fins). Also <em><strong>reduce the printing temperature</strong></em>, 210 °C is pretty high for PLA filament, personally I don't go over 200 °C (note that this depends on your filament, but most PLA brands can be printed in the 185 - 195 °C range).</p>
<p>You have a pretty large retraction specified. The Ultimaker default is 6.5 mm is considered to be large, but works perfectly for Ultimaker machines (read Bowden tube setup). In my Ultimaker 3E which uses all metal hotends, or, in my custom HyperCube Evolution, also Bowden, but with a lined hotend, 6.5 mm retraction works perfectly.</p>
<p>Please look into <a href="https://3dprinting.stackexchange.com/a/2632/5740">this answer</a> and <a href="https://3dprinting.stackexchange.com/a/2622/5740">this answer</a>. Both describe that the retraction performance is worse with all metal hotends. My experiences are exactly the same with metal hotends, at least the cheaper production ones (I tested cheap all metal hotends, but also ran into problems because of production and design errors, I have not tried the better quality heat breaks/throats yet).</p>
<p>Please lower the retraction setting considerably to see if it has an effect. The Monoprice Maker Select uses a direct drive. Direct drive extruders do not need a large retraction length setting. If the filament is hot in the throat (as there is no PTFE lining that in fact acts as an insulator), too large of a retraction may not be reversed when the filament cooles during the retraction.</p>
<hr />
<p>I think you might be experiencing what is described in <a href="https://3dprinting.stackexchange.com/q/5968/5740">this question</a>: "<em>Extruder prints fine up until further down the print</em>". <a href="https://3dprinting.stackexchange.com/a/6469/5740">This answer</a> describes issues of the metal heat breaks.</p>
<p>To comment on your statement in comments above, I am not suggesting you should use a liner in your current extruder. I'm pointing out the differences. Metal hotends are just more tricky to operate regarding retraction and heat management.</p>
|
<p>The Micro Swiss hotend uses an all metal hotend. These type of hotends are more difficult to operate considering they do not have a Teflon liner that shields the filament from heat exchange from the cold end (the Teflon/PTFE tube acts as an insulator). From <a href="https://www.proto-pasta.com/blogs/how-to/avoid-clogs-with-pla-composites-and-all-metal-hotends" rel="nofollow noreferrer">this article</a>:</p>
<blockquote>
<p>Jams and clogs are often from a combination of excessive heat and
non-optimal material flow. This effect is worsened by poorly cooled
<strong>all-metal hot ends, high torque extruder gears</strong>, small nozzles/layers,
slow printing speeds, too thin first layer, and excessive retraction.</p>
</blockquote>
<p>The bold faced text in the quote sums up what is causing this. A smaller gear requires more force/torque as the arm i.e. the radius is smaller.</p>
<p>The article describes what steps you could do to alleviate the problem. Of all the suggestions, <em>"<strong>Minimize retraction</strong>"</em>, seems a possible candidate for you to look into considering the posted print settings. As this is a heat related problem it is advised to also <em><strong>increase your printing speeds</strong></em>, these are pretty low (30 mm/s for slow and 60 mm/s for normal printing) and also <em><strong>check the cooling of the "cold end"</strong></em> (the fan that cools the radiator fins). Also <em><strong>reduce the printing temperature</strong></em>, 210 °C is pretty high for PLA filament, personally I don't go over 200 °C (note that this depends on your filament, but most PLA brands can be printed in the 185 - 195 °C range).</p>
<p>You have a pretty large retraction specified. The Ultimaker default is 6.5 mm is considered to be large, but works perfectly for Ultimaker machines (read Bowden tube setup). In my Ultimaker 3E which uses all metal hotends, or, in my custom HyperCube Evolution, also Bowden, but with a lined hotend, 6.5 mm retraction works perfectly.</p>
<p>Please look into <a href="https://3dprinting.stackexchange.com/a/2632/5740">this answer</a> and <a href="https://3dprinting.stackexchange.com/a/2622/5740">this answer</a>. Both describe that the retraction performance is worse with all metal hotends. My experiences are exactly the same with metal hotends, at least the cheaper production ones (I tested cheap all metal hotends, but also ran into problems because of production and design errors, I have not tried the better quality heat breaks/throats yet).</p>
<p>Please lower the retraction setting considerably to see if it has an effect. The Monoprice Maker Select uses a direct drive. Direct drive extruders do not need a large retraction length setting. If the filament is hot in the throat (as there is no PTFE lining that in fact acts as an insulator), too large of a retraction may not be reversed when the filament cooles during the retraction.</p>
<hr />
<p>I think you might be experiencing what is described in <a href="https://3dprinting.stackexchange.com/q/5968/5740">this question</a>: "<em>Extruder prints fine up until further down the print</em>". <a href="https://3dprinting.stackexchange.com/a/6469/5740">This answer</a> describes issues of the metal heat breaks.</p>
<p>To comment on your statement in comments above, I am not suggesting you should use a liner in your current extruder. I'm pointing out the differences. Metal hotends are just more tricky to operate regarding retraction and heat management.</p>
| 1,062
|
<p>I want to point a file dialog at a particular folder in the current user's Local Settings folder on Windows. What is the shortcut to get this path?</p>
|
<p>How about this, for example:</p>
<pre><code>String appData =
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
</code></pre>
<p>I don't see an enum for just the Local Settings folder.</p>
<p><a href="http://web.archive.org/web/20080303235606/http://dotnetjunkies.com/WebLog/nenoloje/archive/2007/07/07/259223.aspx" rel="noreferrer">http://web.archive.org/web/20080303235606/http://dotnetjunkies.com/WebLog/nenoloje/archive/2007/07/07/259223.aspx</a> has a list with examples.</p>
|
<p>Environment.GetFolderPath( Environment.SpecialFolders.LocalApplicationData);?</p>
<p>I can't remember if there is a "Local Settings" folder on Windows XP anymore, it seems vaguely familiar.</p>
| 8,154
|
<p>Does anyone have any suggestions on how to mentor a junior programmer ? If you have mentored someone did you follow any process or was it quite informal ?</p>
<p>If you've been mentored in the past what kind of things did you find most helpful ?</p>
|
<p>Try to set aside between 30-60 minutes a day to review their code together. If you can't do this, then try to get together to review their code whenever they make a code commit, unless it was very basic. Have them explain why they chose the approach they took in lieu of others. A process like this helps to establish a great relationship, as well as really stimulate the student to think on their own and be able to defend their decisions. Not only does the student end up with someone approachable whom they can trust, but you'll notice an improvement in their quality of code and logic almost immediately. </p>
<p><strong>Edit</strong>: Also, If you are unable to commit this much time to co-review with your junior, then you probably shouldn't be mentoring them and instead see if anyone else has a schedule that would allow it. The whole point of mentoring is to actively aid in the professional development of the student, and they're not going to learn much if proper attention and guidance is not given to them. </p>
|
<p>I have mentored several junior people under me before. My approach varied slightly based on the person a bit based on how they learned. </p>
<p>In short, I gave the junior people small, self-contained projects when I could and gave them a relatively fixed time to complete the task. Once the task was complete I would review their approach, code and solution and made suggestions for improvements or a better way to handle the problem. I think this way they don't feel overwhelmed being part of a much larger project.</p>
<p>Hope this helps a bit.</p>
| 4,471
|
<p>In one of my applications I have a 1gb database table that is used for reference data. It has a huge amounts of reads coming off that table but there are no writes ever. I was wondering if there's any way that data could be loaded into RAM so that it doesn't have to be accessed from disk?</p>
<p>I'm using SQL Server 2005</p>
|
<p>If you have enough RAM, SQL will do an outstanding job determining what to load into RAM and what to seek on disk. </p>
<p>This question is asked a lot and it reminds me of people trying to manually set which "core" their process will run on -- let the OS (or in this case the DB) do what it was designed for.</p>
<p>If you want to verify that SQL is in fact reading your look-up data out of cache, then you can initiate a load test and use Sysinternals <a href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" rel="nofollow noreferrer">FileMon</a>, <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">Process Explorer</a> and <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">Process Monitor</a> to verify that the 1GB table is not being read from. For this reason, we sometimes put our "lookup" data onto a separate filegroup so that it is very easy to monitor when it is being accessed on disk.</p>
<p>Hope this helps.</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/ms178015(SQL.90).aspx" rel="nofollow noreferrer">DBCC PINTABLE</a> will explicitly pin a table in core if you want to make sure it remains cached.</p>
| 6,454
|
<p>My recently installed BLTouch probe regularly fails to perform ABL properly. There seem to be 3-4 failure modes:</p>
<ol>
<li>Probe manages some points but fails partway through, with a "probing failed" message on the LCD screen, rendering it necessary to power-cycle the printer</li>
<li>Probe deploys on some point, then stows itself immediately, and treats that point as being a centimeter or two about where it actually is. </li>
<li>Probe completes all 9 points, then heats the nozzle in the back corner and never moves. The progress bar on the LCD counts up and eventually it claims to have finished the print, but the steppers (including the extruder) never move.</li>
<li><p>Probe flashes red throughout the cycle, which I believe means it failed a self-test probably because the mainboard started trying to speak to it before it was initialized, but occasionally when this occurs, it still works as expected.</p>
<p>For avoidance of doubt - sometimes it actually does work, and I get beautiful prints that adhere well during printing but are easily removed afterwards. And I have never had any issues with the Z homing using the probe, only the auto mesh levelling.</p></li>
</ol>
<p>My setup:</p>
<ul>
<li>Creality Ender 3</li>
<li>v1.1.4 mainboard with non-silent steppers</li>
<li>genuine BLTouch v3, with official Creality pin27 kit</li>
<li>Marlin 1.1.9 bugfix firmware, downloaded as hex file </li>
<li>single iteration of probing</li>
<li>9 point levelling mesh</li>
<li>Ultimaker Cura slicer 4.2.0</li>
<li>Start G-code heats bed, homes <code>G28</code>, performs ABL <code>G29</code>, then heats nozzle (I don't have the actual G-code on my now as I'm away from my slicing computer)</li>
</ul>
<p>[Related question: <a href="https://3dprinting.stackexchange.com/questions/10345/bl-touch-probing-fails-intermittently">BL Touch Probing Fails Intermittently</a> but answers do not apply as I am already using bugfix firmware and have checked all the cabling and connections]</p>
|
<p>So it turns out there are elements from each of the previous answers that make sense here, but its not a clear picture. I've spent a whole lot of time trying to make sense of this. I also upgraded my firmware to <a href="https://www.thingiverse.com/thing:32084" rel="nofollow noreferrer">Sailfish.</a> </p>
<p>For the MakerBot Replicator (or FastForge Creator) family of 3d printers, the origin of the build plate is NOT at any of the corners, its right in the center of the build plate. Reference <a href="https://www.sailfishfirmware.com/doc/parameters-home-offsets.html#x20-630004.1" rel="nofollow noreferrer">here.</a> </p>
<blockquote>
<p>4.1 Home Offsets:<br>
By convention, <strong>the center of the build platform</strong> is assumed to be the point (0,0,0) in XYZ space. The X, Y, and Z <strong>home offsets</strong> tell the printer the location of the X, Y, and Z <strong>endstops</strong> in relation to the build platform’s center.</p>
</blockquote>
<p>Looks like this:</p>
<p><a href="https://i.stack.imgur.com/c2YlJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c2YlJ.png" alt="Center of build plate is origin"></a></p>
<p>And it would appear that most other 3D printers are not using this convention. Sigh. From my testing, the main control of print location is within the G-Code generated by the slicer. The tool I was using, Slic3r does give one a chance to correct that
adjustment. You have to go to top menu <code>Settings --> Printer Settings --> Size and Coordinates (Bed Shape) --> Set</code> to get a nice popup visual tool. See below.</p>
<p>Unfortunately the default setting is accurate for the overall bed size, but is a fail for the origin location on the bed. The default origin is set at 0,0, in the corner. Ouch. Big ouch. The origin needs to be located right in the center of the build plate (to be consistent with the firmware controlling the print for this family of printers). It <strong>should</strong> look like this:</p>
<p><a href="https://i.stack.imgur.com/iXV61.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iXV61.png" alt="print bed origin setup"></a></p>
<p>Note, when you tell the printer to go to 'home' it doesn't go to origin (0,0,0) it goes to the endstops. </p>
<pre><code> G68 X0 Y0 F500 ; Perform Homing Routine
</code></pre>
<p>So as long as you understand the quirks of these printers things will work out. You have to ensure offsets are set accurately in firmware config files. (Replicator / Sailfish) And you have to indicate the correct center location to the slicer program. I will say the advice given here was of some help in understanding this. Many thanks. I'm posting here in case others using the Replicator or FastForge Creator series of printers is having troubles centering their prints on the build plate. </p>
<p>Additional info for anybody using a MakerBot Replicator or Flashforge Creator series printer with Slic3r. I wanted to add my custom G-code stuff. The default Slic3r stuff definitely did not work. </p>
<p>Printer Settings --> Custom G-Code --> Start G-Code</p>
<pre><code>M103 ; Turn all extruders off, Extruder Retraction
G21 ; set units to mm
G90 ; Use absolute coordinates
(**** begin homing ****)
G162 X Y F2500 ; home XY axes to maximum stops
G161 Z F1100 ; home Z axis to minimum stop
G92 Z-5 ; Set Position Z =-5mm
G1 Z0.0 ; move Z to "0"
G161 Z F100 ; home Z axis to minimum stop slowly
M132 X Y Z A B ; Recall stored home offsets for XYZAB axis
; Loads the axis offset of the current home position from the EEPROM and waits for the buffer to empty.
G90 ; Use absolute coordinates
G1 X0 Y0 Z50 F3300.0 ; move to waiting position near center of build plate
</code></pre>
<p>Printer Settings --> Custom G-Code --> End G-Code</p>
<pre><code>M109 S0 T0 ; Cool down the build platform
M104 S0 T0 ; Cool down the Right Extruder
M104 S0 T1 ; Cool down the Left Extruder
M73 P100 ; End build progress
G0 Z150 ; Send Z axis to bottom of machine
M18 ; Disable steppers
G162 X Y F2500 ; Home XY endstops
M18 ; Disable stepper motors
M70 P30 ; We <3 Making Things! Yipee, you made it...
; display message above for 30 seconds
M72 P1 ; Play Ta-Da song
</code></pre>
<p>One other thing I do with Slic3r. I print a single loop of print on the periphery of a phantom skirt. I do this as a printer head clean extrude exercise. </p>
<p>Print Settings --> Skirt and Brim --> Skirt --> Loops (minimum): 1, Distance from object: 6mm, Skirt height: 1 This works well. I do this in lieu of the G-code startup used in ReplicatorG software (which went to the lower left hand corner, and did this odd 4mm extrude exercise, with odd timing...) The skirt thing works just fine. </p>
|
<p>It sounds like you have "Origin at center" checked in your slicer's printer definition. That is generally only used with delta printers. Most Cartesian printers have the origin at the front-left corner of the build plate. Uncheck "Origin at center" and re-slice.</p>
<p>Providing that you have set up your slicer with the build plate dimensions and origin correctly defined, your models will be printed where the slicer shows them in the preview. You can rearrange the models before you slice, of course.</p>
| 1,496
|
<p>I had my printer printing fine when using the stock trigger switch as I used it to print the green bracket you see in the picture. </p>
<p><a href="https://i.stack.imgur.com/6kxYw.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/6kxYw.jpg" alt="Photo of probe atached to hotend"></a></p>
<p>My problem now is when I do a print with the sensor, it moves to 0,0 position. However in this position the sensor is hanging off the bed hence there is nothing for it detect so it crashes into the bed.</p>
<p>As far as I can tell the nozzle is homing in the right place.</p>
<p>How do I tell Marlin the new minimum position it needs to be in so it doesn't crash into the bed?</p>
|
<p>If using <code>marlin firmware</code> center your prints.</p>
<p>In my case...</p>
<pre><code>#define NOZZLE_X 8
#define NOZZLE_Y -56
</code></pre>
<p>Then, set the Z-Probe offset from nozzle.
In my case the Z-Probe is 50mm behind the hotend.</p>
<pre><code>#define SENSOR_LEFT 0
#define SENSOR_RIGHT 0
#define SENSOR_FRONT 0
#define SENSOR_BEHIND 50
</code></pre>
<p>Finally set the bed extra movement. As you see i added the 50mm's at the back of the bed.</p>
<pre><code>#define XTRA_BED_LEFT 0 // Distance nozzle can move towards the left past X = 0
#define XTRA_BED_RIGHT 0 // Distance nozzle can move towards the right past X = 200
#define XTRA_BED_FRONT 0 // Distance bed can move towards the front past Y = 200 (Y=280 for large bed)
#define XTRA_BED_BACK 50 // Distance bed can move towards the back past Y = 0
</code></pre>
<p>This way once auto leveling, the probe starts with (0,0) and the hotend is 50 mm's in front and out of the bed. </p>
|
<p>There are at least 2 options to address the problem that you have:</p>
<ol>
<li>Adjust end-stops so that in 0,0 position Z-sensor would still hang above the printing table. This would reduce printing surface but allow perfect calibration</li>
<li>Mount extra metal plate at the table mount where it would not bump into printer parts and remain reachable for the sensor (perhaps with sensor relocation) when positioned at 0,0. This option requires extra space within table movement boundaries but saves printing surface.</li>
</ol>
| 421
|
<p>Is it possible for gcc to link against a library that was created with Visual C++? If so, are there any conflicts/problems that might arise from doing so? </p>
|
<p>Some of the comments in the answers here are slightly too generalistic. </p>
<p>Whilst no, in the specific case mentioned gcc binaries won't link with a VC++ library (AFAIK). The actual means of interlinking code/libraries is a question of the ABI standard being used.</p>
<p>An increasingly common standard in the embedded world is the EABI (or ARM ABI) standard (based on work done during Itanium development <a href="http://www.codesourcery.com/cxx-abi/" rel="nofollow noreferrer">http://www.codesourcery.com/cxx-abi/</a>). If compilers are EABI compliant they can produce executables and libraries which will work with each other. An example of multiple toolchains working together is ARM's RVCT compiler which produces binaries which will work with GCC ARM ABI binaries.</p>
<p>(The code sourcery link is down at the moment but can be google cached)</p>
|
<p>I would guess not. Usually c++ compilers have quite different methods of name-mangling which means that the linkers will fail to find the correct symbols. This is a good thing by the way, because C++ compilers are allowed by the standard to have much greater levels of incompatibility than just this that will cause your program to crash, die, eat puppies and smear paint all over the wall.</p>
<p>Usual schemes to work around this usually involve language independent techniques like COM or CORBA. A simpler sanctified method is to use C "wrappers" around your C++ code.</p>
| 6,476
|
<p>I've been looking for some good genetic programming examples for C#. Anyone knows of good online/book resources? Wonder if there is a C# library out there for Evolutionary/Genetic programming?</p>
|
<p>After developing <a href="http://code.google.com/p/evo-lisa-clone/" rel="noreferrer">my own Genetic Programming didactic application</a>, I found a complete Genetic Programming Framework called <a href="http://code.google.com/p/aforge/source/browse/#svn/trunk/Sources/Genetic" rel="noreferrer">AForge.NET Genetics</a>. It's a part of the <a href="http://code.google.com/p/aforge/" rel="noreferrer">Aforge.NET library</a>. It's licensed under LGPL.</p>
|
<p>I maintain a port of ECJ in C#. It's great.</p>
| 3,488
|
<p><a href="http://www.nasa.gov/mission_pages/station/research/experiments/1115.html">This article</a> states that 3D printing has been accomplished in outer space, on the International Space Station.</p>
<p>I'm curious as to how this works differently from 3D printing on Earth. Are there any extra measures that needed to be taken to ensure that the filament would be correctly extruded onto the print bed, or during other steps?</p>
|
<p>Most likely, the 3D-printers used on ISS does not incorporate some fundamental difference that allow them to print in zero gravity.</p>
<p>Some people over at <a href="http://3dprint.com/62797/3d-printing-upside-down/" rel="noreferrer">3Dprint.com</a> raised a very similar question, and figured that when turning their 3D-printer upside down and on it's side:</p>
<blockquote>
<p>there’s not really much difference at all. It’s quite interesting to see how the orientation has little effect on the quality.</p>
</blockquote>
<p>One of the early 3D-printer models - the <a href="http://bukito3d.com/" rel="noreferrer">Bukito</a> printer - demonstrated that their printer was so portable it even could print on the move, and <a href="https://www.youtube.com/watch?v=ePU4EEM3JEI" rel="noreferrer">upside down</a>.</p>
<p>In other words, some consumer 3D printers already print upside down, and so they would probably print in zero gravity as well!</p>
<p><em>(That's the short story anyway. Have a look at Ryan's post, who gives a great description of the more intricate parts of space printing!)</em> </p>
|
<p>To answer your question, you have to consider how the melted filament sticks to the print bed and to other layers, and if gravity has any affect on how it sticks. The answer is that gravity does <em>not</em> have any real affect on the stick-to-itivity of the filament. Instead, the plastic bonds to the print bed surface, and then subsequent layers fuse with the previous layer. Nor does gravity have any affect on how the filament is fed or how the belts and gears move. Certain filament roll holders may not be able to be used if they do not clamp the roll down, and the printer also needs to be clamped down. But, perhaps surprisingly, there isn't really anything else that needs to be done differently to make a printer work in space.</p>
| 151
|
<p>This is printing PETG extruding at 250 °C, 1st layer bed at 80 °C then 60 °C on other layers. Nozzle is 0.4 mm; printer is German Reprap X400. The all metal extruder is clean with no oozing. The print gets a blob when the wall width changes from 2 mm to 1 mm. The extruder squishes the blob out the sides of the wall with subsequent layers. Images below show both sides of wall. I'm looking for the cause to come up with a fix. I consistently get the same results in the same location when printing this file. The reduced area of the layer does cause reduced speed to increase the print time for the layer (speed reduced when layer would print in less than 30 seconds; minimum speed 15 mm/s).</p>
<p>When I printed two, there was only one blob on one of two. Below shows the speed settings. The perimeters are three vertical shells, so the walls are all perimeters. My understanding of the setting is the 2 mm wall printed at 20 mm/s and the 1 mm wall at 15 mm/s.</p>
<p>Printing similarly with 2 mm walls only and the same settings, the print is nearly perfect with only a few stringers. Printing with only 1 mm walls does not have the blob, but does have stringers.</p>
<p>See solution at the end.</p>
<p></p>
<p><a href="https://i.stack.imgur.com/T0WBA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T0WBA.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/xDyNO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xDyNO.jpg" alt="enter image description here" /></a></p>
<p><strong>Solution:</strong></p>
<p>Speeding up the print speeds and using thicker walls not only eliminated the blogs, but also completely eliminated stringers, and gave a near perfect print. Apparently, the actual temperature that PETG extrudes is highly dependent on how fast it extrudes. Printing too fast clogs the nozzle because the filament doesn't have time to melt. Printing too slow causes the hotend to stop extruding from heat creep. Here, the actual temperature of the extruded PETG was decreased by speeding up the extrusion.</p>
<p><a href="https://i.stack.imgur.com/7STxh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7STxh.png" alt="enter image description here" /></a>s://i.stack.imgur.com/Uhv61.png</p>
|
<p>If you use a build surface such as PEI, acetone frosts your surface, leaving a white film appearance. If you have no additional surface on a glass or metal bed, it is incomplete cleaning. If incomplete cleaning, you could try isopropyl alcohol (IPA) immediately after acetone, followed immediately by a water based cleaner or DI/distilled water. (IPA dissolves acetone and water dissolves IPA. Once the film dries the next step may not work.)</p>
<p>You can't clean off a frosted surface. The black surface of the hot bed in images of the CR-10S Pro appears to indicate that the steel bed has a build surface with a plastic material such as PEI. Reviews of the build surface being difficult to remove prints also implies a plastic build surface on the steel. Thus, it appears that the white film after cleaning with acetone is actually a frosted surface.</p>
<p>If you use an Elmer's washable glue stick or one with PWP, it will form a barrier between your print and the build surface, that not only will protect your build surface, but will make it easier to clean your build surface with IPA or water based cleaners.</p>
|
<p>If you use a build surface such as PEI, acetone frosts your surface, leaving a white film appearance. If you have no additional surface on a glass or metal bed, it is incomplete cleaning. If incomplete cleaning, you could try isopropyl alcohol (IPA) immediately after acetone, followed immediately by a water based cleaner or DI/distilled water. (IPA dissolves acetone and water dissolves IPA. Once the film dries the next step may not work.)</p>
<p>You can't clean off a frosted surface. The black surface of the hot bed in images of the CR-10S Pro appears to indicate that the steel bed has a build surface with a plastic material such as PEI. Reviews of the build surface being difficult to remove prints also implies a plastic build surface on the steel. Thus, it appears that the white film after cleaning with acetone is actually a frosted surface.</p>
<p>If you use an Elmer's washable glue stick or one with PWP, it will form a barrier between your print and the build surface, that not only will protect your build surface, but will make it easier to clean your build surface with IPA or water based cleaners.</p>
| 1,870
|
<p>I have a project which is source controlled using Subversion and VisualSVN. Since the version of web.config is different on the server and the developers' computers I want the file to remain on the computers but to be ignored by Subversion. I added it to the svn:ignore but it still remains (and still has a red exclamation mark too since we are not committing it).</p>
<p>How can I remove it from Subversion safely without it being deleted from the files system</p>
<p>Thanks,
Adin</p>
|
<p>you'll have to do both the remove and ignore operation</p>
<ul>
<li>first make a backup of your local file (like @ibz said)</li>
<li>then remove the web.config from the repository.</li>
<li>then copy back the web.config to the same folder</li>
<li>finally use svn:ignore so that subversion does not try to add it again to the repository</li>
</ul>
<p>since i use tortoisesvn i can't really tell you what svn commands you have to use, but using tortoisesvn it would be:</p>
<ul>
<li>make backup</li>
<li>right click on web.config on the folder under source control, select TortoiseSVN | Delete</li>
<li>right click on web.config on the folder under source control, select SVN Commit => after this you will notice that the file is actually deleted from the file system</li>
<li>move up and right click on the folder under source control, select TortoiseSVN | Properties</li>
<li>on the properties window click new + property name "svn:ignore"; property value "web.config". accept changes</li>
<li>commit changes</li>
</ul>
<p>on my .net projects i include the following exclusion with svn:ignore: bin, obj, *.suo, *.user</p>
|
<p>I have solved this issue using nant with ccnet. Following nant build script replaces web.test.config file with local web.config file;</p>
<pre><code><?xml version="1.0"?>
<project name="Project1" default="build">
<target name="init" depends="clean" />
<target name="clean" />
<target name="checkout"/>
<target name="compile"/>
<target name="deploy"/>
<target name="test"/>
<target name="inspect"/>
<target name="build" depends="init, checkout">
<call target="compile" />
<call target="inspect" />
<call target="test" />
<call target="deploy" />
</target>
<copy file="..\TestDeployments\Project1\Project1.Solution\Project1.Web.UI\web.Test.config"
tofile="..\TestDeployments\Project1\Project1.Solution\Project1.Web.UI\web.config"
overwrite="true"
/>
<delete file="..\TestDeployments\Project1\Project1.Solution\Project1.Web.UI\web.Test.config" />
</project>
</code></pre>
<p><a href="http://nant.sourceforge.net/release/latest/help/tasks/copy.html" rel="nofollow noreferrer">NAnt Copy Task</a></p>
| 7,999
|
<p>One of the biggest issues currently holding me back from diving full steam into unit testing is that a really large percentage of the code I write is heavily dependent on third-party COM objects from different sources that also tend to interact with each other (I'm writing add-ins for Microsoft Office using several helper libraries if you need to know).</p>
<p>I know I should probably use mock objects but how exactly would I go about that in this case? I can see that it's relatively easy when I just have to pass a reference to an already existing object but some of my routines instantiate external COM objects themselves and then sometimes pass them on to some other external COM-object from yet a different library.</p>
<p>What is the best-practice approach here? Should I have my testing code temporarily change the COM registration information in the registry so the tested code will instantiate one of my mock objects instead? Should I inject modified type library units? What other approaches are there?</p>
<p>I would be especially grateful for examples or tools for Delphi but would be just as happy with more general advice and higher-level explanations just as well.</p>
<p>Thanks,</p>
<p>Oliver</p>
|
<p>The traditional approach says that your client code should use a wrapper, which is responsible for instantiating the COM object. This wrapper can then be easily mocked.</p>
<p>Because you've got parts of your code instantiating the COM objects directly, this doesn't really fit. If you can change that code, you could use the factory pattern: they use the factory to create the COM object. You can mock the factory to return alternative objects.</p>
<p>Whether the object is accessed via a wrapper or via the original COM interface is up to you. If you choose to mock the COM interface, remember to instrument IUnknown::QueryInterface in your mock, so you know that you've mocked all of the interfaces, particularly if the object is then passed to some other COM object.</p>
<p>Alternatively, check out the <a href="http://msdn.microsoft.com/en-us/library/ms693452.aspx" rel="nofollow noreferrer">CoTreateAsClass</a> method. I've never used it, but it might do what you need.</p>
|
<p>It comes down to 'designing for testability'. Ideally, you should not instantiate those COM objects directly but should access them through a layer of indirection that can be replaced by a mock object.</p>
<p>Now, COM itself does provide a level of indirection and you could provide a mock object that provided a substitute for the real one but I suspect it would be a pain to create and I doubt if you'd get much help from an existing mocking framework.</p>
| 9,588
|
<p>I'm using my printer for some baby toys. My last print was one of those <a href="https://www.thingiverse.com/thing:3556006/files" rel="nofollow noreferrer">pillars for stacking rings</a>, base 5. The basic format includes a base and a pillar coming up perpendicularly in the middle. A box with a cylinder sticking out of it.</p>
<p>Settings:</p>
<ul>
<li>0.3 mm layers,</li>
<li>5 layers of base/bottom/shell,</li>
<li>20 % gyroid infill,</li>
<li>PLA,</li>
<li>80 mm/s,</li>
<li>210 °C, bed at 60 °C.</li>
</ul>
<p>Three hours of printing later, I took it out of the printer, it feels <em>really</em> solid, all the surfaces are rigid, no compression or anything.</p>
<p>I hand it to my kid, she drops it and the pillar just detaches along the Z layer seam at the base.</p>
<p>Is there anything I can do, either model or printing-wise to reinforce it, aside from printing it horizontally with a bunch of supports?</p>
<p><a href="https://i.stack.imgur.com/MefU6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MefU6.jpg" alt="The broken Part" /></a></p>
|
<p>So you are printing at 80 mm/s speed * 0.3 mm layer height * something about 0.5 mm line width, which is about 12 mm<sup>3</sup>/s which is likely too much for many printers.</p>
<p>Try keeping linear speed at 60 mm/s and, if you have a 0.4 mm nozzle, never go above 0.24 mm layer thickness if you care about strength.</p>
<p>That will likely solve your problem.</p>
<p>If you want to go further, try to print <a href="https://www.thingiverse.com/thing:35088" rel="nofollow noreferrer">this test piece</a> at 210-220-230 °C (if you notice the walls are not nice anymore, increase cooling). Change ONLY the temperature.</p>
<p>Try then to break them and see which one is the strongest. PLA can be quite strong but not at 210 °C, it's too low. I can tell you that you will likely need 220-225 °C to squeeze every possible strength from PLA.</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/mwS_2R2mIvo?start=0"></iframe>
</div></div></p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/M3bwJx8ZkMA?start=0"></iframe>
</div></div></p>
|
<p>If you don't object to using adhesive to assemble the model, consider that you can succeed with your objective by performing a plane cut in the vertical direction. This allows you to print the model in the strongest orientation without supports. It will also result in an internal set of faces due to duplication of (as-printed) bottom surfaces in the best orientation.</p>
<p>For plane cuts, Meshmixer (free) and Fusion 360 (hobbyist version, free) as well as other programs, will allow you to chop the part directly in half and export the individual pieces. I'm unfamiliar with the software for your printer, but it may also have the ability to cut a model in this manner.</p>
| 2,096
|
<p>Any ideas how to display a PDF file in a WPF Windows Application? </p>
<hr>
<p>I am using the following code to run the browser but the <code>Browser.Navigate</code> method does not do anything!</p>
<pre><code>WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
this.AddChild(browser); // this is the System.Windows.Window
</code></pre>
|
<p>You could simply host a Web Browser control on the form and use it to open the PDF.</p>
<p>There's a new native WPF "WebBrowser" control in .NET 3.51, or you could host the Windows.Forms browser in your WPF app.</p>
|
<p>Check this out: <a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">http://itextsharp.sourceforge.net/</a>
You may have to use a WindowsFormsHost, but since it is open source, you might be able to make it a little more elegant in WPF.</p>
| 7,879
|
<p>Does anyone know how to print a barcode to the Intermec PB20 bluetooth printer from a Windows Compact Framework application? We are currently using the Intermec LinePrinter API but have been unable to find a way to print a barcode.
</p>
|
<p>Thank you all for your thoughts. Printing directly to the serial port is likely the most flexible method. In this case we didn't want to replicate all of the work that was already built into the Intermec dll for handling the port, printer errors, etc. We were able to get this working by sending the printer the appropriate codes to switch it into a different mode and then pass direct printer commands that way.</p>
<p>Here was our solution in case anyone else happens to encounter a similar issue working with Intermec Printers. The following code is a test case that doesn't catch printer errors and retry, etc. (See Intermec code examples.)</p>
<pre><code>Intermec.Print.LinePrinter lp;
int escapeCharacter = int.Parse("1b", NumberStyles.HexNumber);
char[] toEzPrintMode = new char[] { Convert.ToChar(num2), 'E', 'Z' };
lp = new Intermec.Print.LinePrinter("Printer_Config.XML", "PrinterPB20_40COL");
lp.Open();
lp.Write(charArray2); //switch to ez print mode
string testBarcode = "{PRINT:@75,10:PD417,YDIM 6,XDIM 2,COLUMNS 2, SECURITY 3|ABCDEFGHIJKL|}";
lp.Write(testBarcode);
lp.Write("{LP}"); //switch from ez print mode back to line printer mode
lp.NewLine();
lp.Write("Test"); //verify line printer mode is working
</code></pre>
<p>There is a technical document on Intermec's support site called the "Technical Manual" that describes the code for directly controlling the printer. The section about Easy Print describes how to print a variety of barcodes.</p>
|
<p>Last time I had to print Barcode (despite the printer or framework) I resorted to use a True Type font with the Barcode I needed. (In my case was EAN-13 something), an european barcode.</p>
<p>There are fonts where you simply write numbers (and/or letters when supported) and you get a perfect barcode any scanner can read :)</p>
<p>Google is your friend. I don't know if there are free ones.</p>
| 4,590
|
<p>I've just finished building a new printer and I wanted to take advantage of a 32 bits board I ordered some time ago. The board is an MKS SBase 1.3</p>
<p>I've been researching the Smoothiware firmware but somehow I'm not convinced by it yet. One of the things pulling me off is the Z-Probe behavior. On my Arduino-Marlin 1.1.8 machine, I have a probe which serves as both probe and Z-Endstop without a problem and very elegant implemented whereas on Smoothie, it's not so trivial as far as I've seen.</p>
<p>Anyway, there is a branch of Marlin which is not yet for release but for testing and it supports 32 bits boards, being mine mentioned above one of them: </p>
<p><a href="https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.0.x" rel="noreferrer">https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.0.x</a></p>
<p>I have yet to find some documentation explaining how to install it. The closest thing I found is a thread on their GitHub "forum":</p>
<p><a href="https://github.com/MarlinFirmware/Marlin/issues/8131" rel="noreferrer">https://github.com/MarlinFirmware/Marlin/issues/8131</a></p>
<p>It seems that you have to build the project to create a firmware.bin file which you can copy to the microSD card and it will flash automatically to the board... again, no "official" documentation found.</p>
<p>I've tried the steps described in this thread but I'm not able to compile for my board as it gives an error no matter what:</p>
<pre><code>Marlin/src/gcode/eeprom/M500-M504.cpp:74:5: error: no matching function for call to 'MarlinSettings::report(bool, int16_t&)'
</code></pre>
<p>Has somebody successfully compiled this firmware? Is there something I might be doing wrong?</p>
<p>I'm on a macOS machine, using Atom as editor with the Platformio-IDE installed.</p>
<p>Any help is appreciated,
Thanks in advance!</p>
|
<p>So, low-teck, old-style investigative work from my side.... I contacted <a href="http://www.filright.com" rel="nofollow noreferrer">a company</a> selling HDPLA and they got back to me with the following reply.</p>
<blockquote>
<p>We created HDPLA as an industrial PLA with special additives. As a result, our so called HDPLA has the advantages of ABS, but prints as easy as regular PLA. HDPLA has high impact, high strength and high heat deflection temperature (hdt). You can also print at high speed (max 140mm/s inhouse tests). HDPLA has is own high strength, but is even more strong after annealing. A heated bed is not necessary (50-60˚C recommended), and you can print with HDPLA with a 3D printer with open structure.</p>
</blockquote>
<p>This is strikingly similar to the <a href="https://www.3dprima.com/filaments/primaselect-pla-pro-1-75mm-750-g-black/a-22432/" rel="nofollow noreferrer">description of what 3Dprima calls "Prima SELECT PRO"</a>:</p>
<blockquote>
<p>PrimaSelect™ PLA PRO ist the next generation of high performance PLA for demanding industrial applications. Designed to be able to print fast >120mm/s so you can save on production time. Very high heat resistance (95°C+) after annealing. Excellent mechanical properties combined with a matte surface finish that helps concealing the printed layers for optimum appearance.</p>
</blockquote>
<p>While writing this answer I also found <a href="http://fiberlogy.com/en/fiberlogy-filaments/filament-hd-pla/" rel="nofollow noreferrer">a page</a> that escaped my googling until now, sating an additional property of "their" HDPLA: food safety.</p>
<blockquote>
<p>With our HD PLA you have many more options. You can use this material in two ways. Choose the one you like best. You can use it as a normal PLA and get prints characterized by a very good adhesion between the layers and high precision. You can also make your prints acquire similar properties to that of ABS – better impact resistance and high temperature resistance. All you need is an oven. Yes, an oven! By annealing our HD PLA in an oven, in accordance with the manual, you will avoid all the inconveniences of printing with ABS, such as unpleasant odour or hazardous fumes. But these are not all the advantages of HD PLA. For the production of this material we have chosen raw materials that are approved for food contact in compliance with the EU directive and FDA regulations. HD PLA is also certified by RoHS.</p>
</blockquote>
<p>So, it looks like HDPLA is not the shorthand of a polymer molecule, but rather <strong>a trade word indicating that the base PLA has been mixed with additives</strong>. Furthermore, the answer I got via mail seems to indicate that <strong>"HD" refers to the high <em>Heat Deflection</em> temperature</strong> of the filament (the <a href="https://en.wikipedia.org/wiki/Heat_deflection_temperature" rel="nofollow noreferrer">heat deflection temperature</a> is the temperature at which a polymer or plastic sample deforms under a specified load).</p>
|
<p>I doubt that it means very much at all. Filament manufacturers are very tight-lipped about the co-polymers that they add to their base stock in order to improve handling and performance characteristics, so it is impossible to say. The only common attribute that I can see is an advertised diameter tolerance of ±0.02mm. Maybe HD stands for <em>high-definition</em>, rather than <em>high-density</em>?</p>
| 791
|
<p>What libraries exist for other programming languages to provide an Erlang-style concurrency model (processes, mailboxes, pattern-matching receive, etc.)?</p>
<p>Note: I am specifically interested in things that are intended to be similar to Erlang, not just any threading or queueing library.</p>
|
<p>Message Passing Interface (MPI) (<a href="http://www-unix.mcs.anl.gov/mpi/" rel="noreferrer">http://www-unix.mcs.anl.gov/mpi/</a>) is a highly scalable and robust library for parallel programming, geared original towards C but now available in several flavors <a href="http://en.wikipedia.org/wiki/Message_Passing_Interface#Implementations" rel="noreferrer">http://en.wikipedia.org/wiki/Message_Passing_Interface#Implementations</a>. While the library doesn't introduce new syntax, it provides a communication protocol to orchestrate the sharing of data between routines which are parallelizable.</p>
<p>Traditionally, it is used in large cluster computing rather than on a single system for concurrency, although multi-core systems can certainly take advantage of this library.</p>
<p>Another interesting solution to the problem of parallel programming is OpenMP, which is an attempt to provide a portable extension on various platforms to provide hints to the compiler about what sections of code are easily parallelizable.</p>
<p>For example (<a href="http://en.wikipedia.org/wiki/OpenMP#Work-sharing_constructs" rel="noreferrer">http://en.wikipedia.org/wiki/OpenMP#Work-sharing_constructs</a>):</p>
<pre><code>#define N 100000
int main(int argc, char *argv[])
{
int i, a[N];
#pragma omp parallel for
for (i=0;i<N;i++)
a[i]= 2*i;
return 0;
}
</code></pre>
<p>There are advantages and disadvantages to both, of course, but the former has proven to be extremely successful in academia and other heavy scientific computing applications. YMMV.</p>
|
<p>For python you can try using <a href="http://pyprocessing.berlios.de/" rel="nofollow noreferrer">processing module</a>.</p>
| 4,219
|
<p>I am printing this piece using a 0.4 mm nozzle. It happens that the piece on the chin does not print properly.</p>
<p>I have already tried the tree mode supports, touching the plate and in all the places but the same thing happens.</p>
<p>I include photos of my configuration in Cura.</p>
<p><a href="https://i.stack.imgur.com/rXeqU.jpg" rel="nofollow noreferrer" title="Photo of print"><img src="https://i.stack.imgur.com/rXeqU.jpg" alt="Photo of print" title="Photo of print" /></a></p>
<p><a href="https://i.stack.imgur.com/Y5jNA.jpg" rel="nofollow noreferrer" title="Photo of bad print quality"><img src="https://i.stack.imgur.com/Y5jNA.jpg" alt="Photo of bad print quality" title="Photo of bad print quality" /></a></p>
<blockquote>
<p><a href="https://i.stack.imgur.com/0zNft.png" rel="nofollow noreferrer" title="Settings - quality"><img src="https://i.stack.imgur.com/0zNft.png" alt="Settings - quality" title="Settings - quality" /></a></p>
</blockquote>
<blockquote>
<p><a href="https://i.stack.imgur.com/x0WTX.png" rel="nofollow noreferrer" title="Settings - speed"><img src="https://i.stack.imgur.com/x0WTX.png" alt="Settings - speed" title="Settings - speed" /></a></p>
</blockquote>
<blockquote>
<p><a href="https://i.stack.imgur.com/lM79D.png" rel="nofollow noreferrer" title="Settings - support"><img src="https://i.stack.imgur.com/lM79D.png" alt="Settings - support" title="Settings - support" /></a></p>
</blockquote>
<p><a href="https://i.stack.imgur.com/VyQY3.png" rel="nofollow noreferrer" title="Screenshot of Cura - showing supports"><img src="https://i.stack.imgur.com/VyQY3.png" alt="Screenshot of Cura - showing supports" title="Screenshot of Cura - showing supports" /></a></p>
|
<p>I see that you have a minimum support angle of 60 degrees -- that may mean Cura Slicer isn't generating supports for that chin. Try changing this minimum to a lower figure -- 51 degrees or lower. From what I've read, most filaments and settings will allow 60 degrees with PLA, but this is the easy first thing to try to get that chin supported.</p>
<p>On looking at the photo again, I also wonder if what looks like a bad overhang print is actually supports that didn't separate as they should -- perhaps you only need to adjust your Z skip for supports to get them to come off the actual part better.</p>
<p>Following up, I saw a likely cause for this on one of my own prints yesterday -- coincidentally on the chin of a sculpture part. What I observed is that supports for this region, which trailed up the body (as would those for your dragon's chin), likely due to their slenderness, repeatedly got knocked over. The support structure "healed" over several layers after each such incident, but in a very fragile condition that would again get knocked off by a nozzle brush. The solution to this is either to enable Z-hop on retraction (so travel doesn't brush the nozzle across supports printed in the same layer), or to reorient the part so the problem support is shorter and doesn't run right alongside the actual body wall. Z-hop has less effect on other areas of the print.</p>
|
<p>You need to zoom in on the layers where the support is being generated and check if there is actually support being generated under that area.</p>
<p>Additionally, I noticed your support generation setting is "Touching build plate only". You should change this setting to 'everywhere' because it could be that build plate support cannot directly reach the area in question (so a portion of it is residing over an already printed surface). With this setting changed though, double check the rest of your print is not generating unecesssary supports, and if it is, use support blocker feature to get rid of them.</p>
<p>And as a last thought, after changing the setting i mentioned above, also play around with overhang angle and carefully observe how the rendering of the support structures changes (like, really zoom in those gaps and check).</p>
| 1,957
|
<p>What frameworks exist to unit test Objective-C code? I would like a framework that integrates nicely with Apple Xcode.</p>
|
<p>Xcode includes XCTest, which is similar to <a href="http://www.sente.ch/software/ocunit/" rel="noreferrer">OCUnit</a>, an Objective-C unit testing framework, and has full support for running XCTest-based unit tests as part of your project's build process. Xcode's unit testing support is described in the <a href="https://developer.apple.com/library/ios/documentation/ToolsLanguages/Conceptual/Xcode_Overview/UnitTesting.html" rel="noreferrer">Xcode Overview: Using Unit Tests</a>.</p>
<p>Back in the Xcode 2 days, I wrote a series of weblog posts about how to perform some common tasks with Xcode unit testing:</p>
<ul>
<li><a href="http://eschatologist.net/blog/?p=18" rel="noreferrer">Unit testing Cocoa frameworks</a></li>
<li><a href="http://eschatologist.net/blog/?p=20" rel="noreferrer">Debugging Cocoa framework unit tests</a></li>
<li><a href="http://eschatologist.net/blog/?p=24" rel="noreferrer">Unit testing Cocoa applications</a></li>
<li><a href="http://eschatologist.net/blog/?p=26" rel="noreferrer">Debugging Cocoa application unit tests</a></li>
</ul>
<p>Despite using OCUnit rather than XCTest, the concepts are largely the same.</p>
<p>Finally, I also wrote a few posts on how to write tests for Cocoa user interfaces; the way Cocoa is structured makes it relatively straightforward, because you don't have to spin an event loop or anything like that in most cases.</p>
<ul>
<li><a href="http://eschatologist.net/blog/?p=16" rel="noreferrer">Trust, but verify.</a></li>
<li><a href="http://eschatologist.net/blog/?p=10" rel="noreferrer">Unit testing Cocoa user interfaces: Target-Action</a></li>
<li><a href="http://eschatologist.net/blog/?p=12" rel="noreferrer">Unit testing Cocoa user interfaces: Cocoa Bindings</a></li>
</ul>
<p>This makes it possible to do test-driven development for not just your model-level code but also your controller-level and even view-level code.</p>
|
<p>I hope u can use 'SenTestKit', from which u can test each and every method. </p>
| 5,320
|
<p>I'm need to find a method to programmatically determine which disk drive Windows is using to boot. In other words, I need a way from Windows to determine which drive the BIOS is using to boot the whole system. </p>
<p>Does Windows expose an interface to discover this? With how big the Windows API is, I'm hoping there is something buried in there that might do the trick.</p>
<p>Terry</p>
<p>p.s. Just reading the first sectors of the hard disk isn't reveling anything. On my dev box I have two hard disks, and when I look at the contents of the first couple of sectors on either of the hard disks I have a standard boiler plate MBR.</p>
<p>Edit to clarify a few things.
The way I want to identify the device is with a string which will identify a physical disk drive (as opposed to a logical disk drive). Physical disk drives are of the form "\\.\PHYSICALDRIVEx" where x is a number. On the other hand, a logical drive is identified by a string of the form, "\\.\x" where x is a drive letter.</p>
<p>Edit to discuss a few of the ideas that were thrown out.
Knowing which logical volume Windows used to boot doesn't help me here. Here is the reason. Assume that C: is using a mirrored RAID setup. Now, that means we have at least two physical drives. Now, I get the mapping from Logical Drive to Physical Drive and I discover that there are two physical drives used by that volume. Which one did Windows use to boot? Of course, this is assuming that the physical drive Windows used to boot is the same physical drive that contains the MBR. </p>
|
<ol>
<li>Go into <code>Control Panel</code></li>
<li><code>System and Security</code></li>
<li><code>Administrative Tools</code></li>
<li>Launch the <code>System Configuration</code> tool</li>
</ol>
<p>If you have multiple copies of Windows installed, the one you are booted with will be named such as:</p>
<pre><code>Windows 7 (F:\Windows)
Windows 7 (C:\Windows) : Current OS, Default OS
</code></pre>
|
<p>You can try use simple command line. <a href="https://technet.microsoft.com/en-us/library/cc709667%28v=ws.10%29.aspx" rel="nofollow">bcdedit</a> is what you need, just run cmd as administrator and type <code>bcdedit</code> or <code>bcdedit \v</code>, this doesn't work on XP, but hope it is not an issue.</p>
<p>Anyway for XP you can take a look into <code>boot.ini</code> file.</p>
| 6,155
|
<p>I have a few lines of PowerShell code that I would like to use as an automated script. The way I would like it to be able to work is to be able to call it using one of the following options:</p>
<ol>
<li>One command line that opens PowerShell, executes script and closes PowerShell (this would be used for a global build-routine)</li>
<li>A file that I can double-click to run the above (I would use this method when manually testing components of my build process)</li>
</ol>
<p>I have been going through PowerShell documentation online, and although I can find lots of scripts, I have been unable to find instructions on how to do what I need. Thanks for the help.</p>
|
<p>Save your script as a .ps1 file and launch it using powershell.exe, like this:</p>
<pre><code>powershell.exe .\foo.ps1
</code></pre>
<p>Make sure you specify the full path to the script, and make sure you have set your execution policy level to at least "RemoteSigned" so that unsigned local scripts can be run.</p>
|
<p>you can use this command :
powershell.exe -argument c:\scriptPath\Script.ps1</p>
| 4,931
|
<p>I'd like to bind a configuration file to my executable. I'd like to do this by storing an MD5 hash of the file inside the executable. This should keep anyone but the executable from modifying the file.</p>
<p>Essentially if someone modifies this file outside of the program the program should fail to load it again.</p>
<p>EDIT: The program processes credit card information so being able to change the configuration in any way could be a potential security risk. This software will be distributed to a large number of clients. Ideally client should have a configuration that is tied directly to the executable. This will hopefully keep a hacker from being able to get a fake configuration into place.</p>
<p>The configuration still needs to be editable though so compiling an individual copy for each customer is not an option.</p>
<hr>
<p>It's important that this be dynamic. So that I can tie the hash to the configuration file as the configuration changes.</p>
|
<p>A better solution is to store the MD5 in the configuration file. But instead of the MD5 being just of the configuration file, also include some secret "key" value, like a fixed guid, in the MD5.</p>
<pre><code>write(MD5(SecretKey + ConfigFileText));
</code></pre>
<p>Then you simply remove that MD5 and rehash the file (including your secret key). If the MD5's are the same, then no-one modified it. This prevents someone from modifying it and re-applying the MD5 since they don't know your secret key.</p>
<p>Keep in mind this is a fairly weak solution (as is the one you are suggesting) as they could easily track into your program to find the key or where the MD5 is stored. </p>
<p>A better solution would be to use a public key system and sign the configuration file. Again that is weak since that would require the private key to be stored on their local machine. Pretty much anything that is contained on their local PC can be bypassed with enough effort.</p>
<p>If you REALLY want to store the information in your executable (which I would discourage) then you can just try appending it at the end of the EXE. That is usually safe. Modifying executable programs is <em>virus like</em> behavior and most operating system security will try to stop you too. If your program is in the Program Files directory, and your configuration file is in the Application Data directory, and the user is logged in as a non-administrator (in XP or Vista), then you will be unable to update the EXE.</p>
<p><strong>Update:</strong> I don't care if you are using Asymmetric encryption, RSA or Quantum cryptography, if you are storing your keys on the user's computer (which you <em>must</em> do unless you route it all through a web service) then the user can find your keys, even if it means inspecting the registers on the CPU at run time! You are only buying yourself a moderate level of security, so stick with something that is simple. To prevent modification the solution I suggested is the best. To prevent reading then encrypt it, and if you are storing your key locally then use AES Rijndael.</p>
<p><strong>Update:</strong> The FixedGUID / SecretKey could alternatively be generated at install time and stored somewhere "secret" in the registry. Or you could generate it every time you use it from hardware configuration. Then you are getting more complicated. How you want to do this to allow for moderate levels of hardware changes would be to take 6 different signatures, and hash your configuration file 6 times - once with each. Combine each one with a 2nd secret value, like the GUID mentioned above (either global or generated at install). Then when you check you verify each hash separately. As long as they have 3 out of 6 (or whatever your tolerance is) then you accept it. Next time you write it you hash it with the new hardware configuration. This allows them to slowly swap out hardware over time and get a whole new system. . . Maybe that is a weakness. It all comes down to your tolerance. There are variations based on tighter tolerances.</p>
<p><strong>UPDATE:</strong> For a Credit Card system you might want to consider some real security. You should retain the services of a <em>security and cryptography consultant</em>. More information needs to be exchanged. They need to analyze your specific needs and risks. </p>
<p>Also, if you want security with .NET you need to first start with a really good .NET obfuscator (<a href="http://www.google.com/search?hl=en&q=.NET%20obfuscator&aq=f&oq=" rel="nofollow noreferrer">just Google it</a>). A .NET assembly is way to easy to disassemble and get at the source code and read all your secrets. Not to sound a like a broken record, but anything that depends on the security of your user's system is fundamentally flawed from the beginning. </p>
|
<p>just make a const string that holds the md5 hash and compile it into your app ... your app can then just refer to this const string when validating the configuration file</p>
| 5,554
|
<p>Has anyone written an 'UnFormat' routine for Delphi?</p>
<p>What I'm imagining is the <em>inverse</em> of <em>SysUtils.Format</em> and looks something like this </p>
<p>UnFormat('a number %n and another %n',[float1, float2]); </p>
<p>So you could unpack a string into a series of variables using format strings.</p>
<p>I've looked at the 'Format' routine in SysUtils, but I've never used assembly so it is meaningless to me.</p>
|
<p>This is called scanf in C, I've made a Delphi look-a-like for this :</p>
<pre><code>function ScanFormat(const Input, Format: string; Args: array of Pointer): Integer;
var
InputOffset: Integer;
FormatOffset: Integer;
InputChar: Char;
FormatChar: Char;
function _GetInputChar: Char;
begin
if InputOffset <= Length(Input) then
begin
Result := Input[InputOffset];
Inc(InputOffset);
end
else
Result := #0;
end;
function _PeekFormatChar: Char;
begin
if FormatOffset <= Length(Format) then
Result := Format[FormatOffset]
else
Result := #0;
end;
function _GetFormatChar: Char;
begin
Result := _PeekFormatChar;
if Result <> #0 then
Inc(FormatOffset);
end;
function _ScanInputString(const Arg: Pointer = nil): string;
var
EndChar: Char;
begin
Result := '';
EndChar := _PeekFormatChar;
InputChar := _GetInputChar;
while (InputChar > ' ')
and (InputChar <> EndChar) do
begin
Result := Result + InputChar;
InputChar := _GetInputChar;
end;
if InputChar <> #0 then
Dec(InputOffset);
if Assigned(Arg) then
PString(Arg)^ := Result;
end;
function _ScanInputInteger(const Arg: Pointer): Boolean;
var
Value: string;
begin
Value := _ScanInputString;
Result := TryStrToInt(Value, {out} PInteger(Arg)^);
end;
procedure _Raise;
begin
raise EConvertError.CreateFmt('Unknown ScanFormat character : "%s"!', [FormatChar]);
end;
begin
Result := 0;
InputOffset := 1;
FormatOffset := 1;
FormatChar := _GetFormatChar;
while FormatChar <> #0 do
begin
if FormatChar <> '%' then
begin
InputChar := _GetInputChar;
if (InputChar = #0)
or (FormatChar <> InputChar) then
Exit;
end
else
begin
FormatChar := _GetFormatChar;
case FormatChar of
'%':
if _GetInputChar <> '%' then
Exit;
's':
begin
_ScanInputString(Args[Result]);
Inc(Result);
end;
'd', 'u':
begin
if not _ScanInputInteger(Args[Result]) then
Exit;
Inc(Result);
end;
else
_Raise;
end;
end;
FormatChar := _GetFormatChar;
end;
end;
</code></pre>
|
<p>I tend to take care of this using a simple parser. I have two functions, one is called NumStringParts which returns the number of "parts" in a string with a specific delimiter (in your case above the space) and GetStrPart returns the specific part from a string with a specific delimiter. Both of these routines have been used since my Turbo Pascal days in many a project.</p>
<pre><code>function NumStringParts(SourceStr,Delimiter:String):Integer;
var
offset : integer;
curnum : integer;
begin
curnum := 1;
offset := 1;
while (offset <> 0) do
begin
Offset := Pos(Delimiter,SourceStr);
if Offset <> 0 then
begin
Inc(CurNum);
Delete(SourceStr,1,(Offset-1)+Length(Delimiter));
end;
end;
result := CurNum;
end;
function GetStringPart(SourceStr,Delimiter:String;Num:Integer):string;
var
offset : integer;
CurNum : integer;
CurPart : String;
begin
CurNum := 1;
Offset := 1;
While (CurNum <= Num) and (Offset <> 0) do
begin
Offset := Pos(Delimiter,SourceStr);
if Offset <> 0 then
begin
CurPart := Copy(SourceStr,1,Offset-1);
Delete(SourceStr,1,(Offset-1)+Length(Delimiter));
Inc(CurNum)
end
else
CurPart := SourceStr;
end;
if CurNum >= Num then
Result := CurPart
else
Result := '';
end;
</code></pre>
<p>Example of usage:</p>
<pre><code> var
st : string;
f1,f2 : double;
begin
st := 'a number 12.35 and another 13.415';
ShowMessage('Total String parts = '+IntToStr(NumStringParts(st,#32)));
f1 := StrToFloatDef(GetStringPart(st,#32,3),0.0);
f2 := StrToFloatDef(GetStringPart(st,#32,6),0.0);
ShowMessage('Float 1 = '+FloatToStr(F1)+' and Float 2 = '+FloatToStr(F2));
end;
</code></pre>
<p>These routines work wonders for simple or strict comma delimited strings too. These routines work wonderfully in Delphi 2009/2010.</p>
| 9,829
|
<p>I want to copy a file from A to B in C#. How do I do that?</p>
|
<p>The File.Copy method:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.io.file.copy.aspx" rel="nofollow noreferrer">MSDN Link</a></p>
|
<p>System.IO.File.Copy</p>
| 4,027
|
<p>When and how should table stats gathering be performed for Oracle, version 9 and up? How would you go about gathering stats for a large database, where stats gathering would collide with "business hours".</p>
|
<p>I don't agree that you should always rebuild your statistics after there have been lots of deletes or inserts. As ever, it depends. In a data warehouse situation, when re-building your materialized views you will be doing lots of deletes and inserts but the base structure of the data will not change.</p>
<p>You only need to re-calculate statistics on a table if there has been a <em>significant</em> change in its content. This does <em>not</em> necessarily mean after lots of deletes or inserts, but rather when deletes, inserts, or updates materially change the content with respect to possible execution plans.</p>
<p>If you are truncating tables and rebuilding (which will reset your statistics), instead of an expensive statistics calculation, you're often better off storing the statistics before truncating and restoring them once you've rebuilt the table.</p>
<p>For saving the current views of statistics you use:</p>
<pre><code>dbms_stats.export_table_stats
</code></pre>
<p>and to restore them afterwards you use:</p>
<pre><code>dbms_stats.import_table_stats
</code></pre>
<p>(There are corresponding procedures for <code>schema</code> and <code>database</code>.)</p>
|
<p>Make sure when using the estimate (sample_percent) that you gather at least 10 percent. Below that can yield very questionable results.</p>
| 5,741
|
<p>If I have to make an injection mold (for resin based raw material) using 3D printing, what raw material should I choose – PLA, ABS, HIPS etc.</p>
|
<p>P20 mold steel is one standard. Hardened parts are required for long life, depending on the service and material (some materials are quite abrasive). </p>
<p>You can get a small number of relatively poor quality shots out of epoxy if it is properly supported by a metal box. Your best bet if you want to include 3D printing in the equation is probably to use epoxy or lost plastic casting from a 3D-printed master. Aside from the requirements of core and cavity with sufficient strength, there are requirements for vents, cooling tubes (bubblers and such like) ejector pins and slides that complicate most real molds. Productivity demands a high heat transfer rate, for very small quantities of expensive parts, thermal design may be less important. </p>
<p>Temperatures and pressures are very high in injection injection molding- high enough to melt the materials you mention, and the pressures are in the 10K PSI range, so a 4" x 4" projected cavity will have a pressure in the 80 ton region.</p>
<p>If you have sintered and filled metal 3D parts they may be suitable, but from the prices I've seen you'd be better off to use conventional machining. Finish is also very important if you want the part to come out of the mold, with hours of semi-manual polishing not uncommon. If you don't have fine surface finish you will need extreme draft angles.</p>
<p>The requirements can be considerably relaxed if you are molding soft parts such as the PVC or TPE overmolds on cables. The pressure is less and the finish less important because the plastic is soft, but the temperatures are still quite high. This is sort of a sub-category of injection molding and specialized machines are used. </p>
|
<p>P20 mold steel is one standard. Hardened parts are required for long life, depending on the service and material (some materials are quite abrasive). </p>
<p>You can get a small number of relatively poor quality shots out of epoxy if it is properly supported by a metal box. Your best bet if you want to include 3D printing in the equation is probably to use epoxy or lost plastic casting from a 3D-printed master. Aside from the requirements of core and cavity with sufficient strength, there are requirements for vents, cooling tubes (bubblers and such like) ejector pins and slides that complicate most real molds. Productivity demands a high heat transfer rate, for very small quantities of expensive parts, thermal design may be less important. </p>
<p>Temperatures and pressures are very high in injection injection molding- high enough to melt the materials you mention, and the pressures are in the 10K PSI range, so a 4" x 4" projected cavity will have a pressure in the 80 ton region.</p>
<p>If you have sintered and filled metal 3D parts they may be suitable, but from the prices I've seen you'd be better off to use conventional machining. Finish is also very important if you want the part to come out of the mold, with hours of semi-manual polishing not uncommon. If you don't have fine surface finish you will need extreme draft angles.</p>
<p>The requirements can be considerably relaxed if you are molding soft parts such as the PVC or TPE overmolds on cables. The pressure is less and the finish less important because the plastic is soft, but the temperatures are still quite high. This is sort of a sub-category of injection molding and specialized machines are used. </p>
| 896
|
<p>I'm building an application that is targeting Windows, Mac and Linux soon. I was wondering where should I keep application data such as settings, etc.</p>
<p>Application's installation folder is the easiest choice, but I think that might be a problem with new Vista security model. Besides, users might want different settings.</p>
<p>Is it C:\Documents and Settings\username\MyApp good for both Vista and XP?
Is it /home/username/.MyApp good for Linux and Macs?</p>
<p>Any ideas and/or links to best practices much appreciated.</p>
<p>Thanks!</p>
<p>Juan</p>
|
<p>Each platform has its own API for finding the user's home folder, or documents folder, or preferences folder. </p>
<ul>
<li>Windows: SHGetFolderPath() or SHGetKnownFolderPath()</li>
<li>Mac OS X and iPhone OS: NSSearchPathForDirectoriesInDomains()</li>
<li>Unix: $HOME environment variable</li>
</ul>
<p>Don't hardcode specific paths or just tack a prefix and suffix on the user's name. Also, try to follow whatever conventions there are for the platform for naming the files.</p>
|
<p>Never, ever store user data in the application folder. It's just a bad idea.</p>
<p>Most operating systems have a $HOME (or %HOME%) environment variable. That would be the first place to look. </p>
<p>If you want to cleanly support multiple operating systems, though, you're going to have to have some OS-specific code for each that figures out exactly where things need to go. (~/Library for Mac OS, ~/.config for GNOME-based systems, %HOME%/Application Data for Windows, etc.).</p>
| 8,122
|
<p>On Windows I can do:</p>
<pre><code>HANDLE hCurrentProcess = GetCurrentProcess();
SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS);
</code></pre>
<p>How can I do the same thing on *nix?</p>
|
<p>Try:</p>
<pre><code>#include <sys/time.h>
#include <sys/resource.h>
int main(){
setpriority(PRIO_PROCESS, 0, -20);
}
</code></pre>
<p>Note that you must be running as superuser for this to work.</p>
<p>(for more info, type 'man setpriority' at a prompt.)</p>
|
<p>@ allain <blockquote>Can you lower your own process' priority without being superuser?</blockquote></p>
<p>Sure. Be aware, however, that this is a one way street. You can't even get back to where you started. And even fairly small reductions in priority can have startlingly large effects on running time when there is significant load on the system.</p>
| 4,926
|
<p>Is there a way to search the latest version of every file in TFS for a specific string or regex? This is probably the only thing I miss from Visual Source Safe... </p>
<p>Currently I perform a Get Latest on the entire codebase and use Windows Search, but this gets quite painful with over 1GB of code in 75,000 files. </p>
<p><strong>EDIT</strong>: Tried the powertools mentioned, but the "Wildcard Search" option appears to only search filenames and not contents.</p>
<p><strong>UPDATE</strong>: We have implemented a customised search option in an existing MOSS (Search Server) installation. </p>
|
<p>Team Foundation Server 2015 (on-premises) and Visual Studio Team Services (cloud version) include built-in support for searching across all your code and work items.</p>
<p>You can do simple string searches like <code>foo</code>, boolean operations like <code>foo OR bar</code> or more complex language-specific things like <code>class:WebRequest</code></p>
<p><a href="https://i.stack.imgur.com/d0qL0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d0qL0.png" alt="screenshot of code search filter syntax"></a></p>
<p>You can read more about it here: <a href="https://www.visualstudio.com/en-us/docs/search/overview" rel="noreferrer">https://www.visualstudio.com/en-us/docs/search/overview</a></p>
|
<p>This add-in claims to have the functionality that I believe you seek:</p>
<p><a href="http://www.attrice.info/cm/tfs/index.htm" rel="nofollow noreferrer">Team Foundation Sidekicks</a></p>
| 6,232
|
<p>What would be your preferred way to concatenate strings from a sequence such that between every two consecutive pairs a comma is added. That is, how do you map, for instance, <code>['a', 'b', 'c']</code> to <code>'a,b,c'</code>? (The cases <code>['s']</code> and <code>[]</code> should be mapped to <code>'s'</code> and <code>''</code>, respectively.)</p>
<p>I usually end up using something like <code>''.join(map(lambda x: x+',',l))[:-1]</code>, but also feeling somewhat unsatisfied.</p>
|
<pre><code>my_list = ['a', 'b', 'c', 'd']
my_string = ','.join(my_list)
</code></pre>
<pre><code>'a,b,c,d'
</code></pre>
<p>This won't work if the list contains integers</p>
<hr>
<p>And if the list contains non-string types (such as integers, floats, bools, None) then do:</p>
<pre><code>my_string = ','.join(map(str, my_list))
</code></pre>
|
<p>My two cents. I like simpler an one-line code in python:</p>
<pre><code>>>> from itertools import imap, ifilter
>>> l = ['a', '', 'b', 1, None]
>>> ','.join(imap(str, ifilter(lambda x: x, l)))
a,b,1
>>> m = ['a', '', None]
>>> ','.join(imap(str, ifilter(lambda x: x, m)))
'a'
</code></pre>
<p>It's pythonic, works for strings, numbers, None and empty string. It's short and satisfies the requirements. If the list is not going to contain numbers, we can use this simpler variation:</p>
<pre><code>>>> ','.join(ifilter(lambda x: x, l))
</code></pre>
<p>Also this solution doesn't create a new list, but uses an iterator, like @Peter Hoffmann pointed (thanks).</p>
| 6,653
|
<p>I have an NFS-mounted directory on a Linux machine that has hung. I've tried to force an unmount, but it doesn't seem to work:</p>
<pre><code>$ umount -f /mnt/data
$ umount2: Device or resource busy
$ umount: /mnt/data: device is busy
</code></pre>
<p>If I type "<code>mount</code>", it appears that the directory is no longer mounted, but it hangs if I do "<code>ls /mnt/data</code>", and if I try to remove the mountpoint, I get:</p>
<pre><code>$ rmdir /mnt/data
rmdir: /mnt/data: Device or resource busy
</code></pre>
<p>Is there anything I can do other than reboot the machine?</p>
|
<p>You might try a lazy unmount:</p>
<pre><code>umount -l
</code></pre>
|
<p>Your NFS server disappeared.</p>
<p>Ideally your best bet is if the NFS server comes back.</p>
<p>If not, the "umount -f" should have done the trick.
It doesn't ALWAYS work, but it often will.</p>
<p>If you happen to know what processes are USING the NFS filesystem,
you could try killing those processes and then maybe an unmount would work.</p>
<p>Finally, I'd guess you need to reboot.</p>
<p>Also, DON'T soft-mount your NFS drives. You use hard-mounts to guarantee
that they worked. That's necessary if you're doing writes.</p>
| 6,153
|
<p>Whilst refactoring some legacy C++ code I found that I could potentially remove some code duplication by somehow defining a variable that could point to any class method that shared the same signature. After a little digging, I found that I could do something like the following:</p>
<pre><code>class MyClass
{
protected:
bool CaseMethod1( int abc, const std::string& str )
{
cout << "case 1:" << str;
return true;
}
bool CaseMethod2( int abc, const std::string& str )
{
cout << "case 2:" << str;
return true;
}
bool CaseMethod3( int abc, const std::string& str )
{
cout << "case 3:" << str;
return true;
}
public:
bool TestSwitch( int num )
{
bool ( MyClass::*CaseMethod )( int, const std::string& );
switch ( num )
{
case 1: CaseMethod = &MyClass::CaseMethod1;
break;
case 2: CaseMethod = &MyClass::CaseMethod2;
break;
case 3: CaseMethod = &MyClass::CaseMethod3;
break;
}
...
bool res = CaseMethod( 999, "hello world" );
...
reurn res;
}
};
</code></pre>
<p>My question is - <strong>is this the correct way to go about this?</strong> Should I consider anything that <em>Boost</em> has to offer?</p>
<p>Edit...</p>
<p>Ok, my mistake - I should be calling the method like so:</p>
<pre><code>bool res = ( (*this).*CaseMethod )( 999, "Hello World" );
</code></pre>
|
<p>What you have there is a pointer-to-member-function. It will solve your problem. I am surprised that your "TestSwitch" function compiles, as the calling syntax is slightly different to what you might expect. It should be:</p>
<pre><code>bool res = (this->*CaseMethod)( 999, "hello world" );
</code></pre>
<p>However, you might find a combination of boost::function and boost::bind makes things a little easier, as you can avoid the bizarre calling syntax.</p>
<pre><code>boost::function<bool(int,std::string)> f=
boost::bind(&MyClass::CaseMethod1,this,_1,_2);
</code></pre>
<p>Of course, this will bind it to the current <code>this</code> pointer: you can make the <code>this</code> pointer of the member function an explicit third parameter if you like:</p>
<pre><code>boost::function<bool(MyClass*,int,std::string)> f=
boost::bind(&MyClass::CaseMethod1,_1,_2,_3);
</code></pre>
<p>Another alternative might be to use virtual functions and derived classes, but that might require major changes to your code.</p>
|
<p>There's nothing intrinsically wrong with the localised example you've given here, but class method pointers can often be tricky to keep 'safe' if you use them in a wider context, such as outside the class they're a pointer of, or in conjunction with a complex inheritance tree. The way compilers typically manage method pointers is different to 'normal' pointers (since there's extra information beyond just a code entry point), and consequently there are a lot of restrictions on what you can do with them.</p>
<p>If you're just keeping simple pointers the way you describe then you'll be fine, but fore more complex uses you may want to take a look at a more generalised functor system such as <a href="http://www.boost.org/doc/libs/1_36_0/libs/bind/bind.html#with_member_pointers" rel="nofollow noreferrer">boost::bind</a>. These can take pointers to just about any callable code pointer, and can also bind instanced function arguments if necessary.</p>
| 7,998
|
<p>I'm tired of opening Dia and creating a database diagram at the beginning of every project. Is there a tool out there that will let me select specific tables and then create a database diagram for me based on a MySQL database? Preferably it would allow me to edit the diagram afterward since none of the foreign keys are set...</p>
<p>Here is what I am picturing diagram-wise (please excuse the horrible data design, I didn't design it. Let's focus on the diagram concept and not on the actual data it represents for this example ;) ):</p>
<p><img src="https://i.stack.imgur.com/lxvlR.jpg" alt="diagram">
<a href="https://i.stack.imgur.com/ZnN2O.png" rel="noreferrer">see full size diagram</a></p>
|
<p>Try MySQL Workbench, formerly DBDesigner 4:</p>
<p><a href="http://dev.mysql.com/workbench/" rel="noreferrer">http://dev.mysql.com/workbench/</a></p>
<p>This has a "Reverse Engineer Database" mode:</p>
<p>Database -> Reverse Engineer</p>
<p><a href="https://i.stack.imgur.com/wcoq9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wcoq9.png" alt="enter image description here"></a></p>
|
<p>The "Reverse Engineer Database" mode in Workbench is only part of the paid version, not the free one.</p>
| 2,460
|
<p>How can I redirect the response to an IFrame?</p>
|
<p>Do you mean from the server-side? - You can't!</p>
<p><strong>You'll have to do it on the client side.</strong></p>
<p>Say, use a javascript that sends an <em>AJAX request</em> and then embed your response information in the <em>AJAX response</em>. And have the javascript read the response and changes the page in the intended frame accordingly</p>
|
<p>. . . not totally sure what your trying to do, but you normally control the source of an iframe through javascript</p>
| 9,847
|
<p>I know and have Xcode, but I was wondering if there were any other complete development environments that support Objective-C? I'm not looking for solutions with vim or emacs, nor editors like BBEdit that support syntax highlighting, but a full fledged IDE with:</p>
<ul>
<li>code completion</li>
<li>compilation</li>
<li>debugging</li>
<li>refactoring</li>
</ul>
<p>Extra points for being cross platform, supporting vi key bindings and supporting other languages.</p>
<h3>Note:</h3>
<p>I've updated and accepted my answer below as Jetbrains has released Early Access for <em>AppCode</em>, their new Objective-C IDE. Since this has been a fairly popular question, I thought it worthwhile to update the information.</p>
|
<p>I recently learned that <a href="http://www.jetbrains.com/" rel="noreferrer">Jetbrains</a> the make of my favorite IDE (Idea) may support Objective-C (though it is unclear how much it will work for iPhone/iPad development). See the thread <a href="http://www.jetbrains.net/devnet/thread/282271?tstart=0" rel="noreferrer">here</a> for early discussion on this.</p>
<p>In the last year or two, they have started adding additional language support both in their flagship IDE as well as specialized IDEs (for Ruby, Python, PHP). I guess this is just another step in the process. I for one would love to have another option other than XCode and I couldn't think of one that I'd love more.</p>
<p>This is obviously vaporware at the moment, but I think it is something to keep an eye on.</p>
<p>This is now a real product, albeit still in Early Access. See <a href="http://blog.jetbrains.com/objc/" rel="noreferrer">here</a> for a the blog on this new product, which will give you pointers to check out the EAP.</p>
<p>UPDATE: <a href="http://www.jetbrains.com/objc/" rel="noreferrer">AppCode</a> has now been released and offers a true alternative to using Xcode for Objective-C and iPhone/iPad/Mac development. It does still rely on Interface Builder for layout and wiring of GUI components and uses the iOS simulator, but all coding, including a slew of refactorings, smart templating and static analysis, is available through App Code.</p>
|
<p>I believe KDevelop is the only full IDE that supports Obj-C, but I'm not even sure how fully it supports it, having never used it myself. Worth a shot, maybe.</p>
| 9,319
|
<p>Is it possible to determine the MAC address of the originator of a remote connection under Windows NT 4? The remote PC opens a socket connection into my application and I can get the IP address. However I need to determine the MAC address from the information available from the socket such as the IP address of the remote device.</p>
<p>I have tried using <code>SendARP</code> but this doesn't seem to be supported in Windows NT4.</p>
|
<p>Try GetIpNetTable. This function is documented as supported as of NT 4.0 SP4.</p>
|
<p>Hope the machine isn't <em>too</em> remote. MAC addresses will only be known for the local network (subnet).</p>
| 8,836
|
<p>Given the constraint of only using T-Sql in Sql Server 2005, is there a better way to remove the decimal point from a money datatype than a conversion to a varchar (here implicitly) and then a replace of the decimal point?</p>
<p>Here is what I have currently.</p>
<pre><code>SELECT REPLACE(1.23, '.', ''), REPLACE(19.99, '.', '')
</code></pre>
<p>Which returns the desired 123 and 1999, but I was wondering if there was a better way. Any thoughts?</p>
|
<p>Multiply by 100 and then convert to an int.</p>
|
<p>Could you be a little more specific about the use case? Removing the decimal point from the representation is a little unusual given that you'll lose all information about the scale. Are you assuming that there will always be two digits? If so, you could simplify multiply by 100 and then round before converting to a string.</p>
| 2,594
|
<p>I want a data structure that will allow querying <em>how many items in last <strong>X</strong> minutes</em>. An item may just be a simple identifier or a more complex data structure, preferably the timestamp of the item will be in the item, rather than stored outside (as a hash or similar, wouldn't want to have problems with multiple items having same timestamp).</p>
<p>So far it seems that with LINQ I could easily filter items with timestamp greater than a given time and aggregate a count. Though I'm hesitant to try to work .NET 3.5 specific stuff into my production environment yet. Are there any other suggestions for a similar data structure?</p>
<p>The other part that I'm interested in is <em>aging</em> old data out, If I'm only going to be asking for counts of items less than 6 hours ago I would like anything older than that to be removed from my data structure because this may be a long-running program.</p>
|
<p>A simple linked list can be used for this.</p>
<p>Basically you add new items to the end, and remove too old items from the start, it is a cheap data structure.</p>
<p>example-code:</p>
<pre><code>list.push_end(new_data)
while list.head.age >= age_limit:
list.pop_head()
</code></pre>
<p>If the list will be busy enough to warrant chopping off larger pieces than one at a time, then I agree with <a href="https://stackoverflow.com/users/1807/dmo">dmo</a>, use a tree structure or something similar that allows pruning on a higher level.</p>
|
<p>I think that an important consideration will be the frequency of querying vs. adding/removing. If you will do frequent querying (especially if you'll have a large collection) a B-tree may be the way to go:</p>
<p><a href="http://en.wikipedia.org/wiki/B-tree" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/B-tree</a></p>
<p>You could have some thread go through and clean up this tree periodically or make it part of the search (again, depending on the usage). Basically, you'll do a tree search to find the spot "x minutes ago", then count the number of children on the nodes with newer times. If you keep the number of children under the nodes up to date, this sum can be done quickly.</p>
| 3,609
|
<p>I bought a new printer, and unfortunately the left nut for the lead screw isn't tapped.</p>
<p>Does anyone know the thread size, w.r.t. both pitch and lead, of the lead screws?</p>
|
<p>I have the Anet A8, I confirm the threads are Tr8x8(p2). This is explained as "Tr" for trapezoidal thread followed by the nominal diameter in mm. The digits after the "x" denotes the lead of the screw (how much does the nut advance per revolution). The value between the brackets "p2" denotes the pitch. This means that the screw has 8 (lead) / 2 (pitch) = 4 starts.</p>
<p>More information on threads is found <a href="https://en.wikipedia.org/wiki/Trapezoidal_thread_form" rel="nofollow noreferrer">on Wikipedia</a>.</p>
|
<p>The pitch no matter the screw is the distance between the threads. The lead can be different based on a one or two start threads.</p>
| 848
|
<p>I'm suddenly back to WinForms, after years of web development, and am having trouble with something that should be simple. I have an <code>ArrayList</code> of business objects bound to a Windows Forms <code>DataGrid</code>. I'd like the user to be able to edit the cells, and when finished, press a Save button. At that point I'd like to iterate the all the rows and columns in the <code>DataGrid</code> to find any changes, and save them to the database. But I can't find a way to access the <code>DataGrid</code> rows. </p>
<p>I'll also want to validate individual cells real time, as they are edited, but I'm pretty sure that can be done. (Maybe not with an <code>ArrayList</code> as the <code>DataSource</code>?) But as for iterating the <code>DataGrid</code>, I'm quite surprised it doesn't seem possible.</p>
<p>Must I really stuff my business objects data into datatables in order to use the datagrid? </p>
|
<pre class="lang-cs prettyprint-override"><code>foreach(var row in DataGrid1.Rows)
{
DoStuff(row);
}
//Or ---------------------------------------------
foreach(DataGridRow row in DataGrid1.Rows)
{
DoStuff(row);
}
//Or ---------------------------------------------
for(int i = 0; i< DataGrid1.Rows.Count - 1; i++)
{
DoStuff(DataGrid1.Rows[i]);
}
</code></pre>
|
<p>Aha, I was really just testing everyone once again! :) The real answer is, you rarely need to iterate the datagrid. Because even when binding to an ArrayList, the binding is 2 way. Still, it is handy to know how to itereate the grid directly, it can save a few lines of code now and then. </p>
<p>But NotMyself and Orion gave the better answers: Convince the stakeholders to move up to a higher version of C#, to save development costs and increase maintainability and extensability.</p>
| 2,817
|
<p>Is there any way to have something that looks just like a file on a Windows file share, but is really a resource served up over HTTP?</p>
<p>For context, I'm working with an old app that can only deal with files on a Windows file share, I want to create a simple HTTP-based service to serve the content of the files dynamically to pick up real time changes to the underlying data on request.</p>
|
<p>WebDAV (basically) takes an existing directory, and shares it over HTTP - which sounds like the opposite of what you want. </p>
<p>You need something that speaks SMB/CIFS on one end, and your own code on the other. The easiest way to do that is with a userspace file system.</p>
<p>To that end, here's a couple of links:</p>
<ol>
<li><a href="http://www.palissimo.de/index.php?c=6" rel="nofollow noreferrer">WinFUSE</a>, which is kind of a barebones CIFS/SMB server that can host your own filesystem. I've done a couple of small samples with it - and the docs are terrible, but it more or less worked.</li>
<li><a href="http://dokan-dev.net/en/" rel="nofollow noreferrer">Dokan</a>, a userspace file driver with .NET bindings. I haven't used this one, but it looks promising. It has both .NET and Ruby bindings, so you should be able to get a POC up pretty quickly.</li>
<li><a href="http://www.eldos.com/cbfs/" rel="nofollow noreferrer">Callback File System</a> - yet another userspace file system. Again, I have no experience with this one.</li>
<li>A Linux box with SAMBA and FUSE that shares the drive out to the Windows box.</li>
</ol>
|
<p>This won't answer your question in any meaningful way, but maybe it will get you pointed in the right direction. Look into serving the "file(s)" via WebDAV--SharePoint uses this and its files can be accessed exactly as you want, as a file share where the transport mechanism is HTTP. Unfortunately I can't give any more detailed info, as I've only worked on the client end of WebDAV and not the server side of things. </p>
| 4,405
|
<p>I have a flag enum below.</p>
<pre><code>[Flags]
public enum FlagTest
{
None = 0x0,
Flag1 = 0x1,
Flag2 = 0x2,
Flag3 = 0x4
}
</code></pre>
<p>I cannot make the if statement evaluate to true.</p>
<pre><code>FlagTest testItem = FlagTest.Flag1 | FlagTest.Flag2;
if (testItem == FlagTest.Flag1)
{
// Do something,
// however This is never true.
}
</code></pre>
<p>How can I make this true?</p>
|
<p>In .NET 4 there is a new method <a href="http://msdn.microsoft.com/en-us/library/system.enum.hasflag%28VS.100%29.aspx" rel="noreferrer">Enum.HasFlag</a>. This allows you to write:</p>
<pre><code>if ( testItem.HasFlag( FlagTest.Flag1 ) )
{
// Do Stuff
}
</code></pre>
<p>which is much more readable, IMO.</p>
<p>The .NET source indicates that this performs the same logic as the accepted answer:</p>
<pre><code>public Boolean HasFlag(Enum flag) {
if (!this.GetType().IsEquivalentTo(flag.GetType())) {
throw new ArgumentException(
Environment.GetResourceString(
"Argument_EnumTypeDoesNotMatch",
flag.GetType(),
this.GetType()));
}
ulong uFlag = ToUInt64(flag.GetValue());
ulong uThis = ToUInt64(GetValue());
// test predicate
return ((uThis & uFlag) == uFlag);
}
</code></pre>
|
<p>even without [Flags], you could use something like this</p>
<pre><code>if((testItem & (FlagTest.Flag1 | FlagTest.Flag2 ))!=0){
//..
}
</code></pre>
<p>or if you have a Zero value enum</p>
<pre><code>if((testItem & (FlagTest.Flag1 | FlagTest.Flag2 ))!=FlagTest.None){
//..
}
</code></pre>
| 6,143
|
<p>Within Ruby on Rails applications database.yml is a plain text file that stores database credentials.</p>
<p>When I deploy my Rails applications I have an after deploy callback in my Capistrano
recipe that creates a symbolic link within the application's /config directory to the database.yml file. The file itself is stored in a separate directory that's outside the standard Capistrano /releases directory structure. I chmod 400 the file so it's only readable by the user who created it.</p>
<ul>
<li>Is this sufficient to lock it down? If not, what else do you do?</li>
<li>Is anyone encrypting their database.yml files?</li>
</ul>
|
<p>You'll also want to make sure that your SSH system is well secured to prevent people from logging in <em>as</em> your Capistrano bot. I'd suggest restricting access to password-protected key pairs.</p>
<p>Encrypting the .yml file on the server is useless since you have to give the bot the key, which would be stored . . . on the same server. Encrypting it on your machine is probably a good idea. Capistrano can decrypt it before sending.</p>
|
<p>If you're very concerned about security of the yml file, I have to ask: Is it stored in your version control? If so, that's another point where an attacker can get at it. If you're doing checkout/checkin over non-SSL, someone could intercept it.</p>
<p>Also, with some version control (svn, for exampl), even if you remove it, it's still there in the history. So, even if you removed it at some point in the past, it's still a good idea to change the passwords.</p>
| 3,889
|
<p>I need to rotate an image at 12 midnight every day from a group of 5-10 images. How can I go about doing this with JavaScript or jQuery or even PHP?</p>
|
<p>At a basic level what you want to do is define an array of image names then take the number of days from a given point in time then modulo (remainder after division) by the number of images and access that index in the array and set the image, e.g. (untested code)</p>
<pre><code>var images = new Array("image1.gif", "image2.jpg", "sky.jpg", "city.png");
var dateDiff = new Date() - new Date(2008,01,01);
var imageIndex = Math.Round(dateDiff/1000/60/60/24) % images.length;
document.GetElementById('imageId').setAttribute('src', images[imageIndex]);
</code></pre>
<p>Bear in mind that any client-side solution will be using the date and time of the client so if your definition of midnight means in your timezone then you'll need to do something similar on your server in PHP.</p>
|
<p>If you are running a linux system you can set a <a href="http://www.sitepoint.com/article/introducing-cron/" rel="nofollow noreferrer">Cron Job</a> or you can use the windows task scheduler if you are on windows</p>
| 9,193
|
<p>Anyone know how to do this without using a third party program? If there no way to do it with a add-on someone can recommend one?</p>
<p>EDIT: I need to add this in the server so all users have the same signature.</p>
<p>Thanks</p>
|
<p>You need to create your own exchange message sink to do this. Here's a classic VB example from MS KB:</p>
<p><a href="http://support.microsoft.com/kb/317327" rel="nofollow noreferrer">http://support.microsoft.com/kb/317327</a></p>
<p>and a VB Script one:</p>
<p><a href="http://support.microsoft.com/kb/317680" rel="nofollow noreferrer">http://support.microsoft.com/kb/317680</a></p>
<p>And lots of goodness from MSDN about Exchange 2003 Transport Event Sinks:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms526223(EXCHG.10).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms526223(EXCHG.10).aspx</a></p>
<p>If you're running Exchange 2007 then you can use Transport Rules:</p>
<p><a href="http://msexchangeteam.com/archive/2006/12/12/431879.aspx" rel="nofollow noreferrer">http://msexchangeteam.com/archive/2006/12/12/431879.aspx</a></p>
<p><a href="http://www.msexchange.org/tutorials/Using-Transport-Rules-Creating-Disclaimers-Exchange-Server-2007.html" rel="nofollow noreferrer">http://www.msexchange.org/tutorials/Using-Transport-Rules-Creating-Disclaimers-Exchange-Server-2007.html</a></p>
|
<p>We used <a href="http://codetwo.com/" rel="nofollow noreferrer">CodeTwo-s</a> Exchange rules for a while on Exchange 2003.</p>
<p>However there is a known problem with it: if the messages stay in the queue for 2-3 minutes, the Exchange itself sends out the message without the footer. Most of the times it's not a problem, but we have something like 700 people in our organization. If there are a lot of emails and some of them contains attachments, then the virus scanner stops them for a while (MS Antigen).</p>
<p>Otherwise it's a perfect solution if you have a smaller group of users to manage.</p>
<p>From other point of view: our users like to have some kind of control over the signature. We generated them and put it to their Outlooks. They like it that they know and see that the signature is there and how it looks like.</p>
| 3,241
|
<p>I have not been able to print smooth and round shapes using Cura 3.3.1 (or earlier) without bumps. I think they are seams? The filament is PLA.</p>
<p>Combing is enabled, which I thought makes it so that the nozzle travels over already printed areas, instead of flying over the air...<em>right</em>?</p>
<p>I have been able to keep the seems hidden for the most part when there are sharp corners. <em>Sometimes</em> cura hides the seems properly...sometimes it doesn't. </p>
<p>Here is an example shape I have tried printing with several different settings:</p>
<p><a href="https://i.stack.imgur.com/NrinP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NrinP.png" alt="Cura printed object"></a></p>
<p>The object above was printed using "random" seam corner preference. If I had chosen "sharpest corner", the bumps would all just stack up in one place, but still stick out.</p>
<p><a href="https://i.stack.imgur.com/NuTiI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NuTiI.png" alt="Cura shape"></a></p>
<p><a href="https://i.stack.imgur.com/JPmd3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JPmd3.png" alt="Cura settings 1"></a>
<a href="https://i.stack.imgur.com/a5T3w.png" rel="noreferrer"><img src="https://i.stack.imgur.com/a5T3w.png" alt="Cura settings 2"></a></p>
<p><a href="https://i.stack.imgur.com/ygxYP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ygxYP.png" alt="Cura Settings 3"></a>
<a href="https://i.stack.imgur.com/Jvuy1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Jvuy1.png" alt="Cura settings 4"></a></p>
<p>Just look at the travel lines below! Why is it jumping all over the place?</p>
<p><a href="https://i.stack.imgur.com/73rsT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/73rsT.png" alt="Cura travel lines"></a></p>
<p><a href="https://i.stack.imgur.com/gu0TJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gu0TJ.png" alt="Cura travel lines single layer"></a></p>
<p>I have tried "Avoid printed parts when traveling" enabled and disabled, doesn't seem to make much difference.</p>
<p>I feel that there should be a configuration that results in the nozzle not jumping through the air like that, but I can't find it. Perhaps that's not related to the bumps?</p>
<p>The printer is a MonoPrice Mini Delta.</p>
|
<p>Following on from Toon's answer, here is a run down of <a href="https://www.youtube.com/channel/UCb8Rde3uRL1ohROUVg46h1A" rel="nofollow noreferrer">Thomas Sanladerer</a>'s excellent
video: <a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow noreferrer">3D printing guides: Calibration and why you might be doing it wrong</a>.</p>
<p><em>However, this may not be a definitive answer to the actual question about warts and bumps...</em></p>
<hr>
<p><strong><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8&t=8" rel="nofollow noreferrer">0:08 - A step back</a></strong></p>
<p>Back in time - when the RepRap project (and the hobby grade 3D printing market) was new territory - it was seen to be a <em>doable</em> technology, with no restrictions imposed by patents. The new printers created and developed included Darwin, Sells Mendel and Prusa Mendel. These often produced unusable parts.</p>
<p>However, impromptu solutions, or kludges led to poor quality fixes giving poor quality prints, by today's standards. However, people (today) believe that because they worked back then,. that they must still be valid solutions today. However this is not necessarily the case. </p>
<p>The common misconception is that it is necessary to calibrate the esteps per mm for all axes other than extruder - adjusting the x, y and z esteps per mm until the 10 mm cube measures exactly 10x10x10 mm, even if that means squeezing the callipers.</p>
<hr>
<blockquote>
<p><strong><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8&t=85" rel="nofollow noreferrer">1:25 - Car analogy</a></strong></p>
<p>You find that your car pulls to the left, when going in a straight
line, so you adjust the steering. However, then in hard corners and
the rain the car handles poorly. </p>
<p>Upon closer inspection, it then turns out that the car had a flat
tyre. You wouldn't compensate for having a flat tyre by adjusting the
steering, now would you?</p>
</blockquote>
<hr>
<p>In order to get that 10 mm cube precise, it is usual to calibrate for the filament diameter, and extrusion multiplier (most straightforward option), but some printers aren't even that precise in the first place.</p>
<p>Mechanical, ripple, slaw, blacklash, can throw you off by 0.1 mm. Compensation for this 0.1 mm is certainly possible and achievable. However, then for a larger print, say 100 mm, then these <em>overcompensation</em> will become more evident, and you will be one entire milimeter off the desired dimensions.</p>
<p>So, use the ideal calculated esteps per mm. Timing belts and threaded rods are made to tight tolerances. therefore the worst case of ideal step per mm setting is an inaccuracy of 0.5%.</p>
<p>So, to find the ideal calculated steps use <a href="http://prusaprinters.org/calculator/" rel="nofollow noreferrer">Prusa's calculator</a> which is very good indeed. </p>
<p>If you are not using belts, or very large printer, then it is worth recalibrating the steps per mm for x and y, as 0.5% will make a noticeable difference in larger parts.</p>
<p>Use the files and instructions for these <strong>Calibration sticks</strong> on <a href="https://www.youmagine.com/designs/calibration-sticks" rel="nofollow noreferrer">Youmagine</a>, for proper recalibrating without results slewed by the extrusion multiplier being off by a bit.</p>
<p><strong><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8&t=225" rel="nofollow noreferrer">3:45 - So what do I need to do?</a></strong></p>
<p>What do you need to empirically calibrate your printer? In actual fact, not all that much:</p>
<ul>
<li>extruder steps per mm setting</li>
<li><p>extrusion multiplier (see video link - <a href="https://www.youtube.com/watch?v=YUPfBJz3I6Y" rel="nofollow noreferrer">Extruder calibration</a>)</p></li>
<li><p>print speed, jerk and acceleration settings - These depend upon how much quality you want to sacrifice for increased speed.</p>
<p>Pro-tip: <em>slow your printing down</em>. For example, try printing at half speed. Quality <em>may</em> be improved, and even if it isn't you will be able to observe more clearly what is happening, and going wrong.
(see video link - <a href="https://www.youtube.com/watch?v=7HsIZuj9vOs" rel="nofollow noreferrer">Super Fast Guide:Tuning Speeds</a>)</p></li>
</ul>
<p><strong><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8&t=270" rel="nofollow noreferrer">4:30 - Other than that?</a></strong></p>
<p>There is not much else needs calibrating, per se.</p>
<p>With regards to slicer software, there are only a certain range of settings make sense, but this isn't printer calibration. You simply learn the slicer software and, with familiarity, see how far you can go.</p>
<p>These days any well maintained and well built and solid printer will produce good prints.</p>
<p>Most slicers give you decent prints without tweaking or calibrating, other than the basic settings about your printer and deciding how the part should be printed.</p>
<p>What about print temp and retract settings? Well, just use the default settings, or settings which depend upon the type of filament. So, no calibration is required there, as it is a property of the filament.</p>
<p><strong><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8&t=324" rel="nofollow noreferrer">5:24 - Summing up</a></strong></p>
<p>Don't try to calibrate everything</p>
<p>The technology, in particular the software, i.e. slicers, is still developing and improving. Slic3r's prototpye beta (in Nov 2014) has added compensation for fitting errors(?) without messing other things up, which is essentially what the cube calibration tries to do, but in the correct way.</p>
|
<p>Have you correctly calibrated your steps per mm a.k.a. esteps? Tom made a great video about it:</p>
<p><a href="https://www.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow noreferrer">3D printing guides: Calibration and why you might be doing it wrong</a></p>
| 902
|
<p>Generally when I use ClickOnce when I build a VB.NET program but it has a few downsides. I've never really used anything else, so I'm not sure
what my options are.</p>
<p>Downsides to ClickOnce:</p>
<ul>
<li>Consists of multiple files - Seems easier to distribute one file than manageing a bunch of file and the downloader to download those files.</li>
<li>You have to build it again for CD installations (for when the end user dosn't have internet)</li>
<li>Program does not end up in Program Files - It ends up hidden away in some application catch folder, making it much harder to shortcut to.</li>
</ul>
<p>Pros to ClickOnce:</p>
<ul>
<li>It works. Magically. And it's built
into VisualStudio 2008 express.</li>
<li>Makes it easy to upgrade the
application.</li>
</ul>
<p>Does Windows Installer do these things as well? I know it dosen't have any of the ClickOnce cons, but It would be nice to know if it also has the ClickOnce pros.</p>
<p><strong>Update</strong>:
I ended up using Wix 2 (Wix 3 was available but at the time I did the project, no one had a competent tutorial). It was nice because it supported the three things I (eventually) needed. An optional start-up-with-windows shortcut, a start-up-when-the-installer-is-done option, and three paragraphs of text that my boss thinks will keep uses from clicking the wrong option.</p>
|
<p>Have you seen WiX yet?</p>
<p><a href="http://wix.sourceforge.net/" rel="noreferrer">http://wix.sourceforge.net/</a></p>
<p>It builds windows installers using an XML file and has additional libraries to use if you want to fancify your installers and the like. I'll admit the learning curve for me was medium-high in getting things started, but afterwards I was able to build a second installer without any hassles. </p>
<p>It will handle updates and other items if you so desire, and you can apply folder permissions and the like to the installers. It also gives you greater control on where exactly you want to install files and is compatible with all the standardized Windows folder conventions, so you can specify "PROGRAM_DATA" or something to that effect and the installer knows to put it in C:\Documents and Settings\All Users\Application Data or C:\ProgramData depending on if you're running XP or Vista.</p>
<p>The rumor is that Office 2007 and Visual Studio 2008 used WiX to create their installer, but I haven't been able to verify that anywhere. I do believe is is developed by some Microsoft folks on the inside.</p>
|
<p>Creating an installer project, with a dependency on your EXE (which in turn depends on whatever it needs) is a fairly straightforward process - but you'll need at least VS Standard Edition for that.</p>
<p>Inside the installer project, you can create custom tasks and dialog steps that allow you to do anything you code up.</p>
<p>What's missing is the auto-upgrade and version-checking magic you get with ClickOnce. You can still build it in, it's just not automatic.</p>
| 2,564
|
<p>I am working to integrate unit testing into the development process on the team I work on and there are some sceptics. What are some good ways to convince the sceptical developers on the team of the value of Unit Testing? In my specific case we would be adding Unit Tests as we add functionality or fixed bugs. Unfortunately our code base does not lend itself to easy testing.</p>
|
<p>Every day in our office there is an exchange which goes something like this:</p>
<blockquote>
<p>"Man, I just love unit tests, I've just been able to make a bunch of changes to the way something works, and then was able to confirm I hadn't broken anything by running the test over it again..."</p>
</blockquote>
<p>The details change daily, but the sentiment doesn't. Unit tests and test-driven development (TDD) have so many hidden and personal benefits as well as the obvious ones that you just can't really explain to somebody until they're doing it themselves. </p>
<p>But, ignoring that, here's my attempt!</p>
<ol>
<li><p>Unit Tests allows you to make big changes to code quickly. You know it works now because you've run the tests, when you make the changes you need to make, you need to get the tests working again. This saves hours. </p></li>
<li><p>TDD helps you to realise when to stop coding. Your tests give you confidence that you've done enough for now and can stop tweaking and move on to the next thing.</p></li>
<li><p>The tests and the code work together to achieve better code. Your code could be bad / buggy. Your TEST could be bad / buggy. In TDD you are banking on the chances of <strong>both</strong> being bad / buggy being low. Often it's the test that needs fixing but that's still a good outcome. </p></li>
<li><p>TDD helps with coding constipation. When faced with a large and daunting piece of work ahead writing the tests will get you moving quickly.</p></li>
<li><p>Unit Tests help you really understand the design of the code you are working on. Instead of writing code to do something, you are starting by outlining all the conditions you are subjecting the code to and what outputs you'd expect from that. </p></li>
<li><p>Unit Tests give you instant visual feedback, we all like the feeling of all those green lights when we've done. It's very satisfying. It's also much easier to pick up where you left off after an interruption because you can see where you got to - that next red light that needs fixing. </p></li>
<li><p>Contrary to popular belief unit testing does not mean writing twice as much code, or coding slower. It's faster and more robust than coding without tests once you've got the hang of it. Test code itself is usually relatively trivial and doesn't add a big overhead to what you're doing. This is one you'll only believe when you're doing it :)</p></li>
<li><p>I think it was Fowler who said: "Imperfect tests, run frequently, are much better than perfect tests that are never written at all". I interpret this as giving me permission to write tests where I think they'll be most useful even if the rest of my code coverage is woefully incomplete.</p></li>
<li><p>Good unit tests can help document and define what something is supposed to do</p></li>
<li><p>Unit tests help with code re-use. Migrate both your code <strong>and</strong> your tests to your new project. Tweak the code till the tests run again.</p></li>
</ol>
<p>A lot of work I'm involved with doesn't Unit Test well (web application user interactions etc.), but even so we're all test infected in this shop, and happiest when we've got our tests tied down. I can't recommend the approach highly enough. </p>
|
<p>Unit testing works for QA guys or your managers, not for you; so it's definitely not worth it.</p>
<p>You should focus on writing correct code (whatever it means), not test cases. Let other guys worry about those.</p>
| 9,286
|
<p>Does anyone ever found/used an ASP.NET application similar to Joomla?<br />
I need to set up a quick and dirty CMS on a Windows Server and our client doesn't want us to use something else than ASP.NET.<br /></p>
|
<p>I've been told by a friend that <a href="http://www.umbraco.org/" rel="nofollow noreferrer">Umbraco</a> is everything you would ever want in a CMS (and it was in the list that Nathan included in his answer). This recommendation is coming from a guy who's built several CMS solutions over the years and after taking a brief look at it, I think I'm going to try to push my clients towards using it over their current solutions.</p>
|
<p>Did you Look at DotNetNuke (<a href="http://www.dotnetnuke.com/" rel="nofollow noreferrer">http://www.dotnetnuke.com/</a>) Its seems to be a good Systems to Start off as a base , But I doubt I could call it a Full CMS ? (Upto the users to decide)</p>
| 2,703
|
<p>I would like to call Perl script files from my c++ program.</p>
<p>I am not sure that the people I will distribute to will have Perl installed.</p>
<p>Basically I'm looking for a .lib file that I can use that has an Apache like distribution license.</p>
|
<p>You can embed perl into your app. </p>
<ul>
<li><a href="http://www.linuxjournal.com/article/2901" rel="noreferrer">Perl Embedding</a> by John Quillan</li>
<li><a href="http://xaxxon.slackworks.com/ep/" rel="noreferrer">C++ wrapper around Perl C API</a></li>
</ul>
|
<p>To call perl from C++ you need to use the API, as someone else mentioned; the basic tutorial is available in the <a href="http://perldoc.perl.org/perlxstut.html" rel="nofollow noreferrer">perlxstut</a> documentation.</p>
<p>Note that you will most probably need more than just a ".lib", because you'll need a lot of tiny modules which are located in the "lib" directory of the perl distrib: strict.pm, etc. That's a not a big deal though, I guess; the apache example you mentioned has the same constraint of delivering some default configuration files etc.</p>
<p>However, to distribute Perl, on Windows (I guess you're on Windows since you mentionned a .lib file), the ActiveState distribution which everyone uses might cause some licensing headache. It's not really clear to me, but it seems like you cannot redistribute ActivePerl in a commercial product. Note that, if you want to embed Perl in a C++ program, you might have to recompile it anyway, to have the same compilation flags on Perl and on your program.</p>
| 7,163
|
<p>I have a Windows XP SP2 virtual machine which can be accessed via VNC. It's also running Deep Freeze so there should be no problem in forcing it to reboot. I am looking for a way to force the operating system to reboot instead of shutting down or completely remove the ability to shut down the machine using software applications (such as the usual way from the start menu, the shutdown program or other custom programs).</p>
<p>Thank you,
Tom</p>
|
<p>Try this:</p>
<p><code>shutdown /r /t 1 /f</code></p>
<p>Alex</p>
|
<p>Try DShutdown.exe. It's flexible and can do all these things.</p>
| 9,983
|
<p>In Prusa i3 clones the Z axis is often problematic. Mechanically unsynchronized dual Z axises which are driven by the same stepper driver easily misalign. Using only one Z motor makes the whole gantry sag on one side. And Z lead screws that aren't perfectly straight lead to z wobble.</p>
<p>The other day I had a simple idea that would fix all of that, but I can't find anyone who implement it before, so I probably there are drawbacks that I don't see.</p>
<p>The idea is to remove the lead screws (possibly replacing it with a second set of smooth rods to counteract X axis vibrations) and instead hang the gantry onto two ropes/wires which are drawn by a winch. That way, both ends of the gantry could be drawn symmetricaly by a single motor. Since there is no Z lead screw, there is no wobble. And since only the gravity is pulling the gantry down, you shouldn't be able to destroy anything by ramming the nozzle into the bed.</p>
<p>What drawbacks are there for this system? What am I missing? Is the gravity strong enough to press the nozzle into the last layer when printing? I am using a direct drive extruder.</p>
<hr />
<p>Supplemental follow up question (related to, and answered by, Trish's answer):</p>
<blockquote>
<p>From my understanding the hangprinter is only attached to ropes, same as a portal crane. I am considering an i3-style printer with the leadscrews removed, but the smooth Z rods intact (maybe even with a second set of smooth rods in place of the leadscrews. So the only forces that gravity has to work against are: output pressure of the extruder and potential bouncing in z direction. So, how could I calculate if gravity is enough for that?</p>
</blockquote>
|
<p>This concept already exists, it is e.g. found in some high quality 3D printers. Instead of a winch, a belt system (of several belts) is used.</p>
<p>An interesting point from <a href="https://3dprinting.stackexchange.com/a/16289/8884">this answer</a> already mentions that a winch isn't a good mechanism to lower/raise the gantry; if the cables are wound over each other the diameter of the wound cables will get larger and thus the movement. This could be circumvented by creating a push pull system and very few windings on the winch.</p>
<p>But, this concept already has been worked out in the <a href="https://vorondesign.com/voron2.4" rel="nofollow noreferrer">VORON 2.4 printer</a> design. This design is based on the work of a group of engineers and is considered to be a high quality printer that is also suitable for professional use. From the following image you can see (on the right side) a belt. This design uses 4 linear rails to support and guide the bed and 4 belts to drive the whole CoreXY gantry up and down.</p>
<p><a href="https://i.stack.imgur.com/w9eqZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w9eqZ.png" alt="enter image description here" /></a></p>
<p>So, a winch will not work, but the type of suspension already exists and is in use.</p>
<hr />
<p>With respect to the i3 style printers and the free gantry movement the following is from my own experience.</p>
<p><em>I've build several i3 style printers of which my latest 2 where all having a freely moving gantry upwards as I decoupled the lead screw from the X mounts. The lead screw nuts simply push the gantry up as they are embedded in a separate part; gravity will pull the gantry down. The mass of the guide rods, a stepper motor and the hotend provide enough mass to pull it down. I've had excellent results with these printers, e.g. mentioned in <a href="https://3dprinting.stackexchange.com/a/16285/">this answer</a>:</em></p>
<blockquote>
<p>poor layer bonding and possibly even collisions between the nozzle and already-printed material, from slight variations in height where extrusion pushes back against gravity</p>
</blockquote>
<p><em>is not encountered. The following images give an impression of the lifting device:</em></p>
<p><a href="https://i.stack.imgur.com/9B8cMm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9B8cMm.jpg" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/PGu4Mm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PGu4Mm.jpg" alt="enter image description here" /></a></p>
|
<p>Unless your gantry is extremely heavy, I don't think this will work. The Z motion system needs to not only lift, but to hold the nozzle rigidly at the desired distance from the bed/previous layer. Otherwise I would expect poor layer bonding and possibly even collisions between the nozzle and already-printed material, from slight variations in height where extrusion pushes back against gravity.</p>
| 1,939
|
<p>I'm writing (in C# with .NET 3.5) an administrative application which will poll multiple Windows systems for various bits of data. In many cases it will use WMI, but in some cases it may need to read remote registry or remotely execute some command or script on the polled system. This polling will happen at repeating intervals - usually nightly, but can be configured to happen more (or less) frequently. So the poll could happen as often as every 10 minutes or as rarely as once a month. It needs to happen in an automated way, without any human intervention.</p>
<p>These functions will require admin-level access to the polled systems. Now, I expect that in most use cases, there will be a domain, and the polling application can run as a service with Domain Admin (or equivalent) privileges, which means I do not have to worry about storing passwords - the admin setting up the app will define the service's username/password via standard Windows mechanisms.</p>
<p>But there's always a few black sheep out there. The program may run in nondomain environments, or in cases where some polled systems are not members of the domain. In these cases we will have to define a username and password, store them securely, then invoke this user/pass pair at the time we poll that system. So keep in mind - in this case the program being written <em>is the user</em> who <em>sends</em> password to the authenticating system. </p>
<p>I am not sure whether I will need to use a reversible hash which I then decrypt to plaintext at time of use, or if there is some Windows mechanism which would allow me to store and then reuse the hash only. Obviously the second mechanism is preferable; I'd like my program to either <em>never</em> know the password's plaintext value, or know it for the shortest amount of time possible.</p>
<p>I need suggestions for smart and secure ways to accomplish this.</p>
<p>Thanks for looking!</p>
|
<p>The answer is here:</p>
<p><a href="https://stackoverflow.com/questions/40853/how-to-store-passwords-in-winforms-application#40867">How to store passwords in Winforms application?</a></p>
|
<p>Well it seems that your program needs to impersonate a user other than the context under which it is already running. Although, it does look like a pretty automated process, but if it's not, can you simply not ask the administrator to put in username and password at the time this 'black-sheep' computer is being polled?</p>
| 6,949
|
<p>Can someone describe what a symbol table is within the context of C and C++?</p>
|
<p>There are two common and related meaning of symbol tables here.</p>
<p>First, there's the symbol table in your object files. Usually, a C or C++ compiler compiles a single source file into an object file with a .obj or .o extension. This contains a collection of executable code and data that the linker can process into a working application or shared library. The object file has a data structure called a symbol table in it that maps the different items in the object file to names that the linker can understand. If you call a function from your code, the compiler doesn't put the final address of the routine in the object file. Instead, it puts a placeholder value into the code and adds a note that tells the linker to look up the reference in the various symbol tables from all the object files it's processing and stick the final location there.</p>
<p>Second, there's also the symbol table in a shared library or DLL. This is produced by the linker and serves to name all the functions and data items that are visible to users of the library. This allows the system to do run-time linking, resolving open references to those names to the location where the library is loaded in memory.</p>
<p>If you want to learn more, I suggest John Levine's excellent book "Linkers and Loaders".<a href="http://books.google.com/books?id=h34d_jr2iikC&dq=levine+linkers+and+loaders&pg=PP1&ots=IxGcKQO03W&sig=dduAcRRhK6E2nMlkTxbNEDpWBTg&hl=en&sa=X&oi=book_result&resnum=1&ct=result" rel="noreferrer">link text</a></p>
|
<p>Symbol table is an important data structure created and maintained by compilers in order to store information about the occurrence of various entities such as variable names, function names, objects, classes, interfaces, etc.</p>
| 9,458
|
<p>I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or something we can't live with but it is preventing us from producing the beautiful XML we would like to produce. </p>
<p>One of the things we do is transform nodes inline and importing nodes from one XML document to another. </p>
<p>Sadly , when you save nodes to an <code>XmlTextWriter</code> (actually whatever <code>XmlWriter.Create(Stream)</code> returns), the namespace definitions get all thrown in there, regardless of it is necessary (previously defined) or not. You get kind of the following xml:</p>
<pre><code><root xmlns:abx="http://bladibla">
<abx:child id="A">
<grandchild id="B">
<abx:grandgrandchild xmlns:abx="http://bladibla" />
</grandchild>
</abx:child>
</root>
</code></pre>
<p>Does anyone have a suggestion as to how to convince .NET to be efficient about its namespace definitions?</p>
<p>PS. As an added bonus I would like to override the default namespace, changing it as I write a node.</p>
|
<p>Use this code:</p>
<pre class="lang-cs prettyprint-override"><code>using (var writer = XmlWriter.Create("file.xml"))
{
const string Ns = "http://bladibla";
const string Prefix = "abx";
writer.WriteStartDocument();
writer.WriteStartElement("root");
// set root namespace
writer.WriteAttributeString("xmlns", Prefix, null, Ns);
writer.WriteStartElement(Prefix, "child", Ns);
writer.WriteAttributeString("id", "A");
writer.WriteStartElement("grandchild");
writer.WriteAttributeString("id", "B");
writer.WriteElementString(Prefix, "grandgrandchild", Ns, null);
// grandchild
writer.WriteEndElement();
// child
writer.WriteEndElement();
// root
writer.WriteEndElement();
writer.WriteEndDocument();
}
</code></pre>
<p>This code produced desired output:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<root xmlns:abx="http://bladibla">
<abx:child id="A">
<grandchild id="B">
<abx:grandgrandchild />
</grandchild>
</abx:child>
</root>
</code></pre>
|
<p>I'm not sure this is what you're looking for, but you can use this kind of code when you start writing to the Xml stream:</p>
<pre><code>myWriter.WriteAttributeString("xmlns", "abx", null, "http://bladibla");
</code></pre>
<p>The XmlWriter should remember it and not rewrite it anymore. It may not be 100% bulletproof, but it works most of the time.</p>
| 4,631
|
<p>I haven't programmed games for about 10 years (My last experience was DJGPP + Allegro), but I thought I'd check out XNA over the weekend to see how it was shaping up.</p>
<p>I am fairly impressed, however as I continue to piece together a game engine, I have a (probably) basic question.</p>
<p>How much should you rely on C#'s Delegates and Events to drive the game? As an application programmer, I use delegates and events heavily, but I don't know if there is a significant overhead to doing so.</p>
<p>In my game engine, I have designed a "chase cam" of sorts, that can be attached to an object and then recalculates its position relative to the object. When the object moves, there are two ways to update the chase cam.</p>
<ul>
<li>Have an "UpdateCameras()" method in the main game loop.</li>
<li>Use an event handler, and have the chase cam subscribe to object.OnMoved.</li>
</ul>
<p>I'm using the latter, because it allows me to chain events together and nicely automate large parts of the engine. Suddenly, what would be huge and complex get dropped down to a handful of 3-5 line event handlers...Its a beauty.</p>
<p>However, if event handlers firing every nanosecond turn out to be a major slowdown, I'll remove it and go with the loop approach.</p>
<p>Ideas?</p>
|
<p>If you were to think of an event as a subscriber list, in your code all you are doing is registering a subscriber. The number of instructions needed to achieve that is likely to be minimal at the CLR level.</p>
<p>If you want your code to be generic or dynamic, then you're need to check if something is subscribed prior to calling an event. The event/delegate mechanism of C# and .NET provides this to you at very little cost (in terms of CPU).</p>
<p>If you're really concerned about every clock cycle, you'd never write generic/dynamic game logic. It's a trade off between maintainable/configurable code and outright speed.</p>
<p>Written well, I'd favour events/delegates until I could prove it is an issue.</p>
<p>The only way you'll truly know if it is an issue for you is by profiling your code -- which you should do anyway for any game development!</p>
|
<p>XNA encourages the use of interfaces, events and delegates to drive something written with it. Take a look at the GameComponent related classes which set this up for you.</p>
<p>The answer is, "As much as you feel comfortable with".</p>
<p>To elaborate a little bit, If for example you take and inherit from the gamecomponent class into a cameracontroller class and add it to the Game.Component collection. Then you can create your camera classes and add them to your cameracontroller. </p>
<p>Doing this will cause the cameracontroller to be called regularly and be able to select and activate the proper camera or multiple cameras if that is what you are going for.</p>
<p>Here is an example of this (All of his tutorials are excellent):
<a href="http://roecode.wordpress.com/2008/02/11/xna-framework-gameengine-development-part-10-cameramanager-gamecomponents/" rel="nofollow noreferrer">ReoCode</a></p>
| 8,942
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.