instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I'm importing some data from a <code>CSV</code> file, and numbers that are larger than <code>1000</code> get turned into <code>1,100</code> etc. </p> <p>What's a good way to remove both the quotes and the comma from this so I can put it into an <code>int</code> field?</p> <p><strong>Edit:</strong> </p> <p>The data is actually already in a MySQL table, so I need to be able to this using SQL. Sorry for the mixup.</p>
<p>My guess here is that because the data was able to import that the field is actually a varchar or some character field, because importing to a numeric field might have failed. Here was a test case I ran purely a MySQL, SQL solution.</p> <ol> <li><p>The table is just a single column (alpha) that is a varchar.</p> <pre><code>mysql&gt; desc t; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | alpha | varchar(15) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ </code></pre></li> <li><p>Add a record</p> <pre><code>mysql&gt; insert into t values('"1,000,000"'); Query OK, 1 row affected (0.00 sec) mysql&gt; select * from t; +-------------+ | alpha | +-------------+ | "1,000,000" | +-------------+ </code></pre></li> <li><p>Update statement.</p> <pre><code>mysql&gt; update t set alpha = replace( replace(alpha, ',', ''), '"', '' ); Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql&gt; select * from t; +---------+ | alpha | +---------+ | 1000000 | +---------+ </code></pre></li> </ol> <p>So in the end the statement I used was:</p> <pre><code>UPDATE table SET field_name = replace( replace(field_name, ',', ''), '"', '' ); </code></pre> <p>I looked at the <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace" rel="nofollow noreferrer">MySQL Documentation</a> and it didn't look like I could do the regular expressions find <em>and replace</em>. Although you could, like <a href="https://stackoverflow.com/questions/7917/remove-quotes-and-commas-from-a-string-in-mysql#8135">Eldila</a>, use a regular expression for a find and then an alternative solution for replace.</p> <hr> <p>Also be careful with <code>s/"(\d+),(\d+)"/$1$2/</code> because what if the number has more then just a single comma, for instance "1,000,000" you're going to want to do a global replace (in perl that is <code>s///g</code>). But even with a global replace the replacement starts where you last left off (unless perl is different), and would miss the every other comma separated group. A possible solution would be to make the first (\d+) optional like so <code>s/(\d+)?,(\d+)/$1$2/g</code> and in this case I would need a second find and replace to strip the quotes.</p> <p>Here are some ruby examples of the regular expressions acting on just the string "1,000,000", notice there are NOT double quote inside the string, this is just a string of the number itself.</p> <pre><code>&gt;&gt; "1,000,000".sub( /(\d+),(\d+)/, '\1\2' ) # =&gt; "1000,000" &gt;&gt; "1,000,000".gsub( /(\d+),(\d+)/, '\1\2' ) # =&gt; "1000,000" &gt;&gt; "1,000,000".gsub( /(\d+)?,(\d+)/, '\1\2' ) # =&gt; "1000000" &gt;&gt; "1,000,000".gsub( /[,"]/, '' ) # =&gt; "1000000" &gt;&gt; "1,000,000".gsub( /[^0-9]/, '' ) # =&gt; "1000000" </code></pre>
<p>Daniel's and Eldila's answer have one problem: They remove all quotes and commas in the whole file.</p> <p>What I usually do when I have to do something like this is to first replace all separating quotes and (usually) semicolons by tabs. </p> <ul> <li><em>Search:</em> ";"</li> <li><em>Replace:</em> \t</li> </ul> <p>Since I know in which column my affected values will be I then do another search and replace:</p> <ul> <li><em>Search:</em> ^([\t]+)\t([\t]+)\t([0-9]+),([0-9]+)\t</li> <li><em>Replace:</em> \1\t\2\t\3\4\t</li> </ul> <p>... given the value with the comma is in the third column.</p> <p>You need to start with an "^" to make sure that it starts at the beginning of a line. Then you repeat ([0-9]+)\t as often as there are columns that you just want to leave as they are.</p> <p>([0-9]+),([0-9]+) searches for values where there is a number, then a comma and then another number.</p> <p>In the replace string we use \1 and \2 to just keep the values from the edited line, separating them with \t (tab). Then we put \3\4 (no tab between) to put the two components of the number without the comma right after each other. All values after that will be left alone.</p> <p>If you need your file to have semicolon to separate the elements, you then can go on and replace the tabs with semicolons. However then - if you leave out the quotes - you'll have to make sure that the text values do not contain any semicolons themselves. That's why I prefer to use TAB as column separator.</p> <p>I usually do that in an ordinary text editor (EditPlus) that supports RegExp, but the same regexps can be used in any programming language.</p>
2,947
<p>I'm integrating .NET support into our C++ application.<br /> It's an old-school MFC application, with 1 extra file compiled with the "/clr" option that references a CWinFormsControl.</p> <p>I'm not allowed to remove the linker flag "/NODEFAULTLIB".<br /> (We have our own build management system, not Visual Studio's.)<br /> This means I have to specify all necessary libraries: VC runtime and MFC.</p> <p>Other compiler options include "/MD"</p> <p>Next to that: I can't use the linker flag "/FORCE:MULTIPLE" and just add <em>everything</em>:<br /> I'm looking for a non-overlapping set of libraries.</p>
<p>I would also suggest checking out the SharePoint Content Deployment Wizard by Chris O'Brien. <a href="http://www.codeplex.com/SPDeploymentWizard" rel="nofollow noreferrer">http://www.codeplex.com/SPDeploymentWizard</a> </p> <p>Should help smooth the process you describe, and it's a nice tool for your kitbag regardless</p>
<p>We have a BizTalk 2006 with Web Application and Several WebServices that need to go from Dev to UAT to Live.</p> <p>We use MSBuild right from within VS to build, run tests, dependent on test result, complie, zip and ship to servers.</p> <p>Small MSBuild script on server to unzip, move the files, install clean web app, unlist biztalk bits, install new biztalk bits, re enlist and then start the stuff.</p> <p>MSBuild is hugh and more people need to use it as it there now right in the platform =></p> <p>Use <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="nofollow noreferrer"> MSBuild</a></p>
3,094
<p>I read that PTFE starts to deteriorate past 260&nbsp;&deg;C. Does that mean heating to 250&nbsp;&deg;C is no problem at all, or will that destroy the PTFE material over time to?</p>
<p>Degradation starts at 260&nbsp;&deg;C and shifts towards full blown decomposition towards 350&nbsp;&deg;C. 250&nbsp;&deg;C is technically fine, but you should keep in mind that you've got little to no wiggle room for error at that temperature. Your thermistor and board may not be accurate enough to guarantee you'll never overshoot that temperature, and the way 3D printers often handle temperature adjustment exacerbates that risk. You <strong>can</strong> print at 250&nbsp;&deg;C, just be aware you've got basically no margin for error. </p>
<p>High temperature rated PTFE tape is rated for up to 288°C (550°F).</p>
1,337
<p>Assuming you have a high quality printer with a fast processor, will you see a noticeable improvement by upgrading from 16X/32X microstepping drivers to 64X/128X microstepping drivers? (e.g. smoother surface finish). In what ways do they perform differently from the more common 16X or 32X stepper drivers. I'm thinking the RAPS128, Silencioso, and Trinamic drivers vs the DRV8825, A4988 and A4988.</p>
<p>You will likely not see a noticeable improvement by upgrading from a 16x or 32x to a 64x or 128x microstepping driver. Depending on the motors you're driving and the size of the load you could actually see a decrease in quality.</p> <p>Although microstepping increases theoretical resolution it does not necessarily increase accuracy. The reason is that microstepping significantly limits the incremental torque of the motor. This means that you may ask for a step but not get one because the torque of the step won't be enough to actually turn the shaft.</p> <p>As an example: a motor running in full steps will have 100% of its rated holding torque. Moving to 16 microsteps/full steps drops this to ~10%, 128 drops it to ~1%.</p> <p>The practical effect of this is that in high torque situations (such as printing at fast speeds) the motor may end up skipping some of the steps. In this way the increase in resolution can actually lead to a decrease in accuracy (smaller steps but they may not actually be taken).</p> <p>A relevant calculation to do would be to work out what the different number of microsteps to full steps works out to in terms of horizontal, vertical, or whatever movement the motor drives. You can do this by measuring how far the stepper moves said surface in one revolution provided you know the number of steps it takes per revolution.</p> <p><strong>Example:</strong> </p> <p>With no microstepping: 1 turn/inch * 200 steps/turn = 200 steps/inch or .005 inch/step (127 micron resolution)</p> <p>With 16x microstepping: 16 * 200 steps/inch or .0003 inch / step (8 micron resolution)</p> <p>In this example 128x microstepping would be absolutely foolish. Every situation is different and you should use this information to make a decision based on your setup. Many manufacturers have recommendations on how far their motors can be microstepped.</p>
<p>Prints benefit from higher microstepping in two ways:</p> <p><strong>Noise level</strong></p> <p>Using microstepping reduces noise from your printer's operation.</p> <p><strong>Print quality</strong></p> <p>Using higher resolution microstepping does not increase the physical accuracy of your prints meaningfully, but it can reduce surface artifacts such as <a href="http://www.soliforum.com/topic/10108/extruder-pulse-moire-at-132-microstepping-causing-diagonal-lines/" rel="nofollow">moire</a>.</p>
112
<p>I'm trying to find a way to validate a large XML file against an XSD. I saw the question <a href="https://stackoverflow.com/questions/15732/whats-the-best-way-to-validate-an-xml-file-against-an-xsd-file">...best way to validate an XML...</a> but the answers all pointed to using the Xerces library for validation. The only problem is, when I use that library to validate a 180 MB file then I get an OutOfMemoryException.</p> <p>Are there any other tools,libraries, strategies for validating a larger than normal XML file?</p> <p>EDIT: The SAX solution worked for java validation, but the other two suggestions for the libxml tool were very helpful as well for validation outside of java.</p>
<p>Instead of using a DOMParser, use a SAXParser. This reads from an input stream or reader so you can keep the XML on disk instead of loading it all into memory.</p> <pre><code>SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(true); factory.setNamespaceAware(true); SAXParser parser = factory.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setErrorHandler(new SimpleErrorHandler()); reader.parse(new InputSource(new FileReader ("document.xml"))); </code></pre>
<p>SAX and libXML will help, as already mentioned. You could also try increasing the maximum heap size for the JVM using the -Xmx option. E.g. to set the maximum heap size to 512MB: <code>java -Xmx512m com.foo.MyClass</code></p>
6,189
<p>We have a Windows Service written in C#. The service spawns a thread that does this: </p> <pre><code>private void ThreadWorkerFunction() { while(false == _stop) // stop flag set by other thread { try { openConnection(); doStuff(); closeConnection(); } catch (Exception ex) { log.Error("Something went wrong.", ex); Thread.Sleep(TimeSpan.FromMinutes(10)); } } } </code></pre> <p>We put the Thread.Sleep in after a couple of times when the database had gone away and we came back to 3Gb logs files full of database connection errors. </p> <p>This has been running fine for months, but recently we've seen a few instances where the log.Error() statement logs a "System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable" exception and then never ever comes back. The service can be left running for days but nothing more will be logged.</p> <p>Having done some reading I know that Thread.Sleep is not ideal, but why would it simply never come back?</p>
<p>Dig in and find out? Stick a debugger on that bastard!</p> <p>I can see at least the following possibilities:</p> <ol> <li>the logging system hangs;</li> <li>the thread exited just fine but the service is still running because some other part has a logic error.</li> </ol> <p>And maybe, but almost certainly not, the following:</p> <ul> <li>Sleep() hangs.</li> </ul> <p>But in any case, attaching a debugger will show you whether the thread is still there and whether it really has hung.</p>
<p>Have you tried using <a href="http://msdn.microsoft.com/en-us/library/system.threading.monitor.pulse.aspx" rel="nofollow noreferrer">Monitor.Pulse</a> (ensure your thread is using thread management before running this) to get the thread to do something? If that works, then you're going to have to look a bit more into your threading logic.</p>
4,965
<p>Some electronics come as a single PCB. They have CPU and everything on just one board.</p> <p>Other electronics are a shield for an Arduino. So these are always two boards. The Arduino and the other PCB.</p> <p>You probably don't want to exchange the Arduino unless it is broken. Does it break that often or are the two boards just the predecessors of the one board solution?</p> <p>What are the benefits/downsides to having one/two boards?</p>
<p>Many 3d printer motherboards are based on Arduino/Atmega microcontroller and just add some stepper motor drivers, MOSFETs and such in a single board. That explains why you use the Arduino IDE to update or modify their firmware.</p> <p>Now why you would want to use an Arduino + an Arduino shield board like RAMPS? Well if you're not good at electronics, are happy with the cost of your own board, don't care much about upgrades/modding beyond what is possible with your board, maybe you shouldn't, it might be overwhelming.</p> <p>There are several advantages with using Arduino with a shield for your 3d printer, "two boards are not just the predecessors of the one board solution", no.</p> <p>1) It is moddable/exandable/upgradable/has replacable parts. If your printer came with its own motherboard that doesn't have additional or enough pins to add more fans, enclosure lights, a second extruder, an LCD and you want to, it sucks. RAMPS can do that, it has plenty of extra pins. It is upgradable. You want to replace the stepper drivers with a new one? Or you accidentally damaged the one you have? Fear not, you can just replace that instead of the whole motherboard. Think if it like other motherboards being PCs on which you can't change the CPU, RAM and GPU.</p> <p>2) It is here for a long time, you will be able to acquire one for a long time. There isn't just one company making RAMPS or similar sheilds. Sometimes 3d printing companies go out of business or stop producing your particular motherboard. RAMPS is likely here to stay. Because Arduino is very likely here to stay.</p> <p>3) As said above, not just one company owns or makes RAMPS or other Arduino shields. Besides the possibility of your motherboard not being produced anymore, there's also the advantage of not being at the mercy of one companies pricing and shipping policies. This is true for some other boards as well though.</p> <p>4) It is possibly cheaper than what have you. I don't want to post a link, but one company right now is selling their derivative of Printrboard for like $180. Check the cost of Arduino Mega, stepper drivers and a RAMPS board yourself, quite a difference. That said, there are some boards which are close in price.</p> <p>5) It's an Arduino. Why is this a good thing by itself? Because many people who have a 3d printer are tinkerers/makers and they already use Arduino for other projects. It is open source with a rich library to control many things. The modding and upgrades for your 3d printer which can be done with Arduino is another level higher. Or it can be a good learning experience for your future Arduino projects. If on the other hand you already use Arduino and are experienced with it, you might use it just because you know how to control it/fix it better than some specialized board you haven't seen before. Plus for a guy like you your 3d printer's motherboard will be an "off-the-shelf" part, that's nice, right?</p> <p>Video on RAMPS: <a href="https://www.youtube.com/watch?v=FYJn6FuWOv4">https://www.youtube.com/watch?v=FYJn6FuWOv4</a></p>
<p>There isn't really a big advantage to one solution or the other. The approach of having separate boards means it is more modular and broken parts can be replaced more easily, but electronics don't break on their own: it is almost always user error. If you are even a tiny bit careful when assembling your electronics, you won't ever have anything break and the advantage of having modular electronics is moot. On the other hand, there's no disadvantage to using modular electronics either.</p> <p>Of course, another advantage of modular electronics is that you can upgrade separate components (for instance, swap in better stepper drivers). The value of this advantage depends on whether you eventually want to upgrade.</p>
189
<p>I am aware that in <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> there are three timer types (see <em><a href="http://msdn.microsoft.com/en-us/magazine/cc164015.aspx" rel="noreferrer">Comparing the Timer Classes in the .NET Framework Class Library</a></em>). I have chosen a threaded timer as the other types can drift if the main thread is busy, and I need this to be reliable.</p> <p>The way this timer works in the control of the timer is put on another thread so it can always tick along with the work begin completed on the parent thread when it is not busy.</p> <p>The issue with this timer in a console application is that while the timer is ticking along on another thread the main thread is not doing anything to the application closes.</p> <p>I tried adding a <code>while true</code> loop, but then the main thread is too busy when the timer does go off.</p>
<p>You can use something like <code>Console.ReadLine()</code> to block the main thread, so other background threads (like timer threads) will still work. You may also use an <a href="https://learn.microsoft.com/en-us/dotnet/api/system.threading.autoresetevent" rel="noreferrer">AutoResetEvent</a> to block the execution, then (when you need to) you can call Set() method on that AutoResetEvent object to release the main thread. Also ensure that your reference to Timer object doesn't go out of scope and garbage collected.</p>
<p>According to <a href="https://learn.microsoft.com/en-us/dotnet/api/system.threading.timer?view=net-5.0" rel="nofollow noreferrer">MSDN</a> and the other answers, a minimal working example of a Console application using a System.Threading.Timer without exiting immediately :</p> <pre><code>private static void Main() { using AutoResetEvent autoResetEvent = new AutoResetEvent(false); using Timer timer = new Timer(state =&gt; Console.WriteLine(&quot;One second has passed&quot;), autoResetEvent, TimeSpan.Zero, new TimeSpan(0, 0, 1)); autoResetEvent.WaitOne(); } </code></pre>
2,243
<p>Looking for a string to pass to String#matches(String) that will match IPv4, and another to match IPv6.</p>
<pre><code>public static final String IPV4_REGEX = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; public static final String IPV6_HEX4DECCOMPRESSED_REGEX = "\\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?) ::((?:[0-9A-Fa-f]{1,4}:)*)(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; public static final String IPV6_6HEX4DEC_REGEX = "\\A((?:[0-9A-Fa-f]{1,4}:){6,6})(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; public static final String IPV6_HEXCOMPRESSED_REGEX = "\\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)\\z"; public static final String IPV6_REGEX = "\\A(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\\z"; </code></pre> <p>Got these from some blog. Someone good w/ regexes should be able to come up with a single regex for all IPv6 address types. Actually, I guess you could have a single regex that matches both IPv4 and IPv6.</p>
<p>The regex allows the use of leading zeros in the IPv4 parts.</p> <p>Some Unix and Mac distros convert those segments into octals.</p> <p>I suggest using <code>25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d</code> as an IPv4 segment.</p>
6,819
<p>I have a Tomcat Filter that delegates requests to the a handling object depending on the URL. This is the only filter in the <code>FilterChain</code>. I have an Ajax app that hammers this filter with lots of requests.</p> <p>Recently I noticed an issue where the filter's <code>doFilter</code> method is often called with a committed response as a parameter (Internally, it is the coyote response that is marked committed).</p> <p>It seems to me that the only way that this can happen is if the <code>recycle()</code> method is not called on this coyote response. I have checked to make sure that I am not keeping references to any of the request, response, outputStream, or writer objects. Additionally, I made sure to close the outputStream in a finally block. However, this doesn't resolve this issue.</p> <p>This sounds like I am doing something to abuse the servlet container but I am having trouble tracking it down.</p>
<p>I have tried using Tomcat 6.16 and 6.18. This is definitely is the only filter in the chain.</p> <p>It seems that something is keeping a reference to the servlet outputStream. I wrapped the ServletOutputStream in my own OutputStream and then made sure the reference is destroyed. This fixed the issue so that I no longer see a committed response passed in.</p> <p>This is an odd side effect of holding a reference. But I don't think it qualifies as a Tomcat bug. More likely a bug in ImageIO.createImageOutputStream() that I suspect is holding the reference.</p>
<p>What version of Tomcat are you using? To me this sounds like a bug in Tomcat, I can't think of any reason why your doFilter method should be called with a response that's already been committed (if that filter is the only one in the chain, are you sure about this?). </p>
6,721
<p>From the <em>Immediate Window</em> in Visual Studio: </p> <pre><code>&gt; Path.Combine(@"C:\x", "y") "C:\\x\\y" &gt; Path.Combine(@"C:\x", @"\y") "\\y" </code></pre> <p>It seems that they should both be the same. </p> <p>The old FileSystemObject.BuildPath() didn't work this way...</p>
<p>This is kind of a philosophical question (which perhaps only Microsoft can truly answer), since it's doing exactly what the documentation says.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx" rel="noreferrer">System.IO.Path.Combine</a></p> <p>"If path2 contains an absolute path, this method returns path2."</p> <p><a href="http://referencesource.microsoft.com/#mscorlib/system/io/path.cs,2d7263f86a526264" rel="noreferrer">Here's the actual Combine method</a> from the .NET source. You can see that it calls <a href="http://referencesource.microsoft.com/mscorlib/system/io/path.cs.html#16ed6da326ce4745" rel="noreferrer">CombineNoChecks</a>, which then calls <a href="http://referencesource.microsoft.com/mscorlib/system/io/path.cs.html#807960f08fca497d" rel="noreferrer">IsPathRooted</a> on path2 and returns that path if so:</p> <pre><code>public static String Combine(String path1, String path2) { if (path1==null || path2==null) throw new ArgumentNullException((path1==null) ? "path1" : "path2"); Contract.EndContractBlock(); CheckInvalidPathChars(path1); CheckInvalidPathChars(path2); return CombineNoChecks(path1, path2); } internal static string CombineNoChecks(string path1, string path2) { if (path2.Length == 0) return path1; if (path1.Length == 0) return path2; if (IsPathRooted(path2)) return path2; char ch = path1[path1.Length - 1]; if (ch != DirectorySeparatorChar &amp;&amp; ch != AltDirectorySeparatorChar &amp;&amp; ch != VolumeSeparatorChar) return path1 + DirectorySeparatorCharAsString + path2; return path1 + path2; } </code></pre> <p>I don't know what the rationale is. I guess the solution is to strip off (or Trim) DirectorySeparatorChar from the beginning of the second path; maybe write your own Combine method that does that and then calls Path.Combine().</p>
<p>This \ means "the root directory of the current drive". In your example it means the "test" folder in the current drive's root directory. So, this can be equal to "c:\test".</p>
7,652
<p>I have a tree structure in memory that I would like to render in HTML using a Django template. </p> <pre><code>class Node(): name = "node name" children = [] </code></pre> <p>There will be some object <code>root</code> that is a <code>Node</code>, and <code>children</code> is a list of <code>Node</code>s. <code>root</code> will be passed in the content of the template.</p> <p>I have found <a href="http://blog.elsdoerfer.name/2008/01/22/recursion-in-django-templates/" rel="noreferrer">this</a> one discussion of how this might be achieved, but the poster suggests this might not be good in a production environment.</p> <p>Does anybody know of a better way?</p>
<p>I think the canonical answer is: "Don't".</p> <p>What you should probably do instead is unravel the thing in your <em>view</em> code, so it's just a matter of iterating over (in|de)dents in the template. I think I'd do it by appending indents and dedents to a list while recursing through the tree and then sending that "travelogue" list to the template. (the template would then insert <code>&lt;li&gt;</code> and <code>&lt;/li&gt;</code> from that list, creating the recursive structure with "understanding" it.)</p> <p>I'm also pretty sure recursively including template files is really a <em>wrong</em> way to do it...</p>
<p>I had a similar issue, however I had first implemented the solution using JavaScript, and just afterwards considered how I would have done the same thing in django templates.</p> <p>I used the serializer utility to turn a list off models into json, and used the json data as a basis for my hierarchy.</p>
5,200
<p>Here's the thing I want to print.</p> <p><a href="https://i.stack.imgur.com/4bgNK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4bgNK.png" alt="enter image description here"></a></p> <p>The red ring is 3.5&nbsp;mm above the bottom of the orange cylinder. The red ring is 1cm thick. I'd prefer not to use supports because I tend to break as much as I clean up.</p> <p>I know this could be done in two pieces but then I'd have to make sure the pieces fit and then glue it in at that's too much. It'd be ideal to print this as one piece. How can I do this with as few supports as possible?</p>
<p>You can print the support as a separate piece, then when the time is right pause the print, insert the support part into the ring and the resume printing. I guess you might have to use PVA glue on the support to ensure that it comes off easily when the time is right, but I'll leave that experimentation up to you. Note: This is going to be very much trial and error on your part.</p>
<p>Assuming that the red flange needs to be flat on both sides, your best approach for printing in two parts may be a 45 degree conical cut through the flange. This will allow both parts to be printed flat on the bed, and (assuming a low layer height) should give a tolerable overhang result.</p>
1,422
<p>I want to use the functions exposed under the OpenGL extensions. I'm on Windows, how do I do this?</p>
<p><strong>Easy solution</strong>: Use <a href="http://glew.sourceforge.net/" rel="nofollow noreferrer">GLEW</a>. See how <a href="https://stackoverflow.com/questions/17370/using-glew-to-use-opengl-extensions-under-windows">here</a>.</p> <p><strong>Hard solution</strong>: If you have a <strong>really strong reason</strong> not to use GLEW, here's how to achieve the same without it:</p> <p>Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the <a href="http://www.opengl.org/registry/" rel="nofollow noreferrer">OpenGL Extension Registry</a>.</p> <blockquote> <p>Example: I wish to use the capabilities of the <a href="http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt" rel="nofollow noreferrer">EXT_framebuffer_object</a> extension. The APIs I wish to use from this extension are:</p> </blockquote> <pre><code>glGenFramebuffersEXT() glBindFramebufferEXT() glFramebufferTexture2DEXT() glCheckFramebufferStatusEXT() glDeleteFramebuffersEXT() </code></pre> <p>Check if your graphic card supports the extension you wish to use. If it does, then your work is almost done! Download and install the latest drivers and SDKs for your graphics card.</p> <blockquote> <p>Example: The graphics card in my PC is a <strong>NVIDIA 6600 GT</strong>. So, I visit the <a href="http://developer.nvidia.com/object/nvidia_opengl_specs.html" rel="nofollow noreferrer">NVIDIA OpenGL Extension Specifications</a> webpage and find that the <a href="http://www.nvidia.com/dev_content/nvopenglspecs/GL_EXT_framebuffer_object.txt" rel="nofollow noreferrer">EXT_framebuffer_object</a> extension is supported. I then download the latest <a href="http://developer.nvidia.com/object/sdk_home.html" rel="nofollow noreferrer">NVIDIA OpenGL SDK</a> and install it.</p> </blockquote> <p>Your graphic card manufacturer provides a <strong>glext.h</strong> header file (or a similarly named header file) with all the declarations needed to use the supported OpenGL extensions. (Note that not all extensions might be supported.) Either place this header file somewhere your compiler can pick it up or include its directory in your compiler's include directories list.</p> <p>Add a <code>#include &lt;glext.h&gt;</code> line in your code to include the header file into your code.</p> <p>Open <strong><a href="http://oss.sgi.com/projects/ogl-sample/ABI/glext.h" rel="nofollow noreferrer">glext.h</a></strong>, find the API you wish to use and grab its corresponding <em>ugly-looking</em> declaration.</p> <blockquote> <p>Example: I search for the above framebuffer APIs and find their corresponding ugly-looking declarations:</p> </blockquote> <pre><code>typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); for GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); </code></pre> <p>All this means is that your header file has the API declaration in 2 forms. One is a wgl-like ugly function pointer declaration. The other is a sane looking function declaration.</p> <p>For each extension API you wish to use, add in your code declarations of the function name as a type of the ugly-looking string.</p> <blockquote> <p>Example:</p> </blockquote> <pre><code>PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; </code></pre> <p>Though it looks ugly, all we're doing is to declare function pointers of the type corresponding to the extension API.</p> <p>Initialize these function pointers with their rightful functions. These functions are exposed by the library or driver. We need to use <strong>wglGetProcAddress()</strong> function to do this.</p> <blockquote> <p>Example:</p> </blockquote> <pre><code>glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) wglGetProcAddress("glGenFramebuffersEXT"); glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) wglGetProcAddress("glBindFramebufferEXT"); glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) wglGetProcAddress("glFramebufferTexture2DEXT"); glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) wglGetProcAddress("glCheckFramebufferStatusEXT"); glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) wglGetProcAddress("glDeleteFramebuffersEXT"); </code></pre> <p>Don't forget to check the function pointers for <em>NULL</em>. If by chance <strong>wglGetProcAddress()</strong> couldn't find the extension function, it would've initialized the pointer with NULL.</p> <blockquote> <p>Example:</p> </blockquote> <pre><code>if (NULL == glGenFramebuffersEXT || NULL == glBindFramebufferEXT || NULL == glFramebufferTexture2DEXT || NULL == glCheckFramebufferStatusEXT || NULL == glDeleteFramebuffersEXT) { // Extension functions not loaded! exit(1); } </code></pre> <p>That's it, we're done! You can now use these function pointers just as if the function calls existed.</p> <blockquote> <p>Example:</p> </blockquote> <pre><code>glGenFramebuffersEXT(1, &amp;fbo); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorTex[0], 0); </code></pre> <p><strong>Reference:</strong> <a href="http://www.gamedev.net/reference/articles/article1929.asp" rel="nofollow noreferrer">Moving Beyond OpenGL 1.1 for Windows</a> by Dave Astle — The article is a bit dated, but has all the information you need to understand why this pathetic situation exists on Windows and how to get around it.</p>
<p>@Kronikarz: From the looks of it, <strong>GLEW</strong> seems to be the way of the future. NVIDIA already ships it along with its <strong><a href="http://developer.nvidia.com/object/sdk_home.html" rel="nofollow noreferrer">OpenGL SDK</a></strong>. And its latest release was in 2007 compared to GLEE which was in 2006.</p> <p>But, the usage of both libraries looks almost the same to me. (GLEW has an <em>init()</em> which needs to be called before anything else though.) So, you don't need to switch unless you find some extension not being supported under GLEE.</p>
3,523
<p>I want to run a weekly batch process in an asp.net page. How can that be done?</p> <p>Thanks</p>
<blockquote> <p>Is there any known drawbacks with the solution?</p> </blockquote> <p><a href="https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/">Here is the blog post</a> in which Jeff Atwood discusses this approach. As with most of Jeff's post, the meat is in the comments where the pros and cons have been discussed in extreme detail by a large number of opinionated folks, so that is an ideal place to have that particular part of your question answered.</p>
<p>Develop a Windows Service and schedule it to run weekly once.</p>
3,465
<p>What is a good way to perform animation using .NET?</p> <p>I would prefer not to use Flash if possible, so am looking for suggestions of ways which will work to implement different types of animation on a new site I am producing.</p> <p>The new site is for a magician, so I want to provide animated buttons (Cards turning over, etc.) and also embed video. Is it possible to do this without using Flash or is this the only real solution? I would like to keep it as cross-platform and standard as possible.</p>
<p><a href="http://silverlight.net/Default.aspx" rel="nofollow noreferrer">Silverlight</a> springs to mind as an obvious choice if you want to do animation using .NET on the web. It may not cover all platforms but will work in IE and FireFox and on the Mac.</p>
<p>JavaScript is probably the way to go if you want to avoid Flash. Check this: <a href="http://www.webreference.com/programming/javascript/java_anim/" rel="nofollow noreferrer">http://www.webreference.com/programming/javascript/java_anim/</a></p> <p>It won't work for embedded video, though, so you're stuck with Flash for that (or Silverlight, or <a href="http://en.wikipedia.org/wiki/QuickTime" rel="nofollow noreferrer">QuickTime</a>).</p>
2,878
<p>We have a recurring problem at my company with build breaks in our Flex projects. The problem primarily occurs because the build that the developers do on their local machines is fundamentally different from the build that occurs on the build machine. The devs are building the projects using <code>FlexBuilder/eclipse</code> and the build machine is using the command line compilers. Inevitably, the <code>{projectname}-config.xml</code> and/or the batch file that runs the build get out of sync with the project files used by eclipse, so the the build succeeds on the dev's machine, but fails on the build machine.</p> <p>We started down the path of writing a utility program to convert FlexBuilder's project files into a <code>{projectname}-config.xml</code> file, but it's a) undocumented and b) a horrible hack.</p> <p>I've looked into the -dump-config switch to get the config files, but this has a couple of problems: 1) The generated config file has absolute paths which doesn't work in our environment (some developers use macs, some windows machines), and 2) only works right when run from the IDE, so can't be build into the build process.</p> <p>Tomorrow, we are going to discuss a couple of options, neither of which I'm terribly fond of:</p> <p><strong>a)</strong> Add a post check-in event to Subversion to remove these absolute references, or <br> <strong>b)</strong> add a pre-build process that removes the absolute reference.</p> <p>I can't believe that we are the first group of developers to run across this issue, but I can't find any good solutions on Google. How have other groups dealt with this problem?</p>
<ul> <li><p><code>__declspec(dllexport)</code> tells the linker that you want this object to be made available for other DLL's to import. It is used when creating a DLL that others can link to.</p></li> <li><p><code>__declspec(dllimport)</code> imports the implementation from a DLL so your application can use it.</p></li> </ul> <p>I'm only a novice C/C++ developer, so perhaps someone's got a better explanation than I.</p>
<p>Dllexport is used to mark a function as exported. You implement the function in your DLL and export it so it becomes available to anyone using your DLL.</p> <p>Dllimport is the opposite: it marks a function as being imported from a DLL. In this case you only declare the function's signature and link your code with the library.</p>
8,245
<p>Has anyone used Mono, the open source .NET implementation on a large or medium sized project? I'm wondering if it's ready for real world, production environments. Is it stable, fast, compatible, ... enough to use? Does it take a lot of effort to port projects to the Mono runtime, or is it really, <em>really</em> compatible enough to just take of and run already written code for Microsoft's runtime?</p>
<p>There are a couple of scenarios to consider: (a) if you are porting an existing application and wondering if Mono is good enough for this task; (b) you are starting to write some new code, and you want to know if Mono is mature enough.</p> <p>For the first case, you can use the <a href="http://mono-project.com/MoMA" rel="noreferrer">Mono Migration Analyzer tool</a> (Moma) to evaluate how far your application is from running on Mono. If the evaluation comes back with flying colors, you should start on your testing and QA and get ready to ship.</p> <p>If your evaluation comes back with a report highlighting features that are missing or differ significantly in their semantics in Mono you will have to evaluate whether the code can be adapted, rewritten or in the worst case whether your application can work with reduced functionality. </p> <p>According to our Moma statistics based on user submissions (this is from memory) about 50% of the applications work out of the box, about 25% require about a week worth of work (refactoring, adapting) another 15% require a serious commitment to redo chunks of your code, and the rest is just not worth bothering porting since they are so incredibly tied to Win32. At that point, either you start from zero, or a business decision will drive the effort to make your code portable, but we are talking months worth of work (at least from the reports we have).</p> <p>If you are starting from scratch, the situation is a lot simpler, because you will only be using the APIs that are present in Mono. As long as you stay with the supported stack (which is pretty much .NET 2.0, plus all the core upgrades in 3.5 including LINQ and System.Core, plus any of the Mono cross-platform APIs) you will be fine. </p> <p>Every once in a while you might run into bugs in Mono or limitations, and you might have to work around them, but that is not different than any other system.</p> <p>As for portability: ASP.NET applications are the easier ones to port, as those have little to no dependencies on Win32 and you can even use SQL server or other popular databases (there are plenty of bundled database providers with Mono). </p> <p>Windows.Forms porting is sometimes trickier because developers like to escape the .NET sandbox and P/Invoke their brains out to configure things as useful as the changing the cursor blinking rate expressed as two bezier points encoded in BCD form in a wParam. Or some junk like that.</p>
<p>It really depends on the namespaces and classes that you are using from the .NET framework. I had interest in converting one of my windows services to run on my email server, which is Suse, but we ran into several hard roadblocks with APIs that had not been completely implemented. There is a chart somewhere on the Mono website that lists all of the classes and their level of completion. If your application is covered, then go for it.</p> <p>Like any other application, do prototyping and testing before you make a full commitment, of course.</p> <p>Another problem we ran into is licensed software: if you are referencing someone else's DLL, you can't code your way around incompatibilities that are buried in that assembly.</p>
3,904
<p>Is it possible to convert an image image to STL file format? </p> <p><img src="https://i.stack.imgur.com/Y6SYj.png" alt="png image"></p> <p>E.g. I don't need the coloring, I need the lines.</p>
<p>I suggest your objective can best be accomplished by converting the image to a single color vector file. You can do this with Inkscape (free, Linux, Windows, Mac) by combining the built-in bitmap tracing feature with some manual editing. I attempted to do so, but the coarseness of the image would result in excessive manual edit time. It may even be faster to reduce the opacity of the image and create a manual tracing on a second layer.</p> <p>Once you have a vector file, you can use any number of 3D modeling programs to convert the file to a 3D STL. Fusion 360, Tinkercad and OpenSCAD allow import of SVG files to be extruded to user-specified thickness.</p>
<p>For things like a coat of arms, you do not require a full 3D conversion, essentially all you need is a lithograph-like effect. The best program I've found for such conversions is 3D Builder which is a free Microsoft download for windows users (yes, I was surprised too). It can use either color or degrees of greyscale shading to determine the z-axis depth of each region in the picture. Makes the cleanest conversion I've found so far. Exports as a .3mf file but can be readily converted to an .stl for 3D printing (using something like <a href="https://www.swiftconverter.com/convert_3d" rel="nofollow noreferrer">SwiftConverter</a> for example). Also has an option to invert the conversion which I've found quite useful.</p>
1,590
<pre><code>- Unit Testing - Mocking - Inversion of Control - Refactoring - Object Relational Mapping - Others? </code></pre> <p>I have found <a href="http://www.lastcraft.com/simple_test.php" rel="nofollow noreferrer">simpletest</a> for unit testing and mocking and, though it leaves much to be desired, it kind-of sort of works.</p> <p>I have yet to find any reasonable Inversion of Control framework (there is one that came up on phpclasses but no documentation and doesn't seem like anyone's tried it).</p>
<p><a href="http://www.phpundercontrol.org/" rel="nofollow noreferrer">phpUnderControl</a> - continuous integration.</p> <p>Don't forget about version control (e.g. using <a href="http://www.nongnu.org/cvs/" rel="nofollow noreferrer">CVS</a> or <a href="http://subversion.tigris.org/" rel="nofollow noreferrer">Subversion</a>)!</p>
<p>Unit Testing - PHPUnit <a href="http://www.phpunit.de/" rel="nofollow noreferrer">phpunit.de</a></p> <p>ORM - Doctrine <a href="http://www.phpdoctrine.org/" rel="nofollow noreferrer">phpdoctrine.org</a>, Propel <a href="http://propel.phpdb.org/" rel="nofollow noreferrer">propel.phpdb.org</a></p>
7,311
<p>I recently purchased a spool of PETG to try working with it. I have managed to dial in most of the settings in Prusaslicer but one, in particular, is giving me a problem. As seen in the photo, the clip I printed has extra extrusion on the inside and outside. I have noticed that the nozzle will pause at the seam for about 5 secs before continuing. (The bottom is not Elephant's foot, I just didn't clean off all the brim)</p> <p><a href="https://i.stack.imgur.com/WlK7I.jpg" rel="nofollow noreferrer" title="Photo of the front and back of a 3D printed clip showing extra extrusion"><img src="https://i.stack.imgur.com/WlK7I.jpg" alt="Photo of the front and back of a 3D printed clip showing extra extrusion" title="Photo of the front and back of a 3D printed clip showing extra extrusion" /></a></p> <p>I positioned the seam on the inside of the model. I know that the extra extrusion is caused by the seam but why would it also appear on the outside of the model?</p> <p><a href="https://i.stack.imgur.com/3RwLE.png" rel="nofollow noreferrer" title="Screenshot of the Prusaslicer Preview of the model showing the seam and retractions"><img src="https://i.stack.imgur.com/3RwLE.png" alt="Screenshot of the Prusaslicer Preview of the model showing the seam and retractions" title="Screenshot of the Prusaslicer Preview of the model showing the seam and retractions" /></a></p> <p>I have printed the same clip in PLA without any printing errors. What setting within Prusaslicer needs to change so I can get rid of the extra plastic on the inside and outside of the print?</p> <p>[I don't know what relevant print settings are needed to solve this problem, but will edit the question when I get some guidance.]</p>
<p>After checking several places online, I finally got an answer in a Discord chat.</p> <p>The solution was to turn off the <strong>Power-loss recovery</strong> setting on the printer itself.</p> <p>After that was done, the print came out beautifully.</p>
<p>Looks like <strong>Retract at layer change</strong> is causing this. Disable that and see. This will help you to improve the quality a lot.</p> <p>It will be under retraction settings:</p> <p><a href="https://i.stack.imgur.com/tdYOm.png" rel="nofollow noreferrer" title="Screenshot of retraction settings"><img src="https://i.stack.imgur.com/tdYOm.png" alt="Screenshot of retraction settings" title="Screenshot of retraction settings" /></a></p>
2,189
<p>Do you use a formal event to get people talking in your IT department? Like a <strong>monthly meetup</strong> in a social place, a <strong>internal wiki/chat</strong> space or just a regular "information market" with some <strong>presentations about technology or projects</strong> made by your staff for your staff? Do you invite Sales people to participate or is it a closed event for programmers only?</p> <p>How do you get people to participate in these events? Do you allow them to spent work time on knowledge transfer? Or do you understand it as an integral part of the work time?</p> <p>I wonder how to monitor the progress of knowledge transfer itself. How do you spot critical one-person spots of failure in your projects? There are several methods to avoid it, like staff swapping or the "fifo" attempt on bug fixing.</p> <p><em>Note:</em> Ok, this is a very very noisy question and I hope to fix it after a few comments. Sorry for the mixup.</p> <p><strong>edit</strong>: My personal experience is that there is a very high barrier for people to start contributing. It looks like they won't put in the (minimal) extra time to edit our wiki, or spend the hour in the afternoon to talk about technology topics with the developing staff. It's like people don't like our wiki, our document management system or the meeting. Maybe it's because it's all free-to-use and not forced by the management. But I don't like to force people into it - but is it the right way?</p> <p>One example: Our wiki holds pages about projects, telling who worked on it to get a first contact in case of questions. But nobody besides a colleague and me is creating this pages...</p>
<p>Knowledge Transfer and Knowledge Management have one drawback. They seem to cost an aweful lot: if everybody knows what I know, am I still needed? All the time I use to bring others up to speed, what do I gain from it?</p> <p>The best way to go about this is to be an example. Share your knowledge; in a wiki, blog about it, talk about it, make it easily accessible, and talk about the benefits you have from that: less people come to interupt and ask you stuff, as they can get an answer easily without even getting up. And show them that you are still there.</p> <p>This with all the other things mentioned will actually win out. One more thing: one of my employers kept on paying me 1/3 of my salary for another year after I left (on my own initiative), just to keep my knowledge-base up and running. Did he have to? No, it was his property anyway. But it motivated people still working for him to share their knowledge.</p>
<p>One word: Lunch</p>
7,440
<p>In a LotusScript Agent that is being run via WebQueryOpen, how do you get the name of the current server?</p>
<pre><code>Set s = New NotesSession Set db = s.CurrentDatabase If db.Server &lt;&gt; "" Then Set sName = New NotesName(db.Server) Else Set sName = New NotesName(s.Username) End If </code></pre>
<pre><code>'initialize event of a WebQueryOpen agent Dim s As New notessession Dim servername As String servername = s.UserName </code></pre>
8,436
<p>If I open a solution in Visual Studio 2008 and run a unit test then VS creates a new .vsmdi file in the Solution Items folder and gives it the next number available e.g. My Solution2.vsmdi.</p> <p>Any idea why VS is doing this and how I can get it to stop doing this?</p>
<p>It appears that the <a href="http://web.archive.org/web/20080302162715/http://blogs.vertigosoftware.com/teamsystem/archive/2006/06/23/Beware_the_Team_Test_VSMDI_file.aspx" rel="nofollow noreferrer">VSMDI problem is a known bug and has been around since VS2005 Team System</a> but it has no clear fix as yet. Another reason to NOT use MS Test.</p> <p>An MSDN blog details <a href="http://blogs.msdn.com/buckh/archive/2006/11/04/how-to-run-tests-without-test-metadata-files-and-test-lists-vsmdi-files.aspx" rel="nofollow noreferrer">how to run unit tests without VSMDI files</a>.</p>
<p>An <a href="http://blogs.vertigosoftware.com/teamsystem/archive/2006/06/23/Beware_the_Team_Test_VSMDI_file.aspx" rel="nofollow noreferrer">old post but</a> vsmdi is a meta data file created by the test system.</p>
4,782
<p>How do I find out which sound files the user has configured in the control panel?</p> <p>Example: I want to play the sound for "Device connected".</p> <p>Which API can be used to query the control panel sound settings?</p> <p>I see that there are some custom entries made by third party programs in the control panel dialog, so there has to be a way for these programs to communicate with the global sound settings.</p> <p>Edit: Thank you. I did not know that PlaySound also just played appropriate sound file when specifying the name of the registry entry.</p> <p>To play the "Device Conntected" sound:</p> <pre><code>::PlaySound( TEXT("DeviceConnect"), NULL, SND_ALIAS|SND_ASYNC ); </code></pre>
<p><a href="https://learn.microsoft.com/en-us/previous-versions/ms712879(v=vs.85)" rel="nofollow noreferrer"><code>PlaySound</code></a> is the API.</p> <p>Also see <a href="https://learn.microsoft.com/en-us/windows/win32/multimedia/using-playsound-to-play-system-sounds" rel="nofollow noreferrer">Play System Sounds</a>.</p>
<p>Not Win32, but for .net anyway, you can do this using the following in C#:</p> <pre><code>System.Media.SystemSounds.Asterisk.Play(); // Plays the Asterisk sound (used for Information (i)) // Also available: // Exclamation (Warning /!\) // Hand (aka Critical Stop - Error (X)) // Question (?) // Beep (aka Default Beep) </code></pre>
9,777
<p>Having a heckuva time with this one, though I feel I'm missing something obvious. I have a control that inherits from <code>System.Web.UI.WebControls.Button</code>, and then implements an interface that I have set up. So think...</p> <pre><code>public class Button : System.Web.UI.WebControls.Button, IMyButtonInterface { ... } </code></pre> <p>In the codebehind of a page, I'd like to find all instances of this button from the ASPX. Because I don't really know what the <em>type</em> is going to be, just the <em>interface</em> it implements, that's all I have to go on when looping through the control tree. Thing is, I've never had to determine if an object uses an interface versus just testing its type. <strong>How can I loop through the control tree and yank anything that implements <code>IMyButtonInterface</code> in a clean way</strong> (Linq would be fine)?</p> <p>Again, know it's something obvious, but just now started using interfaces heavily and I can't seem to focus my Google results enough to figure it out :)</p> <p><strong>Edit:</strong> <code>GetType()</code> returns the actual class, but doesn't return the interface, so I can't test on that (e.g., it'd return "<code>MyNamespace.Button</code>" instead of "<code>IMyButtonInterface</code>"). In trying to use "<code>as</code>" or "<code>is</code>" in a recursive function, the <em><code>type</code></em> parameter doesn't even get recognized within the function! It's rather bizarre. So</p> <pre><code>if(ctrl.GetType() == typeToFind) //ok if(ctrl is typeToFind) //typeToFind isn't recognized! eh? </code></pre> <p>Definitely scratching my head over this one.</p>
<p>Longhorn213 almost has the right answer, but as as Sean Chambers and bdukes say, you should use </p> <pre><code>ctrl is IInterfaceToFind </code></pre> <p>instead of </p> <pre><code>ctrl.GetType() == aTypeVariable </code></pre> <p>The reason why is that if you use <code>.GetType()</code> you will get the true type of an object, not necessarily what it can also be cast to in its inheritance/Interface implementation chain. Also, <code>.GetType()</code> will never return an abstract type/interface since you can't new up an abstract type or interface. <code>GetType()</code> returns concrete types only.</p> <p>The reason this doesn't work</p> <pre><code>if(ctrl is typeToFind) </code></pre> <p>Is because the type of the variable <code>typeToFind</code> is actually <code>System.RuntimeType</code>, not the type you've set its value to. Example, if you set a string's value to "<code>foo</code>", its type is still string not "<code>foo</code>". I hope that makes sense. It's very easy to get confused when working with types. I'm chronically confused when working with them.</p> <p>The most import thing to note about longhorn213's answer is that <strong>you have to use recursion</strong> or you may miss some of the controls on the page. </p> <p>Although we have a working solution here, I too would love to see if there is a more succinct way to do this with LINQ. </p>
<p>If you're going to do some work on it if it is of that type, then TryCast is what I'd use.</p> <pre><code>Dim c as IInterface = TryCast(obj, IInterface) If c IsNot Nothing 'do work End if </code></pre>
4,825
<p>Another easy one hopefully.</p> <p>Let's say I have a collection like this:</p> <pre><code>List&lt;DateTime&gt; allDates; </code></pre> <p>I want to turn that into </p> <pre><code>List&lt;List&lt;DateTime&gt;&gt; dividedDates; </code></pre> <p>where each List in 'dividedDates' contains all of the dates in 'allDates' that belong to a distinct year.</p> <p>Is there a bit of LINQ trickery that my tired mind can't pick out right now?</p> <p><strong>Solution</strong></p> <p>The Accepted Answer is correct.</p> <p>Thanks, I don't think I was aware of the 'into' bit of GroupBy and I was trying to use the .GroupBy() sort of methods rather than the SQL like syntax. And thanks for confirming the ToList() amendment and including it in the Accepted Answer :-)</p>
<pre><code>var q = from date in allDates group date by date.Year into datesByYear select datesByYear.ToList(); q.ToList(); //returns List&lt;List&lt;DateTime&gt;&gt; </code></pre>
<p>Here's the methods form.</p> <pre> allDates .GroupBy(d => d.Year) .Select(g => g.ToList()) .ToList(); </pre>
9,514
<p>What is the minimum set of HTTP verbs that a server should allow for a web service to be classed as RESTful? </p> <p>What if my hoster doesn't permit <strong><em>PUT</em></strong> and <strong><em>DELETE</em></strong>?</p> <p>Is this actually important, can I live happily ever after with just <strong><em>GET</em></strong> and <strong><em>POST</em></strong> ?</p> <hr> <p><strong>Update:</strong> Thanks for the answers folks, <a href="https://stackoverflow.com/questions/23963/restful-web-services-and-http-verbs#23971">Roger's answer</a> was probably best because of the link to the Bill Venners and Elliotte Rusty Harold interview. I now get it.</p> <hr>
<p>Yes, you can live without PUT and DELETE. </p> <p>This article tells you why: <a href="http://www.artima.com/lejava/articles/why_put_and_delete.html" rel="noreferrer">http://www.artima.com/lejava/articles/why_put_and_delete.html</a></p> <p>While to true RESTafrians this may be heresy, in the real world you do what you can, with what you have. Be as rational as you can and as consistent with your own convention as you can, but you can definitely build a good RESTful system without P and D. </p> <p>rp</p>
<p>Today's web browsers only handle GETS + POSTS. In Rails, for example, PUTS + DELETES are "faked" through hidden form fields.</p> <p>Unless your framework has some workaround to "support" PUTS + DELETES, don't worry about them for now.</p>
4,376
<p>We have an encryption service that we've exposed over net. tcp. Most of the time, the service is used to encrypt/decrypt strings. However, every now and then, we the need to encrypt large documents (pdf, JPG, bmp, etc.).</p> <p>What are the best endpoint settings for a scenario like this? Should I accept/return a stream? I've read a lot about this, but no one gives guidance on what to do when the large file doesn't occur frequently.</p>
<p>MSDN describes <a href="http://msdn.microsoft.com/en-us/library/ms789010.aspx" rel="nofollow noreferrer">how to enable streaming over WCF</a> rather well. </p> <p>Note, if the link between client and server needs to be encrypted, then you'll need to "roll your own" encryption mechanism. The default <code>net.tcp</code> encryption requires X.509 certificates, which won't work with streams as this kind of encryption needs to work on an entire message in one go rather than a stream of bytes. </p> <p>This, in turn, means that you won't be able to authenticate the client using the default WCF security mechanisms as authentication requires encryption. The only work-around for this that I know of is to implement your own custom behaviour extensions on client and server to handle authentication. </p> <p>A really good reference on how to add custom behaviour extensions is <a href="http://www.winterdom.com/weblog/2006/10/02/CustomWCFBehaviorsThroughAppConfig.aspx" rel="nofollow noreferrer">here</a>: this documents how to provide custom configuration, too (something that I don't think is discussed anywhere in the MSDN documents at this time).</p>
<p>One pattern you could follow is to have an asynchronous service that works on files on a shared file system location:</p> <ol> <li>Place the file to be encrypted on a shared location</li> <li>Call the service and tell it to encrypt the file, passing both the location and name of the file, and the addres of a callback service on the client</li> <li>The service would encrypt the file and place the encrypted copy in a shared location (the same as where the unencrypted was placed or different, doesn't matter)</li> <li>The service would call back to the client, giving the name and location of the encrypted file</li> <li>The client can retrieve the encrypted file</li> </ol>
6,832
<p>I'm looking for some examples or samples of routing for the following sort of scenario:</p> <p>The general example of doing things is: {controller}/{action}/{id}</p> <p>So in the scenario of doing a product search for a store you'd have:</p> <pre><code>public class ProductsController: Controller { public ActionResult Search(string id) // id being the search string { ... } } </code></pre> <p>Say you had a few stores to do this and you wanted that consistently, is there any way to then have: {category}/{controller}/{action}/{id}</p> <p>So that you could have a particular search for a particular store, but use a different search method for a different store?</p> <p>(If you required the store name to be a higher priority than the function itself in the url)</p> <p>Or would it come down to:</p> <pre><code>public class ProductsController: Controller { public ActionResult Search(int category, string id) // id being the search string { if(category == 1) return Category1Search(); if(category == 2) return Category2Search(); ... } } </code></pre> <p>It may not be a great example, but basically the idea is to use the same controller name and therefore have a simple URL across a few different scenarios, or are you kind of stuck with requiring unique controller names, and no way to put them in slightly different namespaces/directories?</p> <p>Edit to add:</p> <p>The other reason I want this is because I might want a url that has the categories, and that certain controllers will only work under certain categories.</p> <p>IE:</p> <p>/this/search/items/search+term &lt;-- works</p> <p>/that/search/items/search+term &lt;-- won't work - because the search controller isn't allowed.</p>
<p>I actually found it not even by searching, but by scanning through the ASP .NET forums in <a href="http://forums.asp.net/t/1296928.aspx?PageIndex=1" rel="nofollow noreferrer">this question</a>.</p> <p>Using this you can have the controllers of the same name under any part of the namespace, so long as you qualify which routes belong to which namespaces (you can have multiple namespaces per routes if you need be!)</p> <p>But from here, you can put in a directory under your controller, so if your controller was "MyWebShop.Controllers", you'd put a directory of "Shop1" and the namespace would be "MyWebShop.Controllers.Shop1"</p> <p>Then this works:</p> <pre><code> public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); var shop1namespace = new RouteValueDictionary(); shop1namespace.Add("namespaces", new HashSet&lt;string&gt;(new string[] { "MyWebShop.Controllers.Shop1" })); routes.Add("Shop1", new Route("Shop1/{controller}/{action}/{id}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { action = "Index", id = (string)null }), DataTokens = shop1namespace }); var shop2namespace = new RouteValueDictionary(); shop2namespace.Add("namespaces", new HashSet&lt;string&gt;(new string[] { "MyWebShop.Controllers.Shop2" })); routes.Add("Shop2", new Route("Shop2/{controller}/{action}/{id}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { action = "Index", id = (string)null }), DataTokens = shop2namespace }); var defaultnamespace = new RouteValueDictionary(); defaultnamespace.Add("namespaces", new HashSet&lt;string&gt;(new string[] { "MyWebShop.Controllers" })); routes.Add("Default", new Route("{controller}/{action}/{id}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index", id = "" }), DataTokens = defaultnamespace }); } </code></pre> <p>The only other thing is that it will reference a view still in the base directory, so if you put the view into directories to match, you will have to put the view name in when you return it inside the controller.</p>
<p>The best way to do this without any compromises would be to implement your own ControllerFactory by inheriting off of IControllerFactory. The CreateController method that you will implement handles creating the controller instance to handle the request by the RouteHandler and the ControllerActionInvoker. The convention is to use the name of the controller, when creating it, therefore you will need to override this functionality. This will be where you put your custom logic for creating the controller based on the route since you will have multiple controllers with the same name, but in different folders. Then you will need to register your custom controller factory in the application startup, just like your routes.</p> <p>Another area you will need to take into consideration is finding your views when creating the controller. If you plan on using the same view for all of them, then you shouldn't have to do anything different than the convention being used. If you plan on organizing your views also, then you will need to create your own ViewLocator also and assign it to the controller when creating it in your controller factory.</p> <p>To get an idea of code, there are a few questions I have answered on SO that relate to this question, but this one is different to some degree, because the controller names will be the same. I included links for reference.</p> <ul> <li><a href="https://stackoverflow.com/questions/19746/views-in-seperate-assemblies-in-aspnet-mvc">Views in separate assemblies in ASP.NET MVC</a></li> <li><a href="https://stackoverflow.com/questions/26715/aspnet-mvc-subfolders">asp.net mvc - subfolders</a></li> </ul> <p>Another route, but may require some compromises will be to use the new AcceptVerbs attribute. Check this <a href="https://stackoverflow.com/questions/36197/aspnet-mvc-structuring-controllers">question</a> out for more details. I haven't played with this new functionality yet, but it could be another route.</p>
6,479
<p>Is it possible to print toothbrush bristles using a common FDM 3D printer? I am particularly interested in the width of bristles, closeness together of each bristle, and the flexibility of each particular bristle.</p>
<p>Actually last year a group did use a normal FDM printer to 3d print hair, brushed, etc. See the press release from Carnegie Mellon University</p> <p><a href="https://www.engadget.com/2015/10/29/3d-printing-hair-is-as-easy-as-using-a-hot-glue-gun/" rel="noreferrer">https://www.engadget.com/2015/10/29/3d-printing-hair-is-as-easy-as-using-a-hot-glue-gun/</a></p> <p><a href="http://technabob.com/blog/wp-content/uploads/2015/11/3d_printed_hair_by_Gierad_Laput_Xiang_Chen_Chris_Harrison_1.jpg" rel="noreferrer">http://technabob.com/blog/wp-content/uploads/2015/11/3d_printed_hair_by_Gierad_Laput_Xiang_Chen_Chris_Harrison_1.jpg</a></p> <p>That said as far as I know you will not have access to this process, and is probably under a mountain of patents and other innovation killers. </p> <p>Now how to do this outside of fancy software.</p> <p>For a FDM printer the smallest nozzle I ever got was 0.1mm, it jammed instantly. One could print rows at this precision.</p> <p>Now we have to move to something more advanced, such as DLP. Not the materials you want, but closer to the size you want. a formlabs can print at 25 microns. Which as a hair is 17 microns, you are "close enough" .. but a resin would be brittle and break. They do have other materials such as flexibles, but I am not familiar with them enough.</p> <p>Also just going to mention. Tiny slivers of plastic is more likely to cut you than comb you.</p>
<p>I have had a go at doing something for a <a href="http://www.thingiverse.com/thing:552770" rel="nofollow">christmass tree</a> using a drop loop technique. You could use the same method or somthing similar to try and create something that looks like toothbrush bristles, but I don't think you would want to try cleaning your teeth with it. </p>
317
<p>I am part of a high school robotics team, and there is some debate about which language to use to program our robot. We are choosing between C (or maybe C++) and LabVIEW. There are pros for each language.</p> <p>C(++):</p> <ul> <li>Widely used</li> <li>Good preparation for the future (most programming positions require text-based programmers.)</li> <li>We can expand upon our C codebase from last year</li> <li>Allows us to better understand what our robot is doing.</li> </ul> <p>LabVIEW</p> <ul> <li>Easier to visualize program flow (blocks and wires, instead of lines of code)</li> <li>Easier to teach (Supposedly...)</li> <li>"The future of programming is graphical." (Think so?)</li> <li>Closer to the Robolab background that some new members may have.</li> <li>Don't need to intimately know what's going on. Simply tell the module to find the red ball, don't need to know how.</li> </ul> <p>This is a very difficult decision for us, and we've been debating for a while. Based on those pros for each language, and on the experience you've got, <strong>what do you think the better option is?</strong> Keep in mind that we aren't necessarily going for pure efficiency. We also hope to prepare our programmers for a future in programming.</p> <p>Also:</p> <ul> <li><strong>Do you think that graphical languages such as LabVEIW are the future of programming?</strong></li> <li><strong>Is a graphical language easier to learn than a textual language?</strong> I think that they should be about equally challenging to learn.</li> <li>Seeing as we are partailly rooted in helping people learn, <strong>how much should we rely on prewritten modules, and how much should we try to write on our own?</strong> ("Good programmers write good code, great programmers copy great code." But isn't it worth being a good programmer, first?)</li> </ul> <p>Thanks for the advice!</p> <hr> <p>Edit: I'd like to emphasize this question more: The team captain thinks that LabVIEW is better for its ease of learning and teaching. <strong>Is that true?</strong> I think that C could be taught just as easily, and beginner-level tasks would still be around with C. I'd really like to hear your opinions. <strong>Is there any reason that typing while{} should be any more difficult than creating a "while box?"</strong> <strong>Isn't it just as intuitive that program flows line by line, only modified by ifs and loops, as it is intuitive that the program flows through the wire, only modified by ifs and loops!?</strong></p> <p>Thanks again!</p> <hr> <p>Edit: I just realized that this falls under the topic of "language debate." I hope it's okay, because it's about what's best for a specific branch of programming, with certain goals. If it's not... I'm sorry...</p>
<p>Before I arrived, our group (PhD scientists, with little programming background) had been trying to implement a LabVIEW application on-and-off for nearly a year. The code was untidy, too complex (front and back-end) and most importantly, did not work. I am a keen programmer but had never used LabVIEW. With a little help from a LabVIEW guru who could help translate the textual progamming paradigms I knew into LabVIEW concepts it was possible to code the app in a week. The point here is that <i>the basic coding concepts still have to be learnt, the language, even one like LabVIEW, is just a different way of expressing them</i>.</p> <p>LabVIEW is great to use for what it was originally designed for. i.e. to take data from DAQ cards and display it on-screen perhaps with some minor manipulations in-between. However, programming <i>algorithms</i> is no easier and I would even suggest that it is more difficult. For example, in most procedural languages execution order is generally followed line by line, using pseudo mathematical notation (i.e. <code>y = x*x + x + 1</code>) whereas LabVIEW would implement this using a series of VI's which don't necessarily follow from each other (i.e. left-to-right) on the canvas. </p> <p>Moreover programming as a career is more than knowing the technicalities of coding. Being able to effectively ask for help/search for answers, write readable code and work with legacy code are all key skills which are undeniably more difficult in a graphical language such as LabVIEW.</p> <p>I believe some aspects of graphical programming may become mainstream - the use of sub-VIs perfectly embodies the 'black-box' principal of programming and is also used in other language abstractions such as <a href="http://pipes.yahoo.com/pipes/" rel="noreferrer">Yahoo Pipes</a> and the Apple Automator - and perhaps some future graphical language will revolutionise the way we program but LabVIEW itself is not a massive paradigm shift in language design, we still have <code>while, for, if</code> flow control, typecasting, event driven programming, even objects. If the future really will be written in LabVIEW, C++ programmer won't have much trouble crossing over.</p> <p>As a postcript I'd say that C/C++ is more suited to robotics since the students will no doubt have to deal with embedded systems and FPGAs at some point. Low level programming knowledge (bits, registers etc.) would be invaluable for this kind of thing.</p> <p><i>@mendicant</i> Actually LabVIEW is used a lot in industry, especially for control systems. Granted NASA unlikely use it for on-board satellite systems but then software developement for space-systems is a <a href="http://www.fastcompany.com/magazine/06/writestuff.html" rel="noreferrer">whole different ball game</a>...</p>
<p>It seems that if you are trying to prepare our team for a future in programming that C(++) ma be the better route. The promise of general programming languages that are built with visual building blocks has never seemed to materialize and I am beginning to wonder if they ever will. It seems that while it can be done for specific problem domains, once you get into trying to solve many general problems a text based programming language is hard to beat. </p> <p>At one time I had sort of bought into the idea of executable UML but it seems that once you get past the object relationships and some of the process flows UML would be a pretty miserable way to build an app. Imagine trying to wire it all up to a GUI. I wouldn't mind being proven wrong but so far it seems unlikely we'll be point and click programming anytime soon.</p>
3,461
<p>If I get an error code result from a Cocoa function, is there any easy way to figure out what it means (other than by grepping through all the .h files in the framework bundles)?</p>
<p>You should look at the <code>&lt;Framework/FrameworkErrors.h&gt;</code> header for whatever framework the method you're using that's returning an error comes from.</p> <p>For example, an <code>NSError</code> in the Cocoa domain that you get from a method in the Foundation framework will have its <code>code</code> property described in the <code>&lt;Foundation/FoundationErrors.h&gt;</code> header. Similarly with AppKit and <code>&lt;AppKit/AppKitErrors.h&gt;</code> and Core Data and <code>&lt;CoreData/CoreDataErrors.h&gt;</code>.</p> <p>Also, if you print the description of the <code>NSError</code> in the debugger, it should include not only the error domain and code, but also the name of the actual error code constant so you can look it up in the API reference.</p>
<p>For NSError errors add a line of code:</p> <pre><code>NSError *error; // ... Some code that returns an error // Get the error as a string NSString *s = [error localizedDescription]; // Observe the code for yourself or display to the user. </code></pre>
5,927
<p>Related to an issue I had in <a href="https://3dprinting.stackexchange.com/questions/1205/increased-issues-with-filament-grinding">this question</a>, where the PTFE tube feeding my filament to the metal tip of the extruder clogged and became discolored: what are the advantages and disadvantages of changing out my extruder (Mk10 on a FlashForge Creator X) for an all-metal solution like the one advertised <a href="https://store.micro-swiss.com/products/micro-swiss-mk10-all-metal-hotend-kit" rel="noreferrer">here (by Micro-Swiss)</a>. </p> <p>I understand that the conversion would allow me to print higher-temperature materials (like nylon), but I'm also trying to figure out the trade-offs with regard to printing PLA/ABS parts. </p>
<p>This is a good question to make a comparison table. All-metal hotends Vs. PTFE liner hotends.</p> <p>All metal:</p> <ul> <li>Works well for high (+250ºC) temperatures filaments like nylon or PC.</li> <li>No need to replace the PTFE liner (pretty obvious).</li> <li>Retraction performs worse.</li> <li>Plastic can get stuck to the inner walls. This can lead to clogging, more likely when changing from ABS to PLA (higher temp plastic to lower temp plastic).</li> </ul> <p>PTFE liner hotend:</p> <ul> <li>Limited working temperature. Above 250 PTFE will start to degrade.</li> <li>PTFE tube needs to be replaced more or less often, depending on the use of your printer.</li> <li>Retraction performs better.</li> <li>Plastic is less likely to get stuck in inner wall (PTFE is very nonstick).</li> <li>When using PTFE liner, the plastic is melted very close to the nozzle. Unlike other techniques, in FFF/FDM 3D printing this is more desirable. E.g. to avoid 'heat creep', for a better flow control and more accurate output dimension.</li> </ul> <p>Of course there are more points to compare. Please comment to add any other useful point.</p>
<p>My Tevo Tarantula had an all metal hotend included and I never ran into any issues only printing PLA and PETG, most of the time I was even able to pull out the filament while the printer was cold.</p> <p>After I upgraded to an E3Dv6 clone with PTFE lined heatbreak I started to have issues because of the filament getting stuck where the Bowden tube and the heatbreak connected, so I recently replaced it with an all metal heatbreak again and the issues instantly went away.</p>
359
<p>I am developing an application in using Ruby on Rails, mostly as an excuse to learn the language.</p> <p>This is not intended to be a web-based application - and perhaps I have chosen the wrong language, but...</p> <p>My understanding is, that in order to run an instance of this application on somebody else's computer, they would need to install ruby on rails, and a webserver (or webrick, perhaps), as well as my application code.</p> <p>I am just curious if there are any other options for distributing my application as a standalone app, or perhaps just a simple way to package up a web browser and ROR together with my app for a simple, one-step install?</p>
<p>I have personally never needed to do this. But, I have ran across this tutorial <a href="http://www.erikveen.dds.nl/distributingrubyapplications/rails.html" rel="noreferrer">http://www.erikveen.dds.nl/distributingrubyapplications/rails.html</a> that I think will be helpful. The tutorial covers how to actually convert a rails app into a standalone exe file.</p>
<p>You do not specifically say whether it is supposed to be a GUI application or not. From the other answers, I would guess so. </p> <p>Therefore, you need to clarify what your goals are. RoR is a specialized framework for web applications. If your goal is to learn RoR, I'd say to get yourself some inexpensive web hosting and make yourself an app. If your goal is to learn Ruby, not necessarily Rails, then Shoes, IronRuby, JRuby, MacRuby and others may be good options to look at. </p>
7,953
<p>For example I have a situation where I have something like this (contrived) example:</p> <pre><code>&lt;div id="outer" style="margin: auto&gt; &lt;div id="inner1" style="float: left"&gt;content&lt;/div&gt; &lt;div id="inner2" style="float: left"&gt;content&lt;/div&gt; &lt;div id="inner3" style="float: left"&gt;content&lt;/div&gt; &lt;br style="clear: both"/&gt; &lt;/div&gt; </code></pre> <p>where there are no widths set on any elements, and what I want is <code>#inner1</code>, <code>#inner2</code> and <code>#inner3</code> to appear next to each other horizontally inside <code>#outer</code> but what is happening is that <code>#inner1</code> and <code>#inner2</code> are appearing next to each other and then <code>#inner3</code> is wrapping on to the next line.</p> <p>In the actual page where this is happening there is a lot more going on, but I have inspected all of the elements very carefully with Firebug and do not understand why the <code>#inner3</code> element is not appearing on the same line as <code>#inner1</code> and <code>#inner2</code> and causing <code>#outer</code> to get wider.</p> <p>So, my question is: Is there any way to determine <strong>why</strong> the browser is sizing #outer the way it is, or why it is choosing to wrap <code>#inner3</code> even though there is plenty of room to put it on the previous "line"? Baring specific solutions to this problem, what tips or techniques do you hardcore HTML/CSS/Web UI guys have for a poor back end developer who has found himself working on the front end?</p>
<p>Try the <a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferrer">Web Developer Plugin</a> for Firefox. Specifically, the <strong>Information -> Display Block Size</strong> and <strong>Outline -> Outline Block Level Elements</strong> options. This will allow to see the borders of your elements, and their size as Firefox sees them.</p>
<p>In Firebug's CSS tab, you can see what style rules apply to a selected elements in the cascading order. This may or may not help you in your problem.</p> <p>My guess would be that something about the content of #inner3 is causing it to wrap below the first line, and the #outer is just getting sized to accommodate the smaller needed space.</p>
6,664
<p>I have some code that uses SMO to populate a list of available SQL Servers and databases. While we no longer support SQL Server 2000, it's possible that the code could get run on a machine that SQL Server 2000 and not have the SMO library installed. I would perfer to check for SMO first and degrade the functionality gracefully instead of blowing up in the user's face. What is best way to detect whether or not SMO is available on a machine?</p> <p>Every example that I have seen through a quick Google scan was a variation of "look for C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll". The problem with that approach is that it only works with SQL Server 2005. If SQL Server 2008 is the only SQL Server installed then the path will be different.</p>
<p>I had a look at the SharedManagementObjects.msi from the SQL2008 R2 feature pack and my Windows Registry (SQL2008 R2 Dev is installed on this machine) and I believe these are the reg keys one should use to detect SMO (All under HKLM):</p> <p>SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion - this is apparently the main key, indicating that some version of SMO is installed.</p> <p>SOFTWARE\Microsoft\Microsoft SQL Server 2008 Redist\SharedManagementObjects\1033\CurrentVersion - this one probably means 2008 English is installed. Probably just checking for the presence of SOFTWARE\Microsoft\Microsoft SQL Server 2008 Redist\SharedManagementObjects would suffice.</p> <p>Same applies to SQL2012: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server 2012 Redist\SharedManagementObjects\1033\CurrentVersion</p> <p>But NOT SQL2005! even though I do have 2005 installed on this machine as well.</p> <p>One more thing, You'd normally want Microsoft SQL Server System CLR Types as well, since SMO depends on them. The SQLSysClrTypes.msi has only one registry key: SOFTWARE\Microsoft\Microsoft SQL Server\RefCount\SQLSysClrTypes</p>
<p>Just a quick note: HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion\Version doesn't represent the current version that is installed, because there could be several versions installed.</p> <p>The registry key above is being updated when you install a version, so if you've installed SMO 2014 then you should see 12.x, but if afterwards you install SMO 2012, then this version would change to 11.x If you then decides to repair the 2014 installtion, then the version would be again 12.x</p> <p>You should better look at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server 2012 Redist\SharedManagementObjects\1033\CurrentVersion</p> <p>or HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server 2014 Redist\SharedManagementObjects\1033\CurrentVersion</p> <p>Does someone knows if the 1033 is guaranteed? (Meaning only english version)</p>
6,391
<p>Say I have an interface IFoo which I am mocking. There are 3 methods on this interface. I need to test that the system under test calls at least one of the three methods. I don't care how many times, or with what arguments it does call, but the case where it ignores all the methods and does not touch the IFoo mock is the failure case.</p> <p>I've been looking through the Expect.Call documentation but can't see an easy way to do it.</p> <p>Any ideas?</p>
<p>You can give rhino mocks a lambda to run when a function get's called. This lambda can then increment a counter. Assert the counter > 1 and you're done.</p> <p>Commented by Don Kirkby: I believe Mendelt is referring to the Do method.</p>
<p>Not sure this answers your question but I've found that if I need to do anything like that with Rhino (or any similiar framework/library), anything that I didn't know how to do upfront, then I'm better just creating a manual mock. </p> <p>Creating a class that implements the interface and sets a public boolean field to true if any of the methods is called will be trivially easy, you can give the class a descriptive name which means that (most importantly) the next person viewing the code will immediately understand it.</p>
7,721
<p>Is a GUID unique 100% of the time?</p> <p>Will it stay unique over multiple threads?</p>
<blockquote> <p>While each generated GUID is not guaranteed to be unique, the total number of unique keys (2<sup>128</sup> or 3.4×10<sup>38</sup>) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×10<sup>22</sup> stars; every star could then have 6.8×10<sup>15</sup> universally unique GUIDs.</p> </blockquote> <p>From <a href="https://en.wikipedia.org/wiki/Globally_Unique_Identifier" rel="noreferrer">Wikipedia</a>.</p> <hr /> <p>These are some good articles on how a GUID is made (for .NET) and how you could get the same guid in the right situation.</p> <p><a href="https://ericlippert.com/2012/04/24/guid-guide-part-one/" rel="noreferrer">https://ericlippert.com/2012/04/24/guid-guide-part-one/</a></p> <p><a href="https://ericlippert.com/2012/04/30/guid-guide-part-two/" rel="noreferrer">https://ericlippert.com/2012/04/30/guid-guide-part-two/</a></p> <p><a href="https://ericlippert.com/2012/05/07/guid-guide-part-three/" rel="noreferrer">https://ericlippert.com/2012/05/07/guid-guide-part-three/</a></p> <p>​​</p>
<p>Enough GUIDs to assign one to each and every hypothetical grain of sand on every hypothetical planet around each and every star in the visible universe.</p> <p>Enough so that if every computer in the world generates 1000 GUIDs a second for 200 years, there might (MIGHT) be a collision.</p> <p>Given the number of current local uses for GUIDs (one sequence per table per database for instance) it is extraordinarily unlikely to ever be a problem for us limited creatures (and machines with lifetimes that are usually less than a decade if not a year or two for mobile phones).</p> <p>... Can we close this thread now?</p>
6,093
<p>I've seen SaaS applications hosted in many different ways. Is it a good idea to split features and modules across multiple databases? For example, putting things like the User table on one DB and feature/app specific tables on another DB and perhaps other commonly shared tables in another DB?</p>
<p>Start with one database. Split data/functionality when project requires it.</p> <p>Here is what we can learn from LinkedIn:</p> <ul> <li>A single database does not work</li> <li>Referential integrity will not be possible</li> <li>Any data loss is a problem</li> <li>Caching is good even when it's modestly effective</li> <li>Never underestimate growth trajectory</li> </ul> <p>Source:</p> <p><a href="http://www.slideshare.net/linkedin/linkedins-communication-architecture" rel="noreferrer">LinkedIn architecture</a></p> <p><a href="http://www.slideshare.net/linkedin/linked-in-javaone-2008-tech-session-comm" rel="noreferrer">LinkedIn communication architecture</a></p>
<p>Keep it a natural design (denormalize as much as needed, normalize as less as required). Split the DB Model into its modules and keep the service oriented principles in mind by fronting data with a service (that owns the data). </p>
9,460
<p>When choosing which filament to use for a particular print does the color of the filament have any impact on it's performance, or is it purely a cosmetic choice?</p> <p>For example, are there any side-by-side comparisons available that demonstrate that differences do\don't exist between different color filaments from the same company\range, such as a particular filament needing a hotter bed because the pigment changes it's properties?</p>
<p>Depending on the pigment size and other additions, the melting temperature and crystalline/amorphous structure of prints vary vastly.</p> <p>Titanium white, the most common white pigment in the industry, needs to be applied in large doses to get a good coloration. This means that the brighter the white, the larger the percentage volume of the item is made up of the <em>pockets</em> in the polymer structure that contains the pigment, resulting in a more brittle structure.</p> <p>Carbon black on the other hand is one of the most effective black pigments known to man and can be used very sparingly. It also is an almost perfect UV-absorber, making such prints heat up much more than those of other colors. It also can protect the polymer itself from aging if the polymer chains degrade under UV light. ABS for example does undergo degradation in UV light.</p> <p>Some polymers also contain some kind of filler to adjust melting temperatures:</p> <p>I have encountered PLA spools from two different manufacturers in the almost exact same color before printing. However, the one brand printed well already at 190 °C, the other required 200 °C to print decently. The two filaments <em>also</em> looked vastly different after printing: the hotter printing one showed a much higher gloss after printing, which hints that they had a quite different makeup besides the PLA - either something in the one was making melting easier but reduced gloss or something that increased gloss also rose the melting point.</p> <p>Another thing I found was, that the clear PLA I got from china once printed best at 110 % flow of other PLAs in combination with only 185 °C, making me believe that something in the treatment to achieve the translucent filament also results in altering the flow behavior.</p>
<p>Yes in some cases it does.</p> <p>It is widely known in communities which are pickier about properties that white filament requires a percentage of pigments much higher than other colours, therefore white filaments are typically weaker (or significantly weaker) than most other colours.</p> <p>Another exception is black: ABS is not UV resistant, but if you use black ABS, the UV will not penetrate and, unless the surface is continuously scraped away, the UV resistance of black ABS is better than other colours.</p> <p>I remember some mentions in the Voron discord chats that red (at least from some manufacturers) is better than some other colours from the same manufacturer, but I don't remember the details. You can <a href="https://discord.com/invite/voron" rel="nofollow noreferrer">join</a> the chat yourself and search (before asking!) in the #filament chat.</p> <p>I remember reading that pure (&quot;natural&quot;) filaments are however not always better than filaments with colours added, but I cannot remember the source. It could be that some little amount of extra additives (the colour pigments) offer the polymer something to &quot;grab&quot;, so better than nothing. My guess, but I have no support for it.</p>
2,060
<p>By looking at our <code>DB's</code> error log, we found that there was a constant stream of almost successful SQL injection attacks. Some quick coding avoided that, but how could I have setup a monitor for both the DB and Web server (including POST requests) to check for this? By this I mean if there are off the shelf tools for script-kiddies, are there off the shelf tools that will alert you to their sudden random interest in your site?</p>
<p>Funnily enough, Scott Hanselman had a <a href="http://www.hanselman.com/blog/HackedAndIDidntLikeItURLScanIsStepZero.aspx" rel="nofollow noreferrer">post on UrlScan</a> today which is one thing you could do to help monitor and minimize potential threats. It's a pretty interesting read.</p>
<p>Monitoring web and DB access logs should alert you to things like this, but if you want a more fully featured alert system I would suggest some kind of IDS/IPS. You'll need a spare machine though, and a switch that can do port mirroring. If you have those then an IDS is a cheap way of monitoring your traffic for many intrusion attempts (there will be lots). Snort (www.snort.org) based IDSes are excellent, and there are some free fully packaged versions available. One I have used is StrataGuard (<a href="http://sgfree.stillsecure.com/" rel="nofollow noreferrer">http://sgfree.stillsecure.com/</a>), and it can be configured as an IDS (Intrusion Detection System) or as an IPS (Intrusion Prevention System). It's free to use if your traffic does not exceed 5Mbps. If you do go with an IDS/IPS I'd advise you to let it run as a simple IDS for a month or so, before you allow it to prevent attacks. </p> <p>This may be overkill, but if you have a spare machine lying around it can't hurt to have an IDS running passively.</p>
2,995
<p>I'm using <code>ColdFusion</code> to populate a template that includes HTML unordered lists (<code>&lt;ul&gt;</code>s).</p> <p>Most of these aren't that long, but a few have ridiculously long lengths and could really stand to be in 2-3 columns.</p> <p>Is there an HTML, ColdFusion or perhaps JavaScript (I'm accepting jQuery solutions) way to do this easily? It's not worth some over-complicated heavyweight solution to save some scrolling.</p>
<p>So I dug up this article from A List Apart <a href="http://www.alistapart.com/articles/multicolumnlists" rel="noreferrer">CSS Swag: Multi-Column Lists</a>. I ended up using the first solution, it's not the best but the others require either using complex HTML that can't be generated dynamically, or creating a lot of custom classes, which could be done but would require loads of in-line styling and possibly a huge page.</p> <p>Other solutions are still welcome though.</p>
<p>To output the list into multiple grouped tag you can loop in this fashion.</p> <pre><code>&lt;cfset list="1,2,3,4,5,6,7,8,9,10,11,12,13,14"&gt; &lt;cfset numberOfColumns = "3"&gt; &lt;cfoutput&gt; &lt;cfloop from="1" to="#numberOfColumns#" index="col"&gt; &lt;ul&gt; &lt;cfloop from="#col#" to="#listLen(list)#" index="i" step="#numberOfColumns#"&gt; &lt;li&gt;#listGetAt(list,i)#&lt;/li&gt; &lt;/cfloop&gt; &lt;/ul&gt; &lt;/cfloop&gt; &lt;/cfoutput&gt; </code></pre>
2,692
<p>So for e.g. 0110 has bits 1 and 2 set, 1000 has bit 3 set 1111 has bits 0,1,2,3 set</p>
<p>If there are really only 4 bits, then the fastest method would certainly involve a lookup table. There are only 16 different possibilities after all.</p>
<p>Depends on what you mean by fastest. </p> <p>If you mean "simple to code", in .NET you can use the BitArray class and refer to each bit as a boolean true/false.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx" rel="nofollow noreferrer">BitArray Class</a></p>
9,440
<p>I changed the filament, and to adjust filament temperature, I printed a test model and it looked good: </p> <p><a href="https://i.stack.imgur.com/90rop.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/90rop.jpg" alt="enter image description here"></a></p> <p>But printing another part did not go so well: </p> <p><a href="https://i.stack.imgur.com/kDVQa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kDVQa.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/vYSJy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vYSJy.jpg" alt="enter image description here"></a></p> <p>After the failed print I ran another test: <a href="https://i.stack.imgur.com/Vp0Pk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vp0Pk.jpg" alt="enter image description here"></a></p> <p>Еverything is done with the same settings. And I think the temperature and settings are okay.</p> <p>Is it possible to have a missed step on the Z axis, and this has caused the crushing of the layers or bad filament quality.</p> <p>Where does the problem come from?</p>
<p>It definitely looks like the temperature is too high</p> <p>but it can also mean that </p> <ul> <li>the speed is too low and/or</li> <li>the cooling fan is not driven correctly and/or</li> <li>over extrusion could play a role here</li> </ul> <p>this is the scenario with all these issues together</p> <p>too high temperature melts too much filament which is put by too slow movements</p> <p>;)</p> <p>check the printing when your object changes from well printed to this ugly state</p>
<p>From third picture - moisture!</p> <p>Is new filament cheap? I guess it was too long on stash and/or bad package.</p> <p>Look for <a href="https://www.youtube.com/channel/UCxQbYGpbdrh-b2ND-AfIybg" rel="nofollow noreferrer">Maker's Muse</a>'s video on Youtube about this topic. </p>
1,279
<p>Looking at the following code, from <a href="https://github.com/JimBrown/MarlinTarantula/blob/2ce73937f3c57aac28a8d5f11a6ed9135a27cdca/Marlin/pins_RAMPS.h#L139" rel="nofollow noreferrer">Line 139</a>, <a href="https://github.com/JimBrown/MarlinTarantula/blob/2ce73937f3c57aac28a8d5f11a6ed9135a27cdca/Marlin/pins_RAMPS.h" rel="nofollow noreferrer">pins_RAMPS.h</a></p> <p><a href="https://i.stack.imgur.com/ufVqI.png" rel="nofollow noreferrer" title="Screenshot of code snippet"><img src="https://i.stack.imgur.com/ufVqI.png" alt="Screenshot of code snippet" title="Screenshot of code snippet"></a></p> <p>Here is the actual code:</p> <pre><code>#if ENABLED(EXTRUDER_USE_E1) #define E0_STEP_PIN 36 #define E0_DIR_PIN 34 #define E0_ENABLE_PIN 30 #ifndef E0_CS_PIN #define E0_CS_PIN 44 #endif #else #define E0_STEP_PIN 26 #define E0_DIR_PIN 28 #define E0_ENABLE_PIN 24 #ifndef E0_CS_PIN #define E0_CS_PIN 42 #endif #endif #if DISABLED(X_AXIS_USE_E1) &amp;&amp; DISABLED(Y_AXIS_USE_E1) &amp;&amp; DISABLED(Z_AXIS_USE_E1) &amp;&amp; DISABLED(EXTRUDER_USE_E1) #define E1_STEP_PIN 36 #define E1_DIR_PIN 34 #define E1_ENABLE_PIN 30 #ifndef E1_CS_PIN #define E1_CS_PIN 44 #endif #endif </code></pre> <p>I've already tried everything that the online community tells me to do to solve this problem, but that all doesn't help me. Almost everyone is saying that I just have to swap these lines of code and it will work, but it's not working. Any ideas ?</p> <p>By the way E0 is not working because I've burnt a pot on it :)</p>
<p>At first it was unclear from where the snippet you posted is taken from as it was not stated in the question (<em>this has now been addressed by a moderator edit</em>).</p> <p>Depending on the value of <code>EXTRUDER_USE_E1</code> (and where and how it is set) the underlying code of the if statement will be carried out. Albeit said, swapping lines will not work, if you want to use the E1 connector of your motherboard, you have to make the printer think that it is using the E0 while it is redirecting to E1! This implies that you need to assign the pins of the E1 to the E0 extruder (so swap the pins, not the lines). This has been explained before in <a href="https://3dprinting.stackexchange.com/questions/5840/how-to-change-e0-to-e1-on-marlin-1-1">this topic</a> by editing the correct pin layout file of the Marlin firmware.</p> <hr> <p><strong>EDIT :</strong> Further investigation shows that you have a custom Marlin for the TEVO Tarantula and are using the fork of Marlin maintained by <a href="https://github.com/JimBrown/MarlinTarantula" rel="nofollow noreferrer">JimBrown</a> (<strong>this is essential information</strong> for your question). I have looked into the files, the only thing you would need to do is define the constant <code>EXTRUDER_USE_E1</code> in your <a href="https://github.com/JimBrown/MarlinTarantula/blob/EasyConfig-1.1.x/Marlin/Configuration.h" rel="nofollow noreferrer">configuration.h</a> file:</p> <pre><code>//#define EXTRUDER_USE_E1 </code></pre> <p>to:</p> <pre><code>#define EXTRUDER_USE_E1 </code></pre> <p>So do not swap anything. Once this constant is defined, the pin re-allocation is done for you automatically! (see the <a href="https://github.com/JimBrown/MarlinTarantula/blob/EasyConfig-1.1.x/Marlin/pins_RAMPS.h" rel="nofollow noreferrer">pins_RAMPS.h file</a>)</p> <p>Basically, this is exactly the same as is explained in topic <a href="https://3dprinting.stackexchange.com/questions/5840/how-to-change-e0-to-e1-on-marlin-1-1">How to change E0 to E1 on Marlin 1.1?</a> and hence a duplicate. ;)</p>
<p>I simply swapped the pins </p> <pre><code>#define E1_STEP_PIN 26 //swapping to E1 FRED #define E1_DIR_PIN 28 #define E1_ENABLE_PIN 24 #ifndef E1_CS_PIN #define E1_CS_PIN 42 #endif #define E0_STEP_PIN 36 //swapping to E0 FRED #define E0_DIR_PIN 34 #define E0_ENABLE_PIN 30 #ifndef E0_CS_PIN #define E0_CS_PIN 44 #endif </code></pre> <p>Which worked for the basic operation, however now that I've tried to add Autoleveling it stopped moving E1 motor. My configuration.h file does not have:<br> <code>#define EXTRUDER_USE_E1</code> apparently as its an older version also, just like RAMPS.h doesn't have those conditional statements.</p>
900
<p>From <a href="https://stackoverflow.com/questions/60419/do-i-really-need-to-use-transactions-in-stored-procedures-mssql-2005">this post</a>. One obvious problem is scalability/performance. What are the other problems that transactions use will provoke?</p> <p>Could you say there are two sets of problems, one for long running transactions and one for short running ones? If yes, how would you define them?</p> <p>EDIT: Deadlock is another problem, but data inconsistency might be worse, depending on the application domain. Assuming a transaction-worthy domain (banking, to use the canonical example), deadlock possibility is more like a cost to pay for ensuring data consistency, rather than a problem with transactions use, or you would disagree? If so, what other solutions would you use to ensure data consistency which are deadlock free? </p>
<p>It depends a lot on the transactional implementation inside your database and may also depend on the transaction isolation level you use. I'm assuming "repeatable read" or higher here. Holding transactions open for a long time (even ones which haven't modified anything) forces the database to hold on to deleted or updated rows of frequently-changing tables (just in case you decide to read them) which could otherwise be thrown away. </p> <p>Also, rolling back transactions can be really expensive. I know that in MySQL's InnoDB engine, rolling back a big transaction can take FAR longer than committing it (we've seen a rollback take 30 minutes).</p> <p>Another problem is to do with database connection state. In a distributed, fault-tolerant application, you can't ever really know what state a database connection is in. Stateful database connections can't be maintained easily as they could fail at any moment (the application needs to remember what it was in the middle of doing it and redo it). Stateless ones can just be reconnected and have the (atomic) command re-issued without (in most cases) breaking state.</p>
<p>I think the major issue is at the design level. At what level or levels within my application do I utilise transactions.</p> <p>For example I could:</p> <ul> <li>Create transactions within stored procedures, </li> <li>Use the data access API (ADO.NET) to control transactions </li> <li>Use some form of implicit rollback higher in the application</li> <li>A distributed transaction in (via DTC / COM+).</li> </ul> <p>Using more then one of these levels in the same application often seems to create performance and/or data integrity issues.</p>
8,542
<p>I recently had a print failure/crash, where the print stuck to the nozzle and forced molten filament back into the print head, fans, and heater block.</p> <p>I changed the nozzle for a new 0.4mm same as existing. I shortened the bowden tube by ~8mm to remove some crispiness, and the push-lock connector on top of the print head, which was full of solidified PLA.</p> <p>The hotend was scraped clean of PLA, and the wiring was inspected. The silicon sock was unhappy but I managed to get it to stay in place.</p> <p>The part-cooling fan duct was deformed, but I have reshaped it as well as I could. The part-cooling air is probably slightly less than it was.</p> <p><a href="https://i.stack.imgur.com/7eDR7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7eDR7.jpg" alt="enter image description here" /></a></p> <p>I'm printing some Gridfinity bins, and the base just isn't filling in completely and there is also more stringiness.</p> <p>The sides are not joining up at all, and are just a series of separate strands. They do merge somewhat at the corners.</p> <p><a href="https://i.stack.imgur.com/J1Rrx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J1Rrx.jpg" alt="enter image description here" /></a></p> <p>My printer worked much better before the crash - what do I have to focus on to improve this?</p> <p>All print jobs since the reassembly are lower in quality, with one in three showing these large &quot;wire bundles&quot; look but all of them are not as good as before-prints.</p>
<p>I'm a fan of OpenSCAD and have used the method suggested in the first answer. For non-OpenSCAD users, another option exists, which I've also used.</p> <p>PrusaSlicer is a free 3D printer slicing program. One can configure layer heights as desired for the material thickness, even though it's not likely one will find a printer with such values, except perhaps concrete 3D printers!</p> <p>Once configured and sliced, the exported file (configured for a Prusa SL1 printer) is renamed to .ZIP and the files within extracted. The files of note are going to be PNG format, one file per layer.</p> <p>The settings within the slicer software have to be &quot;adjusted&quot; for your creation.</p> <p>In Print Settings tab, change the layer height to match your material thickness. Also in the Print Settings tab, turn off supports and turn off pad (left column selections).</p> <p>In Material Settings tab, change the Initial layer height to match your overall layer thickness. Unchanged, it remains the default 0.05 mm, unlikely to match your building material.</p> <p>On the Printer Settings tab, change the bed shape to match your objective plus a bit of spacing around the item. Change the max height appropriately.</p> <p>Set the Display Width parameters to match your output. Excessively large values will result in small model segments in a large blank area. Set pixel values to desired resolution of the output image file. For example, 200 is equivalent to a typical inkjet printer resolution.</p> <p>I performed all of the above steps for a simple cube, exported the file to the default .SL1 extension, renamed it to .ZIP and extracted to a folder. The folder contained a number of support files for the MSLA printer, but also a full list of the layer .PNG files. Depending on your system settings, you may be able to change the extension in the Save dialog to .ZIP.</p> <p>If PNG is not a suitable format, one can convert them to SVG using Inkscape bitmap trace or similar software.</p> <p>I recommend to create a model with some form of registration incorporated to the design. One can create and subtract a pair of cylinders, for example, that travels through each layer, allowing insertion of a dowel to more easily stack the slices for assembly.</p> <p>One can add primitives within the slicer, but they fall to the bed and also cannot be subtracted, at least so far as my limited research has shown. I've used Fusion 360 and Meshmixer to create such modifications.</p> <p>Another aspect of the slicer is the ability to hollow the model, which would provide for some interesting constructions as well as possibly easier alignment.</p> <p>This should be a .GIF animation of the results of my testing on Astronaut Phil A Ment, 1 millimeter layer height:</p> <p><a href="https://i.stack.imgur.com/ES8A3.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ES8A3.gif" alt="astronaut slicing animation" /></a></p> <p>stltopng conversion of original STL file of Phil:</p> <p><a href="https://i.stack.imgur.com/of3mZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/of3mZ.png" alt="phil a ment model" /></a></p>
<p>With OpenSCAD, you can <code>import</code> the STL file and apply <code>projection</code> with <code>cut=true</code> at successive Z-axis <code>translate</code> operations, and write out the result as SVG. This can all be automated from the command line to product a series of SVG files for your layers to &quot;2D print&quot;.</p>
2,151
<p>This is related to the <a href="https://stackoverflow.com/questions/24468/running-partially-trusted-net-assemblies-from-a-network-share">this question</a> and the answer maybe the same but I'll ask anyways.</p> <p>I understand that we can start managed executables from the network from .NET 3.5 SP1 but what about assemblies loaded from inside the executable? Does the same thing apply?</p>
<p>You have been able to load Assemblies from the network at leasst from .NET 2.0. I have used this on a previous project. The only thing to watch is the size of the assembly and the number and size of the dependancies that it is loading.</p> <p>If you are using a seperate AppDomain, then you will need to take special consideration of the dependancies.</p>
<p>My understanding is yes, you're trying to load an untrusted module into your local app domain.</p>
8,616
<p>I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians.</p> <p>I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the length of the hypotenuse and therefore the variable angle of var z? A solution in either AS3 or psuedocode would be very helpful. Thanks.</p> <p><img src="https://i.stack.imgur.com/B0nfz.jpg" alt="triangle"></p>
<p>What you need is this:</p> <pre><code>var h:Number = Math.sqrt(x*x + y*y); var z:Number = Math.atan2(y, x); </code></pre> <p>That should give you the angle in radians, you might need to swap x/y and possibly add or remove 90 degrees but it should do the trick! (Note that you don't even need <strong>h</strong> to get <strong>z</strong> when you're using atan2)</p> <p>I use multiplication instead of Math.pow() just because Math is pretty slow, you can do:</p> <pre><code>var h:Number = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); </code></pre> <p>And it should be exactly the same.</p>
<p>What @Patrick said, also the hypotenuse is <code>sqrt(x^2 + y^2)</code>.</p>
8,002
<p>Consider the following setup: A windows PC with a LAN interface and a WiFi interface (the standard for any new laptop). Each of the interfaces might be connected or disconnected from a network. I need a way to determine which one of the adapters is the one connected to the internet - specifically, in case they are both connected to different networks, one with connection to the internet and one without.</p> <p>My current solution involves using IPHelper's "<a href="http://msdn.microsoft.com/en-us/library/aa365920(VS.85).aspx" rel="noreferrer">GetBestInterface</a>" function and supplying it with the IP address "0.0.0.0".</p> <p>Do you have any other solutions you might suggest to this problem?</p> <p>Following some of the answers, let me elaborate:</p> <ul> <li>I need this because I have a product that has to choose which adapter to bind to. I have no way of controlling the setup of the network or the host where the product will run and so I need a solution that is as robust as possible, with as few assumptions as possible.</li> <li>I need to do this in code, since this is part of a product.</li> </ul> <p>@Chris Upchurch: This makes me dependent on google.com being up (usually not a problem) and on any personal firewall that might be installed to allow pinging.</p> <p>@Till: Like Steve Moon said, relying on the adapter's address is kind of risky because you make a lot of assumptions on the internal network setup.</p> <p>@Steve Moon: Looking at the routing table sounds like a good idea, but instead of applying the routing logic myself, I am trying to use "GetBestInterface" as described above. I believe what it should do is exactly what you outlined in your answer, but I am not really sure. The reason I'm reluctant to implement my own "routing logic" is that there's a better chance that I'll get it wrong than if I use a library/API written and tested by more "hard-core" network people.</p>
<p>Technically, there is no "connected to the Internet". The real question is, which interface is routeable to a desired address. Right now, you're querying for the "default route" - the one that applies if no specific route to destination exists. But, you're ignoring any specific routes.</p> <p>Fortunately, for 99.9% of home users, that'll do the trick. They're not likely to have much of a routing table, and GetBestInterface will automatically prefer wired over wireless - so you should be good. Throw in an override option for the .1% of cases you screw up, and call it a day. </p> <p>But, for corporate use, you should be using GetBestInterface for a specific destination - otherwise, you'll have issues if someone is on the same LAN as your destination (which means you should take the "internal" interface, not the "external") or has a specific route to your destination (my internal network could peer with your destination's network, for instance).</p> <p>Then again, I'm not sure what you plan to do with this adapter "connected to the Internet", so it might not be a big deal.</p>
<p>Ping google.com though each NIC.</p>
5,985
<p>When developing whether its Web or Desktop at which point should a developer switch from SQLite, MySQL, MS SQL, etc</p>
<p>It depends on what you are doing. You might switch if:</p> <ul> <li>You need more scalability or better performance - say from SQLite to SQL Server or Oracle.</li> <li>You need access to more specific datatypes.</li> <li>You need to support a customer that only runs a particular database.</li> <li>You need better DBA tools.</li> <li>Your application is using a different platform where your database no longer runs, or it's libraries do not run.</li> <li>You have the ability/time/budget to actually make the change. Depending on the situation, the migration could be a bigger project than everything in the project up to that point. Migrations like these are great places to introduce inconsistencies, or to lose data, so a lot of care is required.</li> </ul> <p>There are many more reasons for switching and it all depends on your requirements and the attributes of the databases.</p>
<p>BrianLy hit the nail on the head, but I'd also add that you may end up using different databases at different levels of development. It's not uncommon for developers to use SQLite on their workstation when they're coding against their personal development server, and then have the staging and/or production sites using a different database tool.</p> <p>Of course, if you're using extensions or capabilities specific to a certain database tool (say, PostGIS in PostGreSQL), then obviously that wouldn't work.</p>
2,688
<p>Does anyone known of a a good reference for canonical CS problems?</p> <p>I'm thinking of things like "the sorting problem", "the bin packing problem", "the travailing salesman problem" and what not.</p> <p><strong>edit:</strong> websites preferred</p>
<p>You can probably find the best in an algorithms textbook like <a href="https://rads.stackoverflow.com/amzn/click/com/0262032937" rel="nofollow noreferrer" rel="nofollow noreferrer">Introduction to Algorithms</a>. Though I've never read that particular book, it's quite renowned for being thorough and would probably contain most of the problems you're likely to encounter.</p>
<p>@rcreswick those sound like good references but fall a bit shy of what I'm thinking of. (However, for all I know, it's the best there is)</p> <p>I'm going to not mark anything as accepted in hopes people might find a better reference.</p> <p>Meanwhile, I'm going to list a few problems here, fell free to add more</p> <p><strong>The sorting problem</strong> Find an order for a set that is monotonic in a given way</p> <p><strong>The bin packing problem</strong> partition a set into a minimum number of sets where each subset is "smaller" than some limit</p> <p><strong>The travailing salesman problem</strong> Find a Hamiltonian cycle in a weighted graph with the minimum total weight</p>
5,603
<pre><code>#include &lt;iostream&gt; using namespace std; int main() { double u = 0; double w = -u; cout &lt;&lt; w &lt;&lt; endl; return 0; } </code></pre> <p>Why does this great piece of code output <code>-0</code> and not <code>0</code>, as one would expect?</p>
<p>The IEEE 754 standard for floating-point numbers has the sign bit separate from the mantissa, which allows for zero to be negative. <a href="http://en.wikipedia.org/wiki/IEEE_754" rel="nofollow noreferrer">Wikipedia</a> should be able to help explain this.</p>
<p>Because "negative zero" is a valid number!</p> <p><a href="http://en.wikipedia.org/wiki/%E2%88%920_(number)" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/%E2%88%920_(number)</a></p>
9,942
<p>How do you turn a Visual Studio build that you'd perform in the IDE into a script that you can run from the command line?</p>
<p>With VS2008 you can do this:</p> <pre><code>devenv solution.sln /build configuration </code></pre>
<p>A more simple way is to change VS 2015 Projects &amp; Solutions configuration: Go to the Tools tab -> Options -> Projects and Solutions -> Build and Run -> On Run, when projects are out of date (choose Always build). VOILA! </p> <p>Now your IDE will automatically build your project when you run (F5) it. Hope this helps, any feedback are welcome.</p>
4,421
<p>I just received my new Creality Ender 3. I was going through and checking/adjusting everything for alignment, and I noticed that when you &quot;auto home&quot; the print head, the nozzle stops off the front of the print bed by 5-10 mm.</p> <p>Is that normal?</p> <p>Is it perhaps by design to allow purging the nozzle without dumping on the bed?</p> <p>It doesn't appear that there is any way to adjust the Y stop switch without making modifications to it. It also didn't look like there was any easy way to move the bed either.</p>
<p>Yes, this is the &quot;intended&quot; behavior, as the home in relation to the physical limit position is not placed correctly about 7.5 mm into the bed in both X and Y.</p> <p>to correct this, please look at the <a href="https://3dprinting.stackexchange.com/questions/6399/recalibrating-home-position">Recalibrating Home-position</a> for the Ender3</p>
<p>It is intentional for the head to start slightly off the build plate. </p> <p>If it did start on the build plate you could crash the nozzle when the bed is not levelled. Note the level varies with temperature and build plate type. If you switch from PLA to ABS etc you should relevel the bed. </p> <p>Having just had the innaccurate z-end stop switch cause a deep gouge across my stock build plate, I strongly recommend getting an ABL (auto bed leveller). </p>
999
<p>Many times I have seen Visual Studio solutions which have multiple projects that share source files. These common source files are usually out in a common directory and in the solution explorer their icon shows up with a link arrow in the bottom left.</p> <p>However, any time I try to add a source file to the project that is outside of that project's main directory, it just automatically copies it into the directory so that I no longer have a shared copy.</p> <p>I found that I can get around this by manually opening the project file in a text editor and modifying the path to something like "../../../Common/Source.cs" but this is more of a hack then I would like.</p> <p>Is there a setting or something I can change that will allow me to do this from within the IDE?</p>
<p>Right click on a project, select <strong>Add->Existing Item->Add as link</strong> (press on small arrow on Add button)</p>
<p>Thanks @aku!</p> <p>I knew this could be done, but I didn't know how to do this from Visual Studio. It shows up as a shortcut to the file and the csproj file generates the resulting XML like this:</p> <pre><code>&lt;Compile Include="..\CommonAssemblyInfo.cs"&gt; &lt;Link&gt;CommonAssemblyInfo.cs&lt;/Link&gt; &lt;/Compile&gt; </code></pre> <p>I've seen this technique commonly used for common AssemblyInfo files to keep a consistent version.</p>
6,763
<p>I'm /relatively/ new to 3d printing (I'm getting pretty good prints from my Wanhao di3 plus, but haven't done any DIY kits or anything) and materials engineering is probably the furthest thing from my area of expertise so I thought I would pose this to more experienced makers:</p> <p>If I'm building a large scale printer (probably a similar size to substation33 - sub33D's 1200x1200 printer) that I'm only going to print in PLA and MAYBE ABS occasionally, can I substitute the heated bed for simply heating the entire enclosure? The idea would be to have a thermistor measuring the ambient air temp inside the enclosure with a heat gun or two to hear the entire enclosure as necessary. I want to do this to try and reduce the cost (significantly as far as I can tell) as it seems 400*400 silicone heat pads tend to go for about 80 bucks a pop. An alternate idea I had was to use two or three heat pads and space them evenly under a glass bed, although I feel that this won't work as well because the heating won't be homogenous...</p> <p>Any input is appreciated :)</p>
<p>With a well-insulated and well distributed (or perhaps well-mixed is a better term - even heating) enclosure you should have a veritable heated bed by dint of heating the enclosure (with the bed in it), unless the bed needs to be hotter than the enclosure. I think that would be bit more elaborate than "a couple of heat guns" and involve several fans to distribute and mix air continuously.</p> <p>But - heated enclosures are not a freebie - everything inside the heated enclosure needs to be happy running at the sort of temperatures the enclosure is running at, and that can be hard on some electronic parts, shortening their lifetimes at least. Likewise, your calibration needs to be done on the hot enclosure - mechanical parts (particularly on a large scale printer) will change size due to the temperature.</p> <p>Insulation will both reduce your running cost (the more heat you keep, the less you have to add) and help keep the temperatures even, by slowing the cooling at the edges of the enclosure.</p>
<p>If it is yours first DIY 3D printer try building smaller version first with just one silicone heat pad. 400^2 mm^2 is good enough.</p> <p>From my experience:</p> <ol> <li><p>I used 500W silicon heater with SSR (AC mains) and it heats as fast as hotend (on DC 12V).</p></li> <li><p>I also recommend tooling plate (CNC machined Aluminum plate), it is better for heat transmission (Al) and it is more flat (machined to +-50um).</p></li> <li><p>You might consider thermal insulation under the silicone heater and also some foil on build plate itself - to minimize thermal losses. Cork might be useful for bottom. For top I use blue foil (in which it was originally wrapped).</p></li> </ol> <p>Enclosure I think it is also necessary, combined with heater, but then you must also have tubes for cooling of printed part, motors, fridge on hot end, etc.</p> <p>Word of caution: You must realize that you will be probably using 1.0mm nozzle or even more, since on 1200x1200mm you will just wait for weeks for part to complete. For reference: I print on 340mm diameter (delta) with 0.3mm nozzle and works just fine. But if I use just 0.1mm instead of 0.2mm layers it takes more time, but at the end it looks fantastic. So in your case even layer height must be big to reduce printing time. So you can increase speed, but then there could emerge some artifacts on printed object and also consider heater on hot end, which might be lagging behind.</p> <p>There are a lot of problems when you go this big and all are not even closely to be considered solved, but if you have time..</p>
672
<p>If you want to use a queuing product for durable messaging under Windows, running .NET 2.0 and above, which alternatives to MSMQ exist today? I know of ActiveMQ (<a href="http://activemq.apache.org/" rel="noreferrer">http://activemq.apache.org/</a>), and I've seen references to WSMQ (pointing to <a href="http://wsmq.net" rel="noreferrer">http://wsmq.net</a>), but the site seems to be down.</p> <p>Are there any other alternatives?</p>
<p>I can't begin to say enough good things about Tibco EMS - an implementation of the Java JMS messaging spec. Tibco EMS has superb support for .NET clients - including Compact Framework .NET on WinCE. (They also have C client libraries too.)</p> <p>So if you're building a heterogeneous distributed application involving messaging code running on Windows, Unix (AIX/Solaris), Linux, or Mac OS X, then Tibco EMS is the ticket.</p> <p>Check out my article here:</p> <p><a href="http://www.javalobby.org/articles/distributed-jms/" rel="noreferrer">Using JMS For Distributed Software Development</a></p> <p>I used to work at Microsoft and did some implementation with MSMQ while there. But you know, Microsoft just concerns itself with Windows. They depended on 3rd parties to provide MSMQ clients to other platforms. My encounter with Tibco EMS was a much better experience. It was very evident that Tibco understood messaging much more so than Microsoft. And Tibco put the effort into supporting diverse client bindings themselves. That is why they eventually changed the product name from Tibco JMS to Tibco EMS (Enterprise Messaging Service).</p> <p>And I did build heterogeneous software systems around Tibco EMS. Rolled C# .NET Winform clients interacting with Java/JBoss middle-tier via Tibco EMS messaging. (And also have WinCE industrial embedded computers that use the Compact Framework .NET Tibco client.)</p> <p><a href="http://vossnet.org/jms-links.html" rel="noreferrer">Links To My JMS Writings</a></p>
<p>If high availability is important Amazon SQS is worth looking at. There's not much additional overhead if messages come from different physical locations. Cheap and scalable!</p>
5,833
<p>I'm about to start a project for a customer who wants CMS-like functionality. They want users to be able to log in, modify a profile, and a basic forum. They also wish to be able to submit things to a front page.</p> <p>Is there a framework or barebones CMS that I could expand on or tailor to my needs? I don't need anything as feature-rich or fancy as Drupal or Joomla. I would actually prefer a framework as opposed to a pre-packaged CMS.</p> <p>I am confident I could code all this from scratch, but would prefer not to, as something like a framework would significantly cut down on my time spent coding, and more on design and layout.</p> <p>Edit: I should have been more specific. I'm looking for a Content Management System that will be run on a Debian server. So no .net preferably.</p> <hr> <p>I think i may end up going with Drupal, and only adding modules that I need. Turbogears looks a bit daunting, and i'm still not quite sure what it does after it's 20 minute intro video...</p> <p>TinyCMS doesn't look like it's been touched since... 2000?!?</p>
<p><a href="http://tinycms.sourceforge.net/" rel="nofollow noreferrer">tinyCMS</a> is about as barebones as you can get. (<strong>edit</strong>: fixed link, I had gotten a little click happy and linked to the wrong thing)</p> <p>@modesty, I would definitely NOT use SharePoint, as it is anything <strong>but</strong> barebones. It is a fairly expensive product (especially when compared to the many free alternatives), and it has quite the learning curve to do anything interesting.</p>
<p>Might want to check out <a href="http://drupal.org/" rel="nofollow noreferrer">Drupal</a>. </p> <p>Here are the details of the <a href="http://drupal.org/node/176052" rel="nofollow noreferrer">technology stack</a> that it uses. </p> <p>I have never used it so I can't vouch for the quality etc but definitely worth a look.</p>
2,616
<p>Is there a rake task for backing up the data in your database? </p> <p>I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. </p>
<p>The below script is a simplified version taken from <a href="http://github.com/engineyard/eycap/tree/master" rel="nofollow noreferrer">eycap</a>, specifically from <a href="http://github.com/engineyard/eycap/tree/master/lib/eycap/recipes/database.rb" rel="nofollow noreferrer">this file</a>.</p> <pre><code>set :dbuser "user" set :dbhost "host" set :database "db" namespace :db do desc "Get the database password from user" task :get_password do set(:dbpass) do Capistrano::CLI.ui.ask "Enter mysql password: " end end task :backup_name, :only =&gt; { :primary =&gt; true } do now = Time.now run "mkdir -p #{shared_path}/db_backups" backup_time = [now.year,now.month,now.day,now.hour,now.min,now.sec].join('-') set :backup_file, "#{shared_path}/db_backups/#{database}-snapshot-#{backup_time}.sql" end desc "Dump database to backup file" task :dump, :roles =&gt; :db, :only =&gt; {:primary =&gt; true} do backup_name run "mysqldump --add-drop-table -u #{dbuser} -h #{dbhost} -p#{dbpass} #{database} | bzip2 -c &gt; #{backup_file}.bz2" end end </code></pre> <p>Edit: Yeah, I guess I missed the point that you were looking for a rake task and not a capistrano task, but I don't have a rake one on hand, sorry.</p>
<p>Make sure to add the "--routines" parameter to mysqldump if you have any stored procs in your database so it backs them up too.</p>
4,704
<p>When I downloaded Skype, I noticed that, in place of a normal "disk image" icon, there was a custom icon, and when I double clicked on the icon, the window used a colorful image as the background, prompting me to drag the skype icon into the applications folder.</p> <p>How can I do that with my applications?</p> <p>Thanks, Jason</p>
<p>Let me add to the other answers <a href="http://www.jwz.org/blog/2006/03/setting-view-options-on-dmg-files/" rel="nofollow noreferrer">jwz's howto</a> on setting view options on .dmg files. This is the simplest one that I got to work with no problems.</p> <p>Also, to change the icon from the default .dmg icon: </p> <ul> <li><p>In the Finder, open an inspector window (^I) for the file whose icon you want to use, click on the icon at the top (it will get a blue border) and copy it to the clipboard (^C). </p></li> <li><p>Then open another inspector for your .dmg, click on the icon and press ^V to paste </p></li> </ul> <p>(you can change the icon for any file like this).</p> <p>For this kind of thing, you can always look at open-source programs and see what they do to get a similar result. For example here are the relevant source files for building pretty dmg files in:</p> <ul> <li><a href="http://trac.adiumx.com/browser/trunk/Release" rel="nofollow noreferrer">Adium</a></li> <li><a href="https://develop.participatoryculture.org/trac/democracy/browser/trunk/tv/platform/osx" rel="nofollow noreferrer">Miro</a></li> </ul>
<p>If you’re interested in a commercial solution, there are a number of DMG designer apps available, including the following I gleaned from a <a href="http://www.macupdate.com/search.php?starget=google&amp;keywords=dmg" rel="nofollow noreferrer">MacUpdate search</a>:</p> <ul> <li><a href="http://freespace.virgin.net/jeremy.dronfield/skoobysoft/utilities/dmgp.html" rel="nofollow noreferrer">DMG Packager</a></li> <li><a href="http://sourcebits.com/dmg/" rel="nofollow noreferrer">DMG Architect</a></li> <li><a href="http://www.araelium.com/dmgcanvas/" rel="nofollow noreferrer">DMG Canvas</a></li> </ul>
8,686
<p>I am using <code>&lt;input type="file" id="fileUpload" runat="server"&gt;</code> to upload a file in an ASP.NET application. I would like to limit the file type of the upload (example: limit to .xls or .xlsx file extensions). </p> <p>Both JavaScript or server-side validation are OK (as long as the server side validation would take place before the files are being uploaded - there could be some very large files uploaded, so any validation needs to take place before the actual files are uploaded).</p>
<p>Seems like you are going to have limited options since you want the check to occur before the upload. I think the best you are going to get is to use javascript to validate the extension of the file. You could build a hash of valid extensions and then look to see if the extension of the file being uploaded existed in the hash.</p> <p>HTML:</p> <pre><code>&lt;input type="file" name="FILENAME" size="20" onchange="check_extension(this.value,"upload");"/&gt; &lt;input type="submit" id="upload" name="upload" value="Attach" disabled="disabled" /&gt; </code></pre> <p>Javascript:</p> <pre><code>var hash = { 'xls' : 1, 'xlsx' : 1, }; function check_extension(filename,submitId) { var re = /\..+$/; var ext = filename.match(re); var submitEl = document.getElementById(submitId); if (hash[ext]) { submitEl.disabled = false; return true; } else { alert("Invalid filename, please select another file"); submitEl.disabled = true; return false; } } </code></pre>
<p>Your only option seems to be client-side validation, because server side means the file was already uploaded. Also the MIME type is usually dictated by the file extension. </p> <p>use a JavaScript Framework like jQuery to overload the onsubmit event of the form. Then check the extension. This will limit most attempts. However if a person changes an image to extension XLS then you will have a problem.</p> <p>I don't know if this is an option for you, but you have more client side control when using something like Silverlight or Flash to upload. You may consider using one of these technologies for your upload process.</p>
9,749
<p>I'm having a problem running a T4 template using TextTransform.exe on my build server. On my dev machine the template works perfectly. The error message is as follows.</p> <blockquote> <p>error : Running transformation: System.TypeLoadException: Could not instantiate type System.Xml.Linq.XDocument</p> </blockquote> <p>The build server has the windows 2008 SDK on it, my machine has VS 2008. I thought mayve it couldn't find System.Data.Xml so I ensure the dll was present in the same directory, but no luck. Any ideas?</p>
<p>Some syntax sugar</p> <pre><code>1 in [1,2,3] </code></pre>
<p>You can also use matches with regular expression like this:</p> <pre><code>boolean bool = List.matches(&quot;(?i).*SOME STRING HERE.*&quot;) </code></pre>
7,515
<p>What techniques can be applied to detect <a href="http://en.wikipedia.org/wiki/Computer_virus#Polymorphic_code" rel="nofollow noreferrer">Polymorphic</a> and <a href="http://en.wikipedia.org/wiki/Computer_virus#Metamorphic_code" rel="nofollow noreferrer">Metamorphic</a> viruses?</p> <p>How difficult is to implement these techniques? </p> <p>Are these techniques being applied in modern day anti-virus softwares?</p>
<p>I thought most of the virus scanners nowadays use <a href="http://www.norman.com/Virus/Sandbox/20374/en" rel="nofollow noreferrer"><em>sandbox techniques</em></a> to check for "bad" behavior. Therefore the polymorphic virusses will also be detected.<br> of course these detection techniques are also known to virus creators, and can easily be bypassed using a bunch of random, unharmfull, code executions before the actual payload.</p>
<p>It's impossiable to detect all known poly/metamorphic bad-code. White lists verification is the only provable technique. It's not always possiable, especially if your infrastructure/computer has not been maintainedd very well. Which is a good reason why signature, heuristic, emulation based detection is still valuable.</p>
5,637
<p>Is there any efficiency difference in an explicit vs implicit inner join? For example:</p> <pre><code>SELECT * FROM table a INNER JOIN table b ON a.id = b.id; </code></pre> <p>vs.</p> <pre><code>SELECT a.*, b.* FROM table a, table b WHERE a.id = b.id; </code></pre>
<p>Performance wise, they are exactly the same (at least in SQL Server).</p> <p>PS: Be aware that the <code>IMPLICIT OUTER JOIN</code> syntax is deprecated since SQL Server 2005. (The <code>IMPLICIT INNER JOIN</code> syntax as used in the question is still supported)</p> <p><a href="https://learn.microsoft.com/en-us/archive/blogs/wardpond/deprecation-of-old-style-join-syntax-only-a-partial-thing" rel="noreferrer">Deprecation of "Old Style" JOIN Syntax: Only A Partial Thing</a></p>
<p>In my experience, using the cross-join-with-a-where-clause syntax often produces a brain damaged execution plan, especially if you are using a Microsoft SQL product. The way that SQL Server attempts to estimate table row counts, for instance, is savagely horrible. Using the inner join syntax gives you some control over how the query is executed. So from a practical point of view, given the atavistic nature of current database technology, you have to go with the inner join.</p>
6,670
<p>I got a new MKS 1.4 controller board and it came with A4988 driver chips. But I can't figure out which way they install. I found something saying to match the printing on the back of the chip to that on the board. But I don't see anything that matches. Suggestions?</p> <p><a href="https://i.stack.imgur.com/dQers.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dQers.jpg" alt="Rear of A4988 breakout board"></a></p> <p><a href="https://i.stack.imgur.com/RdjAB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RdjAB.jpg" alt="Close up of MKS 1.4 A4988 socket"></a></p>
<p>From <a href="https://www.pololu.com/product/1182" rel="nofollow noreferrer">A4988 Stepper Motor Driver Carrier</a>, the rear of the breakout board, is identical to yours:</p> <p><a href="https://i.stack.imgur.com/8xpCF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8xpCF.jpg" alt="A4988 Breakout rear"></a></p> <p>Note the two square pads for the GND, whereas the others are round. Now looking at the top side:</p> <p><a href="https://i.stack.imgur.com/qUSdb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qUSdb.jpg" alt="A4988 Breakout top"></a></p> <p>and note the position of the <em>square</em> GND pins/pads, in relation to the trim pot.</p> <p>Now look at this hi-res photo of a populated MKS board</p> <p><a href="https://i.stack.imgur.com/FZaJZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FZaJZ.jpg" alt="MKS controller with A4988 drivers fitted"></a></p> <p>Again, looking at the position of the trim pots, one can see that the A4988 breakout boards need to be oriented such that the side with GND pins need to be nearest to the top of the board. That is to say the GND on the <em>corner</em> of the breakout board, needs to be pointing North East, as it were.</p> <p>Here is a schematic of the MKS 1.4 as well, although it is not much use, from <a href="http://forums.reprap.org/read.php?13,753796" rel="nofollow noreferrer">MKS Gen 1.4 circuit and pinouts</a>:</p> <p><a href="https://i.stack.imgur.com/2TyK6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2TyK6.jpg" alt="MKS-Gen-V1-4-3D-Printer-Control-Board-Motherboard-of-MEGA2560-RAMPS-1-4-With-USB"></a></p>
<p>The below image was taken from <a href="https://www.aliexpress.com/store/product/3D-printer-control-board-motherboard-MKS-Gen-V1-1-RepRap-Ramps1-4-compatible/1047297_2030818114.html" rel="nofollow noreferrer">their AliExpress shop page</a>.</p> <p>Unfortunately, I don't manage to find the datasheet or schematic to give more technical advice.</p> <p><a href="https://i.stack.imgur.com/Hs1AF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hs1AF.jpg" alt="enter image description here"></a></p>
496
<p>I've been wondering what exactly are the principles of how the two properties work. I know the second one is universal and basically doesn't deal with time zones, but can someone explain in detail how they work and which one should be used in what scenario?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.datetime.utcnow.aspx" rel="noreferrer">DateTime.UtcNow</a> tells you the date and time as it would be in Coordinated Universal Time, which is also called the Greenwich Mean Time time zone - basically like it would be if you were in London England, but not during the summer. <a href="http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx" rel="noreferrer">DateTime.Now</a> gives the date and time as it would appear to someone in your current locale. </p> <p>I'd recommend using <code>DateTime.Now</code> whenever you're displaying a date to a human being - that way they're comfortable with the value they see - it's something that they can easily compare to what they see on their watch or clock. Use <code>DateTime.UtcNow</code> when you want to store dates or use them for later calculations that way (in a client-server model) your calculations don't become confused by clients in different time zones from your server or from each other.</p>
<p>When you need a local time for the machine your application runs at (like CEST for Europe), use Now. If you want a universal time - UtcNow. It's just matter of your preferences - probably making a local website / standalone application you'd want to use the time user has - so affected by his/her timezone setting - DateTime.Now.</p> <p>Just remember, for a website it's the timezone setting of the server. So if you're displaying the time for the user, either get his prefered timezone and shift the time (just save Utc time to database then, and modify it) or specify it's UTC. If you forget to do so, user can see something like: <em>posted 3 minuses ago</em> and then a time in the future near it :)</p>
8,751
<p>I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL:</p> <p><a href="http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html" rel="noreferrer"><a href="http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html" rel="noreferrer">http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html</a></a></p> <p>Now I can transform an 8x8 section of a black and white image, such as:</p> <pre> 0140 0124 0124 0132 0130 0139 0102 0088 0140 0123 0126 0132 0134 0134 0088 0117 0143 0126 0126 0133 0134 0138 0081 0082 0148 0126 0128 0136 0137 0134 0079 0130 0147 0128 0126 0137 0138 0145 0132 0144 0147 0131 0123 0138 0137 0140 0145 0137 0142 0135 0122 0137 0140 0138 0143 0112 0140 0138 0125 0137 0140 0140 0148 0143 </pre> <p>Into this an image with all the important information at the top right. The transformed block looks like this:</p> <pre> 1041 0039 -023 0044 0027 0000 0021 -019 -050 0044 -029 0000 0009 -014 0032 -010 0000 0000 0000 0000 -018 0010 -017 0000 0014 -019 0010 0000 0000 0016 -012 0000 0010 -010 0000 0000 0000 0000 0000 0000 -016 0021 -014 0010 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 -010 0013 -014 0010 0000 0000 </pre> <p>Now, I need to know how can I take advantage of this transformation? I'd like to detect other 8x8 blocks in the same image ( or another image ) that represent a good match.</p> <p>Also, What does this transformation give me? Why is the information stored in the top right of the converted image important?</p>
<p>The result of a DCT is a transformation of the original source into the frequency domain. The top left entry stores the "amplitude" the "base" frequency and frequency increases both along the horizontal and vertical axes. The outcome of the DCT is usually a collection of amplitudes at the more usual lower frequencies (the top left quadrant) and less entries at the higher frequencies. As lassevk mentioned, it is usual to just zero out these higher frequencies as they typically constitute very minor parts of the source. However, this does result in loss of information. To complete the compression it is usual to use a lossless compression over the DCT'd source. This is where the compression comes in as all those runs of zeros get packed down to almost nothing.</p> <p>One possible advantage of using the DCT to find similar regions is that you can do a first pass match on low frequency values (top-left corner). This reduces the number of values you need to match against. If you find matches of low frequency values, you can increase into comparing the higher frequencies.</p> <p>Hope this helps</p>
<p>If I remember correctly, this matrix allows you to save the data to a file with compression.</p> <p>If you read further down, you'll find the zig-zag pattern of data to read from that final matrix. The most important data are in the top left corner, and least important in the bottom right corner. As such, if you stop writing at some point and just consider the rest as 0's, even though they aren't, you'll get a lossy approximation of the image.</p> <p>The number of values you throw away increases compression at the cost of image fidelity.</p> <p>But I'm sure someone else can give you a better explanation.</p>
2,657
<p>I am recently in charge of an older app written in <code>C#</code> using <code>asp.net 1.1</code>. </p> <ol> <li>Are there any resources to guide me in converting the application to a newer version of of the <code>.NET Framework</code>. <em>My main pause is that there are ton's of customized <code>DataGrids</code> in the app as it is written now and since so much of the code needs to be rewritten to use <code>GridViews</code></em> ...</li> <li>is it worth trying to convert the grids in the application to use <code>Silverlight</code> in the attempt to move this code into the future.</li> </ol>
<p>I had a similar experience, and the only thing that we had to replace was a third-party control that we were using in the 1.1 app, and the vendor had gone out of business an never released a version that worked with .NET 2.0. We ended up replacing it fairly easily with an AJAX Control Toolkit control.</p> <p>Other than that, the compiler does a pretty good job of telling you what to do with respect to deprecated method calls.</p> <p>I'd suggest making a copy of the code and upgrading the site in Visual Studio and see what happens. Just open the solution in Visual Studio 2005 or 2008, the IDE will walk you through the upgrade automatically. Get it to compile, then if you have any documented tests you should run through them. If not, you'll want to plan testing to make sure all your functionality still works like it did before the upgrade.</p> <p>Migrating to Silverlight sounds like fun, but if you can get it upgraded and working, I'd probably push that off until a later release -- my experience tells me that you might get into trouble if you bite off too much at once if there is no show-stopping technical reason.</p>
<p>Regarding DataGrids - I don't think you have too much to worry about, DataGrids still work in current versions. It's just that going forward, you should use GridViews.</p> <p>I am sure there are other things you may want to check into though, deeper framework issues. But I don't know enough about those things to speak to that particular point.</p>
6,449
<p>I got an Anet A8 and want to build an enclosure for it. Since I'm currently only printing PLA, I would do it mainly for noise cancelling, because I have to run it in my room. I however want to have the possibility to upgrade it later with, say, an air filter etc., for example for ABS.</p> <ul> <li>What do I have to pay attention to? </li> <li>Do I need ventilation slits? </li> <li>Would you put the filament inside or run it through a small hole from the top? </li> <li>Any tips for making it especially noise cancelling? </li> <li>Is wood the right material?</li> </ul>
<p>Sort of related, see the answers to:</p> <ul> <li><a href="https://3dprinting.stackexchange.com/questions/3771/commercially-available-3d-printer-fume-and-ufp-extractor">Commercially available 3D printer fume and UFP extractor</a>, and;</li> <li><a href="https://3dprinting.stackexchange.com/questions/513/what-are-the-best-air-filtration-options-for-enclosures">What are the best air filtration options for enclosures?</a></li> </ul> <p>Addressing your points in turn:</p> <ul> <li><strong>Ventilation</strong> - Probably not, as you want to keep the print warm. However, when printing with filaments where well ventilated conditions are recommended<sup>1</sup>, to prevent the build up of noxious fumes, from ABS for example, you would need (active) filtration, see <a href="https://3dprinting.stackexchange.com/questions/3771/commercially-available-3d-printer-fume-and-ufp-extractor/4125#4125">this answer</a>.</li> <li><strong>Filament Placement</strong> - I have seen printers fully enclosed, including the filament. However, there is the potential issue, especially if using PLA, that if the temperature inside the enclosure reaches temperatures approaching those of a closed car, on a hot day, then the PLA filament could become damaged/melt, and not roll of the spool correctly. In that case, you could place the reel on to of the enclosure and feed it through a (small) hole in the top. Feeding it through the side, <em>could</em> add additional resistance to it being pulled from the reel, depending upon placement.</li> <li><strong>Noise cancellation</strong> - Line the enclosure with <em>non-flammable</em> foam, or some other <em>non-flammable</em> noise cancelling lining</li> <li><strong>Material</strong> - As Mark states in <a href="https://3dprinting.stackexchange.com/questions/4220/enclosure-things-to-pay-attention-to#answer-4222">his answer</a>, be extra careful of thermal runaway, as 3D printers run hot, and an enclosed printer, even hotter. Wood is the sort of material you probably <em>want to avoid</em>. Whilst it is cheap, and would probably work fine in most situations, in the case of an emergency (read, <em>fire</em>), then you are merely providing additional combustable material. It would be advisable to stick with an aluminium frame (non-combustable) and glass (non-combustable and insulating).</li> </ul> <p>Additonal Points:</p> <ul> <li><strong>Electronics</strong> - You may want to consider placing the electronics (i.e. controller board) outside the enclosure, as the RAMPS board generally likes to be kept as cool as possible (especially the stepper drivers).</li> <li><strong>Display/Control</strong> - Along with the electronics, it could be a good idea to also place the LCD display, and conjoint control panel, outside the enclosure, so as to provide ease of access. You don't really want to have to keep removing/opening the enclosure to change a minor setting.</li> <li><strong>Access</strong> - Do you want a <em>lift-off</em> type enclosure, or have an access door? The latter is certainly more user friendly, or convenient.</li> <li><strong>Sturdiness</strong> - Do you want a light weight (flimsy?) enclosure, or a heavier, more robust, enclosure?</li> <li><strong>Safety</strong> - An air-tight fire box could be worth considering.</li> </ul> <p>Note: After having stated that wood is not the best idea, it seems that IKEA tables are sometimes used, by stacking two on top of each other: <a href="http://www.3ders.org/articles/20150726-new-ikea-hack-lets-you-create-a-3d-printer-enclosure-for-cheap.html" rel="nofollow noreferrer">New IKEA hack lets you create a 3D printer enclosure for cheap</a></p> <p><a href="https://i.stack.imgur.com/WYd4q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WYd4q.png" alt="IKEA table"></a></p> <p><a href="https://i.stack.imgur.com/lBkWI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lBkWI.jpg" alt="Enclosed Prusa i3 printer"></a></p> <p>A safer bet is this delta printer enclosure, which is, essentially, a larger delta frame, made from aluminium extrusion and acrylic, enclosing a smaller delta printer: <a href="https://pinshape.com/blog/build-your-own-3d-printer-enclosure/" rel="nofollow noreferrer">4 Simple Steps to Build Your Own 3D Printer Enclosure</a></p> <p><a href="https://i.stack.imgur.com/0g4gg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0g4gg.jpg" alt="Enclosed delta printer"></a></p> <p>For an example of a cheap, yet extremely flammable enclosure, made from plastic sheeting and piping, see <a href="https://www.matterhackers.com/news/how-to-build-a-3d-printer-enclosure" rel="nofollow noreferrer">How to build an enclosure for your 3D printer</a></p> <p><a href="https://i.stack.imgur.com/o87Je.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o87Je.png" alt="Plastic printer enclosure"></a></p> <hr> <p><sup>1</sup> See Davo's <a href="https://3dprinting.stackexchange.com/questions/4220/enclosure-things-to-pay-attention-to/4223#comment5920_4221">comment</a>.</p>
<p>For ABS, if you are using an air filter, you do NOT want ventilation, because ABS prints are better quality if the ambient temperature is up at 50°C (or even warmer), and ventilation will reduce your chamber temperature. Whatever has been helping for noise cancelling now should work in the future.</p>
622
<p>FCKeditor has InsertHtml API (<a href="http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/JavaScript_API" rel="nofollow noreferrer">JavaScript API document</a>) that inserts HTML in the current cursor position. How do I insert at the very end of the document?</p> <p>Do I need to start browser sniffing with something like this</p> <pre><code>if ( element.insertAdjacentHTML ) // IE element.insertAdjacentHTML( 'beforeBegin', html ) ; else // Gecko { var oRange = document.createRange() ; oRange.setStartBefore( element ) ; var oFragment = oRange.createContextualFragment( html ); element.parentNode.insertBefore( oFragment, element ) ; } </code></pre> <p>or is there a blessed way that I missed?</p> <p>Edit: Of course, I can rewrite the whole HTML, as answers suggest, but I cannot believe that is the "blessed" way. That means that the browser should destroy whatever it has and re-parse the document from scratch. That cannot be good. For example, I expect that to break the undo stack.</p>
<p>It looks like you could use a combination of GetHTML and SetHTML to get the current contents, append your html and reinsert everything into the editor. Although it does say </p> <blockquote> <p>Note that when using this method, you will lose any listener that you may have previously registered on the editor.EditorDocument.</p> </blockquote> <p>Hope that helps!</p>
<pre><code>var oEditor = FCKeditorAPI.GetInstance('Editor_instance') ; OldText=oEditor.GetXHTML( true ); oEditor.SetData( OldText+"Your text"); </code></pre>
4,487
<p>When using Linq to SQL and stored procedures, the class generated to describe the proc's result set uses char properties to represent char(1) columns in the SQL proc. I'd rather these be strings - is there any easy way to make this happen?</p>
<p>You could modify the {database}.designer.cs file. I don't have one handy to check, but I believe it's fairly straight forward --- you'll just have to plow through a lot of code, and remember to re-apply the change if you ever regenerate it.</p> <p>Alternately, you could create your own class and handle it in the select. For example, given the LINQ generated class:</p> <pre><code>class MyTable { int MyNum {get; set;} int YourNum {get; set;} char OneChar {get; set;} } </code></pre> <p>you could easily create: </p> <pre><code>class MyFixedTable { int MyNum {get; set;} int YourNum {get; set;} string OneChar {get; set;} public MyFixedTable(MyTable t) { this,MyNum = t.MyNum; this.YourNum = t.YourNum; this.OneChar = new string(t.OneChar, 1); } } </code></pre> <p>Then instead of writing:</p> <pre><code>var q = from t in db.MyTable select t; </code></pre> <p>write</p> <pre><code>var q = from t in db.MyTable select new MyFixTable(t); </code></pre>
<p>Not sure why you'd want to do that. The underlying data type can't store more than one char, by representing it as a string variable you introduce the need to check lengths before committing to the db, where as if you leave it as is you can just call ToString() on the char to get a string</p>
9,889
<p>Right now I am working on a solution to archive older data from a big working database to a separate archive database with the same schema. I move the data using SQL scripts and SQL Server Management Objects (SMO) from a .Net executable written in C#.</p> <p>The archived data should still be accessible and even (occassionally) changeable, we just want it out of the way to keep the working database lean and fast.</p> <p>Hurling large portions of data around and managing the relations between tables has proven to be quite a challenge.</p> <p>I wonder if there is a better way to archive data with SQL Server.</p> <p>Any ideas?</p>
<p>I think if you still want/need the data to be accessible, then partitioning some of your biggest or most-used tables could be an option.</p>
<p>We are in a similar situation. For regulatory reasons we cannot delete data for a set period of time, but many of our tables grow very large and unwieldy and realistically much of the data that is older than a month can be removed with few day-to-day problems. </p> <p>We currently programatically prune the tables, using a custom .NET/shell combination app using BCP to backup files which can be zipped and left on an out of the way network share. This isn't particularly accessible, but it is more space efficient. (It is complicated by our needing to keep certain historic dates, rather than being able to truncate at a certain size or with key fields in certain ranges.) </p> <p>We are looking into alternatives but, I think surprisingly, there's not much in the way of best-practice on this discussion! </p>
5,185
<p>I'm using NHibernate on a project and I need to do data auditing. I found <a href="http://www.codeproject.com/KB/cs/NHibernate_IInterceptor.aspx" rel="nofollow noreferrer">this article</a> on codeproject which discusses the IInterceptor interface.</p> <p>What is your preferred way of auditing data? Do you use database triggers? Do you use something similar to what's dicussed in the article?</p>
<p>For NHibernate 2.0, you should also look at <a href="http://knol.google.com/k/fabio-maulo/nhibernate-chapter-11/1nr4enxv3dpeq/14#view" rel="noreferrer">Event Listeners</a>. These are the evolution of the IInterceptor interface and we use them successfully for auditing.</p>
<p>I prefer the CodeProject approach you mentioned.</p> <p>One problem with database triggers is that it leaves you no choice but to use Integrated Security coupled with ActiveDirectory as access to your SQL Server. The reason for that is that your connection should inherit the identity of the user who triggered the connection; if your application uses a named "sa" account or other user accounts, the "user" field will only reflect "sa".</p> <p>This can be overriden by creating a named SQL Server account for each and every user of the application, but this will be impractical for non-intranet, public facing web applications, for example.</p>
3,671
<p>I have a database with two tables (<code>Table1</code> and <code>Table2</code>). They both have a common column <code>[ColumnA]</code> which is an <code>nvarchar</code>. </p> <p>How can I select this column from both tables and return it as a single column in my result set?</p> <p>So I'm looking for something like:</p> <pre><code>ColumnA in Table1: a b c ColumnA in Table2: d e f Result set should be: a b c d e f </code></pre>
<pre><code>SELECT ColumnA FROM Table1 UNION Select ColumnB FROM Table2 ORDER BY 1 </code></pre> <p>Also, if you know the contents of Table1 and Table2 will <strong>NEVER</strong> overlap, you can use UNION ALL in place of UNION instead. Saves a little bit of resources that way.</p> <p>-- Kevin Fairchild</p>
<p>You can use a union select: </p> <pre><code>Select columnA from table1 union select columnA from table2 </code></pre>
6,588
<p>I have an <a href="https://smile.amazon.com/gp/product/B01GD8LCFO/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&amp;psc=1" rel="nofollow noreferrer">all-metal V6 hotend clone</a> that has worked in the past, but recently will clog very easily.</p> <p>I've tried the following to address it:</p> <ul> <li>Clean/replace the nozzle (0.4 or 0.5 mm, nozzle is hot-tightened)</li> <li>Ensure nozzle is tightened against the heat-break tube, not the heater block</li> <li>Adjust nozzle temperature higher/lower (190 °C to 230°C)</li> <li>Recalibrate extruder steps/mm</li> <li>Improve cold-end cooling with a 40mm fan (also, a 40 mm blower directly aimed at the fins did not help)</li> <li>Try different filaments, from different brands (all 1.75 mm PLA)</li> <li>Adjust slicer settings (speed, line width, layer thickness is usually ~0.2 mm) and even tried different slicers</li> <li>Reduce/eliminate retractions</li> <li>Replaced stock Ender 5 Bowden extruder with dual-gear setup for higher grip</li> <li>Replaced the thermistor (wire was getting worn from disassembling/reassembling)</li> </ul> <p>Some things I've noticed:</p> <ul> <li>Prints tend to work fine for a while (~30 min to 1 hour or so), then the extruder is suddenly unable to push filament through the Bowden tube and begins to grind/click. There is very little to no period of reduced flow. It simply stops flowing completely.</li> <li>I am unable to push the filament through by hand to clear the clog, but pulling the filament out and trimming the end works</li> <li>The very end of the filament is the only place with any signs of being molten, well within the nozzle length itself</li> <li>Pushing and pulling the filament in the hot-end by hand works for very small retractions, but can instantly result in a clog if pulled too far back (a few mm)</li> <li>So far I have not seen particles / black buildup / other gunk that would explain the clogs</li> <li>Letting the filament sit in the hot-end for a few seconds is enough to make it much harder to extrude by hand until enough filament is pushed through to clear what's melted (sitting too long will make it clog), but there are still no signs of heat-creep beyond the nozzle length.</li> <li>I can always easily pull the filament out by hand after it jams (while still hot)</li> </ul> <p>Examples of what the filament end looked like when a clog formed:</p> <p><a href="https://i.stack.imgur.com/4g6yC.jpg" rel="nofollow noreferrer" title="Filament 1"><img src="https://i.stack.imgur.com/4g6yC.jpg" alt="filament1" title="Filament 1" /></a></p> <p><a href="https://i.stack.imgur.com/DXiBb.jpg" rel="nofollow noreferrer" title="Filament 4"><img src="https://i.stack.imgur.com/DXiBb.jpg" alt="filament4" title="Filament 4" /></a></p> <p>Since the melted material is so short I don't think it's heat-creep. Maybe it's the (very cheap) nozzles themselves having inconsistent dimensions? Not being able to retract a few mm and re-extrude by hand seems pretty odd. I have ordered official E3D nozzles to try in case they are the culprit.</p> <p>Any thoughts on what else it could be?</p> <p><strong>Edit</strong>: I had commented with the new nozzle being a solution, but unfortunately I spoke too soon. Using the E3D nozzle helped for prints that maintain a high enough flow-rate, but when printing small parts and/or multiple parts it seems that the flow rate becomes low enough to overheat the filament and clog (even with reduced print temp to 190 °C).</p> <p><strong>Update</strong>: While using the new nozzle and improving cold-end cooling with a blower aimed directly at the cold-end fins did help delay the clogging a little, it did not prevent it. It seems unrealistic to say that this is traditional heat-creep since the fins were cold to the touch and the length of deformed, clogged filament is even shorter than before (&lt;5 mm).</p>
<p>Since I have been unable to find a way to fix the E3D V6 clone hotend I have instead replaced it with a Creality Mk 8 that I had on-hand, which has so far worked flawlessly.</p> <p>I am assuming that the improved performance is related to the use of a shorter nozzle and/or the Bowden tube butting directly against the nozzle instead of interfacing with an all-metal heat-break. Those seem to be the biggest differences between the two designs.</p>
<p>I had issues with my all metal hot-end where I got heat creep. I ended up doing e-steps, PID tune, and ensuring my speed wasn't too slow either. Is your printer in an enclosure? I found that mine being in an enclosure caused the hotend to not cool sufficiently, so I had to lower the hot bed temp by 10 degrees and that seems to have resolved my issue for heat creep. I also have the Hero Me fan housing which improves airflow.</p>
2,169
<p>I'm not sure if it's my system, although I haven't done anything unusual with it, but I've started noticing incorrectly rendered characters popping up in web pages, text-files, <a href="http://ejohn.org/blog/html5-doctype/" rel="nofollow noreferrer">like this</a>:</p> <p><a href="http://www.kbssource.com/strange-characters.gif" rel="nofollow noreferrer">http://www.kbssource.com/strange-characters.gif</a></p> <p>I have a hunch it's a related to the fairly recent trend to use unicode for everything, which is a good thing I think, combined with fonts that don't support all possible characters.</p> <p>So, does anyone know what's causing these blips (am I right?), and how do I stop this showing up in my own content?</p>
<p>It appears that for this particular author, the text was edited in some editor that assumed it wasn't UTF8, and then re-wrote it out in UTF8. I'm basing this off the fact that if I tell my browser to interpret the page as different common encodings, none make it display correctly. This tells me that some conversion was done at some point improperly.</p> <p>The only problem with UTF8 is that there isn't a standardized way to recognize that a file is UTF8, and until all editors are standardizing on UTF8, there will still be conversion errors. For other unicode variants, a Byte Order Mark (BOM) is fairly standard to help identify a file, but BOMs in UTF8 files are pretty rare.</p> <p>To keep it from showing up in your content, make sure you're always using unicode-aware editors, and make sure that you always open your files with the proper encodings. It's a pain, unfortunately, and errors will occasionally crop up. The key is just catching them early so that you can undo it or make a few edits.</p>
<p>I'm fairly positive it's nothing you can do. I've seen this on the front page of digg alot recently. It more than likely has to do with a character being encoded improperly. Not necessarily a factor of the font, just a mistake made somewhere in translation.</p>
2,754
<p>I have a record set that includes a date field, and want to determine how many unique dates are represented in the record set.</p> <p>Something like:</p> <pre><code>Record.find(:all).date.unique.count </code></pre> <p>but of course, that doesn't seem to work.</p>
<p>What you're going for is the following SQL:</p> <pre><code>SELECT COUNT(DISTINCT date) FROM records </code></pre> <p>ActiveRecord has this built in:</p> <pre><code>Record.count('date', :distinct =&gt; true) </code></pre>
<p>Also, make sure you have an index on the field in your db, or else that query will quickly become sloooow.</p> <p>(It's much better to do this in SQL, otherwise you pull the entire db table into memory just to answer the count.)</p>
5,722
<p>Drawing a parallelgram is nicely supported with Graphics.DrawImage:</p> <pre><code>Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height); using (Graphics gr = new Graphics.FromImage(destImage)) { Point[] destPts = new Point[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x4, y4)}; gr.DrawImage(srcImage, destPts); </code></pre> <p>How, do you do 4 points (obviously the following is not supported, but this is what is wanted):</p> <pre><code>Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height); using (Graphics gr = new Graphics.FromImage(destImage)) { Point[] destPts = new Point[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)}; gr.DrawImage(srcImage, destPts); } </code></pre>
<p>Normally you would do this with a 3x3 Matrix, but the Matrix class only lets you specify 6 values instead of 9. You might be able to do this in Direct X.</p>
<p>Closest I can find is <a href="http://vckicks.110mb.com/image-distortion.html" rel="nofollow noreferrer">this information</a>, which is extremely laggy.</p>
5,922
<p>If I have a </p> <pre><code>&lt;input id="uploadFile" type="file" /&gt; </code></pre> <p>tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user.</p> <p>In FF, I just do:</p> <pre><code>var selected = document.getElementById("uploadBox").files.length &gt; 0; </code></pre> <p>But that doesn't work in IE.</p>
<p>This works in IE (and FF, I believe):</p> <pre><code>if(document.getElementById("uploadBox").value != "") { // you have a file } </code></pre>
<p>The accepted answer is correct to check with &quot;ID&quot;</p> <p>But, those who are here to check file with <strong>class-name</strong>,</p> <p>here is the code:</p> <pre><code>var elements = document.getElementsByClassName('uploadFile_ClassName'); for (var i = 0; i &lt; elements.length; ++i) { if(elements[i].value != &quot;&quot;) { // file is selected here; } } </code></pre>
6,827
<blockquote> <p>This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, <strong>so please do not use it as evidence that you can ask similar questions here.</strong></p> <p>More info: <a href="https://stackoverflow.com/faq">https://stackoverflow.com/faq</a></p> </blockquote> <hr> <p>There are always features that would be useful in fringe scenarios, but for that very reason most people don't know them. I am asking for features that are not typically taught by the text books.</p> <p>What are the ones that you know?</p>
<p>If you place a file named <strong><em>app_offline.htm</em></strong> in the root of a web application directory, ASP.NET 2.0+ will shut-down the application and stop normal processing any new incoming requests for that application, showing only the contents of the app_offline.htm file <em>for all new requests</em>.</p> <p>This is the quickest and easiest way to display your "Site Temporarily Unavailable" notice while re-deploying (or rolling back) changes to a Production server.</p> <p>Also, as pointed out by <a href="https://stackoverflow.com/users/1659/marxidad">marxidad</a>, make sure you have at least 512 bytes of content within the file so IE6 will render it correctly.</p>
<p>This seems like a huge, vague question... But I will throw in Reflection, as it has allowed me to do some incredibly powerful things like pluggable DALs and such.</p>
7,859
<p>I know this site is written using ASP.Net MVC and I do not see "/Home" in the url. This proves to me that it can be done. What special route and do I need?</p>
<p>Just change "Home" to an empty string.</p> <pre><code>routes.MapRoute( "Home", "", new { action = Index, controller = Home } ); </code></pre>
<p>In IIS 7, you can simply delete the Default.aspx file that comes with ASP.NET MVC (assuming you're running on Preview 3 or higher). That file was needed due to an issue with Cassini that was fixed in .NET 3.5 SP1.</p> <p>For more details check out:</p> <p><a href="http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx" rel="nofollow">Upcoming Changes In Routing</a> and <a href="http://haacked.com/archive/2008/05/12/sp1-beta-and-its-effect-on-mvc.aspx" rel="nofollow">.NET 3.5 SP1 Beta and Its Effect on MVC</a></p>
3,627
<p>What's the best framework for writing modules -- <a href="http://search.cpan.org/perldoc/ExtUtils::MakeMaker" rel="noreferrer">ExtUtils::MakeMaker</a> (h2xs) or <a href="http://search.cpan.org/perldoc/Module::Build" rel="noreferrer">Module::Build</a>?</p>
<p><strong>NOTE</strong> This advice is out of date. <a href="http://www.dagolden.com/index.php/2140/paying-respect-to-modulebuild/" rel="nofollow noreferrer">Module::Build has been removed from the Perl core</a> but lives on as a CPAN module. The pros and cons still stand, and my opinions about MakeMaker still stand.</p> <hr> <p>As the former maintainer of ExtUtils::MakeMaker, I like to recommend Module::Build because MakeMaker is a horror show. Module::Build is so much better put together. But those aren't your concerns and I'll present my "least hassle for you" answer.</p> <h2>Executive Summary:</h2> <p>Because Module::Build support is not 100% in place through all of Perl, start with MakeMaker. If you want to do any customization at all, switch to Module::Build. Since their basic layout, options and interface are almost identical this will be painless. As seductive as it looks, avoid Module::Install.</p> <p>Fortunately, Module::Build can emulate MakeMaker which helps some, but doesn't help if you're going to do any customization. See <a href="http://search.cpan.org/perldoc?Module::Build::Compat" rel="nofollow noreferrer">Module::Build::Compat</a>.</p> <p>For CPAN releases using Module::Build is fine. There's enough Module::Build stuff on CPAN now that everyone's dealt with getting it bootstrapped already.</p> <p>Finally, the new <a href="http://module-build.sourceforge.net/META-spec.html#configure_requires" rel="nofollow noreferrer"><code>configure_requires</code></a> option lets CPAN shells know to install Module::Build before they can start building the module. Unfortunately only the latest CPAN shells know about configure_requires.</p> <p>Oh, whatever you do don't use h2xs (unless you're writing XS code... and even then think about it).</p> <h2>MakeMaker Pros:</h2> <ul> <li>Comes with Perl and used by the Perl core (therefore it is actively maintained and will remain so forever)</li> <li>Everything knows what to do with a Makefile.PL.</li> <li>Most module authoring documentation will cover MakeMaker.</li> <li>Uses make (those who know make can debug and patch the build process)</li> </ul> <h2>MakeMaker Cons:</h2> <ul> <li>Requires make (think Windows)</li> <li>Difficult to customize</li> <li>Even harder to customize and make cross platform</li> <li>Difficult to debug when something goes wrong (unless you understand make)</li> </ul> <h2>Module::Build Pros:</h2> <ul> <li>Easier to customize/subclass</li> <li>Pure Perl</li> <li>Easier to debug (it's Perl)</li> <li>Can emulate MakeMaker in several ways</li> <li>The CPAN shell will install Module::Build for you</li> </ul> <h2>Module::Build Cons:</h2> <ul> <li>The Module::Build maintainers (and indeed all of the Perl Toolchain Gang) hate it </li> <li>Older versions of CPAN clients (including CPANPLUS) don't know anything about Module::Build.</li> </ul> <h2>Module::Install Pros:</h2> <ul> <li>Slick interface</li> <li>Bundles itself, you have a known version</li> <li>Everything knows how to deal with a Makefile.PL</li> </ul> <h2>Module::Install Cons:</h2> <ul> <li>Requires make</li> <li>Always uses bundled version, vulnerable to external breakage</li> <li>Difficult to customize outside its interface</li> <li>Mucks with the guts of MakeMaker so a new MakeMaker release will eventually break it.</li> <li>Does not know how to generate a META file using the v2 meta-spec (increasingly a problem with newer tools)</li> </ul>
<p>EU::MM still seems to be the most widely supported and popular one, but Module::Build is catching up. Also, check out <a href="http://search.cpan.org/dist/Module-Starter/" rel="nofollow noreferrer">Module::Starter</a> for a module that will help you get started.</p>
9,958
<p>My LCD rotates. The software that comes with my ATI card to rotate the desktop just crashes (<em>I've uninstalled, reinstalled and rolled them back, still crashes</em>). Is there any other way to rotate a Windows XP Desktop by 90 degree increments? I am looking for either software or code (any language is fine.) I know I have seen 3rd party support for this before, but I can't find it now.</p> <p>I realize this may not be a strictly software development related question, but it is programmer productivity related. If I can get an answer that involves how to write a program to do this, even better!</p>
<p>IRotate: <a href="http://www.entechtaiwan.net/util/irotate.shtm" rel="nofollow noreferrer">http://www.entechtaiwan.net/util/irotate.shtm</a>.<br> Have not used it but heard good things.</p> <p>Same people that make Powerstrip <a href="http://www.entechtaiwan.net/util/ps.shtm" rel="nofollow noreferrer">http://www.entechtaiwan.net/util/ps.shtm</a>.<br> Which gets rave reviews from the HTPC crowd. </p> <p>Was looking at these recently while researching stuff for an HTPC.<br> Both are try before buy shareware.</p>
<p>I hate to give you the answer you probably already know, but yeah this is a video card driver software thing and if the ATI software crashes then it's either corrupted or buggy or your Windows install has gone rotten.</p> <p>I've done this before on my NVidia-based cards without issue. I've never owned an ATI card.</p>
6,917
<p>Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches</p> <ol> <li><p>Use an integer and just don't bother assigning anything other than 0 or 1 to it.</p></li> <li><p>Use a char field with 'Y' or 'N' as the only two values.</p></li> <li><p>Use an enum with the CHECK constraint.</p></li> </ol> <p>Do experienced Oracle developers know which approach is preferred/canonical?</p>
<p>I found <a href="http://www.techrepublic.com/article/oracle-tip-choosing-an-efficient-design-for-boolean-column-values/" rel="noreferrer">this</a> link useful.</p> <p>Here is the paragraph highlighting some of the pros/cons of each approach.</p> <blockquote> <p>The most commonly seen design is to imitate the many Boolean-like flags that Oracle's data dictionary views use, selecting 'Y' for true and 'N' for false. However, to interact correctly with host environments, such as JDBC, OCCI, and other programming environments, it's better to select 0 for false and 1 for true so it can work correctly with the getBoolean and setBoolean functions.</p> </blockquote> <p>Basically they advocate method number 2, for efficiency's sake, using </p> <ul> <li><em>values</em> of 0/1 (because of interoperability with JDBC's <code>getBoolean()</code> etc.) with a check constraint</li> <li>a <em>type</em> of CHAR (because it uses less space than NUMBER). </li> </ul> <p>Their example:</p> <blockquote> <pre><code>create table tbool (bool char check (bool in (0,1)); insert into tbool values(0); insert into tbool values(1);` </code></pre> </blockquote>
<p>In our databases we use an enum that ensures we pass it either TRUE or FALSE. If you do it either of the first two ways it is too easy to either start adding new meaning to the integer without going through a proper design, or ending up with that char field having Y, y, N, n, T, t, F, f values and having to remember which section of code uses which table and which version of true it is using.</p>
4,991
<p>The <a href="http://en.wikipedia.org/wiki/ANSI_C" rel="noreferrer">Wikipedia article on ANSI C</a> says:</p> <blockquote> <p>One of the aims of the ANSI C standardization process was to produce a superset of K&amp;R C (the first published standard), incorporating many of the unofficial features subsequently introduced. However, the standards committee also included several new features, such as function prototypes (borrowed from the C++ programming language), and a more capable preprocessor. The syntax for parameter declarations was also changed to reflect the C++ style.</p> </blockquote> <p>That makes me think that there are differences. However, I didn't see a comparison between K&amp;R C and ANSI C. Is there such a document? If not, what are the major differences?</p> <p>EDIT: I believe the K&amp;R book says "ANSI C" on the cover. At least I believe the version that I have at home does. So perhaps there isn't a difference anymore?</p>
<p>There may be some confusion here about what "K&amp;R C" is. The term refers to the language as documented in the first edition of "The C Programming Language." Roughly speaking: the input language of the Bell Labs C compiler circa 1978.</p> <p>Kernighan and Ritchie were involved in the ANSI standardization process. The "ANSI C" dialect superceded "K&amp;R C" and subsequent editions of "The C Programming Language" adopt the ANSI conventions. "K&amp;R C" is a "dead language," except to the extent that some compilers still accept legacy code.</p>
<p>Despite all the claims to the contary K&amp;R was and is quite capable of providing any sort of stuff from low down close to the hardware on up. The problem now is to find a compiler (preferably free) that can give a clean compile on a couple of millions of lines of K&amp;R C without out having to mess with it.And running on something like a AMD multi core processor. </p> <p>As far as I can see, having looked at the source of the GCC 4.x.x series there is no simple hack to reactivate the -traditional and -cpp-traditional lag functionality to their previous working state without without more effor than I am prepered to put in. And simpler to build a K&amp;R pre-ansi compiler from scratch. </p>
4,253
<p>I am writing a few extensions to mimic the map and reduce functions in Lisp.</p> <pre><code>public delegate R ReduceFunction&lt;T,R&gt;(T t, R previous); public delegate void TransformFunction&lt;T&gt;(T t, params object[] args); public static R Reduce&lt;T,R&gt;(this List&lt;T&gt; list, ReduceFunction&lt;T,R&gt; r, R initial) { var aggregate = initial; foreach(var t in list) aggregate = r(t,aggregate); return aggregate; } public static void Transform&lt;T&gt;(this List&lt;T&gt; list, TransformFunction&lt;T&gt; f, params object [] args) { foreach(var t in list) f(t,args); } </code></pre> <p>The transform function will cut down on cruft like:</p> <pre><code>foreach(var t in list) if(conditions &amp;&amp; moreconditions) //do work etc </code></pre> <p>Does this make sense? Could it be better?</p>
<p>These look very similar to extensions in Linq already:</p> <pre><code>//takes a function that matches the Func&lt;T,R&gt; delegate listInstance.Aggregate( startingValue, (x, y) =&gt; /* aggregate two subsequent values */ ); //takes a function that matches the Action&lt;T&gt; delegate listInstance.ForEach( x =&gt; /* do something with x */); </code></pre> <p>Why is the 2nd example called Transform? Do you intend to change the values in the list somehow? If that's the case you may be better off using <code>ConvertAll&lt;T&gt;</code> or <code>Select&lt;T&gt;</code>.</p>
<p>You might want to add a way to do a map but return a new list, instead of working on the list passed in (and returning the list can prove useful to chain other operations)... perhaps an overloaded version with a boolean that indicates if you want to return a new list or not, as such:</p> <pre><code>public static List&lt;T&gt; Transform&lt;T&gt;(this List&lt;T&gt; list, TransformFunction&lt;T&gt; f, params object [] args) { return Transform(list, f, false, args); } public static List&lt;T&gt; Transform&lt;T&gt;(this List&lt;T&gt; list, TransformFunction&lt;T&gt; f, bool create, params object [] args) { // Add code to create if create is true (sorry, // too lazy to actually code this up) foreach(var t in list) f(t,args); return list; } </code></pre>
6,127
<p>We created several custom web parts for SharePoint 2007. They work fine. However whenever they are loaded, we get an error in the event log saying:</p> <blockquote> <p>error initializing safe control - Assembly: ...</p> </blockquote> <p>The assembly actually loads fine. Additionally, it is correctly listed in the <code>web.config</code> and <code>GAC</code>.</p> <p>Any ideas about how to stop these (Phantom?) errors would be appreciated. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>You need to add a safecontrol entry to the web,config file, have a look at the following:</p> <pre><code>&lt;SafeControls&gt; &lt;SafeControl Assembly = "Text" Namespace = "Text" Safe = "TRUE" | "FALSE" TypeName = "Text"/&gt; ... &lt;/SafeControls&gt; </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/ms413697.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms413697.aspx</a></p>
<p>This is because of the amount of list items in the lists. Your server takes to much time to migrate all the list items and it fails, try deleiting the list items or configuring the server.</p> <p>Regards, Mariano.</p>
4,546
<p>I'm currently working on a project that requires encrypted data be passed between WCF hosts. As I understand it there are only 2 ways to ensure that data passed over WCF is secure. </p> <ol> <li>Using Certificates</li> <li>Using a Domain (or having the same username and password on every machine on the network)</li> </ol> <p>Using certificates can be expensive and complicated to manage and since we're not guaranteed to have a server class machine at every deployment a Domain is also out of the question. Having every machine use the same username and password is also problematic if that password ever needs to be changed.</p> <p>Currently we use OpenSSH to tunnel our connections between hosts. Is there another option built into the framework that I'm unaware of?</p>
<p>Encryption requires a key. Keys are usually implemented as certificates. If you own both sides of the communication, you can create your own certificate for free without having to go buy one from a trusted root authority.</p>
<p>If you are using a http endpoint, you can use a secure transport such as https.</p>
7,345
<p>I wrote an application that currently runs against a local instance of MySql. I would like to centralize the DB somewhere on the Net, and share my application.</p> <p>But, I'm cheap, and don't want to pay for it. Does anyone know of a free on-line relational DB service that I could connect to via C#?</p>
<p>What about <a href="http://www.freesql.org" rel="nofollow noreferrer">http://www.freesql.org</a> ? Seems like you can't be too picky when you're asking for free, and this seems to offer something.</p>
<p>Sounds like you need <a href="http://www.amazon.com/SimpleDB-AWS-Service-Pricing/b?ie=UTF8&amp;node=342335011" rel="nofollow noreferrer">Amazon SimpleDB</a>...</p> <p>It's not free, but pricing looks pretty good. I've not used it myself, but when I've got a bit of spare time I might use it for a project I'm working on.</p>
3,037
<p>I'm running PHP, Apache, and Windows. I do not have a domain setup, so I would like my website's forms-based authentication to use the local user accounts database built in to Windows (I think it's called SAM).</p> <p>I know that if Active Directory is setup, you can use the PHP LDAP module to connect and authenticate in your script, but without AD there is no LDAP. What is the equivalent for standalone machines?</p>
<p>I haven't found a simple solution either. There are examples using CreateObject and the WinNT ADSI provider. But eventually they all bump into <a href="http://support.microsoft.com/kb/218497" rel="nofollow noreferrer"> User authentication issues with the Active Directory Service Interfaces WinNT provider</a>. I'm not 100% sure but I <i>guess</i> the WSH/network connect approach has the same problem.<br /> According to <a href="http://support.microsoft.com/kb/180548/" rel="nofollow noreferrer">How to validate user credentials on Microsoft operating systems</a> you should use LogonUser or SSPI. <br /> It also says<blockquote><pre>LogonUser Win32 API does not require TCB privilege in Microsoft Windows Server 2003, however, for downlevel compatibility, this is still the best approach.</p> <p>On Windows XP, it is no longer required that a process have the SE_TCB_NAME privilege in order to call LogonUser. Therefore, the simplest method to validate a user's credentials on Windows XP, is to call the LogonUser API.</pre></blockquote>Therefore, if I were certain Win9x/2000 support isn't needed, I would write an extension that exposes LogonUser to php.<br /> You might also be interested in <a href="http://www.codewalkers.com/c/a/User-Management-Code/User-Authentication-from-NT-Accounts/" rel="nofollow noreferrer">User Authentication from NT Accounts</a>. It uses the w32api extension, and needs a support dll ...I'd rather write that small LogonUser-extension ;-)<br /> If that's not feasible I'd probably look into the fastcgi module for IIS and how stable it is and let the IIS handle the authentication.</p> <p>edit:<br /> I've also tried to utilize <a href="http://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity.aspx" rel="nofollow noreferrer">System.Security.Principal.WindowsIdentity</a> and php's <a href="http://uk.php.net/manual/en/book.com.php" rel="nofollow noreferrer">com/.net extension</a>. But the dotnet constructor doesn't seem to allow passing parameters to the objects constructor and my "experiment" to get the assembly (and with it CreateInstance()) from GetType() has failed with an "unknown zval" error.</p>
<p>Good Question!</p> <p>I've given this some thought... and I can't think of a good solution. What I can think of is a horrible horrible hack that just might work. After seeing that no one has posted an answer to this question for nearly a day, I figured a bad, but working answer would be ok. </p> <p>The SAM file is off limits while the system is running. There are some DLL Injection tricks which you may be able to get working but in the end you'll just end up with password hashes and you'd have to hash the user provided passwords to match against them anyway.</p> <p>What you really want is something that tries to authenticate the user against the SAM file. I think you can do this by doing something like the following. </p> <ol> <li>Create a File Share on the server and make it so that only accounts that you want to be able to log in as are granted access to it.</li> <li>In PHP use the system command to invoke a wsh script that: mounts the share using the username and password that the website user provides. records if it works, and then unmounts the drive if it does. </li> <li>Collect the result somehow. The result can be returned to php either on the stdout of the script, or hopefully using the return code for the script.</li> </ol> <p>I know it's not pretty, but it should work.</p> <p>I feel dirty :|</p> <p>Edit: reason for invoking the external wsh script is that PHP doesn't allow you to use UNC paths (as far as I can remember).</p>
8,550
<p>E3D hotends use a thermistor whose legs are insulated with glass fiber sleeving and clamped down with a screw and washer:</p> <p><a href="https://i.stack.imgur.com/IAJDy.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/IAJDy.jpg" alt="enter image description here"></a></p> <p>This solution enables the printing of high temperature materials, but it's a bit fragile and after reassembling the hotend a couple of times, the screw will have thoroughly mangled the thermistor's legs and sleeving.</p> <p>Some knockoff E3D hotends use a (horrible) solution where the thermistor is just loose in its respective hole, and kapton taped to the heater cartridge wires which holds it in place:</p> <p><a href="https://i.stack.imgur.com/xMsxq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xMsxq.png" alt="enter image description here"></a></p> <p>This solution seems kind of ad-hoc, and I'm worried about the thermistor coming loose. One advantage is that it can be reassembled arbitrarily often, since just pulling out the heater cartridge also pulls out the thermistor without damaging it. Note that the picture shows PTFE sleeving which restricts the temperature, but you could easily use fibreglass in this situation as well.</p> <p>Another solution is the stud thermistor:</p> <p><a href="https://i.stack.imgur.com/ER2gr.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ER2gr.jpg" alt="enter image description here"></a></p> <p>It screws into the hole that is normally used for the clamping screw. Unfortunately you're limited to around 250C because of the epoxy used in the stud. I've also found that the epoxy fails after a while (regardless of temperature) and the thermistor isn't locked in place any more (it still works, by virtue of being constrained by the heater cartridge wires as in the previous solution but that's not ideal).</p> <p>Are there any solutions, compatible with genuine E3D hotends, that:</p> <ul> <li><p>are not limited in temperature by epoxy or PTFE,</p></li> <li><p>can withstand being disassembled and reassembled better than the standard fiberglass sleeving,</p></li> <li><p>is a bit less hokey than a kapton taping the thermistor's wires to the heater cartridge and hoping that holds it in place?</p></li> </ul>
<p>I like the mounting method on my Mk9 extruder: there's a small hole drilled into the heat block, parallel to the heater hole. B3 Innovations sells a thermistor packaged into a small spring. The whole assembly goes in the hole, and a setscrew (gently!) secures it. You could just as well put a bare thermistor into a spring or something similar; it's mainly to protect the thermistor from the setscrew, and from excessive bending.</p> <p>From your photo, it looks like the same thing would work fine for your hotend.</p> <p>However you mount it, adding some thermal grease can help conduction from the surroundings.</p>
<p>I have now purchased a hot-end block from <a href="https://www.3dprinterspares.eu/heat-block-upgrade-kit-for-prusa-i3--compatiable-3d-printers-73-p.asp" rel="nofollow noreferrer">here</a>, that has a "cartridge style" cylindrical thermistor that fits into a drilled hole of the hot-end block, and is fixed by an additional screw. This system makes maintenance much easier, the thermistor slides in and out without force, and it has a connector to change only thermistor (or unscrew hot-end block without removing cables if your hot-end also has a connector).</p> <p><a href="https://i.stack.imgur.com/2KcU4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2KcU4.jpg" alt="cyclindrical cartridge thermistor"></a> </p> <p>I highly recommend this upgrade, if you are using older-style hot-ends, because it makes maintenance much easier.</p>
149
<p>I have a Chiron from Anycubic and I have had some leveling issues in the last few weeks, however, I believe that I have sorted that. The layers attached to the base plate or the raft now come out very weird and I am uncertain why. I heard that this is caused by the extruder being too cold but I have turned up the temperature and nothing has changed. Could someone please help with this because I have a feeling this is the reason the prints are being warped slightly but enough to not fit together?</p> <p>I am very new to all this and I have no one to help me with this, if you could help I would be very grateful.</p> <p><a href="https://i.stack.imgur.com/ZfWri.jpg" rel="nofollow noreferrer" title="3D printed model with badly extruded layer"><img src="https://i.stack.imgur.com/ZfWri.jpg" alt="3D printed model with badly extruded layer" title="3D printed model with badly extruded layer" /></a></p> <p>My bed temperature is set to 70 °C and the speed is 50 mm/s. I manually leveled it afer the self leveling didn't work, the image shows the top layer of a very bad failed print that had the same settings as my other ones but this one specifically was worse. I use PLA and have the extruder set to a temp of 210 °C most of the time. I now have the base set to 80 °C due to when its lower, adhesion doesn't take place for some reason. There are no large overhangs on my models but it can comfortably do a 70ish degree angle with no major flaw. The extruder height is set to 2 mm due to some massive leveling issues I had before.</p>
<p>Not sure what the other answers are talking about. From the picture, your nozzle is just way too far from the bed and the extruded material is just barely making contact. Adjust it so that, when moved to position Z=0.2, there is exactly 0.2 mm between the nozzle tip and the bed. Then fine-tune with single-layer test prints.</p> <p>Having the nozzle way too far from the bed is probably why you've found a need to jack your bed temperature up so high. Don't do that! 80 °C bed is not usable at all for PLA; it will keep the first 5-10 mm of the print above its glass transition temperature permanently (for the duration of the print), precluding any hope of it holding a proper shape. 60 °C is the absolute max you should ever use for PLA, and even that's too high to avoid warping. If your nozzle distance is right and you're using a textured (e.g. Buildtak or generic clone) build surface, PLA should adhere to a <em>cold</em> bed (not heated at all). Without that you probably need 45-55 °C.</p>
<p>What software do you use? Your nozzle diameter seems to be selected incorrectly or you have a slightly enlarged nozzle. Buy an unused nozzle and make your bed adjustments again.</p> <p>Select correct a nozzle diameter (such as 0.4 mm, 0.6 mm) and slice your print again. For PLA, I suggest using 200-215 °C for better layer adhesion and using the fan to make prints look better.</p>
2,050
<p>How do you use network sockets in Pascal? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>Here's an example taken from <a href="http://www.bastisoft.de/programmierung/pascal/pasinet.html" rel="nofollow noreferrer">http://www.bastisoft.de/programmierung/pascal/pasinet.html</a></p> <pre><code>program daytime; { Simple client program } uses sockets, inetaux, myerror; const RemotePort : Word = 13; var Sock : LongInt; sAddr : TInetSockAddr; sin, sout : Text; Line : String; begin if ParamCount = 0 then GenError('Supply IP address as parameter.'); with sAddr do begin Family := af_inet; Port := htons(RemotePort); Addr := StrToAddr(ParamStr(1)); if Addr = 0 then GenError('Not a valid IP address.'); end; Sock := Socket(af_inet, sock_stream, 0); if Sock = -1 then SockError('Socket: '); if not Connect(Sock, sAddr, sizeof(sAddr)) then SockError('Connect: '); Sock2Text(Sock, sin, sout); Reset(sin); Rewrite(sout); while not eof(sin) do begin Readln(sin, Line); Writeln(Line); end; Close(sin); Close(sout); Shutdown(Sock, 2); end. </code></pre>
<p>If you are using Delphi, I highly recommend <a href="http://www.indyproject.org/index.en.aspx" rel="nofollow noreferrer">Indy</a> sockets, a set of classes for easy manipulation of sockets and many other internet protocols (HTTP, FTP, NTP, POP3 etc.)</p>
3,775
<p>Is there an easy way to set the zoom level for a windows form in C#? In VBA there was a zoom property of the form.</p>
<p>I had the same problem and I solved it this way in c#. Code goes on Form load</p> <pre><code>float scaleX = ((float)Screen.PrimaryScreen.WorkingArea.Width / 1024); float scaleY = ((float)Screen.PrimaryScreen.WorkingArea.Height / 768); SizeF aSf = new SizeF(scaleX, scaleY); this.Scale(aSf); </code></pre> <p>This "more or less" scales form and all children. Loops forever in 800x600 (?) You have to set the following Form properties:</p> <pre><code>AutoscaleMode = Font AutoSize = False </code></pre>
<p>There is no way (that I know of) to do what you ask with typical WinForms.</p> <p>If you're doing custom painting/drawing, you can zoom that by using a zoom transform, but so far as I know there is no "Zoom" property for the form in the entire world of .NET and native Windows/C++ APIs combined.</p> <p>You could probably rig something yourself such that you scale controls by a constant factor. And you can probably find 3rd-party controls/surfaces which support this. And who knows what is possible with WPF. But in a typical WinForms world, no.</p>
5,605
<p>How do you create your own custom moniker (or URL Protocol) on Windows systems?</p> <p>Examples:</p> <ul> <li>http:</li> <li>mailto:</li> <li>service:</li> </ul>
<p>Take a look at <a href="http://msdn.microsoft.com/en-us/library/aa741006(VS.85).aspx" rel="nofollow noreferrer">Creating and Using URL Monikers</a> , <a href="http://msdn.microsoft.com/en-us/library/aa767916(VS.85).aspx" rel="nofollow noreferrer">About Asynchronous Pluggable Protocols</a> and <a href="http://msdn.microsoft.com/en-us/library/aa767914.aspx" rel="nofollow noreferrer">Registering an Application to a URL Protocol</a> from MSDN</p>
<p><em>Inside OLE</em> from Craig Brockschmidt probably has the best coverage on monikers. If you want to dig a little deeper into this topic, I'd recommend getting this book. It is also contained on the MSDN disk that came along with VS 6.0, in case you still have that.</p>
2,665
<p>Questions #1 through #4 on the <a href="http://www.joelonsoftware.com/articles/fog0000000043.html" rel="nofollow noreferrer">Joel Test</a> in my opinion are all about the development tools being used and the support system in place for developers:</p> <ol> <li>Do you use source control? </li> <li>Can you make a build in one step? </li> <li>Do you make daily builds? </li> <li>Do you have a bug database? </li> </ol> <p>I'm just curious what free/cheap (but good) tools exist for the small development shops that don't have large bank accounts to use to achieve a positive answer on these questions.</p> <p>For source control I know Subversion is a great solution, and if you are a one man shop you could even use SourceGear's <a href="http://www.sourcegear.com/vault/index.html" rel="nofollow noreferrer">Vault</a>.</p> <p>I use NAnt for my larger projects, but have yet to set up a script to build my installers as well as running the obfusication tools all as a single step. Any other suggestions?</p> <p>If you can answer yes to the building in a single step, I think creating daily builds would be easy, but what tools would you recommend for automating those daily builds?</p> <p>For a one or two man team, it's already been discussed on SO that you can use FogBugz On Demand, but what other bug tracking solutions exist for small teams?</p>
<ol> <li>source control: <a href="http://subversion.tigris.org/" rel="nofollow noreferrer">Subversion</a> or <a href="http://www.selenic.com/mercurial/wiki/" rel="nofollow noreferrer">Mercurial</a> or <a href="http://git-scm.com/" rel="nofollow noreferrer">Git</a></li> <li>build automation: <a href="http://nant.sourceforge.net/" rel="nofollow noreferrer">NAnt</a>, <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="nofollow noreferrer">MSBuild</a>, <a href="http://rake.rubyforge.org/" rel="nofollow noreferrer">Rake</a>, <a href="http://maven.apache.org/" rel="nofollow noreferrer">Maven</a></li> <li>continuous integration: <a href="http://ccnet.thoughtworks.com/" rel="nofollow noreferrer">CruiseControl.NET</a> or <a href="http://continuum.apache.org/" rel="nofollow noreferrer">Continuum</a> or <a href="http://jenkins-ci.org/" rel="nofollow noreferrer">Jenkins</a></li> <li>issue tracking: <a href="http://trac.edgewall.org/" rel="nofollow noreferrer">Trac</a>, <a href="http://www.bugzilla.org/" rel="nofollow noreferrer">Bugzilla</a>, <a href="http://www.countersoft.com/" rel="nofollow noreferrer">Gemini</a> (if it must be .NET and free-ish)</li> </ol> <p>Don't forget automated testing with <a href="http://www.nunit.org/" rel="nofollow noreferrer">NUnit</a>, <a href="http://fit.c2.com/" rel="nofollow noreferrer">Fit</a>, and <a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">WatiN</a>.</p>
<p>A good issue tracker that was relatively inexpensive was <a href="http://axosoft.com/products/ontime.aspx" rel="nofollow noreferrer">axoSoft OnTime</a>. I used it for years before getting MS TFS.</p> <p><a href="http://nant.sourceforge.net/" rel="nofollow noreferrer">Nant</a> and <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET" rel="nofollow noreferrer">CruiseControl</a> are staples of my environment.</p>
3,579
<p>We have a client that has Oracle <em>Standard</em>, and a project that would be ten times easier addressed using OLAP. However, Oracle only supports OLAP in the <em>Enterprise</em> version.</p> <p>Migration to enterprise is <strong>not</strong> possible</p> <p>I'm thinking of doing some manual simulation of OLAP, creating relational tables to simulate the technology.</p> <p>Do you know of some other way I could do this? Maybe an open-source tool for OLAP? Any ideas?</p>
<p>You can simulate OLAP functionality using client side tools pointed at a relational database.</p> <p>Personally I think the best tool for the job is probably <a href="http://www.tableausoftware.com/" rel="noreferrer">Tableau Desktop</a>. This is an amazingly sophisticated front end analytics tool that will make your relational data look multidimensional without much effort, and the tool itself is really mind blowing. They have a free trial so you can take it for a spin. We use Tableau heavily for our own analysis and have been very impressed. Of course, this tool also works with multidimensional databases as well, so if you end up with some cubes at the end of the day you can continue to use the Tableau front end.</p> <p>As for open source, you could try out <a href="http://www.jedox.com/en/enterprise-spreadsheet-server/excel-olap-server/palo-server.html" rel="noreferrer">Palo</a> - an open source MOLAP server and Excel front end.</p> <p>If you are interesting in building your own reporting front end and use .NET there are a number of components (such as the <a href="http://demos.devexpress.com/ASPxPivotGridDemos/Default.aspx" rel="noreferrer">DevExpress PivotGrid</a> or the several tools from <a href="http://www.radar-soft.com/" rel="noreferrer">RadarSoft</a>) that will do the same thing, but will require some elbow grease to get wired together.</p>
<p>Whilst MS SQL Server offers OLAP, you'll need an Enterprise licence to use a cube in a live environment that is web-facing.</p>
6,398
<p>A question related to <a href="https://stackoverflow.com/questions/28002">Regular cast vs. static_cast vs. dynamic_cast</a>:</p> <p>What cast syntax style do you prefer in C++?</p> <ul> <li>C-style cast syntax: <code>(int)foo</code></li> <li>C++-style cast syntax: <code>static_cast&lt;int&gt;(foo)</code></li> <li>constructor syntax: <code>int(foo)</code></li> </ul> <p>They may not translate to exactly the same instructions (do they?) but their effect should be the same (right?).</p> <p>If you're just casting between the built-in numeric types, I find C++-style cast syntax too verbose. As a former Java coder I tend to use C-style cast syntax instead, but my local C++ guru insists on using constructor syntax.</p> <p>What do you think?</p>
<p>It's best practice <em>never</em> to use C-style casts for three main reasons:</p> <ul> <li>as already mentioned, no checking is performed here. The programmer simply cannot know which of the various casts is used which weakens strong typing</li> <li>the new casts are intentionally visually striking. Since casts often reveal a weakness in the code, it's argued that making casts visible in the code is a good thing.</li> <li>this is especially true if searching for casts with an automated tool. Finding C-style casts reliably is nearly impossible.</li> </ul> <p>As palm3D noted:</p> <blockquote> <p>I find C++-style cast syntax too verbose.</p> </blockquote> <p>This is intentional, for the reasons given above.</p> <p>The constructor syntax (official name: function-style cast) is semantically <em>the same</em> as the C-style cast and should be avoided as well (except for variable initializations on declaration), for the same reasons. It is debatable whether this should be true even for types that define custom constructors but in Effective C++, Meyers argues that even in those cases you should refrain from using them. To illustrate:</p> <pre><code>void f(auto_ptr&lt;int&gt; x); f(static_cast&lt;auto_ptr&lt;int&gt; &gt;(new int(5))); // GOOD f(auto_ptr&lt;int&gt;(new int(5)); // BAD </code></pre> <p>The <code>static_cast</code> here will actually call the <code>auto_ptr</code> constructor.</p>
<p>C-style cast syntax, do not error check. C++-style cast syntax, does some checking. When using static_cast, even if it doesn't do checking, at least you know you should be carefull here.</p>
5,210