instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>In <a href="http://en.wikipedia.org/wiki/PostgreSQL" rel="noreferrer">PostgreSQL</a>, I can do something like this:</p> <pre><code>ALTER SEQUENCE serial RESTART WITH 0; </code></pre> <p>Is there an Oracle equivalent?</p>
<p>Here is a good procedure for resetting any sequence to 0 from Oracle guru <a href="http://asktom.oracle.com" rel="noreferrer">Tom Kyte</a>. Great discussion on the pros and cons in the links below too.</p> <pre><code>tkyte@TKYTE901.US.ORACLE.COM&gt; create or replace procedure reset_seq( p_seq_name in varchar2 ) is l_val number; begin execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'alter sequence ' || p_seq_name || ' increment by -' || l_val || ' minvalue 0'; execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'alter sequence ' || p_seq_name || ' increment by 1 minvalue 0'; end; / </code></pre> <p>From this page: <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:951269671592" rel="noreferrer">Dynamic SQL to reset sequence value</a><br> Another good discussion is also here: <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1119633817597" rel="noreferrer">How to reset sequences?</a></p>
<p>Stored procedure that worked for me</p> <pre><code>create or replace procedure reset_sequence( p_seq_name in varchar2, tablename in varchar2 ) is l_val number; maxvalueid number; begin execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'select max(id) from ' || tablename INTO maxvalueid; execute immediate 'alter sequence ' || p_seq_name || ' increment by -' || l_val || ' minvalue 0'; execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'alter sequence ' || p_seq_name || ' increment by '|| maxvalueid ||' minvalue 0'; execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'alter sequence ' || p_seq_name || ' increment by 1 minvalue 0'; end; </code></pre> <p>How to use the stored procedure:</p> <pre><code>execute reset_sequence('company_sequence','company'); </code></pre>
7,453
<p>I'm likely to need to print some parts from TPU (Shore 95A or harder) in the near future. I have everything I need to do a direct drive conversion using the original extruder on a bracket above the hot end -- but for most of my printing (PLA and PETG), this setup isn't required or even optimal, because of the extra moving mass on the X carriage.</p> <p>It looks as if, once I have the bracket installed the first time, I can move the extruder (including adding/removing a wire extension and switching between full length Bowden tube and short coupler tube) in less than an hour -- in addition to the time I'd need to clear one material from the hot end before loading the other, of course. Is it practical at all to swap the extruder back and forth like this, on the assumption that I'll want/need to print TPU parts from time to time (I'll want softer material, too, since some of what I want TPU capability for is gaskets).</p> <p>Obviously, if I needed to print TPU alongside PLA on a regular basis, I might be ahead to have a second printer, but space considerations, more than money, work against that.</p> <p>Am I missing something on the effort needed to swap the extruder position back and forth (suggesting I should stick with direct drive and pursue firmware and tuning solutions to correct the accompanying problems with faster printing), or should I plan to do this as needed?</p>
<p>With some engineering, you could consider creating a tool dock version where you can easily screw off the Bowden driven hotend and screw on the direct driven hotend. You'll only need to have an extension stepper cable to connect the direct drive stepper and pluggable hotend heater and thermistor connections.</p> <p>E.g. for the Ender printers, there are Voron Afterburner tool heads that are Bowden driven or direct driven (Clockwork or Galileo mods) available. These could be switched very easily, you do need to figure something out to plug the heater cartridge and thermistor.</p> <hr /> <p><em>I'm doing something similar to my Hypercube Evolution where I am creating a Bowden driven 2.85 mm and a 1.75 mm direct driven tool head.</em></p>
<p>It depends on the level of automation you are willing to implement.</p> <p>The Bowden extruder, including the motor, from the Ender 3 which I think you have (but in general, any Bowden extruder) does not need to be moved at all, since it's not on the printing head. You just need to disconnect the Bowden from the hot end and clip it somewhere safe.</p> <p>The direct drive extruder, if you have a supporting plate which makes it as a single part, can be disconnected with a couple of screws and hanged somewhere nearby.</p> <p>Depending on the knowledge of electronics you could set up a very cheap relay array (4 relays) all controlled by a single GPIO pin of your motherboard, so that you can switch the motor with a GCODE command. The relay would have the COM going to the stepper driver, the NO connected to the direct drive motor, the NC to the Bowden motor.</p> <p>Write GCODE macros to change the current, linear advance, steps/mm settings depending on the activation of the relay board (or, even better, depending on the filament).</p> <p>However, if money is not an issue, I would consider an Orbiter or a Sherpa mini extruder, which is direct drive but with 120 gram weight (including motor, not including hot end) can be used all the time. You are likely not going to push the X acceleration to the very very maximum you can, so you get direct drive at no performance cost.</p>
1,996
<p>What languages and tools do you consider a youngster starting out in programming should use in the modern era?</p> <p>Lots of us started with proprietary Basics and they didn't do all of us long term harm :) but given the experiences you have had since then and your knowledge of the domain now are there better options?</p> <p>There are related queries to this one such as "<a href="https://stackoverflow.com/questions/3088/best-ways-to-teach-a-beginner-to-program">Best ways to teach a beginner to program?</a>" and "<a href="https://stackoverflow.com/questions/3553/one-piece-of-advice">One piece of advice</a>" about starting adults programming both of which I submitted answers to but children might require a different tool.</p> <p>Disclosure: it's bloody hard choosing a 'correct' answer to a question like this so who ever has the best score in a few days will get the 'best answer' mark from me based on the communities choice.</p>
<p>I would suggest <a href="http://mindstorms.lego.com/Products/Default.aspx" rel="nofollow noreferrer">LEGO Mindstorm</a>, it provides an intuitive drag and drop interface for programming and because it comes with hardware it provides something tangible for a child to grasp. Also, because it is "LEGO" they might think of it as more of a game then a programming exercise.</p>
<p>Wasn't Smalltalk designed for such a purpose? I think Ruby would be a good choice, as a descendant of Smalltalk.</p>
4,040
<p>I have some classes layed out like this</p> <pre><code>class A { public virtual void Render() { } } class B : A { public override void Render() { // Prepare the object for rendering SpecialRender(); // Do some cleanup } protected virtual void SpecialRender() { } } class C : B { protected override void SpecialRender() { // Do some cool stuff } } </code></pre> <p>Is it possible to prevent the C class from overriding the Render method, without breaking the following code?</p> <pre><code>A obj = new C(); obj.Render(); // calls B.Render -&gt; c.SpecialRender </code></pre>
<p>You can seal individual methods to prevent them from being overridable:</p> <pre><code>public sealed override void Render() { // Prepare the object for rendering SpecialRender(); // Do some cleanup } </code></pre>
<p>yes. If you mark a method as Sealed then it can not be overriden in a derived class.</p>
6,512
<p>I use <strong>Delphi</strong> for many years, and although I have now moved on to Visual Studio I still fondly remember numbered bookmarks (<kbd>CTRL</kbd>+<kbd>K</kbd>+<kbd>1</kbd> to set bookmark 1, <kbd>CTRL</kbd>+<kbd>Q</kbd>+<kbd>1</kbd> to goto bookmark 1).</p> <p>Is there a <strong>Visual Studio</strong> equivalent? I'm find the dumb bookmarks in VS a chore after Delphi. I want to bookmark then return to a specific place in the file.</p>
<p><a href="https://marketplace.visualstudio.com/items?itemName=SergeyM.DPack-16348" rel="nofollow noreferrer">DPack</a> can give you numbered bookmarks in VisualStudio.</p>
<p>I use:</p> <ul> <li><kbd>CTRL</kbd>-<kbd>F2</kbd> toggle bookmark</li> <li><kbd>F2</kbd> next bookmark</li> <li><kbd>SHIFT</kbd>-<kbd>F2</kbd> previous bookmark</li> <li><kbd>CTRL</kbd>-<kbd>SHIFT</kbd>-<kbd>F2</kbd> clear all bookmarks</li> </ul> <p>BTW, after using Visual Studio for years I just found about a couple of months ago that you can press ALT and drag mouse to mark a column or a square.</p>
5,975
<p>I'd like to know which libraries are used by executables on my system. More specifically, I'd like to rank which libraries are used the most, along with the binaries that use them. How can I do this?</p>
<ol> <li>Use <code>ldd</code> to list shared libraries for each executable.</li> <li>Cleanup the output</li> <li>Sort, compute counts, sort by count</li> </ol> <p>To find the answer for all executables in the "/bin" directory:</p> <pre><code>find /bin -type f -perm /a+x -exec ldd {} \; \ | grep so \ | sed -e '/^[^\t]/ d' \ | sed -e 's/\t//' \ | sed -e 's/.*=..//' \ | sed -e 's/ (0.*)//' \ | sort \ | uniq -c \ | sort -n </code></pre> <p>Change "/bin" above to "/" to search all directories.</p> <p>Output (for just the /bin directory) will look something like this:</p> <pre><code> 1 /lib64/libexpat.so.0 1 /lib64/libgcc_s.so.1 1 /lib64/libnsl.so.1 1 /lib64/libpcre.so.0 1 /lib64/libproc-3.2.7.so 1 /usr/lib64/libbeecrypt.so.6 1 /usr/lib64/libbz2.so.1 1 /usr/lib64/libelf.so.1 1 /usr/lib64/libpopt.so.0 1 /usr/lib64/librpm-4.4.so 1 /usr/lib64/librpmdb-4.4.so 1 /usr/lib64/librpmio-4.4.so 1 /usr/lib64/libsqlite3.so.0 1 /usr/lib64/libstdc++.so.6 1 /usr/lib64/libz.so.1 2 /lib64/libasound.so.2 2 /lib64/libblkid.so.1 2 /lib64/libdevmapper.so.1.02 2 /lib64/libpam_misc.so.0 2 /lib64/libpam.so.0 2 /lib64/libuuid.so.1 3 /lib64/libaudit.so.0 3 /lib64/libcrypt.so.1 3 /lib64/libdbus-1.so.3 4 /lib64/libresolv.so.2 4 /lib64/libtermcap.so.2 5 /lib64/libacl.so.1 5 /lib64/libattr.so.1 5 /lib64/libcap.so.1 6 /lib64/librt.so.1 7 /lib64/libm.so.6 9 /lib64/libpthread.so.0 13 /lib64/libselinux.so.1 13 /lib64/libsepol.so.1 22 /lib64/libdl.so.2 83 /lib64/ld-linux-x86-64.so.2 83 /lib64/libc.so.6 </code></pre> <p>Edit - Removed "grep -P"</p>
<p>I found this post very helpful as I needed to investigate dependencies from a 3rd party supplied library (32 vs 64 bit execution path(s)).</p> <p>I put together a Q&amp;D recursing bash script based on the 'readelf -d' suggestion on a RHEL 6 distro.</p> <p>It is very basic and will test every dependency every time even if it might have been tested before (i.e very verbose). Output is very basic too.</p> <pre><code>#! /bin/bash recurse () # Param 1 is the nuumber of spaces that the output will be prepended with # Param 2 full path to library { #Use 'readelf -d' to find dependencies dependencies=$(readelf -d ${2} | grep NEEDED | awk '{ print $5 }' | tr -d '[]') for d in $dependencies; do echo "${1}${d}" nm=${d##*/} #libstdc++ hack for the '+'-s nm1=${nm//"+"/"\+"} # /lib /lib64 /usr/lib and /usr/lib are searched children=$(locate ${d} | grep -E "(^/(lib|lib64|usr/lib|usr/lib64)/${nm1})") rc=$? #at least locate... didn't fail if [ ${rc} == "0" ] ; then #we have at least one dependency if [ ${#children[@]} -gt 0 ]; then #check the dependeny's dependencies for c in $children; do recurse " ${1}" ${c} done else echo "${1}no children found" fi else echo "${1}locate failed for ${d}" fi done } # Q&amp;D -- recurse needs 2 params could/should be supplied from cmdline recurse "" !!full path to library you want to investigate!! </code></pre> <p>redirect the output to a file and grep for 'found' or 'failed'</p> <p>Use and modify, at your own risk of course, as you wish.</p>
7,286
<p>I've got many, many mp3 files that I would like to merge into a single file. I've used the command line method</p> <pre><code>copy /b 1.mp3+2.mp3 3.mp3 </code></pre> <p>but it's a pain when there's a lot of them and their namings are inconsistent. The time never seems to come out right either.</p>
<p>As Thomas Owens pointed out, simply concatenating the files will leave multiple ID3 headers scattered throughout the resulting concatenated file - so the time/bitrate info will be wildly wrong.</p> <p>You're going to need to use a tool which can combine the audio data for you.</p> <p><a href="http://mp3wrap.sourceforge.net/" rel="noreferrer">mp3wrap</a> would be ideal for this - it's designed to join together MP3 files, without needing to decode + re-encode the data (which would result in a loss of audio quality) and will also deal with the ID3 tags intelligently.</p> <p>The resulting file can also be split back into its component parts using the mp3splt tool - mp3wrap adds information to the IDv3 comment to allow this.</p>
<p>Personally I would use something like mplayer with the audio pass though option eg -oac copy</p>
8,810
<p>Trying to print a 3D model for my mobile phone, but I see that when printing the sides, being thin, increases the retraction and the recoil seems a little abrupt and makes a coarse sound.</p> <p>I would like to know if it is possible to know what speed and temperature is recommended to print a model.</p> <p>In my case I use Simplify3D, and when I'm going to save the file in <code>.gcode</code> format, I see that there are some ranges shown in colors, how does this apply to the models?</p> <p><a href="https://i.stack.imgur.com/6Ysqr.png" rel="nofollow noreferrer" title="Screenshot of Simplify3D"><img src="https://i.stack.imgur.com/6Ysqr.png" alt="Screenshot of Simplify3D" title="Screenshot of Simplify3D"></a></p>
<p>The first indication for print speed and temperature should be taken from the box the filament comes in. Generally it specifies temperature ranges for the hotend and the heated bed. Sometime, mostly online, more parameters can be found amongst which is the printing speed. </p> <p>Do note that temperature and printing speed are linked, if you want to print faster you should increase the temperature. But, if you are printing small or thin things you should print slower so that the part cools enough for the next layer. Basically, part cooling is then also important, but not all filament types (e.g. the ones with a high melt temperature like ABS or PETG) like being cooled too much. So you have another parameter to consider.</p> <p>It is difficult to instruct you to print at a certain speed and certain temperatures as it is highly depending on the filament (e.g. also the filament diameter), the machine type/make and model, extruder setup (direct or Bowden), the print, enclosure, etc.</p> <p>Because of the many parameters affecting printing, it is usually suggested to calibrate the printer by printing a <a href="/a/7346/">temperature tower</a> or performing <a href="/q/8194/">retraction tests</a> to find the print window for your specific setup.</p>
<p>So as someone else on here mention, those settings shouldn't be for the model but for the filament. Sadly, you will need to test 99% of filaments to really figure this out. I have a modify tester, and on the description it tells you how to set your temp. <a href="https://www.thingiverse.com/thing:3347967" rel="nofollow noreferrer">https://www.thingiverse.com/thing:3347967</a></p> <p>You can look at the remix if you want to grab the blank model and put your own numbers on it. It should be noted that things like water in the filament can mess with how the filament reacts to speed and temp. If you have questionable prints coming out of a filament that sat there for a long time. You can easily run it through the test to figure out the temp.</p> <p>Anything else I could add is would just repeat what most of 0scar said.</p>
1,298
<p>I've just been learning about master pages in ASP.NET 2.0. </p> <p>They sound great, but how well do they work in practice? </p> <p>Does anybody have experience of using them for a large web site?</p>
<p>I'm pretty sure I've only used master pages in the context of ASP.NET MVC so I'm not sure if it differs from web forms but in my experience they are not only excellent but I couldn't imagine not using them. Master pages are code inheritance to web pages.</p>
<p>Master Pages have made building template-able websites easy.</p> <p>I think the trickiest part in building a website using master pages is knowing when to put things into the master page and when to put things into the ContentPlaceHolder on the child page. Generally, dynamic stuff goes into the placeholder while static items go into the master page, but there is sometimes a gray area. It's mostly a design/architecture question.</p>
2,844
<p>Obviously there are security reasons to close a wireless network and it's not fun if someone is stealing your bandwidth. That would be a serious problem?</p> <p>To address the first concern: Does a device on the same wireless network have any special privileges or access that an other device on the internet has?<br> <strong>Assumptions :</strong> Wireless network is connected to the internet</p> <p>The second seems like a community issue. If your neighbor is stealing bandwidth, you'd act just as if he were "borrowing" water or electricity. </p> <p>First, Talk to him about the problem and if that doesn't work, go to the authorities or lock stuff up. Am I missing something?</p>
<p>Bruce Schneier is famous for running an open wireless network at home (<a href="http://www.schneier.com/blog/archives/2008/01/my_open_wireles.html" rel="noreferrer">see here</a>). He does it for two reasons:</p> <ol> <li>To be neighborly (you'd let your neighbor borrow a cup of sugar, wouldn't you? Why not a few megabits?)</li> <li>To keep away from the false sense of security that a firewall gives you. In other words, it forces him to make sure his hosts are secure.</li> </ol> <p>Personally, I would never run an open wireless network for one reason: accountability. If someone does something illegal on my network, I don't want to be held accountable.</p>
<p>@kronoz: I guess it depends on where you live. Only two houses are within reach of my wireless network, excluding my own. So I doubt that small number of people can affect my bandwidth. But if you live in a major metro area, and many people are able to see and get on the network, yeah, it might become a problem.</p>
5,295
<p>I've read a bunch of articles about getting better springs for my bed levelling screws so that I don't have to adjust it as often because standard springs vibrate loose as it prints.</p> <p>However, would it be simpler and more effective to just use Nyloc nuts tightened against the adjustment wheels so that the wheels cannot rotate? Or some other form of mechanical prevention of the wheels turning? For example, tie a piece of string between the spokes in opposite wheels, so they cannot rotate much relative to each other.</p>
<p>It's because the bed heats up. Since the bed can heat up to the point that locktite or nylon can soften, using those products to keep the screws from turning will have exactly the opposite effect.</p>
<p>Does your bed already have washers on the screws? The neopreme (red) washer under the screw head (in picture). This is the German Reprap X400 design and is worth trying.</p> <p><a href="https://i.stack.imgur.com/jucy3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jucy3.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/V3qrL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V3qrL.jpg" alt="enter image description here" /></a></p>
1,852
<p>In my host, I currently have installed 2 wordpress applications, 1 phpBB forum and one MediaWiki.</p> <p>Is there a way to merge the login so that all applications share the same credentials?</p> <p>For instance, I want to register only in my phpBB and then I want to access all other applications with the given username and password.</p> <p>Even if you don't know a unified way, what other login integration do you know of? Pros and cons of each?</p>
<p>when you integrate the system. Just remember 2 things:</p> <ol> <li><p>Login to system<br/> Check username/password with both systems.</p></li> <li><p>Change of Password<br/> Update the password on both systems.</p></li> </ol>
<p>Having tried to do this some years ago I remember it not being very easy. </p> <p>The way I did it was to create totally new table to user/pass and then replace these columns in the respective software with foreign keys to your new table - this required <strong>a lot</strong> of custom tweaking of core files in each application - mainly making sure all SQL requests to this data have the extra join needed for your new table. If I find the time I will maybe try and provide a step by step of the changes needed.</p> <p>There are some <strong>pretty big drawbacks</strong> to this approach though. The main one being from now on your gonna have to hand update any patches </p> <p>If you have no content or users yet look at <a href="http://bbpress.org/documentation/integration-with-wordpress/" rel="nofollow noreferrer">http://bbpress.org/documentation/integration-with-wordpress/</a> which will make things a lot simpler for you.</p> <p>I can't quite remember but I believe that I big problem I had was that MediaWiki requires usernames formatted a certain that conflicted with phpBB.</p> <hr> <p>Of course, a totally different approach would be to mod each piece of software to use OpenID _ I believe plugins/extensions are readily available for all the applications you mentioned.</p>
6,066
<p>What's the best way to store a linked list in a MySQL database so that inserts are simple (i.e. you don't have to re-index a bunch of stuff every time) and such that the list can easily be pulled out in order?</p>
<p>Store an integer column in your table called 'position'. Record a 0 for the first item in your list, a 1 for the second item, etc. Index that column in your database, and when you want to pull your values out, sort by that column.</p> <pre><code> alter table linked_list add column position integer not null default 0; alter table linked_list add index position_index (position); select * from linked_list order by position; </code></pre> <p>To insert a value at index 3, modify the positions of rows 3 and above, and then insert:</p> <pre><code> update linked_list set position = position + 1 where position &gt;= 3; insert into linked_list (my_value, position) values ("new value", 3); </code></pre>
<p>A list can be stored by having a column contain the offset (list index position) -- an insert in the middle is then incrementing all above the new parent and then doing an insert.</p>
9,098
<p>I have heard/read the term but don't quite understand what it means.</p> <p>When should I use this technique and how would I use it? Can anyone provide a good code sample?</p>
<p>The visitor pattern is a way of doing double-dispatch in an object-oriented way.</p> <p>It's useful for when you want to choose which method to use for a given argument based on its type at runtime rather than compile time.</p> <p>Double dispatch is a special case of <strong>multiple dispatch</strong>. </p> <p>When you call a virtual method on an object, that's considered single-dispatch because which actual method is called depends on the type of the single object.</p> <p>For double dispatch, both the object's type and the method sole argument's type is taken into account. This is like method overload resolution, except that the argument type is determined at runtime in double-dispatch instead of statically at compile-time.</p> <p>In multiple-dispatch, a method can have multiple arguments passed to it and which implementation is used depends on each argument's type. The order that the types are evaluated depends on the language. In LISP, it checks each type from first to last.</p> <p>Languages with multiple dispatch make use of generic functions, which are just function delcarations and aren't like generic methods, which use type parameters.</p> <p><strong>To do double-dispatch in C#</strong>, you can declare a method with a sole object argument and then specific methods with specific types:</p> <pre><code>using System.Linq; class DoubleDispatch { public T Foo&lt;T&gt;(object arg) { var method = from m in GetType().GetMethods() where m.Name == "Foo" &amp;&amp; m.GetParameters().Length==1 &amp;&amp; arg.GetType().IsAssignableFrom (m.GetParameters()[0].GetType()) &amp;&amp; m.ReturnType == typeof(T) select m; return (T) method.Single().Invoke(this,new object[]{arg}); } public int Foo(int arg) { /* ... */ } static void Test() { object x = 5; Foo&lt;int&gt;(x); //should call Foo(int) via Foo&lt;T&gt;(object). } } </code></pre>
<p>Full listing of working code</p> <pre class="lang-cs prettyprint-override"><code>using System; using System.Linq; namespace TestConsoleApp { internal class Program { public static void Main(string[] args) { const int x = 5; var dispatch = new DoubleDispatch(); Console.WriteLine(dispatch.Foo&lt;int&gt;(x)); Console.WriteLine(dispatch.Foo&lt;string&gt;(x.ToString())); Console.ReadLine(); } } public class DoubleDispatch { public T Foo&lt;T&gt;(T arg) { var method = GetType() .GetMethods() .Single(m =&gt; m.Name == "Foo" &amp;&amp; m.GetParameters().Length == 1 &amp;&amp; arg.GetType().IsAssignableFrom(m.GetParameters()[0].ParameterType) &amp;&amp; m.ReturnType == typeof(T)); return (T) method.Invoke(this, new object[] {arg}); } public int Foo(int arg) { return arg; } public string Foo(string arg) { return arg; } } } </code></pre>
6,415
<p>I was reading the example chapter from <a href="http://www.manning.com/rahien/" rel="nofollow noreferrer">the book by Ayende</a> and on the website of <a href="http://boo.codehaus.org/" rel="nofollow noreferrer">the Boo language</a> I saw a reference to the <a href="http://specter.sourceforge.net/" rel="nofollow noreferrer">Specter BDD Framework</a>.</p> <p>I am wondering if anybody is using it in their project, how that works out and if there are more examples and/or suggested readings.</p> <p>Just in case you are wondering, I'm a C# developer and so I plan to use it in a C#/.NET environment.</p> <hr> <p>A few year later visiting this question. I think we can safely assume <a href="http://www.specflow.org/" rel="nofollow noreferrer">Specflow</a> and some others like <a href="http://nspec.org/" rel="nofollow noreferrer">NSpec</a> became the tools we are using.</p>
<p>Create one Message table, containing a unique MessageId and the various properties you need to store for a message.</p> <pre><code>Table: Message Fields: Id, TimeReceived, MessageDetails, WhateverElse... </code></pre> <p>Create two link tables - QuoteMessage and JobMessage. These will just contain two fields each, foreign keys to the Quote/Job and the Message.</p> <pre><code>Table: QuoteMessage Fields: QuoteId, MessageId Table: JobMessage Fields: JobId, MessageId </code></pre> <p>In this way you have defined the data properties of a Message in one place only (making it easy to extend, and to query across all messages), but you also have the referential integrity linking Quotes and Jobs to any number of messages. Indeed, both a Quote and Job could be linked to the <em>same</em> message (I'm not sure if that is appropriate to your business model, but at least the data model gives you the option).</p>
<p>Why not just have both QuoteId and JobId fields in the message table? Or does a message have to be regarding either a quote or a job and not both?</p>
3,999
<p>Can anyone point me to a good resource (or throw me a clue) to show me how to do DataBinding to controls (ComboBox, ListBox, etc.) in WPF? I'm at a bit of a loss when all my WinForms niceities are taken away from me, and I'm not all that bright to start with...</p>
<p>The best resource I've found for WPF data binding is <a href="http://www.beacosta.com" rel="nofollow noreferrer">Bea Costa's blog</a>. Start from the first post and read forward. It's awesome.</p>
<p>in code behind -- set the DataContext of your list box equal to the collection you're binding to.</p> <pre><code>private void OnInit(object sender, EventArgs e) { //myDataSet is some IEnumerable // myListBox is a ListBox control. // Set the DataContext of the ListBox to myDataSet myListBox.DataContext = myDataSet; } </code></pre> <p>In XAML, Listbox can declare which properties it binds to using the "Binding" syntax.</p> <pre><code>&lt;ListBox Name="myListBox" Height="200" ItemsSource="{Binding Path=BookTable}" ItemTemplate ="{StaticResource BookItemTemplate}"/&gt; </code></pre>
2,900
<p>What is the thread pitch of the Ender 3's bed leveling screws? The diameter measures about 4mm. Are they M4 0.7 (coarse) pitch or 0.5 (fine) pitch? I'd like to develop rigorous formulas for the amount to turn the knobs by after measuring (or visually inspecting, since I can see an accurate 0.2 mm first layer decently well) leveling-test patterns in the corners rather than using a closed-loop tune-and-retry approach.</p>
<p>I measured mine with a thread gauge and it says the pitch is <strong>0.7 mm</strong>.</p> <p>So, as the stock adjustment wheels have 14 bumps around their circumference, turning by one of those is an adjustment of exactly 0.05 mm (assuming no backlash).</p> <p>I can't speak for anyone else's, but due to the availability of replacement height adjustment wheels which don't specify alternative thread pitches, I <em>guess</em> that's the only one in use. I encourage you to verify my finding before relying on it.</p>
<p>I don't know what the value is, but there are a few ways to find out. It is very hard to measure this with a caliper, but it can be done, mark the upper and bottom of e.g. 10 windings and measure this with a caliper. Alternatively measure how much the screw drops after 10 full turns. </p> <p>There are special tools that give you the answer directly, they cost a few Euros/bucks but can be very handy; a thread gauge, just place the 0.5&nbsp;mm and the 0.7&nbsp;mm beside the screw and you will instantly see which is the correct one.</p> <p><a href="https://i.stack.imgur.com/UYqFm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UYqFm.jpg" alt="enter image description here"></a></p> <p><em>I bought mine at a typical Chinese vendor site.</em></p>
1,570
<p>What is the RegEx pattern for DateTime (2008-09-01 12:35:45 ) ?</p> <p>I get this error:</p> <blockquote> <p>No ending delimiter '^' found</p> </blockquote> <p>Using:</p> <pre><code>preg_match('(?n:^(?=\d)((?&lt;day&gt;31(?!(.0?[2469]|11))|30(?!.0?2)|29(?(.0?2)(?=.{3,4}(1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))|0?[1-9]|1\d|2[0-8])(?&lt;sep&gt;[/.-])(?&lt;month&gt;0?[1-9]|1[012])\2(?&lt;year&gt;(1[6-9]|[2-9]\d)\d{2})(?:(?=\x20\d)\x20|$))?(?&lt;time&gt;((0?[1-9]|1[012])(:[0-5]\d){0,2}(?i:\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$)', '2008-09-01 12:35:45'); </code></pre> <p>Gives this error: </p> <blockquote> <p>Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 0 in E:\www\index.php on line 19</p> </blockquote>
<p>@Espo: I just have to say that regex is incredible. I'd hate to have to write the code that did something useful with the matches, such as if you wanted to actually find out what date and time the user typed.</p> <p>It seems like Tom's solution would be more tenable, as it is about a zillion times simpler and with the addition of some parentheses you can easily get at the values the user typed:</p> <pre><code>(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) </code></pre> <p>If you're using perl, then you can get the values out with something like this:</p> <pre><code>$year = $1; $month = $2; $day = $3; $hour = $4; $minute = $5; $second = $6; </code></pre> <p>Other languages will have a similar capability. Note that you will need to make some minor mods to the regex if you want to accept values such as single-digit months.</p>
<p>PHP preg functions needs your regex to be wrapped with a delimiter character, which can be any character. You can't use this delimiter character without escaping inside the regex. This should work (here the delimiter character is /):</p> <pre><code>preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', '2008-09-01 12:35:45'); // or this, to allow matching 0:00:00 time too. preg_match('/\d{4}-\d{2}-\d{2} \d{1,2}:\d{2}:\d{2}/', '2008-09-01 12:35:45'); </code></pre> <p>If you need to match lines that contain only datetime, add ^ and $ at the beginning and end of the regex.</p> <pre><code>preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', '2008-09-01 12:35:45'); </code></pre> <p><a href="http://www.php.net/preg-match" rel="nofollow noreferrer">Link to PHP Manual's preg_match()</a></p>
5,852
<p>I have designed a bread mark and printed it on the Prusa i3 MK3.</p> <p><a href="https://i.stack.imgur.com/qs5PP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qs5PP.png" alt="Bread mark"></a></p> <p>I wanted it to have as sharp edges as possible, so I used a triangle:</p> <p><a href="https://i.stack.imgur.com/AMTCP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AMTCP.png" alt="Triangle"></a></p> <p>However, it seems that the print cut off layers that are too thin (x-y-wise) and instead of a 1 cm high bread mark, I only have 0.5 cm.</p> <p>What is the X-Y-resolution of the Prusa i3 MK3? In Slic3r, can I make sure that any wall is made as thick as needed for it to be printed?</p> <p>I have the default 0.4 mm nozzle.</p>
<p>This is dependent on the slicer and the nozzle diameter. Typically, you cannot print a wall smaller than twice the nozzle diameter because walls need an inner and outer line. Therefore, your slicer will make some cutoff and won't print walls below a certain threshold, in order to try to faithfully replicate your model.</p> <p>Slic3r, I believe, will automatically go down to single line walls, but if you turn on "Detect thin walls" in Slic3r's Print Settings, more of the thin walls will be printed. Slic3r will actually reduce the plastic extruded to attempt to make even thinner walls, but there's still a limit.</p> <p>With a 0.4&nbsp;mm nozzle, you should design walls no smaller than 0.8&nbsp;mm, or 0.4&nbsp;mm at the very smallest.</p>
<p>The absolute minimum a slicer will allow existing in a g-code is one extrusion diameter, which is typically roundabout a nozzle diameter. So for a standard 0.4 mm nozzle, the model will be cut in a way that keeps at <em>least</em> 0.4 mm thick walls, or, if the slicer is extra careful, double that, as the model demands 2 walls next to each other. The result is, that the model with such sharp walls will be cut till the model does conform to the minimum wall thickness - in your case about half the height of the model. </p> <p>I strongly encourage to further read <a href="https://3dprinting.stackexchange.com/a/6830/8884">What special considerations must be taken when designing parts for 3D printing?</a></p>
1,101
<p>I'm trying to find out the 'correct' windows API for finding out the localized name of 'special' folders, specifically the Recycle Bin. I want to be able to prompt the user with a suitably localized dialog box asking them if they want to send files to the recycle bin or delete them directly.</p> <p>I've found lots on the internet (and on Stackoverflow) about how to do the actual deletion, and it seems simple enough, I just really want to be able to have the text localized.</p>
<p>Read this article for code samples and usage:</p> <p><a href="http://www.codeproject.com/KB/winsdk/SpecialFolders.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/winsdk/SpecialFolders.aspx</a></p> <p>Also there is an article on MSDN that helps you <a href="http://msdn.microsoft.com/en-us/library/aa140088(office.10).aspx" rel="nofollow noreferrer">Identify the Location of Special Folders with API Calls</a></p>
<p>I actually didn't find the CodeProject article terribly helpful, so I thought I'd answer this question with the actual code that I used to retrieve the localized name of the recycle bin.</p> <p>This sample also tries to behave correctly with regard to freeing resources. Any comments are welcome, especially if you spot an error with my resource management!</p> <pre><code>public static string GetLocalizedRecycleBinName() { IntPtr relative_pidl, parent_ptr, absolute_pidl; PInvoke.SHGetFolderLocation(IntPtr.Zero, PInvoke.CSIDL.BitBucket, IntPtr.Zero, 0, out absolute_pidl); try { PInvoke.SHBindToParent(absolute_pidl, ref PInvoke.Guids.IID_IShellFolder, out parent_ptr, out relative_pidl); PInvoke.IShellFolder shell_folder = Marshal.GetObjectForIUnknown(parent_ptr) as PInvoke.IShellFolder; // Release() for this object is called at finalization if (shell_folder == null) return Strings.RecycleBin; PInvoke.STRRET strret = new PInvoke.STRRET(); StringBuilder sb = new StringBuilder(260); shell_folder.GetDisplayNameOf(relative_pidl, PInvoke.SHGNO.Normal, out strret); PInvoke.StrRetToBuf(ref strret, relative_pidl, sb, 260); string name = sb.ToString(); return String.IsNullOrEmpty(name) ? Strings.RecycleBin : name; } finally { PInvoke.ILFree(absolute_pidl); } } static class PInvoke { [DllImport("shell32.dll")] public static extern int SHGetFolderLocation(IntPtr hwndOwner, CSIDL nFolder, IntPtr hToken, uint dwReserved, out IntPtr ppidl); [DllImport("shell32.dll")] public static extern int SHBindToParent(IntPtr lpifq, [In] ref Guid riid, out IntPtr ppv, out IntPtr pidlLast); [DllImport("shlwapi.dll")] public static extern Int32 StrRetToBuf(ref STRRET pstr, IntPtr pidl, StringBuilder pszBuf, uint cchBuf); [DllImport("shell32.dll")] public static extern void ILFree([In] IntPtr pidl); [ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("000214E6-0000-0000-C000-000000000046")] public interface IShellFolder { [PreserveSig] Int32 CompareIDs(Int32 lParam, IntPtr pidl1, IntPtr pidl2); void ParseDisplayName(IntPtr hwnd, IntPtr pbc, String pszDisplayName, UInt32 pchEaten, out IntPtr ppidl, UInt32 pdwAttributes); void EnumObjects(IntPtr hwnd, int grfFlags, out IntPtr ppenumIDList); void BindToObject(IntPtr pidl, IntPtr pbc, [In] ref Guid riid, out IntPtr ppv); void BindToStorage(IntPtr pidl, IntPtr pbc, [In] ref Guid riid, out IntPtr ppv); void CreateViewObject(IntPtr hwndOwner, [In] ref Guid riid, out IntPtr ppv); void GetAttributesOf(UInt32 cidl, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] apidl, ref uint rgfInOut); void GetUIObjectOf(IntPtr hwndOwner, UInt32 cidl, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] IntPtr[] apidl, [In] ref Guid riid, UInt32 rgfReserved, out IntPtr ppv); void GetDisplayNameOf(IntPtr pidl, SHGNO uFlags, out STRRET pName); void SetNameOf(IntPtr hwnd, IntPtr pidl, string pszName, int uFlags, out IntPtr ppidlOut); } public enum CSIDL { BitBucket = 0x000a, } public enum SHGNO { Normal = 0x0000, ForParsing = 0x8000, } [StructLayout(LayoutKind.Explicit, Size = 520)] public struct STRRETinternal { [FieldOffset(0)] public IntPtr pOleStr; [FieldOffset(0)] public IntPtr pStr; [FieldOffset(0)] public uint uOffset; } [StructLayout(LayoutKind.Sequential)] public struct STRRET { public uint uType; public STRRETinternal data; } public class Guids { public static Guid IID_IShellFolder = new Guid("{000214E6-0000-0000-C000-000000000046}"); } } </code></pre>
5,770
<p>How can I visually customize autocomplete fields in Wicket (change colors, fonts, etc.)?</p>
<p>You can use CSS to modify the look of this component. For the Ajax auto-complete component in 1.3 the element you want to override is div.wicket-aa, so for example you might do:</p> <pre><code>div.wicket-aa { background-color:white; border:1px solid #CCCCCC; color:black; } div.wicket-aa ul { list-style-image:none; list-style-position:outside; list-style-type:none; margin:0pt; padding:5px; } div.wicket-aa ul li.selected { background-color:#CCCCCC; } </code></pre>
<p>Perilandmishap has probably the most usefull answer for your needs. Personally, I always found the default Ajax auto complete control in Wicket to be woefully insufficient for my needs. If you really want a professional "feel" to your auto complete, roll your an using Wicket's Ajax libraries.</p>
9,548
<p>In the business I work for we are discussion methods to reduce the read load on our primary database.</p> <p>One option that has been suggested is to have live one-way replication from our primary database to a slave database. Applications would then read from the slave database and write directly to the primary database. So...</p> <ul> <li>Application Reads From Slave</li> <li>Application Writes to Primary</li> <li>Primary Updates Slave Automatically</li> </ul> <p>What are the major pros and cons for this method?</p>
<p>A few cons:</p> <ul> <li>2 points of failure</li> <li>Application logic will have to take into account the delay between writing something and then reading it, since it won't be available immediately from the secondary database</li> </ul> <p>A strategy I have used is to send key reporting data to a secondary database nightly, de-normalizing it on the way, so that beefy queries can run on that database instead of locking up tables and stealing resources from the OLTP server. I'm not using any formal data warehousing or replication tools, rather I identify problem queries that are Ok without up-to-the-minute data and create data structures on the secondary server specifically for those queries.</p> <p>There are definitely pros to the "replicate everything" approach:</p> <ul> <li>You can run any ad-hoc query on the secondary, since it has all of your data</li> <li>If your primary server dies, you can re-purpose the secondary quickly to take over</li> </ul>
<p>We are using one-way replications, but not from the same application. Our applications are reading-writing to the master database, the data gets synchronized to the replca database, and the reporting tools are using this replica.</p> <p>We don't want our application to read from a different database, so in this scenario I would suggest using file groups and partitioning on the master database. Using file groups (especially on different drives) and partitioning of files and indexes can help on performance a lot.</p>
6,509
<p>We're using SQL Server 2005 in a project. The users of the system have the ability to search some objects by using 'keywords'. The way we implement this is by creating a full-text catalog for the significant columns in each table that may contain these 'keywords' and then using CONTAINS to search for the keywords the user inputs in the search box in that index. </p> <p>So, for example, let say you have the Movie object, and you want to let the user search for keywords in the title and body of the article, then we'd index both the Title and Plot column, and then do something like:</p> <pre><code>SELECT * FROM Movies WHERE CONTAINS(Title, keywords) OR CONTAINS(Plot, keywords) </code></pre> <p>(It's actually a bit more advanced than that, but nothing terribly complex)</p> <p>Some users are adding numbers to their search, so for example they want to find 'Terminator 2'. The problem here is that, as far as I know, by default SQL Server won't index short words, thus doing a search like this:</p> <pre><code>SELECT * FROM Movies WHERE CONTAINS(Title, '"Terminator 2"') </code></pre> <p>is actually equivalent to doing this:</p> <pre><code>SELECT * FROM Movies WHERE CONTAINS(Title, '"Terminator"') &lt;-- notice the missing '2' </code></pre> <p>and we are getting a plethora of spurious results.</p> <p>Is there a way to force SQL Server to index small words? Preferably, I'd rather index only <em>numbers</em> like 1, 2, 21, etc. I don't know where to define the indexing criteria, or even if it's possible to be as specific as that.</p> <hr> <p>Well, I did that, removed the "noise-words" from the list, and now the behaviour is a bit different, but still not what you'd expect. </p> <p>A search won't for "Terminator 2" (I'm just making this up, my employer might not be really happy if I disclose what we are doing... anyway, the terms are a bit different but the principle the same), I don't get <em>anything</em>, but I know there are objects containing the two words.</p> <p>Maybe I'm doing something wrong? I removed all numbers 1 ... 9 from my noise configuration for ENG, ENU and NEU (neutral), regenerated the indexes, and tried the search.</p>
<p>These "small words" are considered "noise words" by the full text index. You can customize the list of noise words. This <a href="http://arcanecode.wordpress.com/2008/05/29/creating-and-customizing-noise-words-in-sql-server-2005-full-text-search/" rel="nofollow noreferrer">blog post</a> provides more details. You need to repopulate your full text index when you change the noise words file.</p>
<p>I knew about the noise words file, but I'm not why your "Terminator 2" example is still giving you issues. You might want to try asking this on the <a href="http://forums.microsoft.com/Forums/ShowForum.aspx?ForumID=93&amp;SiteID=1" rel="nofollow noreferrer">MSDN Database Engine forum</a> where people that specialize in this sort of thing hang out.</p>
9,707
<p>Does it make sense, having all of the C#-managed-bliss, to go back to Petzold's Programming Windows and try to produce code w/ pure WinAPI?</p> <p>What can be learn from it? Isn't it just too outdated to be useful?</p>
<p>This question is bordering on religious :) But I'll give my thoughts anyway.</p> <p>I do see value in learing the Win32 API. Most, if not all, GUI libraries (managed or unmanaged) result in calls to the Win32 API. Even the most thorough libraries don't cover 100% of the API, and hence there are always gaps which need to be plugged by direct API calls or P/invoking. Some of the names of the wrappers around the API calls have similar names to the underlying API calls, but those names aren't exactly self-documenting. So understanding the underlying API, and the terminology used therein, will aid in understanding the wrapper APIs and what they actually do.</p> <p>Plus, if you understand the nature of the underlying APIs that are used by frameworks, then you will make better choices with regards to which library functionality you should use in a given scenario.</p> <p>Cheers!</p>
<p>If you planning to develop a cross platform application, If you use win32, then your application could easily run on linux through WINE. This results in a highly maintainable application. This is one of the advantages of learning win32.</p>
2,740
<p>What's the best practice for making sure that certain ajax calls to certain pages are only accepted from authenticated users?</p> <p>For example:</p> <p>Let's say that I have a main page called <strong>blog.php</strong> (I know, creativity abounds). Let's also say that there is a page called <strong>delete.php</strong> which looks for the parameter <strong>post_id</strong> and then deletes some entry from a database.</p> <p>In this very contrived example, there's some mechanism on blog.php which sends a request via ajax to delete.php to delete an entry. </p> <p>Now this mechanism is only going to be available to authenticated users on blog.php. But what's to stop someone from just calling delete.php with a bunch of random numbers and deleting everything in site?</p> <p>I did a quick test where I set a session variable in blog.php and then did an ajax call to delete.php to return if the session variable was set or not <strong><em>(it wasn't)</em></strong>.</p> <p>What's the accepted way to handle this sort of thing?</p> <hr> <p>OK. I must have been crazy the first time I tried this.</p> <p>I just did another test like the one I described above and it worked perfectly.</p>
<p>You were correct in trying to use session variables. Once your user authenticates, you should store that information in their session so that each subsequent page view will see that. Make sure you are calling <code>session_start()</code> on both pages (blog.php and delete.php) before accessing $_SESSION. Also make sure you have cookies enabled -- and if not, you should pass an additional parameter in the query string, usually PHPSESSID=&lt;<code>session_id()</code>>.</p>
<p>It is not recommended that you rely on sessions for authentication without taking additional actions. <a href="http://shiflett.org/articles/the-truth-about-sessions" rel="nofollow noreferrer">Read more on</a>.</p>
3,618
<p>I created my model in onshape then exported it to stl file then imported it to simplify 3d to convert to gcode.</p> <p>However my model didn't go any in fill, it just continue to print layer after layer in the same fasion as the 1st layer. </p> <p>Correct me if am wrong infill is used so that the middle of your model isn't completely solid hence saving on filament.</p> <p>Is there something special I need to do in onshape or simplify 3d for it to use infill? To me it looked like it was just filling it up with pla </p>
<p>I don't use either of the two piece of software, but the first things to pop to mind:</p> <ul> <li><strong>Inspect the slicing preview</strong>: it should be self-evident if your GCODE is being generated correctly. In my slicer the infill is red and you can discern the typical pattern within:</li> </ul> <p><a href="https://i.stack.imgur.com/jIfh2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jIfh2.png" alt="slicing preview"></a></p> <ul> <li><p><strong>Check your settings</strong>: your shell thickness should be something reasonable (like 0.8mm / 2 shells) and your infill should also be below 100% if you don't want to print it solid. For maximum strength, it doesn't help go much over 60%, typical values for light-duty parts are 20% and 30%.</p></li> <li><p><strong>Check your STL file</strong>: your mesh should be a closed surface, a "shell". Or the slicer won't be able to know what is "inside" and "outside". Many slicers verify this for you automatically and have a built-in utility to attempt to "repair" a broken mesh. I use <a href="https://github.com/prusa3d/Slic3r/releases" rel="nofollow noreferrer">slic3r Prusa Edition</a> and this information is visualised at the bottom right:</p></li> </ul> <p><a href="https://i.stack.imgur.com/mTl9K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mTl9K.png" alt="info box from slic3r PE"></a></p> <ul> <li><p><strong>Let the print finish</strong>: the wording of your question is ambiguous, but it sounds like you may have stopped the printer before the part finished. Certain combination of settings can be deceitful. For example, a layer height of 0.05mm and a shell thickness of 2mm means you will see the printer making 40 (forty!) layers of solid printing, before starting to create the infill.</p></li> <li><p><strong>Try another slicer</strong>: in case your slicer went berserk because of a bug (unlikely but possible), this should fix it.</p></li> </ul> <p>On an unrelated note: the use of infill has a lot of different reasons besides "saving filament", for example:</p> <ul> <li>relative to an empty print, even a very light infill (5%) provides a lot of added rigidity,</li> <li>relative to a solid print, infill reduces weight and relief the tensions that are trapped in the FDM/FFF printing process</li> <li>certain infill patterns allow to provide different responses to stressed in different directions (like for example a crash box that needs to give way in one direction but bear a load in another, or a wing that need to flex on its length but not on its chord)</li> <li>infill provide support for top layers and other concave structures that may otherwise be non-printable</li> <li>...</li> </ul>
<p>The infill portion of your model is configured during the Simplify3D process. After loading your STL file into S3D, edit the process and examine the Infill tab and Infill slider. You'll see a percentage indicator, as well as an extruder selection (left or right, if you have two) to be used for the infill. There are other options within the configuration that would have little to no effect on the problem you are experiencing.</p> <p>Once you have checked and corrected the settings as needed, used the prepare-to-print option and press the play button for a preview to see the infill being printed before you send it to the printer.</p> <p>100% infill is impractical, and one can create strong models with as low as 20% infill.</p> <p>Infill is used to save filament, as you suggest, but it is also used to provide support for top layers on areas that are not vertical. Sometimes, one would use a higher infill figure to provide for smoother top surfaces although increasing the layer count for top/bottom can accomplish that.</p> <p>Check your top/bottom layer figure in the layers tab to ensure you have a reasonable figure. Three or four layers are good for cosmetic reasons, more if you need additional strength. Anything higher or absurdly high would cause some of the trouble you describe.</p>
782
<p>I am developing an application that controls an Machine.<br/> When I receive an error from the Machine the users should be able to directly notice it, one way that is done is Flashing the tray on the taskbar. When the machine clears the error the tray should stop flashing.</p> <p>There's one little annoyance using the <code>FlashWindowEx</code> function, when I clear the flashing of the window, it stays (in my case WinXP) orange (not flashing).</p> <p><a href="https://i.stack.imgur.com/GOS2r.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GOS2r.gif" alt="" /></a></p> <pre><code>[Flags] public enum FlashMode { /// &lt;summary&gt; /// Stop flashing. The system restores the window to its original state. /// &lt;/summary&gt; FLASHW_STOP = 0, /// &lt;summary&gt; /// Flash the window caption. /// &lt;/summary&gt; FLASHW_CAPTION = 1, /// &lt;summary&gt; /// Flash the taskbar button. /// &lt;/summary&gt; FLASHW_TRAY = 2, /// &lt;summary&gt; /// Flash both the window caption and taskbar button. /// This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags. /// &lt;/summary&gt; FLASHW_ALL = 3, /// &lt;summary&gt; /// Flash continuously, until the FLASHW_STOP flag is set. /// &lt;/summary&gt; FLASHW_TIMER = 4, /// &lt;summary&gt; /// Flash continuously until the window comes to the foreground. /// &lt;/summary&gt; FLASHW_TIMERNOFG = 12 } public static bool FlashWindowEx(IntPtr hWnd, FlashMode fm) { FLASHWINFO fInfo = new FLASHWINFO(); fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo)); fInfo.hwnd = hWnd; fInfo.dwFlags = (UInt32)fm; fInfo.uCount = UInt32.MaxValue; fInfo.dwTimeout = 0; return FlashWindowEx(ref fInfo); } [StructLayout(LayoutKind.Sequential)] public struct FLASHWINFO { public UInt32 cbSize; public IntPtr hwnd; public UInt32 dwFlags; public UInt32 uCount; public UInt32 dwTimeout; } </code></pre> <p>In my case I use <code>FLASHW_TRAY</code> to start flashing and <code>FLASHW_STOP</code> to stop the flashing.</p> <p>Am I doing something wrong or is this a known bug of WinXP and is there a fix for it?</p>
<p>Behaviour is the same when a window finishes flashing for as long as it's supposed to: the taskbar button stays coloured. I don't think this is a bug. If you think about it, when you use <code>FLASHW_STOP</code>, the flashing does in fact stop, but the point of the flashing is to get the user's attention. The button stays coloured because the user still may not have looked down and discovered <em>which</em> window was trying to get her attention. Keeping the button coloured keeps that information available.</p>
<p>Just set uCount to 0 to stop the flashing.</p>
4,199
<p>I've been working on a project that accesses the WMI to get information about the software installed on a user's machine. We've been querying Win32_Product only to find that it doesn't exist in 64-bit versions of Windows because it's an <a href="http://msdn.microsoft.com/en-us/library/aa392726(VS.85).aspx" rel="nofollow noreferrer">"optional component"</a>.</p> <p>I know there are a lot of really good alternatives to querying the WMI for this information, but I've got a bit of a <a href="http://www.codeplex.com/linq2wmi" rel="nofollow noreferrer">vested interest</a> in finding out how well this is going to work out.</p> <p>What I want to know is if there's some kind of redistributable that can be packaged with our software to allow 64-bit users to get the WMI Installer Provider put onto their machines? Right now, they have to install it manually and the installation requires they have their Windows disc handy.</p> <p>Edit:</p> <blockquote> <p>You didn't mention for what OS, but the WMI Redistributable Components version 1.0 definitely exists.</p> </blockquote> <p>For Operation System, we've been using .NET 3.5 so we need packages that will work on XP64 and 64bit versions of Windows Vista.</p>
<p>You didn't mention for what OS, but the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=013BB284-3946-44A9-AC3C-BF2A569EAA72&amp;displaylang=en" rel="nofollow noreferrer" title="Microsoft Download Center">WMI Redistributable Components version 1.0</a> definitely exists.</p> <p>For Windows Server 2003, the WMI SDK and redistributables are part of the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&amp;displaylang=en" rel="nofollow noreferrer" title="Windows Server 2003 SDK Full Download">Server SDK</a></p> <p><em>I believe</em> that the same is true for the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&amp;displaylang=en" rel="nofollow noreferrer" title="Microsoft Download Center">Server 2008 SDK</a></p>
<p>Wouldn't the normal approach for a Windows component be that the administrators of a set of servers use whatever their local software push technology (i.e. SMS) to ensure that component is installed? This is not that uncommon of a requirement for the remote management of servers via WMI.</p> <p>By the way, the WMI Installer Provider is not provided in the Standard Edition of the server products, but it is in the Enterprise Edition. So, Windows 2003 Server will not have this installed by default, but Windows 2003 Server Enterprise (and DataCenter) will.</p> <p>This answer does imply that you are putting the burden of installation back on your user base, but for Windows administrators this should not be any issue.</p>
2,581
<p>I've just started developing an ExtJS application that I plan to support with a very lightweight JSON PHP service. Other than that, it will be standalone. My question is, what is the best way to organize the files and classes that will inevitably come into existence? Anyone have any experience with large ExtJS projects (several thousand lines). ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>I would start here <a href="http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/" rel="noreferrer">http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/</a></p> <p>This site gives a good introductory overview of how to structure your application.</p> <p>We are currently using these ideas in two of our ASP.NET MVC / ExtJS applications.</p>
<p>When starting new big project, I decided to make it modular. Usually, in big projects not all modules are used by a particular user, so I load them on demand. F.e., if a project would have 50+ modules, the big probability is that user is working only with 10-. </p> <p>Such architecture lets you to have the initial code relatively small.</p> <p>Modules are stored on the server and loaded by AJAX call, eval'uating the responseText in AJAX callback. The only issue with this, you must keep track on module dependencies, which could be stored inside modules as well. I have a class called Module, and I check every new module instance for existance within the task. If it doesn't yet exist, I load it from the server.</p>
8,856
<p>I would like to enable/disable some code based on a custom solution configuration I added in Visual Studio. How do I check this value at runtime?</p>
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx" rel="noreferrer">precompiler directives</a> within Visual Studio. The #if directive will allow you to determine if you are going to include code or not based on your custom solution configuration.</p>
<p>I'm not sure if you can figure out the exact name of the build configuration. Howerver, if you use Debug.Assert(...), that code will only be run when you compile in debug mode. Not sure it that helps you at all.</p>
5,144
<p>What should every WPF developer know?</p> <p><strong>Entry Level</strong></p> <ul> <li>Strong .NET 2.0 Background &amp; willing to learn!</li> <li>Explain dependency properties?</li> <li>What's a style?</li> <li>What's a template?</li> <li>Binding</li> <li>Differences between base classes: Visual, UIElement, FrameworkElement, Control</li> <li>Visual vs Logical tree?</li> <li>Property Change Notification (INotifyPropertyChange and ObservableCollection) </li> <li>ResourceDictionary - Added by a7an</li> <li>UserControls - Added by a7an</li> <li>difference between bubble and tunnel routing strategies - added by Carlo</li> <li>Why did Microsoft introduce yet another markup language?</li> <li>XAML</li> </ul> <p><strong>Mid-level</strong></p> <ul> <li>Routed Events &amp; Commands</li> <li>Converters - Added by Artur Carvalho</li> <li>Explain WPF's 2-pass layout engine?</li> <li>How to implement a panel?</li> <li>Interoperability (WPF/WinForms)</li> <li><a href="http://en.wikipedia.org/wiki/Microsoft_Expression_Blend" rel="noreferrer">Blend</a>/<a href="http://en.wikipedia.org/wiki/TransGaming_Technologies#Cider" rel="noreferrer">Cider</a> - Added by a7an</li> <li>Animations and Storyboarding</li> <li><a href="http://en.wikipedia.org/wiki/ClickOnce" rel="noreferrer">ClickOnce Deployment</a></li> <li>Skinning/Themeing</li> <li>Custom Controls</li> <li>How can worker threads update the UI?</li> <li>DataTemplate vs HierarchicalDataTemplate</li> <li>ItemsControl vs ItemsPresenter vs ContentControl vs ContentPresenter</li> <li>Different types of Triggers</li> </ul> <p><strong>Senior</strong></p> <ul> <li>Example of attached behavior?</li> <li>What is PRISM,CAL &amp; CAG?</li> <li>How can worker threads update the UI?</li> <li>WPF 3D - Added by a7an</li> <li>Differences between Silverlight 2 and WPF</li> <li>MVVM/MVP - Added by a7an</li> <li>WPF Performance tuning</li> <li>Pixel Shaders</li> <li>Purpose of Freezables</li> </ul> <p>Any other <s>"trick"</s> questions to ask?</p> <p>Do you expect your WPF developer to know blend?</p>
<p>I'd put binding and converters at entry level, since that is how you spend a lot of time in WPF.</p>
<p>I think lifecycle of WPF application - from creation to runtime should be included in the Beginner level of questions. Without knowing it, its hard to believe one is a real WPF dev.</p>
8,316
<p>I recently encountered a problem where a value was null if accessed with Request.Form but fine if retrieved with Request.Params. What are the differences between these methods that could cause this?</p>
<p>Request.Form only includes variables posted through a form, while Request.Params includes both posted form variables and get variables specified as URL parameters.</p>
<p>The reason was that the value I was retrieving was from a form element, but the submit was done through a link + JQuery, not through a form button submit.</p>
2,756
<p>I have a model of an eye that I custom made in <strong>Blender 2.83</strong> that when printed only creates <strong>roughness</strong> on the printed object near where I had the supports. <strong>The supports are not the cause of the roughness</strong> (at least not completely) since the supports don't even touch the parts of the print where the majority of the roughness and bumps are (<strong>refer to my photos</strong> of the print)</p> <p><strong>The roughness is only near the bottom part of the sphere as it prints upwards (refer to photos)</strong></p> <p>What I'm looking for is a technique or any suggestions for printing this without the roughness so it's smooth like in the rest of the print. I'm also curious <em>what</em> is causing the roughness.</p> <hr /> <p><strong>Eye Model in Blender</strong></p> <p><a href="https://i.stack.imgur.com/FNlOr.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FNlOr.gif" alt="Eye model in blender" /></a></p> <p><strong>Blender Scale Ratio:</strong> 0.001</p> <p><strong>Blender Units:</strong> mm</p> <hr /> <p><strong>Eye Model in Prusa Slicer</strong></p> <p>Layer Gif</p> <p><a href="https://i.stack.imgur.com/4pluI.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4pluI.gif" alt="Eye Model in Prusa Slicer" /></a></p> <p>Prusa Slicer Main Settings (Higher Res)</p> <p><a href="https://i.stack.imgur.com/0gEV0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0gEV0.jpg" alt="Prusa Slicer Main Settings (Higher Res)" /></a></p> <p>Variable Layer Heights For Smoothness</p> <p><a href="https://i.stack.imgur.com/ggRpk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ggRpk.png" alt="Variable Layer Heights For Smoothness" /></a></p> <hr /> <p><strong>Eye Model Prints Photos</strong></p> <p>Eye Model Small Version 3D Print (Notice it's <strong>smooth</strong> on top of print)</p> <p><a href="https://i.stack.imgur.com/BA6tY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BA6tY.jpg" alt="Eye Model Small Version 3D Print" /></a></p> <p>Eye Model Small Version 3D Print <strong>Trouble Area</strong></p> <p><a href="https://i.stack.imgur.com/e8pa6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e8pa6.jpg" alt="Eye Model Small Version 3D Print Trouble Area" /></a></p> <p>Eye Model Small &amp; Large Version With Support (Notice <strong>roughness</strong> on the sphere)</p> <p><a href="https://i.stack.imgur.com/4lXuB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4lXuB.jpg" alt="Eye Model Small &amp; Large Version With Support" /></a></p> <p>Example of Support Used On Small Print</p> <p><a href="https://i.stack.imgur.com/OHuyp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OHuyp.jpg" alt="Example of Support Used On Small Print" /></a></p> <p>Smooth on inside of print</p> <p><a href="https://i.stack.imgur.com/fKor2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fKor2.jpg" alt="Smooth on Inside" /></a></p> <hr /> <p><strong>--------- Print Details ---------</strong></p> <p><strong>Printer:</strong> Prusa i3 MK3s</p> <p><strong>Filament:</strong> PLA Galaxy Silver (Prusa Reserach)</p> <p><strong>Slicer Software:</strong> Prusa Slicer</p> <p><strong>Print Temperature First Layer</strong>: 205 degrees</p> <p><strong>Print Temperature Other Layers</strong>: 190 degrees</p> <p><strong>Notes:</strong> The suggested temperature for the filament is 205-215, I've adjusted after careful calibration given my environment to a lower temperature to reduce stringing. I created a tower at different temperatures and discovered 190 was the perfect setting to reduce stringing in my case with this material. Refer to my screenshot below. <strong>I do not think temperature has anything to do with this since the print is smooth inside and near the top without any issues</strong>.</p> <p><strong>Temperature Tower Test For Filament Photo</strong>:</p> <p>(Note stringing in the cone test areas at 225 to 205)</p> <p><a href="https://i.stack.imgur.com/4i87u.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4i87u.jpg" alt="Temperature Tower" /></a></p> <hr /> <p>--------- <strong>Prusa Slicer Settings Photos</strong> ---------</p> <p>Filament settings</p> <p><a href="https://i.stack.imgur.com/QH8q3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QH8q3.png" alt="filament settings" /></a></p> <p>Extruder Settings</p> <p><a href="https://i.stack.imgur.com/90NXg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/90NXg.png" alt="extruder settings" /></a></p> <p>Support Settings</p> <p><a href="https://i.stack.imgur.com/UaBv4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UaBv4.png" alt="Support Settings" /></a></p>
<p>While Trish is completely right that the roughness can't be completely eliminated (you can't print a perfect spherical surface with discrete layers), the situation can be improved dramatically. The most telling photo in your question is the one of the removed support structure.</p> <p>The part of your sphere that's seriously rough is all severe overhang. In this region, the outer wall of layer N+1 barely overlaps the outer wall of layer N, if at all, and without support would be printed mostly or entirely over thin air, failing to attach to anything and sagging/curling down randomly according to tensions in the extruded material, air currents, etc.</p> <p>Now, with support material that's not entirely the case. Every so often (looks like a 2 mm grid) there are support lines under the overhanging outer wall. These will anchor it every so often and keep it from curling or sagging too much, but they don't actually constrain it to the place the slicer wanted the wall to go, and they don't provide a surface for the extruded material to press against to get the desired (e.g. 0.4 mm wide by 0.1 mm thick) extrusion cross section; instead the cross section will tend to be circular as a result of tensions within the molten material.</p> <p>In order to get a decent surface over support material, you need what slicers call &quot;Support Interface&quot; or &quot;Support Roof&quot; (these are the names Cura uses; I suspect it's similar in Prusa Slicer). This feature builds a top surface as part of the support material itself for the supported part of the model to rest upon and press against. Of course that can make support harder (potentially a lot harder) to remove, and depends on tuning the Z distance between the model and the support as a tradeoff between quality and difficulty of removal, but it should get you much better results.</p>
<p>I’ve noticed the best way to get it smooth without support is to make the printer print the inner parts of the model first. That way it gives the hanging layer something to hold on to. I turn my window ac unit up to high aim it at the printer so it cools the filament quickly. Next you’re going to want to mess around with the extruder heat. Try to get it as low as possible but watch out for the good gooey bad gooey range. If the first overhanging layer is close to the bed turn the bed heat off. Then tinker with the flow try to get it low but not super low I go as low as 70 <img src="https://i.stack.imgur.com/3nCLO.jpg" alt="enter image description here" /></p>
1,691
<p>What does the pink color in Slic3r preview mean? Yellow is my model, green is support, and pink is..?</p> <p>If the pink color is some kind of warning, how do I fix it?</p> <p><a href="https://i.stack.imgur.com/2PIRU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2PIRU.jpg" alt="Illustration from preview"></a></p>
<p>In slic3r preview, salmon (pink) represents infill, yellow represents perimeters, and green represents support material, including skirt and brim.</p>
<p>Having had direct experience with Slic3r, I can offer up this information. Your model is composed of bottom layers, top layers, outside layers, infill, rafts, brims and perhaps something I've missed.</p> <p>The program provides for color coding of these features. In the case of your image, the pink represents a top layer, but may also represent a type of infill, depending on "context."</p> <p>Consider to slice the model, select the preview tab, which you have showing here, then using the slider control to the right of the image window. As you move it from bottom to top, you can observe the construction of the model and each feature as it appears, layer by layer.</p>
569
<p>Let's say that you want to output or concat strings. Which of the following styles do you prefer?</p> <ul> <li><p><code>var p = new { FirstName = "Bill", LastName = "Gates" };</code></p></li> <li><p><code>Console.WriteLine("{0} {1}", p.FirstName, p.LastName);</code></p></li> <li><p><code>Console.WriteLine(p.FirstName + " " + p.LastName);</code></p></li> </ul> <p>Do you rather use format or do you simply concat strings? What is your favorite? Is one of these hurting your eyes?</p> <p>Do you have any rational arguments to use one and not the other?</p> <p>I'd go for the second one.</p>
<p>Try this code.</p> <p>It's a slightly modified version of your code.<BR></p> <ol> <li>I removed Console.WriteLine as it's probably a few orders of magnitude slower than what I'm trying to measure.<BR></li> <li>I'm starting the Stopwatch before the loop and stopping it right after, this way I'm not losing precision if the function takes for example 26.4 ticks to execute. <BR></li> <li>The way you divided the result by some iterations was wrong. See what happens if you have 1,000 milliseconds and 100 milliseconds. In both situations, you will get 0 ms after dividing it by 1,000,000.</li> </ol> <p>Code:</p> <pre><code>Stopwatch s = new Stopwatch(); var p = new { FirstName = &quot;Bill&quot;, LastName = &quot;Gates&quot; }; int n = 1000000; long fElapsedMilliseconds = 0, fElapsedTicks = 0, cElapsedMilliseconds = 0, cElapsedTicks = 0; string result; s.Start(); for (var i = 0; i &lt; n; i++) result = (p.FirstName + &quot; &quot; + p.LastName); s.Stop(); cElapsedMilliseconds = s.ElapsedMilliseconds; cElapsedTicks = s.ElapsedTicks; s.Reset(); s.Start(); for (var i = 0; i &lt; n; i++) result = string.Format(&quot;{0} {1}&quot;, p.FirstName, p.LastName); s.Stop(); fElapsedMilliseconds = s.ElapsedMilliseconds; fElapsedTicks = s.ElapsedTicks; s.Reset(); Console.Clear(); Console.WriteLine(n.ToString()+&quot; x result = string.Format(\&quot;{0} {1}\&quot;, p.FirstName, p.LastName); took: &quot; + (fElapsedMilliseconds) + &quot;ms - &quot; + (fElapsedTicks) + &quot; ticks&quot;); Console.WriteLine(n.ToString() + &quot; x result = (p.FirstName + \&quot; \&quot; + p.LastName); took: &quot; + (cElapsedMilliseconds) + &quot;ms - &quot; + (cElapsedTicks) + &quot; ticks&quot;); Thread.Sleep(4000); </code></pre> <p>Those are my results:</p> <blockquote> <p>1000000 x result = string.Format(&quot;{0} {1}&quot;, p.FirstName, p.LastName); took: 618ms - 2213706 ticks<br /> 1000000 x result = (p.FirstName + &quot; &quot; + p.LastName); took: 166ms - 595610 ticks</p> </blockquote>
<p>Actually, I ran these tests yesterday, but it was getting late so I didnt put my responses.</p> <p>The bottom line seems that they take both the same time on average. I did the test over 100000 iterations.</p> <p>I'll try with StringBuilder as well, and I'll post the code and results when I get home.</p>
3,713
<p>I have a query that looks like this:</p> <pre><code>public IList&lt;Post&gt; FetchLatestOrders(int pageIndex, int recordCount) { DatabaseDataContext db = new DatabaseDataContext(); return (from o in db.Orders orderby o.CreatedDate descending select o) .Skip(pageIndex * recordCount) .Take(recordCount) .ToList(); } </code></pre> <p>I need to print the information of the order and the user who created it:</p> <pre><code>foreach (var o in FetchLatestOrders(0, 10)) { Console.WriteLine("{0} {1}", o.Code, o.Customer.Name); } </code></pre> <p>This produces a SQL query to bring the orders and one query for each order to bring the customer. Is it possible to optimize the query so that it brings the orders and it's customer in one SQL query?</p> <p>Thanks</p> <p>UDPATE: By suggestion of sirrocco I changed the query like this and it works. Only one select query is generated:</p> <pre><code>public IList&lt;Post&gt; FetchLatestOrders(int pageIndex, int recordCount) { var options = new DataLoadOptions(); options.LoadWith&lt;Post&gt;(o =&gt; o.Customer); using (var db = new DatabaseDataContext()) { db.LoadOptions = options; return (from o in db.Orders orderby o.CreatedDate descending select o) .Skip(pageIndex * recordCount) .Take(recordCount) .ToList(); } } </code></pre> <p>Thanks sirrocco.</p>
<p>Something else you can do is EagerLoading. In Linq2SQL you can use LoadOptions : <a href="http://oakleafblog.blogspot.com/2007/08/linq-to-sql-query-execution-with.html" rel="nofollow noreferrer">More on LoadOptions</a> One VERY weird thing about L2S is that you can set LoadOptions only before the first query is sent to the Database.</p>
<p>you might want to look into using compiled queries</p> <p>have a look at <a href="http://www.3devs.com/?p=3" rel="nofollow noreferrer">http://www.3devs.com/?p=3</a></p>
7,288
<p>From a web developer point of view, what changes are expected in the development arena when Google Chrome is released?</p> <p>Are the developments powerful enough to make another revolution in the web? Will the way we see web programming change?</p> <p>Or is it just another web browser?</p>
<p>I think this is just another web browser. The most impact I expect to be improved Javascript performance, and the usability perspective. The first will benefit developers, especially when using Google Gears. I think the users will benefit the most from an enhanced user experience, the safety features, and ease of use.</p> <p>I can only hope other browser vendors (MS) will follow Mozilla and Google to create a faster Javascript implementation, since this is the only thing that can truly impact web development.</p>
<p>@bpapa</p> <blockquote> <p>It's just another web browser that very few people are going to use because there are already 4 major browsers out there that work just fine for most people. It doesn't have the extensions like Firefox,</p> </blockquote> <p>Actually, it is pretty clear that it has a plugin architecture</p> <blockquote> <p>it doesn't have browser sync with an iPhone like Safari, it doesn't come with your computer like IE, and it doesn't... well I don't know what Opera does that makes it stand out but I don't think Chrome has it.</p> </blockquote> <p>"I don't know what Opera has, but this piece of software that I've never touched clearly doesn't have it"... what??</p> <blockquote> <p>Another reason why I don't see it taking off - since it's not on OS X a lot of tech people aren't going to be using it.</p> </blockquote> <p>Did you miss the part where the Linux and OS X distros are coming right behind Windows?</p>
6,091
<p>Does anyone know of anywhere I can find actual code examples of Software Phase Locked Loops (SPLLs) ? </p> <p>I need an SPLL that can track a PSK modulated signal that is somewhere between 1.1 KHz and 1.3 KHz. A Google search brings up plenty of academic papers and patents but nothing usable. Even a trip to the University library that contains a shelf full of books on hardware PLL's there was only a single chapter in one book on SPLLs and that was more theoretical than practical.</p> <p>Thanks for your time.</p> <p>Ian</p>
<p>I suppose this is probably too late to help you (what did you end up doing?) but it may help the next guy.</p> <p>Here's a golfed example of a software phase-locked loop I just wrote in one line of C, which will sing along with you:</p> <pre><code>main(a,b){for(;;)a+=((b+=16+a/1024)&amp;256?1:-1)*getchar()-a/512,putchar(b);} </code></pre> <p>I present this tiny golfed version first in order to convince you that software phase-locked loops are actually fairly simple, as software goes, although they can be tricky.</p> <p>If you feed it 8-bit linear samples on stdin, it will produce 8-bit samples of a sawtooth wave attempting to track one octave higher on stdout. At 8000 samples per second, it tracks frequencies in the neighborhood of 250Hz, just above B below middle C. On Linux you can do this by typing <code>arecord | ./pll | aplay</code>. The low 9 bits of <code>b</code> are the oscillator (what might be a VCO in a hardware implementation), which generates a square wave (the 1 or -1) which gets multiplied by the input waveform (<code>getchar()</code>) to produce the output of the phase detector. That output is then low-pass filtered into <code>a</code> to produce the smoothed phase error signal which is used to adjust the oscillation frequency of <code>b</code> to push <code>a</code> toward 0. The natural frequency of the square wave, when <code>a == 0</code>, is for <code>b</code> to increment by 16 every sample, which increments it by 512 (a full cycle) every 32 samples. 32 samples at 8000 samples per second are 1/250 of a second, which is why the natural frequency is 250Hz.</p> <p>Then <code>putchar()</code> takes the low 8 bits of <code>b</code>, which make up a sawtooth wave at 500Hz or so, and spews them out as the output audio stream.</p> <p>There are several things missing from this simple example:</p> <ol> <li><p>It has no good <strong>way to detect lock</strong>. If you have silence, noise, or a strong pure 250Hz input tone, a will be roughly zero and b will be oscillating at its default frequency. Depending on your application, you might want to know whether you've found a signal or not! Camenzind's suggestion in chapter 12 of <a href="http://designinganalogchips.com/">Designing Analog Chips</a> is to feed a second "phase detector" 90° out of phase from the real phase detector; its smoothed output gives you the amplitude of the signal you've theoretically locked onto.</p></li> <li><p>The natural frequency of the oscillator is fixed and <strong>does not sweep</strong>. The <em>capture range</em> of a PLL, the interval of frequencies within which it will notice an oscillation if it's not currently locked onto one, is pretty narrow; its <em>lock range</em>, over which it will will range in order to follow the signal once it's locked on, is much larger. Because of this, it's common to sweep the PLL's frequency all over the range where you expect to find a signal until you get a lock, and then stop sweeping.</p></li> </ol> <p>The golfed version above is reduced from a <a href="http://lists.canonical.org/pipermail/kragen-hacks/2012-February/000534.html">much more readable example of a software phase-locked loop in C</a> that I wrote today, which does do lock detection but does not sweep. It needs about 100 CPU cycles per input sample per PLL on the Atom CPU in my netbook.</p> <p>I think that if I were in your situation, I would do the following (aside from obvious things like looking for someone who knows more about signal processing than I do, and generating test data). I probably wouldn't filter and downconvert the signal in a front end, since it's at such a low frequency already. Downconverting to a 200Hz-400Hz band hardly seems necessary. I suspect that PSK will bring up some new problems, since if the signal suddenly shifts phase by 90° or more, you lose the phase lock; but I suspect those problems will be easy to resolve, and it's hardly untrodden territory.</p>
<p>Have Matlab with Simulink? There are PLL demo files available at Matlab Central <a href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14868&amp;objectType=FILE#" rel="nofollow noreferrer">here</a>. Matlab's code generation capabilities might get you from there to a PLL written in C.</p>
6,057
<p>This is something I've ignored for awhile, but it keeps cropping up, and occasionally, if the filament snags real good, it can mess up a great print half way through, etc.</p> <p>Basically I have my filament spools hanging on a PVC pipe mounted directly above the printer, and the printer just sucks it in from the spool, but occasionally it becomes knotted at the spool, or becomes otherwise tangled.</p> <p>I'm thinking even if I completely unwrapped and rewrapped all of my spools so there was no trace of a tangle, what's to stop it from happening again? -- What's a good strategy for managing this kind of issue?</p> <p><strong>Edit:</strong> From some of the answers below, it seems that maybe the travel of my X carriage back and forth could be why my spools keep getting tangled. -- It looks like many people have their spools at about 90 degrees from mine (rotated relative to the Z axis of the printer), so that the travel of the X carriage won't have that affect. -- Also guides, etc are probably a good idea.</p> <p>Here's my current setup for reference (filament removed): <a href="https://i.stack.imgur.com/lsCOe.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/lsCOe.jpg" alt="enter image description here"></a></p>
<p>I had the same problem with my FFC dual.</p> <p>Consider using some kind of retaing clip to hold the spool in place, so it doesn't move back and forth on the post. This <a href="https://web.archive.org/web/20170127154947if_/http://www.thingiverse.com/thing:923340" rel="nofollow noreferrer">spool holder</a> worked for me:</p> <p><a href="https://i.stack.imgur.com/PGssw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PGssw.png" alt="enter image description here" /></a></p> <p>Another thing that can help is to make sure you are pulling the filament from the middle of the spool. <a href="http://www.thingiverse.com/thing:409297" rel="nofollow noreferrer">This</a> worked for me:</p> <p><a href="https://i.stack.imgur.com/pQ5aD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pQ5aD.png" alt="enter image description here" /></a></p>
<p>I used this solution, it makes a lot of sense, because I store the filament back in a box and the tip endup getting knotted.</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/lE9LchCtKL4?start=0"></iframe> </div></div></p>
397
<p>Is there a good <code>.Net</code> implementation of the <code>NNTP</code> protocol?</p>
<p>Try libraries like <a href="http://sourceforge.net/projects/dougnewsnntp/" rel="nofollow noreferrer">http://sourceforge.net/projects/dougnewsnntp/</a> and <a href="http://www.codeplex.com/nntpclientlib" rel="nofollow noreferrer">http://www.codeplex.com/nntpclientlib</a></p>
<p>There is a C# tutorial for reading posts using NNTP <a href="http://www.geekpedia.com/tutorial212_Developing-an-NNTP-Newsgroup-Reader.html" rel="nofollow noreferrer">here</a>. It should be enough to get you started but if you wish to start getting into processing binary posts, you're probably going to have to deal with some mime-type content too. I don't think this article covers that.</p>
9,000
<p>I originally asked <a href="https://stackoverflow.com/questions/46933/why-doesnt-inheritance-work-the-way-i-think-it-should-work">this question</a>, but in finding an answer, discovered that my original problem was a lack of support in C# for covariance on inherited methods' return types. After discovering that, I became curious as to what languages <em>do</em> support this feature.</p> <p>I will accept the answer of whoever can name the most.</p> <p><strong>EDIT</strong>: John Millikin correctly pointed out that lots of dynamic languages support this. To clarify: </p> <p><strong>I am only looking for static/strongly typed languages.</strong></p>
<ul> <li>C++</li> <li>Java</li> <li>REALbasic</li> <li>Eiffel</li> <li>Sather</li> <li>Modula-3</li> </ul>
<blockquote> <p>but I think thats what I'm asking for..or is it?</p> </blockquote> <p>I frankly don't know what you're asking. Java apparently has the same support for return-type covariance as C#, so if whatever you're looking for is lacking in C#, it's lacking in Java also.</p>
6,921
<p>I know this rather goes against the idea of enums, but is it possible to extend enums in C#/Java? I mean "extend" in both the sense of adding new values to an enum, but also in the OO sense of inheriting from an existing enum. </p> <p>I assume it's not possible in Java, as it only got them fairly recently (Java 5?). C# seems more forgiving of people that want to do crazy things, though, so I thought it might be possible some way. Presumably it could be hacked up via reflection (not that you'd every actually use that method)?</p> <p>I'm not necessarily interested in implementing any given method, it just provoked my curiosity when it occurred to me :-)</p>
<p>The reason you can't extend Enums is because it would lead to problems with polymorphism.</p> <p>Say you have an enum MyEnum with values A, B, and C , and extend it with value D as MyExtEnum.</p> <p>Suppose a method expects a myEnum value somewhere, for instance as a parameter. It should be legal to supply a MyExtEnum value, because it's a subtype, but now what are you going to do when it turns out the value is D?</p> <p>To eliminate this problem, extending enums is illegal</p>
<p>You can't inherit from/extend an enum, you can use <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx" rel="nofollow noreferrer">attributes</a> to <a href="http://blog.waynehartman.com/articles/84.aspx" rel="nofollow noreferrer">declare a description</a>. If you're looking for an integer value, that's built-in.</p>
7,912
<p>Currently I am setting up an application that can deploy other web apps to Tomcat 6 clusters. It is set up right now to have a one to one relationship between deployed web application and a cluster. My current reasoning for this is so that I can change the JVM args of the Tomcat server without disrupting other applications and so that the memory usage of the single application will not conflict with other applications.</p> <p>The question is, what is considered best practice in terms of tomcat instance clusters? Should you only have one application running per cluster or multiple applications like in a single tomcat instance environment? Or does this depend on the size of your application?</p> <p>Thank you</p>
<p>Divide your services by resource requirements at the very least. For example, if you are running a photo album site, separate your image download server from your image upload server. The download server will have many more requests, and because most people have a lower upload speed the upload server will have longer lasting connections. Similarly, and image manipulation server would probably have few connections, but it should fork off threads to perform the CPU intensive image manipulation tasks asynchronously from the web user interface.</p> <p>If you have the hardware to do it, it's a lot easier to manage many separate tomcat instances with one application each than a few instances with many applications.</p>
<p>Divide your services by resource requirements at the very least. For example, if you are running a photo album site, separate your image download server from your image upload server. The download server will have many more requests, and because most people have a lower upload speed the upload server will have longer lasting connections. Similarly, and image manipulation server would probably have few connections, but it should fork off threads to perform the CPU intensive image manipulation tasks asynchronously from the web user interface.</p> <p>If you have the hardware to do it, it's a lot easier to manage many separate tomcat instances with one application each than a few instances with many applications.</p>
5,017
<p>I've been using WatiN as a testing tool for my current project. Besides the minor bugs with the Test Recorder, I've been able to use it and automate a lot of my tests in conjunction with NUnit. Anyone else out there with experience with different tools they might suggest?</p>
<p>I have used:</p> <blockquote> <ul> <li><a href="http://watin.sourceforge.net/" rel="nofollow noreferrer">WatiN</a></li> <li><a href="http://www.automatedqa.com/products/testcomplete/index.asp" rel="nofollow noreferrer">AutomatedQA TestComplete</a></li> </ul> </blockquote> <p>All of them have had their purpose and are very good tools.</p>
<p>WatiN is excellent.</p> <p>I inherited <a href="http://en.wikipedia.org/wiki/HP_QuickTest_Professional" rel="nofollow noreferrer">Mercury Quicktest</a> for functional testing a while back. £30k for the licences and it was truly awful. We never got the same results twice (running on the exact same application). Their support was terrible. It stored tests as collections of encrypted binaries in folders called useful things like Action1 and Action2, so we couldn't source control it properly.</p> <p>No idea whether HP have improved it since they bought out Mercury, but why bother when WatiN is so good?</p>
3,577
<p>On a web page I want to dynamically render very basic flow diagrams, i.e. a few boxes joined by lines. Ideally the user could then click on one of these boxes (<code>DIVs</code>?) and be taken to a different page. Resorting to Flash seems like an overkill. Is anyone aware of any client-side (i.e. <code>server agnostic</code>) Javascript or <code>CSS library/technique</code> that may help achieve this?</p>
<p>Does the rendering have to be client side?</p> <p>If yes, you could try Processing:</p> <p><a href="http://ejohn.org/blog/processingjs/" rel="nofollow noreferrer">http://ejohn.org/blog/processingjs/</a></p> <p>If you can do it server side, then Graphviz is a good choice.</p> <p><a href="http://www.graphviz.org/" rel="nofollow noreferrer">http://www.graphviz.org/</a></p>
<p>This kind of flowchart can be accomplished using CSS, resorting to JavaScript graphing libraries (canvas) might be overkill. You may wish to checkout how some Genealogy sites do this to get a family tree.</p>
4,729
<p>I'm coming from a Rails background and doing some work on a ASP.NET project (not ASP MVC). Newbie question: what's the easiest way to make a custom editor for a table of records?</p> <p>For example: I have a bunch of data rows and want to change the "category" field on each -- maybe a dropdown, maybe a link, maybe the user types it in.</p> <p>In Rails, I'd iterate over the rows to build a table, and would have a form for each row. The form would have an input box or dropdown, and submit the data to a controller like "/item/edit/15?category=foo" where 15 was the itemID and the new category was "foo".</p> <p>I'm new to the ASP.NET model and am not sure of the "right" way to do this -- just the simplest way to get back the new data &amp; save it off. Would I make a custom control and append it to each row? Any help appreciated.</p>
<p>You can REALLY cheat nowadays and take a peek at the new Dynamic Data that comes with .NET 3.5 SP1. Scott Guthrie has a blog entry demoing on how quick and easy it'll flow for you here:</p> <p><a href="http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx</a></p> <p>Without getting THAT cutting edge, I'd use the XSD generator to generate a strongly typed DataSet that coincides with the table in question. This will also generate the TableAdapter you can use to do all your CRUD statements. </p> <p>From there, bind it to a DataGrid and leverage all the standard templates/events involved with that, such as EditIndex, SelectedIndex, RowEditing, RowUpdated, etc.</p> <p>I've been doing this since the early 1.0 days of .NET and this kind of functionality has only gotten more and more streamlined with every update of the Framework.</p> <p>EDIT: I want to give a quick nod to the Matt Berseth blog as well. I've been following a lot of his stuff for a while now and it is great!</p>
<p>There are a few controls that will do this for you, with varying levels of complexity depending on their relative flexibility. </p> <p>The traditional way to do this would be the DataGrid control, which gives you a table layout. If you want something with more flexibility in appearance, the DataList and ListView controls also have built-in support for editing, inserting or deleting fields as well.</p> <p>Check out <a href="http://mattberseth.com/" rel="nofollow noreferrer">Matt Berseth's blog</a> for some excellent examples of asp.net controls in action.</p>
3,381
<p>I am trying to build gdb for armv6 architecture. I will be compiling this package on a Fedora Linux-Intel x86 box. I read the process of installing the gdb, like</p> <ol> <li><p>Download the source pachage</p></li> <li><p>run <code>configure -host</code></p></li> <li><p><code>make</code></p></li> </ol> <p>But I got lost in the process because I was not able to make out what will be the host, target, needed for the <code>configure</code> script. </p> <p>I need to basically be able to debug programs running on armv6 architecture board which runs linux kernel 2.6.21.5-cfs-v19. The gdb executable which I intend to obtain after compilation of the source also needs to be able to run on above mentioned configuration.</p> <p>Now to get a working gdb executable for this configuration what steps should I follow? </p>
<p>We (www.rockbox.org) use the arm target for a whole batch of our currently working DAPS. The target we specify is usually arm-elf, rather than arm-linux.</p>
<p>target/host is usually the target tool chain you would be using (mostly arm-linux)</p>
9,562
<p>Looking to get your take on an automated testing tool (voting should bring good ones to the top)</p> <p>Ideal tool would:</p> <ul> <li>Eliminate the need to present a set of values to a method. </li> <li>employ techniques such as Interactive Exploratory Testing where the code is examined to determine what values are required to exercise all code paths. i.e. the unit tests for a method is determined by the complexity of the code</li> </ul> <p>For example, if a method checks that an integer argument is 123, at least 2 unit tests are generated: one where that argument is 123 and one where it is not.</p> <p>For Java my understanding is these are some options but not .NET</p> <ul> <li>TestGen4J</li> <li>AgitarOne</li> </ul> <p>Have heard of Pex - For .NET from Microsoft Research but this has a non-commercial license</p> <p>Thanks</p>
<p>I've tried some of these tools in other languages and IMHO they are almost a complete waste of time. Reason? They can't guess at the semantics of a method call in any meaningful way. There's a very good article about this <a href="http://blog.objectmentor.com/articles/2008/01/10/generated-tests-and-tdd" rel="nofollow noreferrer">here</a> -- well worth a read.</p>
<p>Another good tool that automatically generates unit tests is Randoop.</p> <p>Randoop is available for Java (<a href="http://mernst.github.io/randoop/" rel="nofollow">http://mernst.github.io/randoop/</a>) and for .NET (<a href="https://github.com/abb-iss/Randoop.NET" rel="nofollow">https://github.com/abb-iss/Randoop.NET</a>).</p> <p>Randoop has found previously unknown errors in widely-used libraries including Sun and IBM's JDKs and in core Microsoft .NET components.</p>
6,865
<p>Given a username and a password for a domain user, what would be the best way to authenticate that user programatically?</p>
<p>It appears that .NET 3.5 added a new namespace to deal with this issue - System.DirectoryServices.AccountManagement. Code sample is below:</p> <pre><code>Private Function ValidateExternalUser(ByVal username As String, ByVal password As String) As Boolean Using context As PrincipalContext = New PrincipalContext(ContextType.Domain, _defaultDomain) Return context.ValidateCredentials(username, password, ContextOptions.Negotiate) End Using End Function </code></pre> <p>The namespace also seems to provide a lot of methods for manipulating a domain account (changing passwords, expiring passwords, etc). </p>
<p>You can use some hacks to <strong>authenticate</strong> only.</p> <pre><code>Try Dim directoryEntry as New DirectoryEntry("LDAP://DomainController:389/dc=domain,dc=suffix", "username", "password") Dim temp as Object = directoryEntry.NativeObject return true Catch return false End Try </code></pre> <p>If the user is not valid, the directory entry NativeObject cannot be accessed and throws an exception. While this isn't the most efficient way (exceptions are evil, blah blah blah), it's quick and painless. This also has the super-cool advantage of working with all LDAP servers, not just AD.</p>
5,072
<p>I have a UserControl in my Asp.net project that has a public property. I do not want this property to show up in the Visual Studio Property Window when a user highlights an instance of the UserControl in the IDE. What attribute (or other method) should I use to prevent it from showing up?</p> <pre><code>class MyControl : System.Web.UI.UserControl { // Attribute to prevent property from showing in VS Property Window? public bool SampleProperty { get; set; } // other stuff } </code></pre>
<p>Use the following attribute ...</p> <pre><code>using System.ComponentModel; [Browsable(false)] public bool SampleProperty { get; set; } </code></pre> <p>In VB.net, this <a href="https://stackoverflow.com/questions/71440/set-a-usercontrol-property-to-not-show-up-in-vs-properties-window#71481">will be</a>:</p> <pre><code>&lt;System.ComponentModel.Browsable(False)&gt; </code></pre>
<p><a href="http://www.c-sharpcorner.com/UploadFile/mgold/PropertyGridInCSharp11302005004139AM/PropertyGridInCSharp.aspx" rel="nofollow noreferrer">Tons of attributes</a> out there to control how the PropertyGrid works.</p> <pre><code>[Browsable(false)] public bool HiddenProperty {get;set;} </code></pre>
9,694
<p>What is the best way of doing case-insensitive string comparison in C++ without transforming a string to all uppercase or all lowercase?</p> <p>Please indicate whether the methods are Unicode-friendly and how portable they are.</p>
<p>Boost includes a handy algorithm for this:</p> <pre><code>#include &lt;boost/algorithm/string.hpp&gt; // Or, for fewer header dependencies: //#include &lt;boost/algorithm/string/predicate.hpp&gt; std::string str1 = "hello, world!"; std::string str2 = "HELLO, WORLD!"; if (boost::iequals(str1, str2)) { // Strings are identical } </code></pre>
<pre class="lang-c++ prettyprint-override"><code>bool insensitive_c_compare(char A, char B){ static char mid_c = ('Z' + 'a') / 2 + 'Z'; static char up2lo = 'A' - 'a'; /// the offset between upper and lowers if ('a' &gt;= A and A &gt;= 'z' or 'A' &gt;= A and 'Z' &gt;= A) if ('a' &gt;= B and B &gt;= 'z' or 'A' &gt;= B and 'Z' &gt;= B) /// check that the character is infact a letter /// (trying to turn a 3 into an E would not be pretty!) { if (A &gt; mid_c and B &gt; mid_c or A &lt; mid_c and B &lt; mid_c) { return A == B; } else { if (A &gt; mid_c) A = A - 'a' + 'A'; if (B &gt; mid_c)/// convert all uppercase letters to a lowercase ones B = B - 'a' + 'A'; /// this could be changed to B = B + up2lo; return A == B; } } } </code></pre> <p>this could probably be made much more efficient, but here is a bulky version with all its bits bare.</p> <p>not all that portable, but works well with whatever is on my computer (no idea, I am of pictures not words)</p>
3,273
<p>Does C# have the notion of private / protected inheritance, and if not, why?</p> <p><strong>C++</strong></p> <pre> <code> class Foo : private Bar { public: ... }; </code> </pre> <p><strong>C#</strong></p> <pre> <code> public abstract NServlet class : private System.Web.UI.Page { // error "type expected" } </code> </pre> <p>I am implementing a "servlet like" concept in an .aspx page and I don't want the concrete class to have the ability to see the internals of the System.Web.UI.Page base.</p>
<p>C# allows public inheritance only. C++ allowed all three kinds. Public inheritance implied an "IS-A" type of relationship, and private inheritance implied a "Is-Implemented-In-Terms-Of" kind of relationship. Since layering (or composition) accomplished this in an arguably simpler fashion, private inheritance was only used when absolutely required by protected members or virtual functions required it - according to Scott Meyers in Effective C++, Item 42. </p> <p>My guess would be that the authors of C# did not feel this additional method of implementing one class in terms of another was necessary.</p>
<p>No it doesn't. What would the benefit be of allowing this type of restriction?</p>
5,312
<p>My website is entirely flash based, it moves around a 3D model which was given to me as chunks of video that I've converted to FLV files. I'm using the FLVPlayback component to control the video inside of my program. While running memory checks using System.totalMemory I've noticed that whenever a video is loaded, it will eat up a chunk of memory and even when I remove all the event listeners from it(they are all weakly referenced), remove the component from its parent, stop the video and null the component instance, it still will not give that memory back.</p> <p>This has been bothering me since I started working on this project because of the huge amount of video a user can potentially instantiate and load. Currently every video is loaded into a new FLVPlayback instance whenever it is required, but I have read that perhaps the best way to go about this problem is to simply have a global FLVPlayback instance and just reload the new video into the old instance, that way there would only be one FLVPlayback component in the application's memory.</p> <p>Has anyone else run into this problem as well? Have you found a better solution than using a global instance that you just re-use for every new video? </p>
<p>You can't help the memory problems much until Flash adds destructors and explicit object deletion, unfortunately. See this thread:</p> <p><a href="https://stackoverflow.com/questions/34/unloading-a-bytearray-in-actionscript-3">Unloading a ByteArray in Actionscript 3</a></p> <p>There's a limit to how much memory Flash applets can use; the GC seems to fire upon reaching that limit. I've seen my memory-easy applets use as much as ~200MB, just because they run for hours on end and the GC doesn't want to kick in.</p> <p>Oh, and I don't think using a single instance is an elegant solution, either. Currently I just write a dispose() function for my custom classes, waiting for some day when it can be turned into a proper destructor.</p>
<p>Unfortuantely, thats just the way flash handles it. Not particularly smart, but it works for most people.</p>
4,340
<p>I'd like to start 3d printing in wax.</p> <p>Is there a reasonably priced 3d printer that is capable of it?</p> <p>Am I right in assuming that all I need is to make my own filament and set extruder temperature correctly, or do I miss something?</p>
<p>Yes, with the proper equipment.</p> <p>Printing wax filament (at 51 seconds): <a href="https://youtu.be/tibkVZB_n9c?t=51s" rel="noreferrer">https://youtu.be/tibkVZB_n9c?t=51s</a></p> <p>There are also options for melting wax, filling a heated reservoir head, and printing with that. I recommend doing this with a cold ambient temperature, so that the wax solidifies quickly. There's no point in just printing a puddle. :)</p>
<p>Just make a silicone mold of any of your prints and pour you wax in the silicone,you silicone putty is pretty cheap so is wax ,no need to break the bank as printers have become less expensive and can do a pretty good job </p>
629
<p>How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL to https://) then Firefox does not send an If-Modified-Since header at all. Is this behavior mandated by the SSL spec or something?</p> <p>Here are some example HTTP and HTTPS request/response pairs, pulled using the Live HTTP Headers Firefox extension, with some differences in bold:</p> <p>HTTP request/response:</p> <pre>http://myserver.com:30000/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30000 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive <b>If-Modified-Since: Tue, 19 Aug 2008 15:57:30 GMT If-None-Match: "a0501d1-300a-454d22526ae80"-gzip Cache-Control: max-age=0</b> HTTP/1.x 304 Not Modified Date: Tue, 19 Aug 2008 15:59:23 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Connection: Keep-Alive Keep-Alive: timeout=5, max=99 Etag: "a0501d1-300a-454d22526ae80"-gzip </pre> <p>HTTPS request/response:</p> <pre>https://myserver.com:30001/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30001 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Date: Tue, 19 Aug 2008 16:00:14 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Last-Modified: Tue, 19 Aug 2008 15:57:30 GMT Etag: "a0501d1-300a-454d22526ae80"-gzip Accept-Ranges: bytes Content-Encoding: gzip Content-Length: 3766 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/javascript</pre> <p>UPDATE: Setting <code>browser.cache.disk_cache_ssl</code> to true did the trick (which is odd because, as Nickolay points out, there's still the memory cache). Adding a "Cache-control: public" header to the response also worked. Thanks!</p>
<blockquote> <p>HTTPS requests are not cached so sending an If-Modified-Since doesn't make any sense. The not caching is a security precaution.</p> </blockquote> <p>The not caching <strong>on disk</strong> is a security pre-caution, but it seems it indeed affects the <strong>If-Modified-Since</strong> behavior (glancing over the code).</p> <p>Try setting the Firefox preference (in about:config) <strong>browser.cache.disk_cache_ssl</strong> to <strong>true</strong>. If that helps, try sending <strong>Cache-Control: public</strong> header in your response.</p> <hr> <p><strong>UPDATE:</strong> Firefox behavior <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=531801" rel="noreferrer">was changed</a> for Gecko 2.0 (Firefox 4) -- HTTPS content is now cached.</p>
<p>HTTPS requests are not cached so sending an <strong>If-Modified-Since</strong> doesn't make any sense. The not caching is a security precaution.</p>
3,721
<p>I’m getting nothing but jams with a new BCN3D Sigma R19 printer, printing PLA at 195 °C, two brands (BCN’s own brand and Monoprice orange). 6.5 mm retraction, as used in BCN’s PLA profile. Using their fork of Cura. Full enclosure, but it gets maybe to 32 °C inside, just warm. It prints fine for a few layers, then it jams, usually partially-I caught it in the act and the extruder (the Bondtech dual gear Bowden extruder they switched to on this model) would make knocking sounds as it skipped steps, and the plastic under extrudes in spider webs. It would valiantly try to keep going, and just chew up the filament a little, then extrude, then skip, etc.</p> <p>After thinking the problem was the extruder, taking it apart, cleaning, trying a few different tensions on the hobbed gears, my attention shifted to the hotend. I did some cold pulls with nylon, and each time the nylon would come out with this frayed ring of plastic about 15 mm above the cone from the nozzle tip. It’s like it was a separate piece of plastic from the filament, but it seems like it constricts the path. <strong>This ring is about the depth where the heat break screws into the heat block.</strong> I supposed it could have started higher in the cool end and gotten pushed down? I suspect the grooves pressed into the filament by the Bondtech might be prone to hang up on this plastic gunk ring.</p> <p>Their hotend design is all metal, similar to the V6 (and apparently manufactured custom for them by E3D). Different, taller nozzle. It has a 30 mm fan blowing on the fins. There is no shroud on the fan, like the blue thing on the V6. The heat block is halfway up into the enclosed part with the cool end and fan. The fan blows on the heat break and the block.</p> <p>One of my cold pulls shows a little bulge, right about where I think the brass nozzle butts into the heat break steel piece. I’m wondering if there is a gap there that plastic melts into? They do an inconvenient thing where they sell the hotend as a whole piece for $125, and apparently you can’t unscrew the nozzle like a V6, people report the threads get ripped out of the heat block. All to say, it isn’t advised to completely disassemble the hotend.</p> <p>I thought the little fan might not be moving enough air across the cooling fins, so I tried to replace it with a new fan that moves more CFM, but it just screeches, it seems the fan isn’t really driven by 12 V, but maybe a PWM thing at 24 V. It was fine on 12 V DC when I bench tested it.</p> <p>I disassembled the cold end from the heat break, and verified it had thermal paste on the threads.</p> <p>My question is if anyone has experience with the gunk ring? Is my heat break getting cooled down into the heat block, or is heat creep getting up into the cool end? Or is the little gap or chamfer where the heat break meets the nozzle causing clogs? I can work on more cooling (faster fan), or design a shroud for the existing fan so it doesn’t cool the heat break+heater block), to just not sure which.</p> <p><a href="https://i.stack.imgur.com/eVGNx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eVGNx.jpg" alt="enter image description here" /></a></p> <p>EDIT: The filament partially jams (the extruder skips steps an knocks) even without printing, while just loading and purging over empty space, no retractions.</p>
<p>My first thought is heat creep. I've never seen a heatsink on the hot-end that couldn't use more air and a lower temperature. IF not heat creep, then perahps under-temperature.</p> <p>But, since you've worked on this issue without success, and the extruder skipping happens even wit a steady flow and no backpressure against the bed or part, perhaps we should look elsewhere.</p> <p>First thing to check would be the friction of the filament through the Bowden tube, and the attachment points. First, I would back off the extruder pressure, remove the nozzle, and see if you can easily and without jerks or hangups slide fresh filament past the extruder gears all the way through the hot end and out where the nozzle would be. You'll be doing this cold with the printer off. That should feel slick and easy. If you need to push with any significant force, find where the friction is happening and fix it.</p> <p>If it flow smoothly, try checking the extruder motor, the extruder gear, and if it is a dual gear system, check both of them. Try running the extruder (you'll need to hear the hot end) with no filament. Does everything turn easily? Try inserting filament in the extruder, pulling back on the filament, and extruding forward. Is the motion smooth? If not, check the gearing to see if a piece of filament or anything else if interfering with the motion.</p> <p>If you can check the motor current, see if it is running to spec on both coils, in all directions. You could have a problem with one half of one H-bridge.</p> <p>If you have two extruders, does the problem happen with both, or only one?</p> <p>I would still mostly suspect that heat creep, or under-temperature. 195 °C may be a little cool. My Prusa prints PLA at 215 °C. I have had heat creep problems with the Prusa, which I addressed by directing more air through the heat sink fins -- too much was passing around the sides of the heat sink without actually cooling it.</p>
<p>Is this what your hotends look like? <a href="https://i.stack.imgur.com/R6FKi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R6FKi.jpg" alt="enter image description here" /></a></p> <p>They look like Bowden tube extruders. Your images are consistent with heat creek for Bowden tub extruders. Can you print with the enclosure open to see if the problem is at least less?</p> <p>Here is a full discussion on heat creep.<br /> <a href="https://3dprinting.stackexchange.com/questions/15629/what-are-ways-to-avoid-heat-creep">What are ways to avoid heat creep?</a></p>
1,972
<p>When should I <strong>not</strong> use the ThreadPool in .Net?</p> <p>It looks like the best option is to use a ThreadPool, in which case, why is it not the only option?</p> <p>What are your experiences around this?</p>
<p>The only reason why I wouldn't use the <code>ThreadPool</code> for cheap multithreading is if I need to&hellip;</p> <ol> <li>interract with the method running (e.g., to kill it)</li> <li>run code on a <a href="http://msdn.microsoft.com/en-us/library/system.stathreadattribute.aspx" rel="nofollow noreferrer" title="Single-Threaded Apartment thread; see e.g. this MSDN reference page for STAThreadAttribute">STA thread</a> (this happened to me)</li> <li>keep the thread alive after my application has died (<code>ThreadPool</code> threads are background threads)</li> <li>in case I need to change the priority of the Thread. We can not change priority of threads in ThreadPool which is by default Normal.</li> </ol> <blockquote> <p><strong>P.S.:</strong> The MSDN article <a href="http://msdn.microsoft.com/en-us/library/0ka9477y.aspx" rel="nofollow noreferrer" title="The Managed Thread Pool (page on MSDN)"><em>"The Managed Thread Pool"</em></a> contains a section titled, <em>"When Not to Use Thread Pool Threads"</em>, with a very similar but slightly more complete list of possible reasons for not using the thread pool.</p> </blockquote> <p>There are lots of reasons why you would need to skip the <code>ThreadPool</code>, but if you don't know them then the <code>ThreadPool</code> should be good enough for you.</p> <p>Alternatively, look at the new <a href="https://learn.microsoft.com/en-us/visualstudio/extensibility/debugger/parallel-extension-internals-for-the-dotnet-framework" rel="nofollow noreferrer">Parallel Extensions Framework</a>, which has some neat stuff in there that may suit your needs without having to use the <code>ThreadPool</code>.</p>
<p>@Eric</p> <blockquote> <p>@Derek, I don't exactly agree with the scenario you use as an example. If you don't know exactly what's running on your machine and exactly how many total threads, handles, CPU time, RAM, etc, that your app will use under a certain amount of load, you are in trouble.</p> </blockquote> <p>Are you the only target customer for the programs you write? If not, you can't be certain about most of that. You generally have no idea when you write a program whether it will execute effectively solo, or if it will run on a webserver being hammered by a DDOS attack. You can't know how much CPU time you are going to have.</p> <p>Assuming your program's behavior changes based on input, it's rare to even know exactly how much memory or CPU time your program will consume. Sure, you should have a pretty good idea about how your program is going to behave, but most programs are never analyzed to determine exactly how much memory, how many handles, etc. will be used, because a full analysis is expensive. If you aren't writing real-time software, the payoff isn't worth the effort.</p> <p>In general, claiming to know exactly how your program will behave is far-fetched, and claiming to know everything about the machine approaches ludicrous.</p> <blockquote> <p>And to be honest, if you don't know exactly what method you should use: manual threads, thread pool, delegates, and how to implement it to do just what your application needs, you are in trouble.</p> </blockquote> <p>I don't fully disagree, but I don't really see how that's relevant. This site is here specifically because programmers don't always have all the answers.</p> <blockquote> <p>If your application is complex enough to require throttling the number of threads that you use, aren't you almost always going to want more control than what the framework gives you?</p> </blockquote> <p>No. If I need a thread pool, I will use the one that's provided, unless and until I find that it is not sufficient. I will not simply assume that the provided thread pool is insufficient for my needs without confirming that to be the case.</p> <blockquote> <p>I'm not speaking as someone with only theoretical knowledge here. I write and maintain high volume applications that make heavy use of multithreading, and I generally don't find the thread pool to be the correct answer.</p> </blockquote> <p>Most of my professional experience has been with multithreading and multiprocessing programs. I have often needed to roll my own solution as well. That doesn't mean that the thread pool isn't useful, or appropriate in many cases. The thread pool is built to handle worker threads. In cases where multiple worker threads are appropriate, the provided thread pool should should generally be the first approach.</p>
3,148
<p>I have a CC.NET project configured to call a common NAnt build file, which does some stuff, and then calls a child NAnt build file. The child build file name is specified by CC.NET to the command build file using a property.</p> <p>The hurdle that I am trying to get over is that the common build file log gets overwritten by the child build file log, so I don't get the common build log in the CC.NET build log.</p> <p>Anyone have any ideas on how to fix this?</p> <p>I thought about changing the child build's log, but reading up on the NAnt <code>&lt;nant&gt;</code> task doesn't allow me to change the child's output log.</p>
<p>Use the <a href="http://nant.sourceforge.net/release/0.85-rc1/help/tasks/nant.html" rel="nofollow noreferrer">nant task</a>, so you get one single build file.</p>
<p>Is there any way that you could <em>include</em> the child nant file as opposed to executing it as a full-fledged child nant project? This would prevent the overwrite, but not sure if it's possible in your situation.</p>
4,345
<p>Does anyone see server-side JavaScript taking off? There are a couple of implementations out there, but it all seems to be a bit of a stretch (as in, "doing it BECAUSE WE CAN" type of attitude). </p> <p>I'm curious to know if anyone actually writes JavaScript for the server-side and what their experiences with it have been to date.</p> <p>Also, which implementation is generally seen as the most stable?</p>
<p>I like to read Googler Steve Yegge's blog, and recently I came across <a href="http://steve-yegge.blogspot.com/2008/06/rhinos-and-tigers.html" rel="nofollow noreferrer" title="Rhinos and Tigers">this article of his</a> where he argues that <a href="http://www.mozilla.org/rhino" rel="nofollow noreferrer" title="Mozilla Rhino">Mozilla Rhino</a> is a good solution for server-side JS. It's a somewhat sloppy transcript, you might prefer to watch the <a href="http://sites.google.com/site/io/server-side-javascript-on-the-java-virtual-machine" rel="nofollow noreferrer" title="Google IO Talk">video of the talk</a>. It also offers a little bit of insight on why he thinks server-side JS is a good idea in the first place (or rather, why he thinks that it's a good idea to use a dynamic language to script Java). I thought the points he makes were convincing, so you might want to check it out.</p> <p>A while earlier, he also posted <a href="http://steve-yegge.blogspot.com/2008/05/dynamic-languages-strike-back.html" rel="nofollow noreferrer" title="Dynamic Languages Strike Back">something about dynamic languages in general</a> (he's a big fan of them), just in case you were wondering why to use JS at all.</p>
<p>I can't see most developers getting over their distaste for client-side JavaScript programming. I'd rather go to Java for server-side stuff before choosing JavaScript.</p>
3,810
<p>I need some software to explore and modify some SQLite databases. Does anything similar to SQL Server Management Studio or MySQLAdmin exist for it?</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/5817" rel="nofollow noreferrer">As a Firefox plugin</a> (aimed mainly at gears, but should work)</p> <p><a href="http://www.sqlitemanager.org" rel="nofollow noreferrer">As a (sucky) web based app</a></p> <p>And <a href="http://www.sqlite.org/cvstrac/wiki?p=ManagementTools" rel="nofollow noreferrer">a big list of management tools</a></p>
<p>I also discovered some SQLite software for Visual Studio at <a href="http://sqlite.phxsoftware.com/" rel="nofollow noreferrer">http://sqlite.phxsoftware.com/</a> which allows you to use the Visual Studio Server Explorer to create connections to SQLite databases.</p>
7,984
<p>I recently finished building my first printer. The only problem that I'm having is that the hotend is not getting hot enough to start printing with PLA (180 to 230 degrees celsius), the hotend getting hotter stops at 170 degrees. Please help I've been stuck on this problem for days. Thanks in advance.</p>
<p>Usually, this kind of problem is due to an issue with the control loop of the temperature. You can try to do <a href="http://reprap.org/wiki/PID_Tuning" rel="noreferrer">PID Tuning</a> by running the command <code>M303 E0 S200 C8</code>. This will heat up the hot end and cycle it around 200C a few times, and afterwards tell you Kp, Ki and Kd values which you need to enter into the PID settings of your firmware configuration, or store them in EEPROM using <code>M301</code>.</p> <p>If this does not solve the problem, then disconnect the heater cartridge and check its resistance with a multimeter. For a 12V system, it should not be higher than 6Ω (24Ω for a 24V system).</p> <p>If the heater cartridge is okay, then perhaps it is a problem with the power supply. While the hotend is heating up, measure the voltage across the heater cartridge. It should not be much less than the nominal 12V/24V your printer runs at. If it is, you may have a bad MOSFET or power supply.</p> <p>Finally, if you have a very powerful fan blowing on the hotend this can cause issues with heating up as well. Adding a fan shroud (or pointing the fan away from the nozzle and only at the print) can help with this.</p>
<p>There are software limits that might be set low by default depending on the software you are using. I know there is with Marlin.</p>
385
<p>This question is a follow up to my <a href="https://stackoverflow.com/questions/56279/export-aspx-to-html">previous question</a> about getting the HTML from an ASPX page. I decided to try using the webclient object, but the problem is that I get the login page's HTML because login is required. I tried "logging in" using the webclient object:</p> <pre><code>WebClient ww = new WebClient(); ww.DownloadString("Login.aspx?UserName=&amp;Password="); string html = ww.DownloadString("Internal.aspx"); </code></pre> <p>But I still get the login page all the time. I know that the username info is not stored in a cookie. I must be doing something wrong or leaving out an important part. Does anyone know what it could be?</p>
<p>Try setting the credentials property of the WebClient object</p> <pre><code>WebClient ww = new WebClient(); ww.Credentials = CredentialCache.DefaultCredentials; ww.DownloadString("Login.aspx?UserName=&amp;Password="); string html = ww.DownloadString("Internal.aspx"); </code></pre>
<p>@Fire Lancer: I asked myself that same question during my tests, so I checked, and it does work from a browser.</p>
8,635
<p>I have been working on a printer project that basically is a 2D printer (dot matrix type). We are using solenoids as actuators to make impressions on the paper. We are now in the process of designing custom software. But a problem that we have encountered is that we have no idea how to design software as we are a bunch of beginners in this field.</p> <p>An idea we are working on is based on position-acknowledge technique. In this technique the computer sends G-code to the controller. The controller after reaching the position defined in code sends an acknowledgement and the computer then sends the next signal. This is the model we are currently working on. </p> <ul> <li>Can anyone suggest any other ideas to make this work? </li> <li>Is Our approach right? </li> <li>Do 3D printers work using same technique?</li> </ul>
<p>3D printer firmware use gcode that is derived from CNC and no acknowledgment. They send movement commands to the stepper motors like <code>G1 X10 Y10</code> to move the printhead 10 mm along the X and Y.</p> <p>You could use a ready 3D printer firmware like Marlin on a 3d printer board and use the X-axis or extruder output to couple to your solenoid, sending a <code>G1 Z0.1</code> or <code>G1 E0.1</code>, which will actuate it for a short time. You might even use E and Z on different solenoids.</p>
<p>The CNC system, and simplifying intentionally, is divided into several steps:</p> <ol> <li><strong>Acquisition of the g-code</strong>: This depends on the platform, whether is a file from an USB flash-memory, network or direct input from the operator. G-code operations needs to be buffered in a quantity enough to allow some "look-ahead" in the program.</li> <li><strong>Parsing of the g-code</strong>: Parsing of any formal language is based on "formal grammars" theory <a href="https://en.wikipedia.org/wiki/Formal_grammar" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Formal_grammar</a>. Fortunately, g-code is one of the simplest grammar of the Chomsky hierarchy. Language parsing is a full topic in itself, and it follows lexical, syntactical and semantical analysis.</li> <li><p><strong>Driving</strong>: It exists several different strategies:</p> <ul> <li><strong>Open-loop vs closed loop</strong>: In closed-loop CNC, sensors provide a feedback from the movement, allowing the driver to fix deviations (e.g. no step lots). Those systems are more expensive and usually not available in cheap 3D printers. In open-loop CNC, the driver send signals and "hope" the machine will follow, this is the case of most cheap 3D-printers, where if you block the head, it will lose steps.</li> <li><strong>Synchronous vs asynchronous</strong> (not sure about this naming): In synchronous systems, the driver send a single step for each axis each loop (one step forward, no step, or one step backward for each of the x, y, z, a... axis). In each iteration, the driver establish which steps need to be activated and send it; the speed of the movement depends on how fast this loop is performed. In Asynchronous driving, the loop run at a specific speed and apply steps as needed to correct the distance between the previous/detected position and the expected position.</li> </ul></li> </ol> <p>Acquisition and parsing of g-code can be performed in soft real-time, however the driving needs hard real-time, which precision determine the maximum speed that your CNC can manage.</p> <p>The servos/steppers usually cannot manage infinite acceleration, this is why the system needs to read g-code instructions ahead to anticipate closed angles or changes in direction. It should then reduce the indicated speed down to something which allows the next instruction.</p> <p>I hope this give a quick introduction to the topic, obviously, each aspect needs further reading.</p>
1,176
<p>Is there a built in function in .NET 2.0 that will take two arrays and merge them into one array?</p> <p>The arrays are both of the same type. I'm getting these arrays from a widely used function within my code base and can't modify the function to return the data in a different format.</p> <p>I'm looking to avoid writing my own function to accomplish this if possible.</p>
<p>In C# 3.0 you can use LINQ's <a href="https://msdn.microsoft.com/en-us/library/vstudio/bb302894%28v=vs.100%29.aspx" rel="noreferrer">Concat</a> method to accomplish this easily:</p> <pre><code>int[] front = { 1, 2, 3, 4 }; int[] back = { 5, 6, 7, 8 }; int[] combined = front.Concat(back).ToArray(); </code></pre> <p>In C# 2.0 you don't have such a direct way, but Array.Copy is probably the best solution:</p> <pre><code>int[] front = { 1, 2, 3, 4 }; int[] back = { 5, 6, 7, 8 }; int[] combined = new int[front.Length + back.Length]; Array.Copy(front, combined, front.Length); Array.Copy(back, 0, combined, front.Length, back.Length); </code></pre> <p>This could easily be used to implement your own version of <code>Concat</code>.</p>
<p>Try this:</p> <pre><code>ArrayLIst al = new ArrayList(); al.AddRange(array_1); al.AddRange(array_2); al.AddRange(array_3); array_4 = al.ToArray(); </code></pre>
8,376
<p>Given a string like this:</p> <blockquote> <p>a,"string, with",various,"values, and some",quoted</p> </blockquote> <p>What is a good algorithm to split this based on commas while ignoring the commas inside the quoted sections?</p> <p>The output should be an array:</p> <blockquote> <p>[ "a", "string, with", "various", "values, and some", "quoted" ]</p> </blockquote>
<p>Looks like you've got some good answers here.</p> <p>For those of you looking to handle your own CSV file parsing, heed the advice from the experts and <a href="http://secretgeek.net/csv_trouble.asp" rel="noreferrer">Don't roll your own CSV parser</a>.</p> <p>Your first thought is, <em>"I need to handle commas inside of quotes."</em></p> <p>Your next thought will be, <em>"Oh, crap, I need to handle quotes inside of quotes. Escaped quotes. Double quotes. Single quotes..."</em></p> <p>It's a road to madness. Don't write your own. Find a library with an extensive unit test coverage that hits all the hard parts and has gone through hell for you. For .NET, use the free <a href="http://www.filehelpers.com/" rel="noreferrer">FileHelpers</a> library.</p>
<p>I use this to parse strings, not sure if it helps here; but with some minor modifications perhaps?</p> <pre><code>function getstringbetween($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $fullstring = "this is my [tag]dog[/tag]"; $parsed = getstringbetween($fullstring, "[tag]", "[/tag]"); echo $parsed; // (result = dog) </code></pre> <p>/mp</p>
2,802
<p>I've recently had to switch from Visual Studio to Eclipse CDT.<br> It would seem that Eclipse "workspaces" are not quite like VS solution files.<br> Eclipse workspaces use the <code>.metadata</code> folder for managing multiple projects, but there doesn't seem to be a simple distinction between user settings or IDE preferences and project/solution settings. </p> <p>What I want is a way to group a collection of related (and dependent) projects together and have that data live in source control without all the other user specific stuff that developers don't need to share. You know, like a <code>.sln</code> file in Visual Studio. </p> <p>Does Eclipse just not work this way? (And if not, then why not?)</p>
<p>Yes you are right eclipse does not manage projects in the same way VS does with solution files. However for putting a group of related projects into a VCS eclipse has the concept of a <em>Team Project Set</em> available in File->Export then under the Team folder there is Team Project Set.</p>
<p>I often find IDE's have a preferred way to work. Sure, you might be able to get the IDE to do it your way, but you'll probably end up fighting it all the way.</p> <p>Try to use your IDE like their makers intended you to. They have made presumptions on how you are supposed to do your work. They have optimized the user experience according to those presumptions.</p> <p>Go with the flow. Anything else will make you gnarly, bitter, wrinkly and give you gastly breath!</p> <p><strong>Corollary</strong>: If you can, choose the IDE that makes the same presumptions about workflow as you do!</p>
7,976
<p>I have developed some classes with similar behavior, they all implement the same interface. I implemented a factory that creates the appropriate object and returns the interface. I am writing a unit test for the factory. All you get back is an interface to the object. What is the best way to test that the factory has worked correctly?</p> <p>I would like to know the answer in Java, but if there is a solution that crosses languages I would like to know it.</p> <p>Number 2. in the answer, would be done like the other answer? If so I will mark the other answer accepted as well and reword my question to adress both a factory where an interface is returned and you have no clue what type of concrete class implemented the interface, and the case where you do know what concrete class was used.</p>
<p>Since I don't know how your factory method looks like, all I can advise right now is to </p> <ol> <li><p>Check to see the object is the correct concrete implementation you were looking for:</p> <pre><code>IMyInterface fromFactory = factory.create(...); Assert.assertTrue(fromFactory instanceof MyInterfaceImpl1); </code></pre></li> <li><p>You can check if the factory setup the concrete instances with valid instance variables.</p></li> </ol>
<pre><code>if (myNewObject instanceof CorrectClass) { /* pass test */ } </code></pre> <p><strong>update:</strong></p> <p>Don't know why this got marked down, so I'll expand it a bit...</p> <pre><code>public void doTest() { MyInterface inst = MyFactory.createAppropriateObject(); if (! inst instanceof ExpectedConcreteClass) { /* FAIL */ } } </code></pre>
5,796
<p>I have a simple type that explicitly implemets an Interface.</p> <pre><code>public interface IMessageHeader { string FromAddress { get; set; } string ToAddress { get; set; } } [Serializable] public class MessageHeader:IMessageHeader { private string from; private string to; [XmlAttribute("From")] string IMessageHeade.FromAddress { get { return this.from;} set { this.from = value;} } [XmlAttribute("To")] string IMessageHeade.ToAddress { get { return this.to;} set { this.to = value;} } } </code></pre> <p>Is there a way to Serialize and Deserialize objects of type IMessageHeader??</p> <p>I got the following error when tried</p> <p>"Cannot serialize interface IMessageHeader"</p>
<p>You cannot serialize IMessageHeader because you can't do Activator.CreateInstance(typeof(IMessageHeader)) which is what serialization is going to do under the covers. You need a concrete type.</p> <p>You can do typeof(MessageHeader) or you could say, have an instance of MessageHeader and do </p> <pre><code>XmlSerializer serializer = new XmlSerializer(instance.GetType()) </code></pre>
<p>You can create an abstract base class the implements IMessageHeader and also inherits MarshalByRefObject</p>
8,476
<p>I was just shopping for filament, and saw some glowing claims about PETG being as easy to work with as PLA, but as strong as ABS, and less brittle. Anyone know if that's actually true, or what the tradeoffs are?</p>
<p>PETG is great stuff to work with. It is stronger than ABS also. It prints slower than ABS and PLA. The formulas vary quite a bit from vendor to vendor. I have used 3 brands, and each of their properties vary. </p> <p>From my experience you do have to be careful with moisture. You'll be able to tell you have moisture in your filament if you start hearing a slight hissing and popping and an increased number of structural zits on the object. Moisture will also increase the problem listed in Mark's post below regarding the accumulation of filament on the nozzle.</p>
<p>I love PETG. When I first started I always used ABS because I thought it was the best and didn't see the point in using PLA. However, after a few years of playing around I no longer use ABS. I use PLA for when I am testing and PETG when I want to print something that will be used, ike parts or models. </p> <p>PETG is a little more expensive, however worth it, as it is strong and easy to use. I normally print at 220°C on the nozzle and 80°C for the bed.</p> <p>PETG has more flex to it so when you are printing parts it is less likely to break under pressure like ABS. </p>
160
<p>I'm trying to print with Laybrick and for the most part it is going. The problem lies with the top layer and gaps appearing. I've tried increasing the number of top layers but the gaps still appear. Any ideas what else I can try? </p> <p>I'm using Simplify3d. <a href="https://i.stack.imgur.com/Y05dR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Y05dR.jpg" alt="Image"></a></p>
<p>When using Simplify3D, you may try referring to their awesome troubleshooting guide: <a href="https://www.simplify3d.com/support/print-quality-troubleshooting/#holes-and-gaps-in-the-top-layers" rel="nofollow">https://www.simplify3d.com/support/print-quality-troubleshooting/#holes-and-gaps-in-the-top-layers</a> 3 reasons (from the guide) for gaps in the top layers:</p> <ol> <li><p>under-extrusion: you may try to increase extrusion multiplier to see if this helps</p></li> <li><p>low infill percentage: not likely in your case if increasing number of top layers did not help</p></li> <li><p>not enough top layers: you already tried increasing number of top layers.</p></li> </ol> <p>In addition to that, you may change certain parameters (such as extrusion multiplier) for a given number of layers by using Simplify3D features. It can be helpful to avoid problems to for the rest of the model.</p>
<p>When using Simplify3D, you may try referring to their awesome troubleshooting guide: <a href="https://www.simplify3d.com/support/print-quality-troubleshooting/#holes-and-gaps-in-the-top-layers" rel="nofollow">https://www.simplify3d.com/support/print-quality-troubleshooting/#holes-and-gaps-in-the-top-layers</a> 3 reasons (from the guide) for gaps in the top layers:</p> <ol> <li><p>under-extrusion: you may try to increase extrusion multiplier to see if this helps</p></li> <li><p>low infill percentage: not likely in your case if increasing number of top layers did not help</p></li> <li><p>not enough top layers: you already tried increasing number of top layers.</p></li> </ol> <p>In addition to that, you may change certain parameters (such as extrusion multiplier) for a given number of layers by using Simplify3D features. It can be helpful to avoid problems to for the rest of the model.</p>
393
<p>I'm trying to implement Drag &amp; Drop functionality with source being a TreeView control. When I initiate a drag on a node, I'm getting:</p> <p><em>Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))</em></p> <p>The ItemDrag handler (where the exception takes place), looks like:</p> <pre><code>private void treeView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { this.DoDragDrop(e.Item, DragDropEffects.Move); } </code></pre> <p>Does anyone know the root cause of this and how to remedy it? (.NET 2.0, Windows XP SP2)</p>
<p>In case it helps anyone else - I encountered this problem with the WPF TreeView (not Windows Forms as listed in the question) and the solution was simply to make sure to mark the event as handled in the drop event handler.</p> <pre><code> private void OnDrop(object sender, DragEventArgs e) { // Other logic... e.Handled = true; } </code></pre>
<p><strong><code>FORMATETC</code></strong> is a type of application clipboard, for lack of a better term. In order to pull off some of the visual tricks of draging around the tree node, it has to be copied into this clipboard with its source description. The source control loads its info into the <code>FORMATETC</code> clipboard and sends it to the target object. It looks like the error occurs on the drop and not on the drag. The <code>DV</code> in <code>DV_E_FORMATETC</code> typically indicates the error occurrs on the drop step.<br> The destination doesn't look like it likes what you are droping on it. The clipboard may be corrupt or the drop destination may not be configured to understand it. </p> <p>I recommend you try one of two things. </p> <ol> <li>Remove the original tree structure and destination. Dump your dlls. Close everything. Open up and put the treeview and destination back on the form. It may have just been poorly formed and not fully populating the <code>FORMATETC</code> structure.</li> <li>Try putting another treeview and droping to that. If you are droping to another tree and it works you know your oranges to oranges work and it isn't the treeview. It may be the destination if it is a grid or listview. You may need to change those structures to be able to receive the drop.</li> </ol> <p>Not that it helps but the structure is something like this: </p> <pre><code>typedef struct tagFORMATETC { CLIPFORMAT cfFormat; DVTARGETDEVICE *ptd; DWORD dwAspect; LONG lindex; DWORD tymed; } FORMATETC, *LPFORMATETC; </code></pre>
7,310
<p>I upgraded to an Mk9 dual extruder, and it came with thermocouples installed instead of the thermistors I had before. </p> <p>No matter what I did with the thermocouples, the indicated temperature jumped around by as much as 30C or more. In short, after several weeks of fiddling I never got the thermocouples to work well, and replaced them with thermistors, which have been fine.</p> <p>So my question is: what is required to get thermocouples to give reliable, consistent, accurate readings? Are they just incredibly touchy?</p> <p>Some things I tried include:</p> <ul> <li><p>Of course, one must add circuitry (typically a thermocouple amplifier board such as <a href="http://wiki.ultimaker.com/Thermocouple_Sensor_Board_v1">http://wiki.ultimaker.com/Thermocouple_Sensor_Board_v1</a>), to convert the tiny voltage differences to larger differences usable with Arduino or similar analog inputs.</p></li> <li><p>Place those boards close to the thermocouples, but far enough that they are at pretty stable temperature themselves.</p></li> <li><p>Have absolutely no wire extensions of splices, changes of wire types (material), etc.</p></li> <li><p>Avoid doing repeated measurements too fast.</p></li> <li><p>I replaced a thermocouple board with 5V through a potentiometer to the analog input pin, to rule out problems in the Arduino, pin configurations, or software, and got stable readings.</p></li> <li><p>I checked for shorts-to-ground from the heater block, both sides of the thermocouples, the heater itself, etc. None found.</p></li> <li><p>The thermocouple wires are surrounded by a braided shield (not common or shorted to either thermocouple wire); I tried grounding that at either end and at both ends, to the heat block, the printer frame, the power-supply ground, and the RAMPS board ground. These had various effects (sometimes large), but I couldn't find any configuration that made the readings stable (much less accurate!).</p></li> </ul> <p>Anything I'm missing?</p> <p>Thanks!</p> <p>Steve</p>
<p>Thermocouples work by passively generating VERY small voltages via the Seebeck effect -- usually a few tens of millivolts. They're literally just a pair of wires made from two different special alloys, electrically connected together at the "hot" end. That wire junction can be mounted inside whatever kind of attachment tip or lug is desired.</p> <p>The fact that they're very simple and passive devices makes them extremely precise and consistent between TCs of the same type, MUCH more so than thermistors. Any type-K thermocouple in the world will give you the same accurate output +/-1-2C or so. You can even cut a thermocouple in half, re-twist the ends of the wires together, and it'll still work! </p> <p>However, the very small (millivolts) signal they generate is quite susceptible to electrical noise and circuit design. The signal voltage has to be greatly amplified to be useful. So it doesn't take much EMR from your heater or stepper wires to interfere with the TC reading. A frequent problem with TC circuits in 3d printers is the dreaded GROUND LOOP -- if the "hot" tip is electrically connected to the hot block, voltage and current on the heater and motor wires can induce small currents through the TC wires that totally screw up the millivolt signal. The amplifier picks up these stray voltages and it throws off the temp read. So, there are some important guidelines for keeping noise out of the TC wires:</p> <ul> <li>The TC wires must be electrically insulated from the mounting hardware (eye lug, thermowell, whatever your extruder has). You can check this with a multimeter -- you want infinite / out of range resistance from the TC leads to the mounting tip and hot block. While you're at it, make sure your heater cartridge wires aren't shorting to the hot block -- that's unsafe and can also cause problems with TCs.</li> <li>Keep the two TC wires close together, and not immediately parallel to noise sources like PWM-controlled heaters or stepper wiring. If you must run the TC in a bundle with the other wires, TWIST the heater/stepper wiring pairs. (For steppers, twist each coil pair to a different pitch if possible. You don't need to twist the separate coil pairs to each other.) </li> </ul> <p>Another common issue with TC circuits is the COLD JUNCTION COMPENSATION. A thermocouple doesn't measure tip temperature, it measures the DIFFERENCE in temperature between the hot tip and the cold junction where the TC is connected to either the amp or copper wiring. The TC amp has an onboard thermistor that it uses to add the temp at the cold junction to the measured signal from the thermocouple. There are a few things you need to do to make sure the cold-junction compensation works properly:</p> <ul> <li>You should run TC wire all the way from the "hot" tip to the TC amp. You CAN splice it and install plugs, but only with more type-K TC wire and proper type-K thermocouple plugs. These use the same metal as the TC wire so they don't generate undesired junction voltages that interfere with the TC signal. If you splice copper wire between the TC and the amp, any temp differences along the copper will not be measured! This is a particularly big problem if you splice to copper inside a warm enclosure and then run copper to an amp outside the enclosure.</li> <li>The amp should not be super hot. The onboard thermistor is designed to accurately measure temperatures reasonably close to room temp, not hot-block temps. </li> <li>There should not be large temperature gradients near the amp or between the TC wire termination and the actual amp chip. Place the amp far enough away from the hot end and other heat sources (like stepper motors) that it isn't experiencing weird temp profiles.</li> </ul> <p>If you do the above, the TC will output a good signal, and the amp will read it properly. But there's one more hitch. The mainboard has to know how to understand the amp's output. 3D printer control boards that are designed exclusively for TCs, like Mightyboards, usually use digital communication between the amp and the main control chip (MCU). This is high-reliability and does not require any special firmware configuration -- support is baked in. But if you're strapping an external TC amp onto a board that is expecting thermistors, <strong>you will have to tell the firmware how to read the signal from the amp.</strong> The most common technique is for the amp to output a linear voltage signal to the MCU's normal thermistor input (ADC). Then you configure the firmware to use the appropriate "thermistor table" (really a voltage lookup table) for that particular amp. Depending on your controller board, you also may need to make sure the regular thermistor pull-up/pull-down resistors aren't affecting the amp's output.</p> <p>So you need to make sure:</p> <ul> <li>You don't have electrical noise issues</li> <li>The cold-junction compensation is working as intended</li> <li>The firmware and controller board is configured correctly for your amp chip's output</li> </ul> <p>If you do all that, a TC should give superior accuracy and reliability over a thermistor. </p>
<p>It sound like you just have a defective thermocouple. But, I just did a google search for "Why are thermocouples inaccurate" and found <a href="http://www.temprel.com/support/troubleshoot-thermocouple.aspx" rel="nofollow">this article</a> on identifying bad thermocouples and preventative maintenance. I never thought of a lot of the tips in the article, but I haven't had such drastic temperature errors either.</p>
126
<p>I have an ANET A2 Prusa - which I've setup and performed a few prints on and they have various problems with the quality. I'm after some specific experience on what the flow of filament should look like or if my decription triggers someone </p> <p>I've been adjusting settings - In particular the temperature - as the filament seemed too fluid as I could easily cause a large spurt of molten plastic by manually pushing the filament with very little effort. </p> <p>So I reduced the head temperature to 195 and all seemed better </p> <p>However after a time - I noticed on a longer print that the feeding was sometimes failing with the filament jerking back as the feeder slipped off it </p> <p>The stepper did not appear to slip back just the gear skipped on the filament It appeared to cause a problem in the print with a few of the lines being missing before it started extruding normally again</p> <p>I increased the temperature back to 200 - however the issue continued intermittently however I left it and when I returned the head had become blocked with the final part of the succesful print consisting of very thin hair like extrusions and eventually stopping completely</p> <p>The head is flooded and I need to clean it out </p> <p>So my questions are - how runny should the filament look when the head is at the correct temperatures, is the extremely runny filament I saw at 200 obviously too hot - or is that normal or at least have people seen it looking like that when successfully printing?</p> <p>Initially , before I reduced the temperature, I doubled the skirt and that seem to make a good enough print </p> <p>Does anyone have experience of why it can seem to be printing but then slowly start failing until the head becomes blocked?</p>
<p>From my experience with mk8 extruders lower than optimal nozzle temperature or clogged nozzle can lead to an extruder's stepper motor overheating and partial burning out of a stepper</p> <p>It looks like “Achilles' heel” of mk8 extruders. I had to change 4 stepper motors for 2 3d printers with mk8 due to that</p> <p>First symptoms – skipped steps. You could also check a temperature of your stepper – next symptom is a high temperature of stepper motor after several hours of printing</p> <p>My fix for this issue – adding cooling fans to stepper sides and top (3 fans). It significantly reduced overheating and hopefully a life of stepper</p> <p>Another solution of this issue can be in using of a stepper motor with gearbox to increase torque on a filament gear, so no high torque needed from stepper itself</p> <p>About printing temperature, it depends on plastic which you are using</p> <p>I’m using ABS plastic with an optimal printing temperature from 230-260 Celsius degree. For my current plastic supplier optimal temp is about 255 Celsius degree</p> <p>To check the optimal temperature for your plastic you can print one box in different temperatures depending on Z position and found the optimal temperature by the z position of surface with the best quality. You can find code samples how doing it <a href="http://forums.designfutures.club/t/tutorial-calibrating-hot-end-temperature-abs-pla-hips-etc/84" rel="nofollow noreferrer">here</a></p> <p>If a temperature is too high then this part of the box will be bloated, if it's too low - you can see the gaps. Here is the <a href="https://www.youtube.com/watch?v=FSOPsRiiOZk" rel="nofollow noreferrer">video</a>, which illustrating this for PLA</p> <p><strong>UPDATE:</strong></p> <p>The issue was in the low temperature of printing. After calibration and setting temperature by calibration outcomes to 200 Celsius degree printer started working well</p> <p>However, please be aware of the fact that wrong printing temperature can not only decrease the quality of printed things, but also can lead to wear of your printer parts and even can break it</p>
<p>From my experience with few printer, Sometime it's happen because of the filament. Solution- If your printer have unload function or if you don't have that funstion select a printerable file and change temperature to 205-210 C and try to use long and thin hex key like this to push the filament out. -Make sure you extruder motor work accordingly to feed the nozzle. </p> <p><a href="https://i.stack.imgur.com/OrXhn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OrXhn.jpg" alt=" try to use long and thin hex key like this to push the filament out"></a> </p>
659
<p>I've had an app doing prefix searches for a while. Recently the index size was increased and it turned out that some prefixes were too darned numerous for lucene to handle. It kept throwing me a <a href="http://web.archive.org/web/20080901205009/http://lucene.apache.org:80/java/2_3_2/api/core/org/apache/lucene/search/BooleanQuery.TooManyClauses.html" rel="nofollow noreferrer">Too Many Clauses</a> error, which was very frustrating as I kept looking at my JARs and confirming that none of the included code actually used a boolean query.</p> <p>Why doesn't it throw something like a Too Many Hits exception? And why does increasing the boolean query's static max clauses integer actually make this error go away, when I'm definitely only using a prefix query? Is there something fundamental to how queries are run that I'm not understanding; is it that they secretly become Boolean queries?</p>
<p>I've hit this before. It has to do with the fact that lucene, under the covers, turns many (all?) things into boolean queries when you call Query.rewrite()</p> <p>From: <a href="http://web.archive.org/web/20110915061619/http://lucene.apache.org:80/java/2_2_0/api/org/apache/lucene/search/Query.html" rel="nofollow noreferrer">http://web.archive.org/web/20110915061619/http://lucene.apache.org:80/java/2_2_0/api/org/apache/lucene/search/Query.html</a></p> <pre><code>public Query rewrite(IndexReader reader) throws IOException Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys. Throws: IOException </code></pre>
<p>When running a prefix query, Lucene searches for all terms in its "dictionary" that match the query. If more than 1024 (by default) match, the TooManyClauses-Exception is thrown.</p> <p>You can call BooleanQuery.setMaxClauseCount to increase the maximum number of clauses permitted per BooleanQuery.</p>
2,997
<p>It seems that IE6 ignores any form of cache invalidation sent via http headers, I've tried setting Pragma to No Cache and setting Cache Expiration to the current time, yet in IE6, hitting back will always pull up a cached version of a page I am working on.</p> <p>Is there a specific HTTP Header that IE6 does listen too?</p>
<p><code>Cache-Control: private, max-age=0</code> should fix it. From classic ASP this is done with <code>Response.Expires=-1</code>.</p> <p>Keep in mind when testing that just because your server is serving pages with caching turned off doesn't mean that the browser will obey that when it has an old cached page that it was told was okay to cache. Clear the cache or use F5 to force that page to be reloaded.</p> <p>Also, for those cases where the server is serving cached content it you can use <KBD>Ctrl+F5</KBD> to signal the server not to serve it from cache.</p>
<p>Have you tried setting an ETag in the header? They're a pretty reliable way to indicate that content has changed <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19" rel="nofollow noreferrer">w3c Spec</a> &amp; <a href="http://en.wikipedia.org/wiki/HTTP_ETag" rel="nofollow noreferrer">Wikipedia</a></p> <p>Beyond that, a little more crude way is to append a random query string parameter to the request, such as the current unix timestamp. As I said, crude, but then IE6 is not the most subtle of beasts </p>
6,371
<p>When writing database queries in something like TSQL or PLSQL, we often have a choice of iterating over rows with a cursor to accomplish the task, or crafting a single SQL statement that does the same job all at once.</p> <p>Also, we have the choice of simply pulling a large set of data back into our application and then processing it row by row, with C# or Java or PHP or whatever.</p> <p>Why is it better to use set-based queries? What is the theory behind this choice? What is a good example of a cursor-based solution and its relational equivalent?</p>
<p>The main reason that I'm aware of is that set-based operations can be optimised by the engine by running them across multiple threads. For example, think of a quicksort - you can separate the list you're sorting into multiple "chunks" and sort each separately in their own thread. SQL engines can do similar things with huge amounts of data in one set-based query.</p> <p>When you perform cursor-based operations, the engine can only run sequentially and the operation has to be single threaded.</p>
<p>The idea behind preferring to do the work in queries is that the database engine can optimize by reformulating it. That's also why you'd want to run EXPLAIN on your query, to see what the db is <em>actually</em> doing. (e.g. taking advantage of indices, table sizes and sometimes even knowledge about the distributions of values in columns.)</p> <p>That said, to get good performance in your actual concrete case, you may have to bend or break rules.</p> <p>Oh, another reason might be constraints: Incrementing a unique column by one might be okay if constraints are checked after <em>all</em> the updates, but generates a collision if done one-by-one.</p>
4,390
<p>When go to export a model using Fusion 360 or Meshmixer, I see that there are two options. Could the final model be affected by the format chosen at the time of saving?</p> <p><a href="https://i.stack.imgur.com/xIEXt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xIEXt.png" alt="enter image description here"></a></p>
<p>The two formats contain the same information about the model, but the binary format is <strong>much more compact</strong>, so it will produce smaller files from the same part but they should work the same. That's to say, if you take the exact same model, save it as a binary STL and as an ASCII STL, the binary STL file will take up <strong>fewer bytes</strong> on disk. The number of triangles and the dimensions of the printed model will <strong>stay the same</strong>.</p> <p>There are a couple of important exceptions here:</p> <ol> <li><p>I don't know about Meshmixer specifically, but some tools will have completely different code paths for exporting the two formats. One exporter may have a bug that the other exporter doesn't. The same is true of the slicer, which may have a bug reading one of the two kinds of STL but not the other. In this case, it'll make a huge difference which one you use, but you'll only find out when one goes wrong. This is what fred_dot_u experienced in <a href="https://3dprinting.stackexchange.com/a/10889/8884">his answer</a>.</p></li> <li><p>Some tools have a way of putting colour information into the binary STL format, which isn't possible with the ASCII format. If your model has coloured triangles, you might find that the binary STL preserves the colours, while the ASCII STL loses the colours. Whether this matters to you depends on what printing technology you'll be using. Most slicers can't use these colours anyway - and subsequently, ignore color information on import.</p></li> </ol> <p>The ASCII STL format is older than the binary format, so you may find some very old software can only understand the ASCII STL files, but unless you're working with such old software, it's usually better to use the binary format. Smaller files don't just save disk space: they're also faster to process and transfer via e-mail or on servers.</p>
<p>The other answers on this thread seem kind of hand-wavy, so I'll give my input.</p> <p>At its simplest, all we're dealing with here is two different formats of encoding the same data. The 3D file is identical, just described by the file data in different terms.</p> <p>That being said, there is a multitude of different reasons that 3D prints can fail. Fusion 360 is notorious for having issues with slicers because of fillets, lofts, smooth-curvy type patterns, or intersecting planes.</p> <p>Binary is a smaller encoding. It almost always works for me. ASCII has never failed me as a backup when binary did.</p>
1,453
<p>I would like to create events for certain resources that are used across various processes and access these events by name. The problem seems to be that the names of the events must be known to all applications referring to them.</p> <p>Is there maybe a way to get a list of names events in the system?</p> <p>I am aware that I might use some standard names, but it seems rather inflexible with regard to future extensibility (all application would require a recompile).</p> <hr> <p>I'm afraid, I can't even consider ZwOpenDirectoryObject, because it is described as needing Windows XP or higher, so it is out of question. Thanks for the suggestion though.</p> <p>I am a little unsure about shared memory, because I haven't tried it so far. Might do some reading in that area I guess. Configuration files and registry are a slight problem, because they do tend to fail with Vista due to access problems. I am a bit afraid, that shared memory will have the same problem.</p> <p>The idea with ProcessExplorer sounds promising. Does anyone know an API that could be used for listing events for a process? And, does it work without administrative rights?</p> <hr> <p>Thank you for the clarification.</p> <p>There is not really a master process. It is more of a driver dll that is used from different processes and the events would be used to "lock" resources used by these processes.</p> <p>I am thinking about setting up a central service that has sufficient access rights even under Vista. It will certainly complicate things, but it might be the only thing left facing the problems with security.</p>
<p>No, there is not any facility to enumerate named events. You could enumerate all objects in the respective object manager directory using ZwOpenDirectoryObject and then filter for events. But this routine is undocumented and therefore should not be used without good reason.</p> <p>Why not use a separate mechanism to share the event names? You could list them in a configuration file, a registry key or maybe even in shared memory.</p>
<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">ProcessExplorer</a> is able to enumerate all the named events held by some specific process. You could go over the entire process list and do something similar although I have now clue as to what API is used to get the list...</p>
5,631
<p>I'm new to this game, and recently upgraded the hotend on my Ender 3 Pro to a <em>clone</em> of an E3D V6, as I'm keen to do nylon prints at some point. I noticed however that this one I got has a teflon liner which seems to negate the advantage of a metal hotend entirely.</p> <p>I'm wondering what temperature it's safe to run this hot end up to?</p> <p><a href="https://i.stack.imgur.com/6Uth3.jpg" rel="nofollow noreferrer" title="Teflon insert#2"><img src="https://i.stack.imgur.com/6Uth3.jpg" alt="Teflon insert#1" title="Teflon insert#2" /></a></p> <p><a href="https://i.stack.imgur.com/QazJ2.jpg" rel="nofollow noreferrer" title="Teflon insert#1"><img src="https://i.stack.imgur.com/QazJ2.jpg" alt="Teflon insert#2" title="Teflon insert#1" /></a></p>
<p>There are many types of <a href="https://3dprinting.stackexchange.com/questions/10998/e3d-v6-original-vs-clone/11012#11012">heatbreak clones</a>. In cour case, your clone effectively turns your hotend into an e3d Lite6, not an all-metal e3d v6. To function properly, the PTFE liner needs to butt against the nozzle or you will quickly develop leak and clog issues.</p> <p>This means, handle it like a Lite6, which has a max of 245 °C listed, but under usual operation should not exceed 230 °C.</p>
<p>Long story short, you can print Nylon with a Teflon tube. I've done it. P.S. The nylon absorbs water like nothing you've ever seen. Even after the part is printed, it absorbs water, and expands!</p>
1,712
<p>If I have an IEnumerator variable is it possible to have a lambda function that takes it, advances it with MoveNext() and returns the Current value every single time its called?</p>
<pre><code>e =&gt; e.MoveNext() ? e.Current : null </code></pre> <p>This will advance the enumerator and return the current value, and return null when the enumeration is complete.</p>
<p>Is this what you are looking for?</p> <pre><code>List&lt;string&gt; strings = new List&lt;string&gt;() { "Hello", "I", "am", "a", "list", "of", "strings." }; IEnumerator&lt;string&gt; e = strings.GetEnumerator(); Func&lt;string&gt; f = () =&gt; e.MoveNext() ? e.Current : null; for (; ; ) { string str = f(); if (str == null) break; Console.Write(str + " "); } </code></pre> <p>The point of an <code>IEnumerator</code> is that you already get syntactic sugar to deal with it:</p> <pre><code>foreach (string str in strings) Console.Write(str + " "); </code></pre> <p>Even handling the enumerator directly looks cleaner in this case:</p> <pre><code>while (e.MoveNext()) Console.Write(e.Current + " "); </code></pre>
9,851
<p>I'm trying to bind a list of custom objects to a WPF Image like this:</p> <pre><code>&lt;Image&gt; &lt;Image.Source&gt; &lt;BitmapImage UriSource="{Binding Path=ImagePath}" /&gt; &lt;/Image.Source&gt; &lt;/Image&gt; </code></pre> <p>But it doesn't work. This is the error I'm getting:</p> <p><em>"Property 'UriSource' or property 'StreamSource' must be set."</em></p> <p>What am I missing?</p>
<p>WPF has built-in converters for certain types. If you bind the Image's <code>Source</code> property to a <code>string</code> or <code>Uri</code> value, under the hood WPF will use an <a href="https://msdn.microsoft.com/en-us/library/system.windows.media.imagesourceconverter(v=vs.110).aspx" rel="noreferrer">ImageSourceConverter</a> to convert the value to an <code>ImageSource</code>.</p> <p>So</p> <pre><code>&lt;Image Source="{Binding ImageSource}"/&gt; </code></pre> <p>would work if the ImageSource property was a string representation of a valid URI to an image.</p> <p>You can of course roll your own Binding converter:</p> <pre class="lang-cs prettyprint-override"><code>public class ImageConverter : IValueConverter { public object Convert( object value, Type targetType, object parameter, CultureInfo culture) { return new BitmapImage(new Uri(value.ToString())); } public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture) { throw new NotSupportedException(); } } </code></pre> <p>and use it like this:</p> <pre><code>&lt;Image Source="{Binding ImageSource, Converter={StaticResource ImageConverter}}"/&gt; </code></pre>
<p>You need to have an implementation of <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx" rel="nofollow noreferrer">IValueConverter</a> interface that converts the uri into an image. Your Convert implementation of IValueConverter will look something like this:</p> <pre><code>BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri(value as string); image.EndInit(); return image; </code></pre> <p>Then you will need to use the converter in your binding:</p> <pre><code>&lt;Image&gt; &lt;Image.Source&gt; &lt;BitmapImage UriSource="{Binding Path=ImagePath, Converter=...}" /&gt; &lt;/Image.Source&gt; &lt;/Image&gt; </code></pre>
4,091
<p>I am adding a ADO.Net Data Service lookup feature to an existing web page. Everything works great when running from visual studio, but when I roll it out to IIS, I get the following error:</p> <blockquote> <p><strong>Request Error</strong><br>The server encountered an error processing the request. See server logs for more details.</p> </blockquote> <p>I get this even when trying to display the default page, i.e.:</p> <blockquote> <p><a href="http://server/FFLookup.svc" rel="noreferrer">http://server/FFLookup.svc</a></p> </blockquote> <p>I have 3.5 SP1 installed on the server.</p> <p>What am I missing, and which "Server Logs" is it refering to? I can't find any further error messages.</p> <p>There is nothing in the Event Viewer logs (System or Application), and nothing in the IIS logs other than the GET:</p> <blockquote> <p>2008-09-10 15:20:19 10.7.131.71 GET /FFLookup.svc - 8082 - 10.7.131.86 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US)+AppleWebKit/525.13+(KHTML,+like+Gecko)+Chrome/0.2.149.29+Safari/525.13 401 2 2148074254</p> </blockquote> <p>There is no stack trace returned. The only response I get is the "Request Error" as noted above.</p> <p>Thanks</p> <p>Patrick</p>
<p>In order to verbosely display the errors resulting from your data service you can place the following tag above your dataservice definition:</p> <pre><code>[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)] </code></pre> <p>This will then display the error in your browser window as well as a stack trace.</p> <p>In addition to this dataservices throws all exceptions to the HandleException method so if you implement this method on your dataservice class you can put a break point on it and see the exception:</p> <pre><code>protected override void HandleException(HandleExceptionArgs e) { try { e.UseVerboseErrors = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } </code></pre>
<p>For me the error was caused by two methods having the same name (unintended overloading).</p> <blockquote> <p>Overloading is not supported but type 'abc' has an overloaded method 'Void SubmitCart(System.String, Int32)'.</p> </blockquote> <p>I found out by running the service in debug mode.</p>
7,799
<p>If you're building an <code>AJA~Xy</code> app, are there any downsides to using <code>JSONP</code> requests/responses even if you're not planning on any <code>cross-domain</code> requests? </p> <p>The only thing I can think of is that there are a couple extra bytes for the callback wrapper... </p> <p><strong>Edit:</strong></p> <p>I found <a href="http://remysharp.com/2007/10/08/what-is-jsonp/" rel="nofollow noreferrer">this</a> which also suggests <code>security and error handling</code> as potential problems... </p> <blockquote> <p>There's no error handling. The <code>script injection</code> either works, or it doesn't. If there's an error from the <code>injection</code>, it'll hit the page, and short of a window wide error handler (bad, bad, very bad), you need to be sure the return value is valid on the <code>server side</code>.</p> </blockquote> <p>I don't think <code>error handling</code> is much of a problem... most of us would use a library to generate the <code>JSON</code>... the well-formedness of my response isn't a concern for this question.</p> <p><strong>and security:</strong></p> <blockquote> <p>There are documents out on the web that can help, but as a cursory check, I would check the referrer in the <code>server side</code> script.</p> </blockquote> <p>it seems like this is a potential problem with any type of response... certainly, there's nothing unique to <code>JSONP</code> in the security arena...?</p>
<p>Downside? It's fairly limited - you trigger a "GET" request and get back some script that's executed. You don't get error handling if your server throws an error, so you need to wrap all errors in JSON as well. You can't really cancel or retry the request. You're at the mercy of the various browser author opinions of "correct" behavior for dynamically-generated <code>&lt;script&gt;</code> tags. Debugging is somewhat more difficult. </p> <p>That said, i've used it on occasion, and haven't suffered. YMMV.</p>
<p>Here is another bit you may want to consider with JSONP.. possible memory leaks.. </p> <p><a href="http://neil.fraser.name/news/2009/07/27/" rel="nofollow noreferrer">http://neil.fraser.name/news/2009/07/27/</a></p>
3,965
<p>Would it be possible to print <code>Hello</code> twice using single <code>condition</code>?</p> <pre><code>if "condition" printf ("Hello"); else printf("World"); </code></pre>
<pre><code>if ( printf("Hello") == 0 ) printf ("Hello"); else printf ("World"); </code></pre> <p>:-)</p>
<p>The condition to this question is:</p> <pre><code> if(printf("hello")? 0 : 1) { } </code></pre>
5,318
<p>I am looking for some JavaScript based component to be used as a course scheduler which would be a cross between Google Calendar and the login time. I do not know if the right term for this is <i>Course Scheduler</i> but I shall describe this in more detail here.</p> <p><b>Course Scheduler</b><br> The widget would be used to enter date and times of a course, as an example if I run a programming course 3 days a week on Mon, Tue and Wed every 7:00 am to 9:00am, 2 hours every day from 1st September to 30th November. I could answer various questions and the course data would be displayed in the calendar. It would also allow for non pattern based timings where each week is different from the other week etc. </p> <p><b>Question</b><br> So would I end up creating something from scratch? Would it be sensible to use Google Calendar API for this? I did a Google search for some widgets, but I believe I need better keywords, as I could not find anything close to what I am looking for. Any tips? Commercial libraries would also work for me. Thanks.</p>
<p>this could be what you're looking for:</p> <p><a href="http://www.dhtmlx.com/docs/products/dhtmlxScheduler/index.shtml" rel="noreferrer">DHTMLxScheduler link</a></p> <ul> <li>It has day/week/month views</li> <li>It is free</li> <li>Data can be loaded in xml or iCal formats</li> </ul> <p>You can populate the calendar using any server-side scripting language. If you wanted to, you could just get your google calendar's xml data as per Mickey's example in the accepted post above, process it in your server-side language of choice and feed the calendar control with that data.</p> <p><strong>EDIT</strong></p> <p>I also found this project on Google code recently:</p> <p><a href="http://code.google.com/p/jquery-frontier-calendar/" rel="noreferrer">JQuery Frontier Calendar</a></p>
<p>try the following open source one. <a href="http://www.web-delicious.com/jquery-events-calendar-wdcalendar/">wdCalendar</a> is a jquery based google calendar clone. It cover most google calendar features.</p> <pre><code>* Day/week/month view provided. * create/update/remove events by drag &amp; drop. * Easy way to integrate with database. * All day event/more days event provided. </code></pre>
4,578
<p>I just installed my BLTouch clone (Marlin 1.8) on my Anycubic i3 Mega Ultrabase and finding confusing information about the <code>Z_PROBE_OFFSET_FROM_EXTRUDER</code> or the <code>M851</code> command.</p> <p>I understand <code>M851</code> command does the same as <code>Z_PROBE_OFFSET_FROM_EXTRUDER</code> in the Configuration.h. (see <a href="https://marlinfw.org/docs/gcode/M851.html" rel="nofollow noreferrer">marlin docs</a>)</p> <p>So according to Marlin, this value is the distance of the nozzle to the distance of the triggering point of the sensor.</p> <p>If I manage to measure that accurately, Marlin could probe the bed, knowing distance of probe to nozzle, add a margin for perfect distance (around paper thickness) and my bed would be forever perfectly measured with every autolevelling process and perfect distances could be calculated.</p> <p>Instead, I find tutorials around the <code>M851</code> (e.g <a href="https://3dprinting.stackexchange.com/questions/5857/z-offset-on-autoleveling-sensor-setup/5858#5858?newreg=7ba284617c6d4de7834be73f67dd4e6b">here</a> telling to manually level the bed, then take the current Z-value of the extruder and put that into the <code>M851</code> value. In my understanding it makes little sense, as it has no reference to when the sensor triggers, its distance to the bed.</p> <p>Sure, maybe this way it can get an understanding of slight derivations in the planarity of the bed, but it would not have automatically &quot;levelled&quot; my bed, just compensated for imperfections.</p> <p>I am confused by the amount of tutorials that suggest so. Whats the case now? Is Marlin not really able to really level to my bed?</p>
<p>What may be confusing is the use of the naming of the mechanism &quot;Auto Bed Levelling&quot;, or short ABL, does not make your build plate to level itself with respect to the frame of the printer<sup>1)</sup>. Hence you are instructed to always tram (level is rather misleading as it doesn't involve bubble levelling, instead it is meant to tram the bed with respect to the X- and Y-axis) the build surface as good as you can.</p> <p>The ABL process could better be described as &quot;Height adjusting to scanned bed geometry&quot; or something like that, as that is exactly what is being done. The <code>G29</code> command scans the bed surface and (depending on the firmware options) it generates a mesh or a plane through the measured points. When printing, the nozzle will follow the bed height geometry and fades this out over about 10 milliliters (depends on setting). So, if you do not tram the bed correctly, you will end up with a skew bottom of the print as the fade out will cause the printer to print eventually parallel to the X- and Y-axis.</p> <p>Note that specifying the Z-offset in the firmware is rather useless, you cannot measure this beforehand. It is far better to do this later using <code>M851</code>.</p> <p><a href="https://3dprinting.stackexchange.com/a/5858">This answer</a> describes in some more detail how the offset is generated and applied to the scanned surface.</p> <hr /> <p><em><sup>1)</sup> It is possible to actually level/tram the bed (e.g. in Marlin firmware), but that are different processes. E.g. a tramming assistant is available when using the <a href="https://marlinfw.org/docs/gcode/G035.html" rel="nofollow noreferrer"><code>G35</code></a> G-code. And, automatically, (for specific printers) possible on build plates that are moved up/down by several lead screws (look into <code>NUM_Z_STEPPER_DRIVERS</code> in Marlin's Configuration_adv.h file). But still, this maintains a certain level, it does not scan the complete surface, that can be achieved by the ABL process.</em></p>
<p>Just thought that BLTouch could automatically measure the nozzle height. If it goes down slowly till nozzle touch the bed and then push down a little more then it will see sensor isn't moving anymore then it means nozzle already pushes the bed down. Beds are usually have springs and shouldn't hurt to push it a little (~1mm) by nozzle. Not sure if such function is implemented. Just an idea. This procedure doesn't need to be used every time. Could be an option after changing the nozzle or other adjustments affecting the nozzle height.</p>
1,845
<p>I have a page with a Google Maps mashup that has pushpins that are color-coded by day (Monday, Tuesday, etc.) The IFrame containing the map is dynamically sized, so it gets resized when the browser window is resized. </p> <p>I'd like to put a legend in the corner of the map window that tells the user what each color means. The Google Maps API includes a <code><a href="http://code.google.com/apis/maps/documentation/reference.html#GScreenOverlay" rel="nofollow noreferrer">GScreenOverlay</a></code> class that has the behavior that I want, but it only lets you specify an image to use as an overlay, and I'd prefer to use a DIV with text in it. What's the easiest way to position a DIV over the map window in (for example) the lower left corner that'll automatically stay in the same place relative to the corner when the browser window is resized?</p>
<p>You can add your own Custom Control and use it as a legend.</p> <p>This code will add a box 150w x 100h (Gray Border/ with White Background) and the words "Hello World" inside of it. You swap out the text for any HTML you would like in the legend. This will stay Anchored to the Top Right (G_ANCHOR_TOP_RIGHT) 10px down and 50px over of the map.</p> <pre><code>function MyPane() {} MyPane.prototype = new GControl; MyPane.prototype.initialize = function(map) { var me = this; me.panel = document.createElement("div"); me.panel.style.width = "150px"; me.panel.style.height = "100px"; me.panel.style.border = "1px solid gray"; me.panel.style.background = "white"; me.panel.innerHTML = "Hello World!"; map.getContainer().appendChild(me.panel); return me.panel; }; MyPane.prototype.getDefaultPosition = function() { return new GControlPosition( G_ANCHOR_TOP_RIGHT, new GSize(10, 50)); //Should be _ and not &amp;#95; }; MyPane.prototype.getPanel = function() { return me.panel; } map.addControl(new MyPane()); </code></pre>
<p>I would use HTML like the following:</p> <pre><code>&lt;div id="wrapper"&gt; &lt;div id="map" style="width:400px;height:400px;"&gt;&lt;/div&gt; &lt;div id="legend"&gt; ... marker descriptions in here ... &lt;/div&gt; &lt;/div&gt; </code></pre> <p>You can then style this to keep the legend in the bottom right:</p> <pre><code>div#wrapper { position: relative; } div#legend { position: absolute; bottom: 0px; right: 0px; } </code></pre> <p><code>position: relative</code> will cause any contained elements to be positioned relative to the <code>#wrapper</code> container, and <code>position: absolute</code> will cause the <code>#legend</code> div to be "pulled" out of the flow and sit above the map, keeping it's bottom right edge at the bottom of the <code>#wrapper</code> and stretching as required to contain the marker descriptions.</p>
5,712
<p>I just tried FxCop. It does detect unused private methods, but not unused public. Is there a custom rule that I can download, plug-in that will detect public methods that aren't called from within the same assembly?</p>
<p>Corey, my answer of using FxCop had assumed you were interested in removing unused private members, however to solve the problem with other cases you can try using <a href="http://www.ndepend.com/" rel="nofollow noreferrer">NDepend</a>. Here is some CQL to detect unused public members (adapted from an article listed below):</p> <pre><code>// &lt;Name&gt;Potentially unused methods&lt;/Name&gt; WARN IF Count &gt; 0 IN SELECT METHODS WHERE MethodCa == 0 AND // Ca=0 -&gt; No Afferent Coupling -&gt; The method // is not used in the context of this // application. IsPublic AND // Check for unused public methods !IsEntryPoint AND // Main() method is not used by-design. !IsExplicitInterfaceImpl AND // The IL code never explicitely calls // explicit interface methods implementation. !IsClassConstructor AND // The IL code never explicitely calls class // constructors. !IsFinalizer // The IL code never explicitely calls // finalizers. </code></pre> <p>Source: <a href="http://codebetter.com/blogs/patricksmacchia/archive/2008/02/15/code-metrics-on-coupling-dead-code-design-flaws-and-re-engineering.aspx" rel="nofollow noreferrer">Patrick Smacchia's "Code metrics on Coupling, Dead Code, Design flaws and Re-engineering</a>. The article also goes over detecting dead fields and types.</p> <p><em>(EDIT: made answer more understandable)</em></p> <hr> <p>EDIT 11th June 2012: <em>Explain new NDepend facilities concerning unused code. Disclaimer: I am one of the developer of this tool.</em></p> <p>Since NDepend v4 released in May 2012, the tool proposes to write <a href="http://codebetter.com/blogs/patricksmacchia/archive/2008/02/15/code-metrics-on-coupling-dead-code-design-flaws-and-re-engineering.aspx" rel="nofollow noreferrer">Code Rule over LINQ Query (CQLinq)</a>. Around <a href="http://www.ndepend.com/DefaultRules/webframe.html" rel="nofollow noreferrer">200 default code rules</a> are proposed, 3 of them being dedicated to <em>unused/dead code</em> detection:</p> <ul> <li><a href="http://www.ndepend.com/DefaultRules/webframe.html?Q_Potentially_dead_Types.html" rel="nofollow noreferrer">Potentially dead Types</a> (hence detect unused class, struct, interface, delegate...)</li> <li><strong><a href="http://www.ndepend.com/DefaultRules/webframe.html?Q_Potentially_dead_Methods.html" rel="nofollow noreferrer">Potentially dead Methods</a></strong> (hence detect unused method, ctor, property getter/setter...)</li> <li><a href="http://www.ndepend.com/DefaultRules/webframe.html?Q_Potentially_dead_Fields.html" rel="nofollow noreferrer">Potentially dead Fields</a></li> </ul> <p>These CQLinq code rules are more powerful than the previous CQL ones. If you click these 3 links above toward the source code of these rules, you'll see that the ones concerning types and methods are a bit complex. This is because they detect not only unused types and methods, but also types and methods used <em>only</em> by unused dead types and methods (recursive).</p> <p>This is <em>static analysis</em>, hence the prefix <em>Potentially</em> in the rule names. If a code element is used <em>only</em> through reflection, these rules might consider it as unused which is not the case. </p> <p>In addition to using these 3 rules, I'd advise measuring code coverage by tests and striving for having full coverage. Often, you'll see that code that cannot be covered by tests, is actually <em>unused/dead</em> code that can be safely discarded. This is especially useful in complex algorithms where it is not clear if a branch of code is reachable or not.</p>
<p>How would it know that the public methods are unused?</p> <p>By marking a method as public it can be accessed by any application which references your library.</p>
9,703
<p><em>Preferred languages</em>: C/C++, Java, and Ruby.</p> <p>I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, and Ruby, so I prefer resources that involve one of those three, but any good resource is acceptable.</p>
<h2>Big List of Resources:</h2> <ul> <li><a href="http://www.cs.indiana.edu/%7Edyb/pubs/nano-jfp.pdf" rel="noreferrer">A Nanopass Framework for Compiler Education</a> ¶</li> <li><a href="http://www.amazon.com/gp/offer-listing/1558603204?tag=thecompilerconne&amp;camp=14573&amp;creative=327641&amp;linkCode=am1&amp;creativeASIN=1558603204&amp;adid=1ZQWN5FGBA1JM6MNQ2ZV&amp;" rel="noreferrer">Advanced Compiler Design and Implementation</a> $</li> <li><a href="http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf" rel="noreferrer">An Incremental Approach to Compiler Construction</a> ¶</li> <li><a href="http://javadude.com/articles/antlr3xtut" rel="noreferrer">ANTLR 3.x Video Tutorial</a></li> <li><a href="http://www.diku.dk/%7Etorbenm/Basics/" rel="noreferrer">Basics of Compiler Design</a></li> <li><a href="http://web.archive.org/web/20160731061607/http://www.onlamp.com/pub/a/onlamp/2004/04/15/parrot_compiler_construction.html" rel="noreferrer">Building a Parrot Compiler</a></li> <li><a href="http://www.cs.man.ac.uk/%7Epjj/farrell/compmain.html" rel="noreferrer">Compiler Basics</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0201403536" rel="noreferrer" rel="nofollow noreferrer">Compiler Construction</a> $</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0442275366" rel="noreferrer" rel="nofollow noreferrer">Compiler Design and Construction</a> $</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0805321667" rel="noreferrer" rel="nofollow noreferrer">Crafting a Compiler with C</a> $</li> <li><a href="http://craftinginterpreters.com/" rel="noreferrer">Crafting Interpreters</a></li> <li>[Compiler Design in C] <a href="http://www.holub.com/software/compiler.design.in.c.html" rel="noreferrer">12</a> ¶</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0321486811" rel="noreferrer" rel="nofollow noreferrer">Compilers: Principles, Techniques, and Tools</a> $ — aka <a href="http://en.wikipedia.org/wiki/Compilers:_Principles%2C_Techniques%2C_and_Tools" rel="noreferrer">&quot;The Dragon Book&quot;</a>; widely considered &quot;the book&quot; for compiler writing.</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/012088478X" rel="noreferrer" rel="nofollow noreferrer">Engineering a Compiler</a> $</li> <li><a href="http://www.cs.indiana.edu/eopl/" rel="noreferrer">Essentials of Programming Languages</a></li> <li><a href="http://flipcode.com/archives/articles.shtml" rel="noreferrer">Flipcode Article Archive</a> (look for &quot;Implementing A Scripting Engine by Jan Niestadt&quot;)</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/1931841578" rel="noreferrer" rel="nofollow noreferrer">Game Scripting Mastery</a> $</li> <li><a href="http://www.codeproject.com/KB/recipes/B32Machine1/VMCS.pdf" rel="noreferrer">How to build a virtual machine from scratch in C#</a> ¶</li> <li><a href="http://research.microsoft.com/%7Esimonpj/papers/pj-lester-book/" rel="noreferrer">Implementing Functional Languages</a></li> <li><a href="http://www1.digitalgrammars.com/ipl-book/" rel="noreferrer">Implementing Programming Languages (with BNFC)</a></li> <li><a href="http://www.codeproject.com/KB/recipes/programminglanguagetoools.aspx" rel="noreferrer">Implementing Programming Languages using C# 4.0</a></li> <li><a href="http://en.wikipedia.org/wiki/Interpreter_pattern" rel="noreferrer">Interpreter pattern</a> (described in <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="noreferrer" rel="nofollow noreferrer">Design Patterns</a> $) specifies a way to evaluate sentences in a language</li> <li><a href="http://pragprog.com/titles/tpdsl/language-implementation-patterns" rel="noreferrer">Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages</a> $</li> <li><a href="http://compilers.iecc.com/crenshaw/" rel="noreferrer">Let's Build a Compiler</a> by Jack Crenshaw — The <a href="http://www.stack.nl/%7Emarcov/compiler.pdf" rel="noreferrer">PDF</a> ¶ version (examples are in Pascal, but the information is generally applicable)</li> <li><a href="http://books.google.com/books?id=Id9cYsIdjIwC&amp;lpg=PP1&amp;ots=IxFkFWJ-8V&amp;dq=%22linkers%20and%20loaders%22&amp;pg=PA215#v=onepage&amp;q=%22linkers%20and%20loaders%22&amp;f=false" rel="noreferrer">Linkers and Loaders</a> $ (Google Books)</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0521562473" rel="noreferrer" rel="nofollow noreferrer">Lisp in Small Pieces (LiSP)</a> $</li> <li><a href="http://llvm.org/docs/tutorial/" rel="noreferrer">LLVM Tutorial</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0521607647" rel="noreferrer" rel="nofollow noreferrer">Modern Compiler Implementation in ML</a> $ — There is a <a href="https://rads.stackoverflow.com/amzn/click/com/052182060X" rel="noreferrer" rel="nofollow noreferrer">Java</a> $ and <a href="https://rads.stackoverflow.com/amzn/click/com/0521607655" rel="noreferrer" rel="nofollow noreferrer">C</a> $ version as well - widely considered a very good book</li> <li><a href="http://www.amazon.com/gp/offer-listing/013630740X?tag=thecompilerconne&amp;camp=14573&amp;creative=327641&amp;linkCode=am1&amp;creativeASIN=013630740X&amp;adid=0JPMVBRNCAN6PDKGYSXX&amp;" rel="noreferrer">Object-Oriented Compiler Construction</a> $</li> <li><a href="http://www.dickgrune.com/Books/PTAPG_1st_Edition/" rel="noreferrer">Parsing Techniques - A Practical Guide</a></li> <li><a href="http://www-old.oberon.ethz.ch/WirthPubl/ProjectOberon.pdf" rel="noreferrer">Project Oberon</a> ¶ - Look at chapter 13</li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0137302673" rel="noreferrer" rel="nofollow noreferrer">Programming a Personal Computer</a> $</li> <li><a href="http://www.cs.brown.edu/%7Esk/Publications/Books/ProgLangs/" rel="noreferrer">Programing Languages: Application and Interpretation</a></li> <li><a href="http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AITR-474.pdf" rel="noreferrer">Rabbit: A Compiler for Scheme</a>¶</li> <li><a href="http://web.archive.org/web/20141221110345/http://cm.bell-labs.com/who/ken/trust.html" rel="noreferrer">Reflections on Trusting Trust</a> — A quick guide</li> <li><a href="http://msdn.microsoft.com/en-us/magazine/cc136756.aspx" rel="noreferrer">Roll Your Own Compiler for the .NET framework</a> — A quick tutorial from MSDN</li> <li><a href="http://mitpress.mit.edu/sicp/" rel="noreferrer">Structure and Interpretation of Computer Programs</a></li> <li><a href="http://www.cis.upenn.edu/%7Ebcpierce/tapl/" rel="noreferrer">Types and Programming Languages</a></li> <li><a href="http://prog21.dadgum.com/30.html" rel="noreferrer">Want to Write a Compiler?</a> - a quick guide</li> <li><a href="http://www.hokstad.com/writing-a-compiler-in-ruby-bottom-up-step-1.html" rel="noreferrer">Writing a Compiler in Ruby Bottom Up</a></li> <li><a href="https://bernsteinbear.com/blog/compiling-a-lisp-0/" rel="noreferrer">Compiling a Lisp</a> — compile directly to x86-64</li> </ul> <p>Legend:</p> <ul> <li>¶ Link to a PDF file</li> <li>$ Link to a printed book</li> </ul>
<p>Whenever I want to try out a new language idea, I just write a simple parser, and have it generate some language that's easy to get good compilers for, like C.</p> <p>How do you think C++ was done?</p>
2,399
<p>I am importing data from MS Excel spreadsheets into a php/mySQL application. Several different parties are supplying the spreadsheets and they are in formats ranging from Excel 4.0 to Excel 2007. The trouble is finding a technique to read ALL versions.</p> <p>More info: </p> <pre><code> - I am currently using php-ExcelReader. - A script in a language other than php that can convert Excel to CSV would be an acceptable solution. </code></pre>
<p>Depending on the nature of your data and the parties that upload the excel files, you might want to consider having them save the data in .csv format. It will be much easier to parse on your end.</p> <p>Assuming that isn't an option a quick google search turned up <a href="http://sourceforge.net/projects/phpexcelreader/" rel="nofollow noreferrer">http://sourceforge.net/projects/phpexcelreader/</a> which might suit your needs.</p>
<p>The open-source ETL tool Talend (<a href="http://wwww.talend.com" rel="nofollow noreferrer">http://wwww.talend.com</a>) will generate Java or Perl code and package such code with the necessary 3rd party libraries. </p> <p>Talend should be able to handle all versions of Excel and output the result set in any format you require (including loading it directly into a database if need be).</p>
9,826
<p>Recently I noticed a small issue with my Creality Ender 3, where I would come home and find one of the bed leveling wheels had fallen off. This one wheel keeps vibrating loose. It's not really affecting my prints for some reason, so I just kind of let it happen.</p> <p>Yesterday I started an 8 hour print and left. When I came home, I heard a loud buzzing noise. I walk into my room and smell a burning smell. I see the printer has extruded plastic all over the place. PLA is all over the floor. The plastic its extruding is normal filament, not extruded plastic; the nozzle is gone. Not entirely sure how it came out, because it was tight.</p> <p>I switch off the printer and assess the damage.</p> <ul> <li><p>The nozzle is on the floor, covered in a big blob of plastic.</p> </li> <li><p>The stock fiberglass build plate is nowhere to be seen; I think it fell behind the desk the printer is on.</p> </li> <li><p>The friction surface below the plate is covered with scratches and blobs of plastic - that needs to be replaced as well.</p> </li> <li><p>Two of the bed leveling wheels are gone. One is on the floor, and the other probably fell behind the desk like the build plate.</p> </li> <li><p>The hotend fan has filament going through it. It's missing three blades. Two of them fell on the floor, and one fell into the hotend and melted, making the burning smell.</p> </li> <li><p>The hotend is <em>covered</em> in melted plastic.</p> </li> <li><p>The heater block has lots of plastic jamming the hole where the nozzle goes.</p> </li> </ul> <p>Where do I go from here? How do I fix this? Is this fixable?</p> <p>What should I do to make sure this doesn't happen again?</p>
<p>From the excellent Thingiverse link, <a href="https://www.thingiverse.com/thing:4967931" rel="nofollow noreferrer">Customizable QR Keyring or Tag</a> by <a href="https://www.thingiverse.com/outwardb/designs" rel="nofollow noreferrer"><em>OutwardB</em></a> - which was provided in the (now deleted) <a href="https://3dprinting.stackexchange.com/a/18296/4762">link-only answer</a>:</p> <blockquote> <ol> <li><h3>Create the QR code</h3> <ul> <li><p>Go to <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a></p> </li> <li><p><strong>Only change the Content settings</strong></p> <p>DO NOT change the color, logo or design settings</p> </li> <li><p>Click <strong>Create QR Code</strong></p> </li> <li><p>Click <strong>Download PNG</strong> and wait for the file to download</p> </li> </ul> </li> <li><h3>Convert to SVG</h3> <ul> <li>Go to <a href="https://convertio.co/png-svg/" rel="nofollow noreferrer">PNG to SVG Converter</a> and convert the PNG image you just downloaded to a .SVG file</li> </ul> </li> <li><h3>Customise in OpenSCAD</h3> <p>You will need <a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a> from the <a href="https://www.thingiverse.com/thing:4967931/files" rel="nofollow noreferrer">files repository on Thingverse</a></p> <ol> <li><p>Download OpenSCAD from here and install it - <a href="https://openscad.org/downloads.html" rel="nofollow noreferrer">https://openscad.org/downloads.html</a></p> </li> <li><p>Put the downloaded SVG file in the same folder as the .SCAD file from this page</p> </li> <li><p>Double-click the .SCAD file to open it</p> </li> <li><p>Click <strong>Window</strong>, then untick <strong>Hide Customizer</strong></p> <p><em>Optional</em>: Click <strong>Window</strong>, then tick <strong>Hide Editor</strong></p> </li> <li><p>Enter the SVG file name in the basic settings tab (or rename the file to qr-code.svg before opening OpenSCAD)</p> </li> <li><p>Customize the settings. After changing a setting, you may need to click outside the text box to apply the change</p> </li> <li><p>Click <strong>Design</strong> &gt; <strong>Render</strong> and wait for the design to render</p> </li> <li><p>Click <strong>File</strong> &gt; <strong>Export</strong> &gt; <strong>Export to STL</strong></p> </li> <li><p>Save the file</p> </li> </ol> <p><a href="https://i.stack.imgur.com/VyzXZ.gif" rel="nofollow noreferrer" title="QR Customisation - optional"><img src="https://i.stack.imgur.com/VyzXZ.gif" alt="QR Customisation - optional" title="QR Customisation - optional" /></a></p> </li> </ol> <h3>Notes</h3> <ul> <li><strong>Raised</strong> and <strong>Cut-Out</strong> types are for changing filament at layer height</li> <li><strong>Multi-color</strong> and <strong>Code</strong> are to be used together for inlay/multi-color printers</li> <li>You can also set <em>Base Height</em> or <em>Code Height</em> to 0 and export each part on it's own</li> <li>If you want to print a <strong>double sided tag</strong>, you can set <em>Base Height</em> to 0 and export the second side. Then just flip this over in the slicer</li> <li>The text options are a okay for basic text, but if you want to use another program to add some, you can add extra height to the top/bottom of the card under <strong>Extra Size Setting</strong></li> </ul> <h3>Advanced Notes</h3> <ul> <li>There is some logic in the script that stop you from making the size too small if you have Line Size set, you can set Line Size to 0 or half your line size value if you really want to override this.</li> <li>You can change the Customize Design settings before generating the QR Code (on <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a>), but you'll need to set Line Size to 0 and there are no promises that it'll print well</li> <li>If you want to use a different site to create the QR code, resize the image to 1147x1147 pixels before converting it to an SVG. Or if the QR code in the image doesn't have a border, resize it to 1000x1000 px.</li> <li>If you want to use a different source for the SVG file, there are instructions for working out the size in the code (<a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a>) at line 215. You'll need to export it as a STL and measure it outside of OpenSCAD, then enter the values into the script.</li> </ul> </blockquote> <p>The linked to Thingiverse page also has some extra steps for adding an icon:</p> <blockquote> <h3>Add an icon</h3> <p>You can import another SVG file as a logo or use logo fonts.</p> <p>The below example uses an <a href="https://iconmonstr.com/?s=wifi" rel="nofollow noreferrer">wifi SVG file</a> from IconMonstr</p> <ul> <li>Download the wifi SVG file</li> <li>Place it in the same folder as the .SCAD file</li> <li>In the customizer: <ul> <li>Add some extra space to the top or bottom of the card under <strong>Extra Size Settings</strong></li> <li>Go to SVG Logo Settings</li> <li>Tick <strong>enable svg logo</strong></li> <li>Enter the filename under <strong>svg logo name</strong></li> <li>Set the <strong>svg y nudge</strong> position and <strong>svg logo scale</strong></li> </ul> </li> </ul> <p><a href="https://i.stack.imgur.com/A2xCK.png" rel="nofollow noreferrer" title="Adding Wi-Fi logo"><img src="https://i.stack.imgur.com/A2xCK.png" alt="Adding Wi-Fi logo" title="Adding Wi-Fi logo" /></a></p> </blockquote>
<p>From the excellent Thingiverse link, <a href="https://www.thingiverse.com/thing:4967931" rel="nofollow noreferrer">Customizable QR Keyring or Tag</a> by <a href="https://www.thingiverse.com/outwardb/designs" rel="nofollow noreferrer"><em>OutwardB</em></a> - which was provided in the (now deleted) <a href="https://3dprinting.stackexchange.com/a/18296/4762">link-only answer</a>:</p> <blockquote> <ol> <li><h3>Create the QR code</h3> <ul> <li><p>Go to <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a></p> </li> <li><p><strong>Only change the Content settings</strong></p> <p>DO NOT change the color, logo or design settings</p> </li> <li><p>Click <strong>Create QR Code</strong></p> </li> <li><p>Click <strong>Download PNG</strong> and wait for the file to download</p> </li> </ul> </li> <li><h3>Convert to SVG</h3> <ul> <li>Go to <a href="https://convertio.co/png-svg/" rel="nofollow noreferrer">PNG to SVG Converter</a> and convert the PNG image you just downloaded to a .SVG file</li> </ul> </li> <li><h3>Customise in OpenSCAD</h3> <p>You will need <a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a> from the <a href="https://www.thingiverse.com/thing:4967931/files" rel="nofollow noreferrer">files repository on Thingverse</a></p> <ol> <li><p>Download OpenSCAD from here and install it - <a href="https://openscad.org/downloads.html" rel="nofollow noreferrer">https://openscad.org/downloads.html</a></p> </li> <li><p>Put the downloaded SVG file in the same folder as the .SCAD file from this page</p> </li> <li><p>Double-click the .SCAD file to open it</p> </li> <li><p>Click <strong>Window</strong>, then untick <strong>Hide Customizer</strong></p> <p><em>Optional</em>: Click <strong>Window</strong>, then tick <strong>Hide Editor</strong></p> </li> <li><p>Enter the SVG file name in the basic settings tab (or rename the file to qr-code.svg before opening OpenSCAD)</p> </li> <li><p>Customize the settings. After changing a setting, you may need to click outside the text box to apply the change</p> </li> <li><p>Click <strong>Design</strong> &gt; <strong>Render</strong> and wait for the design to render</p> </li> <li><p>Click <strong>File</strong> &gt; <strong>Export</strong> &gt; <strong>Export to STL</strong></p> </li> <li><p>Save the file</p> </li> </ol> <p><a href="https://i.stack.imgur.com/VyzXZ.gif" rel="nofollow noreferrer" title="QR Customisation - optional"><img src="https://i.stack.imgur.com/VyzXZ.gif" alt="QR Customisation - optional" title="QR Customisation - optional" /></a></p> </li> </ol> <h3>Notes</h3> <ul> <li><strong>Raised</strong> and <strong>Cut-Out</strong> types are for changing filament at layer height</li> <li><strong>Multi-color</strong> and <strong>Code</strong> are to be used together for inlay/multi-color printers</li> <li>You can also set <em>Base Height</em> or <em>Code Height</em> to 0 and export each part on it's own</li> <li>If you want to print a <strong>double sided tag</strong>, you can set <em>Base Height</em> to 0 and export the second side. Then just flip this over in the slicer</li> <li>The text options are a okay for basic text, but if you want to use another program to add some, you can add extra height to the top/bottom of the card under <strong>Extra Size Setting</strong></li> </ul> <h3>Advanced Notes</h3> <ul> <li>There is some logic in the script that stop you from making the size too small if you have Line Size set, you can set Line Size to 0 or half your line size value if you really want to override this.</li> <li>You can change the Customize Design settings before generating the QR Code (on <a href="https://qrcode-monkey.com" rel="nofollow noreferrer">QRCode Monkey</a>), but you'll need to set Line Size to 0 and there are no promises that it'll print well</li> <li>If you want to use a different site to create the QR code, resize the image to 1147x1147 pixels before converting it to an SVG. Or if the QR code in the image doesn't have a border, resize it to 1000x1000 px.</li> <li>If you want to use a different source for the SVG file, there are instructions for working out the size in the code (<a href="https://www.thingiverse.com/download:10312157" rel="nofollow noreferrer"><code>QR_Code_Customizer_V01_2.scad</code></a>) at line 215. You'll need to export it as a STL and measure it outside of OpenSCAD, then enter the values into the script.</li> </ul> </blockquote> <p>The linked to Thingiverse page also has some extra steps for adding an icon:</p> <blockquote> <h3>Add an icon</h3> <p>You can import another SVG file as a logo or use logo fonts.</p> <p>The below example uses an <a href="https://iconmonstr.com/?s=wifi" rel="nofollow noreferrer">wifi SVG file</a> from IconMonstr</p> <ul> <li>Download the wifi SVG file</li> <li>Place it in the same folder as the .SCAD file</li> <li>In the customizer: <ul> <li>Add some extra space to the top or bottom of the card under <strong>Extra Size Settings</strong></li> <li>Go to SVG Logo Settings</li> <li>Tick <strong>enable svg logo</strong></li> <li>Enter the filename under <strong>svg logo name</strong></li> <li>Set the <strong>svg y nudge</strong> position and <strong>svg logo scale</strong></li> </ul> </li> </ul> <p><a href="https://i.stack.imgur.com/A2xCK.png" rel="nofollow noreferrer" title="Adding Wi-Fi logo"><img src="https://i.stack.imgur.com/A2xCK.png" alt="Adding Wi-Fi logo" title="Adding Wi-Fi logo" /></a></p> </blockquote>
2,045
<p>Using C# 2.0 what is the best way to implement dynamic form controls?</p> <p>I need to provide a set of controls per data object, so should i just do it manually and lay them out while increment the top value or is there a better way?</p>
<p>You can use panels with automatic layout such as <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel.asp" rel="nofollow noreferrer">FlowLayoutPanel</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx" rel="nofollow noreferrer">TableLayoutPanel</a>. </p> <p>Unfortunately there are only 2 panels with automatic layout out of box but you can create custom layout panel.</p> <p>I would recommend you to read following articles: </p> <p><a href="http://msdn.microsoft.com/en-us/library/d4d31tbk.aspx" rel="nofollow noreferrer">How to: Create a Resizable Windows Form for Data Entry</a> </p> <p><a href="http://msdn.microsoft.com/en-us/library/991eahec.aspx" rel="nofollow noreferrer">Walkthrough: Creating a Resizable Windows Form for Data Entry</a></p> <p>Another option would be using of WPF (Windows Presentation Presentation).<br> WPF is a perfect match for your task.<br> WPF controls can be hosted in WinForms apps so you don't have to switch to it completely.</p>
<p>What do you mean by “dynamic”? A new, fixed set of controls for each data row in the data set? Then use a <code>UserControl</code> that contains your controls.</p> <p>Or do you mean that, depending on your data layout, you want to provide the user with a customized set of controls, say, one <code>TextBox</code> for each column?</p>
6,516
<p>I seem right now to be embroiled in a debate with another programmer on this project who thinks that views have no merits. He proposes a system that PHP looks something like this:</p> <pre><code>$draw = new Draw; $nav = $draw-&gt;wideHeaderBox(). $draw-&gt;left(). $draw-&gt;image(). Image::get($image,60,array('id'=&gt;'header_image')). $draw-&gt;imageEnd(). $draw-&gt;leftEnd(). $draw-&gt;left(10). '&lt;div id="header_text"&gt;'. self::defaultSectionText(). '&lt;/div&gt;'. $draw-&gt;leftEnd(). </code></pre> <p>and so on (this is in the controller btw). Now his arguments for this actually make some sense, he claims that if there is a redesign all we need to do is change the HTML in one place and it changes everywhere automatically. For some reason however, this method still rubs me the wrong way, is there any merit to views over this method? I mean besides not having to retype HTML by hand.</p>
<p>HTML time-savers are useful, but they're only useful when they're intuitive and easy-to-understand. Having to instantiate a <code>new Draw</code> just doesn't sound very natural. Furthermore, <code>wideHeaderBox</code> and <code>left</code> will only have significance to someone who intimately knows the system. And what if there <em>is</em> a redesign, like your co-worker muses? What if the <code>wideHeaderBox</code> becomes very narrow? Will you change the markup (and styles, presumable) generated by the PHP method but leave a very inaccurate method name to call the code?</p> <p>If you guys just <em>have</em> to use HTML generation, you should use it interspersed in view files, and you should use it where it's really necessary/useful, such as something like this:</p> <pre><code>HTML::link("Wikipedia", "http://en.wikipedia.org"); HTML::bulleted_list(array( HTML::list_item("Dogs"), HTML::list_item("Cats"), HTML::list_item("Armadillos") )); </code></pre> <p>In the above example, the method names actually make sense to people who aren't familiar with your system. They'll also make more sense to you guys when you go back into a seldom-visited file and wonder what the heck you were doing.</p>
<p>The argument he uses is the argument you need to <em>have</em> views. Both result in only changing it in one place. However, in his version, you are mixing view markup with business code.</p> <p>I would suggest using more of a templated design. Do all your business logic in the PHP, setup all variables that are needed by your page. Then just have your page markup reference those variables (and deal with no business logic whatsoever).</p> <p>Have you looked at smarty? <a href="http://smarty.php.net" rel="nofollow noreferrer">http://smarty.php.net</a></p>
5,851
<p>I have OctoPrint set up on a Raspberry Pi (OctoPi). I have loaded a number of G-code files to the SD card on the printer.</p> <p>My question is: If I initiate a print from the SD card via OctoPrint, can I then turn off the RPi so I can use it for other things while the print continues?</p>
<p>Your printer will stop printing. So no.</p>
<p>Disconnecting the USB or connecting it triggers a reboot in the printer. As a result, you can not disconnect or turn off the print server running OctoPrint.</p>
1,816
<p>In emacs, I've read the following code snippet in <code>simple.el</code>:</p> <pre><code>(frame-parameter frame 'buried-buffer-list) </code></pre> <p>What is the exact meaning of the <code>'buried-buffer-list</code> parameter? What it is used for?</p>
<p>MSSQL2000 won't give you that kind of information. But a way you can identify what tables ARE used (and then deduce which ones are not) is to use the SQL Profiler, to save all the queries that go to a certain database. Configure the profiler to record the results to a new table, and then check the queries saved there to find all the tables (and views, sps, etc) that are used by your applications. </p> <p>Another way I think you might check if there's any "writes" is to add a new timestamp column to every table, and a trigger that updates that column every time there's an update or an insert. But keep in mind that if your apps do queries of the type </p> <pre><code>select * from ... </code></pre> <p>then they will receive a new column and that might cause you some problems. </p>
<p>If you have lastupdate columns you can check for the writes, there is really no easy way to check for reads. You could run profiler, save the trace to a table and check in there</p> <p>What I usually do is rename the table by prefixing it with an underscrore, when people start to scream I just rename it back</p>
5,553
<p>Are <strong>CDATA</strong> tags ever necessary in script tags and if so when?</p> <p>In other words, when and where is this:</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ ...code... //]]&gt; &lt;/script&gt; </code></pre> <p>preferable to this:</p> <pre><code>&lt;script type="text/javascript"&gt; ...code... &lt;/script&gt; </code></pre>
<p>A CDATA section is required if you need your document to parse as XML (e.g. when an XHTML page is interpreted as XML) <em>and you want to be able to write literal <code>i&lt;10</code> and <code>a &amp;&amp; b</code> instead of <code>i&amp;lt;10</code> and <code>a &amp;amp;&amp;amp; b</code></em>, as XHTML will parse the JavaScript code as parsed character data as opposed to character data by default. This is not an issue with scripts that are stored in external source files, but for any inline JavaScript in XHTML you will <em>probably</em> want to use a CDATA section.</p> <p>Note that many XHTML pages were never intended to be parsed as XML in which case this will not be an issue.</p> <p>For a good writeup on the subject, see <a href="https://web.archive.org/web/20140304083226/http://javascript.about.com/library/blxhtml.htm" rel="noreferrer">https://web.archive.org/web/20140304083226/http://javascript.about.com/library/blxhtml.htm</a></p>
<p><a href="http://javascript.about.com/library/blxhtml.htm" rel="nofollow noreferrer">When you want it to validate</a> (in XML/XHTML - thanks, <a href="https://stackoverflow.com/users/6436/loren-segal">Loren Segal</a>).</p>
9,238
<p>I'm having problems when printing small parts over big areas.</p> <p>I'm currently printing quite big casing (~180&nbsp;mm x 100&nbsp;mm), which has hexagonal holes on the corners. On the first layer the printer prints, in order:</p> <ul> <li>Supports inside the holes, </li> <li>Borders around the holes</li> <li>Border of the whole casing and finally </li> <li>Infill (since it is first layer, infill is solid)</li> </ul> <p>When printing borders around holes, printer's head travels between all holes (so that's around 90&nbsp;% of the whole bed width), what results in filament oozing and the hole borders being underextruded (sometimes to the point, that filament doesn't stick to the bed).</p> <p>My setup is CReality3D Ender 3 with Ultimaker Cura 3. Most important settings: </p> <ul> <li>Print speed 40&nbsp;mm/s</li> <li>Nozzle temperature 215&nbsp;&deg;C</li> <li>Bed temperature 60&nbsp;&deg;C</li> <li>Retraction on travel turned on</li> <li>Retraction additional prime amount set to 0.05&nbsp;mm<sup>3</sup>.</li> <li>Outer walls printed after inner ones</li> </ul> <p>What would help (I guess) is slowing down the print after long travels or priming more filament, but proportionally to the travel distance. There are no such settings in Ultimaker Cura though.</p> <p>How can I deal with such problem?</p>
<p>it seems like retraction issue</p> <p>i would say you should experiment with </p> <ul> <li>retraction length - so it would retract more</li> <li>extra extrusion after retraction - so the printer could put some material before it will start your next hole :)</li> </ul> <p>unfortunately there is no good guide how much it should retract and how much it should additionally extrude as it depends on "all your printing circumstances" but here is my arbitrary list in order of importance</p> <ul> <li>filament (density - type and producer)</li> <li>temperature (viscosity - hotter filament flows easier)</li> <li>nozzle diam (as filament escapes easier through big hole ;)</li> <li>heat barrier (cooling efficiency - filament should be cool as long as possible up to (or down to) the nozzle)</li> <li>extruder gearing quality (good coupling makes precise retraction and extra-extrusion)</li> <li>cooling (fan and duct should cool your printing right after it sticks to the surface)</li> </ul> <p>and one more thing worth to mention</p> <p>usually the first layer is not cooled which makes whole system hotter (so filament flows easier)</p> <p>you could experiment with it too especially for big printouts </p> <p>so</p> <ul> <li>overextrude first layer AND </li> <li>turn on cooling first layer</li> </ul> <p>it seems like there is a bunch of things you can do to master it :)</p> <p>good luck - it's definitely manageable</p>
<p>Set <code>retraction_min_travel</code> to 0. The default value is 1.5 and skips retraction when moving less than 1.5 mm. This leads to serious oozing whenever your print has small travel, which seems likely between the hole walls and the supports inside the holes.</p> <p>Also, the "custom start gcode" in Cura's Ender 3 configuration seriously over-primes the extruder, possibly making retraction ineffective until the pressure drops. Lowering the <code>E15</code> and <code>E30</code> amounts to <code>E9</code> and <code>E18</code> improved things <strong>a lot</strong> for me, especially with flex filament, but also with normal PLA. Printing a skirt or brim would probably be an alternative if you don't feel up to editing that part of the config.</p> <p>Increasing the retraction amount could also help. You should <strong>not</strong> need extra prime after travel. It can only help if you've lost material to oozing during travel, and if you have oozing, that's a problem in itself that you need to solve, not paper over by extruding additional material.</p>
1,291
<p>I am using &quot;Pretty PETG&quot; along with PrusaSlicer's consecutive print mode.</p> <p>What I am noticing is that upon finishing the first print, the printer hits <code>MINTEMP BED Fixed</code>. I'm not sure if it's immediate because I let the prints run overnight but I assume the bed cools down and then the error is hit.</p> <p>I'm just starting to learn G-code and my initial thought was there's an errant bed temperature instruction but the only <code>M140 S0</code> instructions I see are in the <code>end_gcode</code> and near the bottom of the file. Maybe there a <code>goto</code> in G-code which may be running after <code>M140 S0</code> which then causes the <code>MINTEMP BED</code> issue? Perhaps there's something else going on?</p>
<p>0.2 mm and 0.4 mm are half the diameter, but the maximum flow is not just half: Flow scales with the area. The 0.4 mm nozzle has an area 4 times as the 0.2 mm one:</p> <p><span class="math-container">$\frac{A_1} {A_2}=\frac {0.2^2}{0.1^2}=4$</span></p> <p>You need to reduce <code>print speed</code> or the <code>volumetric flow</code> by this factor or make sure your printer can handle the increased flow by reducing the viscosity of the melt - for example by increasing the print temperature.</p> <p>Also note, that a 0.2 mm nozzle can't be operated with layer heights above 0.15 mm.</p>
<p>The discussion about slowing the print speed is important, but in my experience it is not at the root of the problem, and slowing down printing may make it worse.</p> <p>If ny &quot;heater&quot; you mean the complete hot-end, then I suspect you are jamming in the cooler part of the hot-end. This cooler part is separated from the heater itself by the heat break, which is often a thin-walled metal tube.</p> <p>The hot side of the heat break is heated by the heater. The cooler-end, the cool side of the heat break, is cooled by two things:</p> <ol> <li>cold filament being moved through it and</li> <li>airflow from the fan over the heat sink fins.</li> </ol> <p>It is heated by:</p> <ol> <li>Thermal conduction through the thin metal tube</li> <li>Convection airflow from the hot-end vertically and over the cooler-end</li> <li>Hot filament being pulled through the heat break during retraction.</li> </ol> <p>When you are printing with a smaller cross-section of extruded filament, the slicer program should adjust the flow rate and speeds based on the lesser volume of plastic extruded for a given pressure. Unfortunately, this is less plastic, so the filament cools the cooler end of the heat break less than it would if the feed rate were higher. As a result, the temperature of the cooler end goes up. If there is insufficient airflow to keep the cooler side below the softening point of filament, the filament softens and jams inside the cooler end.</p> <p>Of course, if your jam actually is in the hot end, this discussion is not relevant.</p> <p>But, I have found with my Prusa i3m3 that I have had problems with jamming in the cooler end, especially when I printed filament with a higher melting temperature, ABS in this case. I reduced the area of the airflow so that no air could pass through other than by passing over the heat sink fins, and the ABS printed correctly.</p> <p>All of 3D printing is a balance of one factor against another. It is hard to lose, though, by increasing the cooler-end temperature. All will seem well until you print something with a lower flow, or a higher retraction rate, or you try using a higher temperature for the same filament. Then the jam can unexpectedly occur, or, perhaps worse, it can be an intermittent jam, or there can be a lot to sticktion, and printing becomes prone to gaps, or occasional under extrusion.</p>
1,744
<p>I am starting a new <strong>client/server</strong> project at work and I want to start using some of the newer technologies I've been reading about, LINQ and Generics being the main ones. Up until now I have been developing these types of applications with MySQL as clients were unwilling to pay the large licence costs for MSSQL. </p> <p>I have played around a small amount with the express versions but have never actually developed anything with them. The new application will not have more than 5 concurrent connections but will be needed for daily reporting.</p> <ol> <li><p>Can MSSQL 2005 express still be downloaded? I cant seem to find it on the microsoft site. I would be hesitant to use MSSQL 2008 on a project so soon after its release.</p></li> <li><p>Are the express version adequate for my needs, I'm sure loads of people reading this have used them. Did you encounter any problems?</p></li> </ol>
<p>The answer to the question on any project in regards to what platform/technologies to use is: <strong>What does everyone know best?</strong></p> <ol> <li><p>Yes express <a href="http://www.microsoft.com/express/2005/sql/download/" rel="nofollow noreferrer">can still be downloaded</a>.</p></li> <li><p>Will it fit your requirements? That depends on your requirements, of course. I have deployed MSSQL2005 Express on several enterprise level projects which I knew had a fixed database size that would never be exceeded (Express has a limit of each database of 4Gb). Also keep in mind there are other hardware constraints such as a 1 cpu limit.</p></li> </ol> <p>Another thing to consider is if you need the Enterprise level tools that come with a paid edition of SQL Server. If you are moving a lot of flat data around you are stuck writing your own Bulk Copy Procs, which rule the house, but its an extra step, no doubt.</p>
<p>Note sure about #2 but you can download <a href="http://www.microsoft.com/sql/editions/express/default.mspx" rel="nofollow noreferrer">SQL Server Express 2005 here</a>.</p>
4,646
<p>Harking back to the days of "singing disk drives," I am wondering if anyone's written music to be performed on a 3D printer. Most of us have noticed in passing that the servo motors for X and Y drive generate a different pitch depending on motion speed. With some care and experimentation, one could write g-code to produce not only a tone but even a 2-tone chord. So -- has this been done? Does anyone want to do so? (Note that there's no need to simultaneously produce a print, but that would be even classier).</p>
<p>Yes, it has been done before, see <a href="https://github.com/forflo/gCodeMusic" rel="noreferrer">here</a> and <a href="https://github.com/yeokm1/midi-to-simple-metal-gcode" rel="noreferrer">here.</a></p> <p>The README file of the first repository linked above contains a detailed explanation of the basic idea/calculations involved. A short excerpt:</p> <blockquote> <p>As you can set the parameters of G1 in such a way as to precisely control the velocity and the distance of a movement along a certain axis, you can control the operation frequency of the stepper motors as well as the actual time to complete a movement.</p> </blockquote> <p>On another note (pun intended), you can also play music by using the code <a href="http://reprap.org/wiki/G-code#M300:_Play_beep_sound" rel="noreferrer"><code>M300</code></a>.</p>
<p>I actually did this, on my Malyan M150. </p> <p>After not that much experimentation at all it turned out that the frequency of the produced tone scales linearly with the speed of the motors. Due to the nature of the way humans perceive music, the actual frequencies do not matter at all, just the relative difference in frequency between the tones. This means that it is actually really easy to let a 3D printer play a tune, you just have to make sure that when the next tone needs to have a frequency that is for example 20% higher than the last one, the motor needs to move 20% faster, no need to actually measure at which speeds the printer produces which tones. </p> <p>One of the main issues turned out to be the maximum speed of the motors, which wasn't high enough for some of the higher notes, but this issue could be solved by multiplying all the speeds by a number lower than 1, thereby lowering the required speeds while still maintaining the original melody. Playing two tones at the same time proved to be a bit too difficult for my not that great programming skills, while not being worth the effort because somehow there was quite a large difference in volume between the motors. </p> <p>In the end, I made a MATLAB script that converts MIDI files to G-code with the following result: <a href="https://www.youtube.com/watch?v=jPV-TolORK4" rel="nofollow noreferrer">3D-printer playing popcorn song</a></p>
853