instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>I am in a position where I could become a team leader of a team distributed over two countries. This team would be the tech. team for a start up company that we plan to bootstrap on limited funds. So I am trying to find out ways to minimize upfront expenses. Right now we are planning to use Java and will have a lot of junit tests. I am planing on using github for VCS and lighthouse for a bug tracker. In addition I want to add a continuous integration server but I do not know of any continuous integration servers that are offered as a web service.</p> <p>Does anybody know if there are continuous integration servers available in a <em>software as a service</em> model?</p> <p>P.S. if anybody knows were I can get these three services at one location that would be great to know to.</p>
<p>I am assuming you are talking about <em>continuous</em> integration.</p> <p>You can run <a href="http://cruisecontrol.sourceforge.net/" rel="nofollow noreferrer">CruiseControl</a> on a virtual machine or an old machine, but if it needs to be up in the Internet, you can try virtual dedicated server hosting services. You can save money by picking Linux here, but I'd go for a Windows server if your target platform is Windows.</p>
<p>I am assuming you are talking about <em>continuous</em> integration.</p> <p>You can run <a href="http://cruisecontrol.sourceforge.net/" rel="nofollow noreferrer">CruiseControl</a> on a virtual machine or an old machine, but if it needs to be up in the Internet, you can try virtual dedicated server hosting services. You can save money by picking Linux here, but I'd go for a Windows server if your target platform is Windows.</p>
8,523
<p>I've somehow managed to get an SVN repository into a bad state. I've moved a directory and now I can't commit it in its new location.</p> <p>As far as <code>svn status</code> is concerned, the directory is unknown (the name of the directory is <code>type</code>).</p> <pre> $ svn status ? type </pre> <p>When I try to add the directory, the server says it already exists.</p> <pre> $ svn add type svn: warning: 'type' is already under version control </pre> <p>If I try to update the directory, it's gone again.</p> <pre> $ svn update type svn: '.' is not under version control </pre> <p>If I try to commit it, the server complains that it's old parent directory no longer exists.</p> <pre> $ svn commit type -m "Moving type" svn: Commit failed (details follow): svn: '/prior/trunk/src/nyu/prior/cvc3/theorem_prover/expression' path not found </pre> <p>To add to the mystery, the contents of the directory are marked as modified.</p> <pre> $ svn status type A + type M + type/IntegerType.java M + type/BooleanType.java M + type/Type.java M + type/RationalRangeType.java M + type/RationalType.java M + type/IntegerRangeType.java </pre> <p>If I try to update from within the directory, I get this.</p> <pre> $ cd type $ svn update svn: Two top-level reports with no target </pre> <p>Committing from within the directory gives the same <code>path not found</code> error as above.</p> <p>What's going on and how do I fix it?</p> <p>EDIT: @Rob Oxspring caught me out: I got too aggressive moving things around in Eclipse.</p> <p>UPDATE: I'm accepting @Rob Oxspring's answer of "don't do that/just start over" and taking his advice. I'd still be interested if anybody could tell me: (a) what the above error messages <em>mean</em> precisely and (b) how to actually <em>fix</em> the problem.</p>
<p>It looks to me like <code>type</code> was created by some Subversion-aware copy command, then moved into the current directory using a Subversion-unaware copy. In my experience, this sort of thing typically occurs when package refactoring operations have been chained together in Eclipse without commits in between. Typically, Subversion doesn't handle it well when you copy/move a locally copied/moved file or folder, although I think version 1.5 may handle it better.</p> <p>To avoid this in the future, commit between such steps. If you'd like to hide the intervening commits then I'd recommend doing the multi-step refactoring on a branch and then merging the changes back into the mainline in that single commit you were after.</p> <p>If it's not too much work, then I'd recommend getting back to a clean working copy and redoing your changes, committing after each step. If you're happy to lose the history, i.e. allowing the new <code>IntegerType.java</code> to not be linked at all to the old <code>IntegerType.java</code>, then you could take the approach suggested by BCS:</p> <ul> <li>Move your changed files into some temporary location, stripping out any <code>.svn</code> directories</li> <li>Update your working copy into a clean working state</li> <li>Copy your changes back to where you want them to be</li> <li>Commit the resulting working copy</li> </ul>
<p>My experience is that sometimes the local copy gets out of sync with the repository. I usually solve this by going up the local directory tree, starting from the directory with the problem and try to do do cleanup and update with each step.</p>
6,922
<p>Say I wanted to print a plastic credit card like shape (like <a href="https://rads.stackoverflow.com/amzn/click/com/B07193KG7G" rel="nofollow noreferrer" rel="nofollow noreferrer">these</a>), but with a QR code engraved. How could I do that for cheap? You can buy an "ID card printer" for $1,000-1,500 on Amazon, but that's way too much for printing one or two cards. Maybe down the road this would be a good option, but I kind of like the option of 3D printing the card from scratch, so the QR code bleeds halfway or all the way through the card, rather than just being printed on the surface. Is this possible for cheap? Maybe like <a href="https://www.library.ucsf.edu/news/3d-print-the-ultimate-business-card/" rel="nofollow noreferrer">this</a> but not as fancy. Mainly (I'm new to all this) I am wondering what machine would accomplish this for low price yet good quality, and what other equipment I would need.</p> <p>Basically, what printer is best for this type of task?</p>
<p><strong>FDM printer?</strong><br> If you want to print one, maybe you should outsource it (let it print the tag on both sides), even the most affordable printers are in the \$100 - \$150 price range. If you want a printer and use it also to create ID tags, you could go for an FDM printer. Considering your request of having the tag inside (and through) the ID-card you need a dual filament option (one or two nozzle arrangement). If the tag can sit on top you can print it with a filament change with a single filament single nozzle printer. But, don't expect to get crystal clear prints (see experience printing signs below)!</p> <p><strong>Alternatives</strong><br> As an alternative, you could print a blank PLA ID-card and laser mark the tag onto both sides, see e.g. <a href="https://cdn.colorfabb.com/media/wysiwyg/colorfabb_video/moving%20banner%20lasermarking_1.webm" rel="nofollow noreferrer">this video</a>.</p> <p>If it is a small batch you can also consider printing/lasering stickers and stick these onto blank ID cards.</p> <hr> <p><strong>From experience</strong><br> I've done some signs with black letters on a white background for "on-lay", inlay and through arrangements using a more expensive (for home use) dual extruder 3D printer (Ultimaker 3 Extended about \$5000,-) with PETG, but the results were not very satisfying. Usually the black smears out on or in the white no matter tweaking the options. Considering the size of an ID-card, the amount of tag squares, this is even more likely to happen when you print at that small size (the signs I printed were sized similar to the "A5" paper standard). </p> <p>From my experience I would say that a 3D printer may not be the best solution for your task.</p>
<p>One option to create the tag you require can be accomplished with a single extruder and a bit of manual intervention.</p> <p>I've performed the sequence of steps from a <a href="https://www.thingiverse.com/thing:1973570" rel="nofollow noreferrer">Thingiverse creation</a> that resulted in a box lid for a gift card box. It's a single layer of multiple colors placed on the print bed, then consolidated with a backing layer.</p> <p>For your card objective, the single layer provides the contrast and you can determine easily how thick you wish the remaining portion to print.</p> <p><a href="https://i.stack.imgur.com/XhBlN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XhBlN.jpg" alt="snowman box lid"></a></p> <p>The detail level is reasonably good, limited to the printer nozzle and specifications. A glass bed or similarly smooth surface bed will provide optimum results. As 0scar suggests, a 3D printer in the US$100-150 will likely suffice, but check reviews and forums for troublesome products of such a low price.</p>
1,558
<p>I have several "ASP:TextBox" controls on a form (about 20).<br> When the form loads, the text boxes are populated from a database.<br> The user can change the populated values, and when they submit the form, I take the values posted to the server and conditionally save them (determined by some business logic).<br> All but 1 of the text boxes work as intended.</p> <p>The odd box out, upon postback, does not contain the updated value that the user typed into the box.<br> When debugging the application, it is clear that <code>myTextBox.Text</code> reflects the old, pre-populated value, not the new, user-supplied value.<br> Every other box properly shows their respective user-supplied values.</p> <p>I did find a workaround.<br> My solution was to basically extract the text box's value out of the <code>Request.Form</code> object: <code>Request.Form[myTextBox.UniqueID]</code>, which does contain the user-supplied value.</p> <p>What could be going on, here?<br> As I mentioned, the other text boxes receive the user-supplied values just fine, and this particular problematic text box doesn't have any logic associated to it -- it just takes the value and saves it.<br> The main difference between this text box and the others is that this is a multi-line box (for inputting notes), which I believe is rendered as an HTML "textarea" tag instead of an "input" tag in ASP.NET.</p>
<p>Are you initially loading the data only when !Page.IsPostBack? Also, is view state enabled for the text box?</p>
<p>Remember the order of the page lifecycle, and where you are databinding your form.</p> <ul> <li>PreInit</li> <li>Init</li> <li>Load</li> <li>Your Control Event Handler</li> </ul> <p>If you are reading the value in the Control Event handler, yet databinding in Init or Load, you'll have the old value.</p> <p>The trick is to always databind in the correct event, or check for postback and don't databind then.</p>
4,299
<p>Imagine we have a program trying to write to a particular file, but failing.</p> <p>On the Windows platform, what are the possible things which might be causing the file to be un-writable, and what steps could be suggested to an end user/administrator to fix it.</p> <hr /> <p>Please include steps which might require administrator permissions (obviously users may not be administrators, but for this question, let's assume they are (or can become) administrators.</p> <p>Also, I'm not really familiar with how permissions are calculated in windows. - Does the user need write access to each directory up the tree, or anything similar to that?</p>
<p>Some suggestions:</p> <ul> <li>No write permission (get permission through Security tab on file Properties window; you must be the file owner or an Administrator)</li> <li>File is locked (close any program that may have the file open, then reboot if that doesn't help)</li> <li>File has the read-only DOS attribute set (unset it from file Properties window, or with <code>attrib -r</code>; you must be the file owner or an Administrator)</li> </ul> <p>Edit 1: Only the second item (file is locked) has a possible solution that all users are likely to be able to do without help. For the first and third, you'll probably want to provide guidance (and hope the file wasn't made read-only intentionally!).</p> <p>Edit 2: Technically, the user does need write and execute (chdir) permissions on all directories up to the root. Windows may skip some of the recursive checks up the tree as a performance optimization, but you should not rely on this because admins can force on these so-called "traverse checks" for certain users.</p> <p>Edit 3: @RobM: Yes, you should check that there is no obvious reason that the user should not have the permissions she needs but does not have. I alluded to this in a less direct way in my first edit. However, in some cases users should have write permission to a file but do not because of filesystem corruption, a misbehaving program, or a mistake on their own part.</p>
<p>On Vista could it also be that it's "marked" as unsafe because it's been downloaded from the internet and you have to click the unblock button on it's explorer properties dialog?</p>
5,824
<p>What is the reason browsers do not correctly recognize:</p> <pre><code>&lt;script src="foobar.js" /&gt; &lt;!-- self-closing script element --&gt; </code></pre> <p>Only this is recognized:</p> <pre><code>&lt;script src="foobar.js"&gt;&lt;/script&gt; </code></pre> <p>Does this break the concept of XHTML support?</p> <p>Note: This statement is correct at least for all IE (6-8 beta 2).</p>
<p>The non-normative appendix ‘HTML Compatibility Guidelines’ of the XHTML 1 specification says:</p> <p><a href="http://www.w3.org/TR/xhtml1/#C_3" rel="noreferrer">С.3. Element Minimization and Empty Element Content</a></p> <blockquote> <p>Given an empty instance of an element whose content model is not <code>EMPTY</code> (for example, an empty title or paragraph) do not use the minimized form (e.g. use <code>&lt;p&gt; &lt;/p&gt;</code> and not <code>&lt;p /&gt;</code>).</p> </blockquote> <p><a href="http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict" rel="noreferrer">XHTML DTD</a> specifies script elements as:</p> <pre><code>&lt;!-- script statements, which may include CDATA sections --&gt; &lt;!ELEMENT script (#PCDATA)&gt; </code></pre>
<p>Difference between 'true XHTML', 'faux XHTML' and 'ordinary HTML' as well as importance of the server-sent MIME type had been <a href="https://stackoverflow.com/a/70288/540955">already described here well</a>.</p> <p>If you want to try it out right now, here is simple editable snippet with live preview including self-closed script tag (see <code>&lt;script src=&quot;data:text/javascript,/*functionality*/&quot; /&gt;</code>) and XML entity (unrelated, see <code>&amp;x;</code>).</p> <p>As you can see, depending on the MIME type of embedding document the data-URI JavaScript functionality is either executed and consecutive text displayed (in <code>application/xhtml+xml</code> mode) or not executed and consecutive text 'devoured' by the script (in <code>text/html</code> mode).</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>div { display: flex; } div + div {flex-direction: column; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;Mime type: &lt;label&gt;&lt;input type="radio" onchange="t.onkeyup()" id="x" checked name="mime"&gt; application/xhtml+xml&lt;/label&gt; &lt;label&gt;&lt;input type="radio" onchange="t.onkeyup()" name="mime"&gt; text/html&lt;/label&gt;&lt;/div&gt; &lt;div&gt;&lt;textarea id="t" rows="4" onkeyup="i.src='data:'+(x.checked?'application/xhtml+xml':'text/html')+','+encodeURIComponent(t.value)" &gt;&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [&lt;!ENTITY x "true XHTML"&gt;]&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;body&gt; &lt;p&gt; &lt;span id="greet" swapto="Hello"&gt;Hell, NO :(&lt;/span&gt; &amp;x;. &lt;script src="data:text/javascript,(g=document.getElementById('greet')).innerText=g.getAttribute('swapto')" /&gt; Nice to meet you! &lt;!-- Previous text node and all further content falls into SCRIPT element content in text/html mode, so is not rendered. Because no end script tag is found, no script runs in text/html --&gt; &lt;/p&gt; &lt;/body&gt; &lt;/html&gt;&lt;/textarea&gt; &lt;iframe id="i" height="80"&gt;&lt;/iframe&gt; &lt;script&gt;t.onkeyup()&lt;/script&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>You should see <code>Hello, true XHTML. Nice to meet you!</code> below textarea.</p> <p>For incapable browsers you can copy content of the textarea and save it as a file with <code>.xhtml</code> (or <code>.xht</code>) extension (<a href="https://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work?rq=1#comment44088198_70288">thanks Alek for this hint</a>).</p>
9,530
<p>I want to create a micromouse project for fun that use 2 20&nbsp;mm&nbsp;x&nbsp;8.5&nbsp;mm (0.8&nbsp;mm shaft) motors. I have my own PCB as base. I want its built-in gears will be attached to two 3D-printed wheels with gears at the back of the wheels at each side. I'm having hard time to start designing the gears since I couldn't find any tutorial.</p> <p>(photo for reference and not mine) <a href="https://i.stack.imgur.com/ady1o.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ady1o.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/3JM9F.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3JM9F.jpg" alt="enter image description here"></a></p> <p>My Question:</p> <ol> <li>How to design the gears at the back of the wheel? (I use Sketchup)</li> <li>Is 3d-printing such small objects possible?</li> </ol>
<p>Designing gears is very difficult for a variety of reasons. Let me list what you should take into account:</p> <ol> <li><p>The shape of the teeth are very peculiar, trapezoid shape will not work as the meshing will not be constant. Exact shape is controlled by the pressure angle</p></li> <li><p>In lower number of teeth, teeth shape must be modified to avoid any locks, these are called cutoffs</p></li> <li><p>Reducing the amount of material to print requires careful design, most people simply place circles but they cause weak points.</p></li> <li><p>Herringbone and double herringbone gears improve meshing but are even more difficult to design.</p></li> </ol> <p>For the reasons stated above, creating gears by hand is next to impossible without special tools. Luckily for those who are searching for it, there are systems that generate gears for 3D printing. This <a href="https://www.thingiverse.com/thing:1427458" rel="nofollow noreferrer">customizer</a> has many options and is very open about the licensing, which is another issue with many scripts. For example, it is explicitly forbidden to print parts imported from the McMaster-Carr Catalogue.</p> <p>If you use OpenSCAD, <a href="https://www.thingiverse.com/thing:1427673" rel="nofollow noreferrer">this library</a> can create racks to go with the gears.</p> <p>The parameters of the customizer are explained in the page. The script also contains explanations of every module and function.</p> <p>Disclaimer: Both scripts are mine, yet I do not earn anything when people use them. I created the library when I was unable to find the gears I needed, published with a relaxed license to help others.</p>
<p>Designing gears is very difficult for a variety of reasons. Let me list what you should take into account:</p> <ol> <li><p>The shape of the teeth are very peculiar, trapezoid shape will not work as the meshing will not be constant. Exact shape is controlled by the pressure angle</p></li> <li><p>In lower number of teeth, teeth shape must be modified to avoid any locks, these are called cutoffs</p></li> <li><p>Reducing the amount of material to print requires careful design, most people simply place circles but they cause weak points.</p></li> <li><p>Herringbone and double herringbone gears improve meshing but are even more difficult to design.</p></li> </ol> <p>For the reasons stated above, creating gears by hand is next to impossible without special tools. Luckily for those who are searching for it, there are systems that generate gears for 3D printing. This <a href="https://www.thingiverse.com/thing:1427458" rel="nofollow noreferrer">customizer</a> has many options and is very open about the licensing, which is another issue with many scripts. For example, it is explicitly forbidden to print parts imported from the McMaster-Carr Catalogue.</p> <p>If you use OpenSCAD, <a href="https://www.thingiverse.com/thing:1427673" rel="nofollow noreferrer">this library</a> can create racks to go with the gears.</p> <p>The parameters of the customizer are explained in the page. The script also contains explanations of every module and function.</p> <p>Disclaimer: Both scripts are mine, yet I do not earn anything when people use them. I created the library when I was unable to find the gears I needed, published with a relaxed license to help others.</p>
1,200
<p>I've found <a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.scriptingjsonserializationsection.aspx" rel="noreferrer"><code>ScriptingJsonSerializationSection</code></a> but I'm not sure how to use it. I could write a function to convert the object to a JSON string manually, but since .Net can do it on the fly with the <code>&lt;System.Web.Services.WebMethod()&gt;</code> and <code>&lt;System.Web.Script.Services.ScriptMethod()&gt;</code> attributes so there must be a built-in way that I'm missing. </p> <p>PS: using Asp.Net 2.0 and VB.Net - I put this in the tags but I think people missed it.</p>
<p>This should do the trick</p> <pre><code>Dim jsonSerialiser As New System.Web.Script.Serialization.JavaScriptSerializer Dim jsonString as String = jsonSerialiser.Serialize(yourObject) </code></pre>
<p>Try</p> <pre><code>System.Web.Script.Serialization.JavaScriptSerializer </code></pre> <p>or Check out <a href="http://www.json.org/" rel="nofollow noreferrer">JSON.org</a> there is a whole list of libraries written to do exactly what you want.</p>
5,555
<p>I'm looking for a .NET regular expression extract all the URLs from a webpage but haven't found one to be comprehensive enough to cover all the different ways you can specify a link. </p> <p>And a side question:</p> <p>Is there <strong>one regex to rule them all</strong>? Or am I better off using a series of less complicated regular expressions and just using mutliple passes against the raw HTML? (Speed vs. Maintainability)</p>
<pre><code>((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+) </code></pre> <p>I took this from <a href="http://regexlib.com/Search.aspx?k=URL" rel="nofollow noreferrer">regexlib.com</a></p> <p>[editor's note: the {1} has no real function in this regex; <a href="https://stackoverflow.com/questions/13470/question-about-specific-regular-expression">see this post</a>]</p>
<p>URL's? As in images/scripts/css/etc.?</p> <blockquote> <p><code>%href="(.["]*)"%</code></p> </blockquote>
2,798
<p>Given this HTML:</p> <pre><code>&lt;ul id="topnav"&gt; &lt;li id="topnav_galleries"&gt;&lt;a href="#"&gt;Galleries&lt;/a&gt;&lt;/li&gt; &lt;li id="topnav_information"&gt;&lt;a href="#"&gt;Information&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>And this CSS:</p> <pre class="lang-css prettyprint-override"><code>#topnav_galleries a, #topnav_information a { background-repeat: no-repeat; text-indent: -9000px; padding: 0; margin: 0 0; overflow: hidden; height: 46px; width: 136px; display: block; } #topnav { list-style-type: none; } #topnav_galleries a { background-image: url('image1.jpg'); } #topnav_information a { background-image: url('image2.jpg'); } </code></pre> <p>How would I go about turning the <code>topnav</code> list into an inline list?</p>
<p>Try this:</p> <pre class="lang-css prettyprint-override"><code>#topnav { overflow:hidden; } #topnav li { float:left; } </code></pre> <p>And for IE you will need to add the following:</p> <pre class="lang-css prettyprint-override"><code>#topnav { zoom:1; } </code></pre> <p>Otherwise your floated &lt; li > tags will spill out of the containing &lt; ul >.</p>
<p>An alternative to floating the elements left, is this:</p> <pre class="lang-css prettyprint-override"><code>#topnav li { display: inline; } </code></pre>
6,696
<p>This is my first post here and I wanted to get some input from people doing iPhone development. Other than the Apple DevCenter, where are there good sites to learn iPhone developement?</p> <p>I know Apple has a tough NDA but there has to be people talking about writing applications for the iPhone.</p>
<p><a href="http://www.icodeblog.com/tag/iphone/" rel="nofollow noreferrer">This site</a> covers some of the basics with little regard for the NDA. Start at the bottom and work up.</p>
<p>In <a href="http://www.raywenderlich.com/tutorials" rel="nofollow">http://www.raywenderlich.com/tutorials</a> you will find a lots of good tutorials, and you will be up to date with new iOS features as soon as Apple release then.</p>
4,165
<p>This is my first time building a 3D printer (a "<a href="https://www.3dprintersonlinestore.com/creality-ender4-3d-printer" rel="nofollow noreferrer">Creality Ender-4</a>").</p> <p>Everything is going fine except the "extruder kit" part that does not have enough space to attach on the frame. Should I drill it to have a longer hole so it can be attached to the frame? I just want another set of eyes to look at it to make sure I'm not crazy.</p> <p><a href="https://i.stack.imgur.com/kw3kh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kw3khm.jpg" alt="Extruder - image#1" title="Extruder - image#1"></a></p> <p><a href="https://i.stack.imgur.com/VCDP6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VCDP6m.jpg" alt="Extruder - image#2" title="Extruder - image#2"></a> <a href="https://i.stack.imgur.com/1Z8C2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Z8C2m.jpg" alt="Extruder - image#3" title="Extruder - image#3"></a></p>
<p>According to the description, the drive gear you have has a <code>10.8mm</code> diameter. This means that (in the ideal case) one full rotation of the drive gear will advance a length of filament equal to its circumference, which is <code>pi x 10.8mm</code> or approximately <code>33.93mm</code>.</p> <p>Your motor rotates <code>1.8</code> degrees per step, so it takes <code>360 / 1.8 = 200 steps</code> for a full rotation. Since you are using 16x microstepping, this is multiplied to <code>200 x 16 = 3200 steps</code>.</p> <p>You thus end up with a steps per mm value of <code>3200 / 33.93 = 94.31 steps/mm</code>.</p> <p>You might need to calibrate this further, for instance by extruding a set length of filament (e.g. 100mm) and measuring how much is actually extruded, and then compensating the steps/mm value to get you closer to the desired 100mm. A simple way to measure this is to put a mark on your filament at 150mm from the extruder, and then (after extruding 100mm) measure how close the mark is to the extruder (which should be 50mm) However, this theoretically computed value should be a good starting point. Note that the speed you do this test at should be close to your normal printing speed, since extruding at a much higher (resp. lower) speed will falsely lead you to believe you are underextruding (resp. overextruding).</p>
<p>Simplest way to calculate your extrusion is:</p> <p>Set your number of perimeters walls 1 top and bottom layer 0 infill 0% and print simple 20x20x20 cube look at the wall thickness with caliper and compare your extrusion width value on your slicer software</p>
657
<p>My <code>C#</code> program has a list of files that can be dragged from it and dropped into another program. My requirements are that the file be copied to a different directory first.</p> <p>So, can I be notified of the drop operation so that I can only copy the file if operation succeeds? I'd rather wait till I know it needs to be copied before actually performing the copy.</p> <p>Also, is it possible to know what program the drop operation is occurring in? Ideally I'd like to alter the filepath based on who or what its being dropped.</p> <p>The solution to this can be in any .NET language or <code>C/C++</code> with <code>COM</code>.</p>
<p>There are a few ambiguities in your question. What operation needs to be successful?</p> <p>For everything you want to know about drag and drop, browse through these search results (multiple pages worth):</p> <p><a href="http://www.google.com/search?q=drag+drop+site%3Ablogs.msdn.com%2Foldnewthing&amp;rls=com.microsoft:en-us&amp;ie=UTF-8&amp;oe=UTF-8&amp;startIndex=&amp;startPage=1" rel="nofollow noreferrer">Raymond Chen on drag and drop</a></p>
<p>So, you intend to modify the data being dropped based on the drop target? I don't think this is possible; after all, you populate the data when the drag is initiated.</p>
4,331
<p>From what I've seen, you can take a typical extruder heater, apply the designated supply voltage without temperature control, and as long as the heater isn't contacting something with a flashpoint below the temperature the heater reaches, the heater will not catch on fire. Thus, unless one catches the filament on fire, it seems that thermal runaway of the extruder heater wouldn't normally start a fire.</p> <p>I'm not sure what would happen if someone installed wrong components, such as a 12V heater to a 24V supply. What are situations that could cause a 3D print to catch fire?</p>
<p>A normal hotend will not melt or cause fires, usually, see first video. However, if the power regulating unit fails as well and higher voltage is supplied (19 V on 12 V cartridge are enough) it can happen, see second video.</p> <p>Fires are more likely caused by overheating wires, especially where joints are presents.</p> <p>Hotend runaway does not cause fires from the hotend itself, but it could cause fire related to its wiring. Also, the uncontrolled temperature may make the hot end fan fail, worsening the situation.</p> <p>Issues canbe caused also by a runaway on the bed and overheating MOSFETs.</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/rPvKBRpU0bo?start=0"></iframe> </div></div></p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/qVjWg2vuWzk?start=0"></iframe> </div></div></p>
<p>A normal hotend will not melt or cause fires, usually, see first video. However, if the power regulating unit fails as well and higher voltage is supplied (19 V on 12 V cartridge are enough) it can happen, see second video.</p> <p>Fires are more likely caused by overheating wires, especially where joints are presents.</p> <p>Hotend runaway does not cause fires from the hotend itself, but it could cause fire related to its wiring. Also, the uncontrolled temperature may make the hot end fan fail, worsening the situation.</p> <p>Issues canbe caused also by a runaway on the bed and overheating MOSFETs.</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/rPvKBRpU0bo?start=0"></iframe> </div></div></p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/qVjWg2vuWzk?start=0"></iframe> </div></div></p>
1,827
<p>I have a method which takes params object[] such as:</p> <pre><code>void Foo(params object[] items) { Console.WriteLine(items[0]); } </code></pre> <p>When I pass two object arrays to this method, it works fine:</p> <pre><code>Foo(new object[]{ (object)"1", (object)"2" }, new object[]{ (object)"3", (object)"4" } ); // Output: System.Object[] </code></pre> <p>But when I pass a single object[], it does not take my object[] as the first param, instead it takes its all elements like I wanted to pass them one by one:</p> <pre><code>Foo(new object[]{ (object)"1", (object)"2" }); // Output: 1, expected: System.Object[] </code></pre> <p>How do I pass a single object[] as a first argument to a params array?</p>
<p>A simple typecast will ensure the compiler knows what you mean in this case.</p> <pre><code>Foo((object)new object[]{ (object)"1", (object)"2" })); </code></pre> <p>As an array is a subtype of object, this all works out. Bit of an odd solution though, I'll agree.</p>
<p>One option is you can wrap it into another array:</p> <pre><code>Foo(new object[]{ new object[]{ (object)"1", (object)"2" } }); </code></pre> <p>Kind of ugly, but since each item is an array, you can't just cast it to make the problem go away... such as if it were Foo(params object items), then you could just do:</p> <pre><code>Foo((object) new object[]{ (object)"1", (object)"2" }); </code></pre> <p>Alternatively, you could try defining another overloaded instance of Foo which takes just a single array:</p> <pre><code>void Foo(object[] item) { // Somehow don't duplicate Foo(object[]) and // Foo(params object[]) without making an infinite // recursive call... maybe something like // FooImpl(params object[] items) and then this // could invoke it via: // FooImpl(new object[] { item }); } </code></pre>
5,701
<p>Is there an easy way in C# to create <a href="http://en.wikipedia.org/wiki/Ordinal_numbers_%28linguistics%29" rel="noreferrer">Ordinals</a> for a number? For example:</p> <ul> <li>1 returns 1st</li> <li>2 returns 2nd</li> <li>3 returns 3rd</li> <li>...etc</li> </ul> <p>Can this be done through <code>String.Format()</code> or are there any functions available to do this?</p>
<p>This page gives you a complete listing of all custom numerical formatting rules:</p> <p><a href="https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings" rel="noreferrer">Custom numeric format strings</a></p> <p>As you can see, there is nothing in there about ordinals, so it can't be done using <code>String.Format</code>. However its not really that hard to write a function to do it.</p> <pre><code>public static string AddOrdinal(int num) { if( num &lt;= 0 ) return num.ToString(); switch(num % 100) { case 11: case 12: case 13: return num + &quot;th&quot;; } switch(num % 10) { case 1: return num + &quot;st&quot;; case 2: return num + &quot;nd&quot;; case 3: return num + &quot;rd&quot;; default: return num + &quot;th&quot;; } } </code></pre> <p>Update: Technically Ordinals don't exist for &lt;= 0, so I've updated the code above. Also removed the redundant <code>ToString()</code> methods.</p> <p>Also note, this is not internationalized. I've no idea what ordinals look like in other languages.</p>
<p>Another alternative that I used based on all the other suggestions, but requires no special casing:</p> <pre><code>public static string DateSuffix(int day) { if (day == 11 | day == 12 | day == 13) return &quot;th&quot;; Math.DivRem(day, 10, out day); switch (day) { case 1: return &quot;st&quot;; case 2: return &quot;nd&quot;; case 3: return &quot;rd&quot;; default: return &quot;th&quot;; } } </code></pre>
4,050
<p>I have a couple of files containing a value in each line.</p> <p><strong>EDIT :</strong></p> <p>I figured out the answer to this question while in the midst of writing the post and didn't realize I had posted it by mistake in its incomplete state.</p> <p>I was trying to do:</p> <pre><code>paste -d ',' file1 file2 file 3 file 4 &gt; file5.csv </code></pre> <p>and was getting a weird output. I later realized that was happening because some files had both a carriage return and a newline character at the end of the line while others had only the newline character. I got to always remember to pay attention to those things. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>file 1:</p> <pre> 1 2 3 </pre> <p>file2:</p> <pre> 2 4 6 </pre> <pre><code>paste --delimiters=\; file1 file2 </code></pre> <p>Will yield:</p> <pre> 1;2 3;4 5;6 </pre>
<p>you probably need to clarify or retag your question but as it stands the answer is below.</p> <p>joining two files under Linux</p> <pre><code>cat filetwo &gt;&gt; fileone </code></pre>
4,485
<p>What is the difference between <strong>CodeFile</strong>="file.ascx.cs" and <strong>CodeBehind</strong>="file.ascx.cs" in the declaration of a ASP.NET user control?</p> <p>Is one newer or recommended? Or do they have specific usage?</p>
<p><strong>CodeBehind</strong>: Needs to be compiled (ASP.NET 1.1 model). The compiled binary is placed in the bin folder of the website. You need to do a compile in Visual Studio before you deploy. It's a good model when you don't want the source code to be viewable as plain text. For example when delivering to a customer to whom you don't have an obligation to provide code.</p> <p><strong>CodeFile</strong>: You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsoft.NET[.NET version]\Temporary ASP.NET Files. </p>
<p>Codebehind file need to compile before run but in src we dont need to compile and then run.. just save the file.</p>
9,864
<pre><code>int i = 4; string text = "Player "; cout &lt;&lt; (text + i); </code></pre> <p>I'd like it to print <code>Player 4</code>.</p> <p>The above is obviously wrong but it shows what I'm trying to do here. Is there an easy way to do this or do I have to start adding new includes?</p>
<p>Well, if you use cout you can just write the integer directly to it, as in</p> <pre><code>std::cout &lt;&lt; text &lt;&lt; i; </code></pre> <p>The C++ way of converting all kinds of objects to strings is through <a href="http://en.cppreference.com/w/cpp/io/basic_stringstream" rel="noreferrer">string streams</a>. If you don't have one handy, just create one.</p> <pre><code>#include &lt;sstream&gt; std::ostringstream oss; oss &lt;&lt; text &lt;&lt; i; std::cout &lt;&lt; oss.str(); </code></pre> <p>Alternatively, you can just convert the integer and append it to the string.</p> <pre><code>oss &lt;&lt; i; text += oss.str(); </code></pre> <p>Finally, the Boost libraries provide <a href="http://www.boost.org/doc/libs/release/doc/html/boost_lexical_cast.html" rel="noreferrer"><code>boost::lexical_cast</code></a>, which wraps around the stringstream conversion with a syntax like the built-in type casts.</p> <pre><code>#include &lt;boost/lexical_cast.hpp&gt; text += boost::lexical_cast&lt;std::string&gt;(i); </code></pre> <p>This also works the other way around, i.e. to parse strings.</p>
<p>There are a few options, and which one you want depends on the context.</p> <p>The simplest way is</p> <pre><code>std::cout &lt;&lt; text &lt;&lt; i; </code></pre> <p>or if you want this on a single line</p> <pre><code>std::cout &lt;&lt; text &lt;&lt; i &lt;&lt; endl; </code></pre> <p>If you are writing a single threaded program and if you aren't calling this code a lot (where "a lot" is thousands of times per second) then you are done.</p> <p>If you are writing a multi threaded program and more than one thread is writing to cout, then this simple code can get you into trouble. Let's assume that the library that came with your compiler made cout thread safe enough than any single call to it won't be interrupted. Now let's say that one thread is using this code to write "Player 1" and another is writing "Player 2". If you are lucky you will get the following:</p> <pre><code>Player 1 Player 2 </code></pre> <p>If you are unlucky you might get something like the following</p> <pre><code>Player Player 2 1 </code></pre> <p>The problem is that std::cout &lt;&lt; text &lt;&lt; i &lt;&lt; endl; turns into 3 function calls. The code is equivalent to the following:</p> <pre><code>std::cout &lt;&lt; text; std::cout &lt;&lt; i; std::cout &lt;&lt; endl; </code></pre> <p>If instead you used the C-style printf, and again your compiler provided a runtime library with reasonable thread safety (each function call is atomic) then the following code would work better:</p> <pre><code>printf("Player %d\n", i); </code></pre> <p>Being able to do something in a single function call lets the io library provide synchronization under the covers, and now your whole line of text will be atomically written.</p> <p>For simple programs, std::cout is great. Throw in multithreading or other complications and the less stylish printf starts to look more attractive.</p>
9,038
<p>I have been trying to find an easy way to parse a search query and convert it to an SQL query for my DB. </p> <p>I have found two solutions:</p> <ol> <li><em><a href="https://lucene.apache.org/" rel="nofollow noreferrer">Lucene</a></em>: Powerful Java-based search engine, contains a query parser but it isn't very configurable and I could find a way to easily hack/adapt it to create SQL queries.</li> <li><em><a href="http://www.antlr.org/" rel="nofollow noreferrer">ANTLR</a></em>: A veteran text lexer-parser. Used for building anything from compilers to sky scrapers. ANTLR is highly configurable but everyone touching the code from now on will have to learn a new language...</li> </ol> <p>Any other ideas?</p>
<p>What exactly do you have in mind? I've used Lucene for text-searching, but where it excels is building an index and searching that <em>instead</em> of hitting the database at all.</p> <p>I recently set up an system where I index a table in Lucene by concatenating all the columns (separated by spaces) into one field, and popping that into Lucene, and then also adding the primary key in a separate column. Lucene does all the searching and returned a list of primary keys, which I used to pull up a populated set of results and display to the user.</p> <p>Converting a search query into a SQL statement would seem to me to be a little messy.</p> <p>Also, here's <a href="http://www.darksleep.com/lucene/" rel="nofollow noreferrer">a great beginning tutorial explaining the basic structure of Lucene</a>.</p>
<p>String [] array;</p> <pre><code>int checkWord(String searchWord) { for(int i = 0; i &lt; array.length; i++) { if(searchWord.equals(array[i])) return i; } return 0; } </code></pre>
3,480
<p>Can anyone provide a good explanation of the volatile keyword in C#? Which problems does it solve and which it doesn't? In which cases will it save me the use of locking?</p>
<p>I don't think there's a better person to answer this than <a href="https://ericlippert.com/2011/06/16/atomicity-volatility-and-immutability-are-different-part-three/" rel="noreferrer">Eric Lippert</a> (emphasis in the original): </p> <blockquote> <p>In C#, "volatile" means not only "make sure that the compiler and the jitter do not perform any code reordering or register caching optimizations on this variable". It also means "tell the processors to do whatever it is they need to do to ensure that I am reading the latest value, even if that means halting other processors and making them synchronize main memory with their caches".</p> <p>Actually, that last bit is a lie. The true semantics of volatile reads and writes are considerably more complex than I've outlined here; in fact <strong>they do not actually guarantee that every processor stops what it is doing</strong> and updates caches to/from main memory. Rather, <strong>they provide weaker guarantees about how memory accesses before and after reads and writes may be observed to be ordered with respect to each other</strong>. Certain operations such as creating a new thread, entering a lock, or using one of the Interlocked family of methods introduce stronger guarantees about observation of ordering. If you want more details, read sections 3.10 and 10.5.3 of the C# 4.0 specification.</p> <p>Frankly, <strong>I discourage you from ever making a volatile field</strong>. Volatile fields are a sign that you are doing something downright crazy: you're attempting to read and write the same value on two different threads without putting a lock in place. Locks guarantee that memory read or modified inside the lock is observed to be consistent, locks guarantee that only one thread accesses a given chunk of memory at a time, and so on. The number of situations in which a lock is too slow is very small, and the probability that you are going to get the code wrong because you don't understand the exact memory model is very large. I don't attempt to write any low-lock code except for the most trivial usages of Interlocked operations. I leave the usage of "volatile" to real experts.</p> </blockquote> <p>For further reading see:</p> <ul> <li><a href="https://learn.microsoft.com/archive/msdn-magazine/2005/october/understanding-low-lock-techniques-in-multithreaded-apps" rel="noreferrer">Understand the Impact of Low-Lock Techniques in Multithreaded Apps</a></li> <li><a href="http://joeduffyblog.com/2010/12/04/sayonara-volatile/" rel="noreferrer">Sayonara volatile</a></li> </ul>
<p>multiple threads can access a variable. The latest update will be on the variable</p>
9,791
<p>Is it possible to create a REST web service using ASP.NET 2.0? The articles and blog entries I am finding all seem to indicate that ASP.NET 3.5 with WCF is required to create REST web services with ASP.NET.</p> <p>If it is possible to create REST web services in ASP.NET 2.0 can you provide an example.</p> <p>Thanks!</p>
<p>I have actually created a REST web service with asp.net 2.0. Its really no different than creating a web page.</p> <p>When I did it, I really didn't have much time to research how to do it with an asmx file so I did it in a standard aspx file. I know thier is extra overhead by doing it this way but as a first revision it was fine.</p> <pre><code>protected void PageLoad(object sender, EventArgs e) { using (XmlWriter xm = XmlWriter.Create(Response.OutputStream, GetXmlSettings())) { //do your stuff xm.Flush(); } } /// &lt;summary&gt; /// Create Xml Settings object to properly format the output of the xml doc. /// &lt;/summary&gt; private static XmlWriterSettings GetXmlSettings() { XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; xmlSettings.IndentChars = " "; return xmlSettings; } </code></pre> <p>That should be enough to get you started, I will try and post more later.</p> <p>Also if you need basic authentication for your web service it can be done, but it needs to be done manually if you aren't using active directory.</p>
<p>I'm only just beginning to use them, but from what I've seen 2.0 pretty assumes SOAP.</p>
6,193
<p>What are the differences between a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html" rel="noreferrer"><code>HashMap</code></a> and a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Hashtable.html" rel="noreferrer"><code>Hashtable</code></a> in Java?</p> <p>Which is more efficient for non-threaded applications?</p>
<p>There are several differences between <a href="http://java.sun.com/javase/7/docs/api/java/util/HashMap.html" rel="noreferrer"><code>HashMap</code></a> and <a href="http://java.sun.com/javase/7/docs/api/java/util/Hashtable.html" rel="noreferrer"><code>Hashtable</code></a> in Java:</p> <ol> <li><p><code>Hashtable</code> is <a href="https://stackoverflow.com/questions/1085709/what-does-synchronized-mean">synchronized</a>, whereas <code>HashMap</code> is not. This makes <code>HashMap</code> better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.</p></li> <li><p><code>Hashtable</code> does not allow <code>null</code> keys or values. <code>HashMap</code> allows one <code>null</code> key and any number of <code>null</code> values.</p></li> <li><p>One of HashMap's subclasses is <a href="http://java.sun.com/javase/7/docs/api/java/util/LinkedHashMap.html" rel="noreferrer"><code>LinkedHashMap</code></a>, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the <code>HashMap</code> for a <code>LinkedHashMap</code>. This wouldn't be as easy if you were using <code>Hashtable</code>.</p></li> </ol> <p>Since synchronization is not an issue for you, I'd recommend <code>HashMap</code>. If synchronization becomes an issue, you may also look at <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentHashMap.html" rel="noreferrer"><code>ConcurrentHashMap</code></a>.</p>
<p>The Hashtable class is synchronized, that is, it is designed to be used by applications that handle multiple or multithreaded process. Synchronized classes are less efficient in the classical case of an application to a process, so the Hashmap class is faster in general. The HashTable class does not accept the Null value, either for keys or for values, while the HashMap class allows a single key with Null and as many as null as possible.</p>
6,170
<p>I'm looking for something that will show me the size of each folder within my main folder recursively.</p> <p>This is a <a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29" rel="nofollow noreferrer">LAMP</a> server with a CGI-Bin so most any PHP script should work or anything that will work in the CGI-Bin.</p> <p>My hosting company does not provide an interface for me to see which folders are consuming the most amount of space. I don't know of anything on the Internet and did a few searches however I came up with no results. </p> <p>Something implementing graphs (<a href="http://en.wikipedia.org/wiki/GD_Graphics_Library" rel="nofollow noreferrer">GD</a>/<a href="http://en.wikipedia.org/wiki/ImageMagick" rel="nofollow noreferrer">ImageMagick</a>) would be best but not required.</p> <p>My host supports only Perl in the CGI-BIN.</p>
<p>Strange, I came up on Google with <a href="http://www.google.com.au/search?hl=en&amp;q=php+directory+size&amp;btnG=Google+Search&amp;meta=" rel="nofollow noreferrer">many relevant results</a> and <a href="http://www.go4expert.com/forums/showthread.php?t=290" rel="nofollow noreferrer">this one</a> is probably the most complete.</p> <blockquote> <p>The function "getDirectorySize" will ignore link/shorcuts to files/directory. The function "sizeFormat" will suffix the size with bytes,KB,MB or GB accordingly.</p> </blockquote> <h2>Code</h2> <pre><code>function getDirectorySize($path) { $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' . $file; if ($file != '.' &amp;&amp; $file != '..' &amp;&amp; !is_link ($nextpath)) { if (is_dir ($nextpath)) { $dircount++; $result = getDirectorySize($nextpath); $totalsize += $result['size']; $totalcount += $result['count']; $dircount += $result['dircount']; } elseif (is_file ($nextpath)) { $totalsize += filesize ($nextpath); $totalcount++; } } } } closedir ($handle); $total['size'] = $totalsize; $total['count'] = $totalcount; $total['dircount'] = $dircount; return $total; } function sizeFormat($size) { if($size&lt;1024) { return $size." bytes"; } else if($size&lt;(1024*1024)) { $size=round($size/1024,1); return $size." KB"; } else if($size&lt;(1024*1024*1024)) { $size=round($size/(1024*1024),1); return $size." MB"; } else { $size=round($size/(1024*1024*1024),1); return $size." GB"; } } </code></pre> <h2>Usage</h2> <pre><code>$path="/httpd/html/pradeep/"; $ar=getDirectorySize($path); echo "&lt;h4&gt;Details for the path : $path&lt;/h4&gt;"; echo "Total size : ".sizeFormat($ar['size'])."&lt;br&gt;"; echo "No. of files : ".$ar['count']."&lt;br&gt;"; echo "No. of directories : ".$ar['dircount']."&lt;br&gt;"; </code></pre> <h2>Output</h2> <pre><code>Details for the path : /httpd/html/pradeep/ Total size : 2.9 MB No. of files : 196 No. of directories : 20 </code></pre>
<h1>number_files_and_size.php</h1> <pre><code>&lt;?php if (isset($_POST["nivel"])) { $mostrar_hasta_nivel = $_POST["nivel"]; $comenzar_nivel_inferior = $_POST["comenzar_nivel_inferior"]; // $mostrar_hasta_nivel = 3; global $nivel_directorio_raiz; global $nivel_directorio; $path = dirname(__FILE__); if ($comenzar_nivel_inferior == "si") { $path = substr($path, 0, strrpos($path, "/")); } $nivel_directorio_raiz = count(explode("/", $path)) - 1; $numero_fila = 1; // Comienzo de Tabla echo "&lt;table border='1' cellpadding='3' cellspacing='0'&gt;"; // Fila encabezado echo "&lt;tr style='font-size: 100%; font-weight: bold;' bgcolor='#e2e2e2'&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Ruta&lt;/td&gt;&lt;td align='center'&gt;Nivel&lt;/td&gt;&lt;td align='right' style='color:#0000ff;'&gt;Ficheros&lt;/td&gt;&lt;td align='right'&gt;Acumulado fich.&lt;/td&gt;&lt;td align='right'&gt;Directorio&lt;/td&gt;&lt;td align='right' style='color:#0000ff;'&gt;Tama&amp;ntilde;o&lt;/td&gt;&lt;td align='right'&gt;Acumulado tama&amp;ntilde;o&lt;/td&gt;&lt;/tr&gt;"; // Inicio Filas de datos echo "&lt;tr&gt;"; //Función que se invoca a si misma de forma recursiva según recorre el directorio raiz ($path) FileCount($path, $mostrar_hasta_nivel, $nivel_directorio_raiz); // Din Filas de datos echo "&lt;/tr&gt;"; // Fin de tabla echo "&lt;/table&gt;"; echo "&lt;div style='font-size: 120%;'&gt;"; echo "&lt;br&gt;Total ficheros en la ruta &lt;b&gt;&lt;em&gt;" . $path . ":&lt;/em&gt; " . number_format($count,0,",",".") . "&lt;/b&gt;&lt;br&gt;"; echo "Tama&amp;ntilde;o total ficheros: &lt;b&gt;". number_format($acumulado_tamanho, 0,",",".") . " Kb.&lt;/b&gt;&lt;br&gt;"; echo "&lt;/div&gt;"; echo "&lt;div style='min-height: 60px;'&gt;&lt;/div&gt;"; } else { ?&gt; &lt;form name="formulario" id="formulario" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt; &lt;br /&gt;&lt;h2&gt;Informe del Alojamiento por directorios (N&amp;uacute;mero de Archivos y Tama&amp;ntilde;o)&lt;/h2&gt; &lt;br /&gt;Nivel de directorios a mostrar: &lt;input type="text" name="nivel" id="nivel" value="3"&gt;&lt;br /&gt;&lt;br /&gt; &lt;input type="checkbox" name="comenzar_nivel_inferior" value="si" checked="checked"/&gt; Comenzar en nivel de directorio inmediatamente inferior a la ubicaci&amp;oacute;n de este m&amp;oacute;dulo PHP&lt;br /&gt;(&lt;?php echo dirname(__FILE__) ?&gt;)&lt;br /&gt;&lt;br /&gt; &lt;input type="submit" name="comenzar" id="comenzar" value="Comenzar proceso"&gt;&lt;br /&gt;&lt;br /&gt; &lt;/form&gt; &lt;?php } function FileCount($dir, $mostrar_hasta_nivel, $nivel_directorio_raiz){ global $count; global $count_anterior; global $suma_tamanho; global $acumulado_tamanho; $arr=explode('&amp;',$dir); foreach($arr as $val){ global $ruta_actual; if(is_dir($val) &amp;&amp; file_exists($val)){ global $total_directorio; global $numero_fila; $total_directorio = 0; $ob=scandir($val); foreach($ob as $file){ if($file=="."||$file==".."){ continue; } $file=$val."/".$file; if(is_file($file)){ $count++; $suma_tamanho = $suma_tamanho + filesize($file)/1024; $acumulado_tamanho = $acumulado_tamanho + filesize($file)/1024; $total_directorio++; } elseif(is_dir($file)){ FileCount($file, $mostrar_hasta_nivel, $nivel_directorio_raiz); } } $nivel_directorio = count(explode("/", $val)) - 1; if ($nivel_directorio &gt; $mostrar_hasta_nivel) { } else { $atributo_fila = (($numero_fila%2)==1 ? "background-color:#ffffff;" : "background-color:#f2f2f2;"); echo "&lt;tr style='".$atributo_fila."'&gt;&lt;td&gt;".$numero_fila."&lt;/td&gt;&lt;td&gt;".$val."&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;td align='center'&gt;".$nivel_directorio."&lt;/td&gt;&lt;td align='right' style='color:#0000ff;'&gt;".number_format(($count - $count_anterior),0,",",".")."&lt;/td&gt;&lt;td align='right'&gt;".number_format($count,0,",",".")."&lt;/td&gt;&lt;td align='right'&gt;".number_format($total_directorio,0,",",".")."&lt;/td&gt;&lt;td align='right' style='color:#0000ff;'&gt;".number_format($suma_tamanho,0,",",".")." Kb.&lt;/td&gt;&lt;td align='right'&gt;".number_format($acumulado_tamanho,0,",",".")." Kb.&lt;/td&gt;&lt;/tr&gt;"; $count_anterior = $count; $suma_tamanho = 0; $numero_fila++; } } } } ?&gt; </code></pre>
4,951
<p>If possible I want to catch pressure sensitive input from a Wacom tablet in Python. Are there any Python libraries available that can do this?</p>
<p>You could perhaps take a look at the <a href="http://www.alexmac.cc/tablet-apps/tablet-apps-0.3.1.tar.bz2" rel="nofollow noreferrer">software</a> described <a href="http://www.alexmac.cc/tablet-apps/" rel="nofollow noreferrer">here</a>. It is a gnome applet, written in Python.</p> <p>From the web site:</p> <p>"The gnome wacom applet is a small gnome panel applet that shows how much pressure is being applied to your wacom tablet by the current device. Clicking on the panel icon brings up a dialog allowing you to select a different device and check what pressure and tilt information is being recieved from it. This dialog also contains a small drawing test area to give your pen a quick test."</p> <p><a href="http://www.google.com/search?q=wacom+tablet+python" rel="nofollow noreferrer">Google is your friend</a></p>
<p>Pressure data is available in <a href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/" rel="nofollow">PyGObject to access Gtk+ 3</a> on multiple platforms, though "Windows users may still want to keep using PyGTK until more convenient installers are published." [<a href="https://wiki.python.org/moin/PyGtk" rel="nofollow">citation</a>] Motion event objects generated by pressure sensitive devices will carry pressure data.</p>
6,739
<p>I've got the following in my .css file creating a little image next to each link on my site:</p> <pre class="lang-css prettyprint-override"><code>div.post .text a[href^="http:"] { background: url(../../pics/remote.gif) right top no-repeat; padding-right: 10px; white-space: nowrap; } </code></pre> <p>How do I modify this snippet (or add something new) to exclude the link icon next to images that are links themselves?</p>
<p>If you set the background color and have a negative right margin on the image, the image will cover the external link image.</p> <p>Example:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>a[href^="http:"] { background: url(http://en.wikipedia.org/skins-1.5/monobook/external.png) right center no-repeat; padding-right: 14px; white-space: nowrap; } a[href^="http:"] img { margin-right: -14px; border: medium none; background-color: red; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;a href="http://www.google.ca"&gt;Google&lt;/a&gt; &lt;br/&gt; &lt;a href="http://www.google.ca"&gt; &lt;img src="http://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/50px-Commons-logo.svg.png" /&gt; &lt;/a&gt;</code></pre> </div> </div> </p> <p>edit: If you've got a patterned background this isn't going to look great for images that have transparency. Also, your <code>href^=</code> selector won't work on IE7 but you probably knew that already</p>
<p>If you have the content of the links as a span, you could do this, otherwise I think you would need to give one scenario a class to differentiate it.</p> <pre class="lang-css prettyprint-override"><code>a &gt; span { background: url(../../pics/remote.gif) right top no-repeat; padding-right: 10px; white-space: nowrap; } a &gt; img { /* any specific styling for images wrapped in a link (e.g. polaroid like) */ border: 1px solid #cccccc; padding: 4px 4px 25px 4px; } </code></pre>
8,399
<p>I have two Tronxy 2.0 V5 Marlin boards that reboot whenever heat is applied to the bed. The bed has been swapped (because I thought that was the problem) for a new shiny one. The thermistors, too, of course. The same boards (both) work when the beds remain unheated (setpoint = 0&nbsp;&deg;C).</p> <p>Any ideas what might be causing this, or what I might do to figure it out?</p> <p>Note: I really have no idea which Tronxy board this is; the "2.0" is stenciled on the board, so that's all I can figure out. I shamefully admit I tagged it with Tronxy x1 to see if I could generate any interest, and because a "Tronxy" tag is not available.</p>
<p>It sounds like a power-related problem. Always use an external MOSFET to drive a heated bed, and consider investing in a decent power supply. Inevitably, the Tronxy PSU will be barely adequate.</p> <p>Edit: I've just noticed the <a href="/questions/tagged/tronxy-x1" class="post-tag" title="show questions tagged &#39;tronxy-x1&#39;" rel="tag">tronxy-x1</a> tag. Be aware that the stock (60 Watt) PSU for the Tronxy X1 cannot power a heated bed (the printer does not have one). Trying to do so will overload the PSU and cause an immediate reset.</p>
<p>First, check the power supply. Although it may be specified to deliver the required power, it is possible that the power supply has failed in a way that it can not deliver the rated power. At lower load, the voltage may be correct, but under higher load, it either droops or cuts out completely.</p> <p>To check this, use a voltmeter on the power as it enters the CPU board, not where it leaves the power supply. This accomplishes one additional check. If the voltage droops rather than cuts off, it may be that the connections have corroded and have a higher resistance.</p> <p>If you have any kind of oscilloscope, I would recommend it over a simple voltmeter, because the power interruption or droop time may be very short. When the CPU resets it will switch off the load that causes the problem, and the power may quickly resume the correct value.</p> <p>Second, check that there is not a short in the bed wiring. You might detect that with an ohm meter. You have used two different CPU boards, to it is unlikely to be a common fault on both boards, but you might be using the same wiring.</p> <p>Third, check the routing of the bed heater wires to see that they are not near other wires which connect with the CPU, including thermistor wires and wires to the UI. High-current switching in the bed wires could be coupling into other wires and conducting a RESET signal to the CPU. Ideally, the heater wires will be twisted together with about 3 (or more) twists per inch, and not twisted together with other wires.</p>
1,330
<p>What is the best way, using Bash, to rename files in the form:</p> <pre><code>(foo1, foo2, ..., foo1300, ..., fooN) </code></pre> <p>With zero-padded file names:</p> <pre><code>(foo00001, foo00002, ..., foo01300, ..., fooN) </code></pre>
<p>In case <code>N</code> is not a priori fixed:</p> <pre><code>for f in foo[0-9]*; do mv &quot;$f&quot; &quot;$(printf 'foo%05d' &quot;${f#foo}&quot;)&quot; done </code></pre>
<p>Here's a quick solution that assumes a fixed length prefix (your "foo") and fixed length padding. If you need more flexibility, maybe this will at least be a helpful starting point.</p> <pre><code>#!/bin/bash # some test data files="foo1 foo2 foo100 foo200 foo9999" for f in $files; do prefix=`echo "$f" | cut -c 1-3` # chars 1-3 = "foo" number=`echo "$f" | cut -c 4-` # chars 4-end = the number printf "%s%04d\n" "$prefix" "$number" done </code></pre>
7,960
<p>Let's say I have four tables: <code>PAGE</code>, <code>USER</code>, <code>TAG</code>, and <code>PAGE-TAG</code>:</p> <pre><code>Table | Fields ------------------------------------------ PAGE | ID, CONTENT TAG | ID, NAME USER | ID, NAME PAGE-TAG | ID, PAGE-ID, TAG-ID, USER-ID </code></pre> <p>And let's say I have four pages:</p> <pre><code>PAGE#1 'Content page 1' tagged with tag#1 by user1, tagged with tag#1 by user2 PAGE#2 'Content page 2' tagged with tag#3 by user2, tagged by tag#1 by user2, tagged by tag#8 by user1 PAGE#3 'Content page 3' tagged with tag#7 by user#1 PAGE#4 'Content page 4' tagged with tag#1 by user1, tagged with tag#8 by user1 </code></pre> <p>I expect my query to look something like this: </p> <pre><code>select page.content ? from page, page-tag where page.id = page-tag.pag-id and page-tag.tag-id in (1, 3, 8) order by ? desc </code></pre> <p>I would like to get output like this:</p> <pre><code>Content page 2, 3 Content page 4, 2 Content page 1, 1 </code></pre> <hr> <p>Quoting Neall </p> <blockquote> <p>Your question is a bit confusing. Do you want to get the number of times each page has been tagged? </p> </blockquote> <p>No</p> <blockquote> <p>The number of times each page has gotten each tag? </p> </blockquote> <p>No</p> <blockquote> <p>The number of unique users that have tagged a page? </p> </blockquote> <p>No </p> <blockquote> <p>The number of unique users that have tagged each page with each tag?</p> </blockquote> <p>No</p> <p>I want to know how many of the passed tags appear in a particular page, not just if any of the tags appear. </p> <p>SQL IN works like an boolean operator OR. If a page was tagged with any value within the IN Clause then it returns true. I would like to know how many of the values inside of the IN clause return true. </p> <p>Below i show, the output i expect: </p> <pre><code>page 1 | in (1,2) -&gt; 1 page 1 | in (1,2,3) -&gt; 1 page 1 | in (1) -&gt; 1 page 1 | in (1,3,8) -&gt; 1 page 2 | in (1,2) -&gt; 1 page 2 | in (1,2,3) -&gt; 2 page 2 | in (1) -&gt; 1 page 2 | in (1,3,8) -&gt; 3 page 4 | in (1,2,3) -&gt; 1 page 4 | in (1,2,3) -&gt; 1 page 4 | in (1) -&gt; 1 page 4 | in (1,3,8) -&gt; 2 </code></pre> <p>This will be the content of the page-tag table i mentioned before: </p> <pre><code> id page-id tag-id user-id 1 1 1 1 2 1 1 2 3 2 3 2 4 2 1 2 5 2 8 1 6 3 7 1 7 4 1 1 8 4 8 1 </code></pre> <p><strong>@Kristof</strong> does not exactly what i am searching for but thanks anyway. </p> <p><strong>@Daren</strong> If i execute you code i get the next error: </p> <pre><code>#1054 - Unknown column 'page-tag.tag-id' in 'having clause' </code></pre> <p><strong>@Eduardo Molteni</strong> Your answer does not give the output in the question but: </p> <pre><code>Content page 2 8 Content page 4 8 content page 2 3 content page 1 1 content page 1 1 content page 2 1 cotnent page 4 1 </code></pre> <p><strong>@Keith</strong> I am using plain SQL not T-SQL and i am not familiar with T-SQL, so i do not know how your query translate to plain SQL.</p> <p>Any more ideas?</p>
<p>This might work:</p> <pre><code>select page.content, count(page-tag.tag-id) as tagcount from page inner join page-tag on page-tag.page-id = page.id group by page.content having page-tag.tag-id in (1, 3, 8) </code></pre>
<p>In T-Sql:</p> <pre><code>select count(distinct name) from page-tag where tag-id in (1, 3, 8) </code></pre> <p>This will give you a count of the number of different tag names for your list of ids</p>
5,202
<p>Given the following XML:</p> <pre><code>&lt;current&gt; &lt;login_name&gt;jd&lt;/login_name&gt; &lt;/current&gt; &lt;people&gt; &lt;person&gt; &lt;first&gt;John&lt;/first&gt; &lt;last&gt;Doe&lt;/last&gt; &lt;login_name&gt;jd&lt;/login_name&gt; &lt;/preson&gt; &lt;person&gt; &lt;first&gt;Pierre&lt;/first&gt; &lt;last&gt;Spring&lt;/last&gt; &lt;login_name&gt;ps&lt;/login_name&gt; &lt;/preson&gt; &lt;/people&gt; </code></pre> <p>How can I get "John Doe" from within the current/login matcher?</p> <p>I tried the following:</p> <pre><code>&lt;xsl:template match="current/login_name"&gt; &lt;xsl:value-of select="../people/first[login_name = .]"/&gt; &lt;xsl:text&gt; &lt;/xsl:text&gt; &lt;xsl:value-of select="../people/last[login_name = .]"/&gt; &lt;/xsl:template&gt; </code></pre>
<p>I'd define a key to index the people:</p> <pre><code>&lt;xsl:key name="people" match="person" use="login_name" /&gt; </code></pre> <p>Using a key here simply keeps the code clean, but you might also find it helpful for efficiency if you're often having to retrieve the <code>&lt;person&gt;</code> elements based on their <code>&lt;login_name&gt;</code> child.</p> <p>I'd have a template that returned the formatted name of a given <code>&lt;person&gt;</code>:</p> <pre><code>&lt;xsl:template match="person" mode="name"&gt; &lt;xsl:value-of select="concat(first, ' ', last)" /&gt; &lt;/xsl:template&gt; </code></pre> <p>And then I'd do:</p> <pre><code>&lt;xsl:template match="current/login_name"&gt; &lt;xsl:apply-templates select="key('people', .)" mode="name" /&gt; &lt;/xsl:template&gt; </code></pre>
<p>I think what he actually wanted was the replacement in the match for the "current" node, not a match in the person node:</p> <pre><code>&lt;xsl:variable name="login" select="//current/login_name/text()"/&gt; &lt;xsl:template match="current/login_name"&gt; &lt;xsl:value-of select='concat(../../people/person[login_name=$login]/first," ", ../../people/person[login_name=$login]/last)'/&gt; &lt;/xsl:template&gt; </code></pre>
8,733
<p>I have a problem (and have been having it for some time now) -- the new sound mixer stack in Vista features new cool things, but also re-invents the wheel. Many applications that used to use Volume Mixer on a Windows system to mix different voiced outputs into one input (for example Wave-out + Line-in --> Stereo Mix) have since stopped working. The prime example of this behavior is the Shoutcast DSP plugin (could be useful for solution testing).</p> <p>How Can I re-enable XP-mixer controls, or maybe emulate this behavior somehow, so that the program (SC DSP) can properly manage Microphone/Line-In playback volume along with Wave-out playback volume?</p> <p>My thinking would be to emulate a program hooked-in into the Vista Mixer for Wave-Out and Line-out (or Mic speaker volume -- all playback, shown as separate adjustable "programs" so that the Vista Mixer could refer to it) and 'hook' it into the system under some emulation representing itself as the old volume mixer control interface for the program, but I frankly have no idea how to do that.</p> <p>To clarify: this is not my PC (it is a HP Pavilion laptop). The problem seems to exist mostly due to the fact that Vista mixer controls separate programs, not separate inputs/outputs. The hardware is fully capable of doing what is needed when using Windows XP. I am well aware of the fact that this is a driver issue, but the driver is simply prepared for what Vista presents to the programmer through interfaces. The mixer device - as seen in the operating system, however it might look in software - is based on the mixer APIs for Windows Audio control.</p> <p>Search using Google on Vista and line-in playback volume control for more info on the problem (and the sheer amount of users affected by it). Of course, a re-write of the Shoutcast Source DSP plug-in for WinAMP would do the trick, but that is not likely to happen...</p>
<p>Controlling the volume levels of a soundcards indivudual input/output levels in Windows Vista mixer is possible using the audio <a href="http://msdn.microsoft.com/en-us/library/ms679162(VS.85).aspx" rel="nofollow noreferrer">EndPoint API</a></p> <p>This should allow you to adjust the main volume, and the volume of and <strong>connected</strong> audio inputs. One wrinkle about this that when you enumerate the end points, if there isn't a microphone plugged into your soundcard, then nothing will be enumerated. This means you'll need to change your application to respond to "microphone plugged in" events, and notify the user appropriately. </p> <p>Another option is to dip below the Microsoft Core Audio and access the <a href="http://www.microsoft.com/whdc/device/audio/wavertport.mspx" rel="nofollow noreferrer">WaveRT</a> driver directly. This is a lot more work than using the WASAPI/Endpoint APIs, but will give you the most control over access to the inputs/outputs of the soundcard. </p>
<blockquote> <p>If you mark your app as running in Windows XP compatibility, then all the old controls and behaviors will come back.</p> </blockquote> <p>This is true, but as of Vista SP1 patch KB957388, included in SP2, and with some soundcard drivers, the old mixer API (winmm.dll) functions can hang when the app is in XP compatibility mode. In particular, mixerGetNumDevs and less often mixerOpen will not return on some computers.</p> <p>I've got reports from 5 Vista users out of around 200 Vista users in total where my app hangs when starting up, and I have tracked it down to these functions hanging.</p> <p>I would like to report this to Microsoft but cannot find anywhere to do so.</p> <p>All I can do now is release my software without compatibility mode enabled, but this loses functionality in my app, and the software cannot control the line-in or microphone mixers.</p> <p>I don't have time to work with low level API functions directly. I rely on high level components, and I cannot find any for the new audio API's for my development system (Delphi).</p> <p>I would be interested in paying someone to write a DLL for me!!! e mail ross att stationplaylist dott com</p>
9,665
<p>Is there any JavaScript method similar to the jQuery <code>delay()</code> or <code>wait()</code> (to delay the execution of a script for a specific amount of time)?</p>
<p>There is the following:</p> <pre><code>setTimeout(function, milliseconds); </code></pre> <p>function which can be passed the time after which the function will be executed.</p> <p>See: <a href="https://www.w3schools.com/jsref/met_win_settimeout.asp" rel="noreferrer">Window <code>setTimeout()</code> Method</a>.</p>
<p>I had some ajax commands I wanted to run with a delay in between. Here is a simple example of one way to do that. I am prepared to be ripped to shreds though for my unconventional approach. :)</p> <pre><code>// Show current seconds and milliseconds // (I know there are other ways, I was aiming for minimal code // and fixed width.) function secs() { var s = Date.now() + ""; s = s.substr(s.length - 5); return s.substr(0, 2) + "." + s.substr(2); } // Log we're loading console.log("Loading: " + secs()); // Create a list of commands to execute var cmds = [ function() { console.log("A: " + secs()); }, function() { console.log("B: " + secs()); }, function() { console.log("C: " + secs()); }, function() { console.log("D: " + secs()); }, function() { console.log("E: " + secs()); }, function() { console.log("done: " + secs()); } ]; // Run each command with a second delay in between var ms = 1000; cmds.forEach(function(cmd, i) { setTimeout(cmd, ms * i); }); // Log we've loaded (probably logged before first command) console.log("Loaded: " + secs()); </code></pre> <p>You can copy the code block and paste it into a console window and see something like:</p> <pre><code>Loading: 03.077 Loaded: 03.078 A: 03.079 B: 04.075 C: 05.075 D: 06.075 E: 07.076 done: 08.076 </code></pre>
4,448
<p>I would like to be able to do such things as</p> <pre><code>var m1 = new UnitOfMeasureQuantityPair(123.00, UnitOfMeasure.Pounds); var m2 = new UnitOfMeasureQuantityPair(123.00, UnitOfMeasure.Liters); m1.ToKilograms(); m2.ToPounds(new Density(7.0, DensityType.PoundsPerGallon); </code></pre> <p>If there isn't something like this already, anybody interested in doing it as an os project?</p>
<p>Check out the <a href="http://www.codeproject.com/KB/library/Measurement_Conversion.aspx" rel="nofollow noreferrer">Measurement Unit Conversion Library</a> on The Code Project.</p>
<p>Unix <a href="http://linux.die.net/man/1/units" rel="nofollow">units</a> is imho brilliant; source must be on the web somewhere.<br> (Under "bugs", the original doc said "do not base your financial plans on the currency conversions".)</p>
7,763
<p>I have two arrays of animals (for example).</p> <pre><code>$array = array( array( 'id' =&gt; 1, 'name' =&gt; 'Cat', ), array( 'id' =&gt; 2, 'name' =&gt; 'Mouse', ) ); $array2 = array( array( 'id' =&gt; 2, 'age' =&gt; 321, ), array( 'id' =&gt; 1, 'age' =&gt; 123, ) ); </code></pre> <p>How can I merge the two arrays into one by the ID?</p>
<p>This does what Erik suggested (id no. as array key) and merges vlaues in <code>$array2</code> to <code>$results</code>.</p> <pre><code>$results = array(); foreach($array as $subarray) { $results[$subarray['id']] = array('name' =&gt; $subarray['name']); } foreach($array2 as $subarray) { if(array_key_exists($subarray['id'], $results)) { // Loop through $subarray would go here if you have extra $results[$subarray['id']]['age'] = $subarray['age']; } } </code></pre>
<pre><code>$new = array(); foreach ($array as $arr) { $match = false; foreach ($array2 as $arr2) { if ($arr['id'] == $arr2['id']) { $match = true; $new[] = array_merge($arr, $arr2); break; } } if ( !$match ) $new[] = $arr; } </code></pre>
4,477
<p>I've been attempting to write a Lisp macro that would perfom the equivalent of ++ in other programming languages for semantic reasons. I've attempted to do this in several different ways, but none of them seem to work, and all are accepted by the interpreter, so I don't know if I have the correct syntax or not. My idea of how this would be defined would be</p> <pre><code>(defmacro ++ (variable) (incf variable)) </code></pre> <p>but this gives me a SIMPLE-TYPE-ERROR when trying to use it. What would make it work?</p>
<p>Remember that a macro returns an expression to be evaluated. In order to do this, you have to backquote:</p> <pre><code>(defmacro ++ (variable) `(incf ,variable)) </code></pre>
<p>This should do the trick, however I'm not a lisp guru.</p> <pre><code>(defmacro ++ (variable) `(setq ,variable (+ ,variable 1))) </code></pre>
9,133
<p>When writing multithreaded applications, one of the most common problems experienced is race conditions.</p> <p>My questions to the community are:</p> <ul> <li>What is the race condition?</li> <li>How do you detect them?</li> <li>How do you handle them?</li> <li>Finally, how do you prevent them from occurring?</li> </ul>
<p>A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don't know the order in which the threads will attempt to access the shared data. Therefore, the result of the change in data is dependent on the thread scheduling algorithm, i.e. both threads are "racing" to access/change the data. </p> <p>Problems often occur when one thread does a "check-then-act" (e.g. "check" if the value is X, then "act" to do something that depends on the value being X) and another thread does something to the value in between the "check" and the "act". E.g:</p> <pre><code>if (x == 5) // The "Check" { y = x * 2; // The "Act" // If another thread changed x in between "if (x == 5)" and "y = x * 2" above, // y will not be equal to 10. } </code></pre> <p>The point being, y could be 10, or it could be anything, depending on whether another thread changed x in between the check and act. You have no real way of knowing.</p> <p>In order to prevent race conditions from occurring, you would typically put a lock around the shared data to ensure only one thread can access the data at a time. This would mean something like this:</p> <pre><code>// Obtain lock for x if (x == 5) { y = x * 2; // Now, nothing can change x until the lock is released. // Therefore y = 10 } // release lock for x </code></pre>
<p>Here is the classical Bank Account Balance example which will help newbies to understand Threads in Java easily w.r.t. race conditions:</p> <pre class="lang-java prettyprint-override"><code>public class BankAccount { /** * @param args */ int accountNumber; double accountBalance; public synchronized boolean Deposit(double amount){ double newAccountBalance=0; if(amount&lt;=0){ return false; } else { newAccountBalance = accountBalance+amount; accountBalance=newAccountBalance; return true; } } public synchronized boolean Withdraw(double amount){ double newAccountBalance=0; if(amount&gt;accountBalance){ return false; } else{ newAccountBalance = accountBalance-amount; accountBalance=newAccountBalance; return true; } } public static void main(String[] args) { // TODO Auto-generated method stub BankAccount b = new BankAccount(); b.accountBalance=2000; System.out.println(b.Withdraw(3000)); } </code></pre>
5,478
<p>What are some simple algorithm or data structure related "white boarding" problems that you find effective during the candidate screening process?</p> <p>I have some simple ones that I use to validate problem solving skills and that can be simply expressed but have some opportunity for the application of some heuristics.</p> <p>One of the basics that I use for junior developers is:</p> <blockquote> <p>Write a C# method that takes a string which contains a set of words (a sentence) and rotates those words X number of places to the right. When a word in the last position of the sentence is rotated it should show up at the front of the resulting string.</p> </blockquote> <p>When a candidate answers this question I look to see that they available .NET data structures and methods (string.Join, string.Split, List, etc...) to solve the problem. I also look for them to identify special cases for optimization. Like the number of times that the words need to be rotated isn't really X it's X % number of words.</p> <p>What are some of the white board problems that you use to interview a candidate and what are some of the things you look for in an answer (do not need to post the actual answer).</p>
<p>I enjoy the classic "what's the difference between a LinkedList and an ArrayList (or between a linked list and an array/vector) and why would you choose one or the other?"</p> <p>The kind of answer I hope for is one that includes discussion of:</p> <ul> <li>insertion performance</li> <li>iteration performance</li> <li>memory allocation/reallocation impact</li> <li>impact of removing elements from the beginning/middle/end</li> <li>how knowing (or not knowing) the maximum size of the list can affect the decision</li> </ul>
<p>I like to go over a code the person actually wrote and have them explain it to me.</p>
8,272
<p>I have two printers, one is an Anet A8 and the other one is a CreatBot DX plus. On both of them I installed a BLTouch, firstly on the DX and today on the A8. I have never had a problem with the probe, but today I am experiencing some problems. I just set the offset, by doing the procedure, and I found to that the Z0 is -0.8 mm.</p> <p>Problem is, when I start to print (I use Cura as a Slicer and OctoPrint), I run <code>G28</code> and <code>G29</code>, everything is fine and the bed gets mapped. When the print starts, something weird occurs: the nozzle goes down for the regions where the bed is higher! So, the layer that is put down, is very thin and the nozzle actually dives into the bed! It is like a <code>Z0</code> too low, so the nozzle crashes into the bed, but it is not because in <code>X100</code> <code>Y100</code> it is perfectly fine! Could you have any idea why this occurs?</p> <h3>What have I tried?</h3> <p><strong>Changing bed springs</strong><br> Because I was curious, and impatient I changed the springs with the Ender ones I bought online. The problem is still here! I can see the bed closer to the nozzle during bed leveling, compared to the left side. So I screwed the right side, to see any difference. However, the nozzle seems to be always closer on the right side! I checked the X rods, they are leveled.</p> <p><strong>Searched online</strong><br> I checked almost everywhere online and I found out that it could be a problem related to the bilinear bed leveling. So I changed to linear, and apparently now I can print! I believe it is something related to the mesh the firmware creates after the leveling, which is avoided for the linear. &lt;I will let you know tomorrow, after I change the frame whether the bilinear will work or not! I can still see that the left-side part of the print is closer to the bed, but now I can print at least. Will let you know! Bye!&gt;</p>
<p>I've tried that item as well. In fact, other than the heart, I built a <a href="https://www.thingiverse.com/thing:3825323" rel="nofollow noreferrer">remix</a> which works better but is still difficult to free up after printing. Those tabs you're concerned about will print better at a very low (thin) layer setting. </p> <p>I am pretty sure that the original design is faulty. All the "leaves" have gears which cause them to rotate when the threaded ring is turned. But the designer made all leaves identical! Each one needs its gear's null-position set differently so that it properly meshes with the thread positions of the outer ring at that leaf's placement. Some day I may remix to adjust those gear positions.... </p>
<p>It's not uncommon that different slicers have different effects on different models. The techniques used to slice the models differs. If the model you slice works fine in one and not in the other it's sometimes a setting but sometimes just the slicer. Just use the slicer that works :)</p>
1,575
<p>I need to add a web part zone to a wiki page. I'm opening the page using SharePoint Designer, but there doesn't seem to be an obvious way (such as a menu) to add a Web Part Zone.</p>
<p>from: <a href="http://office.microsoft.com/en-us/sharepointdesigner/HA101513941033.aspx" rel="noreferrer">http://office.microsoft.com/en-us/sharepointdesigner/HA101513941033.aspx</a></p> <blockquote> <p>Insert a Web Part zone</p> <ol> <li>In Office SharePoint Designer 2007, open the page where you want to insert the Web Part zone.</li> <li>If the Web Parts task pane is not already open, open it by clicking Web Parts on the Task Panes menu.</li> <li>In Design view, click the location on the page where you want to insert the Web Part zone.</li> <li><p>At the bottom of the Web Parts task pane, click New Web Part Zone.</p> <p>The new Web Part zone is inserted on the page. ...</p></li> </ol> </blockquote>
<p>open your site in SPD -->insert-->sharepoint controls--> web part zone. Note that you are unable to add a web part zone in master pages</p>
6,041
<p>When setting up foreign keys in SQL Server, under what circumstances should you have it cascade on delete or update, and what is the reasoning behind it?</p> <p>This probably applies to other databases as well.</p> <p>I'm looking most of all for concrete examples of each scenario, preferably from someone who has used them successfully.</p>
<p>Summary of what I've seen so far:</p> <ul> <li>Some people don't like cascading at all. </li> </ul> <h2>Cascade Delete</h2> <ul> <li>Cascade Delete may make sense when the semantics of the relationship can involve an exclusive <em>"is part of</em>" description. For example, an OrderLine record is part of its parent order, and OrderLines will never be shared between multiple orders. If the Order were to vanish, the OrderLine should as well, and a line without an Order would be a problem.</li> <li>The canonical example for Cascade Delete is SomeObject and SomeObjectItems, where it doesn't make any sense for an items record to ever exist without a corresponding main record.</li> <li>You should <em>not</em> use Cascade Delete if you are preserving history or using a "soft/logical delete" where you only set a deleted bit column to 1/true. </li> </ul> <h2>Cascade Update</h2> <ul> <li>Cascade Update may make sense when you use a real key rather than a surrogate key (identity/autoincrement column) across tables.</li> <li>The canonical example for Cascade Update is when you have a mutable foreign key, like a username that can be changed. </li> <li>You should <em>not</em> use Cascade Update with keys that are Identity/autoincrement columns.</li> <li>Cascade Update is best used in conjunction with a unique constraint. </li> </ul> <h2>When To Use Cascading</h2> <ul> <li>You may want to get an extra strong confirmation back from the user before allowing an operation to cascade, but it depends on your application.</li> <li>Cascading can get you into trouble if you set up your foreign keys wrong. But you should be okay if you do that right.</li> <li>It's not wise to use cascading before you understand it thoroughly. However, it is a useful feature and therefore worth taking the time to understand.</li> </ul>
<p>If you're working on a system with many different modules in different versions, it can be very helpful, if the cascade deleted items are part of / owned by the PK holder. Else, all modules would require immediate patches to clean up their dependent items before deleting the PK owner, or the foreign key relation would be omitted completely, possibly leaving tons of garbage in the system if cleanup is not performed correctly.</p> <p>I just introduced cascade delete for a new intersection table between two already existing tables (the intersection to delete only), after cascade delete had been discouraged from for quite some time. It's also not too bad if data gets lost.</p> <p>It is, however, a bad thing on enum-like list tables: somebody deletes entry 13 - yellow from table "colors", and all yellow items in the database get deleted. Also, these sometimes get updated in a delete-all-insert-all manner, leading to referential integrity totally omitted. Of course it's wrong, but how will you change a complex software which has been running for many years, with introduction of true referential integrity being at risk of unexpected side effects?</p> <p>Another problem is when original foreign key values shall be kept even after the primary key has been deleted. One can create a tombstone column and an ON DELETE SET NULL option for the original FK, but this again requires triggers or specific code to maintain the redundant (except after PK deletion) key value.</p>
8,385
<p>Has anyone had good experiences with any Java libraries for Graph algorithms. I've tried <a href="http://www.jgraph.com/jgraph.html" rel="noreferrer">JGraph</a> and found it ok, and there are a lot of different ones in google. Are there any that people are actually using successfully in production code or would recommend?</p> <p>To clarify, I'm not looking for a library that produces graphs/charts, I'm looking for one that helps with Graph algorithms, eg minimum spanning tree, Kruskal's algorithm Nodes, Edges, etc. Ideally one with some good algorithms/data structures in a nice Java OO API.</p>
<p>If you were using JGraph, you should give a try to <a href="http://jgrapht.org/" rel="noreferrer">JGraphT</a> which is designed for algorithms. One of its features is visualization using the JGraph library. It's still developed, but pretty stable. I analyzed the complexity of JGraphT algorithms some time ago. Some of them aren't the quickest, but if you're going to implement them on your own and need to display your graph, then it might be the best choice. I really liked using its API, when I quickly had to write an app that was working on graph and displaying it later.</p>
<p>If you are actually looking for Charting libraries and not for Node/Edge Graph libraries I would suggest splurging on Big Faceless Graph library (<a href="http://big.faceless.org/products/graph/" rel="nofollow noreferrer">BFG</a>). It's way easier to use than JFreeChart, looks nicer, runs faster, has more output options, really no comparison.</p>
7,470
<p>Here's the code from the ascx that has the repeater:</p> <pre><code>&lt;asp:Repeater ID="ListOfEmails" runat="server" &gt; &lt;HeaderTemplate&gt;&lt;h3&gt;A sub-header:&lt;/h3&gt;&lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; [Some other stuff is here] &lt;asp:Button ID="removeEmail" runat="server" Text="X" ToolTip="remove" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>And in the codebehind for the repeater's databound and events:</p> <pre><code>Protected Sub ListOfEmails_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles ListOfEmails.ItemDataBound If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then Dim removeEmail As Button = CType(e.Item.FindControl("removeEmail"), Button) removeEmail.CommandArgument = e.Item.ItemIndex.ToString() AddHandler removeEmail.Click, AddressOf removeEmail_Click AddHandler removeEmail.Command, AddressOf removeEmail_Command End If End Sub Sub removeEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Response.Write("&lt;h1&gt;click&lt;/h1&gt;") End Sub Sub removeEmail_Command(ByVal sender As Object, ByVal e As CommandEventArgs) Response.Write("&lt;h1&gt;command&lt;/h1&gt;") End Sub </code></pre> <p>Neither the click or command is getting called, what am I doing wrong?</p>
<p>Controls nested inside of Repeaters do not intercept events. Instead you need to bind to the <code>Repeater.ItemCommand</code> Event.</p> <p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.repeater.itemcommand" rel="nofollow noreferrer"><code>ItemCommand</code></a> contains <a href="https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.repeatercommandeventargs" rel="nofollow noreferrer"><code>RepeaterCommandEventArgs</code></a> which has two important fields:</p> <ul> <li>CommandName</li> <li>CommandArgument</li> </ul> <p>So, a trivial example: </p> <pre class="lang-cs prettyprint-override"><code>void rptr_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { // Stuff to databind Button myButton = (Button)e.Item.FindControl("myButton"); myButton.CommandName = "Add"; myButton.CommandArgument = "Some Identifying Argument"; } } void rptr_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Add") { // Do your event } } </code></pre>
<p>Here's an experiment for you to try:</p> <p>Set a breakpoint on ListOfEmails_ItemDataBound and see if it's being called for postbacks.</p>
6,385
<p>Anyone have a quick method for de-duplicating a generic List in C#?</p>
<p>If you're using .Net 3+, you can use Linq.</p> <pre><code>List&lt;T&gt; withDupes = LoadSomeData(); List&lt;T&gt; noDupes = withDupes.Distinct().ToList(); </code></pre>
<p>I think the simplest way is:</p> <p>Create a new list and add unique item.</p> <p>Example:</p> <pre><code> class MyList{ int id; string date; string email; } List&lt;MyList&gt; ml = new Mylist(); ml.Add(new MyList(){ id = 1; date = &quot;2020/09/06&quot;; email = &quot;zarezadeh@gmailcom&quot; }); ml.Add(new MyList(){ id = 2; date = &quot;2020/09/01&quot;; email = &quot;zarezadeh@gmailcom&quot; }); List&lt;MyList&gt; New_ml = new Mylist(); foreach (var item in ml) { if (New_ml.Where(w =&gt; w.email == item.email).SingleOrDefault() == null) { New_ml.Add(new MyList() { id = item.id, date = item.date, email = item.email }); } } </code></pre>
7,001
<p>We have an enterprise web application where every bit of text in the system is localised to the user's browser's culture setting.</p> <p>So far we have only supported English, American (similar but mis-spelt ;-) and French (for the Canadian Gov't - app in English or French depending on user preference). During development we also had some European languages in mind like Dutch and German that tend to concatenate words into very long ones.</p> <p>We're currently investigating support for eastern languages: Chinese, Japanese, and so on. I understand that these use phonetic input converted to written characters. How does that work on the web? Do the same events fire while inputs and textareas are being edited (we're quite Ajax heavy).</p> <p>What conventions do users of these top-down languages expect online? </p> <p>What effect does their dual-input (phonetic typing + conversion) have on web controls?</p> <p>With RTL languages like Arabic do users expect the entire interface to be mirrored? For instance should things like OK/Cancel buttons be swapped and on the left? </p>
<p>Read <a href="https://web.archive.org/web/20080829004345/http://www.microsoft.com/globaldev/getwr/steps/WRGuide.mspx" rel="nofollow noreferrer">Globalization Step-by-Step</a> by Microsoft.</p> <p>I can answer the specifics on CJKV, but you probably want a book on this topic. I haven't read it but CJKV Information Processing is from O'Reilly (2nd ed due Dec, 2008).</p> <blockquote> <p>I understand that these use phonetic input converted to written characters. How does that work on the web?</p> </blockquote> <p>The input is done by a class of software called an <a href="http://en.wikipedia.org/wiki/Input%5Fmethod%5Feditor" rel="nofollow noreferrer">IME (Input Method Editor)</a> on Windows, Mac, and Linux (e.g. SCIM). When an IME is turned on, the input from the keyboard first goes to the IME, and the user gets to pick the correct kanji/hiragana combo. When the user commits by hitting return key, the IME types in the kanji/hiragana into the web browser using the current encoding. Encoding situation was a big mess, but if you are writing a web app, go with an encoding of Unicode. I suggest UTF-8.</p> <blockquote> <p>Do the same events fire while inputs and textareas are being edited?</p> </blockquote> <p>A Unicode savvy web browser and OS combo handles multiple languages. For example, one can use English normal version of Firefox to browse and post to a Japanese website. From the browsers point of view, it's just an array of &quot;bla bla bla&quot; in Unicode. In other words, if the event fires up in English, the same event should fire up in CJKV if you use a Unicode variant.</p> <blockquote> <p>What conventions do users of these top-down languages expect online?</p> </blockquote> <p>CJKV readers expect left-to-right online. Math and science textbooks are written from left-to-right. Most word processors, including localized version of Word, write left-to-right.</p> <blockquote> <p>What effect does their dual-input (phonetic typing + conversion) have on web controls?</p> </blockquote> <p>For the most part you should not have to worry about it, unless you are trapping keyboard events. For example, I hate using Japanese keyboard with bunch of extra keyboard. So, when I have to assign IME on/off command to some key on US keyboard. I personally use right-Alt. Also, spacebar and enter key is used during conversion, but not sure if these events are passed to browser.</p>
<p>The directionality question is easy to answer for East Asian languages: websites are left-to-right, top-to-bottom as per usual.</p> <p>In fact, the general web design layout principles much the same. Have a look at the websites of a <a href="http://www.yomiuri.co.jp/" rel="nofollow noreferrer">newspaper</a> (name top left, navigation bar under with "Home" on the left, headline links below with most important at the top) or a <a href="http://www.baidu.com/" rel="nofollow noreferrer">search engine</a> (don't think I need to say which US site you should compare that layout to).</p> <p>However, just as Arabic/Hebrew/etc right-to-left language users will expect left-to-right progression in some contexts (embedded English fragments and so on), there are situations, even on the web, where top-to-bottom layout is preferred. This is generally done by including an image with the text layout and font desired, or using flash.</p> <p>Internet Explorer has actually offered tb-rl layout with the CSS <a href="http://msdn.microsoft.com/en-us/library/ms531187.aspx" rel="nofollow noreferrer">writing-mode property</a> since version 5.5 however <a href="http://www.blooberry.com/indexdot/css/properties/intl/writingmode.htm" rel="nofollow noreferrer">none of the other browsers</a> have bothered implementing it (or ruby, which is useful for sites aimed at a young audience). IE 5.5 was released in 2000, so that's eight years of support, and there was a <a href="http://www.w3.org/TR/2003/CR-css3-text-20030514/#Progression" rel="nofollow noreferrer">W3C candidate recommendation</a> in 2003 but <a href="http://dev.w3.org/csswg/css3-text-layout/#writing-mode" rel="nofollow noreferrer">text layout in CSS still being poked around</a>.</p> <p>As for your worries with text input and IMEs, as long as you're not doing something bogus like trying to manually translate the virtual keys given by keydown events into text strings, you're unlikely to run into problems.</p> <p>There are some additional issues you've not mentioned however. The minimum comfortably readable font size is larger than for languages written with the Latin script. Bold and italic for emphasis in flow are generally not appropriate. Han unification means to need to be picky about specifying the right fonts for the different CJK languages when working with unicode. You may want to provide both traditional and simplified interfaces for Chinese, depending on what audience you are expecting.</p> <p>I've been meaning to write up a more comprehensive guide along these lines for a while, if you need more information feel free to kick me.</p>
3,424
<p>The source database is quite large. The target database doesn't grow automatically. They are on different machines.</p> <p>I'm coming from a MS SQL Server, MySQL background and IDS11 seems overly complex (I am sure, with good reason).</p>
<p>One way to move data from one server to another is to backup the database using the dbexport command.</p> <p>Then after copying the backup files to the destination server run the dbimport command.</p> <p>To create a new database you need to create the DBSpace for the new database using the onmonitor tool, at this point you could use the existing files from the other server.</p> <p>You will then need to create the database on the destination server using the dbaccess tool. The dbaccess tool has a database option that allows you to create a database. When creating the database you specify what DBSpace to use.</p> <p>The source database may be made up of many chunks which you will also need to copy and attach to the new database.</p>
<p>have you used the export tool ? There used to be a way if you first put the db's into quiescent mode and then you could actually copy the DBSpaces across (dbspaces tool I think... its been a few years now).</p> <p>Because with informix you used to be able to specify the DBSpaces(s) to used for the table (maybe even in the alter table ?). </p> <p>Check - dbaccess tool - there is an export command.<br> Put the DB's into quiesent mode or shut down, copy the dbspaces and then attach table telling it to point to the new dbspaces file. (the dbspaces tool could be worth while looking at.. I have manuals around here. they are 9.2, but it shouldn't have changed too much).</p>
7,486
<p>Will the code below work if the clock on the server is ahead of the clock on the client?</p> <pre><code>Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1)) </code></pre> <p>EDIT: the reason I ask is on one of our web apps some users are claiming they are seeing the pages ( account numbers, etc ) from a user that previously used that machine. Yet we use the line above and others to 'prevent' this from happening.</p>
<p><a href="https://stackoverflow.com/questions/49547/making-sure-a-webpage-is-not-cached-across-all-browsers">This question</a> covers making sure a webpage is not cached. It seems you have to set several properties to ensure a web page is not cached across all browsers.</p>
<p>Your problem could be caused by the browser remembering data entered into form fields. You can turn this off like this:</p> <pre><code>&lt;input autocomplete="off"&gt; </code></pre>
8,157
<p>I am trying to do some string concatenation/formatting, but it's putting all the parameters into the first placeholder.</p> <p><strong>Code</strong></p> <pre><code>function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass) { # Command to create an IIS application pool $AppPoolScript = "cscript adsutil.vbs CREATE ""w3svc/AppPools/$AppPoolName"" IIsApplicationPool`n" $AppPoolScript += "cscript adsutil.vbs SET ""w3svc/AppPools/$AppPoolName/WamUserName"" ""$AppPoolUser""`n" $AppPoolScript += "cscript adsutil.vbs SET ""w3svc/AppPools/$AppPoolName/WamUserPass"" ""$AppPoolPass""`n" $AppPoolScript += "cscript adsutil.vbs SET ""w3svc/AppPools/$AppPoolName/AppPoolIdentityType"" 3" return $AppPoolScript } $s = CreateAppPoolScript("name", "user", "pass") write-host $s </code></pre> <p><strong>Output</strong></p> <pre class="lang-none prettyprint-override"><code>cscript adsutil.vbs CREATE "w3svc/AppPools/name user pass" IIsApplicationPool cscript adsutil.vbs SET "w3svc/AppPools/name user pass/WamUserName" "" cscript adsutil.vbs SET "w3svc/AppPools/name user pass/WamUserPass" "" cscript adsutil.vbs SET "w3svc/AppPools/name user pass/AppPoolIdentityType" 3 </code></pre>
<p>Lose the parentheses and commas. </p> <p>Calling your function as:</p> <pre><code>$s = CreateAppPoolScript "name" "user" "pass" </code></pre> <p>gives:</p> <pre class="lang-none prettyprint-override"><code>cscript adsutil.vbs CREATE "w3svc/AppPools/name" IIsApplicationPool cscript adsutil.vbs SET "w3svc/AppPools/name/WamUserName" "user" cscript adsutil.vbs SET "w3svc/AppPools/name/WamUserPass" "pass" cscript adsutil.vbs SET "w3svc/AppPools/name/AppPoolIdentityType" 3 </code></pre>
<p>Paul's right.<br> In PowerShell, function parameters are not enclosed in parenthesis. (Method parameters still are.)<br> Your initial call was just passing one big array to the function, rather than the three separate parameters you wanted.</p>
4,277
<p>I have a Windows C# program that uses a C++ dll for data i/o. My goal is to deploy the application as a single EXE. </p> <p>What are the steps to create such an executable?</p>
<p>Single Assembly Deployment of Managed and Unmanaged Code Sunday, February 4, 2007</p> <p>.NET developers love XCOPY deployment. And they love single assembly components. At least I always feel kinda uneasy, if I have to use some component and need remember a list of files to also include with the main assembly of that component. So when I recently had to develop a managed code component and had to augment it with some unmanaged code from a C DLL (thx to Marcus Heege for helping me with this!), I thought about how to make it easier to deploy the two DLLs. If this were just two assemblies I could have used ILmerge to pack them up in just one file. But this doesn´t work for mixed code components with managed as well as unmanaged DLLs.</p> <p>So here´s what I came up with for a solution:</p> <p>I include whatever DLLs I want to deploy with my component´s main assembly as embedded resources. Then I set up a class constructor to extract those DLLs like below. The class ctor is called just once within each AppDomain so it´s a neglible overhead, I think.</p> <pre><code>namespace MyLib { public class MyClass { static MyClass() { ResourceExtractor.ExtractResourceToFile("MyLib.ManagedService.dll", "managedservice.dll"); ResourceExtractor.ExtractResourceToFile("MyLib.UnmanagedService.dll", "unmanagedservice.dll"); } ... </code></pre> <p>In this example I included two DLLs as resources, one being an unmanaged code DLL, and one being a managed code DLL (just for demonstration purposes), to show, how this technique works for both kinds of code.</p> <p>The code to extract the DLLs into files of their own is simple:</p> <pre><code>public static class ResourceExtractor { public static void ExtractResourceToFile(string resourceName, string filename) { if (!System.IO.File.Exists(filename)) using (System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create)) { byte[] b = new byte[s.Length]; s.Read(b, 0, b.Length); fs.Write(b, 0, b.Length); } } } </code></pre> <p>Working with a managed code assembly like this is the same as usual - almost. You reference it (here: ManagedService.dll) in your component´s main project (here: MyLib), but set the Copy Local property to false. Additionally you link in the assembly as an Existing Item and set the Build Action to Embedded Resource.</p> <p>For the unmanaged code (here: UnmanagedService.dll) you just link in the DLL as an Existing Item and set the Build Action to Embedded Resource. To access its functions use the DllImport attribute as usual, e.g.</p> <pre><code>[DllImport("unmanagedservice.dll")] public extern static int Add(int a, int b); </code></pre> <p>That´s it! As soon as you create the first instance of the class with the static ctor the embedded DLLs get extracted into files of their own and are ready to use as if you deployed them as separate files. As long as you have write permissions for the execution directory this should work fine for you. At least for prototypical code I think this way of single assembly deployment is quite convenient.</p> <p>Enjoy!</p> <p><a href="http://weblogs.asp.net/ralfw/archive/2007/02/04/single-assembly-deployment-of-managed-and-unmanaged-code.aspx" rel="noreferrer">http://weblogs.asp.net/ralfw/archive/2007/02/04/single-assembly-deployment-of-managed-and-unmanaged-code.aspx</a></p>
<p>PostBuild from <a href="http://www.xenocode.com/" rel="nofollow noreferrer">Xenocode</a> can package up both managed and unmanged into a single exe.</p>
9,789
<p>I'm wondering what strategies people use for reduced sign on with legacy applications and how effective they have found them? </p> <p>We have an ASP.Net based intranet and own a lot of the legacy applications, but not all. We also have BizTalk and are considering the use of it's SSO engine too.</p>
<p>A good compromise between effort/rework and the convenience of single sign on is to continue to maintain a list of users, privileges, roles etc in the legacy app. Make the changes necessary to automatically log the user into your application based on their user account (usually their Windows or network account).</p> <p>I'm currently running a couple of applications that use this method of sign on, and it makes them seem more integrated even though they aren't.</p> <p>Another advantage we've found is that it stops people from sharing passwords to legacy applications. They're much less likely to hand out an admin password that also gives others access to their email or payroll details!</p>
<p>We did two things with legacy accounts. (legacy web based apps)</p> <p>We first mapped the legacy accounts to their system logon accounts (running in a Windows Active Directory). </p> <p>A facade logon screen then was applied to over the top of the legacy apps (web based), this would request the AD logon, which would then reverse map to the legacy applications logon account and assign the appropriate rights to the user, using the legacy systems security model. The user received a token for the session which kept the doors open for them.</p> <p>This gave us the benefit of not having to retrofit legacy apps (for example what would happen is app x only had numbers for ID, and the user uses a windows logon (alphanumeric), and also achieve a psuedo single signon from the client's perspective.</p> <p>The other option that did make sense was at the new logon screen, it would check multiple repositories of security, so even if the user didn't decide to use their windows logon they could still logon with the legacy account name. Obviously this does have some side effects but can also help ease the transition pain end users sometimes feel moving between systems.</p> <p>There are also programs like the <a href="http://www.citrix.com/English/ps2/products/subfeature.asp?contentID=163988" rel="nofollow noreferrer">Citrix XenApp Single Signon</a> which take a totally different approach to the issue. </p>
7,431
<p>TreeNodeCollection, like some of the other control collections in System.Windows.Forms, implements IEnumerable. Is there any design reason behind this or is it just a hangover from the days before generics?</p>
<p>Yes, there are many .NET Framework collection, that does not implement generic IEnumerable. </p> <p>I think that's because after 2.0 there was no (at least not so match) development of the core part of FW.</p> <p>Meanwhile I suggest you to make use of following workaround:</p> <pre><code>using System.Linq; ... var nodes = GetTreeNodeCollection().OfType&lt;TreeNode&gt;(); </code></pre>
<p>Yes, Windows Forms dates back to before generics in .Net</p>
5,838
<p>Recently, at work we bought a Guider II printer from FlashForge. When we try to print models using a high resolution or models with a too high printing time, the feeder gets clogged. And the feeder is too hot. We have concluded that the feeder is getting clogged because the high temperature softens the PLA.</p> <p>We check the feeder fan and is working fine. How can I avoid the jamming? Pausing the 3D printer and wait a few minutes is not working for us. I don't know if it is a common problem for this 3D printer model.</p> <p><strong>Edit:</strong> </p> <p>The hotend is an all metal hot end. I can't find more information about the hot end. </p> <p>In the manual of the guider II flashforge recommend a temperature of 210°C for the head and 30°C for the bed. I have tried different temperatures. The most common temperature I've used is 190°C for the head and 55°C for the bed (I obtain the best results with this temperature).</p> <p>This is the Hotend used by this 3d printer. <a href="https://i.stack.imgur.com/jrEnr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jrEnr.png" alt="Hotend picture"></a></p>
<p>The symptoms you describe hint to heat creep. Heat creep is the gradual increase in temperature of the cold end assembly (cooling fins and heat break). This gradual temperature increase leads to too high filament temperatures and as such premature filament softening. In combination with (large) retraction settings, this can lead to clogging of the nozzle. All-metal hotend assemblies are more prone experiencing these problems; lined hotends have a PTFE lining that also insulates the filament so that it does not soften prematurely like in all-metal hotends can happen. Heat creep is best remedied by properly cooling the hotend (good quality fan, no obstructions or large ducts) and reducing the retraction length (and possibly lowering the print temperature, but you already tried that). You could also contact the manufacturer for advice.</p>
<p>If the temperature is too high it can charr the plastic, causing jams. There are many reasons for that. If the temperature you have selected is not too high (&lt;200C), then it might be the thermistor not correctly reading the temperature. If you can measure the hot end temperature, that will give definitive answer to that question. </p> <p>Additionally, some filament contains additives that can get burned even at lower temperatures. I find it every difficult to print with woodfill if it takes very long to print. Some wood chips gets burned and causes jamming.</p>
1,201
<p>Whilst working on a recent project, I was visited by a customer QA representitive, who asked me a question that I hadn't really considered before:</p> <blockquote> <p>How do you know that the compiler you are using generates machine code that matches the c code's functionality exactly and that the compiler is fully deterministic?</p> </blockquote> <p>To this question I had absolutely no reply as I have always taken the compiler for granted. It takes in code and spews out machine code. How can I go about and test that the compiler isn't actually adding functionality that I haven't asked it for? or even more dangerously implementing code in a slightly different manner to that which I expect?</p> <p>I am aware that this is perhapse not really an issue for everyone, and indeed the answer might just be... "you're over a barrel and deal with it". However, when working in an embedded environment, you trust your compiler implicitly. How can I prove to myself and QA that I am right in doing so?</p>
<p>For safety critical embedded application certifying agencies require to satisfy the "proven-in-use" requirement for the compiler. There are typically certain requirements (kind of like "hours of operation") that need to be met and proven by detailed documentation. However, most people either cannot or don't want to meet these requirements because it can be very difficult especially on your first project with a new target/compiler. </p> <p>One other approach is basically to NOT trust the compiler's output at all. Any compiler and even language-dependent (Appendix G of the C-90 standard, anyone?) deficiencies need to be covered by a strict set of static analysis, unit- and coverage testing in addition to the later functional testing. </p> <p>A standard like <a href="http://www.embedded.com/columns/beginerscorner/9900659?_requestid=212266" rel="noreferrer">MISRA-C</a> can help to restrict the input to the compiler to a "safe" subset of the C language. Another approach is to restrict the input to a compiler to a subset of a language and test what the output for the entire subset is. If our application is only built of components from the subset it is assumed to be known what the output of the compiler will be. The usually goes by "qualification of the compiler". </p> <p>The goal of all of this is to be able to answer the QA representative's question with "We don't just rely on determinism of the compiler but this is the way we prove it...". </p>
<ol> <li>Changing the optimization level of the compiler will change the output.</li> <li>Slight changes to a function may make the compiler inline or no longer inline a function.</li> <li>Changes to the compiler (gcc versions for example) may change the output</li> <li>Certain library functions may be instrinic (i.e., emit optimized assembly) while others most are not.</li> </ol> <p>The good news is that for most things it really doesn't matter that much. Where it does, you may want to consider assembly if it really matters (e.g., in an ISR). </p>
8,544
<p>I am trying to write a web-app to manage references for my PhD thesis.</p> <p>I used to manage this information inside a personal Confluence (fantastic tool! - <a href="http://www.atlassian.com/software/confluence/" rel="nofollow noreferrer">http://www.atlassian.com/software/confluence/</a>) instance however I'm fed-up with the opening of PDF's and cutting and pasting values into fields that I wish to record.</p> <p>I have exposed a webservice that will return me images based on a PDF filename and a page number. The same webservice also exposes a method that will return the text inside of a provided rectangle (top left x-y coord, bottom right x-y coord).</p> <p>I would like to be able to drag a rectangle over part of the PDF image and then call the webservice to give me the text (which I will then store on a EntityBean). I am looking at using the JBoss application stack (Application Server, Hibernate, Seam and Richfaces). Does anybody know how I could go about achieving this? I have seen the ability to draw custom images in other RIA toolkits (e.g. dojo), but I can't see a way of doing this inside of Richfaces.</p> <p>Hopefully somebody out there could prove me wrong, or provide some idea about what I can do (as I am not a web developer - I'm mainly building this tool because the RIA frameworks available now have got me interested!)</p> <p>I already have the code to extract the text, my problem is purely how can I get the user to draw a "selection rectangle" inside the web browser over the top of the image?</p> <p>Many Thanks,</p> <p>Aidos</p>
<p>Try using the <a href="http://livedemo.exadel.com/richfaces-demo/richfaces/paint2D.jsf?c=paint2d&amp;tab=usage" rel="nofollow noreferrer">RichFaces Paint 2D</a> tag</p> <p>It exposes the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics2D.html" rel="nofollow noreferrer">Graphics2D</a> package to the user interface.</p> <p>Track user drag events on the image using javascript, then post the co-ordrdinates to the backing bean to re-render the image with a drawn on selection box.</p>
<p>Have you considered <a href="http://www.mendeley.com/" rel="nofollow noreferrer">Mendeley</a> ? It will try to parse and extract bibliographic information from your pdfs.</p>
9,636
<p>I need help resolving some conflicting logic between the nozzle width and shell thickness--parameters in Cura 16.021--and the physical deposited line width (width on x-y plane).</p> <p>DEFINITIONS</p> <p>For clarity, let me define a few terms I'm using:</p> <p>Nozzle size - nominal diameter of the nozzle / Cura parameter</p> <p>Nozzle diameter - true diameter of the nozzle</p> <p>Extrusion diameter - diameter of circular cross-section extrusion upon leaving the nozzle</p> <p>Deposited line width - width of the rectilinear layer deposited on the build surface <strong>in the x-y plane</strong> (not the z-layer height).</p> <p>Shell thickness - Cura parameter for part wall thickness </p> <p>Cura - Cura version 16.021</p> <p><a href="https://i.stack.imgur.com/XBhmE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XBhmE.png" alt="Extrusion Diagram"></a> PROBLEM 1</p> <p>Physics suggests that for regular continuous flow out of the nozzle the extrusion diameter (cylindrical material extrusion) would be slightly larger than the nozzle diameter, and the deposited line width (rectangular prismatic extrusion) on the x-y plane should be even wider than the extrusion diameter. I'm assuming the deposited line width is equal to the shell thickness as set in Cura. However, I am finding conflicting advice as to whether one should set the shell thickness slightly greater than or slightly less than the nozzle diameter. </p> <p>In <a href="https://community.ultimaker.com/topic/3297-what-does-it-do-when-i-change-the-nozzle-diameter-in-cura/?do=findComment&amp;comment=43605" rel="nofollow noreferrer">this post</a> on the Ultimaker forum, the moderator seems to suggest that the nozzle size and deposited line width are one and the same.</p> <p>In <a href="https://3dprinting.stackexchange.com/questions/1410/how-does-the-sizes-of-nozzle-diameter-and-the-z-axis-layer-resolution-work">this post</a> on StackExchange, the discussion seems to agree with my understanding.</p> <p>PROBLEM 2</p> <p>A <a href="https://mattshub.com/2017/04/19/extruder-calibration/" rel="nofollow noreferrer">commonly referenced procedure</a> for calibrating extrusion suggests printing a 25mm cube with an open top and bottom. My understanding is that by printing four walls of a single shell thickness, we should correct the extrusion rate to achieve a deposited line width equal to nozzle diameter (Cura requires the shell thickness to be a multiple of nozzle diameter) . The problem I have with this is, as stated above, I don't understand a physical basis for targeting nozzle size = shell thickness (deposited line width). I'd expect to calibrate the extrusion to something slightly wider than the nozzle diameter.</p> <p><a href="https://i.stack.imgur.com/E04EG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E04EG.png" alt="enter image description here"></a></p> <p>My printing experience seems to confirm my intuition. If I reduce extrusion rate to achieve shell thickness = nozzle diameter my prints appear visually under-extruded with poor layer adhesion. Calibrating to about 110% of the nozzle size looks about right. </p> <p>PROBLEM 3</p> <p><a href="https://i.stack.imgur.com/XsusB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XsusB.png" alt="enter image description here"></a></p> <p>Although Cura constrains shell thickness to be a multiple of nozzle size, it will not slice thin shapes on the x-y plane equal to nozzle size, they need to be slightly wider. I have verified this multiple times by designing a part in SolidWorks with a 0.4mm wall, exporting it to Cura as an STL, and previewing the slices (using a 0.4 mm nozzle size). If I increase the wall thickness in the model to 0.41mm, Cura will slice the wall. This seems to suggest to me that Cura does account for a deposited line width > nozzle diameter. It calls to question whether the shell thickness is actually a physical dimension for the 3D print or just a parameter for the slicer engine. I have taken it to mean the number of passes around the perimeter in units of nozzle size, similar to other slicers that ask for a shell count.</p> <p>Thanks in advance to anyone who has put in the time to read this post and kindly share some knowledge. </p> <p>EDIT 1: My interchanging of terms "width" and "thickness" made it sound like I'm referring to z-layer height. Also, Trish pointed out that "line width" is the better term rather than "layer width" so I have updated this. My post is only concerned with the deposited layer width in the x-y plane--"line width". </p>
<p>So, I think I may have found a satisfactory answer. Cura 3.6 includes separate parameters for line width and shell count:</p> <p><a href="https://i.stack.imgur.com/L8uJu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L8uJu.png" alt=""></a> </p> <p>This seems to decouple the line width from the specified nozzle size and target what I believe is a more optimal width (~110% the nozzle diameter). It was the other version of Cura that was driving a lot of confusion with the line width being defined by the nozzle size. This also removes the weirdness of not being able slice lines equal to the line width.</p> <p>Thanks to all who responded.</p>
<p>There may be die swell, which will depend on the extrusion force, the material type, and the exact temperature within the hot end. This is because the viscosity is highly dependent on those parameters.</p> <p>As to line width: again extruded temperature, material, ambient temperature, cooling fan coverage all play into how much "sag" takes place before the material hardens. Oh, and X-Y speed of the nozzle, of course. </p> <p>Further, for the first layer, if the nozzle is nice and close to the bed, the nozzle itself will force the material to spread laterally while limiting the vertical extent. </p> <p>Personally, I don't think it's worth the effort to create a mathematical model. Spend the 3 cents' worth of electricity, 0.01 cents' worth of material, and 15 minutes of time to calibrate if desired. </p>
1,091
<p>I have been playing around with creating scripts to generate some custom G-code for a Malyan M180 and I am having trouble understand what commands to use to switch nozzles. Sometimes I can get the nozzles to switch and it doesn't recenter but sometimes it does. I have been using:</p> <pre><code>G54 M108 T0; switch to left </code></pre> <p>and</p> <pre><code>G55 M108 T1; switch to right </code></pre> <p>Has anyone else looked into this and have any idea what commands or sequence of commands should be used to change nozzles?</p>
<p>No, M108 does not do that. You are looking for <strong>T#</strong>, where # is the tool position you want:</p> <pre><code>T1 ; switch to tool position 1 T3 ; switch to tool position 3 </code></pre> <p>This tells the processor to send all heating, cooling and flow commands to this tool until another tool change is specified, and invokes the X/Y(/Z) offset for the new tool position.</p> <p>See <a href="http://reprap.org/wiki/G-code#T:_Select_Tool" rel="nofollow noreferrer">http://reprap.org/wiki/G-code#T:_Select_Tool</a></p>
<p>As @tbm0115 has mentioned - it differs. Your <code>M108 T{index of tool}</code> command is perfectly fine on some FlashForge printers, a company known for its different sorts of proprietary code. It is indeed used for tool changing here.</p> <p>While on the common Marlin firmware (e.g. used on the popular Creality Ender printers), <code>M108</code> does a completely different thing-namely acting as a break sequence if the G-code parser is in a closed-loop-condition (after certain commands like <code>M109</code> that wait until a certain action takes place).</p>
538
<p>My first and only 3D printer is a Printrbot Simple Metal, which has a hotend that doesn't expose any of its internal parts. Easy for beginners, I suppose: "The hotend is that tube that heats up the plastic and deposits it on the print bed."</p> <p><a href="https://i.stack.imgur.com/7y1yy.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/7y1yy.jpg" alt="Printrbot Simple Metal hotend"></a> <a href="https://i.stack.imgur.com/SwwW1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/SwwW1.jpg" alt="More complex looking hotend"></a></p> <p>But I've been trying to learn more, and many hotends out there don't look quite as simple. My Printrbot hotend probably isn't as simple as it looks, either.</p> <p>What are the parts that make up a hotend, and what do they do?</p> <p><em>(PS: This is a general question, not specifically about the two example hotends above.)</em></p>
<p>This varies by hotend design. The following is a list of components which you might find in a typical hotend, but note that different designs may integrate these components to some extent. For instance, on the J-head the heat block, nozzle and heatbreak are all one and the same component whereas on the E3D hotends these are all separate parts.</p> <ul> <li><p><strong>Nozzle</strong>: This is the part where the filament comes out. It takes in the molten filament (typically as a bead of 1.75mm/3mm) and tapers down to the nozzle size (typically around 0.4mm). These are typically made of brass for its good heat conductivity, but brass is not suitable for printing abrasive materials (such as glow in the dark and metal-filled filaments) so sometimes (hardened) stainless steel is used.</p></li> <li><p><strong>Heater Block</strong>: Usually made from aluminium, the heater block joins the nozzle to the heat break and holds the heater cartridge and thermistor.</p></li> <li><p><strong>Heater Cartridge</strong>: most hotends use a ceramic heater cartridge, though some older designs use power resistors or nichrome wire. This component is, as the name suggests, responsible for heating up the hotend. The heat block usually clamps around the heater cartridge to provide good contact.</p></li> <li><p><strong>Thermistor</strong>: This part senses the temperature of the heat block. It is usually a small glass bead with two wires attached (which are typically insulated with glass fiber or teflon). For high-temperature printing, a thermocouple may be used in stead.</p></li> <li><p><strong>Heat Break</strong>: this is the part where hot meets cold. It usually takes the form of a thin tube and is made of stainless steel for its low thermal conductivity. The goal is generally to have the transition be as short as possible so as little of the filament is in a molten state as possible. It connects the heat block to the heat sink.</p></li> <li><p><strong>Heat Sink</strong>: the purpose of the heat sink is to cool down the cold side of the heat break. It is typically cooled with a fan. Most heat sinks also have a standard groove-mount for mounting to your printer. The heat sink usually has grooves to increase its surface area and cooling capability.</p></li> <li><p><strong>Teflon Liner</strong>: some hotends have a PTFE liner that guides the filament through the heat break into the nozzle. This makes it easier to print PLA, but compared to an all-metal hotend, limits the temperatures at which you can print (making it difficult to print PETG and impossible to print polycarbonate).</p></li> </ul> <p>The ubis hotend you mentioned is a bit simpler than this, and simply uses a big chunk of PEEK in place of the heat break/sink. PEEK has very low thermal conductivity and thus passive cooling is sufficient. However, PEEK limits the temperatures at which you can print.</p> <p>Here is an illustration outlining these components on an E3D V6 hotend:</p> <p><a href="https://i.stack.imgur.com/cjuNi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cjuNi.png" alt="enter image description here"></a></p> <p>Note that in this image the Teflon liner only goes into the heat sink, and not into the heat break or block. This means the maximum temperature is not limited by the Teflon, but if it did go all the way in (as is the case with, for instance, the Lite6) then it would be.</p>
<p><strong>picture on the left</strong></p> <p>This hotend is made out of <a href="https://en.wikipedia.org/wiki/PEEK" rel="nofollow">PEEK plastics</a> (beige). It can work in temperature upto 250C. As it is also good heat insulator then it doesn't need to have cooling fan. Red part on this picture is just a cover (insulator) of the heater which heatup nozzle (gold). Black are just wires and connectors.</p> <p><strong>picture on the right</strong></p> <p>This hotend is metal so it needs two things - cooling fan and heat barrier. Beginning fron the left - red wires are connected to (silver) block which is heater itself. Between the block and this round silver part (which is a heatsink) there is heat barrier (thin pipe which is poor heat conductor). Heatsink has plastic funnel (blue) which directs an airflow from fan (black) through heatsink.</p>
345
<p>I just changed my nozzle on my Anet A8 after it was fully used up. When I started printing with my new 0.4&nbsp;mm nozzle (same as before) my <a href="https://imgur.com/a/2x42LTB" rel="nofollow noreferrer">extrusion</a> was VERY bad and inconsistent, even so bad I couldn't continue printing because it would pull the first layer off. </p> <p>If I compare it to my <a href="https://imgur.com/a/oOOK50y" rel="nofollow noreferrer">extrusion</a> before the nozzle switch, it is really bad, even though I tightened everything as before. I am quite sure it doesn't have to do with adhesion to the heated bed since I use tape with PVA glue. </p> <p>Any advice on how to remove this under extrusion so I can continue printing?</p> <p>All the specs:</p> <ul> <li>25&nbsp;mm/s first layer print speed</li> <li>200&nbsp;&deg;C nozzle</li> <li>60&nbsp;&deg;C bed</li> <li>PLA filament;</li> <li>0.4&nbsp;mm nozzle size</li> </ul> <p>Let me know if there is anything else you need to know.</p>
<p>Your good extrusion look also a little bad , and the bad extrusion looks like a big feeding problem. for this you need:</p> <p>Feeding.- try to tight the presure of the feeder thread, the one that press the filament on the extruder.</p> <p>Bed Adhesion.- Use between 32° and 38°C if you are using masking tape, on higher temperatures the masking tape becomes to peel off if any border of the printing part is close to the edge of the tape. </p> <p>Sand the masking tape surface and clean it to be free of dust (eliminate shiny surface) with this is enough to get a good adhesion; I recommend TUK and 3D brands, they are sticky. If you need more adhesion you can spray a little hair spray, just one pass.</p> <p>Clogged Nozzle.- you need to clean it, on your kitchen stove heat the nozzle until melt the filament, then use some cooper wire (some phone wiring has it) to remove residues inside the nozzle. If posible you can buy a drill bit with 0.4mm diameter to ensure a complete cleaning.</p>
<p>In the nozzle assembled properly? As I assumed that there were no other changes during the nozzle exchange process, then there is a risk of a gap inside throat and nozzle that just builds up and blocks the extrusion.</p> <p>Please see <a href="https://3dprinting.stackexchange.com/a/5830/9730">this answer</a> for an assembly hints.</p>
890
<p>I'm deploying to Ubuntu slice on slicehost, using Rails 2.1.0 (from <code>gem</code>)</p> <p>If I try <code>mongrel_rails</code> start or script/server I get this error:</p> <pre><code> Rails requires RubyGems &gt;= 0.9.4. Please install RubyGems </code></pre> <p>When I type <code>gem -v</code> I have version <code>1.2.0</code> installed. Any quick tips on what to look at to fix?</p>
<p>Have you tried reinstalling RubyGems? I had a pretty similar error message until I reuninstalled and for some reason, it installed into a different directory and then the problem went away.</p>
<p>Have you tried reinstalling RubyGems? I had a pretty similar error message until I reuninstalled and for some reason, it installed into a different directory and then the problem went away.</p>
4,902
<p>Reading <a href="http://msdn.microsoft.com/en-us/library/ms345265.aspx" rel="nofollow noreferrer">MSDN</a> (and other sources) about custom report items (CRI) for reporting services 2005. It looks like I'm limited to generating a bitmap. Not even with some mapping overlay for detecting mouse clicks on it. Is there away to go around this? There are two things I would like to do:</p> <ul> <li>Embed HTML directly into the report, to format dynamic text.</li> <li>Embed flash (swf) control in the report. This could be done with HTML if the previous point is possible. But maybe there is another way</li> </ul> <p>Any suggestions? What am I missing?</p>
<p>You didn't missing anything.</p> <p>For me, like you mentioned, the main disadvantage is, that with a CRI you can only render images. You don't get any scalable text or something similar. If you want include swf, you need to render it as static image.</p>
<p>You can render the report as HTML and include the report using a floating frame in a page with the swf file. You can use functions to format dynamic text. SSRS 2008 solves some of these problems with the "richly" formated textbox (not RTF). it may worth a look, if it's an option. </p>
4,118
<p>In prior versions of Windows before Vista you could have a Windows Service interact with the current logged in desktop user to easy display information on the screen from the service. In Windows Vista Session 0 was added for security to isolate the services from the desktop. What is an easy way to communicate between a service and an application running outside of Session 0? So far I have gotten around this by using TCP/IP to communicate between the two but it seems to be kind of a sloppy way to do it.</p>
<p>You can use shared memory or named pipe to facilitate IPC as well. Conceptually this is similar to TCP/IP, but you don't have to worry about finding an unused port.</p> <p>You have to make sure that the named objects you create are prefixed with "Global\" to allow them to be accessed by all sessions as described <a href="http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx" rel="nofollow noreferrer">here</a>.</p> <p>AFAIK there is no way for a service to directly interact with the desktop any more.</p>
<p>For the service to talk to the desktop, you're pretty much stuck with one of the RPC mechanisms. The .NET remoting mechanism (<a href="http://msdn.microsoft.com/en-us/library/system.runtime.remoting.channels.ipc.ipcserverchannel.aspx" rel="nofollow noreferrer">IpcServerChannel</a>) isn't to hard to implement for this purpose. </p> <p>Also with .NET a desktop application can send messages directly to the service with the <a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.executecommand.aspx" rel="nofollow noreferrer">ServiceController.ExecuteCommand</a>. These commands are received by the service via <a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.oncustomcommand.aspx" rel="nofollow noreferrer">ServiceBase.OnCustomCommand</a>. This is even easier to do, and would be all you need if controlling the service is your only requirement.</p>
7,945
<p>So creating a Windows service using Visual Studio is fairly trivial. My question goes a bit deeper as to what actually makes an executable installable as a service &amp; how to write a service as a straight C application. I couldn't find a lot of references on this, but I'm presuming there has to be some interface I can implement so my .exe can be installed as a service.</p>
<p>Setting up your executable as a service is part of it, but realistically it's usually handled by whatever installation software you're using. You can use the command line SC tool while testing (or if you don't need an installer).</p> <p>The important thing is that your program has to call StartServiceCtrlDispatcher() upon startup. This connects your service to the service control manager and sets up a ServiceMain routine which is your services main entry point.</p> <p>ServiceMain (you can call it whatever you like actually, but it always seems to be ServiceMain) should then call RegisterServiceCtrlHandlerEx() to define a callback routine so that the OS can notify your service when certain events occur.</p> <p>Here are some snippets from a service I wrote a few years ago:</p> <p>set up as service:</p> <pre><code>SERVICE_TABLE_ENTRY ServiceStartTable[] = { { "ServiceName", ServiceMain }, { 0, 0 } }; if (!StartServiceCtrlDispatcher(ServiceStartTable)) { DWORD err = GetLastError(); if (err == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) return false; } </code></pre> <p>ServiceMain:</p> <pre><code>void WINAPI ServiceMain(DWORD, LPTSTR*) { hServiceStatus = RegisterServiceCtrlHandlerEx("ServiceName", ServiceHandlerProc, 0); </code></pre> <p>service handler:</p> <pre><code>DWORD WINAPI ServiceHandlerProc(DWORD ControlCode, DWORD, void*, void*) { switch (ControlCode) { case SERVICE_CONTROL_INTERROGATE : // update OS about our status case SERVICE_CONTROL_STOP : // shut down service } return 0; } </code></pre>
<p>Hope this helps:</p> <p><a href="http://support.microsoft.com/kb/251192" rel="nofollow noreferrer">http://support.microsoft.com/kb/251192</a></p> <p>It would seem that you simple need to run this exe against a binary executable to register it as a service.</p>
6,307
<p>I need to run a stored procedure from a C# application.</p> <p>I use the following code to do so:</p> <pre><code>Process sqlcmdCall = new Process(); sqlcmdCall.StartInfo.FileName = "sqlcmd.exe"; sqlcmdCall.StartInfo.Arguments = "-S localhost\\SQLEXPRESS -d some_db -Q \":EXIT(sp_test)\"" sqlcmdCall.Start(); sqlcmdCall.WaitForExit(); </code></pre> <p>From the sqlcmdCall object after the call completes, I currently get an ExitCode of -100 for success and of 1 for failure (i.e. missing parameter, stored proc does not exist, etc...).</p> <p>How can I customize these return codes?</p> <p>H.</p>
<p>If you are trying to call a stored procedure from c# you would want to use ADO.Net instead of the calling sqlcmd via the command line. Look at <code>SqlConnection</code> and <code>SqlCommand</code> in the <code>System.Data.SqlClient</code> namespace.</p> <p>Once you are calling the stored procedure via <code>SqlCommand</code> you will be able to catch an exception raised by the stored procedure as well we reading the return value of the procedure if you need to.</p>
<p>Even with windows authentication you can still use <code>SqlCommand</code> and <code>SqlConnection</code> to execute, and you don't have to re-invent the wheel for exception handling.</p> <p>A simple connection configuration and a single <code>SqlCommand</code> can execute it without issue.</p>
9,871
<p>It seems to me obfuscation is an idea that falls somewhere in the "security by obscurity" or "false sense of protection" camp. To protect intellectual property, there's copyright; to prevent security issues from being found, there's <em>fixing those issues</em>. In short, I regard it as a technical solution to a social problem. <a href="http://www.ietf.org/mail-archive/web/ietf/current/msg22508.html" rel="nofollow noreferrer">Those almost never work.</a></p> <p>However, I seem to be the only one in our dev team to feel that way, so I'm either wrong, or just need convincing arguments. Our product uses .NET, and one dev suggested .NET Reactor (which, incidentally, <a href="https://stackoverflow.com/questions/2525/best-net-obfuscation-toolsstrategy#22990">was suggested in this SO thread as well</a>).</p> <blockquote> <p>.NET Reactor completely stops any decompiling by mixing any pure .NET assembly (written in C#, VB.NET, Delphi.NET, J#, MSIL...) with native machine code.</p> </blockquote> <p>So, basically, you throw all advantages of bytecode away in one go?</p> <p>Are there good <em>engineering</em> benefits to obfuscation?</p>
<p>You asked for engineering reasons, so this is not strictly speaking an answer to the question. But I think it's a valid clarification.</p> <p>As you say, obfuscation is intended to address a social problem. And social (or business) problems, unlike technical ones, rarely have a complete solution. There are only degrees of success in addressing or minimising the problem.</p> <p>In this case, obfuscation will raise the barriers to someone decompiling and stealing your code. It will discourage casual attacks and, through inertia, may make your intellectual property less likely to be stolen. To make a tiresome analogy, an immobiliser doesn't prevent your car being stolen, but it will make it less likely.</p> <p>Of course there is a cost, in maintainability, (possibly) in performance and most importantly in making it harder for users to accurately submit bug reports.</p> <p>As GateKiller said, obfuscation won't prevent a determined team from decompiling, but (and it depends what your product is) how determined a team is likely to be attacking you?</p> <p>So, this is not a technical solution to a social problem, it's a technical decision which adds one influence to a complex social structure.</p>
<p>Use encryption to protect information on the way.</p> <p>Use obfuscation to protect information while your program still has it.</p>
5,183
<p>With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007).</p> <p>One of the main issues with testing forms is that only a few controls have a <code>hwnd</code> handle and other controls only get one they have focus, which makes automation quite opaque since you cant get a list of controls on a form to act on.</p> <p>Any experience to share?</p>
<h1>1. Write Testable Code</h1> <p>First, stop writing business logic into your Form's code behind. That's not the place for it. It can't be properly tested there. In fact, you really shouldn't have to test your form itself at all. It should be a dead dumb simple view that responds to User Interaction and then delegates responsibility for responding to those actions to another class that <strong><em>is</em></strong> testable.</p> <p>How do you do that? Familiarizing yourself with the <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="noreferrer">Model-View-Controller pattern</a> is a good start. </p> <p><img src="https://i.stack.imgur.com/iY37U.png" alt="Model View Controller diagram"></p> <p>It can't be done <em>perfectly</em> in VBA due to the fact that we get either events or interfaces, never both, but you can get pretty close. Consider this simple form that has a text box and a button.</p> <p><img src="https://i.stack.imgur.com/ts6jl.png" alt="simple form with text box and button"></p> <p>In the form's code behind, we'll wrap the TextBox's value in a public property and re-raise any events we're interested in.</p> <pre><code>Public Event OnSayHello() Public Event AfterTextUpdate() Public Property Let Text(value As String) Me.TextBox1.value = value End Property Public Property Get Text() As String Text = Me.TextBox1.value End Property Private Sub SayHello_Click() RaiseEvent OnSayHello End Sub Private Sub TextBox1_AfterUpdate() RaiseEvent AfterTextUpdate End Sub </code></pre> <p>Now we need a model to work with. Here I've created a new class module named <code>MyModel</code>. Here lies the code we'll put under test. Note that it naturally shares a similar structure as our view.</p> <pre><code>Private mText As String Public Property Let Text(value As String) mText = value End Property Public Property Get Text() As String Text = mText End Property Public Function Reversed() As String Dim result As String Dim length As Long length = Len(mText) Dim i As Long For i = 0 To length - 1 result = result + Mid(mText, (length - i), 1) Next i Reversed = result End Function Public Sub SayHello() MsgBox Reversed() End Sub </code></pre> <p>Finally, our controller wires it all together. The controller listens for form events and communicates changes to the model and triggers the model's routines.</p> <pre><code>Private WithEvents view As Form_Form1 Private model As MyModel Public Sub Run() Set model = New MyModel Set view = New Form_Form1 view.Visible = True End Sub Private Sub view_AfterTextUpdate() model.Text = view.Text End Sub Private Sub view_OnSayHello() model.SayHello view.Text = model.Reversed() End Sub </code></pre> <p>Now this code can be run from any other module. For the purposes of this example, I've used a standard module. I highly encourage you to build this yourself using the code I've provided and see it function.</p> <pre><code>Private controller As FormController Public Sub Run() Set controller = New FormController controller.Run End Sub </code></pre> <hr> <p>So, that's great and all <strong><em>but what does it have to do with testing?!</em></strong> Friend, it has <strong><em>everything</em></strong> to do with testing. What we've done is make our code <em>testable</em>. In the example I've provided, there is no reason what-so-ever to even try to test the GUI. The only thing we really need to test is the <code>model</code>. That's where all of the real logic is. </p> <p>So, on to step two.</p> <h1>2. Choose a Unit Testing Framework</h1> <p>There aren't a lot of options here. Most frameworks require installing COM Add-ins, lots of boiler plate, weird syntax, writing tests as comments, etc. That's why I got involved in <a href="https://github.com/rubberduck-vba/Rubberduck" rel="noreferrer">building one myself</a>, so this part of my answer isn't impartial, but I'll try to give a fair summary of what's available.</p> <ol> <li><p><a href="http://accunit.access-codelib.net/" rel="noreferrer">AccUnit</a></p> <ul> <li>Works only in Access.</li> <li>Requires you to write tests as a strange hybrid of comments and code. (no intellisense for the comment part.</li> <li>There <strong><em>is</em></strong> a graphical interface to help you write those strange looking tests though.</li> <li>The project has not seen any updates since 2013.</li> </ul></li> <li><p><a href="http://vb-lite-unit.sourceforge.net/" rel="noreferrer">VB Lite Unit</a> I can't say I've personally used it. It's out there, but hasn't seen an update since 2005.</p></li> <li><p><a href="http://xlvbadevtools.codeplex.com/" rel="noreferrer">xlUnit</a> xlUnit isn't awful, but it's not good either. It's clunky and there's lots of boiler plate code. It's the best of the worst, but it doesn't work in Access. So, that's out.</p></li> <li><p>Build your own framework</p> <p>I've <a href="https://codereview.stackexchange.com/questions/62781/unit-testing-in-vba">been there and done that</a>. It's probably more than most people want to get into, but it is completely possible to build a Unit Testing framework in Native VBA code.</p></li> <li><p><a href="https://github.com/rubberduck-vba/Rubberduck/wiki/Unit-Testing" rel="noreferrer">Rubberduck VBE Add-In's Unit Testing Framework</a><br> <em>Disclaimer: I'm one of the co-devs</em>.</p> <p>I'm biased, but this is by far my favorite of the bunch.</p> <ul> <li>Little to no boiler plate code.</li> <li>Intellisense is available.</li> <li>The project is active.</li> <li>More documentation than most of these projects.</li> <li>It works in most of the major office applications, not just Access.</li> <li>It is, unfortunately, a COM Add-In, so it has to be installed onto your machine.</li> </ul></li> </ol> <h1>3. Start writing tests</h1> <p>So, back to our code from section 1. The only code that we <em>really</em> needed to test was the <code>MyModel.Reversed()</code> function. So, let's take a look at what that test could look like. (Example given uses Rubberduck, but it's a simple test and could translate into the framework of your choice.)</p> <pre><code>'@TestModule Private Assert As New Rubberduck.AssertClass '@TestMethod Public Sub ReversedReversesCorrectly() Arrange: Dim model As New MyModel Const original As String = "Hello" Const expected As String = "olleH" Dim actual As String model.Text = original Act: actual = model.Reversed Assert: Assert.AreEqual expected, actual End Sub </code></pre> <h2>Guidelines for Writing Good Tests</h2> <ol> <li>Only test one thing at a time.</li> <li>Good tests only fail when there is a bug introduced into the system or the requirements have changed.</li> <li>Don't include external dependencies such as databases and file systems. These external dependencies can make tests fail for reasons outside of your control. Secondly, they slow your tests down. If your tests are slow, you won't run them.</li> <li>Use test names that describe what the test is testing. Don't worry if it gets long. It's most important that it is descriptive.</li> </ol> <hr> <p>I know that answer was a little long, and late, but hopefully it helps some people get started in writing unit tests for their VBA code.</p>
<p>Data Access Pages have been deprecated by MS for quite some time, and never really worked in the first place (they were dependent on the Office Widgets being installed, and worked only in IE, and only badly then).</p> <p>It is true that Access controls that can get focus only have a window handle when they have the focus (and those that can't get focus, such as labels, never have a window handle at all). This makes Access singularly inappropriate to window handle-driven testing regimes.</p> <p>Indeed, I question why you want to do this kind of testing in Access. It sounds to me like your basic Extreme Programming dogma, and not all of the principles and practices of XP can be adapted to work with Access applications -- square peg, round hole.</p> <p>So, step back and ask yourself what you're trying to accomplish and consider that you may need to utilize completely different methods than those that are based on the approaches that just can't work in Access.</p> <p>Or whether that kind of automated testing is valid at all or even useful with an Access application.</p>
6,962
<p>The extruder on my Prusa i3 MK3S keeps clogging while printing. Loading is fine, and each time it clogs, unloading and loading the filament seems to work. The filament extruded just after resolving a clog looks like it has small bubbled on it.</p> <p>The problem only seems to happen when printing certain models. Printing the Batman symbol at 0.15&nbsp;mm works every time. But the model I'm trying to print always fails at most a few minutes in.</p> <p>I've tried cleaning the nozzle. Cold pull twice, and taken it out and heated it with my airgun and trying to work on it with the acupuncture needle.</p> <p>The print that fails is <a href="https://www.thingiverse.com/thing:3211975" rel="nofollow noreferrer">this "Small Pill Container"</a> with 0.1&nbsp;mm layer height and 100&nbsp;% infill, but printing a simple cylinder shape (25&nbsp;mm outer diameter, 2.5&nbsp;mm walls) creates the same problem. Trying to print them both at the same slicer settings with 0.15 mm layer height still fails.</p> <p>The model was sliced using the newest version of PrusaSlicer 2.1.0 and printed with Prusament PLA at the factory recommended 215±10&nbsp;&deg;C, and tried 220&nbsp;&deg;C.</p> <p>Any ideas what could be happening? Anybody experienced a similar issue?</p> <p>Printing the bundled TreeFrog 50&nbsp;&mu;m sliced by Prusa for the Prusa I3 MK3S cased the same problem. Jam happened about 30 min in. I guess this rules out slicer problems as the root cause.</p> <hr> <p><em>After a lot of research, it seems a lot of people have problems with the MK3 clogging, especially with PLA, and especially with prints with a lot of retractions. The issue seems to be the design of the heat-break, which has a throat between 2.2&nbsp;mm and 2&nbsp;mm, where the PLA can get stuck. I've ordered a new heatbreak. Please read <a href="/a/11409">this answer of my findings</a>.</em></p>
<p>My problem was 2 things. The <strong>heatbreak</strong>, which was switched out for the MK2 version(Explantation below). And the <strong>Teflon Tube</strong> that runs down the heatsink.</p> <h2>Heatbreak</h2> <p>Change the heat-break to a generic E3D one. You can order the heatbreak for the <strong>MK2</strong> from prusa, or any generic heat break for the E3D hot-end assembly.</p> <p>On the Prusa i3 MK3(s), this component has been given a 45° taper in the middle, between 2.2 and 2&nbsp;mm. This is done to ease filament retraction for the MMU, and will be nothing but problematic if you are not using the multi-material upgrade. Especially with higher nozzle pressures(eq. with lower layer lines), the filament may be squeezed into this taper, clogging the hot-end.</p> <p>You may not experience full clogs, but partial ones that will show themselves as streaks in certain layers on the print.</p> <h2>Heatsink Teflon Tube</h2> <p>There is a teflon tube that runs down the heatsink. It's crucial that this is mounted correctly and it is not entirely intuative how.</p> <p>First, press the teflon tube into the heatsink all the way to the bottom. Then, try to pull it out slightly. You'll notice that the small plastic ring at the top of the heatsink will pull out slightly along with it. Now, hold this black plastic part at it's current position with your fingernail, and push the teflon tube in the extra amount. When done, there should be no play in the tube.</p>
<p>The problem with low layer heights is that the filament flow is low, this means that the filament is at prolonged times at temperature, filament cooking can cause clogging. Try increasing the layer height to 0.2&nbsp;mm to observe if the same clogging problems still occur, furthermore, try lowering the extrusion temperature.</p> <p>Also, heat creep is a known issue (insufficient cooling of the cold end) to cause clogging. Note that this is unlikely on the Prusa MK3S, but you could check whether the fan rotates freely and that there are no additional obstructions in the flow path. </p> <p>It could be that a combination of too much hotend temperature and a low filament flow is causing this issue.</p>
1,511
<p>When I log into a remote machine using ssh X11 forwarding, Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it?</p> <hr> <p>Specifically, the message reads:</p> <pre><code>sh.exe has stopped working </code></pre> <p>So it's not ssh itself that died, but some sub-process.</p> <p>The problem details textbox reads:</p> <pre><code>Problem signature: Problem Event Name: APPCRASH Application Name: sh.exe Application Version: 0.0.0.0 Application Timestamp: 48a031a1 Fault Module Name: comctl32.dll_unloaded Fault Module Version: 0.0.0.0 Fault Module Timestamp: 4549bcb0 Exception Code: c0000005 Exception Offset: 73dc5b17 OS Version: 6.0.6000.2.0.0.768.3 Locale ID: 1033 Additional Information 1: fc4d Additional Information 2: d203a7335117760e7b4d2cf9dc2925f9 Additional Information 3: 1bc1 Additional Information 4: 7bc0b00964c4a1bd48f87b2415df3372 Read our privacy statement: http://go.microsoft.com/fwlink/?linkid=50163&amp;clcid=0x0409 </code></pre> <p>I notice the problem occurs when I use the <strong>-Y</strong> option to enable X11 forwarding in an X terminal under Vista.</p> <p>The dialog box that pops up doesn't automatically gain focus, so pressing Enter serves no purpose. I have to wait for the box to appear, grab it with the mouse, and dismiss it. Even forcing the error to receive focus would be a step in the right direction.</p> <hr> <p>Per DrPizza I have sent an <a href="http://cygwin.com/ml/cygwin/2008-08/msg00880.html" rel="nofollow noreferrer">email</a> to the Cygwin mailing list. The trimmed down subject line represents my repeated attempts to bypass an over-aggressive spam filter and highlights the need for something like StackOverflow.</p>
<p>The problem is, the process didn't just die, it died unexpectedly. Sounds like there's a bug in your SSH client that Vista is pointing out.</p>
<p>I know this is going to be heresy for a cygwin user, but you could just use <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/" rel="nofollow noreferrer">PuTTY</a> instead.</p>
5,576
<p>In our project, <a href="http://sharpwired.sourceforge.net/" rel="nofollow noreferrer">SharpWired</a>, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not.</p> <p>The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list.</p> <p>We've tried using a <code>FlowLayoutPanel</code> but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left &amp; Right. We've also thought about using a <code>TableLayoutPanel</code> but found adding rows dynamically to be a too big overhead so far.</p> <p>This must be quite a common use case, and it seems a bit weird to me that the <code>FlowLayoutPanel</code> has no intuitive way of doing this. <em>Has anyone done something similar or have tips or tricks to get us under way?</em></p> <p>Cheers!<br> /Adam</p>
<p>If you don't want to use databinding (via the <code>DataRepeater</code> control, as mentioned above), you could use a regular <code>Panel</code> control and set its <code>AutoScroll</code> property to true (to enable scrollbars).</p> <p>Then, you could manually add your custom controls, and set the <code>Dock</code> property of each one to <code>Top</code>.</p>
<p>.NET 3.5 SP1 introduced a <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.datarepeater.aspx" rel="nofollow noreferrer">DataRepeater</a> Windows Forms control which sounds like it'd do what you want. Bind it to the list of "downloads" (or whatever your list represents) and customize each item panel to include the controls you need. </p>
4,732
<p>We have got a custom <code>MembershipProvider</code> in <code>ASP.NET</code>. Now there are 2 possible scenario the user can be validated:</p> <ol> <li><p>User login via <code>login.aspx</code> page by entering his username/password. I have used <strong>Login control</strong> and linked it with the <code>MyMembershipProvider</code>. This is working perfectly fine.</p></li> <li><p>An authentication token is passed via some URL in query string form a different web sites. For this I have one overload in <code>MembershipProvider.Validate(string authenticationToken)</code>, which is actually validating the user. In this case we cannot use the <strong>Login control</strong>. Now how can I use the same <code>MembershipProvider</code> to validate the user without actually using the <strong>Login control</strong>? I tried to call <code>Validate</code> manually, but this is not signing the user in.</p></li> </ol> <p>Here is the code snippet I am using </p> <pre><code>if (!string.IsNullOrEmpty(Request.QueryString["authenticationToken"])) { string ticket = Request.QueryString["authenticationToken"]; MyMembershipProvider provider = Membership.Provider as MyMembershipProvider; if (provider != null) { if (provider.ValidateUser(ticket)) // Login Success else // Login Fail } } </code></pre>
<p>After validation is successful, you need to sign in the user, by calling FormsAuthentication.Authenticate: <a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.authenticate.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.authenticate.aspx</a></p> <p>EDIT: It is FormsAuthentication.SetAuthCookie: <a href="http://msdn.microsoft.com/en-us/library/twk5762b.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/twk5762b.aspx</a></p> <p>Also, to redirect the user back where he wanted to go, call: FormsAuthentication.RedirectFromLoginPage: <a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.redirectfromloginpage.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.redirectfromloginpage.aspx</a> </p> <p><a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.authenticate.aspx" rel="nofollow noreferrer">link text</a></p>
<p>You are right in the case of storing the auth information as a cookie directly. But using a strong hash function (e.g. MD5 + SHA1) is great and secure. By the way, if you use sessions (which is also just a hash cookie) you could attach auth information to it.</p>
6,300
<p>I have an Ender 3 which I primarily use for printing with PLA. I haven't branched out to other materials yet. :)</p> <p>I've done <a href="https://3dprinthq.com/desktop-3d-printer-safety/" rel="noreferrer">some research into PLA fumes and airborne particulates</a> which seemed to mention that PLA is mostly safe, but ABS is rather dangerous to print without proper ventilation. However, I understand that there isn't much research on the topic and that there haven't been many studies.</p> <p>I have been keeping my printer in my bedroom, far isolated from flammable materials, which I sometimes leave on to print while I'm asleep. Should I be concerned with my health safety with respect to airborne particulates emitted by printing with PLA?</p> <p><strong>Other questions ask about ABS, but here, I'm asking specifically about PLA.</strong></p>
<p>Fire is the most obvious risk - firmware can now detect some of the more obvious failure modes such as a detached thermistor, but loose or failing connections can still overheat. A smoke alarm is a fairly obvious (but not necessarily effective) protective measure.</p> <p>The risk from particulates in particular is <em>probably</em> low, but marginal health risks like this are extremely hard to analyse, and will likely take many years to manifest. The closest analogue would be to look at commercial plastics workers since they are exposed to both heated plastic, and any potential dust generated.</p> <p>You could also compare the risk to other 'hobby' activities such as soldering, painting, woodworking.</p>
<p>Standard manufacturing practices contraindicate leaving a manufacturing device unmonitored while it's on. That being said, your workshop should be well ventilated anyways since you're probably using acetone, isopropyl alcohol, and other substances that you shouldn't inhale.</p> <p>If you can not move to a well ventilated workshop, consider installing a fume hood or at least a range hood in your current workshop</p>
1,009
<p>I am trying to make SVG XML documents with a mixture of lines and brief text snippets (two or three words typically). The major problem I'm having is getting the text aligning with line segments.</p> <p>For horizontal alignment I can use <code>text-anchor</code> with <code>left</code>, <code>middle</code> or <code>right</code>. I can't find a equivalent for vertical alignment; <code>alignment-baseline</code> doesn't seem to do it, so at present I'm using <code>dy="0.5ex"</code> as a kludge for centre alignment.</p> <p>Is there a proper manner for aligning with the vertical centre or top of the text?</p>
<p>It turns out that you don't need explicit text paths. Firefox 3 has only partial support of the vertical alignment tags (<a href="http://groups.google.com/group/mozilla.dev.tech.svg/browse_thread/thread/1be0c56cfbfb3053?fwc=1" rel="noreferrer">see this thread</a>). It also seems that dominant-baseline only works when applied as a style whereas text-anchor can be part of the style or a tag attribute.</p> <pre><code>&lt;path d="M10, 20 L17, 20" style="fill:none; color:black; stroke:black; stroke-width:1.00"/&gt; &lt;text fill="black" font-family="sans-serif" font-size="16" x="27" y="20" style="dominant-baseline: central;"&gt; Vertical &lt;/text&gt; &lt;path d="M60, 40 L60, 47" style="fill:none; color:red; stroke:red; stroke-width:1.00"/&gt; &lt;text fill="red" font-family="sans-serif" font-size="16" x="60" y="70" style="text-anchor: middle;"&gt; Horizontal &lt;/text&gt; &lt;path d="M60, 90 L60, 97" style="fill:none; color:blue; stroke:blue; stroke-width:1.00"/&gt; &lt;text fill="blue" font-family="sans-serif" font-size="16" x="60" y="97" style="text-anchor: middle; dominant-baseline: hanging;"&gt; Bit of Both &lt;/text&gt; </code></pre> <p>This works in Firefox. Unfortunately Inkscape doesn't seem to handle dominant-baseline (or at least not in the same way).</p>
<p>This effect can indeed be achieved by setting <code>alignment-baseline</code> to <code>central</code> or <code>middle</code>.</p>
8,032
<p>How do I create a background process with Haskell on windows without a visible command window being created?</p> <p>I wrote a Haskell program that runs backup processes periodically but every time I run it, a command window opens up to the top of all the windows. I would like to get rid of this window. What is the simplest way to do this?</p>
<p>You should really tell us how you are trying to do this currently, but on my system (using linux) the following snippet will run a command without opening a new terminal window. It should work the same way on windows.</p> <pre><code>module Main where import System import System.Process import Control.Monad main :: IO () main = do putStrLn "Running command..." pid &lt;- runCommand "mplayer song.mp3" -- or whatever you want replicateM_ 10 $ putStrLn "Doing other stuff" waitForProcess pid &gt;&gt;= exitWith </code></pre>
<p>The simplest way I can think of is to run the rsync command from within a Windows Shell script (vbs or cmd).</p>
7,390
<p>I've been printing PLA on a Pegasus 12" for 2 years. Print quality has been great but in the last few months the quality of the prints has deteriorated. After looking into it, it seems when the head moves away from the spool and puts the filament in tension (and pulls on the spool) the extruder cog slips on the filament. That results in traces where no plastic gets extruded the furthest away the head moves from the spool (the spool is on the left in the picture below):</p> <p><a href="https://i.stack.imgur.com/0W9DA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0W9DA.jpg" alt="See diagonal traces where plastic didn&#39;t extrude"></a></p> <p>The cog slipping can be seen between 0:22 and 0:27 on the video below: the cog on the right spins continuously but the ball bearing on the left stops spinning for 5 seconds. <a href="https://photos.app.goo.gl/cTfySUgXDy1XKXGv8" rel="nofollow noreferrer">https://photos.app.goo.gl/cTfySUgXDy1XKXGv8</a></p> <p>The end result is a part with multiple gaps, especially on the side farthest away from the spool.</p> <p><a href="https://i.stack.imgur.com/lX4eJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lX4eJ.jpg" alt="enter image description here"></a></p> <p>I've cleaned the teeth of the cog (removed plastic dust) to improve traction but that didn't solve the problem. I've also tried to clean up the extruder by inserting a wire from the hot end side, no improvement in print quality.</p> <p>Any ideas on how to fix that slipping problem?</p> <h1><strong>Edit with solution:</strong></h1> <p>To complement Oscar's answer below, here is what I've done that fixed the problem: it turns out the issue was coming from a lack of friction on the filament. To increase the friction, I've slipped a pair of 0.25mm thick pieces of plastic sheet between the bearing axis and the mount. See pic below.</p> <p><a href="https://i.stack.imgur.com/CXw36.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CXw36.jpg" alt="enter image description here"></a></p> <p>That increased the force on the filament enough to fully solve the slippage problem. The print quality is perfect now (see pic below).</p> <p><a href="https://i.stack.imgur.com/KqbYo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KqbYo.jpg" alt="enter image description here"></a></p> <p>The plastic sheet trick is just a short term fix. I'm going to try swapping the drive gear for a slightly thicker one and contact MakerFarm to see if there is any long term modification they recommend.</p>
<p>The soldering in the Tevo components is very low quality as I replaced/resoldered most of the end-stops.</p> <p>As the gantry goes down - please ensure that the cable is not pulled over (no contact) and there is contact on the edge of the acrylic and the end-stop, also the small acrylic switch holder could bend/slip a bit. Finally, the sensor connection to the main board could be dragged by wires that are connected to the hot-end.</p> <p>To validate micro-switch behavior - lift the Z-axis (about 100mm), then set <code>home position</code> and manually trigger the end-stop switch. That shall lift the Z-axis, so then trigger again to see if that works. You will still have a plenty of time to stop the printer if the switch does not work.</p> <p>If that works, then the reason could be in slipping edge of the black acrylic plate and the micro-switch. Also validate the mechanical connection (if there is a loosening screw (the small on the switch plate)).</p>
<p>I'm not familiar with your particular model, so this may not be directly applicable.</p> <p>For many printer models, a swing thru thingiverse.com will find you a replacement z-stop switch mount that uses a threaded screw to set the z-height at which the microswitch fires. It may well be that you simply need to offset that height by a few mm to get your first layer to mate well with the print bed. </p> <p>Here are three examples, albeit for various models. <a href="https://www.thingiverse.com/thing:12488" rel="nofollow noreferrer">12488</a> , <a href="https://www.thingiverse.com/thing:1829747" rel="nofollow noreferrer">1829747</a> ,<br> <a href="https://www.thingiverse.com/thing:2856144" rel="nofollow noreferrer">2856144</a></p>
1,065
<p>I'd like to calculate the power lost through the filament being extruded (or in other words, at how many Watts I'd have to run an ideal heater that loses heat ONLY through filament so that it stays at constant temperature).</p> <ul> <li>Power is defined in Watts as <span class="math-container">$\text W =\frac{\text J}{\text s}$</span></li> <li><a href="https://en.wikipedia.org/wiki/Specific_heat_capacity" rel="nofollow noreferrer">Specific heat capacity</a> of a material is defined as <span class="math-container">$C =\frac{\text J}{ \text K \times\text{kg}}$</span></li> </ul> <p>When extrusion happens, the filament of higher temperature leaves the hotend while the same weight of filament of lower temperature enters the hotend.</p> <p>Let's say the specific heat capacity of the filament is <span class="math-container">$C$</span> and the extrusion rate <span class="math-container">$r$</span> is given with units kg/s. The temperatures are <span class="math-container">$T$</span>.</p> <p>Is it correct then to say that the power consumption of filament extrusion is <span class="math-container">$W = (c\times T_\text{Nozzle} - c\times T_\text{Environment}) \times r$</span></p> <p>meaning that if I would run a heater cartridge at exactly &quot;W&quot; watts and extrude filament with rate &quot;r&quot; and the block would not loose heat through any other means than through the filament extrusion, then the nozzle temperature would stay constant?</p>
<p>This is very simply stated, in fact the specific heat is a function of temperature and state of the material (liquid or solid). Also you need to consider which type of specific heat you use, e.g. the one for constant volume <span class="math-container">$C_V$</span> or for constant pressure <span class="math-container">$C_P$</span>. Constant pressure is probably preferred considering the mechanics of the printer (pressing filament into the nozzle-heatbreak assembly).</p> <p>A very interesting source of information is the <a href="https://polymerdatabase.com/polymer%20physics/HeatCapacity.html" rel="noreferrer">PolymerDatabase.com</a>.</p> <p>This source confirms that:</p> <blockquote> <p>In the case of polymers, we have to distinguish between the heat capacity of liquid, rubbery and glassy polymers. The heat capacity increases with increasing temperature, therefore, a liquid or rubbery polymer can hold more energy than a solid polymer. All materials show this increase in heat capacity with temperature.</p> </blockquote> <p>also:</p> <blockquote> <p>Specific heat capacities as a function of temperature have been published for only a limited number of polymers. In many cases, the heat capacity (at constant pressure) as a function of temperature can be approximated by straight lines.</p> </blockquote> <p>In such cases you can use the value of the specific heat at a predefined temperature (in thermodynamics that is frequently 298 K) to get approximations for your thermoplastic material. These formulae can then be used to integrate over the temperature rise.</p> <p>Please remember that a cartridge is of a certain value of Watt; to have a lower power, the cartridge modulates voltage to keep the heating block within a predefined temperature range.</p>
<h1>No.</h1> <p>Your formula is quite off, and it starts with the nomenclature:</p> <h2>Watt</h2> <p>Watt is the <strong>unit</strong> of <strong>energy transfer</strong> which equals <strong>power</strong>.</p> <p>The commonly used term &quot;wattage&quot; does not exist in science. It is a very despised shorthand <em>only</em> used in terms of <em>electric power</em> <span class="math-container">$P=UI$</span>.</p> <p>Both power <span class="math-container">$P$</span> (like work over time) and heat energy transfer <span class="math-container">$\Delta Q$</span> (which is one variant of power) use the unit <span class="math-container">$\text W=\frac {\text J} {\text s}$</span>, which is confusing but a necessary distinction. Always remember that <span class="math-container">$P_\text{total}=\sum_{i=1}^nP_i$</span> - the total power in and out of an object is the sum of all partial powers!</p> <h2>Heat Energy transfer</h2> <p>The Heat energy transfer through an object is defined as the <em>change</em> of the heat energy <span class="math-container">$Q$</span> stored inside an object. <span class="math-container">$Q$</span> is given in <span class="math-container">$\text J$</span>, so its change <span class="math-container">$\Delta Q$</span> is given in <span class="math-container">$\text J$</span> too. To get to the power, the energy change needs to be measured at several spots in time, so we make the derivate over time and get the power in <span class="math-container">$\text W$</span>. We're looking at <span class="math-container">$\dot Q=\frac {\delta Q} {\delta t}$</span>.</p> <p>The absolute change of heat energy of an item is defined as <span class="math-container">$\Delta Q(t)=m(t) c \Delta T$</span>: Increasing the temperature <span class="math-container">$T$</span> of an object with the mass <span class="math-container">$m$</span> and specific heat capacity <span class="math-container">$c$</span> by <span class="math-container">$\delta T$</span> (between times <span class="math-container">$t_0$</span> and <span class="math-container">$t$</span>) results in a change of the stored energy by <span class="math-container">$\Delta Q(t-t_0)$</span>.</p> <p>So, we know <span class="math-container">$Q=c m \Delta T$</span> and <span class="math-container">$P=\dot Q=\frac \delta {\delta t} c m \Delta T$</span></p> <h2>Problem in question</h2> <p>We know that the drain (<em>loss</em>) of thermal energy from the system is via three ways:</p> <ul> <li>melting plastic (phase transition)</li> <li>extruding heated plastic</li> <li>convective heat loss to the air</li> <li>black body radiation of the heater block</li> </ul> <p>We know that the total balance in equilibrium should be <span class="math-container">$P_\text{total}=P_\text{heating}+P_\text{melting}+P_\text{extrusion}+P_\text{convection}+P_\text{bb}=0$</span>.</p> <h2>heat deposited into the system</h2> <p>Let's start at the simplest: we simply know the nominal heating power of the cartridge, it is usually written upon the cartridge itself, usually something in the area of 20 to 40 W. In praxis, it is not exactly that, but the ballpark fits. Otherwise, we'd plug in <span class="math-container">$P_\text{heating}=\epsilon \frac {U^2} {R}$</span> for our specific resistor, where <span class="math-container">$\epsilon$</span> is a coefficient between 0 and 1 telling us how good it is in converting electric to heat energy. Remember that since <span class="math-container">$U$</span> is technically a function of time (it is modulated to control heating behavior), our heating power also is, even though not explicit!</p> <h2>black body radiation loss <span class="math-container">$P_\text{bb}$</span></h2> <p>Black body radiation: <span class="math-container">$P_\text{bb}=A \sigma T^4$</span> where <span class="math-container">$A$</span> is the surface area of the object, <span class="math-container">$\sigma$</span> is a constant called <a href="https://en.wikipedia.org/wiki/Stefan%E2%80%93Boltzmann_constant" rel="nofollow noreferrer">Stefan-Boltzmann Constant</a>. That much thermal energy is just lost due to radiation via photons, even if we don't see it glowing.</p> <h2>convection loss <span class="math-container">$P_\text{convection}$</span></h2> <p>The change of heat energy via heat convection is roughly defined as <span class="math-container">$H=\theta A (T-T_f)$</span> which brings us another coefficient <span class="math-container">$\theta$</span> about how good the block heats the air and the temperature of the medium (air) around <span class="math-container">$T_f$</span> - which we can replace as <span class="math-container">$(T-T_f)=\Delta T_a$</span>.</p> <p>And then we get to the biggest can of worms: the thermal heat transfer for melting the plastic and how much thermal energy is extruded from the system. For one of them, we can estimate some ballpark numbers, for the other, we will get into problems.</p> <h2>extrusion loss <span class="math-container">$P_\text{extrusion}$</span></h2> <p>The heat energy removed from the system by extruding plastic we can estimate from what we already established about thermal energy back in the Heat Energy transfer paragraph: <span class="math-container">$Q=mc(T_0+\Delta T)$</span> using the specific heat capacity <span class="math-container">$c [\frac {\text{J}}{\text kg K}] $</span> of the molten plastic as it is extruded (more about that later). But that's not the loss per time, but the heat energy stored in it in Joules. What factor is changing? In this case, it is the mass <span class="math-container">$m=r\times t$</span> where <span class="math-container">$r=\frac {\text kg} {\text s}$</span> is the extrusion rate. So <span class="math-container">$Q_\text{extrusion}=rtc\ \Delta T_\text{extrusion}$</span> and subsequently <span class="math-container">$P_\text{extrusion}=rc\ \Delta T_\text{extrusion}$</span></p> <p>This leaves us with the big problem: as <a href="https://3dprinting.stackexchange.com/a/10174/8884">0scar</a> correctly pointed out by directing to the <a href="https://polymerdatabase.com/polymer%20physics/HeatCapacity.html" rel="nofollow noreferrer">PolymerDatabase</a> the specific heat capacity is <em>not</em> a constant and <em>not</em> linear but changes depending on the aggregate of the substance. We can make some estimate about it though from how we formulated the total power and adding a few absolutes for convenience:</p> <p><span class="math-container">$$P_\text{total}=P_\text{heating}+P_\text{melting}+P_\text{extrusion}+H_\text{convection}+P_\text{bb}=0$$</span></p> <p><span class="math-container">$$P_\text{heating}-H_\text{convection}-P_\text{bb}-P_\text{extrusion}=P_\text{melting}$$</span></p> <p><span class="math-container">$$\epsilon \frac {U^2}{R}-\theta A \Delta T_a-A \sigma T^4-rc\ \Delta T_\text{extrusion}=P_\text{melting}$$</span></p> <p>Remember, that <span class="math-container">$U$</span> is a time-dependent factor (because of the control board activating it or disabling it), <span class="math-container">$T_f$</span> is <em>also</em> not a steady thing and changes depending on the airflow (though we can just pin it for our thought experiment) and thus <span class="math-container">$T$</span> itself might change over time as a result. <span class="math-container">$T$</span> is not equal to <span class="math-container">$\ \Delta T_\text{Extrusion}$</span> but is the temperature of the heater block system as a whole. <span class="math-container">$\ \Delta T_\text{Extrusion}$</span>, on the contrary, is the temperature increase <em>of the filament</em> and not necessarily the same <span class="math-container">$\Delta T_{air}$</span>, the differential between the heater block and the air. Why this differentiation is necessary becomes apparent if one realizes that the path of the filament might benefit from the heat that is <em>lost</em> from the heater block along that path, pre-heating the filament.</p> <h2>Phase Transition <span class="math-container">$P_\text{melting}$</span></h2> <p><sub><span class="math-container">$\propto$</span> is the proportionality sign and indicates that I might skip factors or constants.</sub></p> <p>What is that last part? That <span class="math-container">$P_\text{melting}$</span>? It is the power of the <a href="https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/Physical_Properties_of_Matter/States_of_Matter/Phase_Transitions/Fundamentals_of_Phase_Transitions" rel="nofollow noreferrer">Phase Transition</a>. <a href="https://en.wikipedia.org/wiki/Enthalpy_of_fusion" rel="nofollow noreferrer">Matter does <em>not</em> shift between phases <em>freely</em></a>. There is energy stored in the state itself! So when transitioning from one phase to the other, that energy either has to be added (when going from solid to liquid or liquid to gas) or removed (when going the other way).</p> <p>The &quot;heat of fusion&quot; is a material constant. For this look, I'll call it <span class="math-container">$\phi [\frac {\text{J}} {\text {g}}]$</span>. We can make an estimation for the power that is put into melting the filament: there's an amount of filament that gets an amount of heat and undergoes the phase transition per time increment <span class="math-container">$$P_\text{melting}\propto \frac \delta {\delta t}\phi m_\text{melting}=\phi*\dot m$$</span> Now, we have the product of specific &quot;latent heat&quot; and melting mass derived over time... We had earlier the flow rate of material <span class="math-container">$m=r\times t$</span> and the &quot;latent heat&quot; is a constant. So, we pull out <span class="math-container">$\dot m=r$</span> again. So in the end we get that the power that is needed to melt our filament is proportional to the flow of the material and the material constant. <span class="math-container">$$P_\text{melting}\propto \phi r$$</span></p> <h2>Conclusion tl;dr</h2> <p>When eliminating the loss via convection and black body radiation and assuming them 0 or neglectable, we assume our heater is packed in perfect isolation - and call them losses. Assuming <span class="math-container">$\epsilon=1$</span> for a perfect heater, we are left with this equilibrium situation:</p> <p><span class="math-container">$\frac {U^2}{R}-P_\text{losses}=P_\text{melting}+rc\ \Delta T_\text{extrusion}$</span></p> <p><strong>The sum of the power of the phase transition (melting of the filament) and the energy stored in the extruded filament per time <span class="math-container">$(\frac{dQ}{dt})$</span> is equal to the energy deposited into the hotend over time [minus losses over time]</strong></p>
1,339
<p>Is there any research into use of thermoelectric cooler along with part cooling fan to get quicker cooling without strong air currents that apply pressure to the still-soft material? I experimented with custom fan ducts in the past trying to get better cooling and avoid warping for printing thin layers of PLA at high speeds, but found that the concentrated stream of air blowing on the part actually deformed it before it could cool. At the time I wondered if using significantly colder air, at a much lower flow, would work better. But every time I've searched for thermoelectric (peltier) coolers with 3D printing, I've found results that are about cooling motors or the heatbreak (especially inside heated enclosures), nothing about part cooling.</p> <p>If there is no research on this and I want to experiment myself at some point, are there constraints I should consider for how to mount it (in my case on an Ender 3, but also in general)? Perhaps on a separate intake duct before the cooling fan? Or between the cooling fan and hotend assembly to let the waste heat dump into the assembly that the hotend fan is already cooling?</p>
<h1>On the printhead?</h1> <p>TECs or Peltier Elements are incredibly inefficient compared to airstream coolers. Their only benefit is perfect temperature control, from which you will have nothing because there is no firmware that cares for the temperature of cooling air or the cooling body of a Hotend. Also, a TEC creates a lot of heat on its output side - which means you heat the air just millimeters away from where you want to cool the air!</p> <p>To get the heat produced by the TEC away, you either need a rather large cooling body - which is a lot of weight and space you need. As a result, you reduce the maximum print speed a lot. A water cooler isn't necessarily that much lighter, but it also gets us the trouble of having a highly conductive liquid right on the printhead.</p> <h2>lighter alternative: compressed air</h2> <p>You'd have much better efficiency by having compressed air decompress (as in: get out of a slim nozzle) slowly just a few millimeters in front of the air intake of your part cooling fan - expanding air cools down a lot, and running a compressor for a few moments takes less energy than running a Peltier element with the same temperature drop. In a pinch, a CO2 canister could provide the needed high pressure air, and a nozzle like you have it on an airbrush would work.</p> <h1>Move it off the printhead?</h1> <p>As the weight of the necessary secondary equipment is an issue, it might be better to move the Peltier element off the printhead. For example, by using a flexible hose that supplies the air to the cooling fan, and feeding that with precooled air - and now a Peltier element can shine: by having the weight be no longer a matter, we can use a rather large cooling body on the outside and cooling fins on the inside.</p> <p><a href="https://i.stack.imgur.com/FPAzi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FPAzi.png" alt="Sample &quot;Intake&quot;" /></a></p>
<p>It is true that if you try to do bridges with a very hot filament the cooling air will deform or push away the hot filament if it's set at high speed, or it won't cool it enough if you run the fan slower.</p> <p>I experienced it with PETG at 245 °C while performing a parametric optimisation as described in:</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/4KAMFamy3zw?start=0"></iframe> </div></div></p> <p>Still, the TEC are inefficient and they require a bulky heatsink to cool the hot side. Not only that, you also need a heatsink with thin fins to cool the air, which cannot be too small too because the air is flowing relatively fast.</p> <p>Overall, it's clearly not practicable so I doubt you will find studies to confirm what is obvious.</p>
1,797
<p>I have a simple setter method for a property and <code>null</code> is not appropriate for this particular property. I have always been torn in this situation: should I throw an <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html" rel="noreferrer"><code>IllegalArgumentException</code></a>, or a <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html" rel="noreferrer"><code>NullPointerException</code></a>? From the javadocs, both seem appropriate. Is there some kind of an understood standard? Or is this just one of those things that you should do whatever you prefer and both are really correct?</p>
<p>It seems like an <code>IllegalArgumentException</code> is called for if you don't want <code>null</code> to be an allowed value, and the <code>NullPointerException</code> would be thrown if you were trying to <em>use</em> a variable that turns out to be <code>null</code>.</p>
<p>If you choose to throw a NPE and you are using the argument in your method, it might be redundant and expensive to explicitly check for a null. I think the VM already does that for you.</p>
2,593
<p>For a project I am working on in ruby I am overriding the method_missing method so that I can set variables using a method call like this, similar to setting variables in an ActiveRecord object:</p> <p><code>Object.variable_name= 'new value'</code> </p> <p>However, after implementing this I found out that many of the variable names have periods (.) in them. I have found this workaround:</p> <p><code>Object.send('variable.name=', 'new value')</code></p> <p>However, I am wondering is there a way to escape the period so that I can use</p> <p><code>Object.variable.name= 'new value'</code></p>
<p>Don't do it!</p> <p>Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros:</p> <pre><code>attr_writer :bar attr_reader :baz attr_accessor :foo </code></pre> <p>Okay, now that you have been warned, here's how to do it. Just return another instance of the same class every time you get a regular accessor, and collect the needed information as you go.</p> <pre><code>class SillySetter def initialize path=nil @path = path end def method_missing name,value=nil new_path = @path ? "#{@path}.#{name}" : name if name.to_s[-1] == ?= puts "setting #{new_path} #{value}" else return self.class.new(path=new_path) end end end s = SillySetter.new s.foo = 5 # -&gt; setting foo= 5 s.foo.bar.baz = 4 # -&gt; setting foo.bar.baz= 4 </code></pre> <p>I didn't want to encourage ruby sillyness, but I just couldn't help myself!</p>
<p>If there's no hope of changing the canonical names, you could alias the getters and setters manually:</p> <pre><code>def variable_name send 'variable.name' end def variable_name=(value) send 'variable.name=', value end </code></pre>
7,173
<p>Is there any simple way of creating tappered thread in OpenSCAD? I need something like 10 mm in diameter at the end, 9 at the top and the height of 10 mm.</p>
<p>I mostly use a tooth brush for that kind of problem</p>
<p>If you are able to remove the gear, as I suspect you can, a useful tool is the file card. It resembles a flat hair brush but the bristles are short wire, very stiff. In traditional use, it removes metal shavings from conventional metal files. It will easily remove plastic from between the gear teeth. If you are unable to remove the gear, but can access a portion of the exposed teeth, a suitably named dental pick can remove slowly the clogged material.</p> <p>Cooking the gear may not cause a fire, but could carbonize the plastic onto the teeth, perhaps creating a greater problem.</p>
323
<p>I'm getting weak prints on Ender 3 Pro with Cura after Cura upgrade.</p> <p>Prints on my Ender 3 Pro have been good until I was forced to update Cura due to having to update the OS on my laptop. Now my prints are weak even after using Infill 50 % from 20 %.</p> <p>Upgraded to Cura 4.8.0.</p> <p>I noticed that it seems my print settings were saved from the older non-working Cura version. I went ahead and printed an XYZ Cube with the same settings from my older Cura version where prints were printing fine/acceptable. It fell apart as I tried to lift it off the build plate so I printed a second XYZ Cube with 50 % infill from previous 20 % pictured below:</p> <p><a href="https://i.stack.imgur.com/2hnqO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2hnqO.jpg" alt="enter image description here" /></a></p> <p>The above print is noticeably weak, with layers not bonding or maybe something else.</p> <p>Below is an image of when an XYZ Cube printed with my older Cura version. It is not perfect but it is much stronger without visible separation and actually noticeably heavier than the grey XYZ Cube printed with Cura 4.8.0 :</p> <p><a href="https://i.stack.imgur.com/Z0Mon.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z0Mon.jpg" alt="enter image description here" /></a></p> <p>The green and the grey 1.75 mm PLA I use and shown in the photos are different brands but both printed very much the same with the older Cura version.</p> <p>I'm thinking this is an issue with the new Cura 4.8.0 that I'm using as nothing about my printing has changed besides the new Cura version assuming that my original print settings were saved which it looks to me that they were.</p> <p>Has anyone had a similar issue or is there a known fix for this?</p> <hr /> <p><em>Posting settings pics below:</em></p> <p><a href="https://i.stack.imgur.com/wkGz5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wkGz5.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/lnXOD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lnXOD.png" alt="enter image description here" /></a></p> <p>12/28/20 : Went to <a href="https://www.chepclub.com/cura-profiles.html" rel="nofollow noreferrer">https://www.chepclub.com/cura-profiles.html</a> and noted that they mention to use the Cura 4.8.0 Built-In profiles. Below are two pics of test print while using Cura 4.8.0's Built-In Standard Profile :</p> <p><a href="https://i.stack.imgur.com/e2Dd0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e2Dd0.jpg" alt="Cura 4.8.0 Standard Profile" /></a></p> <p><a href="https://i.stack.imgur.com/R0i8m.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R0i8m.jpg" alt="Cura 4.8.0 Standard Profile" /></a></p> <p>12/29/20 :</p> <p>Screenshot showing Nozzle Diameter (still using the 0.4 mm stock nozzle) &amp; Flow @ 100 %. Please let me know if these are not the correct settings you asked me to look in :</p> <p><a href="https://i.stack.imgur.com/cq4yH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cq4yH.png" alt="enter image description here" /></a></p>
<p>Total user error on my end. With the new version of this app somehow I did not catch that material selected on the UI dropdown was set to some custom material and not Generic PLA. Once I selected the proper material, all worked as expected.</p>
<p>There are three settings you will want to check in Cura to help with this.</p> <p><strong>Nozzle Diameter</strong></p> <p>Check your &quot;Nozzle Diameter&quot; if you've moved to a larger nozzle and haven't changed it in the new Cura version then it'll be under-extruding, or the default option may just be incorrect for you, most printers (Like the stock Ender 3 Pro) use a 0.4 mm nozzle.</p> <p><strong>Flow Rate</strong></p> <p>Flow rate usually requires a calibration test, however you should reference your old Cura profile for this, if in doubt, 100 %.</p> <p><strong>Filament Diameter</strong></p> <p>This needs to be set to 1.75 mm on almost every printer, which yours is.</p> <p>If you can't get it figured out with these, generate G-code With two versions of Cura side-by-side.</p>
1,808
<p>Here's a scenario I'm sure you're all familiar with. </p> <ol> <li><p>You have a fairly "hands off" customer, who really doesn't want to get too involved in the decision making despite your best efforts. </p></li> <li><p>An experienced development team spend hours discussing the pros and cons of a particular approach to a problem and come up with an elegant solution which avoids the pitfalls of the more obvious approaches. </p></li> <li><p>The customer casually mentions after a quick glance that they want it changed. They have no understanding of all the usability / consistency issues you were trying to avoid in your very carefully thought out approach. </p></li> <li><p>Despite explanations, customer isn't interested, they just want it changed. </p></li> <li><p>You sigh and do what they ask, knowing full well what will happen next...</p></li> <li><p>3 weeks later, customer says it isn't working well this way, could you change it? You suggest again your original solution, and they seize on it with enthusiasm. They invariably seem to have had a form of selective amnesia and blocked out their role in messing this up in the first place. </p></li> </ol> <p>I'm sure many of you have gone through this. The thing which gets me is always when we know the time and effort that reasonably bright and able people have put in to really understanding the problem and trying to come up with a good solution. The frustration comes in contrasting this with the knowledge that the customer's choice is made in 3 minutes in a casual glance (or worse, by their managers who often don't even know what the project is really about). The icing on the cake is that it's usually made very late in the day. </p> <p>I know that the agile methodologies are designed to solve exactly this kind of problem, but it requires a level of customer buy in that certain types of customers (people spending other peoples money usually) are just not willing to give. </p> <p>Anyone any clever insight into how you deal with this?</p> <p>EDIT: Oops - by the way, I'm not talking about any current or recent customer in this. It's purely hypothetical...</p>
<p>Make your customer pay by the effort you are putting into designing and developing the solution to their problem.</p> <p>The more you work, the more you get. The customer will have to pay for his mistakes.</p> <p>Customer will eventually learn to appreciate your experience and insight in the programming field.</p>
<p>Or else, <em>if they won't pay for the effort</em>, just avoid putting that much resources into the solution of the problem, and just give them exactly what they've asked for and then think about it after the three weeks have passed.</p> <p>Somewhat frustrating, yes, but that's the way it'll always be with that kind of customers. At least you won't be losing money.</p>
7,715
<p>How do I find the 'temp' directory in Linux? I am writing a platform neutral C++ function that returns the temp directory. In Mac and Windows, there is an API that returns these results. In Linux, I'm stumped. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>Check following variables:</p> <ul> <li>The environment variable <code>TMPDIR</code></li> <li>The value of the <a href="http://www.gnu.org/software/libc/manual/html_node/Temporary-Files.html#index-P_005ftmpdir-1608" rel="noreferrer"><code>P_tmpdir</code> macro</a></li> </ul> <p>If all fails try to use the directory <code>/tmp</code>.</p> <p>You can also use <code>tempnam</code> function to generate a unique temporary file name.</p>
<p>In standard c, you could try: P_tmpdir</p>
5,094
<p>I have the following html.erb code that I'm looking to move to Haml:</p> <pre><code>&lt;span class="&lt;%= item.dashboardstatus.cssclass %&gt;" &gt;&lt;%= item.dashboardstatus.status %&gt;&lt;/span&gt; </code></pre> <p>What it does is associate the CSS class of the currently assigned status to the span.</p> <p>How is this done in Haml? I'm sure I'm missing something really simple.</p>
<p>Not sure. Maybe:</p> <pre><code>%span{:class =&gt; item.dashboardstatus.cssclass }= item.dashboardstatus.status </code></pre>
<p>This worked.</p> <p>Where ever the link is to the page do something like this</p> <pre><code> %div{"data-turbolinks" =&gt; "false"} = link_to 'Send payment', new_payments_manager_path(sender_id: current_user.id, receiver_id: @collaboration.with(current_user).id, collaboration_id: params[:id]), class: 'button' </code></pre>
2,808
<p>I am trying to find a generic way of accessing a set of containers. I have a standard vector and list in addition to another custom list.</p> <p>The custom list defines an iterator;</p> <pre><code>class Iterator: public std::iterator&lt;std::forward_iterator_tag, T&gt; { // ... } Iterator begin() { return (Iterator(root)); } Iterator end() { return (Iterator(NULL)); } </code></pre> <p>with the appropriate operators overloaded. </p> <p>Ideally, I would like to do this;</p> <pre><code>class Foo { public: Foo() { std::list&lt;int&gt; x; std::vector&lt;int&gt; y; custom_list&lt;int&gt; z; iter = x.begin(); // OR iter = y.begin(); // OR iter = z.begin(); // ... }; private: std::iterator&lt;int&gt; iter; }; </code></pre> <p>But obviously these are all iterators of different types. I can assume all the containers are of the same type however.</p> <p>Is there an elegant way to solve this problem?</p>
<p>Here are some articles you might find of interest</p> <p><a href="http://accu.org/index.php/journals/479" rel="noreferrer">Giving STL Iterators a Base Class</a></p> <p><a href="http://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/start_page.html" rel="noreferrer">Type Erasure for C++ Iterators</a></p> <p><a href="http://stlab.adobe.com/classadobe_1_1any__iterator.html" rel="noreferrer">any_iterator Class Reference</a></p>
<p>Better late than never...</p> <p>The latest issue of <a href="http://accu.org/index.php/aboutus/aboutjournals" rel="nofollow noreferrer">C-Vu</a> turned up and guess what was in it: That's right, iterators that do <em>exactly</em> what you wanted.</p> <p>Unfortunately you need to become a member of the <a href="http://accu.org/" rel="nofollow noreferrer">ACCU</a> to view the magazine (the article references the Overload article from 2000 that David links to). But for a measly price a year you get a nice magazine to read, conferences and user groups. When you become a member you can view PDF's of the back issues so <a href="http://accu.org/index.php/joining" rel="nofollow noreferrer">what are you waiting for</a>?</p>
3,126
<p>I have created a template for Visual Studio 2008 and it currently shows up under File->New Project->Visual C#. However, it is only really specific to Visual C#/Windows but I can't work out how to get it to show up under the "Windows" category and not the more general "Visual C#".</p>
<p>Check out MSDN "<a href="http://msdn.microsoft.com/en-us/library/y3kkate1.aspx" rel="noreferrer">How to: Locate and Organize Project and Item Templates</a>"</p> <p>Create a folder within one of these</p> <pre><code>&lt;VisualStudioInstallDir&gt;\Common7\IDE\ItemTemplates\CSharp\ My Documents\Visual Studio 2008\Templates\ProjectTemplates\CSharp\ </code></pre>
<p>Categorization of templates depends on settings (for example, if you choose "C#" settings, all of a sudden all other languages move to an "other languages" tree).</p> <p>What folder is your template in?</p>
3,331
<p>The MediaElement doesn't support rounded corners (radiusx, radiusy). Should I use a VideoBrush on a Rectangle with rounded corners?</p>
<p>Yeah - In a way you're both asking and answering the question yourself... But that is one of the two options I can think of. The reasons that might be a problem is that you lose some of the features/control you get from the MediaElement control. Another option is to do this:</p> <ol> <li>Add your MediaElement to your page.</li> <li>Draw a Rectangle on top of it and set wanted corner radius</li> <li>Right click the rectangle in Blend and choose "Create Clipping Path"</li> <li>Apply the clipping path to your MediaElement</li> </ol> <p>That way you're still using a MediaElement control, but you can "clip" away what ever you want to get the desired rounded effect.</p> <p>This example shows a clipped MediaElement. I know it's not easy to picture the vector path, but if you open it open in Blend you will see a rounded MediaElement.</p> <pre><code>&lt;MediaElement Height="132" Width="176" Source="Egypt2007.wmv" Clip="M0.5,24.5 C0.5,11.245166 11.245166,0.5 24.5,0.5 L151.5,0.5 C164.75484,0.5 175.5,11.245166 175.5,24.5 L175.5,107.5 C175.5, 120.75484 164.75484,131.5 151.5,131.5 L24.5,131.5 C11.245166, 131.5 0.5,120.75484 0.5,107.5 z"/&gt; </code></pre>
<p>Using a rounded rectangle and a VideoBrush doesn't lose you any features/control over using a displayed MediaElement - since the element has to be in the Xaml anyway, you can control it using the usual Play/Pause/Stop methods, except that the playback happens in your rectangle. Using a clip region is a little unwieldy because it's harder to resize the region. A Rectangle is better because you have flexibility of layout.</p> <pre><code>&lt;MediaElement x:Name="myElement" Source="clip.wmv" Visibility="Collapsed"/&gt; &lt;Rectangle RadiusX="10" RadiusY="10" Width="640" Height="480"&gt; &lt;Rectangle.Fill&gt; &lt;VideoBrush Source="myElement" Stretch="Uniform"/&gt; &lt;/Rectangle.Fill&gt; &lt;Rectangle/&gt; </code></pre>
5,129
<p>First, I'm using Linux Mint 18.3 (Sylvia). Until now, I've been using OpenSCAD with the GUI and never experienced issues. Now I try to start OpenSCAD from the command line, but it always opens an empty file, even if a file with the specified name exists. </p> <p>Since I have a rather big script, I'd like to generate the STL's via the CLI. Due to this error, I can not even do any tests for parameter passing.</p> <p>What I'd like to do is to issue a command (flom the command line or in a shell script) that says "Set objectID to 1, render and export the result to stl".</p> <p>Here is my M(N)WE:</p> <pre><code>// test.scad objectID = 2; if (objectID == 1) difference(){ cylinder(d=20, h=50, center=true); cylinder(d=16, h=50.2, center=true); } else if (objectID == 2) difference(){ cube(50, center=true); cube([35,35,70], center=true); } </code></pre> <p>Any help will greatly be appreciated.</p>
<p>I could finally solve the issue. Calling <code>openscad</code> from command line with parameters does NOT work with the AppImage I used. It works fine with a "standard" installation, though.</p> <p>Thanks for your support.</p>
<p>You can specify variable values from command line using:</p> <pre> openscad ...\ ... \ [ -D var=val [..] ] \ ... \ ... \ filename </pre> <p>See the <a href="https://en.m.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment" rel="nofollow noreferrer">OpenSCAD Manual</a>.</p>
1,227
<p>I am debugging my ASP.NET application on my Windows XP box with a virtual directory set up in IIS (5.1).</p> <p>I am also running <strong>VirtualPC</strong> with XP and IE6 for testing purposes. When I connect to my real machine from the virtual machine, I enter the URL: <a href="http://machinename/projectname" rel="nofollow noreferrer">http://machinename/projectname</a>.</p> <p>I get a security popup to connect to my machine (which I expect), but the User name field is disabled. I cannot change it from machinename\Guest to machinename\username in order to connect.</p> <p>How do I get this to enable so I can enter the correct credentials.</p>
<p>Consider:</p> <pre><code>-maxdepth n True if the depth of the current file into the tree is less than or equal to n. -mindepth n True if the depth of the current file into the tree is greater than or equal to n. </code></pre>
<p>Use the <strong>-prune</strong> option.</p>
4,674
<p>I would like to know how people implement the following data structures in C# without using the base class library implementations:-</p> <ul> <li>Linked List</li> <li>Hash Table</li> <li>Binary Search Tree</li> <li>Red-Black Tree</li> <li>B-Tree</li> <li>Binomial Heap</li> <li>Fibonacci Heap</li> </ul> <p>and any other fundamental data structures people can think of!</p> <p>I am curious as I want to improve my understanding of these data structures and it'd be nice to see C# versions rather than the typical C examples out there on the internet!</p>
<p>There's a series of <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336800.aspx" rel="nofollow noreferrer">MSDN articles</a> on this subject. However, I haven't really read the text myself. I believe that the collections framework by .NET has a broken interface and cannot be extended very well.</p> <p>There's also <a href="http://www.itu.dk/research/c5/" rel="nofollow noreferrer">C5</a>, a libray that I am investigating right now.</p> <p>For the reason mentioned above, I've had the project to implement my own collections library for .NET but I've stopped this project after the first benchmark revealed that even a straightforward, non-thread-safe generic <code>Vector</code> implementation is slower than the native <code>List&lt;T&gt;</code>. Since I've taken care not to produce any inefficient IL code, this means that .NET is simply not suited (yet) for writing on-par replacements for intrinsic data structures, and that the .NET framework has to use some behind-the-scenes knowledge to optimize the builtin collection classes.</p>
<p>Check out <a href="https://github.com/SSCLI" rel="nofollow noreferrer">Rotor 2</a> or use <a href="https://www.red-gate.com/products/dotnet-development/reflector/" rel="nofollow noreferrer">reflector</a> too see how Microsoft did it!!!</p> <p>also you can check <a href="https://referencesource.microsoft.com/#mscorlib/system/collections/generic/list.cs" rel="nofollow noreferrer">Microsoft reference source</a></p>
7,072
<p>I'd like to experiment with burn-down and planning game with the team I'm on. People on my team are interested in making it happen, however I'm sure someone has done this before and has learned some lessons we hopefully don't have to repeat. Does anyone know of an example Excel (or other tool) template available for burn-down or planning game activities?</p>
<p><a href="http://blogs.msdn.com/progressive_development/archive/2008/02/19/motley-says-what-are-we-burning-down-your-house-scrum-part-v.aspx" rel="nofollow noreferrer">This MSDN Blog article</a> Has quite a good review of using burndowns in combination with Cumulative Flow Diagrams which fleshes out the diagrams even more. In the resources links at the bottom of the article there is a <a href="http://go.microsoft.com/fwlink/?LinkId=98602&amp;clcid=0x409" rel="nofollow noreferrer">link to the Microsoft Scrum kit</a> which has a pre-built excel file.</p>
<p>yes I answered this somewhere else but we use tools just to generate burndown charts. Like this one: <a href="http://www.burndown-charts.com" rel="nofollow">http://www.burndown-charts.com</a> </p> <p>For the rest, a real board, some post-its and good will do wonders.</p> <p>And for that tool they also <a href="http://www.burndown-charts.com/teams/dreamteam" rel="nofollow">manage teams</a> and allow readonly view of the chart so you can show it to your manager:D .</p>
9,333
<p>I'm using an XmlSerializer to deserialize a particular type in mscorelib.dll</p> <pre><code>XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) ); return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) ); </code></pre> <p>This throws a caught <code>FileNotFoundException</code> when the assembly is loaded:</p> <blockquote> <p>"Could not load file or assembly 'mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."</p> </blockquote> <p>FusionLog:</p> <pre><code>=== Pre-bind state information === LOG: User = ### LOG: DisplayName = mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86 (Fully-specified) LOG: Appbase = file:///C:/localdir LOG: Initial PrivatePath = NULL Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\localdir\bin\Debug\appname.vshost.exe.Config LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Post-policy reference: mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86 LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers/mscorlib.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers.EXE. LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers/mscorlib.XmlSerializers.EXE. </code></pre> <p>As far as I know there is no mscorlib.XmlSerializers.DLL, I think the DLL name has bee auto generated by .Net looking for the serializer. </p> <p>You have the option of creating a myApplication.XmlSerializers.DLL when compiling to optimise serializations, so I assume this is part of the framework's checking for it.</p> <p>The problem is that this appears to be causing a delay in loading the application - it seems to hang for a few seconds at this point.</p> <p>Any ideas how to avoid this or speed it up?</p>
<p>I'm guessing now. but:</p> <ol> <li>The system might be generating a serializer for the whole of mscorlib, which could be very slow.</li> <li>You could probably avoid this by wrapping the system type in your own type and serialising that instead - then you'd get a serializer for your own assembly.</li> <li>You might be able to build the serializer for mscorlib with sgen.exe, which was the old way of building serializer dlls before it got integrated into VS.</li> </ol>
<p>The delay is because, having been unable to find the custom serializer dll, the system is building the equivalent code (which is very time-consuming) on the fly.</p> <p>The way to avoid the delay is to have the system build the DLL, and make sure it's available to the .EXE - have you tried this?</p>
3,321
<p>So our SQL Server 2000 is giving me the error, "The log file for database is full. Back up the transaction log for the database to free up some log space."</p> <p>How do I go about fixing this without deleting the log like some other sites have mentioned?</p> <p>Additional Info: Enable AutoGrowth is enabled growing by 10% and is restricted to 40MB.</p>
<p>To just empty it:</p> <pre><code>backup log &lt;dbname&gt; with truncate_only </code></pre> <p>To save it somewhere:</p> <pre><code>backup log &lt;dbname&gt; to disk='c:\somefile.bak' </code></pre> <p>If you dont really need transactional history, try setting the database recovery mode to simple.</p>
<p>Rename it it. eg:<br> old-log-16-09-08.log</p> <p>Then the SQL server can use a new empty one.</p>
9,858
<p>I'm new to 3D printing, I have printed the cat that comes on the SD card on my Ender 3 and it's amazing the level of detail. After that, I tried to print another figure and I don't know what I'm doing wrong. I don't even know what to search for troubleshooting images because none of those seems similar to my problem.</p> <p>I used Ultimaker Cura to generate the G-code, it's the same filament, good (I think) bed leveling with 50 °C and nozzle at 200 °C. Is something wrong with the printer? Or is it the configuration of my G-code and what parameters do I need to check?</p> <p>The next images are:</p> <ol> <li>my first cat (nice print)</li> <li>what I want to print</li> <li>what I actually print</li> </ol> <p><a href="https://i.stack.imgur.com/yBTwS.jpg" rel="nofollow noreferrer" title="3D printed cat model from SD card"><img src="https://i.stack.imgur.com/yBTwS.jpg" alt="3D printed cat model from SD card" title="3D printed cat model from SD card" /></a></p> <p><a href="https://i.stack.imgur.com/qchXO.jpg" rel="nofollow noreferrer" title="3D rendering of a skeletal monster model"><img src="https://i.stack.imgur.com/qchXO.jpg" alt="3D rendering of a skeletal monster model" title="3D rendering of a skeletal monster model" /></a></p> <p><a href="https://i.stack.imgur.com/t12Ce.jpg" rel="nofollow noreferrer" title="Failed print of skeletal monster model"><img src="https://i.stack.imgur.com/t12Ce.jpg" alt="Failed print of skeletal monster model" title="Failed print of skeletal monster model" /></a></p>
<p>In principle you can re-extrude it with a somewhat simpler machine/setup than making filament from scratch, but controlling the diameter is the hard part of making filament - as you can see from how the manufacturer of yours botched it.</p> <p>I would first try insisting on a refund without returning the item unless they pay return shipping, and that they cover the original shipping cost. The product they delivered is not usable for the purpose it was advertised for.</p> <p>As for salvaging it - if that's what you really want to do, or if you end up stuck with it - as long as it's not too wide to fit through the filament path to the nozzle, an extruder that's spring loaded can <em>probably</em> manage to push it reliably. You will of course have pulsating under- and over-extrusion which will make it largely unusable for serious parts that need to be dimensionally accurate, strong, or visually appealing, but there are lots of things without these requirements it might be useful for. If your printer isn't capable of handling it, you could perhaps sell or trade it to someone whose printer can handle it.</p> <p>Getting more on the wild end of things, there are filament diameter sensors that can be integrated with your printer and firmware (I'm pretty sure Klipper supports this; not sure about Marlin and others) to measure the diameter and compensate extruder motor steps to keep the extruded volume per requested E-axis length constant. This would in theory make it possible to use the bad filament for serious prints.</p>
<p>Personally I store all my filament waste in tubs for the day a recycling/reuse solution offers itself. You can &quot;compact&quot; waste prints using hot air which also sticks the whispy pieces together. Someone will eventually come out with a &quot;re-extruder&quot; that simply cooks old filament and then produces a consistent 1.75mm or 3mm output. Cost is the limiting factor here, both in up-front equipment and ongoing electricity cost.</p> <p>Plain unused filament is specified as a pin for a hinge in some designs. However that doesn't use very much.</p> <p>It can also be used as string, but tends to break at the knot if tied tightly.</p> <p>Filament could be platted into a rope, but that's going to be more decorative than useful.</p> <p>Last thought, I've not tried it but filament has a low melting temperature compared to metals. You may be able to &quot;cast&quot; a 3D shape in a metal mold an a hot oven or with a gas torch or perhaps even in a fire. Fumes could be an issue, and you'd have to somehow stop the plastic from igniting.<br> I doubt it would be possible to cast a thin round cylinder; the top would be flat at best.</p> <hr /> <p>I happened to come across a &quot;spring mandrel&quot; at <a href="https://www.thingiverse.com/thing:92266" rel="nofollow noreferrer">https://www.thingiverse.com/thing:92266</a> <br> One could soften the poor filament and then wind it around a structure like that, and when cooled you have a low-pressure coil spring of a length and diameter you chose. Probably not that strong or robust, but worth a try if you need springs for other prints.</p>
2,137
<p>Can a Linq query retrieve BLOBs from a Sql Database?<br> And how do they come out?</p>
<p>LINQ-To-SQL classes create properties of type System.Data.Linq.Binary for all binary and varbinary fields in SQL-Server. The Binary type has a .ToArray() method that returns a byte[], and its constructor can take a byte[].</p> <p>Older versions of SQLMetal generated properties of type byte[], but the problem with these was that they failed in any joins. I think that's the main reason they replaced it with the IEquatable Binary type.</p>
<p>If I'm not mistaken LINQ to SQL teats BLOB as System.Byte[]<br> I recall that there was some problem with SqlMetal, it generated wrong type for BLOB, but MSVS dmbl designer should work.</p>
7,746
<p>I notice that StackOverflow has a views count for each question and that these view numbers are fairly low and accurate. </p> <p>I have a similar thing on one of my sites. It basically logs a "hit" whenever the page is loaded in the backend code. Unfortunately it also does this for search engine hits giving bloated and inaccurate numbers.</p> <p>I guess one way to not count a robot would be to do the view counting with an AJAX call once the page has loaded, but I'm sure there's other, better ways to ignore search engines in your hit counters whilst still letting them in to crawl your site. Do you know any?</p>
<p>An AJAX call will do it, but usually search engines will not load images, javascript or CSS files, so it may be easier to include one of those files in the page, and pass the URL of the page you want to log a request against as a parameter in the file request.</p> <p>For example, in the page...</p> <p><a href="http://www.example.com/example.html" rel="noreferrer">http://www.example.com/example.html</a></p> <p>You might include in the head section</p> <pre><code>&lt;link href="empty.css?log=example.html" rel="stylesheet" type="text/css" /&gt; </code></pre> <p>And have your server side log the request, then return an empty css file. The same approach would apply to JavaScript or and image file, though in all cases you'll want to look carefully at what caching might take place.</p> <p>Another option would be to eliminate the search engines based on their <a href="http://en.wikipedia.org/wiki/User_agent" rel="noreferrer">user agent</a>. There's a big list of possible user agents at <a href="http://user-agents.org/" rel="noreferrer">http://user-agents.org/</a> to get you started. Of course, you could go the other way, and only count requests from things you know are web browsers (covering IE, Firefox, Safari, Opera and this newfangled Chrome thing would get you 99% of the way there).</p> <p>Even easier would be to use a log analytics tool like <a href="http://awstats.sourceforge.net/" rel="noreferrer">awstats</a> or a service like <a href="http://www.google.com/analytics/" rel="noreferrer">Google analytics</a>, both of which have already solved this problem.</p>
<p>The reason Stack Overflow has accurate view counts is that it only count each view/user once.</p> <p>Third-party hit counter (and web statistics) application often filter out search engines and display them in a separate window/tab/section. </p>
6,783
<p>I'm sure this has already been asked and answered so I apologize in advance for that but I'm not figuring out the correct keywords to search for. Searching for "Pattern" hits way too many Q &amp; A's to be useful.</p> <p>I'm working on a regression testing app. I'm displaying a form on the screen and according to which user is logged in to the app some of the fields should be read-only. So I can abstract a field object and I can abstract a user object but what pattern should I be looking at to describe the intersection of these two concepts? In other words how should I describe that for Field 1 and User A, the field should be read-only? It seems like read-only (or not) should be a property of the Field class but as I said, it depends on which user is looking at the form. I've considered a simple two-dimensional array (e. g. ReadOnly[Field,User] = True) but I want to make sure I've picked the most effective structure to represent this. </p> <p>Are there any software design patterns regarding this kind of data structure? Am I overcomplicating things--would a two-dimensional array be the best way to go here? As I said if this has been asked and answered, I do apologize. I did search here and didn't find anything and a Google search failed to turn up anything either. </p>
<p>Table driven designs can be effective. Steve Maguire had few nice examples in <em>Writing</em> <em>Solid</em> <em>Code</em> .</p> <p>They are also a great way to capture tests, see <a href="http://fit.c2.com/" rel="nofollow noreferrer">fit</a> .</p> <p>In your case something like:</p> <pre><code>Field1ReadonlyRules = { 'user class 1' : True, 'user class 2' : False } field1.readOnly = Field1ReadonlyRules[ someUser.userClass ] </code></pre> <p>As an aside you probably want to model <em>both</em> users and user classes/roles/groups instead of combining them. A user typically captures <em>who</em> (authentication) while groups/roles capture <em>what</em> (permissions, capabilities)</p>
<p>At first blush it sounds more like you have two different types of users and they have different access levels. This could be solved by inheritance (PowerUser, User) or by containing a security object or token that sets the level for the user. </p> <p>If you don't like inheritance as a rule, you could use a State pattern on the application, Decorate the user objects (Shudder) or possibly add strategy patterns for differing security levels. But I think it's a little early yet, I don't normally apply patterns until I have a firm idea of how the item will grown and be maintained.</p>
7,566
<p>At the beginning of all my executable Python scripts I put the <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)" rel="noreferrer">shebang</a> line:</p> <pre><code>#!/usr/bin/env python </code></pre> <p>I'm running these scripts on a system where <code>env python</code> yields a Python 2.2 environment. My scripts quickly fail because I have a manual check for a compatible Python version:</p> <pre><code>if sys.version_info &lt; (2, 4): raise ImportError("Cannot run with Python version &lt; 2.4") </code></pre> <p>I don't want to have to change the shebang line on every executable file, if it's possible; however, I don't have administrative access to the machine to change the result of <code>env python</code> and I don't want to force a particular version, as in:</p> <pre><code>#!/usr/bin/env python2.4 </code></pre> <p>I'd like to avoid this because system may have a newer version than Python 2.4, or may have Python 2.5 but no Python 2.4.</p> <p>What's the elegant solution?</p> <p>[Edit:] I wasn't specific enough in posing the question -- I'd like to let users execute the scripts without manual configuration (e.g. path alteration or symlinking in <code>~/bin</code> and ensuring your PATH has <code>~/bin</code> before the Python 2.2 path). Maybe some distribution utility is required to prevent the manual tweaks?</p>
<p>"env" simply executes the first thing it finds in the PATH env var. To switch to different python, prepend the directory for that python's executable to the path before invoking your script.</p>
<p>@morais: That's an interesting idea, but I think maybe we can take it one step farther. Maybe there's a way to use <a href="http://pypi.python.org/pypi/virtualenv" rel="nofollow noreferrer">Ian Bicking's virtualenv</a> to:</p> <ul> <li>See if we're running in an acceptable environment to begin with, and if so, do nothing.</li> <li>Check if there exists a version-specific executable on the <code>PATH</code>, i.e. check if <code>python2.x</code> exists <code>for x in reverse(range(4, 10))</code>. If so, re-run the command with the better interpreter.</li> <li>If no better interpreter exists, use virtualenv to try and install a newer version of Python from the older version of Python and get any prerequisite packages.</li> </ul> <p>I have no idea if virtualenv is capable of this, so I'll go mess around with it sometime soon. :)</p>
6,195
<p>I'm talking about an action game with no upper score limit and no way to verify the score on the server by replaying moves etc. </p> <p>What I really need is the strongest encryption possible in Flash/PHP, and a way to prevent people calling the PHP page other than through my Flash file. I have tried some simple methods in the past of making multiple calls for a single score and completing a checksum / fibonacci sequence etc, and also obfuscating the SWF with Amayeta SWF Encrypt, but they were all hacked eventually.</p> <p>Thanks to StackOverflow responses I have now found some more info from Adobe - <a href="http://www.adobe.com/devnet/flashplayer/articles/secure_swf_apps_12.html" rel="noreferrer">http://www.adobe.com/devnet/flashplayer/articles/secure_swf_apps_12.html</a> and <a href="https://github.com/mikechambers/as3corelib" rel="noreferrer">https://github.com/mikechambers/as3corelib</a> - which I think I can use for the encryption. Not sure this will get me around CheatEngine though.</p> <p>I need to know the best solutions for both AS2 and AS3, if they are different.</p> <p>The main problems seem to be things like TamperData and LiveHTTP headers, but I understand there are more advanced hacking tools as well - like CheatEngine (thanks Mark Webster)</p>
<p>This is a classic problem with Internet games and contests. Your Flash code works with users to decide a score for a game. But users aren't trusted, and the Flash code runs on the user's computer. You're SOL. There is nothing you can do to prevent an attacker from forging high scores:</p> <ul> <li><p>Flash is even easier to reverse engineer than you might think it is, since the bytecodes are well documented and describe a high-level language (Actionscript) --- when you publish a Flash game, you're publishing your source code, whether you know it or not.</p></li> <li><p>Attackers control the runtime memory of the Flash interpreter, so that anyone who knows how to use a programmable debugger can alter any variable (including the current score) at any time, or alter the program itself.</p></li> </ul> <p>The simplest possible attack against your system is to run the HTTP traffic for the game through a proxy, catch the high-score save, and replay it with a higher score.</p> <p>You can try to block this attack by binding each high score save to a single instance of the game, for instance by sending an encrypted token to the client at game startup, which might look like:</p> <pre><code>hex-encoding( AES(secret-key-stored-only-on-server, timestamp, user-id, random-number)) </code></pre> <p>(You could also use a session cookie to the same effect).</p> <p>The game code echoes this token back to the server with the high-score save. But an attacker can still just launch the game again, get a token, and then immediately paste that token into a replayed high-score save. </p> <p>So next you feed not only a token or session cookie, but also a high-score-encrypting session key. This will be a 128 bit AES key, itself encrypted with a key hardcoded into the Flash game:</p> <pre><code>hex-encoding( AES(key-hardcoded-in-flash-game, random-128-bit-key)) </code></pre> <p>Now before the game posts the high score, it decrypts the high-score-encrypting-session key, which it can do because you hardcoded the high-score-encrypting-session-key-decrypting-key into the Flash binary. You encrypt the high score with this decrypted key, along with the SHA1 hash of the high score:</p> <pre><code>hex-encoding( AES(random-128-bit-key-from-above, high-score, SHA1(high-score))) </code></pre> <p>The PHP code on the server checks the token to make sure the request came from a valid game instance, then decrypts the encrypted high score, checking to make sure the high-score matches the SHA1 of the high-score (if you skip this step, decryption will simply produce random, likely very high, high scores). </p> <p>So now the attacker decompiles your Flash code and quickly finds the AES code, which sticks out like a sore thumb, although even if it didn't it'd be tracked down in 15 minutes with a memory search and a tracer ("I know my score for this game is 666, so let's find 666 in memory, then catch any operation that touches that value --- oh look, the high score encryption code!"). With the session key, the attacker doesn't even have to run the Flash code; she grabs a game launch token and a session key and can send back an arbitrary high score.</p> <p>You're now at the point where most developers just give up --- give or take a couple months of messing with attackers by:</p> <ul> <li><p>Scrambling the AES keys with XOR operations</p></li> <li><p>Replacing key byte arrays with functions that calculate the key</p></li> <li><p>Scattering fake key encryptions and high score postings throughout the binary.</p></li> </ul> <p>This is all mostly a waste of time. It goes without saying, SSL isn't going to help you either; SSL can't protect you when one of the two SSL endpoints is evil.</p> <p>Here are some things that can actually reduce high score fraud:</p> <ul> <li><p>Require a login to play the game, have the login produce a session cookie, and don't allow multiple outstanding game launches on the same session, or multiple concurrent sessions for the same user.</p></li> <li><p>Reject high scores from game sessions that last less than the shortest real games ever played (for a more sophisticated approach, try "quarantining" high scores for game sessions that last less than 2 standard deviations below the mean game duration). Make sure you're tracking game durations serverside.</p></li> <li><p>Reject or quarantine high scores from logins that have only played the game once or twice, so that attackers have to produce a "paper trail" of reasonable looking game play for each login they create.</p></li> <li><p>"Heartbeat" scores during game play, so that your server sees the score growth over the lifetime of one game play. Reject high scores that don't follow reasonable score curves (for instance, jumping from 0 to 999999). </p></li> <li><p>"Snapshot" game state during game play (for instance, amount of ammunition, position in the level, etc), which you can later reconcile against recorded interim scores. You don't even have to have a way to detect anomalies in this data to start with; you just have to collect it, and then you can go back and analyze it if things look fishy.</p></li> <li><p>Disable the account of any user who fails one of your security checks (for instance, by ever submitting an encrypted high score that fails validation). </p></li> </ul> <p>Remember though that you're only deterring high score fraud here. There's <em>nothing</em> you can do to prevent if. If there's money on the line in your game, someone is going to defeat any system you come up with. The objective isn't to <em>stop</em> this attack; it's to make the attack more expensive than just getting really good at the game and beating it.</p>
<p>Whenever your highscore system is based on the fact that the Flash application sends unencrpyted/unsigned highscore data via the network, that can be intercepted and manipulated/replayed. The answer follows from that: encrypt (decently!) or cryptographically sign highscore data. This, at least, makes it harder for people to crack your highscore system because they'll need to extract the secret key from your SWF file. Many people will probably give up right there. On the other hand, all it takes is a singly person to extract the key and post it somewhere.</p> <p>Real solutions involve more communication between the Flash application and the highscore database so that the latter can verify that a given score is somewhat realistic. This is probably complicated depending on what kind of game you've got.</p>
9,965
<p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p> <p>This is similar to what I'm actually doing:</p> <pre><code>import xml.etree.ElementTree as ET root = ET.Element('html') head = ET.SubElement(root,'head') script = ET.SubElement(head,'script') script.set('type','text/javascript') script.text = "var a = 'I love &amp;aacute; letters'" body = ET.SubElement(root,'body') h1 = ET.SubElement(body,'h1') h1.text = "And I like the fact that 3 &gt; 1" tree = ET.ElementTree(root) tree.write('foo.xhtml') # more foo.xhtml &lt;html&gt;&lt;head&gt;&lt;script type="text/javascript"&gt;var a = 'I love &amp;amp;aacute; letters'&lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;And I like the fact that 3 &amp;gt; 1&lt;/h1&gt; &lt;/body&gt;&lt;/html&gt; </code></pre>
<p>Another way is using the <a href="http://codespeak.net/lxml/tutorial.html#the-e-factory" rel="nofollow noreferrer">E Factory</a> builder from lxml (available in <a href="http://effbot.org/zone/element-builder.htm" rel="nofollow noreferrer">Elementtree</a> too)</p> <pre><code>&gt;&gt;&gt; from lxml import etree &gt;&gt;&gt; from lxml.builder import E &gt;&gt;&gt; def CLASS(*args): # class is a reserved word in Python ... return {"class":' '.join(args)} &gt;&gt;&gt; html = page = ( ... E.html( # create an Element called "html" ... E.head( ... E.title("This is a sample document") ... ), ... E.body( ... E.h1("Hello!", CLASS("title")), ... E.p("This is a paragraph with ", E.b("bold"), " text in it!"), ... E.p("This is another paragraph, with a", "\n ", ... E.a("link", href="http://www.python.org"), "."), ... E.p("Here are some reserved characters: &lt;spam&amp;egg&gt;."), ... etree.XML("&lt;p&gt;And finally an embedded XHTML fragment.&lt;/p&gt;"), ... ) ... ) ... ) &gt;&gt;&gt; print(etree.tostring(page, pretty_print=True)) &lt;html&gt; &lt;head&gt; &lt;title&gt;This is a sample document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 class="title"&gt;Hello!&lt;/h1&gt; &lt;p&gt;This is a paragraph with &lt;b&gt;bold&lt;/b&gt; text in it!&lt;/p&gt; &lt;p&gt;This is another paragraph, with a &lt;a href="http://www.python.org"&gt;link&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Here are some reservered characters: &amp;lt;spam&amp;amp;egg&amp;gt;.&lt;/p&gt; &lt;p&gt;And finally an embedded XHTML fragment.&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<p>Try <a href="http://uche.ogbuji.net/tech/4suite/amara" rel="nofollow noreferrer">http://uche.ogbuji.net/tech/4suite/amara</a>. It is quite complete and has a straight forward set of access tools. Normal Unicode support, etc. </p> <pre><code># #Output the XML entry # def genFileOLD(out,label,term,idval): filename=entryTime() + ".html" writer=MarkupWriter(out, indent=u"yes") writer.startDocument() #Test element and attribute writing ans=namespace=u'http://www.w3.org/2005/Atom' xns=namespace=u'http://www.w3.org/1999/xhtml' writer.startElement(u'entry', ans, extraNss={u'x':u'http://www.w3.org/1999/xhtml' , u'dc':u'http://purl.org/dc/elements/1.1'}) #u'a':u'http://www.w3.org/2005/Atom', #writer.attribute(u'xml:lang',unicode("en-UK")) writer.simpleElement(u'title',ans,content=unicode(label)) #writer.simpleElement(u'a:subtitle',ans,content=u' ') id=unicode("http://www.dpawson.co.uk/nodesets/"+afn.split(".")[0]) writer.simpleElement(u'id',ans,content=id) writer.simpleElement(u'updated',ans,content=unicode(dtime())) writer.startElement(u'author',ans) writer.simpleElement(u'name',ans,content=u'Dave ') writer.simpleElement(u'uri',ans, content=u'http://www.dpawson.co.uk/nodesets/'+afn+".xml") writer.endElement(u'author') writer.startElement(u'category', ans) if (prompt): label=unicode(raw_input("Enter label ")) writer.attribute(u'label',unicode(label)) if (prompt): term = unicode(raw_input("Enter term to use ")) writer.attribute(u'term', unicode(term)) writer.endElement(u'category') writer.simpleElement(u'rights',ans,content=u'\u00A9 Dave 2005-2008') writer.startElement(u'link',ans) writer.attribute(u'href', unicode("http://www.dpawson.co.uk/nodesets/entries/"+afn+".html")) writer.attribute(u'rel',unicode("alternate")) writer.endElement(u'link') writer.startElement(u'published', ans) dt=dtime() dtu=unicode(dt) writer.text(dtu) writer.endElement(u'published') writer.simpleElement(u'summary',ans,content=unicode(label)) writer.startElement(u'content',ans) writer.attribute(u'type',unicode("xhtml")) writer.startElement(u'div',xns) writer.simpleElement(u'h3',xns,content=unicode(label)) writer.endElement(u'div') writer.endElement(u'content') writer.endElement(u'entry') </code></pre>
8,012
<p>I'm seeing a current trend towards many questions only receiving a single answer, and according the the <a href="http://area51.stackexchange.com/proposals/82438/3d-printing">Area 51</a> stats, we ought to have an <em>average</em> closer to 2.5. Granted that some questions are really only in need of a single (obvious) answer, I think we're missing something here.</p> <p>I've seen a few questions with 'answers in the comments', which is understandable if a user wants to make a drive-by quick tip, but we should really be encouraging them to try and come back later to get the points due to them.</p> <p>Are users put off by an expectation that a wrong answer might lose them rep? Or by an overly high (assumed) expectation for making an answer?</p> <p>What can we do to raise ApQ, without dropping answer quality significantly?</p> <p>Some thoughts from IoT meta on why <a href="https://iot.meta.stackexchange.com/questions/291">more answers are good</a>.</p>
<p>Well done for bringing this up. I was looking at those numbers too. </p> <p>Referring to <a href="https://3dprinting.meta.stackexchange.com/questions/264/what-does-it-take-to-get-out-of-beta-stage/265#265">this post</a>, almost all of the stats are improving (albeit) slowly, except for one, the ApQ </p> <blockquote> <p>Are users put off by an expectation that a wrong answer might lose them rep?</p> </blockquote> <p>It seems that way. Without wishing to provide a link to the actual comment, I noticed a comment the other day that suggested as much, and a nicely detailed comment was left instead. </p> <p>To be fair, I feel that way sometimes, and often hesitate (maybe rightly so to save myself from spamming the site) in posting questions on SE.Meta, as there are a number of drive-by downvoters there<sup>1</sup>. Unless you have a definite bug that you are able to document clearly or have a well rounded proposal that can be implemented easily, then your question may end up downvoted. This is probably rightly so, TBH, in most cases, but nevertheless it can be discouraging.</p> <p>If you don't have much hard-earned rep then you may be less willing to risk it by posting a informative answer, that only answers half the question. Is that a bad thing? Well, it is a double edged sword. It is a good thing, because that promotes good solid answers, but with the downside that you point out (a lack of multiple answers per question).</p> <p>What can we do? Probably, not much other than creating a small community by promoting a friendly environment and communicating more clearly... Inviting people to chat in the chatroom, being more welcoming (with Hi and welcome), actually helping people without the old "Did you google this?" immediately. All of these things help a lot. And which we seem to have developed of late. So we seem to be getting there.</p> <p>I know that a number of members have already been adding answers to single answer questions as well as tackling the unanswered queue too. The more people that help the better...</p> <hr> <p><sup>1</sup> Don't get me wrong, I looove (justified) downvotes, but I would like to know <em>why</em>.</p>
<p>Something to realize is, ApQ is one of the least dependent factors for graduation. I don't think this site lends to having a huge amount of ApQ's, because usually there is only going to really be one answer which will work. I think the ApQ category was based more towards the programming/tech sites. I mean, when programming, there's almost ALWAYS going to be more than one way to answer a question.Then when you look at other sites where there is advice given, like Travel.SE or Law.SE, you could possibly see a plethora of answers for each of their questions. Then you take WorldBuilding.SE and it's a whole new level.</p> <p>IIRC, when Mechanics.SE graduated, we had sub 2.0 ApQ. I don't think 3D's is out of line with that and it isn't going to hurt the site for graduation.</p> <p>While multi-ApQ is not a bad thing, it only works if the question deserves it. If the question isn't answered correctly or if there might be something else which could be the answer, then multi-ApQ is an awesome thing. To make answers for answer sake, just to boost the ApQ, that can be ugly. A much better idea is (IMHO), to upvote good Q/A's and downvote bad ones.</p> <p>I completely agree with moving the site forward, but my suggestion is to move it forward in the right direction by putting energy where energy is needed. </p>
54
<p>Our installer is written with Inno Setup and we are actually quite happy with it. Yet some customers keep asking for an MSI installer which they could more easily distribute via Active Directory. We have already gone to some lengths to make the installer deal really well with automated and unattended installations by extending Inno Setup's <code>/LOADINF</code>-mechanism with our own options.</p> <p>In order to satisfy the customers asking for MSI, I had been thinking about simply wrapping our regular installer inside an MSI, possibly created using WIX. The question is: can I maintain the high configurability which our current installer offers that way? How would I go about exposing the Inno Setup installer's options through the outer MSI in the unattended/mass installation scenario?</p> <p>Note that I haven't really gotten to the point of actually digging into MSI-creation and WIX myself yet. Right now I'm only interested in whether people who do know what they're talking about think this would be a feasible/sensible approach to invest our energy in in the first place...</p> <p>[EDIT:] Initially I thought I could do with the temp extraction and execution approach, i.e. the MSI would simply serve as a vessel for delivering the Inno installer to the target PC and executing it there in <code>/VERYSILENT</code>-mode. But I guess the customers who ask for the MSI also want to be able to uninstall or even modify the install from a central location and I guess that won't be possible in that scenario, would it?</p> <p>P.S.: We do have an old copy of WISE for MSI here as well but that experience was actually the reason why we started using Inno instead to begin with...</p>
<p>No, there's no way to do that while still keeping the functionality your customers are 'implicitly' asking for. The only 'wrapping' in MSI you can do is to extract it on installation and start your InnoSetup installer from the temporary location where you extracted to. MSI is a fundamentally different way of working: InnoSetup (&amp; NSIS &amp; most other installers) take a code-centric approach: you 'program' the 'steps' to install your data. MSI is a database and takes a 'data-centric' approach: you indicate what files should be installed and the MSI 'runtime' does the rest. This gives you versioning and exact control of what goes where.</p> <p>In short, to give your customers what they want (i.e., the ease of deployment that MSI brings with AD), you'll need 'proper' MSI's. Good luck with that, it's a major pain IMHO. But it does give good results once you master MSI &amp; WiX.</p>
<p>Doing so would be pretty much equivalent to delivering a ZIP file and calling unzip by the end of installation.</p> <p>With such approach AD and Windows Installer would be fooled as if dealing with proper MSI installation, but as it is not the case, they'd backfire on you on the very first occasion.</p> <p>Don't go this way.</p> <p>And WiX is superior toolset to InnoSetup, anyway, so the time you'll spend on learning and porting will pay off by better support of collaboration.</p>
9,667
<p>I like HtmlControls because there is no HTML magic going on... the asp source looks similar to what the client sees. </p> <p>I can't argue with the utility of GridView, Repeater, CheckBoxLists, etc, so I use them when I need that functionality. </p> <p>Also, it looks weird to have code that mixes and matches:</p> <pre><code>&lt;asp:Button id='btnOK' runat='server' Text='OK' /&gt; &lt;input id='btnCancel' runat='server' type='button' value='Cancel' /&gt; </code></pre> <p>(The above case in the event you wanted to bind a server-side event listener to OK but Cancel just runs a javascript that hides the current div)</p> <p>Is there some definitive style guide out there? Should HtmlControls just be avoided? </p>
<p>It might be useful to think of HTML controls as an option when you want more control over the mark up that ends up getting emitted by your page. More control in the sense that you want EVERY browser to see exactly the same markup.</p> <p>If you create System.Web.UI.HtmlControls like:</p> <pre><code>&lt;input id='btnCancel' runat='server' type='button' value='Cancel' /&gt; </code></pre> <p>Then you know what kind of code is going to be emitted. Even though most of the time:</p> <pre><code>&lt;asp:Button id='btnCancel' runat='server' Text='Cancel' /&gt; </code></pre> <p>will end up being the same markup. The same markup is not always emitted for all WebControls. Many WebControls have built in adaptive rendering that will render different HTML based on the browser user agent. As an example a DataGrid will look quite different in a mobile browser than it will in a desktop browser.</p> <p>Using WebControls as opposed to HtmlControls also lets you take advantage of <a href="http://msdn.microsoft.com/en-us/library/67276kc5.aspx" rel="noreferrer">ASP.NET v2.0 ControlAdapters</a> which I believe only works with WebControls, this will allow you programatic config driven control over the markup that gets emitted.</p> <p>This might seem more valuable when you consider that certain mobile browsers or WebTVs are going to want WML or completely different sets of markups.</p>
<p>By adding runat="server" you can get access to any HTML controls in server side.. and I believe HTML controls are less weight compared to ASP.NET server controls..</p>
8,241