instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>What fonts do you use for programming, and for what language/IDE? I use <a href="http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&amp;displaylang=en" rel="nofollow noreferrer" title="Consolas">Consolas</a> for all my Visual Studio work, any other recommendations?</p>
<p>Either Consolas <a href="http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&amp;displaylang=en">(download)</a> or Andale Mono <a href="http://prdownloads.sourceforge.net/corefonts/andale32.exe?download">(download)</a>. I mostly use Andale Mono. I wrote an article about programming fonts <a href="http://www.deadprogrammer.com/the-programmers-font">a long time ago</a>, I think Consolas wasn't even out yet.</p> <p><a href="http://www.deadprogrammer.com/photos/fonts.gif">http://www.deadprogrammer.com/photos/fonts.gif</a></p> <p>I find that typing <code>Illegal1 = O0</code> is a good test of suitability.</p>
<p>Any sans-serif.</p>
2,672
<p>I have a very simple WPF application in which I am using data binding to allow editing of some custom CLR objects. I am now wanting to put some input validation in when the user clicks save. However, all the WPF books I have read don't really devote any space to this issue. I see that you can create custom ValidationRules, but I am wondering if this would be overkill for my needs.</p> <p>So my question is this: is there a good sample application or article somewhere that demonstrates best practice for validating user input in WPF?</p>
<p>I think the new preferred way might be to use IDataErrorInfo</p> <p>Read more <a href="http://blogs.msdn.com/wpfsdk/archive/2007/10/02/data-validation-in-3-5.aspx" rel="noreferrer">here</a></p>
<p>If your business class is directly used by your UI is preferrable to use IDataErrorInfo because it put logic closer to their owner.</p> <p>If your business class is a stub class created by a reference to an WCF/XmlWeb service then you can not/must not use IDataErrorInfo nor throw Exception for use with ExceptionValidationRule. Instead you can:</p> <ul> <li>Use custom ValidationRule.</li> <li>Define a partial class in your WPF UI project and implements IDataErrorInfo.</li> </ul>
8,905
<p>We know from <a href="https://3dprinting.stackexchange.com/a/183/11242">this answer</a>, 3d printed materials continue to outgas after printing and being cured. My question relates to this:</p> <ul> <li>How much does heating the printed object after printing (or being cured) affect out-gassing? </li> <li>Does the continued out-gassing degrade the stability/quality of the print?</li> </ul>
<p>This is not an answer to your question, but it relates to outgassing so I am sharing it here. </p> <p>I have used the acetone vapor method of smoothing the surface of ABS prints. It works really well, and the surface becomes much smoother and glassy. I printed a large coffee mug (lets, for the moment, ignore food safety issues) and made it very smooth.</p> <p>After a couple of weeks to allow the acetone to fully evaporate, I poured a nice, hot cup of tea. Unfortunately, the acetone had not fully left the print, and the surface was immediately covered with dozens of bubbles as the acetone evaporated and pushed against the ABS.</p> <p>This effect was only because of the acetone. Another cup that had not been vapor smoothed worked perfectly and was unaffected by the hot water.</p> <p>I have not seen similar outgassing from PLA, ABS, Nylon, or PETG.</p> <p>If I may hazard an opinion about the substance of your question...</p> <p>I don't think that outgassing is the biggest contributor to the aging of prints and their properties changing. I suspect that (perhaps not in order) these are larger factors:</p> <ol> <li>exposure to UV light. UV light breaks polymer bonds and reduces the strength of plastic. </li> <li>absorption of water vapor, which can both expand the material which causes stress, and chemically break polymer bonds.</li> <li>long-term crystallization of the material</li> <li>fatigue from repeated sub-failure stress</li> </ol> <p>NASA used to have resources that spoke to outgassing rates related to suitability for space applications.</p>
<p>The effect of temperature on outgas rates is a subject for Engineering.SE . As to continued outgassing - depends on the material in question. To pick an extreme example, solid CO2 (dry ice) will outgas until it's gone. But stuff that's got VOCs is expected to outgas; said volatiles leave by design and the remaining material stands on its own. </p>
982
<p>I'm looking to create a dashboard type gui for a web application. I'm looking for the user to be able to drag and drop different elements (probably either image buttons, anchor tags, or maybe just divs) to different (defined) places and be able to save their setup (in a cookie or on the server). I'm working with c# in the .Net 2.0 framework. I've tried using mootools but their recent update has left their drag/drop capabilities un-useful for me. I'm looking for a bit of direction because I know there is something out there that is just what I'm looking for so I wont have to build from scratch.</p> <p>Thanks.</p>
<p>I have been looking at this kind of functionality myself recently and have decided on using jQuery with the help of <a href="http://ui.jquery.com/" rel="noreferrer">jQuery UI</a>. I came across a large amount of information that also suggested <a href="http://developer.yahoo.com/yui/" rel="noreferrer">Yahoo UI</a> (YUI), I had already started learning <a href="http://jQuery.com" rel="noreferrer">jQuery</a> due to the AJAX support that it offers, so I stuck with it.</p> <p><a href="http://ui.jquery.com/" rel="noreferrer">jQuery UI Site</a><br/> <a href="http://docs.jquery.com/UI" rel="noreferrer">jQuery UI Documentation</a><br/> <a href="http://ui.jquery.com/repository/real-world/layout/" rel="noreferrer">Example of a drag and drop screen layout with jQuery UI</a><br/> <a href="http://www.learningjquery.com/2008/07/introduction-to-jquery-ui#" rel="noreferrer">Introduction to jQuery UI</a></p> <p>If you decide to use the YUI javascript library, here is a link to a vast amount of videos to help get you started.</p> <p><a href="http://developer.yahoo.com/yui/theater/" rel="noreferrer">http://developer.yahoo.com/yui/theater/</a></p>
<p>I used the Microsoft ASP.Net Ajax and AjaxControlToolkit to do something like this. They have a ResizeableControl and a DragPanel. I used these, then hosted an IFrame inside the panel to display the content.</p> <p>Worked pretty well.</p> <hr> <p>This site:</p> <p><a href="http://www.asp.net/learn/videos/default.aspx?tabid=63#ajax" rel="nofollow noreferrer">http://www.asp.net/learn/videos/default.aspx?tabid=63#ajax</a></p> <p>Has lots of tutorial videos that show you how to get started using the controls.</p>
3,694
<p>I'm trying to customize some TFS work items via the VS2008 xml editor, but every time I open a work item xml file it jumps to the graphical designer. All that gives me is a "View XML" button that doesn't let you edit the xml directly.</p>
<p>I don't have TFS but I know in regular VS there is an Open With... option in most items' contextual menu that even let you change the default editor. Very useful when you are tired of the Designer opening instead of the Code file on Windows forms.</p>
<p>As per Coincoin's answer, this feature is also great for setting the default editor for ASPX. If you want to go to the Code Editor most often, then this is a default you'd want to change.</p>
2,796
<p>I'm trying to provide a link to my company's website from a Windows Form. I want to be well behaved and launch using the user's preferred browser.</p> <p>What is the best way to open a URL in the user's default browser from a Windows Forms application?</p>
<p>This <a href="http://support.microsoft.com/kb/320478" rel="noreferrer">article</a> will walk you through it.</p> <p>Short answer:</p> <pre><code>ProcessStartInfo sInfo = new ProcessStartInfo("http://mysite.com/"); Process.Start(sInfo); </code></pre>
<p>The above approach is perfect, I would like to recommend this approach to where you can pass your parameters.</p> <pre><code>Process mypr; mypr = Process.Start("iexplore.exe", "pass the name of website"); </code></pre>
8,246
<p>I'm quite used to my IDE setup in Delphi 7, where I have my comments rendered in italics.</p> <p>This doesn't appear to be possible in VS2008. There's only an option for bold font, not italics.</p> <p>Is there some kind of registry hack or font magic I can perform to get it to work? The font I'm using is Consolas, if that makes a difference.</p> <p><strong>Edit:</strong> This is possible. See <a href="https://stackoverflow.com/questions/17508/how-to-modify-the-style-property-of-a-font-on-windows#25676">this</a> answer for details.</p> <hr> <p>Adam, as far as I can tell, you can't change the font name for just comments - only the colour, and boldness. If I'm wrong, please tell me!</p>
<p>If you have a font editor, you can change an italic font to pretend it's bold. <a href="http://damieng.com/blog/2007/07/11/italic-syntax-highlighting-in-visual-studio-2005" rel="nofollow noreferrer">Here's an example of it.</a> (For VS 2005, but it should work all the same.)</p>
<p>Unfortunately not...not sure why they don't let you do that.</p> <p>You can, however, change the font for just comments. So you could make it something different which will make it stand out more.</p> <p>You may even be able to make a custom version of the font you use that is by default italic and then set that as the comment font.</p>
3,625
<p>I'm convinced from <a href="http://www.masukomi.org/talks/unit_testing_talk_2/index.xul?data=slide_data.txt#page2" rel="nofollow noreferrer">this presentation</a> and other commentary here on the site that I need to learn to Unit Test. I also realize that there have been many questions about what unit testing is here. Each time I go to consider how it should be done in the application I am currently working on, I walk away confused. It is a xulrunner application application, and a lot of the logic is event-based - when a user clicks here, this action takes place.</p> <p>Often the examples I see for testing are testing classes - they instantiate an object, give it mock data, then check the properties of the object afterward. That makes sense to me - but what about the non-object-oriented pieces?</p> <p><a href="https://stackoverflow.com/questions/2364/what-is-your-experience-with-unit-testing-in-practice#2390">This guy mentioned</a> that GUI-based unit testing is difficult in most any testing framework, maybe that's the problem. The presentation linked above mentions that each test should only touch one class, one method at a time. That seems to rule out what I'm trying to do.</p> <p>So the question - how does one unit testing procedural or event-based code? Provide a link to good documentation, or explain it yourself.</p> <p>On a side note, I also have a challenge of not having found a testing framework that is set up to test xulrunner apps - it seems that the tools just aren't developed yet. I imagine this is more peripheral than my understanding the concepts, writing testable code, applying unit testing.</p>
<p>The idea of unit testing is to test small sections of code with each test. In an event based system, one form of unit testing you could do, would be to test how your event handlers respond to various events. So your unit test might set an aspect of your program into a specific state, then call the event listener method directly, and finally test the subsequent state of of your program. </p> <p>If you plan on unit testing an event-based system, you will make your life a lot easier for yourself if you use the dependency injection pattern and ideally would go the whole way and use inversion of control (see <a href="http://martinfowler.com/articles/injection.html" rel="nofollow noreferrer">http://martinfowler.com/articles/injection.html</a> and <a href="http://msdn.microsoft.com/en-us/library/aa973811.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa973811.aspx</a> for details of these patterns)</p> <p>(thanks to pc1oad1etter for pointing out I'd messed up the links)</p>
<p>An approach I've found helpful for procedural code is to use TextTest. It's not so much about unit testing, but it helps you do automated regression testing. The idea is that you have your application write a log then use texttest to compare the log before and after your changes. </p>
9,874
<p>I print on a glass bed covered with BuildTak. Prints stick well, release is difficult. They sell a mod, self adhesive magnetic sheet that holds a steel plate which in turn you put the BuildTak on making it easier to get your prints off by twisting the flexible steel as opposed to chiseling your print off a glass plate while attempting to not peel chunks of the expensive Buildtak off.</p> <p>Magnetic sheets have different strengths proportional to thickness in milimeters. I can get 0.03 mm locally which provides 85 lbs pull per sqft. and was wondering if this might work. It's hard to find the stronger pulls, 0.045 mm and 0.06 mm which can pull 115 and 145 lbs respectively.</p> <p>I'd prefer cut my own new bed sandwich rather than pay 90 bucks for one. </p> <ul> <li>Has anyone made a bed using adhesive magnetic sheet> </li> <li>What thickness magnetic sheet has worked for you? </li> <li>What thickness steel are you using? </li> </ul> <p>Assume it has to flex easily to twist the part of and also flexible enough for the magnet to pull it flat.</p> <hr> <p>With respect to <a href="https://3dprinting.stackexchange.com/questions/3493/bed-design-for-easy-release-pla#comment4773_3493">the comment</a> by tbm0115:</p> <blockquote> <p>I don't think you need that much magnetic pull for this application. Adhering basic coin magnets to a material in a large array should secure the material appropriately for a desktop printer.</p> </blockquote> <p>I see where you are going with coin magnets. Have you tried this? In the original Makerbot Cupcake this is how it was done though with larger build surfaces you get warp on metal plates. Most metal sheet comes from the plant on a roll. Though your metal looks nice and flat, temperature changes will cause it to warp and as you know with SLA printers, a changing bed can cause a failure. This happened on the original Makerbot replicator 1st release followed by using a machined plate as a replacement.</p>
<p>Follow up:</p> <p>I used the 6mil magnet, cut a sheet of thin steel, (about .5mm) to fit, added a layer of Buildtak and now it's much easier to remove prints, build surface is very flat. I assume you could deform the metal beyond the magnet's ability to flatten it but it works quite well. The metal was cut with sheet metal snips, risky as they can bend the sheet. Probably better done with a saw though.</p>
<p>Try using buildtak flex. <a href="https://www.buildtak.com/product/flexplate/" rel="nofollow noreferrer">https://www.buildtak.com/product/flexplate/</a></p> <p>or cheaper alternatives: <a href="http://www.printinz.com/printinz-plate-3d-printer-bed-upgrade/" rel="nofollow noreferrer">http://www.printinz.com/printinz-plate-3d-printer-bed-upgrade/</a> </p>
504
<p>The Interface Segregation Principle (ISP) says that many client specific interfaces are better than one general purpose interface. Why is this important?</p>
<p>ISP states that:</p> <blockquote> <p>Clients should not be forced to depend on methods that they do not use.</p> </blockquote> <p>ISP relates to important characteristics - <a href="http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29" rel="noreferrer">cohesion</a> and <a href="http://en.wikipedia.org/wiki/Coupling_%28computer_science%29" rel="noreferrer">coupling</a>.<br> Ideally your components must be highly tailored. It improves code robustness and maintainability. </p> <p>Enforcing ISP gives you following bonuses:</p> <ul> <li>High <a href="http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29" rel="noreferrer">cohesion</a> - better understandability, robustness</li> <li>Low <a href="http://en.wikipedia.org/wiki/Coupling_%28computer_science%29" rel="noreferrer">coupling</a> - better maintainability, high resistance to changes</li> </ul> <p>If you want to learn more about software design principles, get a copy of <a href="https://rads.stackoverflow.com/amzn/click/com/0135974445" rel="noreferrer" rel="nofollow noreferrer">Agile Software Development, Principles, Patterns, and Practices</a> book.</p>
<p>One reason is that having many interfaces with a minimal amount of methods for each one makes it easier to implement each interface and to implement them correctly. A large interface can be unruly. Also, using a focused interface in a scenario makes the code more maintanable because you can see which facet of the object is being used (e.g., an IComparable interface lets you know that the object is only being used for comparisons in the given scenario). </p>
8,344
<p>Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code. </p> <p>Basically my unit test needs to read some xml test files which are located relative to the dll. I want the path to always resolve correctly regardless of whether the testing dll is run from TestDriven.NET, the MbUnit GUI or something else.</p> <p><strong>Edit</strong>: People seem to be misunderstanding what I'm asking.</p> <p>My test library is located in say </p> <blockquote> <p>C:\projects\myapplication\daotests\bin\Debug\daotests.dll</p> </blockquote> <p>and I would like to get this path:</p> <blockquote> <p>C:\projects\myapplication\daotests\bin\Debug\</p> </blockquote> <p>The three suggestions so far fail me when I run from the MbUnit Gui:</p> <ul> <li><p><code>Environment.CurrentDirectory</code> gives <em>c:\Program Files\MbUnit</em></p></li> <li><p><code>System.Reflection.Assembly.GetAssembly(typeof(DaoTests)).Location</code> gives <em>C:\Documents and Settings\george\Local Settings\Temp\ ....\DaoTests.dll</em></p></li> <li><p><code>System.Reflection.Assembly.GetExecutingAssembly().Location</code> gives the same as the previous.</p></li> </ul>
<p><strong>Note</strong>: Assembly.CodeBase is deprecated in .NET Core/.NET 5+: <a href="https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.codebase?view=net-5.0" rel="noreferrer">https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.codebase?view=net-5.0</a></p> <p><strong>Original answer:</strong></p> <p>I've defined the following property as we use this often in unit testing.</p> <pre><code>public static string AssemblyDirectory { get { string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); return Path.GetDirectoryName(path); } } </code></pre> <p>The <code>Assembly.Location</code> property sometimes gives you some funny results when using NUnit (where assemblies run from a temporary folder), so I prefer to use <code>CodeBase</code> which gives you the path in URI format, then <code>UriBuild.UnescapeDataString</code> removes the <code>File://</code> at the beginning, and <code>GetDirectoryName</code> changes it to the normal windows format.</p>
<p>I use this to get the path to the Bin Directory:</p> <pre><code>var i = Environment.CurrentDirectory.LastIndexOf(@"\"); var path = Environment.CurrentDirectory.Substring(0,i); </code></pre> <p>You get this result:</p> <blockquote> <p>"c:\users\ricooley\documents\visual studio 2010\Projects\Windows_Test_Project\Windows_Test_Project\bin"</p> </blockquote>
7,611
<p>I want to extend a WPF application with database functionality. Which database engine would you suggest and why? SQLite, SQL CE, other?</p>
<p>Depending on the applications use, <strong>I would recommend using SQL Lite</strong> because it doesn't require you to install any other software (SQL CE or Express, etc. usually would require a separate install).</p> <p>A list of the most important benefits for SQL Lite from the provider link at the bottom of this post:</p> <blockquote> <p>SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine. Features include:</p> <ul> <li>Zero-configuration - no setup or administration needed.</li> <li>Implements most of SQL92. (Features not supported)</li> <li>A complete database is stored in a single disk file.</li> <li>Database files can be freely shared between machines with different byte orders.</li> <li>Supports databases up to 2 terabytes (2^41 bytes) in size.</li> <li>Small code footprint: less than 30K lines of C code, less than 250KB code space (gcc on i486)</li> <li>Faster than popular client/server database engines for most common operations.</li> <li>Simple, easy to use API.</li> <li>Self-contained: no external dependencies.</li> <li>Sources are in the public domain. Use for any purpose.</li> </ul> </blockquote> <p>Since you're using WPF I can assume you're using at least .NET 3.0. I would then recommend going to .NET 3.5 SP1 (sames size as .NET 3.5 but includes a bunch of performance improvements) which includes LINQ.</p> <p>When using SQLite, however, you would want to use the following SQLite Provider which should provide LINQ support: <a href="http://sqlite.phxsoftware.com/" rel="noreferrer">An open source ADO.NET provider for the SQLite database engine</a></p>
<p>I would agree that SQLite is the way to go. Subsonic 2.1 now includes SQLite support as well.</p>
9,271
<p>I bought an Ender 3 two days ago and assembled it today. I think I did it properly, tested the movement of all axes which works for all axes. Then I performed the calibration as described in the manual. I used a piece of paper and adjusted the bed until it barely fits underneath the nozzle for all four corners. Afterwards, I wanted to print my first model so I selected the cat from the usb stick which came with printer. And now comes my problem. I let the printer run for 15 minutes. It moved and moved and moved but there was no filament on the bed. The nozzle and bed were heated properly. The one thing which I noticed was that the stepper which feeds the filament turns for like 30° and then flips back: to me it looks like the filament can not be fed in. After canceling the print the extruder moves back to the home position which is like 5 mm off the bed and then suddenly the filament flows out of the nozzle.</p> <p>What part of the configuration I'm missing?</p>
<p>I am a fairly new user of an Ender 3 and had similar issues on a couple of occasions.</p> <p>The main reason was as @0scar suggested - the nozzle was too close to the build plate preventing the filament from exiting - and the back-pressure was causing the filament to jump back, giving the extruder a "shudder" as it slips on the filament. Lower your build plate as suggested by @0scar. The paper should only just drag.</p> <p>The fact that filament oozes after the hot end/print heads moves to home suggests you don't have a blockage... but you will if you don't adjust this.</p> <p>It is better to have the nozzle slightly too high, so the first level does not stick and gradually raise the bed up while you are running the test patterns. Only turn the adjustment knob about 1/8 of a turn before checking - you are dealing in tenths of a millimeter here. Also remember that changing the front setting is going to change the back settings too because the plate will tilt. </p>
<p>I use Cura on my Anycubic Chiron which I encountered a similar problem with and I was able to resolve the issue by preheating the nozzle to a higher temp. I would test the nozzle and make sure it is feeding properly. What I mean by that is load the filament manually and make sure it comes out. Reason I say this is because the other issue you may be running into is either the nozzle is clogged or it may be too close to the bed for it to come out of the nozzle. This is all speculation but hopefully it helps. </p>
1,537
<p>I worked on an embedded system this summer written in straight C. It was an existing project that the company I work for had taken over. I have become quite accustomed to writing unit tests in Java using JUnit but was at a loss as to the best way to write unit tests for existing code (which needed refactoring) as well as new code added to the system.</p> <p>Are there any projects out there that make unit testing plain C code as easy as unit testing Java code with JUnit? Any insight that would apply specifically to embedded development (cross-compiling to arm-linux platform) would be greatly appreciated.</p>
<p>One unit testing framework in C is <a href="https://libcheck.github.io/check/" rel="noreferrer">Check</a>; a list of unit testing frameworks in C can be found <a href="http://check.sourceforge.net/doc/check_html/check_2.html#SEC3" rel="noreferrer">here</a> and is reproduced below. Depending on how many standard library functions your runtime has, you may or not be able to use one of those.</p> <blockquote> <h3>AceUnit</h3> <p>AceUnit (Advanced C and Embedded Unit) bills itself as a comfortable C code unit test framework. It tries to mimick JUnit 4.x and includes reflection-like capabilities. AceUnit can be used in resource constraint environments, e.g. embedded software development, and importantly it runs fine in environments where you cannot include a single standard header file and cannot invoke a single standard C function from the ANSI / ISO C libraries. It also has a Windows port. It does not use forks to trap signals, although the authors have expressed interest in adding such a feature. See the <a href="http://aceunit.sourceforge.net/" rel="noreferrer">AceUnit homepage</a>.</p> <h3>GNU Autounit</h3> <p>Much along the same lines as Check, including forking to run unit tests in a separate address space (in fact, the original author of Check borrowed the idea from GNU Autounit). GNU Autounit uses GLib extensively, which means that linking and such need special options, but this may not be a big problem to you, especially if you are already using GTK or GLib. See the <a href="http://autounit.tigris.org/" rel="noreferrer">GNU Autounit homepage</a>.</p> <h3>cUnit</h3> <p>Also uses GLib, but does not fork to protect the address space of unit tests.</p> <h3>CUnit</h3> <p>Standard C, with plans for a Win32 GUI implementation. Does not currently fork or otherwise protect the address space of unit tests. In early development. See the <a href="http://cunit.sourceforge.net/" rel="noreferrer">CUnit homepage</a>.</p> <h3>CuTest</h3> <p>A simple framework with just one .c and one .h file that you drop into your source tree. See the <a href="http://cutest.sourceforge.net/" rel="noreferrer">CuTest homepage</a>.</p> <h3>CppUnit</h3> <p>The premier unit testing framework for C++; you can also use it to test C code. It is stable, actively developed, and has a GUI interface. The primary reasons not to use CppUnit for C are first that it is quite big, and second you have to write your tests in C++, which means you need a C++ compiler. If these don’t sound like concerns, it is definitely worth considering, along with other C++ unit testing frameworks. See the <a href="http://cppunit.sourceforge.net/doc/cvs/index.html" rel="noreferrer">CppUnit homepage</a>.</p> <h3>embUnit</h3> <p>embUnit (Embedded Unit) is another unit test framework for embedded systems. This one appears to be superseded by AceUnit. <a href="http://sourceforge.net/projects/embunit/" rel="noreferrer">Embedded Unit homepage</a>.</p> <h3>MinUnit</h3> <p>A minimal set of macros and that’s it! The point is to show how easy it is to unit test your code. See the <a href="http://www.jera.com/techinfo/jtns/jtn002.html" rel="noreferrer">MinUnit homepage</a>.</p> <h3>CUnit for Mr. Ando</h3> <p>A CUnit implementation that is fairly new, and apparently still in early development. See the <a href="http://park.ruru.ne.jp/ando/work/CUnitForAndo/html/" rel="noreferrer">CUnit for Mr. Ando homepage</a>.</p> <p><em>This list was last updated in March 2008.</em></p> </blockquote> <h2>More frameworks:</h2> <h3>CMocka</h3> <p>CMocka is a test framework for C with support for mock objects. It's easy to use and setup.</p> <p>See <a href="https://cmocka.org/" rel="noreferrer">the CMocka homepage</a>.</p> <h3>Criterion</h3> <p>Criterion is a cross-platform C unit testing framework supporting automatic test registration, parameterized tests, theories, and that can output to multiple formats, including TAP and JUnit XML. Each test is run in its own process, so signals and crashes can be reported or tested if needed.</p> <p>See the <a href="https://github.com/Snaipe/Criterion" rel="noreferrer">Criterion homepage</a> for more information.</p> <h3>HWUT</h3> <p>HWUT is a general Unit Test tool with great support for C. It can help to create Makefiles, generate massive test cases coded in minimal 'iteration tables', walk along state machines, generate C-stubs and more. The general approach is pretty unique: Verdicts are based on 'good stdout/bad stdout'. The comparison function, though, is flexible. Thus, any type of script may be used for checking. It may be applied to any language that can produce standard output.</p> <p>See <a href="http://hwut.sourceforge.net/" rel="noreferrer">the HWUT homepage</a>.</p> <h3>CGreen</h3> <p>A modern, portable, cross-language unit testing and mocking framework for C and C++. It offers an optional BDD notation, a mocking library, the ability to run it in a single process (to make debugging easier). A test runner which discover automatically the test functions is available. But you can create your own programmatically.</p> <p>All those features (and more) are explained in <a href="https://cgreen-devs.github.io/" rel="noreferrer">the CGreen manual</a>.</p> <p>Wikipedia gives a detailed list of C unit testing frameworks under <a href="https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C" rel="noreferrer">List of unit testing frameworks: C</a></p>
<p>In case you are targeting Win32 platforms or NT kernel mode, you should have a look at <a href="http://cfix.sf.net/" rel="nofollow noreferrer">cfix</a>.</p>
9,149
<p>Singletons are a hotly debated design pattern, so I am interested in what the Stack Overflow community thought about them.</p> <p>Please provide reasons for your opinions, not just "Singletons are for lazy programmers!"</p> <p>Here is a fairly good article on the issue, although it is against the use of Singletons: <a href="http://web.archive.org/web/20090303174418/http://scientificninja.com/advice/performant-singletons" rel="nofollow noreferrer">scientificninja.com: performant-singletons</a>.</p> <p>Does anyone have any other good articles on them? Maybe in support of Singletons?</p>
<p>In defense of singletons:</p> <ul> <li><strong>They are not as bad as globals</strong> because globals have no standard-enforced initialization order, and you could easily see nondeterministic bugs due to naive or unexpected dependency orders. Singletons (assuming they're allocated on the heap) are created after all globals, and in a very predictable place in the code.</li> <li><strong>They're very useful for resource-lazy / -caching systems</strong> such as an interface to a slow I/O device. If you intelligently build a singleton interface to a slow device, and no one ever calls it, you won't waste any time. If another piece of code calls it from multiple places, your singleton can optimize caching for both simultaneously, and avoid any double look-ups. You can also easily avoid any deadlock condition on the singleton-controlled resource.</li> </ul> <p>Against singletons:</p> <ul> <li><strong>In C++, there's no nice way to auto-clean-up after singletons.</strong> There are work-arounds, and slightly hacky ways to do it, but there's just no simple, universal way to make sure your singleton's destructor is always called. This isn't so terrible memory-wise -- just think of it as more global variables, for this purpose. But it can be bad if your singleton allocates other resources (e.g. locks some files) and doesn't release them.</li> </ul> <p>My own opinion:</p> <p>I use singletons, but avoid them if there's a reasonable alternative. This has worked well for me so far, and I have found them to be testable, although slightly more work to test.</p>
<p>I really disagree on the <em>bunch of global variables in a fancy dress</em> idea. Singletons are really useful when used to solve the right problem. Let me give you a real example.</p> <p>I once developed a small piece of software to a place I worked, and some forms had to use some info about the company, its employees, services and prices. At its first version, the system kept loading that data from the database every time a form was opened. Of course, I soon realized this approach was not the best one.</p> <p>Then I created a singleton class, named <em>company</em>, which encapsulated everything about the place, and it was completely filled with data by the time the system was opened.</p> <p>It was not just a bunch of variables in a fancy dress because this was had dozens of responsibilities, like communicating with persistence layer to save/retrieve data about the company, deal with employees and prices collections, etc.</p> <p>Plus, it was a fixed, system-wide, easily accessible point to have the company data.</p>
3,295
<p>We're in the process of setting up a new framework and way of doing business for our new internal apps. Our current design dictates that all security logic should be handled by our database, and all information (and I mean all) will be going in and out of the database via stored procedures.</p> <p>The theory is, the data access layer requests info from a stored procedure and passes over authentication to the database. The database determines the user's role/permissions and decides whether or not to perform the task (whether that be retrieving data or making an update).</p> <p>I guess this means fewer database transactions. One call to the database. If the security was in our data access layer, this would require 1 database call to determine if the user had proper permissions, and then 1 separate database call to perform the action.</p> <p>I, for one, find the SQL Management studio completely lacking as an IDE. My main concern is we will end up having to maintain some nasty amount of business logic in our stored procedures for some very minimal performance gains.</p> <p>Right now, we're using LINQ for our ORM. It seems light and fast, but best of all, its really easy to rapidly develop in.</p> <p>Is the maintenance cost worth the performance gain? Are we fooling ourselves into thinking there will even be a noticeable performance gain? Or are we just making a nightmare for ourselves?</p> <p>Our environment:</p> <ul> <li>Internal, non-mission critical business apps</li> <li>C#/ASP.NET 3.5</li> <li>Windows 2003</li> <li>MS SQL Server 2005</li> <li>35 Medium sized web apps with approx 500 users</li> </ul>
<p><strong>Don't do that</strong>. We recently had a <strong>VERY BAD</strong> experience when the "database guru" decided to go to another company. The maintenance of all the logic in the procedures are just horrible!!</p> <p>Yes, you're going to have some performance improvement, but that's not worth it. In fact, performance is not even a big concern in internal application. Invest more money in good servers. It'll pay off.</p>
<p>My opinion is that the application itself should handle authentication and authorisation. On the database side you should only handle encryption of data as needed.</p>
7,967
<p>I have a WCF application that has two Services that I am trying to host in a single Windows Service using net.tcp. I can run either of the services just fine, but as soon as I try to put them both in the Windows Service only the first one loads up. I have determined that the second services ctor is being called but the OnStart never fires. This tells me that WCF is finding something wrong with loading up that second service.</p> <p>Using net.tcp I know I need to turn on port sharing and start the port sharing service on the server. This all seems to be working properly. I have tried putting the services on different tcp ports and still no success.</p> <p>My service installer class looks like this:</p> <pre><code> [RunInstaller(true)] public class ProjectInstaller : Installer { private ServiceProcessInstaller _process; private ServiceInstaller _serviceAdmin; private ServiceInstaller _servicePrint; public ProjectInstaller() { _process = new ServiceProcessInstaller(); _process.Account = ServiceAccount.LocalSystem; _servicePrint = new ServiceInstaller(); _servicePrint.ServiceName = "PrintingService"; _servicePrint.StartType = ServiceStartMode.Automatic; _serviceAdmin = new ServiceInstaller(); _serviceAdmin.ServiceName = "PrintingAdminService"; _serviceAdmin.StartType = ServiceStartMode.Automatic; Installers.AddRange(new Installer[] { _process, _servicePrint, _serviceAdmin }); } } </code></pre> <p>and both services looking very similar</p> <pre><code> class PrintService : ServiceBase { public ServiceHost _host = null; public PrintService() { ServiceName = "PCTSPrintingService"; CanStop = true; AutoLog = true; } protected override void OnStart(string[] args) { if (_host != null) _host.Close(); _host = new ServiceHost(typeof(Printing.ServiceImplementation.PrintingService)); _host.Faulted += host_Faulted; _host.Open(); } } </code></pre>
<p>Base your service on this <a href="http://msdn.microsoft.com/en-us/library/ms733069.aspx" rel="nofollow noreferrer">MSDN article</a> and create two service hosts. But instead of actually calling each service host directly, you can break it out to as many classes as you want which defines each service you want to run:</p> <pre><code>internal class MyWCFService1 { internal static System.ServiceModel.ServiceHost serviceHost = null; internal static void StartService() { if (serviceHost != null) { serviceHost.Close(); } // Instantiate new ServiceHost. serviceHost = new System.ServiceModel.ServiceHost(typeof(MyService1)); // Open myServiceHost. serviceHost.Open(); } internal static void StopService() { if (serviceHost != null) { serviceHost.Close(); serviceHost = null; } } }; </code></pre> <p>In the body of the windows service host, call the different classes:</p> <pre><code> // Start the Windows service. protected override void OnStart( string[] args ) { // Call all the set up WCF services... MyWCFService1.StartService(); //MyWCFService2.StartService(); //MyWCFService3.StartService(); } </code></pre> <p>Then you can add as many WCF services as you like to one windows service host.</p> <p>REMEBER to call the stop methods as well....</p>
<p>you probably just need 2 service hosts.</p> <p>_host1 and _host2.</p>
7,803
<p>I am using SQL Server 2000 and I have two databases that both replicate (transactional push subscription) to a single database. I need to know which database the records came from.</p> <p>So I want to add a fixed column specified in the publication to my table so I can tell which database the row originated from.</p> <p>How do I go about doing this?</p> <p>I would like to avoid altering the main databases mostly due to the fact there are many tables I would need to do this to. I was hoping for some built in feature of replication that would do this for me some where. Other than that I would go with the view idea.</p>
<p>You could use a calculated column Use the following on the two databases:</p> <pre><code> ALTER TABLE TableName ADD MyColumn AS 'Server1' </code></pre> <p>Then just define the single "master" database to use a VARCHAR column (or whatever you want) that you fill using the calculated columns value.</p>
<p>You can create a view, which adds the "constant" column, and use it as a replication source.</p>
8,969
<p>My master branch layout is like this:</p> <p><strong>/</strong> &lt;-- top level</p> <p><strong>/client</strong> &lt;-- desktop client source files</p> <p><strong>/server</strong> &lt;-- Rails app</p> <p>What I'd like to do is only pull down the /server directory in my <code>deploy.rb</code>, but I can't seem to find any way to do that. The /client directory is huge, so setting up a hook to copy /server to / won't work very well, it needs to only pull down the Rails app.</p>
<p>Without any dirty forking action but even dirtier !</p> <p>In my config/deploy.rb :</p> <pre><code>set :deploy_subdir, "project/subdir" </code></pre> <p>Then I added this new strategy to my Capfile :</p> <pre><code>require 'capistrano/recipes/deploy/strategy/remote_cache' class RemoteCacheSubdir &lt; Capistrano::Deploy::Strategy::RemoteCache private def repository_cache_subdir if configuration[:deploy_subdir] then File.join(repository_cache, configuration[:deploy_subdir]) else repository_cache end end def copy_repository_cache logger.trace "copying the cached version to #{configuration[:release_path]}" if copy_exclude.empty? run "cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} &amp;&amp; #{mark}" else exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ') run "rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} &amp;&amp; #{mark}" end end end set :strategy, RemoteCacheSubdir.new(self) </code></pre>
<p>Looks like it's also not working with codebasehq.com so I ended up making capistrano tasks that cleans the mess :-) Maybe there's actually a less hacky way of doing this by overriding some capistrano tasks...</p>
4,886
<p>I've been asked to screen some candidates for a MySQL DBA / Developer position for a role that requires an enterprise level skill set.</p> <p>I myself am a SQL Server person so I know what I would be looking for from that point of view with regards to scalability / design etc but is there anything specific I should be asking with regards to MySQL?</p> <p>I would ideally like to ask them about enterprise level features of MySQL that they would typically only use when working on a big database. Need to separate out the enterprise developers from the home / small website kind of guys.</p> <p>Thanks.</p>
<p>Although SQL Server and MySQL are both RDBMs, MySQL has many unique features that can illustrate the difference between novice and expert.</p> <p>Your first step should be to ensure that the candidate is comfortable using the command line, not just GUI tools such as phpMyAdmin. During the interview, try asking the candidate to write MySQL code to create a database table or add a new index. These are very basic queries, but exactly the type that GUI tools prevent novices from mastering. You can double-check the answers with someone who is more familiar with MySQL.</p> <p>Can the candidate demonstrate knowledge of how JOINs work? For example, try asking the candidate to construct a query that returns all rows from Table One where no matching entries exist in Table Two. The answer should involve a LEFT JOIN.</p> <p>Ask the candidate to discuss backup strategies, and the various strengths and weaknesses of each. The candidate should know that backing up the database files directly is not an effective strategy unless all the tables are MyISAM. The candidate should definitely mention mysqldump as a cornerstone for backups. More sophisticated backup solutions include ibbackup/innobackup and LVM snapshots. Ideally, the candidate should also discuss how backups can affect performance (a common solution is to use a slave server for taking backups).</p> <p>Does the candidate have experience with replication? What are some of the common replication configurations and the various advantages of each? The most common setup is master-slave, allowing the application to offload SELECT queries to slave servers, along with taking backups using a slave to prevent performance issues on the master. Another common setup is master-master, the main benefit being the ability to make schema changes without impacting performance. Make sure the candidate discusses common issues such as cloning a slave server (<a href="http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html#option_mysqldump_master-data" rel="noreferrer">mysqldump + notation of the binlog position</a>), load distribution using a load balancer or MySQL proxy, <a href="http://www.mysqlperformanceblog.com/2007/10/12/managing-slave-lag-with-mysql-replication/" rel="noreferrer">resolving slave lag</a> by breaking larger queries into chunks, and how to promote a slave to become a new master.</p> <p>How would the candidate troubleshoot performance issues? Do they have sufficient knowledge of the underlying operating system and hardware to diagnose whether a bottleneck is CPU bound, IO bound, or network bound? Can they demonstrate how to use <a href="http://www.devshed.com/c/a/MySQL/Analyzing-Queries-for-Speed-with-EXPLAIN/" rel="noreferrer">EXPLAIN</a> to discover indexing problems? Do they mention the slow query log or configuration options such as the key buffer, tmp table size, innodb buffer pool size, etc?</p> <p>Does the candidate appreciate the subtleties of each storage engine? (MyISAM, InnoDB, and MEMORY are the main ones). Do they understand how each storage engine optimizes queries, and how locking is handled? At the least, the candidate should mention that MyISAM issues a table-level lock whereas InnODB uses row-level locking.</p> <p>What is the safest way to make schema changes to a live database? The candidate should mention master-master replication, as well as avoiding the locking and performance issues of ALTER TABLE by creating a new table with the desired configuration and using mysqldump or INSERT INTO ... SELECT followed by RENAME TABLE.</p> <p>Lastly, the only true measurement of a pro is experience. If the candidate cannot point to specific experience managing large data sets in a high availability environment, they might not be able to back up any knowledge they possess on a purely intellectual level.</p>
<p>I think it would depend on the database type: transactional or data warehouse?</p> <p>Anyhow, for all types I'd ask about specific to MySQL replication and clustering, performance tuning and monitorization concepts.</p>
8,741
<p>In regards to a part that I'm having printed remotely (by two processes:- stereolithography and laser sintering), I've been advised by the 3d printing company that 'the triangulation of the file is rather rough'. </p> <p>In this particular instance, it probably doesn't matter, but for the future, are there any tips to improving 'triangulation' when generating forms in AutoCAD?</p> <p>Note, AutoCAD's FACETRES variable is set to 10. </p>
<p>The phrase "triangulation of the file is rather rough" is somewhat vague, but one can interpret it to mean that the surface is what is considered "low poly" in the 3D modeling world.</p> <p><a href="https://i.stack.imgur.com/RarRO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RarRO.jpg" alt="low poly fox"></a></p> <p>From <a href="https://www.thingiverse.com/thing:937740" rel="nofollow noreferrer">Thingiverse</a>, this low poly fox shows an intentionally reduced poly surface. I'm not suggesting that your models appear this distorted, but it may give a hint to what the service is referencing.</p> <p>Consider to load your model into a program such as Meshmixer, which will show you the triangles in 'W'ireframe mode. If there are few triangles over a surface, you can get the aforementioned effect.</p> <p>Meshmixer also allows you to increase the mesh count, possibly improving the surface and satisfying the requirements of the printing service.</p>
<p><a href="https://forums.autodesk.com/t5/autocad-forum/stl-files-resolution/td-p/6591803" rel="nofollow noreferrer">This thread</a> and <a href="https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-2DF46705-EE9E-409F-86B5-ED391CE207DC-htm.html" rel="nofollow noreferrer">this article</a>, both on Autodesks website, suggest altering the <code>FACETRES</code> system variable to <code>10</code> to achieve a higher-quality .stl export.</p> <p>Alternatively, you can use the <code>3DPRINT</code> command for <code>FACETRES</code> to be increased automatically, which will then offer an .stl export or to send the file directly to a 3D printing service.</p>
1,362
<p>It seems to me that it would work perfectly well to do tail-recursion optimization in both C and C++, yet while debugging I never seem to see a frame stack that indicates this optimization. That is kind of good, because the stack tells me how deep the recursion is. However, the optimization would be kind of nice as well.</p> <p>Do any C++ compilers do this optimization? Why? Why not?</p> <p>How do I go about telling the compiler to do it?</p> <ul> <li>For MSVC: <code>/O2</code> or <code>/Ox</code></li> <li>For GCC: <code>-O2</code> or <code>-O3</code></li> </ul> <p>How about checking if the compiler has done this in a certain case?</p> <ul> <li>For MSVC, enable PDB output to be able to trace the code, then inspect the code</li> <li>For GCC..?</li> </ul> <p>I'd still take suggestions for how to determine if a certain function is optimized like this by the compiler (even though I find it reassuring that Konrad tells me to assume it)</p> <p>It is always possible to check if the compiler does this at all by making an infinite recursion and checking if it results in an infinite loop or a stack overflow (I did this with GCC and found out that <code>-O2</code> is sufficient), but I want to be able to check a certain function that I know will terminate anyway. I'd love to have an easy way of checking this :)</p> <hr> <p>After some testing, I discovered that destructors ruin the possibility of making this optimization. It can sometimes be worth it to change the scoping of certain variables and temporaries to make sure they go out of scope before the return-statement starts.</p> <p>If any destructor needs to be run after the tail-call, the tail-call optimization can not be done.</p>
<p><strong>All current mainstream compilers perform tail call optimisation</strong> fairly well (and have done for more than a decade), <a href="https://godbolt.org/g/TjqTHV" rel="noreferrer">even for mutually recursive calls</a> such as:</p> <pre><code>int bar(int, int); int foo(int n, int acc) { return (n == 0) ? acc : bar(n - 1, acc + 2); } int bar(int n, int acc) { return (n == 0) ? acc : foo(n - 1, acc + 1); } </code></pre> <p>Letting the compiler do the optimisation is straightforward: Just switch on optimisation for speed:</p> <ul> <li>For MSVC, use <code>/O2</code> or <code>/Ox</code>.</li> <li>For GCC, Clang and ICC, use <code>-O3</code></li> </ul> <p>An easy way to check if the compiler did the optimisation is to perform a call that would otherwise result in a stack overflow — or looking at the assembly output.</p> <p>As an interesting historical note, tail call optimisation for C was added to the GCC in the course of a <a href="http://www.complang.tuwien.ac.at/schani/diplarb.ps" rel="noreferrer">diploma thesis</a> by Mark Probst. The thesis describes some interesting caveats in the implementation. It's worth reading.</p>
<p>As Greg mentions, compilers won't do it in debug mode. It's ok for debug builds to be slower than a prod build, but they shouldn't crash more often: and if you depend on a tail call optimization, they may do exactly that. Because of this it is often best to rewrite the tail call as an normal loop. :-(</p>
5,429
<p>My team has a command parsing library for console apps. Each team around us has their own as well. There isn't anything in the BCL so I suppose this is natural.</p> <p>I've looked at the the module in Mono, which seems solid, and the one on CodePlex looks fine as well. There are probably others out there that will work (and I would love to hear your suggestions).</p> <p>The real question is: how do I get my team, and others around us, to commit to just using one? </p>
<p>Well to be honest, you <strong>can't</strong> make everyone settle on one solution. You can suggest a solution and point out it's benefits, but eventually the advantages would have to be greater than the inertia that they have built up with their present library.</p> <p>To make them settle on one library you would need to go up the management change until you get to the person that manages all the groups involved. Convince that person why everyone should use one library then let it filter back down.</p> <p>Now that I have said that, why does it matter? Does your team routinely have to work on code from the other teams? Are the other teams using libraries that cause problems for your code? Is this standardization purely for the sake of standardization or is there some specific problem that not standardizing causes?</p>
<p>EBGreen, good point, I should have mentioned <em>why</em> I am looking to do this. Our teams frequently read and edit code from the surrounding teams. And I mean feature teams, not just dev/test/pm divisions. </p> <p>This is just one of those little things that slow everybody down. Working on Team C's code? Got to track down their lib, which mysteriously isn't in the nightly builds (another problem, but independent of this). Reviewing another dev's work? Need to figure out how their parser works. Starting a new project? Need to decide which library to import. </p> <p>I think that your response does indicate the solution though: Put the library somewhere very convenient, so it can be picked up by new projects (I doubt that many existing ones will be revised, nor should they be if they're working fine), and make the advantages of using it clear. </p> <p>Thanks! </p>
7,867
<p>I am using ActiveScaffold in a Ruby on Rails app, and to save space in the table I have replaced the default "actions" text in the table (ie. "edit", "delete", "show") with icons using CSS. I have also added a couple of custom actions with action_link.add ("move" and "copy").</p> <p>For clarity, <strong>I would like to have a tooltip pop up with the related action</strong> (ie. "edit", "copy") when I hover the mouse over the icon.</p> <p>I thought I could do this by adding a simple "alt" definition to the tag, but that doesn't appear to work.</p> <p>Can somebody point me in the right direction?</p>
<p>The <code>alt</code> attribute is to be used as an alternative to the image, in the case of the image missing, or in a text only browser.</p> <p>IE got it wrong, when they made <code>alt</code> appear as a tooltip. It was never meant to be that.</p> <p>The correct attribute for this is <code>title</code>, which of course doesn't do a tooltip in IE.</p> <p>So, to do have a tooltip show up in both IE, and FireFox/Safari/Chrome/Opera, use both an <code>alt</code> attribute and a <code>title</code> attribute.</p>
<p>As Prestaul pointed out, the alt tag should work for images and title for links. However, this is also browser dependent...most browsers <strong>should</strong> implement functionality that displays this metadata as tooltips but they aren't required to do so.</p>
8,378
<p>In Visual Studio 2008</p> <ul> <li>add a new DataGridView to a form</li> <li>Edit Columns</li> <li>Add a a new DataGridViewImageColumn</li> <li>Open the CellStyle Builder of this column (DefaultCellStyle property)</li> <li>Change the NullValue from System.Drawing.Bitmap to null</li> <li>Try to add a new Row to the DataGridView at runtime (dataGridView1.Rows.Add();)</li> <li>You get this error: System.FormatException: Formatted value of the cell has a wrong type.</li> </ul> <p>If you change back the NullValue to System.Drawing.Bitmap (as it was) you still get the same error at adding a row.</p> <p>If you set the NullValue at runtime instead of designtime you don't get anny error. (dataGridView1.Columns[0].DefaultCellStyle.NullValue = null;)</p> <p>Could you tell me why is that?</p>
<p>This may well be a bug in the designer; if you take a look around at the .designer.cs file (maybe doing a diff from before and after you set NullValue to null) you should be able to see the code it generates.</p>
<p>I found that its better if you just delete the item from the designer all together from the Format area and the default null value area. Then it sets it back to the real null. I'm going to try to set it in the init section away from the designer generated crap.</p>
7,067
<p>This problem has been occurring for a while. On the top of round objects, you can see the individual layers. Maybe I just need a lower layer height.</p> <p><a href="https://i.stack.imgur.com/AQqhp.jpg" rel="nofollow noreferrer" title="Photo of a 3D printed model with printing errors on the top"><img src="https://i.stack.imgur.com/AQqhp.jpg" alt="Photo of a 3D printed model with printing errors on the top" title="Photo of a 3D printed model with printing errors on the top" /></a></p>
<p>At the top of curves layers will always be more visible because the layers are increasing offset from each other. Layer height will help with this, but if you really want it smooth you will need to do some post-processing.</p> <p>Usually if possible I avoid having a top surface like that of any significant size. But when I do I either leave it and post process or add some little design elements to break it up a bit. So it's still there but not really noticeable.</p>
<p>Kilisi is absolutely right that you necessarily (without advanced non-planar slicing techniques that aren't available in production slicers) have a &quot;stairstep&quot; effect whenever you have a shallow angle top surface like that. However, it looks from your picture like you also have some <em>gaps</em> that are accentuating the problem and making your top surface non-watertight. This can be fixed.</p> <p>Slicers (at least Cura) are fairly bad about figuring out where they have to put material under the very top layer to ensure that you have a solid wall of the desired thickness. Where the outer wall face is pointing almost-upward, you would need either a lot more outer perimeters than the shell thickness you want, because they're significantly offset from each other (often by as much or more than the whole 2D wall width) at each successive layer. Using excessively many walls will solve this, but wastes a lot of print time and material. Using more top layers is the easiest fix I know. I find that 5 top layers at 0.2 layer height pretty much always gives solid curved tops, even with spherical top shape. The only way that might fail is if you have really low infill and they all &quot;sink in&quot; rather than bonding properly.</p> <p>Of course these gaps could also be caused by underextrusion or misplaced extrusion. Check instructions for enabling and calibrating Linear Advance/Pressure Advance on your printer for one of the big ingredients in fixing top gaps and related extrusion inaccuracy problems.</p>
2,126
<p>I want to print a piece of fruit modeled in Blender. It is an STL file. Please note that I am an absolute beginner at 3D printing models. </p> <p>What do these red zones mean? What is wrong about the mesh in each case?</p> <p><a href="https://i.stack.imgur.com/GGEQe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GGEQe.png" alt="The fruit has some low-poly seeds. These used to be a particle system but I then changed them into individual objects."></a></p> <p>The fruit has some low-poly seeds. These used to be a particle system but I then changed them into individual objects.</p> <p><a href="https://i.stack.imgur.com/cmOfL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cmOfL.png" alt="These would be the base of the fruit. Why is it erroneous?"></a></p> <p>This view shows the base of the fruit, why is it colored red?</p>
<p>3D printers cannot print in the air without a prior layer or a support structure supporting the new printed layer. For the picture showing the bottom of the fruit, the red area is the calculated area that requires support for printing, so please enable that in the slicer application.</p> <p>For the top picture please post a detail or a zoomed in part. It is currently difficult to see what is the matter. It looks as though the STL model is incorrect and Ultimaker Cura thinks that the seeds are upside down, hence the red coloring also. This means that you need to fix the normals of the faces in the STL model. Please look into <a href="https://3dprinting.stackexchange.com/a/2785/5740">this answer</a> and <a href="https://3dprinting.stackexchange.com/a/3298/5740">this answer</a> for some hints.</p>
<p>Red is the color Cura uses to mark overhang areas. For the bottom that is normal, it can be fixed by using support.</p> <p>For the top, the presence of red <strong>atop</strong> the seeds is a common tell of inverted normals in the seeds.</p> <p>To fix, open your .blend file again, choose the seeds and <code>flip normals</code>. To make the whole thing even better, choose both the fruit and the seeds and then apply the <code>union</code> modifier on both.</p>
1,086
<p>I have a simple little test app written in Flex 3 (MXML and some AS3). I can compile it to a SWF just fine, but I'd like to make it into an EXE so I can give it to a couple of my coworkers who might find it useful.</p> <p>With Flash 8, I could just target an EXE instead of a SWF and it would wrap the SWF in a projector, and everything worked fine. Is there an equivalent to that using the Flex 3 SDK that doesn't end up requiring AIR?</p> <p>Note: I don't have Flex Builder, I'm just using the free Flex 3 SDK.</p>
<p>In your Flex SDK folders you should see a 'runtimes\player\win\FlashPlayer.exe' which is a stand alone Flash player. Open your SWF with that and you'll see a 'Create Projector...' menu item in the File menu which will create the stand-alone EXE.</p>
<p>There's also <a href="http://www.multidmedia.com/software/zinc/" rel="nofollow noreferrer">Zinc</a> that also provides API:s for accessing the filesystem and other thinks that AIR does, but less restrictive.</p>
4,333
<p>Does anyone know how IE7 determines what Security Zone to use for a site? I see the basics for IE6 <a href="http://www.microsoft.com/technet/prodtechnol/ie/reskit/6/default.mspx?mfr=true" rel="nofollow noreferrer">here</a>, but I can't find the equivalent for IE7.</p>
<p>I could use a little more information to narrow down my answer, but here is what I have:</p> <p>Internet Explorer has 5 different security zones be default: Local Machine Zone, Intranet, Internet, Trusted, and Restricted These are determined in urlmon.dll (Url Moniker) More information here: <a href="http://msdn.microsoft.com/en-us/library/ms537183(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms537183(VS.85).aspx</a></p> <p>But you can also implement your own custom security zone: <a href="http://msdn.microsoft.com/en-us/library/ms537182(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms537182(VS.85).aspx</a></p> <p>The way that IE determines the security zones should not have changes between IE6 and IE7 (or IE8 for that matter)</p> <p>Intranet sites are determined: 1. By url host names do not have any dots (<a href="http://stackoverflow">http://stackoverflow</a> vs <a href="http://stackoverflow.com">http://stackoverflow.com</a>)</p> <ol start="2"> <li>Sites from the file:// scheme where the resource is collected from UNC</li> </ol>
<p>Not sure what the confusion is. Sites on your intranet are in the intranet zone, web sites are in the internet zone, and sites on your computer are in the local zone, unless you've specifically overridden something in the browser's preferences.</p>
4,326
<p>Is there a way to change the use of an extruder port on a 3D printer motherboard to move stepper motors (on y axis) on a 3D printer?</p> <p>This is for a school project, and we have replaced the extruder with a laser for cutting material.</p> <p>We were tasked with converting a 3D printer into LOM 3D printer, the laser is set using the fan port, however we still need two stepper motors to move material from one side of the printer to the other after each layer of material is cut.</p> <p><a href="https://i.stack.imgur.com/l40X1.png" rel="nofollow noreferrer" title="Diagram"><img src="https://i.stack.imgur.com/l40X1.png" alt="Diagram" title="Diagram"></a></p> <p>The mother board we are using is <a href="https://rads.stackoverflow.com/amzn/click/com/B07MXX2RV7" rel="nofollow noreferrer" rel="nofollow noreferrer">WitBot MKS Gen L V1.0 Controller Board Integrated mainboard Compatible Ramps1.4/Mega2560 R3 with A4988 Motor Driver for 3D</a>.</p>
<p>This has nothing to do with the infill overlap, the image you've added looks as if the issue is related to non-bonding perimeters (it looks as if it is in between the 2<sup>nd</sup> and the 3<sup>rd</sup> perimeter), hence infill overlap doesn't apply here. If that is the case look into <a href="/q/6067">this question</a>.</p> <p>I've had this same issue, the problem is that if the perimeters do not touch, this is most probably caused by insufficient filament flow which can be a result of a too high of a print speed (or too low print temperature) of the inner perimeters. This is frequently seen when printing PETG. PETG has a limited print speed, the PETG I use (premium brand) has a maximum speed value of 50 mm/s, your values are for some values over that value. That would be fine for PLA, but high for PETG, the question is not clear on the material used for this print (the hotend temperatures hint to PLA, the bed temperatures are rather high though).</p> <p>If it is not related to the material being printed, these gaps are also explained if the positioning of the nozzle is not correct, e.g. caused by loose belts. This is supported by the comment on the first layer:</p> <blockquote> <p>where the infill on a first layer would often not reach the perimeter shells</p> </blockquote>
<p>I had absolutely the same issue. And after some research I finally found that this is because of wrong pressure advance setting (In case of Marlin - linear advance) in the firmware. Without pressure advance (linear advance) will be more plastic at the end of the travel rather than at the start. As result the fast full infill will have uneven distribution of the plastic with more plastic close to the perimeters that usually produce rounded corners. The pressure advance makes it better and redistribute plastic flow more even with the speed however if you make this setting too big for your 3d printer and filament then this will result in what you can see on the picture with less plastic at the end of the travel. Basically too big pressure advance parameter will result in less plastic near the perimeters and especially near corners where change in speed happening.</p>
1,277
<p>I'm currently looping through a datareader and calling the System.Net.Mail.SmtpClient's Send() method. The problem with this is that it's slow. Each email takes about 5-10 seconds to send (it's possible this is just an issue with my host). I had to override the executionTimeout default in my web.config file (it defaults to 90 seconds) like this:</p> <pre><code> &lt;httpRuntime executionTimeout="3000" /&gt; </code></pre> <p>One caveat: I'm on a shared host, so I don't think it is possible for me to send using the PickupDirectoryFromIis option (at least, it gave me errors when I turned it on).</p>
<p>You could send the mail asynchronous. That way the timeout should not interrupt your sending.</p> <p>This article should help you get started with that: <a href="http://www.eggheadcafe.com/articles/20030720.asp" rel="nofollow noreferrer">Sending Emails Asynchronously in C#</a>.</p> <p>There is another approach here: <a href="http://www.vikramlakhotia.com/Sending_Email_asynchronously_in_AspNet_20.aspx" rel="nofollow noreferrer">http://www.vikramlakhotia.com/Sending_Email_asynchronously_in_AspNet_20.aspx</a></p> <p>And off course there are several commercial clients available, but the only one that i have tried and can recommend is <a href="http://www.aspnetemail.com/" rel="nofollow noreferrer">http://www.aspnetemail.com/</a></p>
<p>Definitely spawn it off on a background worker process so they go out asynchronously. </p> <p>BTW, 5-10 seconds per e-mail seems way slow to me. On my server it takes just fractions of a second per e-mail. </p>
8,117
<p>What should i use to code Classic ASP under Linux. I have really tried to use Emacs and Vim but I don't have the time to learn them.</p> <p>What i'm looking for is:</p> <ul> <li>Syntax highlighting</li> <li>Code Browser (Ctags)</li> <li>Preferably som sort of code insight</li> </ul> <p>Something like Ultra Edit or E-texteditor.</p>
<p>I'm not sure what you're asking here, but if you are simply looking for a text-editor, my recommendations would be:</p> <p>Console-based:</p> <ul> <li>jed (simple, with a DOS Edit-like menubar, supports syntax-highlighing)</li> <li>nano / pico (even simpler)</li> </ul> <p>X-based:</p> <ul> <li>Kate (KDE, syntax-highlighing)</li> <li>Mousepad (like notepad)</li> <li>SciTE (syntax-highlighing)</li> </ul> <p>There are of course likely to be a gazillion other text-editors better than the ones listed above, but these are the ones I tend to use.</p>
<p>I played with BlueFish for a while when I was contemplating switching over completely and I liked it better than Kate. But, you will have to add the code to enable ASP highlighting. Its floating around numerous places - I found it in short order with a quick trip to the trusty ole Google. ;)</p> <p>But that is just my personal preference. Your mileage may vary.</p>
4,422
<p>Instead of arranging controls on a winform form by specifying pixel locations, I'd like to lay it out similar to the way you'd layout a form in html. This would make it scale better (for larger fonts etc).</p> <p>Does anyone know of a layout library that allows you to define the form in xml and lay it out similar to html?</p>
<p>Have you checked out the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx" rel="nofollow noreferrer">TableLayoutPanel</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel.aspx" rel="nofollow noreferrer">FlowLayoutPanel</a> in the .NET framework? It might be what you are looking for.</p>
<p>You may also want to consider using Windows Presentation Foundation (WPF) instead of WinForms - WPF has an XML declarative markup language (XAML) that works well for defining scalable UI.</p>
7,217
<p>How can I have it so Visual Studio doesn't keep re-creating this folder that I never use. It's annoying ot keep looking and unnecessary.</p>
<p>Add a trailing slash to the default projects location:</p> <p><a href="http://rerrify.wordpress.com/2012/03/22/get-rid-of-the-annoying-vsmacros80-folder-5/" rel="nofollow">Get Rid of the Annoying VSMacros80 Folder</a></p>
<pre><code>Tools-&gt;Options-&gt;Addin/Macro Security </code></pre> <p>Change Paths there.</p>
4,771
<p>The problem with my Anet E12 should be on USB connection itself.</p> <ol> <li>If powered down, the board still gets power from USB</li> <li>If board is resett, USB will still connect</li> <li>Still works on SD; seem like most part not damage. What cause the problem? Where to check first? How to fix it?</li> </ol> <p>Note: This printer worked with no problem before.</p>
<p>Your formula doesn't seem to take into account two important factors: layer height and average speed.</p> <p>Do the math differently:</p> <p>voumetric flow rate [mm^3/s] = layer height [mm] * line width [mm] * speed [mm/s]</p> <p>For example, 0.2 * 0.45 * 70 = 6.3 mm^3/s</p> <p>which is realistic, the extruder on the Ender 3 cannot go much faster than that reliably.</p> <p>PLA weighs 1.24 g/cm^3 = 0.00124 g/mm^3</p> <p>To extrude 1 kg you need 1000/(0.00124 * 6.3) = 35 hours (70 for 2 kg).</p> <p>However the printer does not reach 70 mm except on straight long moves, the average speed may be lower or much lower depending on what you print.</p> <p>If you print technical parts with straight edges, maybe you can multiply by 1.5 (50 hours/kg), but if you print models and small statues or similar you may need to double it (70 hours/kg).</p> <p>I use Klipper as firmware and I have a macro which keeps track of printing time and filament length used.</p>
<p>Your math looks correct, and is also a good approximation for what I've seen in the first few weeks with my own Ender 3.</p> <p>Another way to calculate (to check yourself) is to calculate the volume extruded (nozzle area times extrusion percentage times print speed -- be sure you convert everything to the same units!) in a given second, multiply by the density of your filament (common PLA runs about 1.2 g/cm^3), and get a rough figure for how long it takes to print a kilogram of filament. Your actual print time will always be higher than this approximation, because there are moves during which the extruder isn't running, infill is often set to lower extrusion level, and of course there's setup and cleanup time to account for.</p>
1,952
<p>If you're writing a library, or an app, where do the unit test files go? </p> <p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p> <p>Is there a best practice here?</p>
<p>For a file <code>module.py</code>, the unit test should normally be called <code>test_module.py</code>, following Pythonic naming conventions.</p> <p>There are several commonly accepted places to put <code>test_module.py</code>:</p> <ol> <li>In the same directory as <code>module.py</code>.</li> <li>In <code>../tests/test_module.py</code> (at the same level as the code directory).</li> <li>In <code>tests/test_module.py</code> (one level under the code directory).</li> </ol> <p>I prefer #1 for its simplicity of finding the tests and importing them. Whatever build system you're using can easily be configured to run files starting with <code>test_</code>. Actually, the <a href="https://docs.python.org/library/unittest.html#test-discovery" rel="noreferrer">default <code>unittest</code> pattern used for test discovery is <code>test*.py</code></a>.</p>
<p>I've recently started to program in Python, so I've not really had chance to find out best practice yet. But, I've written a module that goes and finds all the tests and runs them.</p> <p>So, I have:</p> <pre> app/ appfile.py test/ appfileTest.py </pre> <p>I'll have to see how it goes as I progress to larger projects.</p>
8,627
<p>How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight.</p> <p>Edit: Here's the code I'm now using this for, based on the answer from Santiago below.</p> <pre><code>public DataTemplate Create(Type type) { return (DataTemplate)XamlReader.Load( @"&lt;DataTemplate xmlns=""http://schemas.microsoft.com/client/2007""&gt; &lt;" + type.Name + @" Text=""{Binding " + ShowColumn + @"}""/&gt; &lt;/DataTemplate&gt;" ); } </code></pre> <p>This works really nicely and allows me to change the binding on the fly. </p>
<p>Although you cannot programatically create it, you can load it from a XAML string in code like this:</p> <pre><code> public static DataTemplate Create(Type type) { return (DataTemplate) XamlReader.Load( @"&lt;DataTemplate xmlns=""http://schemas.microsoft.com/client/2007""&gt; &lt;" + type.Name + @"/&gt; &lt;/DataTemplate&gt;" ); } </code></pre> <p>The snippet above creates a data template containing a single control, which may be a user control with the contents you need.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.datatemplate%28v=vs.95%29.aspx" rel="nofollow noreferrer">citation from MSDN</a>: </p> <blockquote> <p>The XAML usage that defines the content for creating a data template is not exposed as a settable property. It is special behavior built into the XAML processing of a DataTemplate object element.</p> </blockquote>
8,405
<p>What is WCF in simple terms?</p> <p>It's hard to distill the meaning from <a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation" rel="noreferrer">the Wikipedia page</a>.</p>
<p>WCF - <a href="http://msdn.microsoft.com/en-us/library/ms731082.aspx" rel="noreferrer">Windows Communication Framework</a> - is Microsoft's framework to make inter-process communication easier. It let's you do this communication through various means, plain old asmx web services, Remoting, MS Message Queuing, and a couple more.</p> <p>It let's you talk with other .NET apps, or non-Microsoft technologies (like J2EE). It's extensible enough to allow for newer stuff, like REST too (I don't think REST is built-in).</p>
<p>WCF is Microsoft's new .NET do-all extensible communications framework meant to replace functionality previously available in <a href="http://en.wikipedia.org/wiki/Distributed_Component_Object_Model" rel="nofollow noreferrer">DCOM</a>, <a href="http://en.wikipedia.org/wiki/.NET_Remoting" rel="nofollow noreferrer">.NET Remoting</a> and ASMX web services.</p>
6,430
<p>I have this program, we'll call it Host. Host does all kinds of good stuff, but it needs to be able to accept input through the command line <strong>while it's running</strong>. This means it has to somehow send its other process data and then quit. For example, I need to be able to do this:</p> <pre><code>./Host --blahblah 3 6 3 5 </code></pre> <p>This should somehow end up calling some function in Host called</p> <pre><code>handleBlahBlah(int x1, int y1, int x2, int y2){ //do some more sweet stuff } </code></pre> <p>Host is a C program, and does not need to support multiple instances.</p> <p>An example of this is Amarok music player. With Amarok running and playing, you can type "amarok --pause" and it will pause the music.</p> <p>I need to be able to do this in Linux or Windows. Preferably Linux.</p> <p>What is the cleanest way to implement this?</p>
<p>If you were on Windows, I'd tell you to use a hidden window to receive the messages, but since you used <code>./</code>, I assume you want something Unix-based.</p> <p>In that case, I'd go with a <a href="http://en.wikipedia.org/wiki/Named_pipe" rel="noreferrer">named pipe</a>. Sun has a <a href="http://developers.sun.com/solaris/articles/named_pipes.html" rel="noreferrer">tutorial</a> about named pipes that might be useful.</p> <p>The program would probably create the pipe and listen. You could have a separate command-line script which would open the pipe and just echo its command-line arguments to it.</p> <p>You <em>could</em> modify your program to support the command-line sending instead of using a separate script. You'd do the same basic thing in that case. Your program would look at it's command-line arguments, and if applicable, open the pipe to the "main" instance of the program, and send the arguments through.</p>
<p>So, I may be missing the point here, but by deafult a C program's main function takes two arguments; argc, a count of the number of arguments (at least one), and argv (or arg vector), the argument list. You could just parse through the arguments and call the correct method. For example:</p> <pre><code> int main(int argc, *argv[]) { /*loop through each argument and take action*/ while (--argc &gt; 0) { printf(%s%s, *++argv, (argc &gt; 1) ? " " : ""); } } </code></pre> <p>would print all of the arguments to screen. I am no C guru, so I hope I haven't made any mistakes.</p> <p>EDIT: Ok, he was after something else, but it wasn't really clear before the question was edited. Don't have to jump on my rep...</p>
3,162
<p>I'm trying to create a dialog box using C++ and the windows API, but I don't want the dialog defined in a resource file. I can't find anything good on this on the web, and none of the examples I've read seem to define the dialog programmatically.</p> <p>How can I do this?</p> <p>A simple example is fine. I'm not doing anything complicated with it yet.</p>
<p>Raymond Chen wrote a few posts about the dialog manager:</p> <ul> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050329-00/?p=36043" rel="nofollow noreferrer">The dialog manager, part 1: Warm-ups</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050330-00/?p=36023" rel="nofollow noreferrer">The dialog manager, part 2: Creating the frame window</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050331-00/?p=36003" rel="nofollow noreferrer">The dialog manager, part 3: Creating the controls</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050401-00/?p=35993" rel="nofollow noreferrer">The dialog manager, part 4: The dialog loop</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050404-48/?p=35983" rel="nofollow noreferrer">The dialog manager, part 5: Converting a non-modal dialog box to modal</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050405-46/?p=35973" rel="nofollow noreferrer">The dialog manager, part 6: Subtleties in message loops</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050406-57/?p=35963" rel="nofollow noreferrer">The dialog manager, part 7: More subtleties in message loops</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050407-00/?p=35953" rel="nofollow noreferrer">The dialog manager, part 8: Custom navigation in dialog boxes</a></li> <li><a href="https://devblogs.microsoft.com/oldnewthing/20050408-41/?p=35943" rel="nofollow noreferrer">The dialog manager, part 9: Custom accelerators in dialog boxes</a></li> </ul>
<p>Take a look at <a href="http://www.codeproject.com/KB/wtl/resourcelessdialogtoolkit.aspx" rel="nofollow noreferrer">this toolkit</a> that describes how to create dialogs without resource files.</p> <p>It's in WTL. However, I'm sure you can pick apart the internals to achieve the same thing using the Win32 API directly.</p>
8,685
<p>In .net frameworks 1.1, I use </p> <pre><code>System.Configuration.ConfigurationSettings.AppSettings["name"]; </code></pre> <p>for application settings. But in .Net 2.0, it says ConfigurationSettings is obsolete and to use ConfigurationManager instead. So I swapped it out with this:</p> <pre><code>System.Configuration.ConfigurationManager.AppSettings["name"]; </code></pre> <p>The problem is, ConfigurationManager was not found in the System.Configuration namespace. I've been banging my head against the wall trying to figure out what I'm doing wrong. Anybody got any ideas?</p>
<p>You have to reference the System.configuration assembly (note the lowercase)</p> <p>I don't know why this assembly is not added by default to new projects on Visual Studio, but I find myself having the same problem every time I start a new project. I always forget to add the reference.</p>
<p>You are missing the reference to System.Configuration.</p>
5,167
<p>I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time.</p> <pre><code>int globalgarbage; unsigned int anumber = 42; </code></pre> <p>But what about static ones defined within a function?</p> <pre><code>void doSomething() { static bool globalish = true; // ... } </code></pre> <p>When is the space for <code>globalish</code> allocated? I'm guessing when the program starts. But does it get initialized then too? Or is it initialized when <code>doSomething()</code> is first called?</p>
<p>I was curious about this so I wrote the following test program and compiled it with g++ version 4.1.2.</p> <pre><code>include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class test { public: test(const char *name) : _name(name) { cout &lt;&lt; _name &lt;&lt; " created" &lt;&lt; endl; } ~test() { cout &lt;&lt; _name &lt;&lt; " destroyed" &lt;&lt; endl; } string _name; }; test t("global variable"); void f() { static test t("static variable"); test t2("Local variable"); cout &lt;&lt; "Function executed" &lt;&lt; endl; } int main() { test t("local to main"); cout &lt;&lt; "Program start" &lt;&lt; endl; f(); cout &lt;&lt; "Program end" &lt;&lt; endl; return 0; } </code></pre> <p>The results were not what I expected. The constructor for the static object was not called until the first time the function was called. Here is the output:</p> <pre><code>global variable created local to main created Program start static variable created Local variable created Function executed Local variable destroyed Program end local to main destroyed static variable destroyed global variable destroyed </code></pre>
<p>In the following code it prints Initial = 4 which is the value of static_x as it is implemented in the compiling time.</p> <pre><code> int func(int x) { static int static_x = 4; static_x = x; printf (&quot;Address = 0x%x&quot;,&amp;static_x ); // prints 0x40a010 return static_x; } int main() { int x = 8; uint32_t *ptr = (uint32_t *)(0x40a010); // static_x location printf (&quot;Initial = %d\n&quot;,*ptr); func(x); return 0; } </code></pre>
7,931
<p>I'm looking for a good method of generating an iCalendar file (*.ics) in c# (asp.net). I've found a couple resources, but one thing that has been lacking is their support for <strong>quoted-printable</strong> fields - fields that have carriage returns and line feeds.</p> <p>For example, if the <strong>description</strong> field isn't encoded properly, only the first line will display and possibly corrupting the rest of the information in the *.ics file.</p> <p>I'm looking for existing classes that can generate *.ics files and/or a class that can generate <strong>quoted-printable</strong> fields.</p>
<p>I use <a href="http://sourceforge.net/projects/dday-ical/" rel="noreferrer">DDay.Ical</a>, its good stuff. Has the ability to open up an ical file and get its data in a nice object model. It says beta, but it works great for us.</p> <h1>Edit Nov 2016</h1> <p>This library has been deprecated, but was picked up and re-released as iCal.NET by another dev. </p> <p>Notes about the release: <a href="http://rianjs.net/2016/07/dday-ical-is-now-ical-net" rel="noreferrer">rianjs.net/2016/07/dday-ical-is-now-ical-net</a></p> <p>Source on GitHub: <a href="https://github.com/rianjs/ical.net" rel="noreferrer">github.com/rianjs/ical.net</a></p>
<p>iCal can be complicated, so I recommend using a library. DDay is a good free solution. Last I checked it didn't have full support for recurring events, but other than that it looks really nice. Definitely test the calendars with several clients.</p>
3,186
<p>We have a whole bunch of queries that "search" for clients, customers, etc. You can search by first name, email, etc. We're using LIKE statements in the following manner: </p> <pre><code>SELECT * FROM customer WHERE fname LIKE '%someName%' </code></pre> <p>Does full-text indexing help in the scenario? We're using SQL Server 2005.</p>
<p>It will depend upon your DBMS. I believe that most systems will not take advantage of the full-text index unless you use the full-text functions. (e.g. <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-natural-language.html" rel="nofollow noreferrer">MATCH/AGAINST</a> in mySQL or FREETEXT/CONTAINS in MS SQL)</p> <p>Here is two good articles on when, why, and how to use full-text indexing in SQL Server:</p> <ol> <li><a href="https://www.developer.com/database/sql-server-full-text-searching/" rel="nofollow noreferrer">How To Use SQL Server Full-Text Searching</a></li> <li><a href="https://www.developer.com/guides/solving-complex-sql-problems-with-full-text-indexing/" rel="nofollow noreferrer">Solving Complex SQL Problems with Full-Text Indexing</a></li> </ol>
<p>To answer the question specifically for MSSQL, full-text indexing will <strong>NOT</strong> help in your scenario.</p> <p>In order to improve that query you could do one of the following:</p> <ol> <li>Configure a full-text catalog on the column and use the CONTAINS() function.</li> <li><p>If you were primarily searching with a prefix (i.e. matching from the start of the name), you could change the predicate to the following and create an index over the column.</p> <p>where fname like 'prefix%'</p></li> </ol> <p>(1) is probably overkill for this, unless the performance of the query is a big problem. </p>
8,236
<p>I've tried to apply a sharp blade (the one that came witht he printer) to scrape the model off like I usually do but this model seems overly robust. What method can I do to take this off safely? </p> <p>See image <a href="https://i.stack.imgur.com/c9nIu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c9nIu.jpg" alt="at"></a></p>
<p>Unfortunately, you may have to destroy this part, or the build surface, just to get it off the plate. It looks really on there, and if you can't get under it even with a razor that further supports my gut instinct. It's happened to me before, just part of learning how to print with a particular material on a particular printer and build surface.</p> <p>One thing to try before just hacking away at the part or replacing the build surface (which you may have to do anyway) would be to heat the plate back up to maybe 60-70*C, then hit the part with some freeze spray (or the poor man's version, turning a can of air duster upside-down). The rapid expansion-contraction may pop the part free. How effective this is depends on the plastic you used. PLA doesn't stretch and shrink much, but by the same token it's also very inflexible, so the stretching and shrinking it does do can stil pop the part off. This method's <em>really</em> effective for plastics like ABS that stretch/shrink a lot with heat. Remember to ventilate well; the principal component of these sprays is difluoroethane, which isn't great stuff to breathe in any significant concentration, and when spraying the liquid the resulting "steam" state of boiling liquid is much more flammable (so after the bed comes up to proper heat, I'd turn off the printer just in case).</p> <p>EDIT: Per the comment to this answer, an alternate method would be to heat the plate even further, to about 80-90*C, which would heat the PLA beyond its glass transition temperature, softening it and reducing its adhesion. You would destroy the part, but parts can be reprinted, that's the beauty of owning a general-purpose computer-controlled additive plastic forming machine.</p> <p>Your first layer including the brim looks a little close to the plate, which is part of the problem; you <em>really</em> squished that first layer down onto the bed. I would relevel the bed a bit further away, or (if you're happy with how actually level the bed is) set a Z-offset to increase first layer width. There's a very fine balance to be struck here; once you find it, printing (and removing said prints) becomes a lot easier.</p> <p>In future, a build adhesive like Elmer's glue stick or hairspray (or a dedicated adhesive like 3DLAC or Bed Weld) also doubles as a release agent; the adhesive grabs the extruded plastic to keep it on the plate, but also prevents direct contact between two plastics and thus avoids any chemical bonding between the part and plate. Also consider upgrading to a flexible removable surface, like a magnetic BuildTak surface. Being able to take the bed off the printer and then flex the surface to help pull a corner free (at which point you can slip a scraper in to lift the rest of it off) is a real boon to these types of situations. </p>
<p>Some comments assume that this is a PLA print. IS it PLA, or something more exotic?</p> <p>If PLA, then try softening the object by heating the print with a heat gun or hair drier. </p> <p>I assume that the bed is not easily removed and that you can not flex the bed. If you can remove the bed by unscrewing it, it might flex enough to break away the print. It doesn't take a lot of flex to remove a part. The smallest opening concentrates force on the edge.</p> <p>I have had some success using a wood chisel "upside down". Don't try to get the edge under the part, but instead embed the pointy edge into the object and then use the angle behind the edge as a fulcrum to focus upward force on the object. That might work better while the object is hot.</p>
1,556
<p>So I was thinking of using a closed-loop motor in my 3D printer for better accuracy and high-speed printing without losing steps. I have analyzed options available including just tweaking stepper current and firmware changes to prevent step losses but I want to find the best way to do it with encoders. The problem is I need a pretty high resolution for a 3d printer and usually, high-resolution servo motors use potentiometers that are limited and not suitable for a 3d printer. I am thinking of building my own closed-loop continuous rotation servo using stepper/DC motors and encoders but I can't find any high-resolution encoder at a reasonable price. So is there any way to somehow use low-resolution encoders (like 36 pulse every full turn) or is there any encoder type that I can use for better accuracy at a reasonable price other than optical ones? Also is there any other solution for closed-loop systems at a reasonable price?<br /> Note that I am aware that I may need to modify firmware or write my own code for motors and program them from scratch.<br /> <strong>Note:</strong> You might consider this question <a href="https://3dprinting.stackexchange.com/questions/12087/closed-loop-stepper-motors">Closed-loop stepper motors</a> a possible duplicate but I have read that and my main problem is not being able to find any cheap high-resolution encoder for this purpose.<br /> <br /> Also for some reason, I can't use products like BTT S42B closed-loop stepper drives, my only option is to build them myself.<br /> <strong>TL;DR:</strong><br /> Is there any type of encoder with high resolution and cheap price for use in 3D printers? (I don't mean brand, I mean technology)</p>
<p>You can use a magnetic position encoder.</p> <p><a href="https://ams.com/as0548b" rel="nofollow noreferrer">AS5048B High Resolution Position Sensor</a></p> <p>14-bit rotary position sensor with digital angle (interface) and PWM output</p> <p>14 bit means 16k steps/rotation. With a stepper which does 200 steps/rotation and 16x microstepping, you will need only 11 bit, so you have plenty of extra accuracy you can use to filter noise.</p> <p>You may use <a href="https://ams.com/as5600" rel="nofollow noreferrer">AS5600 Positioning Sensor</a> instead, which is 12 bits, since you don't need to track each microsteps in a closed loop, 4x is enough.</p> <p>AS5600 in PWM mode does up to 920 Hz, AS5048 1 kHz. I'm not sure in I2C mode but surely more. Of course you have to take into account delay between measuring the position and transmission of the position.</p>
<p>The gearbox approach is solid, but it will be 100x slower, and you said you wanted speed.</p>
1,889
<p>I'm testing the VB function below that I got from a Google search. I plan to use it to generate hash codes for quick string comparison. However, there are occasions in which two different strings have the same hash code. For example, these strings</p> <p>"122Gen 1 heap size (.NET CLR Memory w3wp):mccsmtpteweb025.20833333333333E-02"</p> <p>"122Gen 2 heap size (.NET CLR Memory w3wp):mccsmtpteweb015.20833333333333E-02"</p> <p>have the same hash code of 237117279.</p> <p>Please tell me: - What is wrong with the function? - How can I fix it?</p> <p>Thank you</p> <p>martin</p> <hr> <pre><code>Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, src As Any, ByVal bytes As Long) Private Function HashCode(Key As String) As Long On Error GoTo ErrorGoTo Dim lastEl As Long, i As Long ' copy ansi codes into an array of long' lastEl = (Len(Key) - 1) \ 4 ReDim codes(lastEl) As Long ' this also converts from Unicode to ANSI' CopyMemory codes(0), ByVal Key, Len(Key) ' XOR the ANSI codes of all characters' For i = 0 To lastEl - 1 HashCode = HashCode Xor codes(i) 'Xor' Next ErrorGoTo: Exit Function End Function </code></pre>
<p>I'm betting there are more than just "occasions" when two strings generate the same hash using your function. In fact, it probably happens more often than you think.</p> <p>A few things to realize:</p> <p>First, there will be hash collisions. It happens. Even with really, really big spaces like MD5 (128 bits) there are still two strings that can generate the same resulting hash. You have to deal with those collisions by creating buckets.</p> <p>Second, a long integer isn't really a big hash space. You're going to get more collisions than you would if you used more bits.</p> <p>Thirdly, there are libraries available to you in Visual Basic (like .NET's <code>System.Security.Cryptography</code> namespace) that will do a much better job of hashing than most mere mortals.</p>
<p>I don't quite see the environment you work in. Is this .Net code? If you really want good hash codes, I would recommend looking into cryptographic hashes (proven algorithms) instead of trying to write your own.</p> <p>Btw, could you edit your post and paste the code in as a Code Sample (see toolbar)? This would make it easier to read.</p>
8,935
<p>I have a BSTR object that I would like to convert to copy to a wchar__t object. The tricky thing is the length of the BSTR object could be anywhere from a few kilobytes to a few hundred kilobytes. Is there an efficient way of copying the data across? I know I could just declare a wchar_t array and alway allocate the maximum possible data it would ever need to hold. However, this would mean allocating hundreds of kilobytes of data for something that potentially might only require a few kilobytes. Any suggestions?</p>
<p>BSTR objects contain a length prefix, so finding out the length is cheap. Find out the length, allocate a new array big enough to hold the result, process into that, and remember to free it when you're done.</p>
<p>Use ATL, and CStringT then you can just use the assignment operator. Or you can use the USES_CONVERSION macros, these use heap alloc, so you will be sure that you won't leak memory.</p>
9,754
<p>A member of our hackspace wants to get their 8- and 11- year old kids<sup>1</sup> excited about 3D-printing and CNC cutting and makering in general. We have a weekly open training where people can design and print/CNC/laser an item of their choice like a dogboned box or a two-piece sword and hilt, or a name tag, or whatever. I need a few ideas prepared so we don't spend half our lesson on Thingiverse or in Fusion (more like a quarter)! I'm not a parent and my youngest friend is probably in their twenties.</p> <p>What we have: </p> <ul> <li>a full bed 1200x1800 mm CNC (preferred, because it's loud and fast)</li> <li>Prusa mk3</li> <li>cheapo 80W 500x300 mm laser</li> <li>Fusion 360 based workflow, easy :)</li> <li>Arduinos and stuff</li> </ul> <p>Ideas we've had: a minecraft creeper, done as a simple-ish box.</p> <p><hr> <sub>1: the (girls) are not interested in my normal kids' goto, which is: swords, shields. They are interested in: minecraft, dragons, horses. _o_/</sub></p> <p>edit: this is NOT an opinion-gathering post, though there may be more than one "correct" answer. We need specific applications of 3d printing for a young audience. This collection of answers will be useful to evangelize making to a whole new generation!</p>
<p>Our local library makerspace holds summer camp for a limited number of lucky attendees, ages from 12-15 and the curriculum has a segment which appears to match your objective.</p> <p>In the case of the Launch Pad Camp, the campers will be using <a href="http://onshape.com/" rel="nofollow noreferrer">OnShape</a> to create a keychain/nametag with text of their choosing. It will be an unremarkable 3mm thick x 35-40 mm wide x 70-80 mm long "plank" with a depressed center (by 1.5mm) and raised text. The mentors of the camp expect to be able to teach these campers how to use the software to perform tasks by rote. I assisted the mentor in the process as she had no idea how to use OnShape. Neither did I, but that never slows me down.</p> <p>Another aspect of her camp is that it will (or may) include using <a href="https://scratch.mit.edu/" rel="nofollow noreferrer">Scratch</a> </p> <p><a href="https://i.stack.imgur.com/bqBBt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bqBBt.png" alt="scratch screencap"></a></p> <p>and does include using a Scratch based program called <a href="https://ozoblockly.com/" rel="nofollow noreferrer">Ozoblocky</a> to interface with <a href="https://ozobot.com/" rel="nofollow noreferrer">Ozobots</a>. </p> <p><a href="https://i.stack.imgur.com/BmG3q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BmG3q.png" alt="ozoblocky screencap"></a></p> <p>I suggested to her that she could use <a href="https://www.blockscad3d.com/" rel="nofollow noreferrer">BlockSCAD</a> to create the 3D objects, as the interface is nearly identical, and in my opinion, very easy to use.</p> <p>Not surprisingly, BlockSCAD has a series of tutorials available on the <a href="https://www.youtube.com/watch?v=xs0a4hzd1Tk" rel="nofollow noreferrer">YouTube</a>.</p> <p>The <a href="https://www.blockscad3d.com/editor/" rel="nofollow noreferrer">editor for BlockSCAD</a> is browser based removing the requirement to install on every computer.</p> <p><a href="https://i.stack.imgur.com/zd5VS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zd5VS.png" alt="blockscad editor image"></a></p>
<p>Our local library makerspace holds summer camp for a limited number of lucky attendees, ages from 12-15 and the curriculum has a segment which appears to match your objective.</p> <p>In the case of the Launch Pad Camp, the campers will be using <a href="http://onshape.com/" rel="nofollow noreferrer">OnShape</a> to create a keychain/nametag with text of their choosing. It will be an unremarkable 3mm thick x 35-40 mm wide x 70-80 mm long "plank" with a depressed center (by 1.5mm) and raised text. The mentors of the camp expect to be able to teach these campers how to use the software to perform tasks by rote. I assisted the mentor in the process as she had no idea how to use OnShape. Neither did I, but that never slows me down.</p> <p>Another aspect of her camp is that it will (or may) include using <a href="https://scratch.mit.edu/" rel="nofollow noreferrer">Scratch</a> </p> <p><a href="https://i.stack.imgur.com/bqBBt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bqBBt.png" alt="scratch screencap"></a></p> <p>and does include using a Scratch based program called <a href="https://ozoblockly.com/" rel="nofollow noreferrer">Ozoblocky</a> to interface with <a href="https://ozobot.com/" rel="nofollow noreferrer">Ozobots</a>. </p> <p><a href="https://i.stack.imgur.com/BmG3q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BmG3q.png" alt="ozoblocky screencap"></a></p> <p>I suggested to her that she could use <a href="https://www.blockscad3d.com/" rel="nofollow noreferrer">BlockSCAD</a> to create the 3D objects, as the interface is nearly identical, and in my opinion, very easy to use.</p> <p>Not surprisingly, BlockSCAD has a series of tutorials available on the <a href="https://www.youtube.com/watch?v=xs0a4hzd1Tk" rel="nofollow noreferrer">YouTube</a>.</p> <p>The <a href="https://www.blockscad3d.com/editor/" rel="nofollow noreferrer">editor for BlockSCAD</a> is browser based removing the requirement to install on every computer.</p> <p><a href="https://i.stack.imgur.com/zd5VS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zd5VS.png" alt="blockscad editor image"></a></p>
955
<p>I have a small VB.NET application that I'm working on using the full version of Visual Studio 2005. In the <strong>Publish</strong> properties of the project, I have it set to <em>Automatically increment revision with each publish</em>.</p> <p>The issue is that it's only incrementing the revision in the Setup files. It doesn't seem to be updating the version number in the About Box (which is the generic, built-in, About Box template). That version number seems to be coming from <em>My.Application.Info.Version</em>.</p> <p>What should I be using instead so that my automatically incrementing revision number shows up in the about box?</p>
<p>Change the code for the About box to </p> <pre><code>Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Deployment.CurrentVersion.ToString) </code></pre> <p>Please note that all the other answers are correct for "how do I get my assembly version", not the stated question "how do I show my publish version".</p>
<p>I'm no VB.NET expert, but have you tried to set the value to for example 1.0.0.*? This should increase the revision number (at least it does in the AssemblyInfo.cs in C#).</p>
3,242
<p>I've been doing ASP.NET development for a little while now, and I've used both the GridView and the DataGrid controls before for various things, but I never could find a really good reason to use one or the other. I'd like to know:</p> <p>What is the difference between these 2 ASP.NET controls? What are the advantages or disadvantages of both? Is one any faster? Newer? Easier to maintain?</p> <p>The intellisense summary for the controls doesn't seem to describe any difference between the two. They both can view, edit, and sort data and automatically generate columns at runtime.</p> <p><strong>Edit:</strong> Visual Studio 2008 no longer lists DataGrid as an available control in the toolbox. It is still available (for legacy support I assume) if you type it in by hand though.</p>
<p>DataGrid was an ASP.NET 1.1 control, still supported. GridView arrived in 2.0, made certain tasks simpler added different databinding features:</p> <p>This link has a comparison of DataGrid and GridView features -</p> <p><a href="https://msdn.microsoft.com/en-us/library/05yye6k9(v=vs.100).aspx" rel="noreferrer">https://msdn.microsoft.com/en-us/library/05yye6k9(v=vs.100).aspx</a></p>
<p>some basic diffrence between gridview and details view</p> <p>the GridView control also has a number of new features and advantages over the DataGrid control, which include: </p> <p>· Richer design-time capabilities. · Improved data source binding capabilities. · Automatic handling of sorting, paging, updates, and deletes. · Additional column types and design-time column operations. · A Customized pager user interface (UI) with the PagerTemplate property. </p> <p>Differences between the GridView control and the DataGrid control include: · Different custom-paging support. · Different event models.</p>
2,624
<p>I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?</p>
<p><strong>Declaration</strong></p> <p>A prototype for a function which takes a function parameter looks like the following:</p> <pre><code>void func ( void (*f)(int) ); </code></pre> <p>This states that the parameter <code>f</code> will be a pointer to a function which has a <code>void</code> return type and which takes a single <code>int</code> parameter. The following function (<code>print</code>) is an example of a function which could be passed to <code>func</code> as a parameter because it is the proper type:</p> <pre><code>void print ( int x ) { printf("%d\n", x); } </code></pre> <p><strong>Function Call</strong></p> <p>When calling a function with a function parameter, the value passed must be a pointer to a function. Use the function's name (without parentheses) for this:</p> <pre><code>func(print); </code></pre> <p>would call <code>func</code>, passing the print function to it.</p> <p><strong>Function Body</strong></p> <p>As with any parameter, <code>func</code> can now use the parameter's name in the function body to access the value of the parameter. Let's say that <code>func</code> will apply the function it is passed to the numbers 0-4. Consider, first, what the loop would look like to call print directly:</p> <pre><code>for ( int ctr = 0 ; ctr &lt; 5 ; ctr++ ) { print(ctr); } </code></pre> <p>Since <code>func</code>'s parameter declaration says that <code>f</code> is the name for a pointer to the desired function, we recall first that if <code>f</code> is a pointer then <code>*f</code> is the thing that <code>f</code> points to (i.e. the function <code>print</code> in this case). As a result, just replace every occurrence of print in the loop above with <code>*f</code>:</p> <pre><code>void func ( void (*f)(int) ) { for ( int ctr = 0 ; ctr &lt; 5 ; ctr++ ) { (*f)(ctr); } } </code></pre> <p><a href="http://math.hws.edu/bridgeman/courses/331/f05/handouts/c-c++-notes.html" rel="noreferrer">Source</a></p>
<p>It's not really a function, but it is an localised piece of code. Of course it doesn't pass the code just the result. It won't work if passed to an event dispatcher to be run at a later time (as the result is calculated now and not when the event occurs). But it does localise your code into one place if that is all you are trying to do.</p> <pre><code>#include &lt;stdio.h&gt; int IncMultInt(int a, int b) { a++; return a * b; } int main(int argc, char *argv[]) { int a = 5; int b = 7; printf("%d * %d = %d\n", a, b, IncMultInt(a, b)); b = 9; // Create some local code with it's own local variable printf("%d * %d = %d\n", a, b, ( { int _a = a+1; _a * b; } ) ); return 0; } </code></pre>
3,083
<p>Since Graduating from a very small school in 2006 with a badly shaped &amp; outdated program (I'm a foreigner &amp; didn't know any better school at the time) I've come to realize that I missed a lot of basic concepts from a mathematical &amp; software perspective that are mostly the foundations of other higher concepts.</p> <p>I.e. I tried to listen/watch the open courseware from MIT on <a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-046JFall-2005/CourseHome/" rel="nofollow noreferrer">Introduction to Algorithms</a> but quickly realized I was missing several mathematical concepts to better understand the course.</p> <p>So what are the core mathematical concepts a good software engineer should know? And what are the possible books/sites you will recommend me?</p>
<p><a href="http://steve-yegge.blogspot.com/2006/03/math-for-programmers.html" rel="nofollow noreferrer">Math for Programmers</a>. A good read.</p>
<p>My math background is really poor (Geologist by training), but I took a <a href="http://en.wikipedia.org/wiki/Discrete_mathematics" rel="nofollow noreferrer">discrete math</a> class in high school and I use the concepts every day as a programmer. It is probably the most valuable class I took in all of my education as it relates to my current profession.</p>
7,544
<p>I'm writing a tool to run a series of integration tests on my product. It will install it and then run a bunch of commands against it to make sure its doing what it is supposed to. I'm exploring different options for how to markup the commands for each test case and wondering if folks had insight to share on this. I'm thinking of using YAML and doing something like this (kinda adapted from rails fixtures): </p> <pre><code>case: name: caseN description: this tests foo to make sure bar happens expected_results: bar should happen commands: | command to run next command to run verification: command to see if it worked </code></pre> <p>Does anyone have another, or better idea? Or is there a domain specific language I'm unaware of? </p>
<p>Go and have a look at the XUnit suite of test tools. This framework was originally designed for Smalltalk by Kent Beck and, I think, Erich Gamma, and it has now been ported to a whole stack of other languages, e.g. <a href="http://cunit.sourceforge.net/" rel="nofollow noreferrer">CUnit</a></p>
<p>You might want to check out <a href="http://www.cpan.org/" rel="nofollow noreferrer">CPAN</a>. It does for Perl scripts exactly what it sounds like your utility will do for your app.</p>
6,324
<p>I am facing a problem with my 3D print. Whenever I am printing any object, the print from the top is shifting to the right hand side - it is symmetric at the bottom but not at the top. </p> <p>Checkout the photo below:</p> <p><a href="https://i.stack.imgur.com/uocCD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uocCD.jpg" alt="101hero print"></a></p>
<p>You appear to have a couple of issues here, </p> <p>First off your nozzle appears to be a bit hot for your filament (you can see this be the drooping and sagginess of the layers on the outer shell)</p> <p>Second issue is it appears as though your belts are loose. You can tell if your belts are loose if your parts seem to be shifted in one way. </p> <p>Third issue (maybe). You may want to try slowing down your nozzle speed slightly. The faster the extruder moves, the more inertia that is generated which in effect makes your belt act as a spring and will cause it to bounce along the axis while it's printing. Slowing it down will result in your belt acting more like a rigid member and help to clean up the outer layers of your print. Also, it's easier on your belts. The downside is that your parts will take a bit longer to print. In my experience, parts that look great but take a bit longer are well worth the wait.</p>
<p>Make sure you are using cura 15.02.1, also download the configuration file from the 101hero website, and upload it to cura using the" open profile" button. Make sure your extruder temp is set to 198. I use a 113% flow rate on my 101hero.</p>
560
<p>What is the best way to use ResolveUrl() in a Shared/static function in Asp.Net? My current solution for VB.Net is:</p> <pre><code>Dim x As New System.Web.UI.Control x.ResolveUrl("~/someUrl") </code></pre> <p>Or C#:</p> <pre><code>System.Web.UI.Control x = new System.Web.UI.Control(); x.ResolveUrl("~/someUrl"); </code></pre> <p>But I realize that isn't the best way of calling it.</p>
<p>I use <a href="http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility.aspx" rel="noreferrer">System.Web.VirtualPathUtility.ToAbsolute</a>.</p>
<p>I tend to use HttpContext.Current to get the page, then run any page/web control methods off that.</p>
4,637
<p>I want to use a file to store the current version number for a piece of customer software which can be used by a start-up script to run the binary in the correct directory.</p> <p>For Example, if the run directory looks like this:</p> <pre><code>. .. 1.2.1 1.2.2 1.3.0 run.sh current_version </code></pre> <p>And current_version contains:</p> <pre><code>1.2.2 </code></pre> <p>I want <code>run.sh</code> to descend into 1.2.2 and run the program <code>foo</code>.</p> <p>The current solution is this:</p> <pre><code>#!/bin/sh version = `cat current_version` cd $version ./foo </code></pre> <p>It works but is not very robust. It does not check for file existence, cannot cope with multiple lines, leading spaces, commented lines, blank files, etc.</p> <p>What is the most survivable way to do this with either a shell or perl script?</p>
<p>That's a common approach. You can check for dir/file existence using test operators such as "if [ -d "somedirectory" ]; then" or [ -t "somefile" ]</p> <p>I use symbolic links more often, though. Then, you can just change your symbolic link to use the version you want.</p> <p>For example,</p> <pre> $ ln -s 1.2.2 current_version $ ls -al total 20 drwxr-xr-x 5 dbreese dbreese 4096 2008-09-15 13:34 . drwxr-xr-x 3 dbreese dbreese 4096 2008-09-15 13:34 .. drwxr-xr-x 2 dbreese dbreese 4096 2008-09-15 13:34 1.2.1 drwxr-xr-x 2 dbreese dbreese 4096 2008-09-15 13:34 1.2.2 drwxr-xr-x 2 dbreese dbreese 4096 2008-09-15 13:34 1.3.0 lrwxrwxrwx 1 dbreese dbreese 6 2008-09-15 13:34 current_version -> 1.2.2/ </pre> <p>Then your script can just use "cd current_version".</p>
<pre><code>!#/bin/sh if [ -e 'current_version' ]; then version=`cat current_version`; version=`echo $version | tr -ds [[:blank:]]` if [ -n "$version" ]; then if [ -d "$version" ]; then cd "$version" else echo $version is not a directory fi else echo version_file contained only blanks fi else No file named current_version exists fi </code></pre>
9,164
<p>I was recently brushing up on some fundamentals and found merge sorting a linked list to be a pretty good challenge. If you have a good implementation then show it off here.</p>
<p>Wonder why it should be big challenge as it is stated here, here is a straightforward implementation in Java with out any &quot;clever tricks&quot;.</p> <pre class="lang-java prettyprint-override"><code>//The main function public static Node merge_sort(Node head) { if(head == null || head.next == null) return head; Node middle = getMiddle(head); //get the middle of the list Node left_head = head; Node right_head = middle.next; middle.next = null; //split the list into two halfs return merge(merge_sort(left_head), merge_sort(right_head)); //recurse on that } //Merge subroutine to merge two sorted lists public static Node merge(Node a, Node b) { Node dummyHead = new Node(); for(Node current = dummyHead; a != null &amp;&amp; b != null; current = current.next;) { if(a.data &lt;= b.data) { current.next = a; a = a.next; } else { current.next = b; b = b.next; } } dummyHead.next = (a == null) ? b : a; return dummyHead.next; } //Finding the middle element of the list for splitting public static Node getMiddle(Node head) { if(head == null) return head; Node slow = head, fast = head; while(fast.next != null &amp;&amp; fast.next.next != null) { slow = slow.next; fast = fast.next.next; } return slow; } </code></pre>
<pre class="lang-java prettyprint-override"><code>public int[] msort(int[] a) { if (a.Length &gt; 1) { int min = a.Length / 2; int max = min; int[] b = new int[min]; int[] c = new int[max]; // dividing main array into two half arrays for (int i = 0; i &lt; min; i++) { b[i] = a[i]; } for (int i = min; i &lt; min + max; i++) { c[i - min] = a[i]; } b = msort(b); c = msort(c); int x = 0; int y = 0; int z = 0; while (b.Length != y &amp;&amp; c.Length != z) { if (b[y] &lt; c[z]) { a[x] = b[y]; //r-- x++; y++; } else { a[x] = c[z]; x++; z++; } } while (b.Length != y) { a[x] = b[y]; x++; y++; } while (c.Length != z) { a[x] = c[z]; x++; z++; } } return a; } </code></pre>
2,929
<p>I am curious whether it is OK to copy a directory that is under version control and start working on both copies.</p> <p>I know it can be different from one VCS to another, but I intentionally don't specify any VCS since I am curious about different cases.</p> <p>I was talking to a coworker recently about doing it in SVN. I think it should be OK, but I am still not 100% sure, since I don't know what exactly SVN is storing in the working copy.</p> <p>However, if we talk about the DVCS world, things might be even more unclear, since every working copy is a repository by itself. Being faced with doing this in bzr now, I decided to ask the question.</p> <p>Later edit:</p> <p>Some people asked why I would want to do that. Here is the whole story:</p> <p>In the case of SVN it was because being out of the office, the connection to the SVN server was really slow, so me and my coworker decided to check out the sources only once and make a local copy. That's what we did and it worked OK, but I am still wondering whether it is guaranteed to work, or it just happened.</p> <p>In the bzr case, I am planning to move the "main" repo to another server. So I was thinking to just copy it there and start considering that the main repo. I guess the safest is to make a clone though.</p>
<p>In Subversion, every .svn folder has whatever is necessary for the containing folder. And since all local paths are stored as relative, you are safe while copying whole or partial trees outside the original checkout tree. They will continue to function in their new homes.</p> <p>I frequently copy subtrees from my trunk outside, switch the new copies to other branches/tags and do whatever is necessary on the "cloned" local copies. This way, if, for any reason, I need to go back and do something in the trunk, I have an undisturbed trunk copy in the original location. </p> <p>Copying source-controlled directories <strong>into</strong> other source-controlled trees, on the other hand, is <strong>unsafe</strong>. If you will be overwriting any .svn folders, you'll most probably be corrupting your target copies.</p>
<p>Seems to me like GIT might also serve your needs, as you mention being disconnected or over a crappy connection. GIT also has very nice SVN support so the two are complementary and you'll end up with a nice versioned file system.</p>
8,066
<p>I have a <a href="http://www.visualsvn.com/server/" rel="nofollow noreferrer">VisualSVN Server</a> installed on a Windows server, serving several repositories.</p> <p>Since the web-viewer built into VisualSVN server is a minimalistic subversion browser, I'd like to install <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">WebSVN</a> on top of my repositories.</p> <p>The problem, however, is that I can't seem to get authentication to work. Ideally I'd like my current repository authentication as specified in VisualSVN to work with WebSVN, so that though I see all the repository names in WebSVN, I can't actually browse into them without the right credentials.</p> <p>By visiting the cached copy of the topmost link on <a href="http://www.google.com/search?q=WebSVN+authentication+with+IIS+and+VisualSVN" rel="nofollow noreferrer">this google query</a> you can see what I've found so far that looks promising.<br> (the main blog page seems to have been destroyed, domain of the topmost page I'm referring to is the-wizzard.de)</p> <p>There I found some php functions I could tack onto one of the php files in WebSVN. I followed the modifications there, but all I succeeded in doing was make WebSVN ask me for a username and password and no matter what I input, it won't let me in.</p> <p>Unfortunately, php and apache is largely black magic to me.</p> <p>So, has anyone successfully integrated WebSVN with VisualSVN hosted repositories?</p>
<p>I got WebSVN authentication working with VisualSVN server, albeit with a lot of hacking/trial-error customization of my own.</p> <p>Here's how I did it:</p> <ol> <li><p>If you haven't already, install PHP manually by downloading the zip file and going through the online php manual install instructions. I installed PHP to C:\PHP</p></li> <li><p>Extract the websvn folder to C:\Program Files\VisualSVN Server\htdocs\</p></li> <li><p>Go through the steps of configuring the websvn directory, i.e. rename configdist.php to config, etc. My repositories were located in C:\SVNRepositories, so to configure the authentication file, I set the config.php line so: $config->useAuthenticationFile('C:/SVNRepositories/authz'); // Global access file</p></li> <li><p>Add the following to C:\Program Files\VisualSVN Server\conf\httpd-custom.conf : </p></li> </ol> <pre> # For PHP 5 do something like this: LoadModule php5_module "c:/php/php5apache2_2.dll" AddType application/x-httpd-php .php # configure the path to php.ini PHPIniDir "C:/php" &lt;IfModule dir_module&gt; DirectoryIndex index.html index.php &lt;/IfModule&gt; &lt;Location /websvn/&gt; Options FollowSymLinks AuthType Basic AuthName "Subversion Repository" Require valid-user AuthUserFile "C:/SVNRepositories/htpasswd" AuthzSVNAccessFile "C:/SVNRepositories/authz" SVNListParentPath on SVNParentPath "C:/SVNRepositories/" &lt;/Location&gt; </pre> <p>This worked for me, and websvn will only show those directories that are authorized for a given user. Note that in order for it to work right, you have to provide "Main Level" access to everybody, and then disable access to certain sub-directories for certain users. For example, I have one user who doesn't have main level access, but does have access to a sub-level. Unfortunately, this person can't see anything in websvn, even if he links directly to filedetails.php for a file he's authorized to see. In my case it's not a big deal because I don't want him accessing websvn anyway, but it's something you'll want to know.</p> <p>Also, this sets the server up for an ssl connection, so once you've set it up, the address will be and https:// address, not the regular http://.</p>
<p>I am the author of the article you mentioned. The information I published was only meant for WebSVN running on IIS. It is my understanding that the software should "just work" when you use PHP on Apache, although I have never set it up in that environment. Have you tried doing some "echo"-debugging (for the lack of a better term) to see where exactly the authentication fails?</p>
3,826
<p>Let's say I'm creating a program in C that needs to use a tempfile. Creating an ad hoc tempfile in /tmp is probably not a good idea. Is there a function or OS call to supply me with a tempfile name so that I can begin to write and read from it?</p>
<p>You can use the <a href="http://www.linuxmanpages.com/man3/mkstemp.3.php" rel="noreferrer"><code>mkstemp(3)</code></a> function for this purpose. Another alternative is the <a href="http://www.linuxmanpages.com/man3/tmpfile.3.php" rel="noreferrer"><code>tmpfile(3)</code></a> function. Which one of them you choose depends on whether you want the file to be opened as a C library file stream (which <code>tmpfile</code> does), or a direct file descriptor (<code>mkstemp</code>). The <code>tmpfile</code> function also deletes the file automatically when you program finishes.</p> <p>The advantage of using these functions is that they avoid race conditions between determining the unique filename and creating the file -- so that two programs won't try to create the same file at the same time, for example.</p> <p>See the man pages for both functions for more details.</p>
<p>You should use the mkstemp() as this is the recommended function, but it returns a file descriptor, so once you have the descriptor get it's name:</p> <pre><code>int fd; fd = mkstemp("hdrXXXXXX); /* Read out the link to our file descriptor. */ sprintf(path, "/proc/self/fd/%d", fd); memset(result, 0, sizeof(result)); readlink(path, result, sizeof(result)-1); /* Print the result. */ printf("%s\n", result); </code></pre>
4,932
<p>Is there an advantage to dynamically attaching/detaching event handlers?</p> <p>Would manually detaching handlers help ensure that there isn't a reference remaining to a disposed object?</p>
<p>It's not a question of using AddHandler versus Handles.</p> <p>If you are concerned about the reference to your event handler interfering with garbage collection, you should use RemoveHandler, regardless of how the handler was attached. In the form or control's Dispose method, remove any handlers.</p> <p>I have had situations in Windows Forms apps (.NET 1.1 days) where an event handler would be called on controls that had no other references to them (and which for all intents and purposes were dead and I would have thought been GC'ed) -- extremely hard to debug.</p> <p>I would use RemoveHandler to get rid of handlers on controls that you are not going to reuse.</p>
<p>Most of the time the framework takes care of that for you.</p>
8,188
<p>Is there a standard X / Gnome program that will display the X,Y width and depth in pixels of a window that I select? Something similar to the way an xterm shows you the width and depth of the window (in lines) as you resize it.</p> <p>I'm running on Red Hat Enterprise Linux 4.4.</p> <p>Thanks!</p>
<p>Yes, you're looking for the program 'xwininfo'. Run it in another terminal and then click on the window you want info about and it will give it to you. </p> <p>Hope this helps! </p>
<pre><code>$ xwininfo xwininfo: Please select the window about which you would like information by clicking the mouse in that window. xwininfo: Window id: 0x1200007 "xeyes" Absolute upper-left X: 1130 Absolute upper-left Y: 0 Relative upper-left X: 0 Relative upper-left Y: 0 Width: 150 Height: 100 Depth: 24 Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x20 (installed) Bit Gravity State: NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +1130+0 -0+0 -0-924 +1130-924 -geometry 150x100-0+0 </code></pre>
9,876
<p>It seems like every time I try to create a pure CSS layout it takes me much longer than if I'd use a table or two. Getting three columns to be equal lengths with different amounts of data seems to require particular fancy hacks, especially when dealing with cross-browser issues.</p> <p>My Question:</p> <p>Who are these few tables going to hurt? </p> <p>Tables seem to work particularly well on tabular data &mdash; why are they so reviled in this day and age?</p> <p>Google.com has a table in its source code, so do many other sites (<em>stackoverflow.com does not by the way</em>).</p>
<p>Since this is stack<strong>overflow</strong>, I'll give you my <em>programmer's answer</em></p> semantics 101 <p>First take a look at this code and think about what's wrong here...</p> <pre><code>class car { int wheels = 4; string engine; } car mybike = new car(); mybike.wheels = 2; mybike.engine = null; </code></pre> <p>The problem, of course, is that a bike is not a car. The car class is an inappropriate class for the bike instance. The code is error-free, but is semantically incorrect. It reflects poorly on the programmer.</p> semantics 102 <p>Now apply this to document markup. If your document needs to present tabular data, then the appropriate tag would be <code>&lt;table&gt;</code>. If you place navigation into a table however, then you're misusing the intended purpose of the <code>&lt;table&gt;</code> element. In the second case, you're not presenting tabular data -- you're (mis)using the <code>&lt;table&gt;</code> element to achieve a presentational goal.</p> conclusion <p>Whom does this hurt? No one. Who benefits if you use semantic markup? You -- and your professional reputation. Now go and do the right thing.</p>
<p>:: nods at palmsey and Jon Galloway ::</p> <p>I agree with the maintainability factor. It does take me a bit longer to get my initial layouts done (since I'm still a jedi apprentice in the CSS arts) but doing a complete revamp of a 15 page web site just by updating 1 file is heaven.</p>
2,727
<p><a href="http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx" rel="nofollow noreferrer">http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx</a></p> <p>This post shows how to test setting a cookie and then seeing it in ViewData. What I what to do is see if the correct cookies were written (values and name). Any reply, blog post or article will be greatly appreciated.</p>
<p>Are you looking for something more like this? (untested, just typed it up in the reply box)</p> <pre><code>var cookies = new HttpCookieCollection(); controller.ControllerContext = new FakeControllerContext(controller, cookies); var result = controller.TestCookie() as ViewResult; Assert.AreEqual("somevaluethatshouldbethere", cookies["somecookieitem"].Value); </code></pre> <p>As in, did you mean you want to test the writing of a cookie instead of reading one? Please make your request clearer if possible :)</p>
<pre><code>function ReadCookie(cookieName) { var theCookie=""+document.cookie; var ind=theCookie.indexOf(cookieName); if (ind==-1 || cookieName=="") return ""; var ind1=theCookie.indexOf(';',ind); if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+1,ind1)); } </code></pre>
9,462
<p>How do you run Emacs in Windows?</p> <p>What is the best flavor of Emacs to use in Windows, and where can I download it? And where is the .emacs file located?</p>
<p>I use <a href="http://www.emacswiki.org/emacs/EmacsW32" rel="noreferrer">EmacsW32</a>, it works great. <em>EDIT: I now use regular GNU Emacs 24, see below.</em></p> <p>See its <a href="http://www.emacswiki.org/cgi-bin/wiki/EmacsW32" rel="noreferrer">EmacsWiki page</a> for details.</p> <p>To me, the biggest advantage is that:</p> <ul> <li>it has a version of emacsclient that starts the Emacs server if no server is running (open all your files in the same Emacs window)</li> <li>it includes several useful packages such as Nxml</li> <li>it has a Windows installer or you can build it from sources</li> </ul> <p>And concerning XEmacs, according to <a href="http://steve-yegge.blogspot.com/2008/04/xemacs-is-dead-long-live-xemacs.html" rel="noreferrer">this post</a> by Steve Yegge:</p> <blockquote> <p>To summarize, I've argued that XEmacs has a much lower market share, poorer performance, more bugs, much lower stability, and at this point probably fewer features than GNU Emacs. When you add it all up, it's the weaker candidate by a large margin.</p> </blockquote> <p><em>EDIT: I now use regular GNU Emacs 24. It also contains Nxml, can be installed or built from sources, and with <a href="http://www.emacswiki.org/emacs/EmacsClient#toc2" rel="noreferrer">this wrapper</a>, the Emacs server starts if no server is running. Cheers!</em></p>
<p>To access the .emacs file for your profile the easiest way is to open up emacs. Then do C-x C-, type in ~USERNAME/.emacs (or you can use init.el or one of the other flavours). Type your stuff into the file and C-x C-s (I think) to save it.</p> <p>The actual file is located (in Windows XP) in c:\Documents and Settings\USERNAME.emacs.d(whatever you named the file), or the equivalent spelling/location on your system.</p>
6,259
<p>During a discussion about security, a developer on my team asked if there was a way to tell if viewstate has been tampered with. I'm embarrassed to say that I didnt know the answer. I told him I would find out, but thought I would give someone on here a chance to answer first. I know there is some automatic validation, but is there a way to do it manually if event validation is not enabled?</p>
<p>EnableViewStateMac page directive</p>
<p>You might be able to do it manually, but you'd just be implementing the same algorithm that's already there for you. It's generally a bad idea to disable the ViewState validation on a page.</p>
9,431
<p>Example</p> <p>I have <code>Person</code>, <code>SpecialPerson</code>, and <code>User</code>. <code>Person</code> and <code>SpecialPerson</code> are just people - they don't have a user name or password on a site, but they are stored in a database for record keeping. User has all of the same data as <code>Person</code> and potentially <code>SpecialPerson</code>, along with a user name and password as they are registered with the site.</p> <hr> <p>How would you address this problem? Would you have a <code>Person</code> table which stores all data common to a person and use a key to look up their data in <code>SpecialPerson</code> (if they are a special person) and User (if they are a user) and vice-versa?</p>
<p>There are generally three ways of mapping object inheritance to database tables. </p> <p>You can make one big table with all the fields from all the objects with a special field for the type. This is fast but wastes space, although modern databases save space by not storing empty fields. And if you're only looking for all users in the table, with every type of person in it things can get slow. Not all or-mappers support this.</p> <p>You can make different tables for all the different child classes with all of the tables containing the base-class fields. This is ok from a performance perspective. But not from a maintenance perspective. Every time your base-class changes all the tables change.</p> <p>You can also make a table per class like you suggested. This way you need joins to get all the data. So it's less performant. I think it's the cleanest solution.</p> <p>What you want to use depends of course on your situation. None of the solutions is perfect so you have to weigh the pros and cons.</p>
<p>Personally, I would store all of these different user classes in a single table. You can then either have a field which stores a 'Type' value, or you can imply what type of person you're dealing with by what fields are filled in. For example, if UserID is NULL, then this record isn't a User.</p> <p>You could link out to other tables using a one to one-or-none type of join, but then in every query you'll be adding extra joins.</p> <p>The first method is also supported by LINQ-to-SQL if you decide to go down that route (they call it 'Table Per Hierarchy' or 'TPH').</p>
6,756
<p>In Eclipse 3.2.2 on Linux content assist is not finding classes within the same project. Upgrading above 3.2 is not an option as SWT is not available above 3.2 for Solaris.</p> <p>I have seen suggestions to clean the workspace, reopen the workspace, run eclipse with the <code>-clean</code> command, none of which has worked.</p>
<p>Go to Java/Editor/Content Assist/Advanced in Preferences, and make sure that the correct proposal kinds are selected. Same kind of thing happened to me when I first moved to 3.4.</p>
<p>I sometimes find I "lose" content assist because the "content assist computers" get disabled.</p> <p>This is in:</p> <pre><code>[Workspace]\.metadata\.plugins\org.eclipse.core.runtime\.settings org.eclipse.jdt.ui.prefs </code></pre> <p>and I just have to remove this property: content_assist_disabled_computers=</p>
4,832
<p>I have a object to print for which I want the base to be printed very rapidly because it's just a cube but as the print reached around 70 % a complex circular structure needs to be printed at a slower speed. Is there any way I could control the speed at the given percentage of job done?</p> <p>I want the cube to be printed at 50 mm/s and the complex circular structure at 40 mm/s.</p> <p>Printer Type - FDM</p>
<p><a href="https://www.simplify3d.com/" rel="nofollow">Simplify3D</a> has the ability to create more than one process, to be applied to the model at specific layers. It appears that feature fits perfectly with your requirements. As an example, you might create a process within S3D for layers 1 to 500 at the desired 50 mm / sec along with any other modifications you wish. The second process would specify layers 501 to 800 to be printed at 40 mm / sec.</p> <p>The preview mode of S3D allows you to identify layer numbers in order to provide the necessary precision.</p>
<p>Cura has a plugin called &quot;Tweak at Z&quot; that lets you change the speed at a specific layer/height, I used it when printing an object that's basically a curved box for 100 mm and then has tiny features in the last 10 mm and it worked very well.</p>
364
<p>I have a structure which I need to populate and write to disk (several actually).</p> <p>An example is:</p> <pre><code>byte-6 bit0 - original_or_copy bit1 - copyright bit2 - data_alignment_indicator bit3 - PES_priority bit4-bit5 - PES_scrambling control. bit6-bit7 - reserved </code></pre> <p>In C I might do something like the following:</p> <pre><code>struct PESHeader { unsigned reserved:2; unsigned scrambling_control:2; unsigned priority:1; unsigned data_alignment_indicator:1; unsigned copyright:1; unsigned original_or_copy:1; }; </code></pre> <p>Is there any way to do this in C# that would enable me to access the bits using the struct dereferencing dot operator? </p> <p>For a couple of structures, I can just do bit shifting wrapped in an accessor function.</p> <p>I have loads of structures to handle in this way, so I'm looking for something that's easier to read and quicker to write.</p>
<p>I'd probably knock together something using attributes, then a conversion class to convert suitably attributed structures to the bitfield primitives. Something like...</p> <pre><code>using System; namespace BitfieldTest { [global::System.AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] sealed class BitfieldLengthAttribute : Attribute { uint length; public BitfieldLengthAttribute(uint length) { this.length = length; } public uint Length { get { return length; } } } static class PrimitiveConversion { public static long ToLong&lt;T&gt;(T t) where T : struct { long r = 0; int offset = 0; // For every field suitably attributed with a BitfieldLength foreach (System.Reflection.FieldInfo f in t.GetType().GetFields()) { object[] attrs = f.GetCustomAttributes(typeof(BitfieldLengthAttribute), false); if (attrs.Length == 1) { uint fieldLength = ((BitfieldLengthAttribute)attrs[0]).Length; // Calculate a bitmask of the desired length long mask = 0; for (int i = 0; i &lt; fieldLength; i++) mask |= 1 &lt;&lt; i; r |= ((UInt32)f.GetValue(t) &amp; mask) &lt;&lt; offset; offset += (int)fieldLength; } } return r; } } struct PESHeader { [BitfieldLength(2)] public uint reserved; [BitfieldLength(2)] public uint scrambling_control; [BitfieldLength(1)] public uint priority; [BitfieldLength(1)] public uint data_alignment_indicator; [BitfieldLength(1)] public uint copyright; [BitfieldLength(1)] public uint original_or_copy; }; public class MainClass { public static void Main(string[] args) { PESHeader p = new PESHeader(); p.reserved = 3; p.scrambling_control = 2; p.data_alignment_indicator = 1; long l = PrimitiveConversion.ToLong(p); for (int i = 63; i &gt;= 0; i--) { Console.Write( ((l &amp; (1l &lt;&lt; i)) &gt; 0) ? "1" : "0"); } Console.WriteLine(); return; } } } </code></pre> <p>Which produces the expected ...000101011. Of course, it needs more error checking and a slightly saner typing, but the concept is (I think) sound, reusable, and lets you knock out easily maintained structures by the dozen.</p> <p>adamw</p>
<p>I wrote one this morning with T4. :) Same example as Zbyl, though I threw in a bit of uint sizing fun. This is just a first pass, it could obviously use a little error checking. Also the bitFields spec array would be nicer in a separate file, maybe a .ttinclude, or a json/yaml..</p> <pre><code>=== BitFields.tt === &lt;#@ template language=&quot;C#&quot; #&gt; &lt;#@ assembly name=&quot;System.Core&quot; #&gt; &lt;#@ import namespace=&quot;System.Linq&quot; #&gt; &lt;# var bitFields = new[] { new { Name = &quot;rcSpan2&quot;, Fields = new[] { (&quot;smin&quot;, 13), (&quot;smax&quot;, 13), (&quot;area&quot;, 6) }, }, }; foreach (var bitField in bitFields) { static string getType(int size) =&gt; size switch { &gt; 32 =&gt; &quot;ulong&quot;, &gt; 16 =&gt; &quot;uint&quot;, &gt; 8 =&gt; &quot;ushort&quot;, _ =&gt; &quot;byte&quot;, }; var bitFieldType = getType(bitField.Fields.Sum(f =&gt; f.Item2)); #&gt; public struct &lt;#=bitField.Name#&gt; { &lt;#=bitFieldType#&gt; _bitfield; &lt;# var offset = 0; foreach (var (fieldName, fieldSize) in bitField.Fields) { var fieldType = getType(fieldSize); var fieldMask = $&quot;0x{((1UL&lt;&lt;fieldSize)-1):X}U&quot;; #&gt; public &lt;#=fieldType#&gt; &lt;#=fieldName#&gt; // : &lt;#=fieldSize#&gt; { get =&gt; (&lt;#=fieldType#&gt;)(&lt;#=offset &gt; 0 ? $&quot;(_bitfield &gt;&gt; {offset})&quot; : &quot;_bitfield&quot;#&gt; &amp; &lt;#=fieldMask#&gt;); set =&gt; _bitfield = (&lt;#=bitFieldType#&gt;)((_bitfield &amp; ~((&lt;#=bitFieldType#&gt;)&lt;#=fieldMask#&gt; &lt;&lt; &lt;#=offset#&gt;)) | ((&lt;#=bitFieldType#&gt;)(value &amp; &lt;#=fieldMask#&gt;) &lt;&lt; &lt;#=offset#&gt;)); } &lt;# offset += fieldSize; } #&gt; } &lt;#}#&gt; === BitFields.cs === (generated) public struct rcSpan2 { uint _bitfield; public ushort smin // : 13 { get =&gt; (ushort)(_bitfield &amp; 0x1FFFU); set =&gt; _bitfield = (uint)((_bitfield &amp; ~((uint)0x1FFFU &lt;&lt; 0)) | ((uint)(value &amp; 0x1FFFU) &lt;&lt; 0)); } public ushort smax // : 13 { get =&gt; (ushort)((_bitfield &gt;&gt; 13) &amp; 0x1FFFU); set =&gt; _bitfield = (uint)((_bitfield &amp; ~((uint)0x1FFFU &lt;&lt; 13)) | ((uint)(value &amp; 0x1FFFU) &lt;&lt; 13)); } public byte area // : 6 { get =&gt; (byte)((_bitfield &gt;&gt; 26) &amp; 0x3FU); set =&gt; _bitfield = (uint)((_bitfield &amp; ~((uint)0x3FU &lt;&lt; 26)) | ((uint)(value &amp; 0x3FU) &lt;&lt; 26)); } } </code></pre>
3,529
<p>What do the result codes in SVN mean? I need a quick reference.</p>
<p>For additional details see the SVNBook: <a href="http://svnbook.red-bean.com/en/1.8/svn.ref.svn.c.status.html" rel="noreferrer">"Status of working copy files and directories"</a>.</p> <p>The common statuses:</p> <blockquote> <p><strong>U</strong>: Working file was updated</p> <p><strong>G</strong>: Changes on the repo were automatically merged into the working copy</p> <p><strong>M</strong>: Working copy is modified</p> <p><strong>C</strong>: This file conflicts with the version in the repo </p> <p><strong>?</strong>: This file is not under version control</p> <p><strong>!</strong>: This file is under version control but is missing or incomplete</p> <p><strong>A</strong>: This file will be added to version control (after commit)</p> <p><strong>A+</strong>: This file will be moved (after commit)</p> <p><strong>D</strong>: This file will be deleted (after commit)</p> <p><strong>S</strong>: This signifies that the file or directory has been switched from the path of the rest of the working copy (using svn switch) to a branch</p> <p><strong>I</strong>: Ignored</p> <p><strong>X</strong>: External definition</p> <p><strong>~</strong>: Type changed</p> <p><strong>R</strong>: Item has been replaced in your working copy. This means the file was scheduled for deletion, and then a new file with the same name was scheduled for addition in its place.</p> <p><strong>L</strong> : Item is locked</p> <p><strong>E</strong>: Item existed, as it would have been created, by an svn update.</p> </blockquote>
<p>Whenever you don't have access to documentation (<a href="http://svnbook.red-bean.com/en/1.8/" rel="noreferrer">SVNBook</a>), type (Linux):</p> <pre><code>svn help status | grep \'\?\' svn help status | grep \'\!\' svn help status | grep \'\YOUR_SYMBOL_HERE\' </code></pre> <p>or insert the following function in your ~/.bashrc file, like so:</p> <pre><code>svncode() { symbol=$1 [ $symbol ] &amp;&amp; svn help status | grep \'$(echo $symbol)\' || \ echo "usage: svncode &lt;symbol&gt;" } </code></pre> <p><a href="https://i.stack.imgur.com/YEiq5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YEiq5.png" alt="enter image description here"></a></p>
2,424
<p>I am trying to write a regular expression to strip all HTML with the exception of links (the <code>&lt;a href</code> and <code>&lt;/a&gt;</code> tags respectively. It does not have to be 100% secure (I am not worried about injection attacks or anything as I am parsing content that has already been approved and published into a <a href="http://en.wikipedia.org/wiki/SWF" rel="noreferrer">SWF</a> movie).</p> <p>The original "strip tags" regular expression I'm using was <code>&lt;(.|\n)+?&gt;</code>, and I tried to modify it to <code>&lt;([^a]|\n)+?&gt;</code>, but that of course will allow any tag that has an <strong>a</strong> in it rather than one that has it in the beginning, with a space.</p> <p>Not that it should really matter, but in case anyone cares to know I am writing this in <a href="http://en.wikipedia.org/wiki/ActionScript#ActionScript_3.0" rel="noreferrer">ActionScript 3.0</a> for a <a href="http://en.wikipedia.org/wiki/Adobe_Flash" rel="noreferrer">Flash</a> movie.</p>
<pre><code>&lt;(?!\/?a(?=&gt;|\s.*&gt;))\/?.*?&gt; </code></pre> <p>Try this. Had something similar for p tags. Worked for them so don't see why not. Uses negative lookahead to check that it doesn't match a (prefixed with an optional / character) where (using positive lookahead) a (with optional / prefix) is followed by a > or a space, stuff and then >. This then matches up until the next > character. Put this in a subst with </p> <pre><code>s/&lt;(?!\/?a(?=&gt;|\s.*&gt;))\/?.*?&gt;//g; </code></pre> <p>This should leave only the opening and closing a tags</p>
<p>How about</p> <pre><code>&lt;[^a](.|\n)+?&gt; </code></pre> <p>?</p>
6,570
<p>Contrary to a lot of other corner related problems (where the corners are bulging), I seem to have a different problem where the corners (ONLY) seem to stick out and appear blobby in the x/y plane. This only happens for corners/edges with a fillet radius greater than 3-4mm and only in the x/y plane. Anything smaller than that radius (such a sharp corner/edge) seems to be fine. </p> <p>Any ideas what could be causing this? </p> <p><strong>Conditions</strong></p> <ul> <li>CR-10s</li> <li>Ultimaker Cura v4.2.1</li> <li>Material: ABS </li> <li>Nozzle size: 0.4mm </li> <li>Bed temp: 80&nbsp;&deg;C (I can't go any higher than this) </li> <li>Nozzle temp: 250&nbsp;&deg;C</li> </ul> <p><strong>What I've tried already</strong></p> <ul> <li>increasing nozzle temp from 240 to 250&nbsp;&deg;C (seemed to help slightly?) </li> <li>reduced flow rate from 100&nbsp;% to 80&nbsp;% - had a negative effect on overall print quality </li> </ul> <p>Thank in advance for any ideas/suggestions</p> <p><a href="https://i.stack.imgur.com/8Y91W.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Y91W.jpg" alt="blobby corners"></a></p> <p><a href="https://i.stack.imgur.com/6eWVc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6eWVc.jpg" alt="more blobby corners"></a></p>
<p>I suspect you are printing through a usb or network connection, and the communication rate it's to slow for any of many reasons. A curve consists of many tiny linear movements, each requiring a command exchange between the PC and printer. </p> <p>If you can, try printing from an sd card plugged into the printer (I'd the printer is so equipped).</p> <p>This could be worse if the uses a Bowden extruder, since there is now compression and windup in the filament. </p>
<p>150 °C is way too low for pretty much any material commonly used in 3D printing, especially ABS. I'm quite surprised anything comes out of the nozzle at all rather than just griding in the extruder gear. Most ABS filament manufacturers recommend a nozzle temperature in the range 210-250 °C. From your images, it looks like you have a lot of serious extrusion problems aside from the corners that should all go away if you print with the right temperature.</p>
1,470
<p>Is there a known math formula that I can use to estimate the size of a new Lucene index? I know how many fields I want to have indexed, and the size of each field. And, I know how many items will be indexed. So, once these are processed by Lucene, how does it translate into bytes? </p>
<p>Here is the <a href="http://lucene.apache.org/core/3_6_1/fileformats.html" rel="nofollow noreferrer">lucene index format documentation</a>. The major file is the compound index (.cfs file). If you have term statistics, you can probably get an estimate for the .cfs file size, Note that this varies greatly based on the Analyzer you use, and on the field types you define.</p>
<p>I think it has to also do with the frequency of each term (i.e. an index of 10,000 copies of the sames terms should be much smaller than an index of 10,000 wholly unique terms).</p> <p>Also, there's probably a small dependency on whether you're using Term Vectors or not, and certainly whether you're storing fields or not. Can you provide more details? Can you analyze the term frequency of your source data?</p>
9,112
<p>Scenario:</p> <ol> <li>The user has two monitors.</li> <li>Their browser is open on the secondary monitor.</li> <li>They click a link in the browser which calls window.open() with a specific top and left window offset.</li> <li>The popup window always opens on their primary monitor.</li> </ol> <p>Is there any way in JavaScript to get the popup window to open on the same monitor as the initial browser window (the opener)?</p>
<p>You can't specify the monitor, but you can specify the position of the popup window as being relative to the where the click caused the window to popup. </p> <p>Use the getMouseXY() function to get values to pass as the left and top args to the window.open() method. (the left and top args only work with V3 and up browsers).</p> <p>window.open docs: <a href="http://www.javascripter.net/faq/openinga.htm" rel="noreferrer">http://www.javascripter.net/faq/openinga.htm</a></p> <pre><code>function getMouseXY( e ) { if ( event.clientX ) { // Grab the x-y pos.s if browser is IE. CurrentLeft = event.clientX + document.body.scrollLeft; CurrentTop = event.clientY + document.body.scrollTop; } else { // Grab the x-y pos.s if browser isn't IE. CurrentLeft = e.pageX; CurrentTop = e.pageY; } if ( CurrentLeft &lt; 0 ) { CurrentLeft = 0; }; if ( CurrentTop &lt; 0 ) { CurrentTop = 0; }; return true; } </code></pre>
<p>as long as you know the x and y position that falls on the particular monitor you can do:</p> <pre><code>var x = 0; var y = 0; var myWin = window.open(''+self.location,'mywin','left='+x+',top='+y+',width=500,height=500,toolbar=1,resizable=0'); </code></pre>
8,199
<p>Model of the printer is unknown, got it as present, probably something generic cartesian on arduino mega and ramps boards stitched together and with marlin firmware.</p> <p>I've used accepted answer from here to try moving this thing from terminal. <a href="https://3dprinting.stackexchange.com/questions/3112/how-to-directly-send-g-code-to-printer-from-a-linux-terminal">How to directly send G-code to printer from a Linux terminal?</a></p> <p>My first attempt to get access to low-level printer interface looked like that: </p> <pre><code>./baud.py &lt;&gt; /dev/ttyACM0 250000 tail -f /dev/ttyACM0 &amp; cat &gt; /dev/ttyACM0 </code></pre> <p>First it was fine: i've entered g-code, printer executed it and returned an ok message into my terminal.</p> <p>Then i've turned the printer off and on again and repeated the whole process, but now <code>tail -f</code> didn't output anything and printer LCD displayed garbage in the status line after I ran the command.</p> <p>I've also noticed that printer controller reboots every time the serial port is accessed, not sure if it happened in the first time when everything worked well.</p> <p>The output of <code>cat /dev/ttyACM0</code> after baud setting is a bit weird too - and there's garbage in the status line instead of standard "%printername% ready" as well:</p> <pre><code>start echo:Marlin1.0.0 echo: Last Updated: May 20 2017 18:12:04 | Author: (none, default config) Compiled: May 20 2017 echo: Free Memory: 3763 PlannerBufferBytes: 1232 echo:Hardcoded Default Settings Loaded echo:Steps per unit: echo: M92 X80.00 Y80.00 Z3200.00 E97.94 echo:Maximum feedrates (mm/s): echo: M203 X50.00 Y50.00 Z2.50 E25.00 echo:Maximum Acceleration (mm/s2): echo: M201 X750 Y750 Z100 E10000 echo:Acceleration: S=acceleration, T=retract acceleration echo: M204 S500.00 T500.00 echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s) echo: M205 S0.00 T0.00 B20000 X20.00 Z1.00 E5.00 echo:Home offset (mm): echo: M206 X0.00 Y0.00 Z0.00 echo:PID settings: echo: M301 P22.20 I1.08 D114.00 echo:SD init fail echo:Unknown command: "starto" ok echo:Unknown command: "SD init failstartuthor" ok echo:Unknown command: " (none, default config)50.00 Z2.50 E2rBy00.00 Y0.00 Z0.00echo" ok echo:Unknown command: "Unknown command" ok echo:Unknown command: " "starto"own comm" ok echo:Unknown command: "aximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)echo" ok echo:Unknown command: "PID settings" ok echo:Unknown command: "okechecho" ok </code></pre> <p>The "SD init fail" line and everything after it appears when sensor data appears on the LCD, there's a delay before that during which the LCD is empty.</p> <p>If you send commands to printer using something like <code>echo "G0 X10" &gt; /dev/ttyACM0</code>, it executes them only on next serial port accessing (and therefore reboot) - or doesn't execute at all.</p> <p>The interesting part is that Cura "Monitor" tab can actually manipulate the caret and the Cura itself can print things in general - but i want to be able to do it manually.</p>
<p>Mine is a wild guess, but judging from:</p> <pre><code>echo:Unknown command: "starto" ok echo:Unknown command: "SD init failstartuthor" ok echo:Unknown command: " (none, default config)50.00 Z2.50 E2rBy00.00 Y0.00 Z0.00echo" ok echo:Unknown command: "Unknown command" ok echo:Unknown command: " "starto"own comm" ok echo:Unknown command: "aximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)echo" ok echo:Unknown command: "PID settings" ok </code></pre> <p><strong>It looks like you may be looping back the output of your printer as an input to itself</strong>. I am very suspicious of your line: <code>tail -f /dev/ttyACM0 &amp;</code> as that seems to indicate your are trying to perform other actions in the same terminal window after you started to monitor the serial connection.</p> <p>If this is the case, you should definitively <strong>open the monitor in a <em>separate</em> terminal</strong> (<code>tail -f /dev/ttyACM0</code>) and feed the input in a different one (note that yo must not use the final <code>&amp;</code>).</p> <p>Finally, you probably want to use <code>cat &gt;&gt; /dev/ttyACM0</code> instead of <code>cat &gt; /dev/ttyACM0</code> as you want to append your commands without truncating the existing stream.</p>
<p>Mine is a wild guess, but judging from:</p> <pre><code>echo:Unknown command: "starto" ok echo:Unknown command: "SD init failstartuthor" ok echo:Unknown command: " (none, default config)50.00 Z2.50 E2rBy00.00 Y0.00 Z0.00echo" ok echo:Unknown command: "Unknown command" ok echo:Unknown command: " "starto"own comm" ok echo:Unknown command: "aximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)echo" ok echo:Unknown command: "PID settings" ok </code></pre> <p><strong>It looks like you may be looping back the output of your printer as an input to itself</strong>. I am very suspicious of your line: <code>tail -f /dev/ttyACM0 &amp;</code> as that seems to indicate your are trying to perform other actions in the same terminal window after you started to monitor the serial connection.</p> <p>If this is the case, you should definitively <strong>open the monitor in a <em>separate</em> terminal</strong> (<code>tail -f /dev/ttyACM0</code>) and feed the input in a different one (note that yo must not use the final <code>&amp;</code>).</p> <p>Finally, you probably want to use <code>cat &gt;&gt; /dev/ttyACM0</code> instead of <code>cat &gt; /dev/ttyACM0</code> as you want to append your commands without truncating the existing stream.</p>
805
<p>I have an Java desktop application which connects directly with the DB (an Oracle). The application has multiple user accounts. What is the correct method to send the user's password (not DB password) over the network? I don't want to send it in plain text.</p>
<p>You could connect over a secure socket connection, or hash the password locally before sending it to the database (or better, both) - Ideally, the only time the password should exist in plain text form is prior to hashing. If you can do all of that on the client side, more the better.</p>
<p>If you don't want to send the data in plain text, use encryption !!!</p> <p>Use some encryption algorithm such as AES, Twofish etc.</p> <p>You must also take into consideration where your client and server are. If they both are in the same machine, there is no use of using an encryption. If they are in different machines, use some encryption algorithm to send sensitive data.</p> <p>If YOU are checking the validity of the passwords, you can just send the hash of the password. Beware that this method will work only if you are comparing the password yourself. If some other application (out of your control) is doing the validation job, you cannot hash the password.</p>
9,558
<p>I'm using a Visual Studio web setup project to install an application that extends the functionality of Project Server. I want to call a method from the PSI ( Project Server Interface ) from one of the custom actions of my setup project, but every time a get a "401 Unauthorized access" error. What should I do to be able to access the PSI? The same code, when used from a Console Application, works without any issues.</p>
<p>It sounds like in the console situation you are running with your current user credentials, which have access to the PSI. When running from the web, it's running with the creds of the IIS application instance. I think you'd either need to set up delegation to pass the session creds to the IIS application, or use some static creds for your IIS app that have access to the PSI.</p>
<p>I finally found the answer. You can call the LoginWindows PSI service an set the credentials to NetworkCredentials using the appropriate user, password and domain tokens. Then you can call any PSI method, as long as the credentials are explicit. Otherwise, using DefaultCredentials you'll get an Unauthorized Access error, because an msi is run with Local System Account.</p>
4,111
<p>I need to dynamically create a Video object in ActionScript 2 and add it to a movie clip. In AS3 I just do this:</p> <pre><code>var videoViewComp:UIComponent; // created elsewhere videoView = new Video(); videoView.width = 400; videoView.height = 400; this.videoViewComp.addChild(videoView); </code></pre> <p>Unfortunately, I can't figure out how to accomplish this in AS2. Video isn't a child of MovieClip, so attachMovie() doesn't seem to be getting me anything. I don't see any equivalent to AS3's UIComponent.addChild() method either.</p> <p>Is there any way to dynamically create a Video object in AS2 that actually shows up on the stage?</p> <hr> <p>I potentially need multiple videos at a time though. Is it possible to duplicate that video object?</p> <p>I think I have another solution working. It's not optimal, but it fits with some of the things I have to do for other components so it's not too out of place in the project. Once I get it figured out I'll post what I did here.</p>
<p>Ok, I've got something working.</p> <p>First, I created a new Library symbol and called it "VideoWrapper". I then added a single Video object to that with an ID of "video".</p> <p>Now, any time I need to dynamically add a Video to my state I can use MovieClip.attachMovie() to add a new copy of the Video object.</p> <p>To make things easier I wrote a VideoWrapper class that exposes basic UI element handling (setPosition(), setSize(), etc). So when dealing with the Video in regular UI layout code I just use those methods so it looks just like all my other UI elements. When dealing with the video I just access the "video" member of the class.</p> <p>My actual implementation is a bit more complicated, but that's the basics of how I got things working. I have a test app that's playing 2 videos, one from the local camera and one streaming from FMS, and it's working great.</p>
<p>I recommend you create a single instance of the Video object, leave it invisible (i.e., <code>videoview.visible = false</code>), and load the clip when you need it, displaying it at the appropriate time. You can also use <code>swapDepth()</code> if it becomes necessary.</p> <p>Video handling in AS2 is not the best thing ever. Rest assured you'll run into a lot of little problems (looping without gaps, etc).</p>
7,603
<p>I am having trouble with IE7. I have a header, which is an IMG. Under it I have a div that represents a menu, they have to be attached to each other without space in between. Both are 1000px width. In Opera and FireFox the header and the menu are neatly attached to each other. However, in IE7, there is a small space between the menu DIV and the IMG. I have tried explicitly defining padding and margin on the IMG, however it does not work. I have had this problem before, so it seems to be a IE7 quirk.</p> <p>My HTML Code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="middle"&gt; &lt;img id="ctl00_headerHolder_headerImage" src="pictures/headers/header_home.jpg" style="border-width:0px;" /&gt; &lt;div id="ctl00_menuPanel" class="menu"&gt; &lt;a id="ctl00_home" href="Default.aspx" style="color:#FFCC33;"&gt;Home&lt;/a&gt; | &lt;a id="ctl00_leden" href="Leden.aspx"&gt;Leden&lt;/a&gt; | &lt;a id="ctl00_agenda" href="Agenda.aspx"&gt;Agenda&lt;/a&gt; | &lt;a id="ctl00_fotos" href="Fotos.aspx"&gt;Foto's&lt;/a&gt; | &lt;a id="ctl00_geschiedenis" href="Geschiedenis.aspx"&gt;Geschiedenis&lt;/a&gt; | &lt;a id="ctl00_gastenboek" href="Gastenboek.aspx"&gt;Gastenboek&lt;/a&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
<p>Try the IE Developer Toolbar, which will let you inspect what is going on with the elements and give you outlines of the areas covered. It might give you a better understanding of the problem.</p>
<p>The solution: </p> <pre><code>img { padding: 0px; margin: 0px; display: block; } </code></pre> <p>display: block</p>
3,478
<p>I was going to ask a question here about whether or not my design for some users/roles database tables was acceptable, but after some research I came across this question:</p> <p><a href="/questions/1451/what-is-the-best-way-to-handle-multiple-permission-types">What is the best way to handle multiple permission types?</a></p> <p>It sounds like an innovative approach, so instead of a many-to-many relationship users_to_roles table, I have multiple permissions defined as a single decimal (int data type I presume). That means all permissions for a single user are in one row. It probably won't make sense until you read the other question and answer</p> <p>I can't get my brain around this one. Can someone please explain the conversion process? It sounds "right", but I'm just not getting how I convert the roles to a decimal before it goes in the db, and how it gets converted back when it comes out of the db. I'm using Java, but if you stubbed it out, that would be cool as well.</p> <p>Here is the original answer in the off chance the other question gets deleted:</p> <p>"Personally, I sometimes use a flagged enumeration of permissions. This way you can use AND, OR, NOT and XOR bitwise operations on the enumeration's items.</p> <pre><code>[Flags] public enum Permission { VIEWUSERS = 1, // 2^0 // 0000 0001 EDITUSERS = 2, // 2^1 // 0000 0010 VIEWPRODUCTS = 4, // 2^2 // 0000 0100 EDITPRODUCTS = 8, // 2^3 // 0000 1000 VIEWCLIENTS = 16, // 2^4 // 0001 0000 EDITCLIENTS = 32, // 2^5 // 0010 0000 DELETECLIENTS = 64, // 2^6 // 0100 0000 } </code></pre> <p>Then, you can combine several permissions using the AND bitwise operator. </p> <p>For example, if a user can view &amp; edit users, the binary result of the operation is 0000 0011 which converted to decimal is 3. You can then store the permission of one user into a single column of your DataBase (in our case it would be 3).</p> <p>Inside your application, you just need another bitwise operation (OR) to verify if a user has a particular permission or not."</p>
<p>You use bitwise operations. The pseudo-code would be something like:</p> <pre><code>bool HasPermission(User user, Permission permission) { return (user.Permission &amp; permission) != 0; } void SetPermission(User user, Permission permission) { user.Permission |= permission; } void ClearPermission(User user, Permission permission) { user.Permission &amp;= ~permission; } </code></pre> <p>Permission is the enum type defined in your post, though whatever type it is needs to be based on an integer-like type. The same applies to the User.Permission field.</p> <p>If those operators (&amp;, |=, and &amp;=) don't make sense to you, then read up on bitwise operations (bitwise AND and bitwise OR).</p>
<p>Actually, this is how we determine authority within a fairly large web application that I'm the DBA for. </p> <p>If you are going to do something like this, you'll really benefit from having a <a href="http://snippets.dzone.com/posts/show/1184" rel="nofollow noreferrer">numbers table</a>. It will make your calculations much faster.</p> <p>The basic setup includes the following tables:</p> <ol> <li>Groups - for doing many to many of users and security points</li> <li>Security points - which contain a value for anonymous authorization and one for authenticated users who are not part of a separate group</li> <li>Group security point join table </li> <li>A special BitMask numbers table that contains entries for the ^2 values. Thus there is one entry for 2 (2) and two entries for three (2 and 1). This keeps us from having to calculate values each time.</li> </ol> <p>First we determine if the user is logged in. If they aren't we return the anonymous authorization for the security point.</p> <p>Next we determine if the user is a member of any groups associated with the security point through a simple <code>EXISTS</code> using a <code>JOIN</code>. If they aren't we return the value associated with authenticated user. Most of the anonymous and authenticated defaults are set to 1 on our system because we require you to belong to specific groups.</p> <blockquote> <p><strong>Note:</strong> If an anonymous user gets a no access, the interface throws them over to a log in box to allow them to log in and try again.</p> </blockquote> <p>If the user <em>is</em> a member of one or more groups, then we select distinct values from the BitMask table for each of the values defined for the groups. For example, if you belonged to three groups and had one authorization level of 8, one with 12 and the last with 36, our select against the Bit Mask table would return 8, 8 and 4, and 4 and 32 respectively. By doing a distinct we get the number 4, 8 and 32 which correctly bit masks to 101100.</p> <p>That value is returned as the users authorization level and processed by the web site.</p> <p>Make sense?</p>
8,503
<p>When I try to do any svn command and supply the <code>--username</code> and/or <code>--password</code> options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified by <code>--username</code>. Neither <code>--no-auth-cache</code> nor <code>--non-interactive</code> have any effect on this. This is a problem because I'm trying to call svn commands from a script, and I can't have it show the prompt.</p> <p>For example, logged in as user1:</p> <pre><code># $ svn update --username 'user2' --password 'password' # user1@domain.com's password: </code></pre> <p>Other options work correctly:</p> <pre><code># $ svn --version --quiet # 1.3.2 </code></pre> <p>Why does it prompt me?<br> And why is it asking for user1's password instead of user2's?<br> I'm 99% sure all of my permissions are set correctly. Is there some config option for svn that switches off command-line passwords?<br> Or is it something else entirely?</p> <p>I'm running svn 1.3.2 (r19776) on Fedora Core 5 (Bordeaux).</p> <hr> <p>Here's a list of my environment variables (with sensitive information X'ed out). None of them seem to apply to SVN:</p> <pre><code># HOSTNAME=XXXXXX # TERM=xterm # SHELL=/bin/sh # HISTSIZE=1000 # KDE_NO_IPV6=1 # SSH_CLIENT=XXX.XXX.XXX.XXX XXXXX XX # QTDIR=/usr/lib/qt-3.3 # QTINC=/usr/lib/qt-3.3/include # SSH_TTY=/dev/pts/2 # USER=XXXXXX # LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35: # KDEDIR=/usr # MAIL=/var/spool/mail/XXXXXX # PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin # INPUTRC=/etc/inputrc # PWD=/home/users/XXXXXX/my_repository # KDE_IS_PRELINKED=1 # LANG=en_US.UTF-8 # SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass # SHLVL=1 # HOME=/home/users/XXXXXX # LOGNAME=XXXXXX # QTLIB=/usr/lib/qt-3.3/lib # CVS_RSH=ssh # SSH_CONNECTION=69.202.73.122 60998 216.7.19.47 22 # LESSOPEN=|/usr/bin/lesspipe.sh %s # G_BROKEN_FILENAMES=1 # _=/bin/env # OLDPWD=/home/users/XXXXXX </code></pre>
<p>Do you actually have the single quotes in your command? I don't think they are necessary. Plus, I think you also need <code>--no-auth-cache</code> and <code>--non-interactive</code></p> <p>Here is what I use (no single quotes)</p> <pre> --non-interactive --no-auth-cache --username XXXX --password YYYY </pre> <p>See the <a href="http://svnbook.red-bean.com/en/1.4/svn.serverconfig.netmodel.html#svn.serverconfig.netmodel.credcache" rel="noreferrer"><b>Client Credentials Caching</b> documentation in the svnbook</a> for more information.</p>
<p>Best I can give you is a "works for me" on SVN 1.5. You may try adding <code>--no-auth-cache</code> to your <code>svn update</code> to see if that lets you override more easily.</p> <p>If you want to permanently switch from user2 to user1, head into ~/.subversion/auth/ on *nix and delete the auth cache file for domain.com (most likely in ~/.subversion/auth/svn.simple/ -- just read through them and you'll find the one you want to drop). While it is possible to update the current auth cache, you have to make sure to update the length tokens as well. Simpler just to get prompted again next time you update.</p>
5,501
<p>We have a program that produces several SWF files, some CSS and XML files, all of which need to be deployed for the thing to work.</p> <p>Is there a program or technique out there for wrapping all these files together into a single SWF file?</p>
<p>If you use the Flex compiler (<code>mxmlc</code> or FlexBuilder) you can embed SWF files and create them at runtime, more or less like you would create any display object:</p> <pre><code>package { public class Assets { [Embed(source="another.swf")] public var another : Class; } } </code></pre> <p>The code above embeds the file <code>another.swf</code> and makes it possible to create it in another SWF, like this:</p> <pre><code>package { import flash.display.Sprite; public class MyFancySite extends Sprite { public function MyFancySprite( ) { var theOther : DisplayObject = new Assets.another(); addChild(theOther); } } } </code></pre> <p>CSS, XML and any other file can be embedded in a similar fashion. Here's a description: <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html</a></p>
<p>I think you can just drag them into the library of your main swf and make references to them. At least the other SWFs you can, not sure about the CSS and XML.</p>
9,391
<p>Store everything in GMT?</p> <p>Store everything the way it was entered with an embedded offset?</p> <p>Do the math everytime you render?</p> <p>Display relative Times "1 minutes ago"?</p>
<p>You have to store in UTC - if you don't, your historic reporting and behaviour during things like Daylight Savings goes... funny. GMT is a local time, subject to Daylight Savings relative to UTC (which is not).</p> <p>Presentation to users in different time-zones can be a real bastard if you're storing local time. It's easy to adjust to local if your raw data is in UTC - just add your user's offset and you're done!</p> <p>Joel talked about this in one of the podcasts (in a round-about way) - he said to <a href="https://stackoverflow.fogbugz.com/default.asp?W12621" rel="noreferrer">store your data in the highest resolution possible</a> (search for 'fidelity'), because you can always munge it when it goes out again. That's why I say store it as UTC, as local time you need to adjust for anyone who's not in that timezone, and that's a lot of hard work. And you need to store whether, for example, daylight savings was in effect when you stored the time. Yuk.</p> <p>Often in databases in the past I've stored two - UTC for sorting, local time for display. That way neither the user nor the computer get confused.</p> <p>Now, as to display: Sure, you can do the "3 minutes ago" thing, but only if you store UTC - otherwise, data entered in different timezones is going to do things like display as "-4 hours ago", which will freak people out. If you're going to display an actual time, people love to have it in their local time - and if data's being entered in multiple timezones you can only do that with ease if you're storing UTC.</p>
<p>I like storing in GMT and showing only relative ("about 10 seconds ago", "5 months ago"). Users don't need to see actual timestamps for most use cases.</p> <p>There are certainly exceptions, and an individual application might have many of them, so it can't be a 'one-true-way' answer. Things that need strong audit-ability (e.g. voting), and systems where time is part of the domain of discourse (astronomy, scientific research) might demand true timestamps to be shown to the user.</p> <p>Most apps, though, are easier to understand with a simple relative time.</p>
3,309
<p>In <a href="http://channel9.msdn.com/posts/Dan/Countdown-to-PDC2008-By-Developers-for-Developers-Don-Box-and-Chris-Anderson/" rel="nofollow noreferrer">today's channel9.msdn.com video</a>, the PDC guys posted a challenge to decipher this code:</p> <pre><code>2973853263233233753482843823642933243283 6434928432937228939232737732732535234532 9335283373377282333349287338349365335325 3283443783243263673762933373883363333472 8936639338428833535236433333237634438833 3275387394324354374325383293375366284282 3323383643473233852922933873933663333833 9228632439434936334633337636632933333428 9285333384346333346365364364365365336367 2873353883543533683523253893663653393433 8837733538538437838338536338232536832634 8284348375376338372376377364368392352393 3883393733943693253343433882852753933822 7533337432433532332332328232332332932432 3323323323323336323333323323323327323324 2873323253233233233892792792792792792792 7934232332332332332332332733432333832336 9344372376326339329376282344 </code></pre> <p>Decipher it and win a t-shirt. (Lame, I know, was hoping for a free trip to the PDC.)</p> <p>I notice some interesting patterns in this code, such as the 332 pattern towards the end, but I'm at a loss as to where to go from here. They've said the answer is a text question.</p> <p>Any ideas on deciphering this code?</p>
<p>Well, based on the 332 pattern you pointed out and the fact that the number of numbers is divisible by 3, and that several of the first 3 digit groups have matches... it might be that each 3 digits represent a character. Get a distribution of the number matches for all the 3 digit groups, then see if that distribution looks like the distribution of common letters.</p> <p>If so, each 3 digit code could then be mapped to a character, and you might get a lot of the characters filled in for you this way, then just see if you can fill in the blanks of the less common letters that may not match the distribution perfectly. </p> <p>A quick google search revealed <a href="https://web.archive.org/web/20080220140738/http://www.csm.astate.edu/~rossa/datasec/frequency.html" rel="nofollow noreferrer">this source for distribution of frequency</a> in the English language. </p> <p>This, of course, may not be fruitful, but it's a good first attempt.</p>
<p>I wrote some C# code to scan the cipher and give me some stats back. Here are some interesting results:</p> <p>With a chunk size of 3, </p> <ul> <li><p>There are 236 chunks.</p></li> <li><p>There are 172 duplicates.</p></li> <li><p>The 323 code shows up a whopping total of 29 times!</p></li> <li><p>The 333 code shows up 11 times.</p></li> <li><p>All other codes show up 7 times or less.</p></li> <li><p>35 chunks start with a 2.</p></li> <li><p>200 chunks start with a 3. (Interesting!)</p></li> <li><p>1 chunk starts with a 4.</p></li> <li><p>Despite the cipher containing 2s, 3s, 4s, 5s, 6s, 7s, 8s, and 9s, chunks only start with 2 and 3, except the 1 chunk that starts with 4.</p></li> <li><p>There are no 0s.</p></li> <li><p>There are no 1s.</p></li> <li><p>There are 115 2s.</p></li> <li><p>There are 293 3s.</p></li> <li><p>There are 56 4s.</p></li> <li><p>There are 38 5s.</p></li> <li><p>There are 49 6s.</p></li> <li><p>There are 52 7s.</p></li> <li><p>There are 63 8s.</p></li> <li><p>There are 42 9s.</p></li> </ul> <p>I'd describe the 323 appearance count highly irregular. I'd also suggest that the fact that all of the chunks start with either 3 or 2 (barring the 1 appearance of a 4 chunk) is also highly irregular.</p> <p>I've ran the same analysis using chunks of 2, 4, and 8, and the results look more or less random. At this point, I'm leaning towards a 3 chunk.</p>
5,695
<p>I have a ContextMenu that is displayed after a user right clicks on a ComboBox. When the user selects an item in the context menu, a form is brought up using the <code>ShowDialog()</code> method. </p> <pre><code>If frmOptions.ShowDialog() = Windows.Forms.DialogResult.Cancel Then LoadComboBoxes() End If </code></pre> <p>When that form is closed, I refresh all the data in the ComboBoxes on the parent form. However, when this happens the ComboBox that opened the ContextMenu is reset to have a selected index of -1 but the other selected indexes of the other ComboBoxes remain the same. </p> <p>How do I prevent the ComboBox that opened the context menu from being reset?</p>
<p>One way to handle this would be to use the context menu's Popup event to grab the selected index of the combobox launching the menu. When the dialog form closes reset the selected index.</p>
<p>I figured it out.</p> <p>I created a method that passed the <strong>ContextMenu.SourceControl()</strong> property by reference so I could manipulate the control that called the ContextMenu. In the beginning of the method, I got the <strong>SelectedValue</strong> of the ComboBox and the reloaded the data in the ComboBoxes. I then set the <strong>SelectedValue</strong> to the value I had got in the beginning of the method.</p> <p>Thank you DaveK for pointing me in the right direction.</p>
7,336
<p>I would like to log each line of G-code to the serial port as it is processed.</p> <p><strong>Steps to achieve</strong>:</p> <ul> <li>the printer reads a file from the SD card</li> <li>each line it reads will be serial logged (this I can't figure out)</li> <li>those lines can then read via the serial monitor on a laptop</li> </ul> <p>So by the end of the print, on my laptop I would have the reconstructed G-code file (plus whatever other logs the printer outputs).</p> <p>The printer runs the Prusa Firmware. Ideally I would like to achieve the logging from altering the firmware rather than adding an extra plugin/server (For understanding and experimenting purposes).</p> <p><strong>What I tried</strong></p> <p>I have looked in code and found <a href="https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/Marlin.h#L99" rel="nofollow noreferrer">the print functions</a> and examples of them in use in the code. This line is the &quot;<a href="https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/cmdqueue.h#L43" rel="nofollow noreferrer">command, which is to be excecuted right now</a>&quot;, but I think that would be the just one command not the full line.</p> <p>The <a href="https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/cardreader.cpp" rel="nofollow noreferrer">cardreader</a> or <a href="https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/SdBaseFile.cpp" rel="nofollow noreferrer">SdBaseFile</a> are where I would expect a G-code line to be read such that I could add a print statement after it but I did not see where.</p> <p>Would it be as easy as setting this <a href="https://github.com/prusa3d/Prusa-Firmware/blob/MK3/Firmware/cardreader.cpp#L30" rel="nofollow noreferrer">card.logging</a> bool to true?</p> <p>I imagine this is quite an easy thing to do and that I have just overcomplicated it by trying to understand the firmware. Any advice would be great!</p>
<p>If you have the hardware at hand, you can use OctoPrint to collect the data you require. It's common for users to create an OctoPrint server on a Raspberry Pi, but it can be installed easily on a Windows or Linux machine as well. Once in place, logging is available for various types of information.</p> <p>From the <a href="https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299" rel="nofollow noreferrer">OctoPrint blog</a>:</p> <p>The logs are crucial instruments of analysis and debugging, so it's usually in your best interest to provide them when asking for help or reporting a bug, even if not explicitly prompted for them:</p> <blockquote> <p>octoprint.log: OctoPrint's main application log file. Contains a general log of everything that happens while OctoPrint is running. Includes version information, installed plugins and a myriad of more data points.</p> <p>This must always be included when reporting a bug 47 to allow for further analysis and reproduction. It is also a very good idea to provide this when asking for help :wink:</p> <p>serial.log: A log of all of the communication going on between OctoPrint and your printer. Usually disabled for performance reasons, enable it through Settings &gt; Serial Connection.</p> <p>Either that or at the very least the output in OctoPrint's Terminal tab is crucial for analysis of any kind of communication issues or misbehaviours observed with your printer, so it's important to include it when discussing such issues.</p> <p>plugin_pluginmanager_console.log: A log of the command line activity of the plugin manager. Very important for analysis of such questions like &quot;Why can't I install plugin $xyz?&quot;, so if you have such a problem, best include this.</p> <p>plugin_softwareupdate_console.log: A log of the command line activity of the software updater. Very important for analysis of such questions like &quot;Updating OctoPrint always fails, why?&quot;, so if you have such a problem, best include this.</p> </blockquote> <p>Third party plugins might also have special log files here. If a plugin author asks you to provide a special log created by their plugin for further analysis, this should be where you can find it.</p> <p>The above selection is from the linked site, which also includes embedded links for more information regarding the log files. Note that serial.log is specifically referenced to collect data between OctoPrint and your printer, although it defaults to disabled on install.</p>
<p>If you have the hardware at hand, you can use OctoPrint to collect the data you require. It's common for users to create an OctoPrint server on a Raspberry Pi, but it can be installed easily on a Windows or Linux machine as well. Once in place, logging is available for various types of information.</p> <p>From the <a href="https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299" rel="nofollow noreferrer">OctoPrint blog</a>:</p> <p>The logs are crucial instruments of analysis and debugging, so it's usually in your best interest to provide them when asking for help or reporting a bug, even if not explicitly prompted for them:</p> <blockquote> <p>octoprint.log: OctoPrint's main application log file. Contains a general log of everything that happens while OctoPrint is running. Includes version information, installed plugins and a myriad of more data points.</p> <p>This must always be included when reporting a bug 47 to allow for further analysis and reproduction. It is also a very good idea to provide this when asking for help :wink:</p> <p>serial.log: A log of all of the communication going on between OctoPrint and your printer. Usually disabled for performance reasons, enable it through Settings &gt; Serial Connection.</p> <p>Either that or at the very least the output in OctoPrint's Terminal tab is crucial for analysis of any kind of communication issues or misbehaviours observed with your printer, so it's important to include it when discussing such issues.</p> <p>plugin_pluginmanager_console.log: A log of the command line activity of the plugin manager. Very important for analysis of such questions like &quot;Why can't I install plugin $xyz?&quot;, so if you have such a problem, best include this.</p> <p>plugin_softwareupdate_console.log: A log of the command line activity of the software updater. Very important for analysis of such questions like &quot;Updating OctoPrint always fails, why?&quot;, so if you have such a problem, best include this.</p> </blockquote> <p>Third party plugins might also have special log files here. If a plugin author asks you to provide a special log created by their plugin for further analysis, this should be where you can find it.</p> <p>The above selection is from the linked site, which also includes embedded links for more information regarding the log files. Note that serial.log is specifically referenced to collect data between OctoPrint and your printer, although it defaults to disabled on install.</p>
1,798
<p>I'm trying to locate an open source business rules engine that has a decent interface for building the rules.</p> <p>OR at least one that works well on the .Net platform and has been updated sometime in the past 12 months. </p> <p>Thanks,</p>
<p>NxBRE is one option. </p> <p><a href="http://sourceforge.net/projects/nxbre/#item3rd-5" rel="noreferrer">http://sourceforge.net/projects/nxbre/#item3rd-5</a></p>
<p>I'm going to throw one more piece of software I ran across: <a href="http://ncalc.codeplex.com/" rel="nofollow">ncalc</a>.</p> <p>It's not exactly a "rules" engine; but it does do dynamic calculations where you can give it the expression to evaluate and all of the variables necessary. This was pretty much exactly all I needed for the app I was working on.</p> <p>For a simple engine it works just fine. As far as an interface, it wasn't that complicated to build a few pages to let people type in the expressions.</p> <p>For more complicated things, NxBRE is a better option; as @Kevin Dente answered above.</p>
4,187
<p>A while ago I read the <a href="http://www.martinfowler.com/articles/mocksArentStubs.html" rel="nofollow noreferrer">Mocks Aren't Stubs</a> article by Martin Fowler and I must admit I'm a bit scared of external dependencies with regards to added complexity so I would like to ask:</p> <p>What is the best method to use when unit testing?</p> <p>Is it better to always use a mock framework to automatically mock the dependencies of the method being tested, or would you prefer to use simpler mechanisms like for instance test stubs?</p>
<p>As the mantra goes 'Go with the simplest thing that can possibly work.'</p> <ol> <li>If fake classes can get the job done, go with them. </li> <li>If you need an interface with multiple methods to be mocked, go with a mock framework.</li> </ol> <p>Avoid using mocks <em>always</em> because they make tests brittle. Your tests now have intricate knowledge of the methods called by the implementation, if the mocked interface or your implementation changes... your tests break. This is bad coz you'll spend additional time getting your tests to run instead of just getting your SUT to run. <em>Tests should not be inappropriately intimate with the implementation.</em><br> So use your best judgment.. I prefer mocks when it'll help save me writing-updating a fake class with n>>3 methods.</p> <p><strong>Update</strong> Epilogue/Deliberation:<br> (Thanks to Toran Billups for example of a mockist test. See below)<br> Hi Doug, Well I think we've transcended into another holy war - Classic TDDers vs Mockist TDDers. I think I'm belong to the former. </p> <ul> <li>If I am on test#101 Test_ExportProductList and I find I need to add a new param to IProductService.GetProducts(). I do that get this test green. I use a refactoring tool to update all other references. Now I find all the mockist tests calling this member now blow up. Then I have to go back and update all these tests - a waste of time. Why did ShouldPopulateProductsListOnViewLoadWhenPostBackIsFalse fail? Was it because the code is broken? Rather the tests are broken. I favor the <em>one test failure = 1 place to fix</em>. Mocking freq goes against that. Would stubs be better? If it I had a fake_class.GetProducts().. sure One place to change instead of shotgun surgery over multiple Expect calls. In the end it's a matter of style.. if you had a common utility method MockHelper.SetupExpectForGetProducts() - that'd also suffice.. but you'll see that this is uncommon. </li> <li>If you place a white strip on the test name, the test is hard to read. Lot of plumbing code for the mock framework hides the actual test being performed.</li> <li>requires you to learn this particular flavor of a mocking framework</li> </ul>
<p>Read Luke Kanies' discussion of exactly this question in <a href="http://www.madstop.com/ruby/jay_and_i_converge_on_testing.html" rel="nofollow noreferrer">this blog post</a>. He references <a href="http://blog.jayfields.com/2008/05/using-stubs-to-capture-test-essence.html" rel="nofollow noreferrer">a post from Jay Fields</a> which even suggests that using [a equivalent to ruby's/mocha's] stub_everything is preferrable to make the tests more robust. To quote Fields' final words: "Mocha makes it as easy to define a mock as it is to define a stub, but that doesn't mean you should always prefer mocks. In fact, I generally prefer stubs and use mocks when necessary."</p>
7,000
<p>Lasty, I tried to implements an hybrid structure in Java, something that looks like:</p> <pre><code>public class MapOfSet&lt;K, V extends HasKey&lt;K&gt;&gt; implements Set&lt;V&gt;, Map&lt;K, Set&lt;V&gt;&gt; </code></pre> <p>Where HasKey is the following interface:</p> <pre><code>public interface HasKey&lt;K&gt; { public K getKey(); } </code></pre> <p>Unfortunately, there are some conflicts between methos signature of the Set interface and the Map interface in Java. I've finally chosen to implements only the Set interface and to add the Map method without implementing this interface.</p> <p>Do you see a nicer solution?</p> <p>In response to the first comments, here is my goal:</p> <blockquote> <p>Have a set structure and be able to efficiently access to a subset of values of this set, corresponding to a given key value. At the beginning I instantiated a map and a set, but I tried to joined the two structures to optimize performances.</p> </blockquote>
<p>What are you trying to accomplish? <code>Map</code> already exposes its keys as a <code>Set</code> via its [keySet()](<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html#keySet())" rel="nofollow noreferrer">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html#keySet())</a> method. If you want a reliable iteratior order, there's <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedHashMap.html" rel="nofollow noreferrer">LinkedHashMap</a> and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/TreeMap.html" rel="nofollow noreferrer">TreeMap</a>.</p> <p>UPDATE: If you want to ensure that a value has only been inserted once, you can extend one of the classes I mentioned above to create something like a <code>SingleEntryMap</code> and override the implementation of <code>put(K key, V value)</code> to do a uniqueness check and throw an Exception when the value has already been inserted.</p> <p>UPDATE: Will something like this work? (I don't have my editor up, so this may not compile)</p> <pre><code>public final class KeyedSets&lt;K, V&gt; implements Map&lt;K,Set&lt;V&gt;&gt; { private final Map&lt;K, Set&lt;V&gt;&gt; internalMap = new TreeMap&lt;K, Set&lt;V&gt;&gt;; // delegate methods go here public Set&lt;V&gt; getSortedSuperset() { final Set&lt;V&gt; superset = new TreeSet&lt;V&gt;(); for (final Map.Entry&lt;K, V&gt; entry : internalMap.entrySet()) { superset.addAll(entry.getValue()); } return superset; } } </code></pre>
<p>I would say that something that is meant to be sometimes used as a Map and sometimes as a Set should implement Map, since that can be viewed as a set of keys or values as well as a mapping between keys and values. That is what the Map.containsKey() and Map.containsValue() methods are for.</p>
9,617
<p>This is a sql 2000 database that I am working with.</p> <p>I have what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255). </p> <p>I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.)</p> <p>The way I was going to do this was to iterate through all records using a while loop and attempt a CAST on each column on a single record during each iteration, after I visit a particular record I flag it as processed (bit field).</p> <p>But how can I log the error when/if it occurs but allow the while loop to continue.</p> <p>At first I implemented this using a TRY CATCH in a local SQL 2005 instance (to get the project going) and all was working well, but i learned today that the dev &amp; production database that the international DBA's have set up is a SQL 2000 instance so I have to conform.</p> <p><strong>EDIT</strong>: I am using a SSIS package to populate the staging table. I see that now I must revisit that package and implement a script component to handle the conversions. Thanks guys</p> <p><strong>EDIT</strong>: I <em>am</em> doing this on a record by record basis, not a batch insert, so the transaction idea seems like it would be feasible but I'm not sure how to trap @@ERROR and allow the stored procedure to continue.</p> <p><strong>EDIT</strong>: I really like <a href="https://stackoverflow.com/questions/33685/sql-2000-try-catch-like-error-handling#39161">Guy's approach</a>, I am going to implement it this way.</p>
<p>Generally I don't like "loop through the record" solutions as they tend to be slow and you end up writing a lot of custom code.</p> <p>So...</p> <p>Depending on how many records are in your staging table, you could post process the data with a series of SQL statements that test the columns for correctness and mark any records that fail the test.</p> <p>i.e.</p> <pre><code>UPDATE staging_table SET status_code = 'FAIL_TEST_1' WHERE status_code IS NULL AND ISDATE(ntext_column1) = 0; UPDATE staging_table SET status_code = 'FAIL_TEST_2' WHERE status_code IS NULL AND ISNUMERIC(ntext_column2) = 0; etc... </code></pre> <p>Finally</p> <pre><code>INSERT INTO results_table ( mydate, myprice ) SELECT ntext_column1 AS mydate, ntext_column2 AS myprice FROM staging_table WHERE status_code IS NULL; DELETE FROM staging_table WHERE status_code IS NULL; </code></pre> <p>And the staging table has all the errors, that you can export and report out.</p>
<p>It looks like you are doomed. See <a href="http://www.sommarskog.se/error-handling-I.html#whathappens" rel="nofollow noreferrer">this</a> document.</p> <p>TL/DR: A data conversion error always causes the whole batch to be aborted - your sql script will not continue to execute no matter what you do. Transactions won't help. You can't check @@ERROR because execution will already have aborted.</p> <p>I would first reexamine why you need a staging database full of varchar(255) columns - can whatever fills that database do the conversion?</p> <p>If not, I guess you'll need to write a program/script to select from the varchar columns, convert, and insert into the prod db.</p>
5,374
<p>I have 12 parts for a model I want to print but I would like to know if I can put all of them in a single G-code file and print that on its own. Would this affect the model in any way?</p> <p>I’m using PLA on my Ender 3 Pro</p>
<blockquote> <p>I have 12 parts for a model I want to print but I would like to know if I can put all of them in a single G-code file and print that on its own.</p> </blockquote> <p>You certainly can. The printer doesn't care how many parts there are. Many single parts, like those with holes, will have layers that have areas that aren't contiguous. To the printer, multiple parts look just like a single part that happens not to be connected.</p> <p>That said, printing multiple parts at once means that the job will be larger and take longer, and a problem printing any of those parts can force you to stop the whole job. Because small parts have less area in contact with the bed, small parts are more likely to come loose from the bed during the print, so running a job with many small parts can be risky -- if any one part comes loose, you might lose all the time and material you put into the whole job.</p> <p>One tool that can help mitigate that risk is the <a href="https://plugins.octoprint.org/plugins/cancelobject/" rel="nofollow noreferrer">Cancel Objects plugin</a> for <a href="https://octoprint.org" rel="nofollow noreferrer">OctoPrint</a>. If you use OctoPrint to manage your printer, you can use the plugin to stop further work on any objects that have problems during the print and continue with the rest. <a href="https://youtu.be/ANfOr2F79LQ" rel="nofollow noreferrer">Here's a video</a> about using Cancel Objects.</p> <p>Also, when printing multiple parts, be sure to check that you have enough material (filament, resin, etc) available to complete the whole job.</p>
<p>This answer assumes FDM printing -- for resin printers, as I understand it, as long as there's flow space between parts, if they fit on the build plate, they'll print.</p> <p>For FDM, generally, you'll get better print quality printing a single part, because layers don't cool while you print the same layer for each of the other parts (meaning layer adhesion will be better). That said, if the parts are very small, this additional cooling may be an improvement vs. having to set your slicer to provide a pause between layers to avoid slumps and layer spreading.</p> <p>A compromise, if the parts are low enough, is that most slicers can be instructed to print the parts sequentially -- that is, print all of part A, then all of part B, and so forth. This has some limitation in that all parts already printed must clear parts of the machine, and may also require larger clearance between parts for items like fan shrouds.</p> <p>But printing a bunch of parts at one time does work, if the compromises in layer adhesion and other quality issues related to traveling between parts are acceptable. The only way to be sure is to print the whole lot (perhaps with a large nozzle and thick layers, low infill, etc. to minimize filament consumption and print time) and see if they're good enough.</p>
2,188
<p>In a ColdFusion Component (CFC), is it necessary to use fully qualified names for variables-scoped variables?</p> <p>Am I going to get myself into trouble if I change this:</p> <pre><code>&lt;cfcomponent&gt; &lt;cfset variables.foo = "a private instance variable"&gt; &lt;cffunction name = "doSomething"&gt; &lt;cfset var bar = "a function local variable"&gt; &lt;cfreturn "I have #variables.foo# and #bar#."&gt; &lt;/cffunction&gt; &lt;/cfcomponent&gt; </code></pre> <p>to this?</p> <pre><code>&lt;cfcomponent&gt; &lt;cfset foo = "a private instance variable"&gt; &lt;cffunction name = "doSomething"&gt; &lt;cfset var bar = "a function local variable"&gt; &lt;cfreturn "I have #foo# and #bar#."&gt; &lt;/cffunction&gt; &lt;/cfcomponent&gt; </code></pre>
<p>It won't matter to specify "variables" when you create the variable, because foo will be placed in the variables scope by default; but it will matter when you access the variable.</p> <pre><code>&lt;cfcomponent&gt; &lt;cfset foo = "a private instance variable"&gt; &lt;cffunction name="doSomething"&gt; &lt;cfargument name="foo" required="yes"/&gt; &lt;cfset var bar = "a function local variable"&gt; &lt;cfreturn "I have #foo# and #bar#."&gt; &lt;/cffunction&gt; &lt;cffunction name="doAnotherThing"&gt; &lt;cfargument name="foo" required="yes"/&gt; &lt;cfset var bar = "a function local variable"&gt; &lt;cfreturn "I have #variables.foo# and #bar#."&gt; &lt;/cffunction&gt; &lt;/cfcomponent&gt; </code></pre> <p>doSomething("args") returns "I have <strong>args</strong> and a <strong>function local variable</strong>"</p> <p>doAnotherThing("args") returns "I have <strong>a private instance of a variable</strong> and a <strong>function local variable</strong>."</p>
<p>After reading your answers here's what I'm thinking:</p> <p><strong>Yes, it's safe. In general, it's not necessary or useful to explicitly specify the variables scope. It just adds clutter to an already verbose language.</strong></p> <p>Granted, there is one minor exception, as <a href="https://stackoverflow.com/users/3420/soldarnal">Soldarnal</a> pointed out, where qualifying a variables-scoped variable is required. That is if you have a function local variable with the same name. (But you probably shouldn't do that anyway.)</p>
8,394
<p>Maybe this is a dumb question, but is there any way to convert a boolean value to a string such that 1 turns to "true" and 0 turns to "false"? I could just use an if statement, but it would be nice to know if there is a way to do that with the language or standard libraries. Plus, I'm a pedant. :)</p>
<p>How about using the C++ language itself?</p> <pre><code>bool t = true; bool f = false; std::cout &lt;&lt; std::noboolalpha &lt;&lt; t &lt;&lt; " == " &lt;&lt; std::boolalpha &lt;&lt; t &lt;&lt; std::endl; std::cout &lt;&lt; std::noboolalpha &lt;&lt; f &lt;&lt; " == " &lt;&lt; std::boolalpha &lt;&lt; f &lt;&lt; std::endl; </code></pre> <p>UPDATE: </p> <p>If you want more than 4 lines of code without any console output, please go to <a href="https://en.cppreference.com/w/cpp/io/manip/boolalpha" rel="noreferrer">cppreference.com's page talking about <code>std::boolalpha</code> and <code>std::noboolalpha</code></a> which shows you the console output and explains more about the API. </p> <p>Additionally using <code>std::boolalpha</code> will modify the global state of <code>std::cout</code>, you may want to restore the original behavior <a href="https://stackoverflow.com/q/2273330/52074">go here for more info on restoring the state of <code>std::cout</code></a>.</p>
<p>I agree that a macro might be the best fit. I just whipped up a test case (believe me I'm no good with C/C++ but this sounded fun):</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdarg.h&gt; #define BOOL_STR(b) (b?"true":"false") int main (int argc, char const *argv[]) { bool alpha = true; printf( BOOL_STR(alpha) ); return 0; } </code></pre>
4,903
<p>I found the ad on this site to Krypton controls (<a href="https://github.com/ComponentFactory/Krypton" rel="nofollow noreferrer">and here's another one!</a>) and was wondering if any of you using vs.net 05 or 08 are using them and how that's working out. If you're answering, please specify which parts you're using (free, ribbons, tabs) and which vs.net you're on, which language(s) you use, along with pros and cons. I know there are probably better suites out there that you may be fond of, but this question is specifically about Krypton controls. We'd be using it with vb.net, .net 3.5, 08, so I'm particularly interested in hearing about your experience in those areas. (I've watched all the screencasts)</p>
<p>I have been using the <strong>Krypton Controls ToolKit for over 3 years</strong> with <strong>Visual Studio 2005 and 2008</strong> in <strong>.NET 2.0, 3.0, 3.5, and 3.5 SP1</strong>. I have <strong>only used the free ToolKit</strong> and not the Ribbon or Tab controls. I have used it <strong>only in C</strong>#.</p> <p><strong>Pros:</strong></p> <ol> <li>Free</li> <li>Easy to Use - It adds all of the components to the Toolbox so it's very easy to implement.</li> <li>The font rendering is awesome compared to the default windows form controls.</li> <li>The "chrome" which allows you to totally override the look of the application is very nice.</li> <li>The ability to define a master scheme makes it easy to change the look of similar controls in one central location.</li> <li>The support, even on the free Toolkit is awesome, by submitting questions on the Component Factory forum.</li> <li>It includes additional controls that should've been part of the windows form controls including headergroups.</li> </ol> <p><strong>Cons:</strong> </p> <ol> <li>That the other components aren't free ;)</li> <li>In older versions, some controls didn't exist in the ToolKit so you had to use the winform control which wouldn't entirely fit with the application look. The latest version, however, has most, if not all the controls implemented as Krypton controls.</li> </ol> <p>Here's a quick sample of our options dialog for the "<a href="http://www.muvenum.com/products/freeware/" rel="nofollow noreferrer">MuvEnum Address Bar</a>" using the Krypton Chrome. It was super easy to create. Notice the smoothness of the fonts.</p> <p><img src="https://www.muvenum.com/images/freeware/mab-options-ss-full.png" alt="alt text"></p> <p>I can't recommend the Krypton Controls enough.</p> <p>John Rennemeyer</p> <p><a href="http://www.muvenum.com/" rel="nofollow noreferrer">MuvEnum</a></p>
<p>I'm using it. It's quite okay.</p>
9,183
<p>I'm facing weird "pillars" of underextrusion on outer walls of my XYZ test cube.</p> <p>On the pictures below I`ve printed PLA test cubes with a 0.4&nbsp;mm nozzle, 0.2&nbsp;mm height and 210/50&nbsp;&deg;C hotends/bed temperature.</p> <p>Gaps are appearing in walls parallel to both X and Y sides. The pictured side is parallel to Y face.</p> <p>I'm slicing with Cura, my printer is a homebuilt around Anycubic Kossel with Marlin 2.0 onboard. </p> <p>What have I tried already:<br> 1. Temperature from 190 to 210&nbsp;&deg;C<br> 2. Retraction from none to 6&nbsp;mm 60&nbsp;mm/sec<br> 3. Tuning down Jerk in Marlin from [10,10,0.3] to [5,5,0.3]<br> 4. Tuning down acceleration from 3000 to 1000<br> 5. Tuning print speed from 60 to 30&nbsp;mm/sec 6. Checking belts, nozzle and extruder. </p> <p>Now I just ran out of ideas. Delta is calibrated by <code>G33</code> autotune. Mechanics looks just fine. What am I missing? <a href="https://i.stack.imgur.com/EUYpL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EUYpL.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/hJxp4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hJxp4.jpg" alt="enter image description here"></a></p> <p><strong>UPD1</strong>: tried removing combing - it did not help. But I noticed that my printer accelerates strangely at this parts</p> <p><strong>UPD2</strong>: could it be stuttering? I have 320 segments per second with block buffer size of 8 bytes(?)</p> <p><strong>UPD3</strong>: lowering segments count to 120 and raising block size to 32</p>
<p>Localized underextrusion usually means you're oozing material somewhere it wasn't supposed to go. Since you have Marlin 2.0, linear advance might help solve that, and in general right retraction amount is important and turning off combing may be needed (combing over infill allows material to ooze).</p> <p>Also there are reported bugs in Marlin 2.0 such as <a href="https://github.com/MarlinFirmware/Marlin/issues/15473" rel="nofollow noreferrer">https://github.com/MarlinFirmware/Marlin/issues/15473</a> that might be related, though I would think you'd not be using junction deviation since it's supposedly incompatible with deltas.</p>
<p>Well, I could not track the problem and it lasted till two major updates:</p> <ol> <li>I have changed rods for ones with proper lenght</li> <li>I have reset all Cura settings to default</li> </ol>
1,591
<p>When designing a REST API or service are there any established best practices for dealing with security (Authentication, Authorization, Identity Management) ?</p> <p>When building a SOAP API you have WS-Security as a guide and much literature exists on the topic. I have found less information about securing REST endpoints.</p> <p>While I understand REST intentionally does not have specifications analogous to WS-* I am hoping best practices or recommended patterns have emerged.</p> <p>Any discussion or links to relevant documents would be very much appreciated. If it matters, we would be using WCF with POX/JSON serialized messages for our REST API's/Services built using v3.5 of the .NET Framework.</p>
<p>As tweakt said, Amazon S3 is a good model to work with. Their request signatures do have some features (such as incorporating a timestamp) that help guard against both accidental and malicious request replaying.</p> <p>The nice thing about HTTP Basic is that virtually all HTTP libraries support it. You will, of course, need to require SSL in this case because sending plaintext passwords over the net is almost universally a bad thing. Basic is preferable to Digest when using SSL because even if the caller already knows that credentials are required, Digest requires an extra roundtrip to exchange the nonce value. With Basic, the callers simply sends the credentials the first time.</p> <p>Once the identity of the client is established, authorization is really just an implementation problem. However, you could delegate the authorization to some other component with an existing authorization model. Again the nice thing about Basic here is your server ends up with a plaintext copy of the client's password that you can simply pass on to another component within your infrastructure as needed.</p>
<p>REST itself offers no security standards, but things like OAuth and SAML are rapidly becoming the standards in this space. However, authentication and authorization are only a small part of what you need to consider. Many of the known vulnerabilities relating to web applications apply very much to REST apis. You have to consider input validation, session cracking, inappropriate error messages, internal employee vulnerabilities and so on. It is a big subject.</p>
2,910
<p>Is there an easy way to iterate over an associative array of this structure in PHP:</p> <p>The array <code>$searches</code> has a numbered index, with between 4 and 5 associative parts. So I not only need to iterate over <code>$searches[0]</code> through <code>$searches[n]</code>, but also <code>$searches[0]["part0"]</code> through <code>$searches[n]["partn"]</code>. The hard part is that different indexes have different numbers of parts (some might be missing one or two).</p> <p>Thoughts on doing this in a way that's nice, neat, and understandable?</p>
<p>Nest two <a href="http://php.net/foreach" rel="noreferrer"><code>foreach</code> loops</a>:</p> <pre><code>foreach ($array as $i =&gt; $values) { print "$i {\n"; foreach ($values as $key =&gt; $value) { print " $key =&gt; $value\n"; } print "}\n"; } </code></pre>
<p>Can you just loop over all of the "part[n]" items and use isset to see if they actually exist or not?</p>
4,559
<p>Why does the default IntelliJ default class javadoc comment use non-standard syntax? Instead of creating a line with "User: jstauffer" it could create a line with "@author jstauffer". The other lines that it creates (Date and Time) probably don't have javadoc syntax to use but why not use the javadoc syntax when available?</p> <p>For reference here is an example:</p> <pre>/** * Created by IntelliJ IDEA. * User: jstauffer * Date: Nov 13, 2007 * Time: 11:15:10 AM * To change this template use File | Settings | File Templates. */</pre>
<p>I'm not sure why Idea doesn't use the <code>@author</code> tag by default. </p> <p>But you can change this behavior by going to <code>File -&gt; Settings -&gt; File Templates</code> and editing the <code>File Header</code> entry in the <code>Includes</code> tab.</p> <p>As of IDEA 14 it's: <code>File -&gt; Settings -&gt; Editor -&gt; File and Code Templates -&gt; Includes -&gt; File Header</code></p>
<p>It is likely that the header snippet you show is older than javadoc and was just borrowed from some coding standard document, probably written for C++.</p>
8,912