instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>Suppose someone worked for a company that put up an HTTP proxy preventing internet access without password authentication (NTLM, I think). Also suppose that this password rotated on a daily basis, which added very little security, but mostly served to annoy the employees. How would one get started writing a Firefox add-on that automatically entered these rotating passwords?</p> <p><em>To clarify: This add-on would not just submit the password; the add-on would programmatically generate it with some knowledge of the password rotation scheme.</em></p>
<p>This is built into Firefox. Open up about:config, search for 'ntlm'</p> <p>The setting you're looking for is called network.automatic-ntlm-auth.trusted-uris and accepts a comma-space delimited list of your proxy server uris.</p> <p>This will make FireFox automatically send hashed copies of your windows password to the proxy, which is disabled by default for obvious reasons. IE can do this automatically because it can use security zones to figure out whether a proxy server is trusted or not.</p> <p><a href="https://sivel.net/2007/05/firefox-ntlm-sso/" rel="nofollow noreferrer">Blog post discussing this</a></p>
<p>It's your lucky day - no need for an add-on!</p> <h2>How to configure Firefox for automatic NTLM authentication</h2> <ol> <li>In Firefox, type about:config into the address bar and hit enter. You should see a huge list of configuration properties. </li> <li>Find the setting named network.negotiate-auth.delegation-uris (the easiest way to do this is to type that into the filter box at top). </li> <li>Double-click this line, and enter the names of all servers for which network authentication is desired, separated by commas. Then press ‘OK’ to confirm. </li> <li>Find the setting network.negotiate-auth.trusted-uris, and set it to the same value used in #3. </li> <li>Find the setting network.ntlm.send-lm-response, and set it to true. </li> <li>Skip steps 7 and 8 if you aren't using a proxy.</li> <li>Open the options dialog (Tools->Options menu), and on the Advanced page, Network tab, press the Connection Settings button to get the proxy configuration dialog: </li> <li>Make sure the correct proxy server is configured, and that the same list of servers is listed in the No Proxy for: entryfield as were set in step #3. </li> <li>Done. </li> </ol>
6,244
<p>I'm looking into writing a audio syntesizer in Java, and was wondering if anybody has any advice or good resources for writing such a program. I'm looking for info on generating raw sound waves, how to output them into a usable form (playing over speakers), as well as general theory on the topic. Thanks guys.</p>
<ol> <li><p>This problem is basically about mapping functions to arrays of numbers. A language that supports first-class functions would come in really handy here.</p></li> <li><p>Check out <a href="http://www.harmony-central.com/Computer/Programming" rel="nofollow noreferrer">http://www.harmony-central.com/Computer/Programming</a> and <a href="http://www.developer.com/java/other/article.php/3071021" rel="nofollow noreferrer">http://www.developer.com/java/other/article.php/3071021</a> for some Java-related info.</p></li> <li><p>If you don't know the basic concepts of encoding sound data, then read <a href="http://en.wikipedia.org/wiki/Sampling_rate" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Sampling_rate</a></p></li> <li><p>The canonical WAVE format is very simple, see <a href="http://www.lightlink.com/tjweber/StripWav/Canon.html" rel="nofollow noreferrer">http://www.lightlink.com/tjweber/StripWav/Canon.html</a>. A header (first 44 bytes) + the wave-data. You don't need any library to implement that.</p></li> </ol> <p>In C/C++, the corresponding data structure would look something like this:</p> <pre class="lang-cpp prettyprint-override"><code>typedef struct _WAVstruct { char headertag[4]; unsigned int remnantlength; char fileid[4]; char fmtchunktag[4]; unsigned int fmtlength; unsigned short fmttag; unsigned short channels; unsigned int samplerate; unsigned int bypse; unsigned short ba; unsigned short bipsa; char datatag[4]; unsigned int datalength; void* data; //&lt;--- that's where the raw sound-data goes }* WAVstruct; </code></pre> <p>I'm not sure about Java. I guess you'll have to substitute "struct" with "class" and "void* data" with "char[] data" or "short[] data" or "int[] data", corresponding to the number of bits per sample, as defined in the field bipsa.</p> <p>To fill it with data, you would use something like that in C/C++:</p> <pre class="lang-cpp prettyprint-override"><code>int data2WAVstruct(unsigned short channels, unsigned short bipsa, unsigned int samplerate, unsigned int datalength, void* data, WAVstruct result) { result-&gt;headertag[0] = 'R'; result-&gt;headertag[1] = 'I'; result-&gt;headertag[2] = 'F'; result-&gt;headertag[3] = 'F'; result-&gt;remnantlength = 44 + datalength - 8; result-&gt;fileid[0] = 'W'; result-&gt;fileid[1] = 'A'; result-&gt;fileid[2] = 'V'; result-&gt;fileid[3] = 'E'; result-&gt;fmtchunktag[0] = 'f'; result-&gt;fmtchunktag[1] = 'm'; result-&gt;fmtchunktag[2] = 't'; result-&gt;fmtchunktag[3] = ' '; result-&gt;fmtlength = 0x00000010; result-&gt;fmttag = 1; result-&gt;channels = channels; result-&gt;samplerate = samplerate; result-&gt;bipsa = bipsa; result-&gt;ba = channels*bipsa / 8; result-&gt;bypse = samplerate*result-&gt;ba; result-&gt;datatag[0] = 'd'; result-&gt;datatag[1] = 'a'; result-&gt;datatag[2] = 't'; result-&gt;datatag[3] = 'a'; result-&gt;datalength = datalength; result-&gt;data = data; // &lt;--- that's were the data comes in return 0; // an error code, not implemented, yet ...; in Java: return result } </code></pre> <p>Again, I'm not sure about Java but the conversion should be straightforward if you convert the void-pointer to an array corresponding to the bitrate. </p> <p>Then simply write the entire structure to a file to get a playable wave file.</p>
<p>I dont't know if that helps, but if you can use MIDI for anything, you should check out <a href="http://www.jfugue.org/" rel="nofollow noreferrer">JFuge</a>.</p>
5,717
<p>On these questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/17653/which-vista-edition-is-the-best-for-developer-machine">Which Vista edition is best for a developer machine?</a></li> <li><a href="https://stackoverflow.com/questions/4433/vista-or-xp-for-dev-machine">Vista or XP for Dev Machine</a></li> </ul> <p>People are recommending 64 bit, can you explain why? Is it just so you can have more then 3GB of addressable RAM that 32 bit gives you?</p> <p>And how does Visual Studio benefit from all this extra RAM?</p> <p>I went from 64 bit XP back to 32 bit due to 90% of the software I was using only being 32 bit anyway and I had issues with drivers and some software with 64 bit.</p>
<p>A number of reasons.</p> <ol> <li>Yes, you're right it is so you can have more than 3 gig of ram</li> <li>More and more systems are going to be 64 bit soon so it makes sense to develop on what you're going to be running on</li> <li>Some bugs can only be observed when running in 64 bit mode</li> </ol>
<p>XP 64bit wasn't ready for prime time, there were no drivers for it. In Windows Vista 64-bit this isn't the case. So if you are looking to install Windows Vista go 64-bit if you are keeping XP stay at 32-bit.</p>
3,866
<p>This is an ASP.Net 2.0 web app. The Item template looks like this, for reference:</p> <pre><code>&lt;ItemTemplate&gt; &lt;tr&gt; &lt;td class="class1" align=center&gt;&lt;a href='url'&gt;&lt;img src="img.gif"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td class="class1"&gt;&lt;%# DataBinder.Eval(Container.DataItem,"field1") %&gt;&lt;/td&gt; &lt;td class="class1"&gt;&lt;%# DataBinder.Eval(Container.DataItem,"field2") %&gt;&lt;/td&gt; &lt;td class="class1"&gt;&lt;%# DataBinder.Eval(Container.DataItem,"field3") %&gt;&lt;/td&gt; &lt;td class="class1"&gt;&lt;%# DataBinder.Eval(Container.DataItem,"field4") %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; </code></pre> <p>Using this in codebehind:</p> <pre><code>foreach (RepeaterItem item in rptrFollowupSummary.Items) { string val = ((DataBoundLiteralControl)item.Controls[0]).Text; Trace.Write(val); } </code></pre> <p>I produce this:</p> <pre><code>&lt;tr&gt; &lt;td class="class1" align=center&gt;&lt;a href='url'&gt;&lt;img src="img.gif"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td class="class1"&gt;23&lt;/td&gt; &lt;td class="class1"&gt;1/1/2000&lt;/td&gt; &lt;td class="class1"&gt;-2&lt;/td&gt; &lt;td class="class1"&gt;11&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>What I need is the data from Field1 and Field4</p> <p>I can't seem to get at the data the way I would in say a DataList or a GridView, and I can't seem to come up with anything else on Google or quickly leverage this one to do what I want. The only way I can see to get at the data is going to be using a regex to go and get it (Because a man takes what he wants. He takes it all. And I'm a man, aren't I? Aren't I?). </p> <p>Am I on the right track (not looking for the specific regex to do this; forging that might be a followup question ;) ), or am I missing something?</p> <hr> <p>The Repeater in this case is set in stone so I can't switch to something more elegant. Once upon a time I did something similar to what Alison Zhou suggested using DataLists, but it's been some time (2+ years) and I just completely forgot about doing it this way. Yeesh, talk about overlooking something obvious. . .</p> <p>So I did as Alison suggested and it works fine. I don't think the viewstate is an issue here, even though this repeater can get dozens of rows. I can't really speak to the question if doing it that way versus using the instead (but that seems like a fine solution to me otherwise). Obviously the latter is less of a viewstate footprint, but I'm not experienced enough to say when one approach might be preferrable to another without an extreme example in front of me. Alison, one question: why literals and not labels?</p> <p>Euro Micelli, I was trying to avoid a return trip to the database. Since I'm still a little green relative to the rest of the development world, I admit I don't necessarily have a good grasp of how many database trips is "just right". There wouldn't be a performance issue here (I know the app's load enough to know this), but I suppose I was trying to avoid it out of habit, since my boss tends to emphasize fewer trips where possible.</p>
<p>Off the top of my head, you can try something like this:</p> <pre><code>&lt;ItemTemplate&gt; &lt;tr&gt; &lt;td "class1"&gt;&lt;asp:Literal ID="litField1" runat="server" Text='&lt;%# Bind("Field1") %&gt;'/&gt;&lt;/td&gt; &lt;td "class1"&gt;&lt;asp:Literal ID="litField2" runat="server" Text='&lt;%# Bind("Field2") %&gt;'/&gt;&lt;/td&gt; &lt;td "class1"&gt;&lt;asp:Literal ID="litField3" runat="server" Text='&lt;%# Bind("Field3") %&gt;'/&gt;&lt;/td&gt; &lt;td "class1"&gt;&lt;asp:Literal ID="litField4" runat="server" Text='&lt;%# Bind("Field4") %&gt;'/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; </code></pre> <p>Then, in your code behind, you can access each Literal control as follows:</p> <pre><code>foreach (RepeaterItem item in rptrFollowupSummary.Items) { Literal lit1 = (Literal)item.FindControl("litField1"); string value1 = lit1.Text; Literal lit4 = (Literal)item.FindControl("litField4"); string value4 = lit4.Text; } </code></pre> <p>This will add to your ViewState but it makes it easy to find your controls.</p>
<p>If you can afford a smidge more overhead in the generation, go for DataList and use the DataKeys property, which will save the data fields you need.</p> <p>You could also use labels in each of your table cells and be able to reference items with e.Item.FindControl("LabelID").</p>
7,830
<p>Prusa MK3 heatbed power cable shorted out (on the Einsy side) and it looks like I need to replace the Einsy. Should I replace the heatbed too? I don’t know electronics well and am worried I will just fry a new Einsy.</p> <p>Heatbed end: <a href="https://i.stack.imgur.com/1pA7t.jpg" rel="nofollow noreferrer" title="Heatbed end"><img src="https://i.stack.imgur.com/1pA7t.jpg" alt="Heatbed end" title="Heatbed end" /></a></p> <p>Crispy at RAMBo end: <a href="https://i.stack.imgur.com/rWn8V.jpg" rel="nofollow noreferrer" title="Crispy at RAMBo end"><img src="https://i.stack.imgur.com/rWn8V.jpg" alt="Crispy at RAMBo end" title="Crispy at RAMBo end" /></a></p> <p>Crispy at RAMBo end: <a href="https://i.stack.imgur.com/4Ot8Z.jpg" rel="nofollow noreferrer" title="Crispy at RAMBo end"><img src="https://i.stack.imgur.com/4Ot8Z.jpg" alt="Crispy at RAMBo end" title="Crispy at RAMBo end" /></a></p> <p>Larger images can be found <a href="https://imgur.com/gallery/sAL61ux" rel="nofollow noreferrer">here</a>.</p>
<p>It's common for modeling software to flip normals, causing what you describe. You said,</p> <blockquote> <p>I only care about the externally facing faces.</p> </blockquote> <p>But are you sure they are truly externally facing? Turn on normals in Blender and ensure that all the arrows/pointers are external.</p> <p>Another problem that can generate the results you're seeing are self-intersecting surfaces, non-manifold edges, and a couple others that are explained in a <a href="https://www.3dhubs.com/knowledge-base/fixing-most-common-stl-file-errors/" rel="nofollow noreferrer">3dhubs article.</a> Correcting those problems involve a bit more examination and trouble shooting.</p> <p>The slicing software prefers to have clean, well defined triangular surfaces in order to create a print file. When something is amiss, you get results you've presented.</p> <p>With the STL in hand, I opened it in Meshmixer (free) and immediately was given a clue.</p> <p><a href="https://i.stack.imgur.com/oITba.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oITba.png" alt="STL image in meshmixer" /></a></p> <p>The zebra-stripes are reversed normals.</p> <p>Here's another error point, difficult to see clearly in flat 2D image, but panning and zooming and orbiting and all those 3D manipulating things shows there's nothing there:</p> <p><a href="https://i.stack.imgur.com/FrtCK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FrtCK.png" alt="broken corner" /></a></p> <p>The other end of this not-joined area shows a bit better:</p> <p><a href="https://i.stack.imgur.com/IH41m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IH41m.png" alt="other broken corner" /></a></p> <p>After selecting all I could find/locate, I did the reverse normals and here's a slightly improved result:</p> <p><a href="https://i.stack.imgur.com/GcpRG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GcpRG.png" alt="corrected part" /></a></p> <p>Unfortunately, the other borked up portions prevented meshmixer from performing a suitable auto-repair, completely destroying the model in the process.</p> <p>Those joint corners and any other colored lines have to be addressed individually.</p>
<p>Okay, so like suggested I put it into 3D Builder (A free Windows 3D modeling program). I imported it as an stl, then exported it as an stl and imported that stl into Cura. And lo and behold all problems were gone! If you are having a similar issue give that a try! The 3D Builder program and similar ones are designed to export for the sole purpose of 3D printing so it automatically fixes these issues! If this doesn't work try editing yours in edit mode (Blender) a bit so it makes it easier for 3D Builder to fix it.</p>
1,892
<p>To make a JavaScript class with a public method I'd do something like:</p> <pre><code>function Restaurant() {} Restaurant.prototype.buy_food = function(){ // something here } Restaurant.prototype.use_restroom = function(){ // something here } </code></pre> <p>That way users of my class can:</p> <pre><code>var restaurant = new Restaurant(); restaurant.buy_food(); restaurant.use_restroom(); </code></pre> <p>How do I create a private method that can be called by the <code>buy_food</code> and <code>use_restroom</code> methods but not externally by users of the class?</p> <p>In other words, I want my method implementation to be able to do:</p> <pre><code>Restaurant.prototype.use_restroom = function() { this.private_stuff(); } </code></pre> <p>But this shouldn't work:</p> <pre><code>var r = new Restaurant(); r.private_stuff(); </code></pre> <p>How do I define <code>private_stuff</code> as a private method so both of these hold true?</p> <p>I've read <a href="http://javascript.crockford.com/private.html" rel="noreferrer">Doug Crockford's writeup</a> a few times but it doesn't seem like "private" methods can be called by public methods and "privileged" methods can be called externally.</p>
<p>You can do it, but the downside is that it can't be part of the prototype:</p> <pre><code>function Restaurant() { var myPrivateVar; var private_stuff = function() { // Only visible inside Restaurant() myPrivateVar = "I can set this here!"; } this.use_restroom = function() { // use_restroom is visible to all private_stuff(); } this.buy_food = function() { // buy_food is visible to all private_stuff(); } } </code></pre>
<p>Private functions cannot access the public variables using module pattern</p>
7,942
<p>I switched my Anet A8 over to a Bowden and it's printing great. Moving that weight off has enabled me to almost double the speed and resonance problems have vanished. </p> <p>My question is regarding after the print is done should I add a retraction code and back the filament out of the v6 or is it okay to leave it in there?</p> <p>My concern is that if I leave it in there, will it cause a clog or anything when I warm up the printer tomorrow to print something else? If that's not a something I should be concerned about let me know.</p>
<p>It's okay to leave the filament in the hot end, as long as you let it cool down with the hot end cooling fan running.</p> <hr> <p><em>From comment:</em></p> <blockquote> <p>That's not an issue, you can simply leave it in the hot end. The only "end of print" clogs usually occur when leaving the hot end hot for a while - allowing the filament to drip out - and then retract the filament without feeding it against the nozzle once more. That creates a plug that's larger than the filament diameter that might get stuck in the bowden tube</p> </blockquote>
<p>I agree with towe's answer. I would leave it, retracting at most a mm or two just to avoid a mess. If you retract much at end of print, initial state for the second or later print is different from after just loading new filament, and this leads to different priming/skirt outcomes for the two cases, which can be problematic.</p>
1,518
<p>We generate dynamic reports in all of our business web applications written for .Net and J2EE. On the server side we use ActiveReports.Net and JasperReports to generate the reports. We then export them to PDF to send down to the browser.</p> <p>Our clients all use Adobe Reader. We have endless problems with the different versions of Adobe Reader and how they are setup on the client. </p> <p>What file format/readers are others using for their dynamic reports? We need something that allows for precise layout as many of the reports are forms that are printed with data from out systems. HTML is not expressive enough.</p>
<p>I've used SQL Reporting Services for this purpose. You can design a report template in Visual Studio or generate the XML for the report on the fly in code. You can then have SSRS export the report to about 10 different formats and send to the client including pdf, excel, html, etc. You can also write your own plugin to export to your own format.</p> <p>Crystal Reports has a similar product thats more expensive but has a better report designer.</p>
<p>I've always had the most success using PDFs to accomplish this. I can't think of a more universally acceptable format that does what you are trying to do. Rather than looking for another format, perhaps it would be better to try to understand how to overcome the problems that you are experiencing with Acrobat on the client side. Can you provide some more information on the types of problems that you are experiencing with Acrobat? </p>
6,817
<p>Given a reference to a method, is there a way to check whether the method is bound to an object or not? Can you also access the instance that it's bound to?</p>
<pre class="lang-py prettyprint-override"><code>def isbound(method): return method.im_self is not None def instance(bounded_method): return bounded_method.im_self </code></pre> <p><a href="https://docs.python.org/2.7/reference/datamodel.html#index-40" rel="nofollow noreferrer">User-defined methods:</a></p> <blockquote> <p>When a user-defined method object is created by retrieving a user-defined function object from a class, its <code>im_self</code> attribute is <code>None</code> and the method object is said to be unbound. When one is created by retrieving a user-defined function object from a class via one of its instances, its <code>im_self</code> attribute is the instance, and the method object is said to be bound. In either case, the new method's <code>im_class</code> attribute is the class from which the retrieval takes place, and its <code>im_func</code> attribute is the original function object.</p> </blockquote> <p>In Python <a href="https://docs.python.org/2.7/whatsnew/2.6.html" rel="nofollow noreferrer">2.6 and 3.0</a>:</p> <blockquote> <p>Instance method objects have new attributes for the object and function comprising the method; the new synonym for <code>im_self</code> is <code>__self__</code>, and <code>im_func</code> is also available as <code>__func__</code>. The old names are still supported in Python 2.6, but are gone in 3.0.</p> </blockquote>
<p>A solution that works for both Python 2 and 3 is tricky.</p> <p>Using the package <a href="https://six.readthedocs.io/" rel="nofollow noreferrer"><code>six</code></a>, one solution could be:</p> <pre class="lang-py prettyprint-override"><code>def is_bound_method(f): &quot;&quot;&quot;Whether f is a bound method&quot;&quot;&quot; try: return six.get_method_self(f) is not None except AttributeError: return False </code></pre> <p>In Python 2:</p> <ul> <li>A regular function won't have the <code>im_self</code> attribute so <code>six.get_method_self()</code> will raise an <code>AttributeError</code> and this will return <code>False</code></li> <li>An unbound method will have the <code>im_self</code> attribute set to <code>None</code> so this will return <code>False</code></li> <li>An bound method will have the <code>im_self</code> attribute set to non-<code>None</code> so this will return <code>True</code></li> </ul> <p>In Python 3:</p> <ul> <li>A regular function won't have the <code>__self__</code> attribute so <code>six.get_method_self()</code> will raise an <code>AttributeError</code> and this will return <code>False</code></li> <li>An unbound method is the same as a regular function so this will return <code>False</code></li> <li>An bound method will have the <code>__self__</code> attribute set (to non-<code>None</code>) so this will return <code>True</code></li> </ul>
7,666
<p>So basically I am looking for good templates for writing both technical and functional specs on a project or work request.</p> <p>What do you use? How deep do you get while writing the specs? Any additional general tips you could provide would be appreciated.</p> <p>My company needs these badly. I work for a contractor and right now we do not use these documents at all. </p> <p><strong>EDIT:</strong> I have read Joel's take about <a href="http://www.joelonsoftware.com/articles/fog0000000036.html" rel="noreferrer">Painless Specification</a>, I really liked it, but are there any other opinions :) </p>
<p>On general tips;</p> <p>We are implementing a process of </p> <p>1) Business Requirements Statement (BRS)</p> <p>2) Functional Specification</p> <p>3) Technical specification</p> <p>The BRS covers what the business problems are, and what the requirements are around solutions, testing, security, reliability and delivery. This defines what would make a successful solution.</p> <p>The functional spec details what is needed, how it should look, how long fields should be, etc.</p> <p>The technical spec details where the data comes from, any tricky code that may need to be considered.</p> <p>The customer owns the requirements. The developers own the tech specs, and the functional spec is a middle ground. Testing is done against the tech specs (usually unit testing) then against the functional specs (usually system testing) and then against the requirements (UAT).</p> <p>The important part of this (and we are struggling with) is that the developers still need to deliver to the functional spec, and the original business requirements. In reality the functional and tech specs are just there for clarity.</p> <p>In short, my main tip is to first work out the process you wish to implement. Then seek agreement from all parties involved in your proposed process, then work on the templates to fit. The templates themselves are only are a small part of the change you want to make.</p>
<p>Start off simple, and work your way from there. Since this is your first experience working with this, use a word document with bullet points. Write it, re-read it and provide enough detail that it makes sense. For technical specifications, you may want to lead the developer toward a solution, but for functional specifications the "how" should be completely missing. </p>
7,552
<p>How can I build a loop in JavaScript?</p>
<p><strong>For loops</strong></p> <pre><code>for (i = startValue; i &lt;= endValue; i++) { // Before the loop: i is set to startValue // After each iteration of the loop: i++ is executed // The loop continues as long as i &lt;= endValue is true } </code></pre> <p><strong>For...in loops</strong></p> <pre><code>for (i in things) { // If things is an array, i will usually contain the array keys *not advised* // If things is an object, i will contain the member names // Either way, access values using: things[i] } </code></pre> <p>It is bad practice to use <code>for...in</code> loops to itterate over arrays. It goes against the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="noreferrer">ECMA 262</a> standard and can cause problems when non-standard attributes or methods are added to the Array object, e.g. by <a href="http://www.prototypejs.org/api/array" rel="noreferrer">Prototype</a>. <em>(Thanks to <a href="https://stackoverflow.com/users/7679/chase-seibert">Chase Seibert</a> for pointing this out in the comments)</em></p> <p><strong>While loops</strong></p> <pre><code>while (myCondition) { // The loop will continue until myCondition is false } </code></pre>
<p>A loop in JavaScript looks like this:</p> <pre><code>for (var = startvalue; var &lt;= endvalue; var = var + increment) { // code to be executed } </code></pre>
7,531
<p>I have a c# asp.net web app. Breakpoints in the database layer are no longer stopping execution but the breakpoints in the UI layer are still working okay. Can anyone hazard a guess why this might be happening?</p> <p>I've checked all the usual suspects (Debug build is on for all projects) and recompiled all projects in solution...</p>
<p>I would ensure that the UI layer is referencing the appropriate 'debug' .dll's. I'd also consider pressing <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>U</kbd> (<code>Modules View</code>) when you're debugging to see if symbols are loaded for your BLL and DAL <code>.dlls</code>. If not then Visual Studio is unable to find <code>.PDBs</code> for that file.<br> Are debug files <code>.PDBs</code> in the same directory as the <code>.dlls</code> that are being referenced from the Modules window?</p>
<p>Have you tried deleting your bin directories before recompiling?</p>
8,489
<p>I have a .NET application, which is using an open source C++ compression library for compressing images. We are accessing the C++ library via managed C++. I'm seeing heap corruption during compression. A call to _CrtIsValidHeapPointer is finding an error on a call to free() when cleaning up after compression.</p> <p>Are there tools such as <a href="https://en.wikipedia.org/wiki/PurifyPlus" rel="nofollow noreferrer">Purify</a> to help diagnosis this problem and what is causing the heap corruption when working in a combination of managed and unmanaged code? I do have the exception caught in the debugger, but it would be nice to have other tools to help find the solution to the problem.</p>
<p>In native code, if the corruption always occurs in the same place in memory, you can use a <a href="http://msdn.microsoft.com/en-us/library/350dyxd0.aspx" rel="nofollow noreferrer">data breakpoint</a> to break the debugger when that memory is changed. Unfortunately, you cannot set a data breakpoint in the managed C++ environment, presumably because the GC could move the object in memory.</p> <p>Not sure if this helps, but hopefully it leads you off in the right direction.</p>
<p><a href="http://www-01.ibm.com/software/awdtools/purifyplus/win/" rel="nofollow noreferrer">Rational Purify for Windows</a> supports .NET, so I guess that could be used.</p>
5,536
<p>What is the fastest way of transferring few thousand rows of data from one DataTable to another? Would be great to see some sample code snippets.</p> <p>Edit: I need to explain a bit more. There is a filtering condition for copying the rows. So, a plain Copy() will not work.</p>
<p>You can't copy the whole table, you need to copy one rows. From <a href="http://support.microsoft.com/kb/308909" rel="noreferrer">http://support.microsoft.com/kb/308909</a> (sample code if you follow the link)</p> <p>"How to Copy DataRows Between DataTables Before you use the ImportRow method, you must ensure that the target table has the identical structure as the source table. This sample uses the Clone method of DataTable class to copy the structure of the DataTable, including all DataTable schemas, relations, and constraints.</p> <p>This sample uses the Products table that is included with the Microsoft SQL Server Northwind database. The first five rows are copied from the Products table to another table that is created in memory."</p>
<p>What is wrong with <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.copy.aspx" rel="nofollow noreferrer">DataTable.Copy</a>?</p>
9,347
<p>Are there any good tools out there for automatically converting non-Java source code into Java source?</p> <p>I'm not expecting something perfect, just to get the worst of the grunt work out of the way.</p> <p>I guess there is a sliding scale of difficulty. C# should be relatively easy (so long as you ignore all the libraries). (well written) C++ not so bad. C requires making a little OO. (Statically type) functional languages may be easy to grok. Dynamic OO languages may require non-local analysis.</p>
<p>One thing you can try is find a Java bytecode compiler for the language you're talking about (there are JVM compilers for all kinds of languages) and then decompile the bytecode back into Java using a decompiler like Jad. </p> <p>This is fraught with peril. The regenerated code will suck and will probably be unreadable.</p>
<p>ADA to Java can be done with a find-and-replace!</p>
6,893
<p>After encountering extreme under extrusion on my Anycubic i3 Mega, I first cleaned the nozzle and ended up replacing the entire hotend + nozzle. Since that did not help and I couldn't see any issues with it, I went on to check my E-steps. It seems that this is the root cause of the issue.</p> <p>I removed the Bowden tube to have no resistance and used <code>G1 E100 F100</code> to feed 100 mm of filament through the extruder. The extruder only extruded ca. 23 mm though, so I had to adjust the E-Steps value from <strong>92</strong> to <strong>398</strong> which already seemed way off, seemingly &quot;fixed&quot; the issue though. When I repeated the test &quot;under load&quot; with the Bowden tube connected and the hotend heated to 220 °C (using PLA I normally print at 200 °C), the extruder once again only extruded a fraction of the supposed 100 mm (I don't remember the exact measurement, though approximately 30 mm). The gears seem to be fine, and the filament that is pushed against the small gear doesn't seem to slip either.</p> <p>Unfortunately, that's where my experience ends, can someone tell me how to proceed to narrow down the issue? I suppose it could be the motor itself, a faulty stepper motor driver, loose cables, or the mainboard.</p> <p><strong>Edit to @Citadel:</strong> When I bought the printer it had a spare hot end that came with it. I simply replaced the old one with this one. I did not do any further hardware customization.</p> <p><strong>Edit2:</strong> Sorry for the late update, I wasn't able to check the printer before due to work. I swapped the stepper driver with one of the others on board and checked the e-steps again. Aaaand I just then I noticed I must have forgotten to save the to eeprom when I updated the e-steps last time... So of course I tried with the swapped stepper driver and original e-steps (<strong>92</strong>), but this didn't fix the issue. So the issue is not the driver. After that I changed the e-steps to <strong>398</strong> again and saved this time. Last time I accidentally started a print that that caused the eeprom reset before I saved the settings and tried the e-steps under load. This time it worked, even under load. I still believe this must mean that the motor is missing some steps but for now it seems to print fine. If I get issues again I'll next try to swap the motor. Thanks for your answers!</p> <p>TL;DR: forgot to save the new e-steps due to starting a calibration print that reset the value before saving. New value actually works but probably indicates that something might be wrong with the motor as the stepper driver is fine.</p>
<p>The raft still needs to fit on the bed, and it counts as a print, because, it is printed. You want the raft for better adhesion, so that means that you need more contact with the bed. If you’re not, your basically wasting filament. Its kinda logical actually.</p>
<h2>Adjusted model Dimensions</h2> <p>The model has the size determined by the base area of the bounding box, in this case, <span class="math-container">$\pu{190 \times 200 mm }$</span>. The raft as told by OP adds 15mm on <strong>all</strong> sides of the model, and thus adds 30 mm in total on both the X and Y dimensions. This gets us a bounding box floor area of <span class="math-container">$\pu{220 \times 230 mm}$</span>.</p> <p>The model's bounding box has a height of <span class="math-container">$\pu{200 mm}$</span>. Add to that the thickness of the raft. This is not mentioned, but in the worst case, this is about 3 mm, and so you get <span class="math-container">$\pu{203 mm}$</span> as the maximum. Our model's Bounding Box thus is <span class="math-container">$\pu{220\times 230\times 203 mm}$</span></p> <p>The smaller scale model (<span class="math-container">$\pu{171 \times 183 \times 180 mm}$</span>) results in an adjusted area of <span class="math-container">$\pu{201 \times 213 \times 183 mm}$</span>.</p> <h2>Printer dimensions</h2> <p>The standard Creality Ender3 v2 is set up with a build volume of (<span class="math-container">$\pu{220\times 220\times 250 mm}$</span>) As your base area is 230 mm in one dimension, it just can't fit. The slightly scaled item is <em>just</em> under that dimension and thus fits.</p> <h2>Solutions</h2> <p>With a firmware update, the printer can be told to use all of the bed, and then Cura's printer settings can be adjusted accordingly.</p> <p>Sometimes, but not in this case, rotating the model can result in a model that doesn't fit in normal orientation to fit: A line of 240 mm doesn't fit along the X or Y axis, but easily along the diagonal of the printer. In fact, it is enough to turn the model by about 23.3° and the line fits:</p> <p><a href="https://i.stack.imgur.com/rP9Ab.png" rel="nofollow noreferrer" title="Graphic showing a 240 mm line at a 23.3-degree angle fitting inside a gray box"><img src="https://i.stack.imgur.com/rP9Ab.png" alt="Graphic showing a 240 mm line of 0.45 mm width first at horizontal orientation and then at a 23.3-degree angle fitting inside a gray box of 220 mm width" title="Graphic showing a 240 mm line at a 23.3-degree angle fitting inside a gray box" /></a></p>
2,225
<p>I've recently switched to Linux on my work machine and, new to the Linux desktop environment, I'd like to find a decent ERD tool for database design. Booting back into my Windows partition every time I need to create a diagram is going to get unpleasant quickly. I looked at Dia, but didn't see any DB tools - only UML, networking, etc.</p> <p>Anyone have any recommendations? For what it's worth, I'm using Ubuntu (Hardy Heron).</p> <p>Thanks.</p>
<p>MySQL just officially released the alpha of "MySQL Workbech for linux":</p> <p>See the announcement here: <a href="http://dev.mysql.com/workbench/?p=153" rel="noreferrer">MySQL Workbench 5.1 Alpha for Linux available</a>.</p>
<p>You can try Base from <a href="https://www.libreoffice.org/features/base/" rel="nofollow">LibreOffice</a>. It can connect to any database and you can easily create, design and write queries using visual wizards and tools.</p>
3,491
<p>My path to a 'fulltime'- developer stated as a analyst using VBA with Excel, Access, and then onto C#. I went to college part time once I discovered I had a passion for coding not business.</p> <p>I do about most of my coding in C#, but being an ASP.NET developer I also write in HTML, JavaScript, SQL etc. . . the usual suspects.</p> <p>I like to keep moving forward find the edge that will get me to the next level, the next job, and of course more money. Most importantly I just want to learning something new and challenge me.</p> <p>I have spent time recently learning LINQ, but was wondering what should I learn next? Something on the .NET Framework or a new language technology?</p>
<p>If you want to be one of the best you need to specialise. If you become very good in many skills then you may never become truly excellent in one. I know because I have taken this route myself and have found it difficult to get employment at times. After all, who wants someone who is capable at many languages when there is someone who excels at the specific thing they need. If a company develops in C# then who would want someone who is OK at C# but also is good at C, Visual Basic, Perl and Cobol, when all they really want is the best possible C# developer for the money they can afford.</p> <p>After all, you will only ever be employed for one, maybe two of your skills. There are very few jobs for people who are good in 10 or 15 skills.</p> <p>If you are looking to a new skill then maybe check out the job boards and find which skills are particularly in need, but be aware that what is the flavour of the month this year may not even be on the scene next year, which will make all of that effort to learn the skill futile and wasted.</p> <p>What I would say is:</p> <ol> <li>do one thing, and do it well. This may include supporting skills (C#, ASP.Net, SQL, LINQ etc). </li> <li>If you want to choose something else, then choose something complementary.</li> <li>Possibly most importantly, choose something you will enjoy. Maybe Ruby on Rails is the current flavour of the month, but if you don't enjoy doing it, then don't do it. Really, it's not worth it. You will never wish, on your death bed, that you had worked more in something you didn't enjoy.</li> </ol> <p>Another direction you could look at is maybe not for a particular development skill, but look for something else, maybe soft skills like people management, better business understanding or even look to something like literary skills to help improve your communications skills. All of these will help to allow you to do what you want to do more, and cut down on the stuff you really don't enjoy, thus helping to make your job more enjoyable.</p> <p>Apologies for the waffling here. Hope you are still awake :)</p>
<p>Why don't you swap stacks and look at the LAMP stack?</p> <p>Or how about a functional language like haskell?</p> <p>Or write a DSL?</p> <p>Or an app for your phone?</p>
4,336
<p>To create a playlist for all of the music in a folder, I am using the following command in bash:</p> <pre><code>ls &gt; list.txt </code></pre> <p>I would like to use the result of the <code>pwd</code> command for the name of the playlist.</p> <p>Something like:</p> <pre><code>ls &gt; ${pwd}.txt </code></pre> <p>That doesn't work though - can anyone tell me what syntax I need to use to do something like this?</p> <p><strong>Edit:</strong> As mentioned in the comments pwd will end up giving an absolute path, so my playlist will end up being named .txt in some directory - d'oh! So I'll have to trim the path. Thanks for spotting that - I would probably have spent ages wondering where my files went!</p>
<p>The best way to do this is with <code>"$(command substitution)"</code> (thanks, <a href="https://stackoverflow.com/a/58233/1899640">Landon</a>):</p> <pre><code>ls &gt; "$(pwd).txt" </code></pre> <p>You will sometimes also see people use the older backtick notation, but this has <a href="https://stackoverflow.com/questions/4708549/what-is-the-difference-between-command-and-command-in-shell-programming">several drawbacks</a> in terms of nesting and escaping:</p> <pre><code>ls &gt; "`pwd`.txt" </code></pre> <p>Note that the unprocessed substitution of <code>pwd</code> is an absolute path, so the above command creates a file with the same name in the same directory as the working directory, but with a <code>.txt</code> extension. Thomas Kammeyer pointed out that the <code>basename</code> command strips the leading directory, so this would create a text file in the current directory with the name of that directory:</p> <pre><code>ls &gt; "$(basename "$(pwd)").txt" </code></pre> <p>Also thanks to erichui for bringing up the problem of spaces in the path.</p>
<p>to strip all but the directory name</p> <pre><code>ls &gt;/playlistdir/${PWD##/*}.txt </code></pre> <p>this is probably not what you want because then you don't know where the files are (unless you change the ls command)</p> <p>to replace "/" with "_"</p> <pre><code>ls &gt;/playlistdir/${PWD//\//_}.txt </code></pre> <p>but then the playlist would look ugly and maybe not even fit in the selection window</p> <p>So this will give you both a short readable name and usable paths inside the file</p> <pre><code>ext=.mp3 #leave blank for all files for FILE in "$PWD/*$ext"; do echo "$FILE";done &gt;/playlistdir/${PWD##/*}.txt </code></pre>
8,260
<p>Typically I develop my websites on trunk, then merge changes to a testing branch where they are put on a 'beta' website, and then finally they are merged onto a live branch and put onto the live website.</p> <p>With a Facebook application things are a bit tricky. As you can't view a Facebook application through a normal web browser (it has to go through the Facebook servers) you can't easily give each developer their own version of the website to work with and test.</p> <p>I have not come across anything about the best way to develop and test a Facebook application while continuing to have a stable live website that users can use. My question is this, what is the best practice for organising the development and testing of a Facebook application?</p>
<p>The way I and my partner did it was we each made our own private Facebook applications, that pointed to our IP address where we worked on it. Since we worked in the same place, we each picked a different port, and had our router forward that port to our local IP address. It was kinda slow to refresh a page, but it worked very nicely.</p>
<p>Another solution is NGROK</p> <p><a href="https://ngrok.com/" rel="nofollow">https://ngrok.com/</a></p> <p>It opens a public tunnel to your local app</p> <p>Example on my rails application by simply typing</p> <pre><code>./ngrok 3000 </code></pre> <p>I get</p> <pre><code>http://630066fe.ngrok.com -&gt; 127.0.0.1:3000 </code></pre>
6,038
<p>I'm working on a cube in Blender. I just deleted one of the faces (the top face) of the cube and added solidify to avoid non manifold edges. </p> <p>In this case, when I check the design it shows that the bottom face is an overhang face (shown with yellow color). However, if I change the overhang parameter in 3D printing tool box from 45 to 90° and then check the model, it doesn't show any overhang faces and it seems that everything is okay. I don't think increasing the overhang parameter could be a good idea. However, this is my first time that I'm trying to design a model for 3D printing. Can this model with the overhang parameter equal to 90° be printed using a 3D printer? How can I fix the overhang problem in this simple model. </p> <p><a href="https://i.stack.imgur.com/eZuaF.png" rel="nofollow noreferrer" title="Blender screenshot"><img src="https://i.stack.imgur.com/eZuaF.png" alt="Blender screenshot]" title="Blender screenshot"></a></p> <p>Today I tested another simple model. I used a fill circle and added solidify to the model. Although the model is really simple, check the model shows the same as the previous design - the bottom face is an overhang face. It seems that adding solidify to a shape leads to this problem. I don't know how can I fix this problem. Changing the overhang parameter fixes the overhang problem but it seems that this not a good idea for printing models.</p> <p>Unfortunately, I can not test the print myself as I do not have a printer myself and I need to outsource the print job.</p>
<p>Overhangs that are substantially greater than 45° to the vertical generally require supports, and overhangs of 90° will definitely require supports, unless they are bridges (supported at both ends). Depending on how well you have your printer and filament "dialled in", it is possible to print overhangs up to 70° without supports. However, if your model is a simple cube, it will have no overhangs, so it doesn't really matter what value you give the overhang parameter. Supports are usually generated when the model is sliced, but some modelling software will generate supports as part of the model.</p>
<p>Overhangs that are substantially greater than 45° to the vertical generally require supports, and overhangs of 90° will definitely require supports, unless they are bridges (supported at both ends). Depending on how well you have your printer and filament "dialled in", it is possible to print overhangs up to 70° without supports. However, if your model is a simple cube, it will have no overhangs, so it doesn't really matter what value you give the overhang parameter. Supports are usually generated when the model is sliced, but some modelling software will generate supports as part of the model.</p>
1,333
<p>Im searching a tool which allows me to specify some folders as "bookmarks" and than access them on the commandline (on Windows XP) via a keyword. Something like:</p> <pre><code>C:\&gt; go home D:\profiles\user\home\&gt; go svn-project1 D:\projects\project1\svn\branch\src\&gt; </code></pre> <p>I'm currently using a bunch of batch files, but editing them by hand is a daunting task. On Linux there is <a href="http://www.skamphausen.de/software/cdargs/" rel="noreferrer">cdargs</a> or <a href="http://kore-nordmann.de/blog/shell_bookmarks.html" rel="noreferrer">shell bookmarks</a> but I haven't found something on windows.</p> <hr> <p>Thanks for the Powershell suggestion, but I'm not allowed to install it on my box at work, so it should be a "classic" cmd.exe solution.</p>
<p>What you are looking for is called DOSKEY </p> <p>You can use the doskey command to create macros in the command interpreter. For example:</p> <pre><code>doskey mcd=mkdir "$*"$Tpushd "$*" </code></pre> <p>creates a new command "mcd" that creates a new directory and then changes to that directory (I prefer "pushd" to "cd" in this case because it lets me use "popd" later to go back to where I was before)</p> <p>The $* will be replaced with the remainder of the command line after the macro, and the $T is used to delimit the two different commands that I want to evaluate. If I typed:</p> <pre><code>mcd foo/bar </code></pre> <p>at the command line, it would be equivalent to:</p> <pre><code>mkdir "foo/bar"&amp;pushd "foo/bar" </code></pre> <p>The next step is to create a file that contains a set of macros which you can then import by using the /macrofile switch. I have a file (c:\tools\doskey.macros) which defines the commands that I regularly use. Each macro should be specified on a line with the same syntax as above.</p> <p>But you don't want to have to manually import your macros every time you launch a new command interpreter, to make it happen automatically, just open up the registry key </p> <p>HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun and set the value to be doskey /macrofile "c:\tools\doskey.macro". Doing this will make sure that your macros are automatically predefined every time you start a new interpreter.</p> <p>Extra thoughts: - If you want to do other things in AutoRun (like set environment parameters), you can delimit the commands with the ampersand. Mine looks like: set root=c:\SomeDir&amp;doskey /macrofile "c:\tools\doskey.macros" - If you prefer that your AutoRun settings be set per-user, you can use the HKCU node instead of HKLM. - You can also use doskey to control things like the size of the command history. - I like to end all of my navigation macros with \$* so that I can chain things together - Be careful to add quotes as appropriate in your macros if you want to be able to handle paths with spaces in them.</p>
<p>Environment variables?</p> <pre><code>set home=D:\profiles\user\home set svn-project1=D:\projects\project1\svn\branch\src cd %home% </code></pre> <p>On Unix I use this along with popd/pushd/cd - all the time.</p>
5,194
<p>I'm loading a <strong><em>SQL Server 2000</em></strong> database into my new <strong><em>SQL Server 2005</em></strong> <strong><em>instance</em></strong>. <strong><em>As expected, the full-text catalogs don't come with it.</strong> <strong>How can I rebuild them?</em></strong></p> <p>Right-clicking my full text catalogs and hitting "<strong><em>rebuild indexes</em></strong>" just hangs for hours and hours without doing anything, so it doesn't appear to be that simple...</p>
<p>Try it using SQL.</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms189520%28SQL.90%29.aspx" rel="nofollow noreferrer">CREATE FULLTEXT CATALOG</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms176095%28SQL.90%29.aspx" rel="nofollow noreferrer">ALTER FULLTEXT CATALOG</a></li> </ul> <p>Here's an example from Microsoft.</p> <pre><code>--Change to accent insensitive USE AdventureWorks; GO ALTER FULLTEXT CATALOG ftCatalog REBUILD WITH ACCENT_SENSITIVITY=OFF; GO -- Check Accentsensitivity SELECT FULLTEXTCATALOGPROPERTY('ftCatalog', 'accentsensitivity'); GO --Returned 0, which means the catalog is not accent sensitive. </code></pre>
<p>Thanks, that helped because it showed what was wrong: My file paths were different. Here's how I fixed it:</p> <p>1) Load database from SQL 2000 backup</p> <p>2) Set compatibility mode to SQL 2005</p> <pre><code>USE mydb GO ALTER DATABASE mydb SET COMPATIBILITY_LEVEL = 90 GO </code></pre> <p>3) Get the filegroup names</p> <pre><code>SELECT name FROM sys.master_files mf WHERE type = 4 AND EXISTS( SELECT * FROM sys.databases db WHERE db.database_id = mf.database_id AND name = 'mydb') </code></pre> <p>4) Then for each name (I did this in a little script)</p> <pre><code>ALTER DATABASE mydb MODIFY FILE( NAME = {full text catalog name}, FILENAME="N:\ew\path\to\wherever") </code></pre> <p>5) Then collect all the "readable" names of the catalogs:</p> <pre><code>SELECT name FROM sys.sysfulltextcatalogs </code></pre> <p>6) Finally, now you can rebuild each one:</p> <pre><code>ALTER FULLTEXT CATALOG {full text catalog name} REBUILD </code></pre>
7,016
<p>I'm using Flash to play an .flv movieclip on my site, but I want to have the .swf send trigger an event in my javascript when it start loading, starts playing and ends playing.</p> <p>What is the best way to do that in Flash CS3 using Actionscript 3.0 ?</p>
<p>You need to use the "allowScriptAccess" flash variable in the HTML. You probably want to use "sameDomain" as the type. Note that if you go cross-domain, you also need to host a special file on the server called 'crossdomain.xml' which enables such scripting (the flash player will check for this. More info at <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213&amp;sliceId=2" rel="noreferrer">http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213&amp;sliceId=2</a></p> <p>The call is the easy part. :-) In the Flash code, you'll use the ExternalInterface to do the call, as documented here:</p> <p><a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001655.html" rel="noreferrer">http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001655.html</a></p> <p>Short version: you say </p> <blockquote> <p>ExternalInterface.call("javascriptFunction", "argument")</p> </blockquote>
<p>A common way to do this is with the <strong>ExternalInterface</strong> class, which you can use to call JavaScript methods.</p> <p>First define your JavaScript methods, for example:</p> <pre><code>&lt;script language="JavaScript"&gt; function startsPlaying() { // do something when the FLV starts playing } &lt;/script&gt; </code></pre> <p>Then modify your ActionScript to call the JavaScript method at the appropriate time:</p> <pre><code>// inform JavaScript that the FLV has started playing ExternalInterface.call("startsPlaying"); </code></pre> <p>For more information, see the related Flash CS3 <a href="http://livedocs.adobe.com/flash/9.0/main/00000342.html" rel="nofollow noreferrer">documentation</a>.</p>
5,930
<p>We are automating Excel using VB.Net, and trying to place multiple lines of text on an Excel worksheet that we can set to not print. Between these we would have printable reports. We can do this if we add textbox objects, and set the print object setting to false. (If you have another way, please direct me)</p> <p>The code to add a textbox is:</p> <pre><code>ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 145.5, 227.25, 304.5, 21#) </code></pre> <p>but the positioning is in points. We need a way to place it over a specific cell, and size it with the cell. How can we find out where to put it when we just know which cell to put it over?</p>
<p>If you have the cell name or position, you can do:</p> <pre><code>With ActiveSheet .Shapes.AddTextbox msoTextOrientationHorizontal, .Cells(3,2).Left, .Cells(3,2).Top, .Cells(3,2).Width, .Cells(3,2).Height End With </code></pre> <p>This will add a textbox over cell B3. When B3 is resized, the textbox is also.</p>
<p>When you copy &amp; paste a textbox, Excel will place the new textbox over whichever cell is currently selected. So you can achieve this very easily by simply using the VBA copy &amp; paste commands. This can be particularly useful if you are going to be using a lot of very similar textboxes, as you are effectively creating a textbox template.</p>
9,252
<p>What is the best way to keep an asp:button from displaying it's URL on the status bar of the browser? The button is currently defines like this:</p> <pre><code>&lt;asp:button id="btnFind" runat="server" Text="Find Info" onclick="btnFind_Click"&gt; &lt;/asp:button&gt; </code></pre> <p><strong>Update:</strong></p> <p>This appears to be specific to IE7, IE6 and FF do not show the URL in the status bar.</p>
<p>I use FF so never noticed this, but the link does in fact appear in the status bar in IE..</p> <p>I dont think you can overwrite it :( I initially thought maybe setting the ToolTip (al la &quot;title&quot;) property might do it.. Seems it does not..</p> <p>Looking at the source, what appears is nowhere to be found, so I would say this is a <em>browser</em> issue, I don't think you can do anything in code.. :(</p> <h2>Update</h2> <p>Yeah, Looks like IE always posts whatever the form action is.. Can't see a way to override it, as yet..</p> <p>Perhaps try explicitly setting it via JS?</p> <h2>Update II</h2> <p>Done some more Googleing. Don't think there really is a &quot;nice&quot; way of doing it.. Unless you remove the form all together and post data some other way..</p> <p><strong>Is it really worth that much? Generally this just tends to be the page name?</strong></p>
<p>I don't see a link, I see this:</p> <pre><code>javascript:__doPostBack('btn',''); </code></pre> <p><strong>EDIT</strong>: Sorry, was looking at a LinkButton, not an ASP:Button. The ASP:Button shows the forms ACTION element like stated. </p> <p>But, if you are trying to hide the DoPostBackCall, the only way to do that is to directly manipulate window.status with javascript. <strong>The downside is most browsers don't allow this anymore.</strong></p> <p>To do that, in your page_load add:</p> <pre><code>btnFind.Attributes.Add("onmouseover","window.status = '';"); btnFind.Attributes.Add("onmouseout","window.status = '';"); </code></pre>
8,369
<p>I'm trying to improve performance under high load and would like to implement opcode caching. Which of the following should I use?</p> <ul> <li>APC - <a href="http://www.howtoforge.com/apc-php5-apache2-debian-etch" rel="noreferrer">Installation Guide</a></li> <li>eAccelerator - <a href="http://www.howtoforge.com/eaccelerator_php5_debian_etch" rel="noreferrer">Installation Guide</a></li> <li>XCache - <a href="http://www.howtoforge.com/xcache-php5-apache2-debian-etch" rel="noreferrer">Installation Guide</a></li> </ul> <p>I'm also open to any other alternatives that have slipped under my radar.</p> <p>Currently running on a stock Debian Etch with Apache 2 and PHP 5.2</p> <p><strong>[Update 1]</strong></p> <p>HowtoForge installation links added</p> <p><strong>[Update 2]</strong></p> <p>Based on the answers and feedback given, I have tested all 3 implementations using the following Apache JMeter test plan on my application:</p> <ul> <li>Login</li> <li>Access Home Page</li> </ul> <p>With 50 concurrent connections, the results are as follows:</p> <p>No Opcode Caching<br> <img src="https://i.stack.imgur.com/ueCBW.jpg" alt="No Opcode Caching"></p> <p>APC<br> <img src="https://i.stack.imgur.com/ggqC8.jpg" alt="APC"></p> <p>eAccelerator<br> <img src="https://i.stack.imgur.com/puxe5.jpg" alt="eAccelerator"></p> <p>XCache<br> <img src="https://i.stack.imgur.com/GybYH.jpg" alt="XCache"></p> <p>Performance Graph (smaller is better)<br> <img src="https://i.stack.imgur.com/oXTe9.png" alt="Performance Graph"></p> <p>From the above results, eAccelerator has a slight edge in performance compared to APC and XCache. However, what matters most from the above data is that any sort of opcode caching gives a tremendous boost in performance.</p> <p>I have decided to use APC due to the following 2 reasons:</p> <ul> <li>Package is available in official Debian repository</li> <li>More functional control panel</li> </ul> <p>To summarize my experience:</p> <p>Ease of Installation: APC > eAccelerator > XCache<br> Performance: eAccelerator > APC, XCache<br> Control Panel: APC > XCache > eAccelerator</p>
<p>I think the answer might depend on the type of web applications you are running. I had to make this decision myself two years ago and couldn't decide between Zend Optimizer and eAccelerator.</p> <p>In order to make my decision, I used ab (apache bench) to test the server, and tested the three combinations (zend, eaccelerator, both running) and proved that eAccelerator on its own gave the greatest performance.</p> <p>If you have the luxury of time, I would recommend doing similar tests yourself, and making the decision based on your results.</p>
<p>I've been using XCache for more than a year now with no problems at all.</p> <p>I tried to switch to eAccelerator, but ended up with a bunch of segmentation faults (it's less forgiving of errors). The major benefit to eAccelerator is that it's not just an opcode cache, it's also an optimizer.</p> <p>You should fully test out your application with each one of them to make sure there aren't any problems, and then I'd use apachebench to test it under load.</p>
4,834
<p>I am currently running my Tronxy X5s with a MKS Gen L board. So far I have not ran the heat bed over 50 degrees C since I have only printed with PLA so far. I plan to try PETG and/or ABS in the near future and I have a spare power supply 12V/360W laying around. </p> <p>When I first got my printer I purchased <a href="http://www.lerdge.com/prod_view.aspx?TypeId=12&amp;Id=212&amp;FId=t3:12:3" rel="nofollow noreferrer">this</a> external MOSFET board after reading about X5s "upgrades", but so far have not used it.</p> <p><a href="https://i.stack.imgur.com/u6M16.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u6M16.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/QiqlH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QiqlH.jpg" alt="enter image description here"></a></p> <p>My plan is to now run the heat bed using a separate power supply than the one running my control board using the external MOSFET to switch it. Since this power supply will only be powering the bed, I would like to bump up the voltage, via trim-pot somewhere from 12V-15V, to gain some watts per square inch on my heat bed. </p> <p>Will this MOSFET isolate the heat bed circuit from my control board to allow it be ran at a higher voltage? Is it safe to run the power supply/heat bed at a higher voltage than it is rated for a significant amount of time?</p>
<p>Short answer YES. You can run it from a different power supply at a higher voltage. Also it has a PC817 Optical isolator (for some reason) therefore the second power supply and your main board should not be electrically connected at all.</p>
<p>For reference,I done tracing this module as shown. <a href="https://i.stack.imgur.com/ols3z.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ols3z.jpg" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/r8ao6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r8ao6.jpg" alt="enter image description here" /></a> So you can use isolated power supply for load. Also you can use up to 24V without any problem. Edit: This module still work with higher voltage up to 24V. But according to question. Using higher voltage supply more than rated is same as my question <a href="https://3dprinting.stackexchange.com/questions/15263/can-we-apply-more-voltage-to-a-pcb-heated-bed-to-get-faster-heating">here</a>. For summary. Adding more voltage to resistive load results to higher current flow. Recheck your wire and connectors for current rate so you will know the limit of voltage you can go with. One more thing, mosfet can fail like short circuit. At this situation the temperature of bed cannot be controlled. At normal voltage rate even we left the bed connected to power supply the temperature will rising to about 100C if you add more voltage it will go higher than that can the heated bed will broken or burned or start to fires</p>
1,261
<p>Wouldn't it be better to mount lead screws with the motor on top and the bottom end unconstrained? Compared to the conventional way (motor on the bottom) the lead screw would be under constant tension rather than compression and any misalignment would always be &quot;pulled straight&quot; and in this way minimize z-wobble.</p> <p>Here is a image for clarification:</p> <p><a href="https://i.stack.imgur.com/7hSCU.png" rel="nofollow noreferrer" title="Illustration of wobble in both top and bottom mounted stepper motors with lead screws"><img src="https://i.stack.imgur.com/7hSCU.png" alt="Illustration of wobble in both top and bottom mounted stepper motors with lead screws" title="Illustration of wobble in both top and bottom mounted stepper motors with lead screws" /></a></p> <p>With the motor on top the load of the bed will help to move the lead screw in line with the mount. In the opposite case the load tends to further increase any misalignment.</p>
<p>The motor is mounted in a fixed position no matter if it's on top or bottom. You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compression instead of hanging from the rod.</p> <p>Any forces that might &quot;pull it straight&quot; are the same forces that can cause Z wobble so you would not want to even try to use the misalignment to straighten a bent lead screw.</p> <p>The only thing this that really changes with this orientation is if the lead screw is under tension or compression. Even a relatively thin lead screw can easy counter the forces of gravity and the forces is the same in both directions. Its easy and cheap to make a smooth rod or rail straight but not so easy to make a threaded one straight.</p>
<p>The motor is mounted in a fixed position no matter if it's on top or bottom. You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compression instead of hanging from the rod.</p> <p>Any forces that might &quot;pull it straight&quot; are the same forces that can cause Z wobble so you would not want to even try to use the misalignment to straighten a bent lead screw.</p> <p>The only thing this that really changes with this orientation is if the lead screw is under tension or compression. Even a relatively thin lead screw can easy counter the forces of gravity and the forces is the same in both directions. Its easy and cheap to make a smooth rod or rail straight but not so easy to make a threaded one straight.</p>
2,017
<p>It happens to me all the time. I accidentally version a file, I do not want to be versioned (i.e. developer/machine specific config-files).</p> <p>If I commit this file, I will mess up the paths on all the other developer machines - they will be unhappy.</p> <p>If I do delete the file from versioning, it will be deleted from the other developers machines - they will be unhappy.</p> <p>If I choose to never commit the file, I always have a "dirty" checkout - I am unhappy.</p> <p>Is a clean way to "unversion" a file from revision-control, that will result in no-one being unhappy?</p> <p>edit: trying to clarify a bit: I have already commited the file to the repository and I want to only remove it from versioning - I specifically do not want it to be physically deleted from everyone doing a checkout. I initially wanted it to be ignored.</p> <p>Answer: If I could accept a second answer, it would be <a href="https://stackoverflow.com/questions/27695/how-to-unversion-a-file-in-either-svn-andor-git#27727">this</a>. It answers my question with respect to git - the accepted answer is about svn.</p>
<p>SVN version 1.5 supports removing/deleting a file from a repository with out losing the local file</p> <p>taken from <a href="http://subversion.tigris.org/svn_1.5_releasenotes.html" rel="noreferrer">http://subversion.tigris.org/svn_1.5_releasenotes.html</a> </p> <p>New --keep-local option retains path after delete..</p> <p>Delete (remove) now takes a --keep-local option to retain its targets locally, so paths will not be removed even if unmodified.</p>
<p>As far as I know there is no easy way to remove an added file from versioning control in svn once it is committed.</p> <p>You will have to save the file somewhere else and delete it from version control. Than copy the backup back again.</p> <p>It's a version control system after all... ;)</p>
4,733
<p>What are the best open source (open source and commercial) reporting tools for ASP.NET similar to Crystal Reports for ASP.NET?</p>
<p>Microsoft Reporting Services, <strong>free</strong> and included with SQL Server 2005 and 2008.</p> <p>Of course, this is great if you need a separation of report design and application, which for Enterprise applications is a huge plus.</p> <p>However, if what you want is to be able to create "in application" dashboards, where "you" design the reports and have limited parameters you expose to the user, then I suggest looking into "control" based charting vendors like <a href="http://www.steema.com/" rel="noreferrer">TeeChart</a> . </p> <p>Pros/cons of each strategy: Crystal/Microsoft Reporting services will give you out of the box handling of things like report scheduling, export to excel and pdf, and separation between application and report design. The independent charting tools you can get give you better control, they render better on any size you need, easier to grammatically manipulate and can handle eye candy such as flash based (no flash charts in MS SSRS)</p>
<p>As much as I despise Crystal Reports (we describe digging deep into it the seven layers of Crystal hell) -- it seems to be the best/most-flexible tool for the job. I hope someone comes along and knocks them off the block though. </p> <p>Microsoft Reporting Services is an alternative, but didn't have the features we needed.</p>
4,352
<p>I'm thinking this might be a quick and easy way to lower the form spam on our site just a little bit. The idea being that (I have read) spammers aren't running with javascript enabled. (Or at least they are accessing your website without running javascript. I.e., they aren't browsing up to it in IE or FF.</p> <p>I can use .asp or .aspx.</p>
<p>The simplest way is to set a cookie via javascript and check for it on postback.However, if you're looking to minimize spam you should actually have the browser perform a simple task which requires javascript execution. See Phil Haack's "Invisibile Captcha Validator" control, which has since been included in his Subkismet library: <a href="http://haacked.com/archive/2006/09/26/Lightweight_Invisible_CAPTCHA_Validator_Control.aspx" rel="noreferrer">http://haacked.com/archive/2006/09/26/Lightweight_Invisible_CAPTCHA_Validator_Control.aspx</a></p>
<p>I see you've accepted the <code>noscript</code> answer, but how will you use this to fight spam? <code>noscript</code> will allow you to add special content for users without JS, but unless you're generating the rest of your site in JS, it will still be available to user agents without JS.</p> <p>A captcha of some sort is still likely the best bet. Ultimately, you're trying to get the user agent to prove that it's being controlled by a human, so do your best to make it prove that actual fact, instead of something else. Screen readers for the visually impaired typically go without Javascript, too, and many people browsing from mobile devices have Javascript disabled to speed things up.</p>
7,559
<p>I have a very simple mapping function called "BuildEntity" that does the usual boring "left/right" coding required to dump my reader data into my domain object. (shown below) My question is this - If I don't bring back every column in this mapping as is, I get the "System.IndexOutOfRangeException" exception and wanted to know if ado.net had anything to correct this so I don't need to bring back every column with each call into SQL ... </p> <p>What I'm really looking for is something like "IsValidColumn" so I can keep this 1 mapping function throughout my DataAccess class with all the left/right mappings defined - and have it work even when a sproc doesn't return every column listed ...</p> <pre><code>Using reader As SqlDataReader = cmd.ExecuteReader() Dim product As Product While reader.Read() product = New Product() product.ID = Convert.ToInt32(reader("ProductID")) product.SupplierID = Convert.ToInt32(reader("SupplierID")) product.CategoryID = Convert.ToInt32(reader("CategoryID")) product.ProductName = Convert.ToString(reader("ProductName")) product.QuantityPerUnit = Convert.ToString(reader("QuantityPerUnit")) product.UnitPrice = Convert.ToDouble(reader("UnitPrice")) product.UnitsInStock = Convert.ToInt32(reader("UnitsInStock")) product.UnitsOnOrder = Convert.ToInt32(reader("UnitsOnOrder")) product.ReorderLevel = Convert.ToInt32(reader("ReorderLevel")) productList.Add(product) End While </code></pre>
<p>Also check out this <a href="http://www.madprops.org/blog/another-idbcommand-extension-fill/" rel="noreferrer">extension method I wrote</a> for use on data commands:</p> <pre><code>public static void Fill&lt;T&gt;(this IDbCommand cmd, IList&lt;T&gt; list, Func&lt;IDataReader, T&gt; rowConverter) { using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { list.Add(rowConverter(rdr)); } } } </code></pre> <p>You can use it like this:</p> <pre><code>cmd.Fill(products, r =&gt; r.GetProduct()); </code></pre> <p>Where "products" is the IList&lt;Product&gt; you want to populate, and "GetProduct" contains the logic to create a Product instance from a data reader. It won't help with this specific problem of not having all the fields present, but if you're doing a lot of old-fashioned ADO.NET like this it can be quite handy.</p>
<p>Why don't you use LinqToSql - everything you need is done automatically. For the sake of being general you can use any other <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" rel="nofollow noreferrer">ORM tool</a> for .NET</p>
4,218
<p>I am having a few problems with my BLTouch. I have calibrated it several times using different methods and get the nozzle being 1.3&nbsp;mm lower than the BLTouch pin so a Z offset of -1.3&nbsp;mm. This works fine for auto homing, bed levelling and using code <code>G1 Z0</code> to lower to where needed. However when using Cura to print the nozzle homes exactly as it should then drives the nozzle in to the bed as it starts or tries to start to print and not just a little bit either. Anyone have any ideas?</p> <p>Start G-code is:</p> <pre> G28 ;Home G29 ;Probe G1 Z15.0 F6000 ;Move Platform down 15 mm G92 E0 G1 F200 E3 G92 E0 </pre>
<p>This answer is intended to be a generic answer for Z-offset determination. The question is not clear on how the Z-offset has been determined. It appears as if this distance is measured, while in reality this cannot be measured.</p> <p>A touch (or a inductive or capacitive) probe uses a trigger point to determine the distance of the probe trigger point to the bed print surface. Correct installation is trivial, as is the determination of the nozzle to trigger point definition. For a touch sensor, the probing element is either stowed, fully deployed, or pushed in during leveling up to the point that the trigger point is reached and the probe stowes the rest of the pin, see figure:</p> <p><a href="https://i.stack.imgur.com/wdto7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wdto7.png" alt="BLTouch or 3DTouch sensor Z-offset definition"></a></p> <p>The <code>M851 Zxx.xx</code> offset is determined by lowering the nozzle beyond the trigger point until the nozzle hits a paper sheet. If the stowed position to nozzle distance is used, the distance is too large and the nozzle will dive into the bed on printing.</p>
<p>You should be able to offset this with a <code>G54 Z-1.3</code> - <strong>if your setup accepts these gcodes</strong>. </p> <p>If you do this, always add a <code>G53</code> to the very start and just before the <code>M30</code> to clear all offsets after job finish (or in the event of a cancel, at the start of the next job).</p> <p>I'm not experienced with a wide variety of printers or firmware, but our repetier-based printers (and we use the same controls for our refurbished Fadal CNC machines) use G53-G59:</p> <p><a href="https://www.cnccookbook.com/g54-g92-g52-work-offsets-cnc-g-code/" rel="nofollow noreferrer">As explained in this tutorial from cnccookbook.com</a>:</p> <blockquote> <p>Basic work offsets are very simple to specify: simply enter one of G54, G55, G56, G57, G58, or G59. [...] When you execute the work offset g-code, the XYZ offset will be added to all of your coordinates from that point forward.</p> </blockquote> <p><a href="https://en.wikipedia.org/wiki/G-code" rel="nofollow noreferrer">As detailed on Wikipedia</a>:</p> <blockquote> <p><strong>G54-59</strong>: Have largely replaced position register (G50 and G92). Each tuple of axis offsets relates program zero directly to machine zero. Standard is 6 tuples (G54 to G59), with optional extensibility to 48 more via G54.1 P1 to P48.</p> </blockquote> <p><a href="http://hyrel3d.net/wiki/index.php/Gcode#G54_through_G59_-_Set_Offsets" rel="nofollow noreferrer">And on the gcode dictionary provided by Hyrel 3D</a>:</p> <blockquote> <p><strong>G54 through G59 - Set Offsets</strong> G54, G55, G56, G57, G58, and G59 will each store and invoke offsets in the X, Y, and/or Z axes for all subsequent moves. Any values not invoked will remain with their previous value (0 unless earlier specified otherwise).</p> <ul> <li>X is the offset in mm in the X axis.</li> <li>Y is the offset in mm in the Y axis.</li> <li>Z is the offset in mm in the Z axis.</li> </ul> <p>Here is an example:</p> <p><code>G54 X100 Y-50</code></p> <p>This command is decoded and executed by the printer as follows:</p> <p>G54 (set offsets)<br> - X100 (+100mm to all X coordinates)<br> - Y-50 (-50mm to all Y coordinates)<br></p> <p>Note that this differs from an M6, where the offsets are only applied to a SINGLE tool position.</p> </blockquote> <p><em>Disclaimer: I work for Hyrel 3D.</em></p>
1,466
<p>Does anyone know of a way to find out how much memory an instance of an object is taking?</p> <p>For example, if I have an instance of the following object:</p> <pre><code>TestClass tc = new TestClass(); </code></pre> <p>Is there a way to find out how much memory the instance <code>tc</code> is taking?</p> <p>The reason for asking, is that although C# has built in memory management, I often run into issues with not clearing an instance of an object (e.g. a List that keeps track of something).</p> <p>There are couple of reasonably good memory profilers (e.g. ANTS Profiler) but in a multi-threaded environment is pretty hard to figure out what belongs where, even with those tools. </p>
<p>If you are not trying to do it in code itself, which I'm assuming based on your ANTS reference, try taking a look at CLRProfiler (currently v2.0). It's free and if you don't mind the rather simplistic UI, it can provide valuable information. It will give you a in-depth overview of all kinds of stats. I used it a while back as one tool for finding a memory leek.</p> <p>Download here: <a href="https://github.com/MicrosoftArchive/clrprofiler" rel="nofollow noreferrer">https://github.com/MicrosoftArchive/clrprofiler</a></p> <p>If you do want to do it in code, the CLR has profiling APIs you could use. If you find the information in CLRProfiler, since it uses those APIs, you should be able to do it in code too. More info here: <a href="http://msdn.microsoft.com/de-de/magazine/cc300553(en-us).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/de-de/magazine/cc300553(en-us).aspx</a></p> <p>(It's not as cryptic as using WinDbg, but be prepared to do mighty deep into the CLR.)</p>
<p>I have good experiences with <a href="http://memprofiler.com/" rel="nofollow noreferrer">MemProfiler</a>. It gives you stack traces of when the object was created and all the graphs of why the object is still not garbage collected.</p>
8,584
<p>If it's possible, I'm interested in being able to embed a PostgreSQL database, similar to <a href="http://www.sqlite.org/" rel="noreferrer">sqllite</a>. I've read that it's <a href="http://bytes.com/forum/thread647637.html" rel="noreferrer">not possible</a>. I'm no database expert though, so I want to hear from you.</p> <p>Essentially I want PostgreSQL without all the configuration and installation. If it's possible, tell me how.</p>
<p>Unless you do a major rewrite of code, it is not possible to run Postgres "embedded". Either run it as a separate process or use something else. SQLite is an excellent choice. But there are others. MySQL has an embedded version. See it at <a href="http://mysql.com/oem/" rel="noreferrer">http://mysql.com/oem/</a>. Also several java choices, and Mac has Core Data you can write too. Hell, you can even use FoxPro. What OS you on and what services you need from the database?</p>
<p>Anyone tried on Mac OS X:</p> <p><a href="http://pagesperso-orange.fr/bruno.gaufier/xhtml/prod_postgresql.xhtml" rel="nofollow noreferrer">http://pagesperso-orange.fr/bruno.gaufier/xhtml/prod_postgresql.xhtml</a></p> <p><a href="http://www.macosxguru.net/article.php?story=20041119135924825" rel="nofollow noreferrer">http://www.macosxguru.net/article.php?story=20041119135924825</a></p> <p>(Of course sqlite would be my embedded db of choice as well)</p>
8,515
<p>I have some C# / asp.net code I inherited which has a textbox which I want to make multiline. I did so by adding textmode="multiline" but when I try to insert a newline, the enter key instead submits the form :P</p> <p>I googled around and it seems like the default behavior should be for enter (or control-enter) to insert a newline. Like I said I inherited the code so I'm not sure if there's javascript monkeying around or if there's just a simple asp.net thing I have to do.</p>
<p>It turns out this is a bug with Firefox + ASP.NET where the generated javascript for the defaultButton stuff doesn't work in Firefox. I had to put a replacement for the WebForm_FireDefatultButton function as described <a href="http://forums.asp.net/t/1294544.aspx" rel="nofollow noreferrer">here</a>:</p> <pre><code>function WebForm_FireDefaultButton(event, target) { var element = event.target || event.srcElement; if (event.keyCode == 13 &amp;&amp; !(element &amp;&amp; element.tagName.toLowerCase() == "textarea")) { var defaultButton; if (__nonMSDOMBrowser) { defaultButton = document.getElementById(target); } else { defaultButton = document.all[target]; } if (defaultButton &amp;&amp; typeof defaultButton.click != "undefined") { defaultButton.click(); event.cancelBubble = true; if (event.stopPropagation) { event.stopPropagation(); } return false; } } return true; } </code></pre>
<p>you can use \n for enter key i.e. [a-zA-Z 0-9/.\n]{20,500}</p>
5,011
<p>I've found myself increasingly unsatisfied with the DataSet/DataTable/DataRow paradigm in .Net, mostly because it's often a couple of steps more complicated than what I really want to do. In cases where I'm binding to controls, DataSets are fine. But in other cases, there seems to be a fair amount of mental overhead.</p> <p>I've played a bit with SqlDataReader, and that seems to be good for simple jaunts through a select, but I feel like there may be some other models lurking in .Net that are useful to learn more about. I feel like all of the help I find on this just uses DataSet by default. Maybe that and DataReader really are the best options.</p> <p>I'm not looking for a best/worst breakdown, just curious what my options are and what experiences you've had with them. Thanks!</p> <p>-Eric Sipple</p>
<p>Since .NET 3.5 came out, I've exclusively used LINQ. It's really that good; I don't see any reason to use any of those old crutches any more. </p> <p>As great as LINQ is, though, I think any ORM system would allow you to do away with that dreck.</p>
<p>I NEVER use datasets. They are big heavyweight objects only usable (as someone pointed out here) for "demoware". There are lot's of great alternatives shown here.</p>
3,909
<p><strong>problem solved by resetting cura.</strong></p> <p>I have problems like this: How can I fix this? I can't find the right setting.</p> <p><a href="https://i.stack.imgur.com/2cf9Q.png" rel="nofollow noreferrer" title="No top layer"><img src="https://i.stack.imgur.com/2cf9Q.png" alt="No top layer" title="No top layer"></a></p> <p>Also, what are these yellow lines? Do you know how to remove them? They disappear when I disable to show the brim/raft/skirt.</p> <p><a href="https://i.stack.imgur.com/Bj7Sx.png" rel="nofollow noreferrer" title="Yellow lines #1"><img src="https://i.stack.imgur.com/Bj7Sx.png" alt="Yellow lines #1" title="Yellow lines #1"></a></p> <p><a href="https://i.stack.imgur.com/BnAc4.png" rel="nofollow noreferrer" title="Yellow lines #2"><img src="https://i.stack.imgur.com/BnAc4.png" alt="Yellow lines #2" title="Yellow lines #2"></a></p>
<p>This problem appears when a face is inverted, so the slicer confuses and expect the other wall to close the object. So you need to reverse that face to show the face out and the back face inside the shape to be filled</p> <p><a href="https://i.stack.imgur.com/OklcS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OklcS.png" alt="enter image description here"></a> </p> <p><em>I will edit this answer with more examples</em></p>
<p>I'm pretty sure the yellow lines are showing the full path of the extruder head, including where it's retracted. Somewhere in Cura's maze of menus, there's an option to turn on/off various displays related to the slicing. </p> <p>As to why the top layer isn't there -- most likely it's too thin in your source model. You might try enabling "Print thin walls" options in the Preferences advanced list. BTW, if you post the original STL or CAD file, we might be able to provide more accurate diagnosis.</p>
1,036
<p>I need to programatically determine whether .NET 3.5 is installed. I thought it would be easy:</p> <pre><code>&lt;% Response.Write(Environment.Version.ToString()); %&gt; </code></pre> <p>Which returns "2.0.50727.1434" so no such luck...</p> <p>In my research I have that there are some rather obscure registry keys I can look at but I'm not sure if that is the route to go. Does anyone have any suggestions?</p>
<p>You could try:</p> <pre><code>static bool HasNet35() { try { AppDomain.CurrentDomain.Load( "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); return true; } catch { return false; } } </code></pre> <p>@<a href="https://stackoverflow.com/questions/16178/best-way-to-determine-if-net-35-is-installed#16253">Nick</a>: Good question, I'll try it in a bit. </p> <p>Kev</p>
<p>Without any assembly loading and catching exceptions (which is slow), check for class API changes between 2.0 and 3.5. <a href="http://mono.ximian.com/class-status/2.0-vs-3.5/index.html" rel="nofollow noreferrer">Mono Class Status</a> is very helpful for this. For example you could check for <code>GC.Collect Method (Int32, GCCollectionMode)</code> which is in mscorlib and was added in 3.5 .</p>
3,693
<p>When applying the Single Responsibility Principle and looking at a class's reason to change, how do you determine whether that reason too change is too granular, or not granular enough?</p>
<p>Make liberal use of [SuppressMessage] attribute to begin with. At least at the beginning. Once you get the count to 0 via the attribute, you then put in a rule that new checkins may not introduce FxCop violations. </p> <p>Visual Studio 2008 has a nice code analysis feature that allows you to ensure that code analysis runs on every build and you can treat warnings as errors. That might slow things down a bit so I recommend setting up a continuous integration server (like CruiseControl.NET) and having it run code analysis on every checkin.</p> <p>Once you get it under control and aren't introducing new violations with every checkin, start to tackle whole classes of FxCop violations at a time with the goal of removing the SuppressMessageAttributes that you used.</p> <p>The way to keep track of which ones you really want to keep is to always add a Justification value to the ones you really want to suppress.</p>
<p>An alternative to FxCop would be to use the tool <a href="http://www.ndepend.com/" rel="nofollow noreferrer">NDepend</a>. This tool lets write <strong>Code Rules over C# LINQ Queries</strong> (what we call <a href="http://www.ndepend.com/Features.aspx#CQL" rel="nofollow noreferrer">CQLinq</a>). <em>Disclaimer: I am one of the developers of the tool</em></p> <p>More than <a href="http://www.ndepend.com/DefaultRules/webframe.html" rel="nofollow noreferrer">200 code rules</a> are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the <em>well-known</em> C# LINQ syntax.</p> <p>To keep the number of false-positives low, CQLinq offers the unique capabilities to define what is the set <strong>JustMyCode</strong> through special code queries prefixed with <strong>notmycode</strong>. More explanations about this feature can be found <a href="http://www.ndepend.com/Doc_CQLinq_Syntax.aspx#NotMyCode" rel="nofollow noreferrer">here</a>. Here are for example two <em>notmycode</em> default queries:</p> <ul> <li><a href="http://www.ndepend.com/DefaultRules/webframe.html?Q_Discard_generated_and_designer_Methods_from_JustMyCode.html" rel="nofollow noreferrer">Discard generated and designer Methods from JustMyCode</a></li> <li><a href="http://www.ndepend.com/DefaultRules/webframe.html?Q_Discard_generated_Types_from_JustMyCode.html" rel="nofollow noreferrer">Discard generated Types from JustMyCode</a></li> </ul> <p>To keep the number of false-positives low, with CQLinq you can also focus rules result only on code added or code refactored, since a <a href="http://www.ndepend.com/Doc_CI_Diff.aspx" rel="nofollow noreferrer">defined baseline in the past</a>. See the following rule, that detect methods too complex added or refactored since the baseline:</p> <pre><code>warnif count &gt; 0 from m in Methods where m.CyclomaticComplexity &gt; 20 &amp;&amp; m.WasAdded() || m.CodeWasChanged() select new { m, m.CyclomaticComplexity } </code></pre> <p>Finally, notice that with NDepend code rules can be verified <a href="http://www.ndepend.com/Doc_VS_CQL.aspx" rel="nofollow noreferrer">live in Visual Studio</a> and at build process time, in a <a href="http://www.ndepend.com/Doc_CI_Report.aspx#CQLRule" rel="nofollow noreferrer">generated HTML+javascript report</a>.</p>
4,664
<p>I would like display something more meaningful that animated gif while users upload file to my web application. What possibilities do I have? </p> <p><em>Edit: I am using .Net but I don't mind if somebody shows me platform agnostic version.</em></p>
<p>Here are a couple of versions of what you're looking for for some common JavaScript toolkits.</p> <ul> <li>Mootools - <a href="http://digitarald.de/project/fancyupload/" rel="noreferrer">http://digitarald.de/project/fancyupload/</a></li> <li>Extjs - <a href="http://extjs.com/learn/Extension:UploadForm" rel="noreferrer">http://extjs.com/learn/Extension:UploadForm</a></li> </ul>
<p>jQuery UI Progressbar - <a href="http://jqueryui.com/demos/progressbar/" rel="nofollow noreferrer">http://jqueryui.com/demos/progressbar/</a></p>
7,219
<p>I have a basic understanding of mock and fake objects, but I'm not sure I have a feeling about when/where to use mocking - especially as it would apply to this scenario <a href="https://stackoverflow.com/questions/37375/how-do-i-unit-test-a-wcf-service"><strong>here</strong></a>.</p>
<p>A unit test should test a single codepath through a single method. When the execution of a method passes outside of that method, into another object, and back again, you have a dependency.</p> <p>When you test that code path with the actual dependency, you are not unit testing; you are integration testing. While that's good and necessary, it isn't unit testing.</p> <p>If your dependency is buggy, your test may be affected in such a way to return a false positive. For instance, you may pass the dependency an unexpected null, and the dependency may not throw on null as it is documented to do. Your test does not encounter a null argument exception as it should have, and the test passes.</p> <p>Also, you may find its hard, if not impossible, to reliably get the dependent object to return exactly what you want during a test. That also includes throwing expected exceptions within tests.</p> <p>A mock replaces that dependency. You set expectations on calls to the dependent object, set the exact return values it should give you to perform the test you want, and/or what exceptions to throw so that you can test your exception handling code. In this way you can test the unit in question easily.</p> <p>TL;DR: Mock every dependency your unit test touches.</p>
<p>You should mock an object when you have a dependency in a unit of code you are trying to test that needs to be "just so". </p> <p>For example, when you are trying to test some logic in your unit of code but you need to get something from another object and what is returned from this dependency might affect what you are trying to test - mock that object.</p> <p>A great podcast on the topic can be found <a href="http://www.hanselminutes.com/default.aspx?showID=43" rel="noreferrer">here</a></p>
5,907
<p>When using Business Objects' CrystalReportViewer control, how can you detect and manually print the report the user has currently drilled into? You can print this automatically using the Print() method of the CrystalReportViewer, but I want to be able to do a manual printing of this report.</p> <p>It is possible to print the main ReportSource of the CrystalReportViewer, but I need to know what report the user has drilled into and then do a manual printing of that particular drill down. Any ideas?</p>
<p>You are after a native SQL query.</p> <p>If you are using JPA the syntax is:</p> <pre><code>Query q = em.createNativeQuery("select foo.* from Foo foo " + "where f.x = max(f.x) over " + "(partition by f.y)", Foo.class); </code></pre> <p>If you need to return multiple types, take a look at the <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/SqlResultSetMapping.html" rel="noreferrer">SQLResultSetMapping</a> annotation.</p> <p>If you're using the the Hibernate API directly:</p> <pre><code>Query q = session.createSQLQuery("select {foo.*} from Foo foo " + "where f.x = max(f.x) over "+ "(partition by f.y)"); q.addEntity("foo", Foo.class); </code></pre> <p>See <a href="http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html#objectstate-querying-nativesql" rel="noreferrer">10.4.4. Queries in native SQL</a> in the Hibernate documentation for more details.</p> <p>In both APIs you can pass in parameters as normal using setParameter. </p>
<p>Another approach would be to use the mapping. Please see this article: <a href="https://forums.hibernate.org/viewtopic.php?f=1&amp;t=998482" rel="nofollow noreferrer">https://forums.hibernate.org/viewtopic.php?f=1&amp;t=998482</a></p> <p>I am against the usage of native SQL queries in Hibernate... you lose the benefits of having a mapping:-)</p>
9,977
<p>This morning I ran into an issue with returning back a text string as result from a Web Service call. the Error I was getting is below</p> <pre><code>************** Exception Text ************** System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'GetFilingTreeXML'. ---&gt; System.InvalidOperationException: There is an error in XML document (1, 9201). ---&gt; System.Xml.XmlException: The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 9201. at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3) at System.Xml.XmlExceptionHelper.ThrowMaxStringContentLengthExceeded(XmlDictionaryReader reader, Int32 maxStringContentLength) at System.Xml.XmlDictionaryReader.ReadString(Int32 maxStringContentLength) at System.Xml.XmlDictionaryReader.ReadString() at System.Xml.XmlBaseReader.ReadElementString() at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderImageServerClientInterfaceSoap.Read10_GetFilingTreeXMLResponse() at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer9.Deserialize(XmlSerializationReader reader) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest) --- End of inner exception stack trace --- </code></pre> <p>I did a search and the results are below: <a href="http://search.yahoo.com/search?p=This+quota+may+be+increased+by+changing+the+MaxStringContentLength+property+on+the+XmlDictionaryReaderQuotas+object+used+when+creating+the+XML+reader." rel="nofollow noreferrer">Search Results</a></p> <p>Most of those are WCF related but were enough to point me in the right direction. I will post answer as reply.</p>
<p>Try this blog post <a href="https://web.archive.org/web/20210128000850/http://geekswithblogs.net/niemguy/archive/2007/12/11/wcf-maxstringcontentlength-maxbuffersize-and-maxreceivedmessagesize.aspx" rel="nofollow noreferrer">here</a>. You can modify the MaxStringContentLength property in the Binding configuration.</p>
<p><a href="http://joewirtley.blogspot.com/2007/08/maximum-string-content-length-and.html" rel="nofollow noreferrer">Jow Wirtley's blog post</a> pointed me in the right direction.</p> <p>All I had to do was update the bindings in the app.config of the client app and it all works now.</p>
9,117
<p>Today I was listening to the <a href="http://www.hanselminutes.com/default.aspx?showID=145" rel="nofollow noreferrer">Hanselminutes show about .NET 3.5 SP1...What's inside</a>, and they twice mentioned the Office 2007-like Ribbon control that is included in Visual Studio 2008 Service Pack 1. </p> <p>I am very interested about this, as I was previously looking at purchasing this from a 3rd party vendor (likely <a href="http://www.devcomponents.com/dotnetbar/ribbon-control.aspx" rel="nofollow noreferrer">DevComponent's DotNetBar</a>). However, I did some research this morning and have found nothing about this control being included for use with C# and WPF. Does anyone know more about the included Ribbon control and whether or not it is available for C# or WPF?</p>
<p>Yeah I did a double-take when I heard them say that too.</p> <p>The ribbon control, along with a DatePicker and DataGrid, are being developed out of band <a href="http://www.codeplex.com/wpf" rel="nofollow noreferrer">over here</a> on CodePlex. I'm not sure why Carl and Scott were suggesting that it was part of the SP1 release.</p> <p><a href="http://blogs.msdn.com/vinsibal/" rel="nofollow noreferrer">Vincent Sibal</a> posts about DataGrid (which is available already in some form) on his blog.</p>
<p>A preview of the WPF Ribbon control was released last week, you can find <a href="http://www.codeplex.com/wpf/Wiki/View.aspx?title=WPF%20Ribbon%20Preview" rel="nofollow noreferrer">here</a></p>
5,404
<p>How should I describe this part which looks like a threaded flange so that I can research replacements? It is the gold piece in the middle of each photo. It is used to create a bed raiser in the FLSUN Cube 3D printer.</p> <p><a href="https://i.stack.imgur.com/iNRcM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iNRcM.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/UGmZd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UGmZd.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/lUqe9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lUqe9.png" alt="enter image description here"></a></p> <p>It gets attached to a motor using a flexible bearing</p>
<p>To the best of my knowledge, it's just called a <strong>lead screw nut</strong> or <strong>lead nut</strong>. The flange and holes for attaching it to a surface are inherent in its role in letting the lead screw move something.</p>
<p>To the best of my knowledge, it's just called a <strong>lead screw nut</strong> or <strong>lead nut</strong>. The flange and holes for attaching it to a surface are inherent in its role in letting the lead screw move something.</p>
1,411
<p>I'm looking for a way to check within <code>pageLoad()</code> if this method is raised during load event because of a postback/async postback or because of being loaded and access the first time.</p> <p>This is similar to <code>Page.IsPostback</code> property within code behind page.</p> <p>TIA, Ricky</p>
<p>One way you could do that is to wire up an Application.Load handler in Application.Init, then have that handler unbind itself after running:</p> <pre><code>Sys.Application.add_init(AppInit); function AppInit() { Sys.Application.add_load(RunOnce); } function RunOnce() { // This will only happen once per GET request to the page. Sys.Application.remove_load(RunOnce); } </code></pre> <p>That will execute after Application.Init. It should be the last thing before pageLoad is called.</p>
<p>You can still use Page.IsPostback during an async call.</p>
6,218
<p>I'm starting a new project here (Windows Forms). What's the best option today for a small (free as in beer) DBMS?</p> <p>I've used SQL Server Express on the past projects, but time and time again I hear people saying that the product from Oracle is faster and more powerful.</p> <p>It will be used in a small company (around 20 users) and will not reach the 4 GB limit any time soon :)</p> <p>I don't want to start a flame war on my first post, so please point me to some link showing a good (and actual) comparison between the 2 products, if possible.</p> <p>PS: I've heard about <a href="http://en.wikipedia.org/wiki/IBM_DB2_Express-C" rel="nofollow noreferrer">IBM DB2 Express</a> too, but I coudn't find any information about it. (Marketing material from IBM doesn't count :) )</p>
<p>I would go for the <strong>SQL Server Express</strong> solution, unless you absolutely have to use a feature in Oracle that SQL Server does not have and you have no usable workaround.</p> <p>Example of Oracle's strengths: </p> <ul> <li>Analytical Functions in Oracle ROCK!</li> <li><a href="http://en.wikipedia.org/wiki/PL/SQL" rel="noreferrer">PL/SQL</a> is better than <a href="http://en.wikipedia.org/wiki/Transact-SQL" rel="noreferrer">T-SQL</a>. </li> <li>If you're going to scale up the system to 1,000's of users all updating the same small dataset </li> <li>You scale upto multi-TB databases, </li> <li>You need to scale to need big numbers of CPU's in your server (over 8). </li> <li>need instant failover (<a href="http://en.wikipedia.org/wiki/Oracle_RAC" rel="noreferrer">RAC</a>)</li> <li>you <em>really cannot</em> afford to lose a transaction.</li> </ul> <p>Maybe you can tell, I'm a big Oracle fan! But I think that Oracle Express is a commercial reaction to SQL Server Express and I don't think Oracle <em>really deep deep down</em> likes it.</p> <ul> <li>You know with SQL Server that there is an upgrade path (SQL Server 2008 is soon) plus service packs.</li> <li>SQL Express is also more "install and forget" than Oracle.</li> <li>and it will integrate better with your IDE (if your using .NET)</li> </ul> <p>In terms of speed, both are going to be lighting quick with such a small dataset size.</p>
<p>Is this any use:</p> <p><a href="https://web.archive.org/web/1/http://downloads.techrepublic%2ecom%2ecom/5138-9592-6028761.html" rel="nofollow noreferrer">https://web.archive.org/web/1/http://downloads.techrepublic%2ecom%2ecom/5138-9592-6028761.html</a></p> <p>NB Registration is required</p>
3,115
<p>On my OS X box, the kernel is a 32-bit binary and yet it can run a 64-bit binary. How does this work?</p> <pre><code>cristi:~ diciu$ file ./a.out ./a.out: Mach-O 64-bit executable x86_64 cristi:~ diciu$ file /mach_kernel /mach_kernel: Mach-O universal binary with 2 architectures /mach_kernel (for architecture i386): Mach-O executable i386 /mach_kernel (for architecture ppc): Mach-O executable ppc cristi:~ diciu$ ./a.out cristi:~ diciu$ echo $? 1 </code></pre>
<p>The CPU can be switched from 64 bit execution mode to 32 bit when it traps into kernel context, and a 32 bit kernel can still be constructed to understand the structures passed in from 64 bit user-space apps.</p> <p>The MacOS X kernel does not directly dereference pointers from the user app anyway, as it resides its own separate address space. A user-space pointer in an ioctl call, for example, must first be resolved to its physical address and then a new virtual address created in the kernel address space. It doesn't really matter whether that pointer in the ioctl was 64 bits or 32 bits, the kernel does not dereference it directly in either case.</p> <p>So mixing a 32 bit kernel and 64 bit binaries can work, and vice-versa. The thing you cannot do is mix 32 bit libraries with a 64 bit application, as pointers passed between them would be truncated. MacOS X supplies more of its frameworks in both 32 and 64 bit versions in each release.</p>
<p>For the kernel to be 64-bit would only bring the effective advantage that kernel extensions (i.e., typically drivers) could be 64-bit. In fact, you'd need to have either all 64-bit kernel extensions, or (as is the case now) all 32-bit ones; they need to be native to the architecture of the running kernel.</p>
7,255
<p>Experienced with Rails / ActiveRecord 2.1.1</p> <ul> <li>You create a first version with (for example) ruby script\generate scaffold product title:string description:text image_url:string</li> <li>This create (for example) a migration file called 20080910122415_create_products.rb</li> <li>You apply the migration with rake db:migrate</li> <li>Now, you add a field to the product table with ruby script\generate migration add_price_to_product price:decimal</li> <li>This create a migration file called 20080910125745_add_price_to_product.rb</li> <li>If you try to run rake db:migrate, it will actually revert the first migration, not apply the next one! So your product table will get destroyed!</li> <li>But if you ran rake alone, it would have told you that one migration was pending</li> </ul> <p>Pls note that applying rake db:migrate (once the table has been destroyed) will apply all migrations in order.</p> <p>The only workaround I found is to specify the version of the new migration as in: </p> <pre><code>rake db:migrate version=20080910125745 </code></pre> <p>So I'm wondering: is this an expected new behavior?</p>
<p>You should be able to use </p> <pre><code>rake db:migrate:up </code></pre> <p>to force it to go forward, but then you risk missing interleaved migrations from other people on your team</p> <p>if you run </p> <pre><code>rake db:migrate </code></pre> <p>twice, it will reapply all your migrations.</p> <p>I encounter the same behavior on windows with SQLite, it might be a bug specific to such an environment.</p> <p><strong>Edit</strong> -- I found why. In the railstie database.rake task you have the following code :</p> <pre><code>desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false." task :migrate =&gt; :environment do ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby end </code></pre> <p>Then in my environment variables I have </p> <pre><code>echo %Version% #=&gt; V3.5.0f </code></pre> <p>in Ruby</p> <pre><code>ENV["VERSION"] # =&gt; V3.5.0f ENV["VERSION"].to_i #=&gt;0 not nil ! </code></pre> <p>thus the rake task calls </p> <pre><code>ActiveRecord::Migrator.migrate("db/migrate/", 0) </code></pre> <p>and in ActiveRecord::Migrator we have : </p> <pre><code>class Migrator#:nodoc: class &lt;&lt; self def migrate(migrations_path, target_version = nil) case when target_version.nil? then up(migrations_path, target_version) when current_version &gt; target_version then down(migrations_path, target_version) else up(migrations_path, target_version) end end </code></pre> <p>Yes, <code>rake db:migrate VERSION=0</code> is the long version for <code>rake db:migrate:down</code> </p> <p><strong>Edit</strong> - I would go update the lighthouse bug but I the super company proxy forbids that I connect there</p> <p>In the meantime you may try to unset Version before you call migrate ...</p>
<p>This is not the expected behaviour. I was going to suggest reporting this as a bug on lighthouse, but I see you've <a href="http://rails.lighthouseapp.com/projects/8994/tickets/1021-rake-dbmigrate-doesnt-detect-new-migration" rel="nofollow noreferrer">already done so</a>! If you provide some more information (including OS/database/ruby version) I will take a look at it. </p>
9,568
<p>What is the difference between Build Solution and Batch Build in Visual Studio 2008?</p>
<p>The key point which seems to be missed in both the existing answers is that batch build allows you to build <em>multiple configurations</em> of each project (e.g. you can build debug <em>and</em> release configurations with a single operation).</p> <p>With a normal build, you have to use the configuration manager to select just one configuration for each project.</p>
<p>Building the solution is the same as batch building all projects. Both methods respect the solution's dependencies.</p>
5,421
<p>We are now using NHibernate to connect to different database base on where our software is installed. So I am porting many SQL Procedures to Oracle.</p> <p>SQL Server has a nice function called DateDiff which takes a date part, startdate and enddate.</p> <p>Date parts examples are day, week, month, year, etc. . . </p> <p>What is the Oracle equivalent?</p> <p>I have not found one do I have to create my own version of it?</p> <p><strong>(update by Mark Harrison)</strong> there are several nice answers that explain Oracle date arithmetic. If you need an Oracle datediff() see Einstein's answer. (I need this to keep spme SQL scripts compatible between Sybase and Oracle.) Note that this question applies equally to Sybase.</p>
<p>I stole most of this from an old tom article a few years ago, fixed some bugs from the article and cleaned it up. The demarcation lines for datediff are calculated differently between oracle and MSSQL so you have to be careful with some examples floating around out there that don't properly account for MSSQL/Sybase style boundaries which do not provide fractional results.</p> <p>With the following you should be able to use MSSQL syntax and get the same results as MSSQL such as SELECT DATEDIFF(dd,getdate(),DATEADD(dd,5,getdate())) FROM DUAL;</p> <p>I claim only that it works - not that its effecient or the best way to do it. I'm not an Oracle person :) And you might want to think twice about using my function macros to workaround needing quotes around dd,mm,hh,mi..etc.</p> <p><strong>(update by Mark Harrison)</strong> added dy function as alias for dd.</p> <pre><code>CREATE OR REPLACE FUNCTION GetDate RETURN date IS today date; BEGIN RETURN(sysdate); END; / CREATE OR REPLACE FUNCTION mm RETURN VARCHAR2 IS BEGIN RETURN('mm'); END; / CREATE OR REPLACE FUNCTION yy RETURN VARCHAR2 IS BEGIN RETURN('yyyy'); END; / CREATE OR REPLACE FUNCTION dd RETURN VARCHAR2 IS BEGIN RETURN('dd'); END; / CREATE OR REPLACE FUNCTION dy RETURN VARCHAR2 IS BEGIN RETURN('dd'); END; / CREATE OR REPLACE FUNCTION hh RETURN VARCHAR2 IS BEGIN RETURN('hh'); END; / CREATE OR REPLACE FUNCTION mi RETURN VARCHAR2 IS BEGIN RETURN('mi'); END; / CREATE OR REPLACE FUNCTION ss RETURN VARCHAR2 IS BEGIN RETURN('ss'); END; / CREATE OR REPLACE Function DateAdd(date_type IN varchar2, offset IN integer, date_in IN date ) RETURN date IS date_returned date; BEGIN date_returned := CASE date_type WHEN 'mm' THEN add_months(date_in,TRUNC(offset)) WHEN 'yyyy' THEN add_months(date_in,TRUNC(offset) * 12) WHEN 'dd' THEN date_in + TRUNC(offset) WHEN 'hh' THEN date_in + (TRUNC(offset) / 24) WHEN 'mi' THEN date_in + (TRUNC(offset) /24/60) WHEN 'ss' THEN date_in + (TRUNC(offset) /24/60/60) END; RETURN(date_returned); END; / CREATE OR REPLACE Function DateDiff( return_type IN varchar2, date_1 IN date, date_2 IN date) RETURN integer IS number_return integer; BEGIN number_return := CASE return_type WHEN 'mm' THEN ROUND(MONTHS_BETWEEN(TRUNC(date_2,'MM'),TRUNC(date_1, 'MM'))) WHEN 'yyyy' THEN ROUND(MONTHS_BETWEEN(TRUNC(date_2,'YYYY'), TRUNC(date_1, 'YYYY')))/12 WHEN 'dd' THEN ROUND((TRUNC(date_2,'DD') - TRUNC(date_1, 'DD'))) WHEN 'hh' THEN (TRUNC(date_2,'HH') - TRUNC(date_1,'HH')) * 24 WHEN 'mi' THEN (TRUNC(date_2,'MI') - TRUNC(date_1,'MI')) * 24 * 60 WHEN 'ss' THEN (date_2 - date_1) * 24 * 60 * 60 END; RETURN(number_return); END; / </code></pre>
<p>YOU Could write a function in oracle for this</p> <pre><code>function datediff( p_what in varchar2, p_d1 in date, p_d2 in date) return number as l_result number; BEGIN select (p_d2-p_d1) * decode( upper(p_what), 'SS', 24*60*60, 'MI', 24*60, 'HH', 24, NULL ) into l_result from dual; return l_result; END; </code></pre> <p>and use it like :</p> <pre><code>DATEDIFF('YYYY-MM-DD', SYSTIMESTAMP, SYSTIMESTAMP) </code></pre>
6,544
<p>I have a table of tags and want to get the highest count tags from the list.</p> <p>Sample data looks like this</p> <pre><code>id (1) tag ('night') id (2) tag ('awesome') id (3) tag ('night') </code></pre> <p>using</p> <pre><code>SELECT COUNT(*), `Tag` from `images-tags` GROUP BY `Tag` </code></pre> <p>gets me back the data I'm looking for perfectly. However, I would like to organize it, so that the highest tag counts are first, and limit it to only send me the first 20 or so.</p> <p>I tried this...</p> <pre><code>SELECT COUNT(id), `Tag` from `images-tags` GROUP BY `Tag` ORDER BY COUNT(id) DESC LIMIT 20 </code></pre> <p>and I keep getting an "Invalid use of group function - ErrNr 1111"</p> <p>What am I doing wrong?</p> <p>I'm using MySQL 4.1.25-Debian</p>
<p>In all versions of MySQL, simply alias the aggregate in the SELECT list, and order by the alias:</p> <pre><code>SELECT COUNT(id) AS theCount, `Tag` from `images-tags` GROUP BY `Tag` ORDER BY theCount DESC LIMIT 20 </code></pre>
<p>Try this query</p> <pre><code> SELECT data_collector_id , count (data_collector_id ) as frequency from rent_flats where is_contact_person_landlord = 'True' GROUP BY data_collector_id ORDER BY count(data_collector_id) DESC </code></pre>
4,765
<p>I need to implement version control, even for just the developing I do at home. I have read about how great subversion is for the past couple of years and was about to dedicate myself to learning this on the side until I heard about Git being the up and coming version control system.</p> <p>Given the situation, should I hold off and see which one comes out on top? What are their relative advantages?</p> <p>One issue I noticed with Git is, there are not many full featured GUIs, which is important to many users on my team.</p> <p>Also, wouldn't mind suggestions on how to get started with one or the other. (tutorials, etc.)</p>
<p>The most important thing about version control is:</p> <p><em><strong>JUST START USING IT</strong></em></p> <p>Not using version control is a horrible idea. If you are not using version control, stop reading right now and start using it.</p> <p>It is very easy to convert from</p> <pre><code>cvs&lt;-&gt;svn&lt;-&gt;git&lt;-&gt;hg </code></pre> <p>It doesn't matter which one you choose. Just pick the easiest one for you to use and start recording the history of your code. You can always migrate to another (D)VCS later.</p> <p>If you are looking for a easy to use GUI look at <a href="http://tortoisesvn.tigris.org/%22TortoiseSVN%22" rel="noreferrer">TortoiseSVN (Windows)</a> and <a href="http://www.versionsapp.com/" rel="noreferrer">Versions (Mac)</a> (Suggested by <a href="https://stackoverflow.com/questions/2658?sort=newest#2708">codingwithoutcomments</a>)</p> <hr /> <p>Edit:</p> <blockquote> <p><a href="https://stackoverflow.com/questions/2658/#2672">pix0r said:</a></p> <p>Git has some nice features, but you won't be able to appreciate them unless you've already used something more standard like CVS or Subversion.</p> </blockquote> <p>This. Using git is pointless if you don't know what version control can do for you.</p> <p>Edit 2:</p> <p>Just saw this link on reddit: <a href="http://www.addedbytes.com/cheat-sheets/subversion-cheat-sheet/" rel="noreferrer">Subversion Cheat Sheet</a>. Good quick reference for the svn command line.</p>
<p>Short answer: Subversion if you're the only one coding it or you're on site with everyone you work with. GIT if you're working with people in different sites and your code base is huge.</p> <p>Subversion is really, really easy to setup and get using. It is also nice because you can do relatively complicated things with it too, like hook it up to Apache and use SSL or plug it into Trac for project management. There's so many tools available for Subversion that it's really a good choice.</p> <p>GIT is much more useful for people who are on large teams working in a distributed environment. Linus T. developed it for the Linux team because he was unsatisfied with the capabilities of traditional repositories. Well worth learning if you ever plan to be working with people on open source projects.</p>
2,477
<p>How do you expose a LINQ query as an ASMX web service? <br> Usually, from the business tier, I can return a typed <code>DataSet</code> or a <code>DataTable</code> which can be serialized for transport over ASMX.</p> <p>How can I do the same for a LINQ query? <br> Is there a way to populate a typed <code>DataSet</code> or a <code>DataTable</code> via a LINQ query?</p> <pre><code>public static MyDataTable CallMySproc() { string conn = &quot;...&quot;; MyDatabaseDataContext db = new MyDatabaseDataContext(conn); MyDataTable dt = new MyDataTable(); // execute a sproc via LINQ var query = from dr in db.MySproc().AsEnumerable select dr; // copy LINQ query resultset into a DataTable -this does not work ! dt = query.CopyToDataTable(); return dt; } </code></pre> <p>How could I put the result set of a LINQ query into a <code>DataSet</code> or a <code>DataTable</code>? <br> Alternatively, can the LINQ query be serializable so that I can expose it as an ASMX web service?</p>
<p>As mentioned in the question, <code>IEnumerable</code> has a <code>CopyToDataTable</code> method:</p> <pre><code>IEnumerable&lt;DataRow&gt; query = from order in orders.AsEnumerable() where order.Field&lt;DateTime&gt;("OrderDate") &gt; new DateTime(2001, 8, 1) select order; // Create a table from the query. DataTable boundTable = query.CopyToDataTable&lt;DataRow&gt;(); </code></pre> <p>Why won't that work for you?</p>
<p>For the sake of completeness, these solutions do not work for EF Core (at least not for EF Core 2.2). Casting to <code>IEnumerable&lt;DataRow&gt;</code>, as suggested in the other answers here, fails. Implementing this class and extension methods worked for me <a href="https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/implement-copytodatatable-where-type-not-a-datarow" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/implement-copytodatatable-where-type-not-a-datarow</a>.</p> <p>Why it's not built into EF Core, I have not idea.</p>
2,236
<p>If I've got a table containing Field1 and Field2 can I generate a new field in the select statement? For example, a normal query would be:</p> <pre><code>SELECT Field1, Field2 FROM Table </code></pre> <p>And I want to also create Field3 and have that returned in the resultset... something along the lines of this would be ideal:</p> <pre><code>SELECT Field1, Field2, Field3 = 'Value' FROM Table </code></pre> <p>Is this possible at all?</p>
<pre><code>SELECT Field1, Field2, 'Value' Field3 FROM Table </code></pre> <p>or for clarity</p> <pre><code>SELECT Field1, Field2, 'Value' AS Field3 FROM Table </code></pre>
<p>Yes - it's very possible, in fact you almost had it! Try:</p> <pre><code>SELECT Field1, Field2, 'Value' AS `Field3` FROM Table </code></pre>
5,994
<p>I'm building a Django project that needs search functionality, and until there's a <code>django.contrib.search</code>, I have to choose a search app. So, which is the best? By "best" I mean...</p> <ul> <li>easy to install / set up</li> <li>has a Django- or at least Python-friendly API</li> <li>can perform reasonably complex searches</li> </ul> <p>Here are some apps I've heard of, please suggest others if you know of any:</p> <ul> <li><a href="http://code.google.com/p/djangosearch/" rel="noreferrer">djangosearch</a></li> <li><a href="http://code.google.com/p/django-sphinx/" rel="noreferrer">django-sphinx</a></li> </ul> <p>I'd also like to avoid using a third-party search engine (like Google SiteSearch), because some of the data I'd like to index is for site members only and should not be public.</p>
<p>Check out <a href="http://haystacksearch.org/" rel="noreferrer">Haystack Search</a> - a new model based search abstraction layer that currently supports <a href="http://xapian.org/" rel="noreferrer">Xapian</a>, <a href="http://lucene.apache.org/solr/" rel="noreferrer">Solr</a> and <a href="https://bitbucket.org/mchaput/whoosh/wiki/Home" rel="noreferrer">Whoosh</a>. Looks like it's well supported and documented.</p>
<p>Thanks Joe,</p> <p>We decided to go with Tsearch2 and a custom postgres adaptor. Tsearch2 does not need an extra process to run, which was convenient since we are on a WebFaction hosting with limited memory... It's not completely done yet, but seems to be a good solution...</p>
7,876
<p>Perl has OOP features, but they are somewhat rarely used. How do you create and use Perl objects with methods and properties?</p>
<p>You should definitely take a look at <a href="http://search.cpan.org/perldoc?Moose" rel="noreferrer"><code>Moose</code></a>.</p> <pre><code>package Point; use Moose; # automatically turns on strict and warnings has 'x' =&gt; (is =&gt; 'rw', isa =&gt; 'Int'); has 'y' =&gt; (is =&gt; 'rw', isa =&gt; 'Int'); sub clear { my $self = shift; $self-&gt;x(0); $self-&gt;y(0); } </code></pre> <p>Moose gives you (among other things) a constructor, accessor methods, and type checking for free! </p> <p>So in your code you can:</p> <pre><code>my $p = Point-&gt;new({x=&gt;10 , y=&gt;20}); # Free constructor $p-&gt;x(15); # Free setter print $p-&gt;x(); # Free getter $p-&gt;clear(); $p-&gt;x(15.5); # FAILS! Free type check. </code></pre> <p>A good starting point is <a href="http://search.cpan.org/perldoc?Moose::Manual" rel="noreferrer"><code>Moose::Manual</code></a> and <a href="http://search.cpan.org/perldoc?Moose::Cookbook" rel="noreferrer"><code>Moose::Cookbook</code></a></p> <p>If you just need the basic stuff you can also use <a href="http://search.cpan.org/perldoc?Mouse" rel="noreferrer"><code>Mouse</code></a> which is not as complete, but without most of the compile time penalty.</p>
<p>On one foot, each class is a package; you establish (multiple, if desired) inheritance by setting the package variable <a href="http://perldoc.perl.org/perltoot.html#Inheritance" rel="nofollow noreferrer">@ISA</a> (preferably at compile time); you create an object from an existing piece of data (often, but not always, an anonymous hash used to store instance variables) with <a href="http://perldoc.perl.org/functions/bless.html" rel="nofollow noreferrer">bless</a>(REFERENCE [, CLASSNAME]); you call object methods like $obj->methodname(@ARGS) and class methods like "CLASSNAME"->methodname(@ARGS). Multiple inheritance method resolution order can be altered using <a href="http://search.cpan.org/perldoc/mro" rel="nofollow noreferrer">mro</a>.</p> <p>Because this is somewhat minimalistic and doesn't force encapsulation, there are many different modules that provide more or different functionality.</p>
2,945
<p>What's the best way to deal with a sharded database in Rails? Should the sharding be handled at the application layer, the active record layer, the database driver layer, a proxy layer, or something else altogether? What are the pros and cons of each?</p>
<p>FiveRuns have a gem named <a href="https://github.com/bpot/data_fabric" rel="nofollow noreferrer">DataFabric</a> that does application-level sharding and master/slave replication. It might be worth checking out.</p>
<p>To my mind, the simplest way is maintain a 1:1 between rails instances and DB shards.</p>
6,583
<p>In a world where manual memory allocation and pointers still rule (Borland Delphi) I need a general solution for what I think is a general problem:</p> <p>At a given moment an object can be referenced from multiple places (lists, other objects, ...). Is there a good way to keep track of all these references so that I can update them when the object is destroyed? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
<p>If you want to notify others of changes you should implement the <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">"Observer Pattern"</a>. Delphi has already done that for you for TComponent descendants. You can call the TComponent.FreeNotification method and have your object be notified when the other component gets destroyed. It does that by calling the Notification method. You can remove yourself from the notification list by calling TComponent.RemoveFreeNotification. Also see <a href="http://delphi.about.com/library/bluc/text/uc083101a.htm" rel="nofollow noreferrer">this page</a>.</p> <p>Most Garbage Collectors do not let you get a list of references, so they won't help in this case. Delphi can do reference counting if you would use interfaces, but then again you need to keep track of the references yourself.</p>
<p>Are you trying to keep track of who's referencing an object so you can clear those references when the object is destroyed, or are you trying to keep track of when it's safe to destroy the object?</p> <p>If the latter then it sounds like you're looking for a garbage collector. I've never dealt with Delphi so I don't know if there are GCs for it you can use, but I'd be surprised if there weren't.</p> <p>If the former then a GC probably wouldn't help. If Delphi supports OOP/inheritence (I honestly don't know if it does) you could do something like this (pseudocode):</p> <pre><code>// Anything that will use one of your tracked objects implements this interface interface ITrackedObjectUser { public void objectDestroyed(TrackedObject o); } // All objects you want to track extends this class class TrackedObject { private List&lt;ITrackedObjectUser&gt; users; public void registerRef(ITrackedObjectUser u) { users.add(u); } public void destroy() { foreach(ITrackedObjectUser u in users) { u.objectDestroyed(this); } } } </code></pre> <p>Basically, whenever you add one of your tracked objects to a collection that collection would register itself with that object. When the object is being destroyed (I figure you'd call destroy() in the object's destructor) then the object signals the collection that it's being destroyed so the collection can do whatever it needs to.</p> <p>Unfortunately, this isn't really a good solution if you want to use build-in collections. You'd have to write your own collection objects (they could just wrap build-in ones though). And it would require to to make sure you're registering everywhere you want to track the object. It's not what I would consider a "happy" solution, though for small projects it probably wouldn't be too bad. I'm mainly hoping this idea will help spawn other ideas. :)</p>
3,874
<p>As the title already states, I'm trying to declare a nested function and return a pointer to that function. I want this function 'not' to return a new function pointer which will return the negation of whatever the original function was.</p> <p>Here is what I have:</p> <pre><code>someType not( someType original ) { int isNot( ListEntry* entry ) { return !original( entry ); } someType resultFunc = calloc( 1024, 1 ); memcpy( resultFunc, &amp;isNot, 1024 ); return resultFunc; } </code></pre> <p>someType is defined as:</p> <pre><code>typedef int(*someType)(ListEntry* entry) </code></pre>
<p>Steve, you have a completely wrong mental model of what is a C function. </p> <pre><code>someType resultFunc = calloc( 1024, 1 ); memcpy( resultFunc, &amp;isNot, 1024 ); </code></pre> <p>From your code fragment, I can surmise that you think that you can copy function's compiled code into a block of memory, and then reuse it. This kind of thing smells of Lisp, except even in lisp you don't do it that way.</p> <p>In fact, when you say "&amp;isNot", you get a pointer to function. Copying the memory that pointer points at is counterproductive - the memory was initialized when you loaded your executable into memory, and it's not changing. In any case, writing someFunc() would cause a core dump, as the heap memory behing someFunc cannot be executed - this protects you from all sorts of viruses.</p> <p>You seem to expect an implementation of closures in C. That implementation is simply not there. Unlike Lisp or Perl or Ruby, C cannot preserve elements of a stack frame once you exited that frame. Even is nested functions are permitted in some compilers, I am sure that you cannot refer to non-global variables from inside those functions. The closes thing to closures is indeed C++ object that stores the state and implements operator(), but it's a completely different approach, and you'd still have to do things manually.</p> <p>Update: <a href="http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Nested-Functions.html#Nested-Functions" rel="noreferrer">here</a> is the relevant portion of GCC documentation. Look for "But this technique works only so long as the containing function (hack, in this example) does not exit."</p>
<p>I'm using GCC.</p> <p>You can turn on nested functions by using the flag:</p> <pre><code>-fnested-functions </code></pre> <p>when you compile.</p>
6,174
<p>I'm currently working on creating a new C# project that needs to interact with an older C++ application. There is an error enumeration that already exists in the C++ app that I need to use in the C# app.</p> <p><em>I don't want to just re declare the enumeration in C# because that could cause sync issues down the line if the files aren't updated together</em>. </p> <p>All that being said my question is this: Is there a way for me to taken an enumeration declared like so:</p> <pre><code>typedef enum { eDEVICEINT_ERR_FATAL = 0x10001 ... } eDeviceIntErrCodes; </code></pre> <p>and use it in a C# program like so:</p> <pre><code>eDeviceIntErrCodes.eDEVICEINT_ERR_FATAL </code></pre>
<p>Check out the PInvoke Interop Assistant tool <a href="http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120" rel="noreferrer">http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120</a>. Its a useful tool for generating PInvoke signatures for native methods. </p> <p>If I feed it your enum it generates this code. There is a command line version of the tool included so you could potentially build an automated process to keep the C# definition of the enum up to date whenever the C++ version changes.</p> <pre><code> public enum eDeviceIntErrCodes { /// eDEVICEINT_ERR_FATAL -> 0x10001 eDEVICEINT_ERR_FATAL = 65537, } </code></pre>
<p>If you had declared the enum like:</p> <pre><code>namespace blah { enum DEVICE_ERR_CODES { eDEVICEINT_ERR_FATAL = 0x10001, eDEVICEINT_ERR_OTHER = 0x10002, }; }</code></pre> <p>and in another file:</p> <pre><code>DEVICE_ERR_CODES eDeviceIntErrCodes;</code></pre> <p>and named the enum file with a .cs extension, you might be able to get it to work. You'd reference it like:</p> <pre><code>DEVICE_ERR_CODES err = DEVICE_ERR_CODES.eDEVICEINT_ERR_FATAL;</code></pre>
3,931
<p>According to the instructions I have read, you use the same output on the printers mainboard to control a 110&nbsp;V heated bed with a solid state relay, as you do to power the 12/24&nbsp;V heated bed that comes with the printer. </p> <p>The relay's datasheet states that its max input current is 25&nbsp;mA, obviously a 12/24&nbsp;V heated bed would draw a lot more than that.</p> <p>How does Marlin know that the heated bed pins are controlling a relay now instead of a bed directly, and therefore should limit their current output?</p> <p>In other words: I am worried that if I just drop in the relay, it will burn up since the board still thinks it needs to supply high current to the bed.</p>
<blockquote> <p>How does Marlin know that the heated bed pins are controlling a relay now instead of a bed directly, and therefore should limit their current output?</p> </blockquote> <p>Marlin does not (need to) know this. Simply put, all Marlin does is switch on/off the <em>voltage</em> at the heated bed output. The amount of current that will flow is a function of the voltage and the device connected. If you connect a heated bed to a 12&nbsp;V voltage, a high current will flow. If you connect your relay to 12&nbsp;V, only a small current will flow.</p> <blockquote> <p>In other words- I am worried that if I just drop in the relay, it will burn up since the board still thinks it needs to supply high current to the bed.</p> </blockquote> <p>You do not need to worry about this. Your question is essentially equivalent to this: "<em>if I replace my 100W incandescent lightbulb with a 1W LED one, do I need to replace the light switch in the wall?</em>" The switch (i.e., your printer board/Marlin) does not care what load is connected to it, so long as it does not exceed the <em>maximum</em> rated current.</p>
<p>There are two current parameters which you are looking at in your instructions for the solid state relay. The first one (the 25mA) is for the <em>control</em> circuit. This is how much amperage the device itself will draw when in operation. The second is for the <em>load</em> circuit. This is the max amperage which can pass through the device.</p> <p>Your <a href="https://pickercomponents.com/pdf/Relays/PCS15.pdf" rel="nofollow noreferrer">instruction sheet</a> shows the device having the ability to work at 10A, 15A, 20A, 25A, or 40A. These are different ratings for the same style of device. When you purchase the device, you'd need to specify which amperage rating you'd want your device to be at. They use the same spec sheet for all five flavors, because they are basically the same thing with the one exception, which is the amp rating.</p>
1,505
<p>I'm looking for a good article on using emacs as C/C++ IDE.</p> <p>Something like Steve Yegge's <a href="http://steve.yegge.googlepages.com/effective-emacs" rel="noreferrer">"Effective emacs"</a>.</p>
<p>No specific article, really, but I've found <a href="http://www.emacswiki.org/cgi-bin/wiki" rel="noreferrer">EmacsWiki</a> to be full of useful information. Consider checking out these entries:</p> <ul> <li><a href="http://www.emacswiki.org/cgi-bin/wiki/CPlusPlus" rel="noreferrer">CPlusPlus</a> as a starting point for many C++-related articles, and</li> <li><a href="http://www.emacswiki.org/cgi-bin/wiki/CppTemplate" rel="noreferrer">CppTemplate</a> to define a template that can give you a good skeleton when you start new files</li> </ul>
<p>I recommend <a href="https://github.com/leoliu/ggtags" rel="nofollow">ggtags</a> and <a href="https://github.com/Sarcasm/irony-mode" rel="nofollow">irony-mode</a>. Other then that you may want to use <a href="https://github.com/syohex/emacs-helm-ag" rel="nofollow">helm-ag</a> to search ("grep") for strings in your codebase.</p>
3,207
<p>What's the best and/or fastest method of doing multijoin queries in Django using the ORM and QuerySet API? </p>
<p>If you are trying to join across tables linked by ForeignKeys or ManyToManyField relationships then you can use the double underscore syntax. For example if you have the following models:</p> <pre><code>class Foo(models.Model): name = models.CharField(max_length=255) class FizzBuzz(models.Model): bleh = models.CharField(max_length=255) class Bar(models.Model): foo = models.ForeignKey(Foo) fizzbuzz = models.ForeignKey(FizzBuzz) </code></pre> <p>You can do something like:</p> <pre><code>Fizzbuzz.objects.filter(bar__foo__name = "Adrian") </code></pre>
<p>Caktus blog has an answer to this: <a href="http://www.caktusgroup.com/blog/2009/09/28/custom-joins-with-djangos-queryjoin/" rel="nofollow noreferrer">http://www.caktusgroup.com/blog/2009/09/28/custom-joins-with-djangos-queryjoin/</a></p> <p>Basically there is a hidden QuerySet.query.join method that allows adding custom joins.</p>
9,819
<p>I have a Monoprice Maker Select Plus (Wanhao Duplicator i3 clone) and I'm having issued with the top layer of my prints. The bottom surface and the sides always come out perfect but my top layer is left with gaps in it. I have tried adjusting the print temperature, flow rate, print speed and layer height all with no success. I use Cura for my slicing software. If anyone knows how to help it'd be much appreciated</p> <p><a href="https://i.stack.imgur.com/MZFpf.jpg" rel="nofollow noreferrer" title="Closeup of failed print"><img src="https://i.stack.imgur.com/MZFpf.jpg" alt="Closeup of failed print" title="Closeup of failed print" /></a></p> <p><a href="https://i.stack.imgur.com/45rzs.jpg" rel="nofollow noreferrer" title="Failed print"><img src="https://i.stack.imgur.com/45rzs.jpg" alt="Failed print" title="Failed print" /></a></p>
<p>This is probably caused by too few top layers in combination with a too low infill percentage. Increase skin layers and increase infill percentage.</p> <p>If you have multiple layers already (at least about 4 for 0.2 mm layer height, for smaller layer heights even more), you might be printing at a too high temperature and or too few part cooling percentage and a too low infill percentage.</p>
<p>To combat the bad top layers, I usually use usually 5 top layers for any model of layer height 0.1 to 0.3 mm. I generally don't print with less than 9 % infill for PLA, which I have found sufficient to support even complex geometry on top.</p> <p>Also, I generally use a mixed setup of layers: the outermost layers I demand as concentric because this is the most beautiful setup, while the lower levels are Zig-Zag patterned, as this gives the best layer-to-wall connection.</p>
1,813
<p>I have an old C library with a function that takes a void**:</p> <pre><code>oldFunction(void** pStuff); </code></pre> <p>I'm trying to call this function from managed C++ (m_pStuff is a member of the parent ref class of type void*):</p> <pre><code>oldFunction( static_cast&lt;sqlite3**&gt;( &amp;m_pStuff ) ); </code></pre> <p>This gives me the following error from Visual Studio:</p> <blockquote> <p>error C2440: 'static_cast' : cannot convert from 'cli::interior_ptr' to 'void **'</p> </blockquote> <p>I'm guessing the compiler is converting the void* member pointer to a cli::interior_ptr behind my back.</p> <p>Any advice on how to do this?</p>
<p>EDIT: Fixed answer, see below.</p> <p>Really you need to know what oldFunction is going to be doing with pStuff. If pStuff is a pointer to some unmanaged data you can try wrapping the definition of m_pStuff with:</p> <pre><code>#pragma unmanaged void* m_pStuff #pragma managed </code></pre> <p>This will make the pointer unmanaged which can then be passed into unmanaged functions. Of course you will not be able to assign any managed objects to this pointer directly. </p> <p>Fundamentally unmanaged and managed pointers are not the same and can't be converted without some sort of glue code that copies the underlying data. Basically managed pointers point to the managed heap and since this is garbage collected the actual memory address they point to can change over time. Unmanaged pointers do not change the memory address without you explicitly doing so. </p> <p>Scratch that, you can't define unmanaged / managed inside a class definition. But this test code seems to work just fine:</p> <pre><code>// TestSol.cpp : main project file. #include "stdafx.h" using namespace System; #pragma unmanaged void oldFunction(void** pStuff) { return; } #pragma managed ref class Test { public: void* m_test; }; int main(array&lt;System::String ^&gt; ^args) { Console::WriteLine(L"Hello World"); Test^ test = gcnew Test(); void* pStuff = test-&gt;m_test; oldFunction(&amp;pStuff); test-&gt;m_test = pStuff; return 0; } </code></pre> <p>Here I copy the pointer out of the managed object first and then pass that in by to the oldFunction. Then I copy the result (probably updated by oldFunction) back into the managed object. Since the managed object is on the managed heap, the compiler won't let you pass a reference to the pointer contained in that object as it may move when the garbage collector runs.</p>
<p>Thanks for the advice, the pointer is to an C style abstract structure which I think if I leave that structure exposed to the managed code is going to cause further pain due to its lack of defined structure. So what I think I will do is wrap the C library in C++ and then wrap the C++ wrapper with managed C++, which will prevent exposing those C structures to managed code.</p>
4,672
<p>First of all, I'm still new to this 3D printing and I've bought myself a second hand Ender 3 with some mods done to it.</p> <p>I've successfully printed with PLA in different colors but after a good first layer the print seems like it is skipping lines.</p> <p>I've already tried to:</p> <ul> <li>Change the nozzle</li> <li>Set the bed level (like a million times)</li> <li>Download calibration files (e.g calibration squares)</li> </ul> <p>I have used Cura with the Ender 3 Pro profile:</p> <ul> <li>I print in PLA at 200 °C</li> <li>A print bed temperature of 60°C</li> <li>Cooling fan at 100%</li> <li>Layer height of 0.2 mm</li> <li>Line width is 0.4 mm from a 0.4 mm nozzle</li> <li>Printing Speed is set to 50 mm/s for walls and 25mm/s for infill</li> <li>Retraction is 6.5 mm/off at 25mm/s</li> </ul> <p>I really don't know how to fix it the bad quality.</p> <p><a href="https://i.stack.imgur.com/SJMBw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SJMBw.jpg" alt="enter image description here" /></a></p>
<p>Many questions on 3D Printing SE are answered, at least by me, not with a &quot;this is the problem&quot;, but instead, this is how I would analyze it.</p> <p>Looking at the picture you supplied, there is something strangely periodic about the under-extrusion in the top visible flat layer.</p> <p>I don't think it is an X or Y axis problem. It is too low-frequency to be an extruder drive problem, such as a slippery drive hobbed gear. It seems too high frequency to be a filament feed problem, unless you are very close to the end of a spool with a small inner diameter. This is less likely because you have printed many things, and I would infer that you have seen this with full spools and empty ones.</p> <p>The Ender 3 looks like a Bowden-fed printer. You are printing PLA, which should work well with Bowden.</p> <p>Temperature variation could also cause this problem. If the nozzle were cooling and heating in an unstable control cycle, where the nozzle is cooler you would find under extrusion and even non-extrusion. This looks compatible with the results.</p> <p>What could cause thermal problems?</p> <ul> <li>Not delivering energy to the heater, perhaps because of a bad connection, or perhaps because of an intermittent heater cartridge</li> <li>Not sensing the temperature correctly, perhaps because of a shorting thermister</li> <li>Thermal control look is out of tune, which I consider unlikely since you haven't messed with it, and in my experience that is pretty forgiving</li> <li>Not conducting heat from the heater to the nozzle, which is unlikely</li> </ul> <p>If you have an infrared thermometer, put a piece of masking tape on the heater (to get a consistent IR emissivity) and monitor the temperature. Is it cooler when under extruding? It might only be a few degrees different, but that could be enough if you are right on the transition temperature.</p> <p>If the temperature is stable, you might try printing 10 degrees hotter, just to see. Some variation is normal, and you might be on the edge.</p> <p>It is possible you have a filament that widely varies in diameter, but for that strong an effect, you would have noticed that the filament was thinner in some places than others.</p> <p>My best suggestion is to look at temperature.</p> <h2>Further Reflection</h2> <p>It is also possible that you have something dragging on the filament spool. I don't like it as a solution, but it is consistent with printing a lot (at the beginning of spools) and then encountering this problem. A problem feeding, although I discounted it in my earlier answer, could could produce a periodic underextrusion if the drag on the spool changes. If the problem was one-time, then it may have been bad winding in the spool so that once per revolution it requires some extra tug to unwind the filament. That tug would reduce the torque available to press the filament through the working side of the printer. There might be extruder jumps (pops, clicks, etc.) coming from the extruder as it skipped steps.</p>
<p>I'd suggest running through basic maintenance. Check</p> <ul> <li>Is the nozzle clean/unblocked? If not clean it out</li> <li>Is the nozzle worn? If so, replace it</li> <li>Is the bowden tube okay in the hot end ? If not, replace, or at least shorten it.</li> <li>Are your e-steps calibrated correctly?<br /> ...etc</li> </ul> <p>Also consider whatever mods were made, and whether they help or not. There's a chance something there was sub-optimal, which is why it was sold off by the previous owner.</p>
1,674
<p>How do I get ms-access to connect (through ODBC) to an ms-sql database as a different user than their Active Directory ID? </p> <p>I don't want to specify an account in the ODBC connection, I want to do it on the ms-access side to hide it from my users. Doing it in the ODBC connection would put me right back in to the original situation I'm trying to avoid.</p> <p>Yes, this relates to a previous question: <a href="http://www.stackoverflow.com/questions/50164/">http://www.stackoverflow.com/questions/50164/</a></p>
<p>I think you can get this to work the way you want it to if you use an <a href="http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForSQLServer" rel="noreferrer">"ODBC DSN-LESS connection"</a></p> <p>If you need to, keep your ODBC DSN's on your users' machines using windows authentication. Give your users read-only access to your database. (If they create a new mdb file and link the tables they'll only be able to read the data.)</p> <p>Create a SQL Login which has read/write permission to your database.</p> <p>Write a VBA routine which loops over your linked tables and resets the connection to use you SQL Login but be sure to use the "DSN-Less" syntax.</p> <pre><code>"ODBC;Driver={SQL Native Client};" &amp; "Server=MyServerName;" &amp; _ "Database=myDatabaseName;" &amp; _ "Uid=myUsername;" &amp; _ "Pwd=myPassword" </code></pre> <p>Call this routine as part of your startup code. </p> <p><strong>A couple of notes about this approach:</strong></p> <ul> <li><p>Access seems to have an issue with the connection info once you change from Read/Write to Read Only and try going back to Read/Write without closing and re-opening the database (mde/mdb) file. If you can change this once at startup to Read/Write and not change it during the session this solution should work.</p></li> <li><p>By using a DSN - Less connection you are able to hide the credentials from the user in code (assuming you're giving them an mde file you should be ok). Normally hard-coding connection strings isn't a good idea, but since you're dealing with an in-house app you should be ok with this approach.</p></li> </ul>
<p>I think you'd have to launch the MS Access process under the account you want to use to connect. There are various tools that let you do this, such as <a href="http://www.joeware.net/freetools/tools/cpau/index.htm" rel="nofollow noreferrer">CPAU</a>. This tool will let you encrypt the password as well.</p>
7,357
<p>I am in the middle of a "discussion" with a colleague about the best way to implement the data layer in a new application.</p> <p>One viewpoint is that the data layer should be aware of business objects (our own classes that represent an entity), and be able to work with that object natively. </p> <p>The opposing viewpoint is that the data layer should be object-agnostic, and purely handle simple data types (strings, bools, dates, etc.)</p> <p>I can see that both approaches may be valid, but my own viewpoint is that I prefer the former. That way, if the data storage medium changes, the business layer doesn't (necessarily) have to change to accommodate the new data layer. It would therefore be a trivial thing to change from a SQL data store to a serialized xml filesystem store.</p> <p>My colleague's point of view is that the data layer shouldn't have to know about object definitions, and that as long as the data is passed about appropriately, that is enough. </p> <p>Now, I know that this is one of those questions that has the potential to start a religious war, but I'd appreciate any feedback from the community on how you approach such things. </p> <p>TIA</p>
<p>It really depends on your view of the world - I used to be in the uncoupled camp. The DAL was only there to supply data to the BAL - end of story.</p> <p>With emerging technologies such as Linq to SQL and Entity Framework becoming a bit more popular, then the line between DAL and BAL have been blurred a bit. In L2S especially your DAL is quite tightly coupled to the Business objects as the object model has a 1-1 mapping to your database field.</p> <p>Like anything in software development there is no right or wrong answer. You need to understand your requirements and future requirments and work from there. I would no more use a Ferrari on the Dakhar rally as I would a Range Rover on a track day.</p>
<p>One trick I've found handy is to have my data layer be "collection agnostic". That is, whenever I want to return a list of objects from my data layer, I get the caller to pass in the list. So instead of this:</p> <pre><code>public IList&lt;Foo&gt; GetFoosById(int id) { ... } </code></pre> <p>I do this:</p> <pre><code>public void GetFoosById(IList&lt;Foo&gt; foos, int id) { ... } </code></pre> <p>This lets me pass in a plain old List if that's all I need, or a more intelligent implementation of IList&lt;T&gt; (like ObservableCollection&lt;T&gt;) if I plan to bind to it from the UI. This technique also lets me return stuff from the method like a ValidationResult containing an error message if one occurred.</p> <p>This still means that my data layer knows about my object definitions, but it gives me one extra degree of flexibility.</p>
3,203
<p>Recently I have been getting some layer shifting starting at layer one. I have had layer shifting at higher layers due to various reasons but mainly for the belts being too loose. But now I am reading that layer shifting can also be caused by belts being too tight.</p> <p>The <a href="https://reprap.org/wiki/Shifted_layers" rel="nofollow noreferrer">RepRap wiki</a> page for layer shifting simply gives the mechanical reason for this as "binding". Can anyone explain what binding means? I thought it meant that the rails were crashing into something but apparently it doesn't. Then I thought it meant that the X and Y axes weren't perfectly perpendicular. </p> <p>Does it mean that the "teeth" of the belts stay "stuck" to the gear for too long when moving in one direction? Why would this happen in one direction and not the other? Because the pulleys/gears are at different heights? Or just because of the belts being tighter? Or one of these reasons?</p> <p>Just trying to understand what its happening so I can debug it for my particular 3D printer. </p>
<p>I think the RepRap wiki is using the word "binding", which translates to <em>"stick together or cause to stick together in a single mass"</em> (from Google dictionary), to indicate that some sort of friction is experienced (as you experience when things are sticking together).</p> <p>When there is too much tension in the belt, pulleys and bearings experience a larger radial force stressing the balls of the bearings and pulley shafts. This causes extra friction for the stepper motor to overcome (as the friction force, tangential, is related to the radial force); this means that the stepper has to work harder and can skip steps (for more insight please read below).</p> <hr> <p>While ball bearings are used to <em>reduce</em> friction (opposed to a bush bearing), each ball has a little friction from a couple of sources according to <a href="https://www.amroll.com/friction-frequency-factors.html" rel="nofollow noreferrer">this reference</a>:</p> <blockquote> <p>The sources of this friction are: slight deformation of the rolling elements and raceways under load, sliding friction of the rolling elements against the cage and guiding surfaces. </p> </blockquote> <p>These effects are generally captured in a single friction coefficient called "&mu;". The relation between friction force (tangential) and bearing loading (radial) is written by <span class="math-container">$$P_{friction}=P_{load} \times \mu$$</span> so the higher the belt tension (<span class="math-container">$P_{load}$</span>), the higher the frictional force (<span class="math-container">$P_{friction}$</span>), the harder the stepper has to work.</p>
<p>It is the bearings that are binding (dragging), due to lateral forces caused by over-tight belts. It may be the bearings in the stepper motors that are binding, but it is more likely to be the bearings in the idler pulleys.</p>
1,423
<p>How do you debug <strong>PHP</strong> scripts?</p> <p>I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in <strong>PHPEclipse</strong> is also quite useful.</p> <p>What is the <strong>best</strong> (in terms of fast and easy) way to debug in phpStorm or any other IDE?</p>
<p>Try <a href="https://eclipse.org/pdt/" rel="noreferrer">Eclipse PDT</a> to setup an Eclipse environment that has debugging features like you mentioned. The ability to step into the code is a much better way to debug then the old method of var_dump and print at various points to see where your flow goes wrong. When all else fails though and all I have is SSH and vim I still <code>var_dump()</code>/<code>die()</code> to find where the code goes south.</p>
<p>+1 for print_r(). Use it to dump out the contents of an object or variable. To make it more readable, do it with a pre tag so you don't need to view source. </p> <pre><code>echo '&lt;pre&gt;'; print_r($arrayOrObject); </code></pre> <p>Also var_dump($thing) - this is very useful to see the type of subthings</p>
2,332
<p>I'm a long-time emacs user, and I'm now working about 1/2 time in Java.</p> <p>What are the best emacs libraries for</p> <ol> <li>Debugging Java</li> <li>Code Completion/Intellisense</li> <li>Javadoc browsing</li> </ol> <p>?</p>
<p>I've used <a href="http://jdee.sourceforge.net/" rel="noreferrer">JDEE</a> on several projects. It handles Code Completion. I've never used it for debugging or browsing docs, but it's a big step up from a basic text editor.</p>
<p>I've had good success with <a href="http://code.google.com/p/jdibug/" rel="nofollow noreferrer">jdibug</a> for debugging Java code with Emacs.</p>
6,236
<p>This is what I've got. It works. But, is there a simpler or better way?</p> <p>One an ASPX page, I've got the download link...</p> <pre><code>&lt;asp:HyperLink ID="HyperLinkDownload" runat="server" NavigateUrl="~/Download.aspx"&gt;Download as CSV file&lt;/asp:HyperLink&gt; </code></pre> <p>And then I've got the Download.aspx.vb Code Behind...</p> <pre><code>Public Partial Class Download Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set header Response.Clear() Response.ContentType = "text/csv" Dim FileName As String = "books.csv" Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName) 'generate file content Dim db As New bookDevelopmentDataContext Dim Allbooks = From b In db.books _ Order By b.Added _ Select b Dim CsvFile As New StringBuilder CsvFile.AppendLine(CsvHeader()) For Each b As Book In Allbooks CsvFile.AppendLine(bookString(b)) Next 'write the file Response.Write(CsvFile.ToString) Response.End() End Sub Function CsvHeader() As String Dim CsvLine As New StringBuilder CsvLine.Append("Published,") CsvLine.Append("Title,") CsvLine.Append("Author,") CsvLine.Append("Price") Return CsvLine.ToString End Function Function bookString(ByVal b As Book) As String Dim CsvLine As New StringBuilder CsvLine.Append(b.Published.ToShortDateString + ",") CsvLine.Append(b.Title.Replace(",", "") + ",") CsvLine.Append(b.Author.Replace(",", "") + ",") CsvLine.Append(Format(b.Price, "c").Replace(",", "")) Return CsvLine.ToString End Function End Class </code></pre>
<p>CSV formatting has some gotchas. Have you asked yourself these questions:</p> <ul> <li>Does any of my data have embedded commas?</li> <li>Does any of my data have embedded double-quotes?</li> <li>Does any of my data have have newlines?</li> <li>Do I need to support Unicode strings?</li> </ul> <p>I see several problems in your code above. The comma thing first of all... you are stripping commas:</p> <pre><code>CsvLine.Append(Format(b.Price, "c").Replace(",", "")) </code></pre> <p>Why? In CSV, you should be surrounding anything which has commas with quotes:</p> <pre><code>CsvLine.Append(String.Format("\"{0:c}\"", b.Price)) </code></pre> <p>(or something like that... my VB is not very good). If you're not sure if there are commas, but put quotes around it. If there are quotes in the string, you need to escape them by doubling them. <code>"</code> becomes <code>""</code>.</p> <pre><code>b.Title.Replace("\"", "\"\"") </code></pre> <p>Then surround this by quotes if you want. If there are newlines in your string, you need to surround the string with quotes... yes, literal newlines <em>are</em> allowed in CSV files. It looks weird to humans, but it's all good.</p> <p>A good CSV writer requires some thought. A good CSV reader (parser) is just plain hard (and no, regex not good enough for parsing CSV... it will only get you about 95% of the way there).</p> <p>And then there is Unicode... or more generally I18N (Internationalization) issues. For example, you are stripping commas out of a formatted price. But that's assuming the price is formatted as you expect it in the US. In France, the number formatting is reversed (periods used instead of commas, and <em>vice versa</em>). Bottom line, use culture-agnostic formatting wherever possible.</p> <p>While the issue here is <em>generating</em> CSV, inevitably you will need to parse CSV. In .NET, the best parser I have found (for free) is <a href="http://www.codeproject.com/KB/database/CsvReader.aspx" rel="noreferrer">Fast CSV Reader</a> on <a href="http://www.codeproject.com" rel="noreferrer">CodeProject</a>. I've actually used it in production code and it is really really fast, and very easy to use!</p>
<p>I use the following method when building a CSV file from a DataTable. ControllerContext is just the reponse stream object where the file is written to. For you it is just going to be the Response object. </p> <pre><code>public override void ExecuteResult(ControllerContext context) { StringBuilder csv = new StringBuilder(10 * Table.Rows.Count * Table.Columns.Count); for (int c = 0; c &lt; Table.Columns.Count; c++) { if (c &gt; 0) csv.Append(","); DataColumn dc = Table.Columns[c]; string columnTitleCleaned = CleanCSVString(dc.ColumnName); csv.Append(columnTitleCleaned); } csv.Append(Environment.NewLine); foreach (DataRow dr in Table.Rows) { StringBuilder csvRow = new StringBuilder(); for(int c = 0; c &lt; Table.Columns.Count; c++) { if(c != 0) csvRow.Append(","); object columnValue = dr[c]; if (columnValue == null) csvRow.Append(""); else { string columnStringValue = columnValue.ToString(); string cleanedColumnValue = CleanCSVString(columnStringValue); if (columnValue.GetType() == typeof(string) &amp;&amp; !columnStringValue.Contains(",")) { cleanedColumnValue = "=" + cleanedColumnValue; // Prevents a number stored in a string from being shown as 8888E+24 in Excel. Example use is the AccountNum field in CI that looks like a number but is really a string. } csvRow.Append(cleanedColumnValue); } } csv.AppendLine(csvRow.ToString()); } HttpResponseBase response = context.HttpContext.Response; response.ContentType = "text/csv"; response.AppendHeader("Content-Disposition", "attachment;filename=" + this.FileName); response.Write(csv.ToString()); } protected string CleanCSVString(string input) { string output = "\"" + input.Replace("\"", "\"\"").Replace("\r\n", " ").Replace("\r", " ").Replace("\n", "") + "\""; return output; } </code></pre>
6,590
<p>I have a 3D printer that I built using CD-ROM drives. It's all set and ready to go but when I generate <code>.stl</code> or <code>.obj</code> files my G-code sender program cannot load it. I have found that Slic3r will export the <code>.stl</code> into G-code but it has the option of changing the <em>G-code flavour</em>, or <em>firmware</em>. </p> <p>My machine is running from an Arduino Uno with Grbl v0.8. </p> <p>So the question is, which firmware setting would be appropriate for my machine that would require the least amount of editing before I can print?</p>
<p>From what I understand, you're trying to partition your object into smaller pieces with the hopes of putting them back together in a manner similar to a Jigsaw puzzle.</p> <p>There are two options that I know of to do this, which requires using OpenSCAD:</p> <ul> <li>The <a href="https://www.thingiverse.com/thing:35834" rel="nofollow noreferrer">PuzzleCut</a> library - This allows you to disassemble your object into a multiple pieces that can be assembled together in a jigsaw puzzle type manner</li> <li>The <a href="https://www.thingiverse.com/thing:310652" rel="nofollow noreferrer">PinCut</a> library - This allows you to disassemble your objects into multiple pieces that than be reassembled using the pins and corresponding holes on the pieces.</li> </ul>
<p>Sorry to put it that way, but does 3D printing the best "tool" for your case? </p> <p>it seems you want to generate a huge flat file when a CnC would be the best to generate a clean and solid part.</p> <p>Otherwise, as others suggets you are looking for a tooling tool.</p>
714
<p>How can I get precompiled headers working with GCC?</p> <p>I have had no luck in my attempts and I haven't seen many good examples for how to set it up. I've tried on <a href="https://en.wikipedia.org/wiki/Cygwin" rel="nofollow noreferrer">Cygwin</a> GCC 3.4.4 and using 4.0 on <a href="https://en.wikipedia.org/wiki/Ubuntu_%28operating_system%29" rel="nofollow noreferrer">Ubuntu</a>.</p>
<p><a href="http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html" rel="noreferrer">Firstly, see the documentation here</a>.</p> <p>You compile headers just like any other file but you put the output inside a file with a suffix of <code>.gch</code>. </p> <p>So for example if you precompile stdafx.h you will have a precompiled header that will be automatically searched for called <code>stdafx.h.gch</code> anytime you include <code>stdafx.h</code></p> <p>Example:</p> <p>stdafx.h:</p> <pre><code>#include &lt;string&gt; #include &lt;stdio.h&gt; </code></pre> <p>a.cpp:</p> <pre><code>#include "stdafx.h" int main(int argc, char**argv) { std::string s = "Hi"; return 0; } </code></pre> <p>Then compile as:</p> <blockquote> <p><code>&gt; g++ -c stdafx.h -o stdafx.h.gch</code><br> <code>&gt; g++ a.cpp</code><br> <code>&gt; ./a.out</code></p> </blockquote> <p>Your compilation will work even if you remove stdafx.h after step 1.</p>
<p>A subtle tip about the file extension that tripped me up, because I wasn't paying close enough attention: the <code>.gch</code> extension is added to the precompiled file's full name; it doesn't replace <code>.h</code>. If you get it wrong, the compiler won't find it and silently does not work.</p> <p>precomp.h =&gt; precomp.<strong>h.gch</strong></p> <p>Not:</p> <p>precomp.h =&gt; precomp.<strong>gch</strong></p> <p>Use GCC's <code>-H</code> to check if it's finding/using it.</p>
8,329
<p>Has anyone ever integrated an external web application with Siebel On-Premise CRM? Note that I'm not talking about Siebel On-Demand SaaS, but their behind-the-firewall product. Specifically, I'm trying to achieve two-way synchronization of CRM objects (contacts, accounts, sales opportunities) between my web application and a customer's internal Siebel setup. Are there any well-known techniques for initiating or receiving external connections from a Siebel On-Premise installation. </p>
<p>Siebel On-Premise offers a wealth of integration options. Start with Siebel Bookshelf and specifically Integration Platform Technologies: Siebel Enterprise Application Integration.</p> <p>For your more static data, have a look at MDM. In this case refer to Siebel Master Data Applications Reference for Industry Applications.</p> <p>Otherwise, webservices or Siebel's prebuilt ASI's offer alternatives. Exchanging XML through webservices which map data to Siebel Integration Objects, which map to Siebel Business Components, is pretty much standard fare from the architectural point-of-view.</p>
<p>Worked on a couple of Siebel projects for my sins. Standard ways to interface include: - Web Services (which I think MoMo was referring to) - you'll need to check with the Siebel app team to see if this is / can be turned on; also, the vanilla services might need to be modified to reflect any modifications to the Siebel data structures; even in Siebel this has become the standard way to interface between web apps - Direct reads from the Siebel database tables (you can't write to them though for very special and sad reasons); fast and no mods required - Direct writes to the Siebel EIM database tables (you can write to them and then get the Siebel Server to run a data-load job); fast, but needs the data-load job to run - I think there is some JBeans support but I don't know if it works or not</p> <p>Drop by the Oracle support site and look for a document called "Overview: Siebel Enterprise Application Integration"</p> <p>OK - so you'll also need to remember that Siebel is a bit weird so you will need a Siebel dev to help you out with understanding what the hell is going on...</p>
9,723
<p>I am trying to implement NTLM authentication on one of our internal sites and everything is working. The one piece of the puzzle I do not have is how to take the information from NTLM and authenticate with Active Directory.</p> <p>There is a <a href="http://www.innovation.ch/personal/ronald/ntlm.html" rel="nofollow noreferrer">good description of NTLM</a> and the <a href="http://us1.samba.org/samba/docs/man/Samba-Developers-Guide/pwencrypt.html" rel="nofollow noreferrer">encryption used for the passwords</a>, which I used to implement this, but I am not sure of how to verify if the user's password is valid.</p> <p>I am using ColdFusion but a solution to this problem can be in any language (Java, Python, PHP, etc).</p> <p>Edit:</p> <p>I am using ColdFusion on Redhat Enterprise Linux. Unfortunately we cannot use IIS to manage this and instead have to write or use a 3rd party tool for this.</p> <hr> <p><strong>Update</strong> - <em>I got this working and here is what I did</em></p> <p>I went with the <a href="http://jcifs.samba.org/" rel="nofollow noreferrer">JCIFS library from samba.org.</a></p> <blockquote> <p>Note that the method below will only work with NTLMv1 and <strong>DOES NOT</strong> work with NTLMv2. If you are unable to use NTLMv1 you can try <a href="http://www.ioplex.com/jespa.html" rel="nofollow noreferrer">Jespa</a>, which supports NTLMv2 but is not open source, or you can use <a href="http://spnego.sourceforge.net" rel="nofollow noreferrer">Kerberos/SPNEGO.</a></p> </blockquote> <p>Here is my web.xml:</p> <pre><code>&lt;web-app&gt; &lt;display-name&gt;Ntlm&lt;/display-name&gt; &lt;filter&gt; &lt;filter-name&gt;NtlmHttpFilter&lt;/filter-name&gt; &lt;filter-class&gt;jcifs.http.NtlmHttpFilter&lt;/filter-class&gt; &lt;init-param&gt; &lt;param-name&gt;jcifs.http.domainController&lt;/param-name&gt; &lt;param-value&gt;dc01.corp.example.com&lt;/param-value&gt; &lt;/init-param&gt; &lt;init-param&gt; &lt;param-name&gt;jcifs.smb.client.domain&lt;/param-name&gt; &lt;param-value&gt;CORP.EXAMPLE.COM&lt;/param-value&gt; &lt;/init-param&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;NtlmHttpFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/admin/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;/web-app&gt; </code></pre> <p>Now all URLs matching <code>/admin/*</code> will require NTLM authentication.</p>
<p>What you're really asking is: Is there any way to validate the "WWW-Authenticate: NTLM" tokens submitted by IE and other HTTP clients when doing Single Sign-On (SSO). SSO is when the user enters their password a "single" time when they do Ctrl-Alt-Del and the workstation remembers and uses it as necessary to transparently access other resources without prompting the user for a password again.</p> <p>Note that Kerberos, like NTLM, can also be used to implement SSO authentication. When presented with a "WWW-Authenticate: Negotiate" header, IE and other browsers will send SPNEGO wrapped Kerberos and / or NTLM tokens. More on this later but first I will answer the question as asked.</p> <p>The only way to validate an NTLMSSP password "response" (like the ones encoded in "WWW-Authenticate: NTLM" headers submitted by IE and other browsers) is with a NetrLogonSamLogon(Ex) DCERPC call with the NETLOGON service of an Active Directory domain controller that is an authority for, or has a "trust" with an authority for, the target account. Additionally, to properly secure the NETLOGON communication, Secure Channel encryption should be used and is required as of Windows Server 2008.</p> <p>Needless to say, there are very few packages that implement the necessary NETLOGON service calls. The only ones I'm aware of are:</p> <ol> <li><p>Windows (of course)</p></li> <li><p>Samba - Samba is a set of software programs for UNIX that implements a number of Windows protocols including the necessary NETLOGON service calls. In fact, Samba 3 has a special daemon for this called "winbind" that other programs like PAM and Apache modules can (and do) interface with. On a Red Hat system you can do a <code>yum install samba-winbind</code> and <code>yum install mod_auth_ntlm_winbind</code>. But that's the easy part - setting these things up is another story.</p></li> <li><p>Jespa - Jespa (<a href="http://www.ioplex.com/jespa.html" rel="noreferrer">http://www.ioplex.com/jespa.html</a>) is a 100% Java library that implements all of the necessary NETLOGON service calls. It also provides implementations of standard Java interfaces for authenticating clients in various ways such as with an HTTP Servlet Filter, SASL server, JAAS LoginModule, etc.</p></li> </ol> <p>Beware that there are a number of NTLM authentication acceptors that do not implement the necessary NETLOGON service calls but instead do something else that ultimately leads to failure in one scenario or another. For example, for years, the way to do this in Java was with the NTLM HTTP authentication Servlet Filter from a project called JCIFS. But that Filter uses a man-in-the-middle technique that has been responsible for a long-standing "hiccup bug" and, more important, it does not support NTLMv2. For these reasons and others it is scheduled to be removed from JCIFS. There are several projects that have been unintentionally inspired by that package that are now also equally doomed. There are also a lot of code fragments posted in Java forums that decode the header token and pluck out the domain and username but do absolutely nothing to actually validate the password responses. Suffice it to say, if you use one of those code fragments, you might as well walk around with your pants down.</p> <p>As I eluded to earlier, NTLM is only one of several Windows Security Support Providers (SSP). There's also a Digest SSP, Kerberos SSP, etc. But the Negotiate SSP, which is also known as SPNEGO, is usually the provider that MS uses in their own protocol clients. The Negotiate SSP actually just negotiates either the NTLM SSP or Kerberos SSP. Note that Kerberos can only be used if both the server and client have accounts in the target domain and the client can communicate with the domain controller sufficiently to acquire a Kerberos ticket. If these conditions are not satisfied, the NTLM SSP is used directly. So NTLM is by no means obsolete.</p> <p>Finally, some people have mentioned using an LDAP "simple bind" as a make-shift password validation service. LDAP is not really designed as an authentication service and for this reason it is not efficient. It is also not possible to implement SSO using LDAP. SSO requires NTLM or SPNEGO. If you can find a NETLOGON or SPNEGO acceptor, you should use that instead.</p> <p>Mike</p>
<p>Hm, I'm not sure what you're trying to accomplish.</p> <p>Usually implementing NTLM on an internal site is as simple as unchecking "Enable Anonymous Access" in "Authentication and Access Control" in the "Directory Security" tab of website properties in IIS. If that is cleared, then your web application users will see a pop-up NTLM dialog.</p> <p>There's no need for you to write any code that interfaces with Active Directory. IIS takes care of the authentication for you.</p> <p>Can you be more specific about what you're trying to do?</p>
4,212
<p>I'm looking for a light version of REST for a Java web application I'm developing. </p> <p>I've looked at RESTlet (www.restlet.org) and the REST plugin for Struts 2, but I haven't made up my mind. I'm leaning towards RESTlet, as it seems to be lighter.</p> <p>Has anyone implemented a RESTful layer without any of the the frameworks or with the frameworks? </p> <p>Any performance issues that you've seen because of the new web layer? </p> <p>Did the introduction of REST added unmanageable or unreasonable complexity to your project? (Some complexity is understandable, but what I mean is just plain overkilling your design just to add REST)</p>
<p>I'm a huge fan of JAX-RS - I think they've done a great job with that specification. I use it on a number of projects and its been a joy to work with. </p> <p>JAX-RS lets you create REST resources using POJOs with simple annotations dealing with the URI mappings, HTTP methods and content negotiation all integrated nicely with dependency injection. There's no complex APIs to learn; just the core REST concepts (URIs, headers/response codes and content negotiation) are required. FWIW JAX-RS is quite Rails-ish from the controller point of view</p> <p>There are a number of JAX-RS implementations out there - see <a href="https://stackoverflow.com/questions/80799/jax-rs-frameworks">this thread for a discussion</a>.</p> <p>My personal recommendation is to use <a href="http://jersey.java.net/" rel="nofollow noreferrer">Jersey</a> as its got the biggest, most active community behind it, has the best features at the time of writing (WADL support, implicit views, spring integration, nice REST client API); though if you are using JBoss/SEAM you might find RESTeasy integrates a little better.</p>
<p>I am working on a REST API for <a href="http://www.gliffy.com" rel="nofollow noreferrer">gliffy.com</a> and we ended up rolling our own. We didn't want to have to bring in Struts 2, Spring, or any other framework. I looked at RESTLet and found it incredibly confusing and over complicated.</p> <p>Apache has an implementation of the JAX-RS spec, but it is not finalized and also has some oddities to it. We're tentatively planning to open source our solution, but that's not for a few months. </p> <p>Rolling your own is easy, though. The Servlet Specification gives you everything you need, and you can easily connect to a database via Hibernate (see <a href="http://www.naildrivin5.com/daveblog5000/?p=39" rel="nofollow noreferrer">http://www.naildrivin5.com/daveblog5000/?p=39</a> for how to set up JPA without using EJB3).</p>
9,184
<p>Basically what I want to do it this: a pdb file contains a location of source files (e.g. <code>C:\dev\proj1\helloworld.cs</code>). Is it possible to modify that pdb file so that it contains a different location (e.g. <code>\more\differenter\location\proj1\helloworld.cs</code>)?</p>
<p>You can use the source indexing feature of the Debugging Tools for Windows, which will save references to the appropriate revisions of the files in your source repository as an alternate stream in the PDB file.</p>
<p>It is certainly possible, as On Freund has already pointed out. But if it is only so that the sources can be located and loaded during debugging, then a better way would be to set the source path correspondingly. Once set in a debugger, it will preemt all hard coded paths inside PDBs.</p> <p> In windbg (for instance): <blockquote> .srcpath+ path_to_source_root </blockquote> or this (in case you're debugging remotely): <blockquote> .lsrcpath+ path_to_source_root </blockquote> </p>
4,763
<p>So I just got my first 3D printer the Ender 3 Pro. My nozzle is a bit too high (first image) and this is what happened after my first test print (second image).</p> <p>I saved for a while to buy this and I’m really upset about this.</p> <p><a href="https://i.stack.imgur.com/x1wNg.jpg" rel="nofollow noreferrer" title="Photo of Ender 3 Pro nozzle well above the build plate"><img src="https://i.stack.imgur.com/x1wNg.jpg" alt="Photo of Ender 3 Pro nozzle well above the build plate" title="Photo of Ender 3 Pro nozzle well above the build plate" /></a></p> <p><a href="https://i.stack.imgur.com/SRbKI.jpg" rel="nofollow noreferrer" title="Photo of a model printed halfway through with 'spaghetti'"><img src="https://i.stack.imgur.com/SRbKI.jpg" alt="Photo of a model printed halfway through with 'spaghetti'" title="Photo of a model printed halfway through with 'spaghetti'" /></a></p> <p><a href="https://i.stack.imgur.com/Gt4h1.jpg" rel="nofollow noreferrer" title="Photo of a model printed halfway through with 'spaghetti' but from the side"><img src="https://i.stack.imgur.com/Gt4h1.jpg" alt="Photo of a model printed halfway through with 'spaghetti' but from the side" title="Photo of a model printed halfway through with 'spaghetti' but from the side" /></a></p> <p><a href="https://i.stack.imgur.com/QrEJo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QrEJo.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/D480L.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D480L.jpg" alt="enter image description here" /></a></p>
<p>Your Z-endstop assembly is clearly too high. Referring to your own first foto you see that the switch on the Z-endstop mount is nearly touching the bottom of the X-Z mounting.</p> <p><a href="https://i.stack.imgur.com/GUPv9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GUPv9.png" alt="enter image description here" /></a></p> <p>You need to adjust the whole mount by loosening the 2 hex key screws and lower the assembly (move in the direction of the blue arrow):</p> <p><a href="https://i.stack.imgur.com/fHmi1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fHmi1.png" alt="enter image description here" /></a> <em><a href="https://m.all3dp.com/2/ender-3-pro-z-offset/" rel="nofollow noreferrer">Source: Larry Wood via All3DP</a></em></p> <p>Before lowering the Z-endstop mount first screw in all the levelling/tramming screws under the build plate/heated bef a little and position the nozzle a little above the build plate; when the mount is fastened you can move the build plate up a little and tram the complete bed surface.</p> <hr /> <p><em><a href="https://www.all3dp.com/2/ender-3-pro-z-offset/" rel="nofollow noreferrer">This All3D article</a> describes the above in more detail, but the basics are covered above.</em></p>
<p>Flash the firmware. If that doesn't fix it then you have a defective printer assuming everything else in your question and comments is correct.</p>
2,106
<p>The <a href="http://msdn.microsoft.com/en-us/library/kx145dw2.aspx" rel="noreferrer">ClientScriptManager.RegisterClientScriptInclude</a> method allows you to register a JavaScript reference with the Page object (checking for duplicates).</p> <p>Is there an equivalent of this method for CSS references?</p> <p>Similar questions apply for <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerclientscriptblock.aspx" rel="noreferrer">ClientScriptManager.RegisterClientScriptBlock</a> and <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerclientscriptresource.aspx" rel="noreferrer">ClientScriptManager.RegisterClientScriptResource</a></p>
<p>Short answer: no. You could certainly roll your own functions (as CMPalmer suggests) to take CSS embedded resources (as Gulzar suggests) and embed them on the page.</p> <p>As a best-practice matter, though, I'm not sure why you would want to do this. If you're making a reusable control that has a lot of CSS styling, my advice would be to just hard-code the class names into the standards-compliant output of your control, and ship the control accompanied by a suggested stylesheet. This gives your users/customers the option of overriding your suggested styles to fit their needs, and in general allows them to manage their CSS setup as they see fit. </p> <p>Separating style from markup is a Good Thing - you're already headed down the right path in avoiding the various built-in ASP.NET style attributes, but you should take it all the way and keep the CSS out of your .dll.</p>
<p>One more thought: You might want to consider "namespacing" your class names to avoid collisions with common class names that your consumers might already be using. E.g.</p> <pre><code>&lt;div class="SmillerControls_Toolbar"&gt; &lt;a class="SmillerControls_Button" ...&gt;...&lt;/a&gt; ... &lt;/div&gt; </code></pre> <p>or you could wrap the whole thing in a single "namespace" class and then write your CSS to that:</p> <pre><code> &lt;div class="SmillerControls"&gt; &lt;div class="Toolbar"&gt; &lt;a class="Button" ...&gt;...&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>your CSS would be like</p> <pre><code> div.SmillerControls div.Toolbar { ... } div.SmillerControls div.Toolbar a.Button { ... } </code></pre>
7,825
<p>I have a Prusa i3 that I am mostly happy with. However, I am seeing these strange artifacts when the extruder moves along one axis in one direction - in particular from the back of the printer towards the front. The extruded lines look uneven and the surface is quite rough, but only in that area and only while the extruder moves in that direction.</p> <p>Here is a recent print that shows this happen. The pieces were printed side by side, and both of them show this on the left hand side, while the right is okay.</p> <p><a href="https://i.stack.imgur.com/MNLHp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/MNLHp.jpg" alt="Left hand side of the print shows uneven and rough lines"></a> </p> <p>I am thinking maybe the extruder tip is slanted (not perpendicular to the bed), which causes some sort of scraping while extruding? What do you think?</p>
<p>In case of such difference in printing in different directions you can check if;</p> <ol> <li>for x and partially z axis <ul> <li>filament is blocked and cannot be pulled as it should</li> <li>spool is blocked</li> </ul></li> <li>for x and y axis <ul> <li>rods on which caret/HB is sliding are parallel</li> <li>timing belt idlers are parallel and they are in a line</li> </ul></li> </ol> <p>Shape of the nozzle or its perpendicularity should not be the case as it's hot and it wipes layer itself.</p> <p>You can also check if it's not an issue of cooling fan. It can vibrate as such.</p> <p>Eventually it could be an issue of cooling itself. Let's assume you have cooling fan at the back and it pushes air to the front then when caret moves from the front to the back then cooling time is longer than when the fan goes in opposite direction.</p>
<p>In my case, there were some artifacts only on the right side, and the problem was that the screw was partly out of the pulley under the bed. I would suggest moving the bed to the back and checking the pulley. You might also consider <a href="https://help.prusa3d.com/en/guide/maintenance-tips_23200" rel="nofollow noreferrer">cleaning and lubricating the rods</a>, which is what I was doing when I discovered it.</p> <p>Here is an example of the bumps when the pulley was loose (using TPU):</p> <p><a href="https://i.stack.imgur.com/QSrzW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QSrzW.jpg" alt="3d print showing bumps on one side" /></a></p>
283
<p>I'm having trouble getting my MendelMax 2's heatbed <em>not</em> to heat up when I want to print without it. I don't get how multiple sources of control relate to each other (same with extrusion temperatures, actually):</p> <ul> <li><p>Slic3r (1.2.9) has settings under Filament Settings / Filament / Bed, for First layer and Other layers (and groups of settings can be saved).</p></li> <li><p>The pronterface GUI (Printrun-Mac-10Mar2014) has an "Options" panel where you can set "Bed temperature" (actually, two settings, one for PLA and one for ABS -- though I doubt the software can test which filament is loaded!)</p></li> <li><p>The pronterface GUI also has a menu/fill-in labelled "Bed", which works fine to adjust the bed when nothing is printing. The menu there lets you pick from a manually-entered value, "0 (off)", and (apparently) the settings for PLA and ABS from the options panel.</p></li> <li><p>Marlin's Configuration.h has settings for bed minimum and maximum temps (the non-zero minimum seems to be to prevent running the bed when the thermistor isn't working, to avoid unlimited overheating).</p></li> </ul> <p>I recently tried to print some PLA with no bed heat (using blue tape on the glass build plate). I sliced the model with bed heat off in Slic3r; changed the PLA bed temps in the printerface options panel to 0; and picked the PLA setting in the GUI main screen (and also tried setting "0 (off)" manually.</p> <p>When I started to print the object, the bed turned on and stayed on, maintaining 60C.</p> <p>I thought of just unplugging the heatbed, but then I expect the print would never start, since it would try to heat up the bed and never succeed.</p> <p>So how does the decision about which temperature setting to use, <em>really</em> get made? I have the same question about extruder temps, speeds, accelerations, and other things, too -- whose settings are really in charge?</p>
<p>3D printer get the temperature settings from g-code file. The firmware settings for min and max temperature are just safeguards.</p> <p>You should verify instructions within the g-code file. If you are not familiar with g-code, take a look to <a href="https://en.wikipedia.org/wiki/G-code" rel="noreferrer">wikipedia</a>. List of g-code instructions for marlin firmware is <a href="http://reprap.org/wiki/G-code" rel="noreferrer">here</a>.</p> <p>Instruction responsible for setting bed temperature are <a href="http://reprap.org/wiki/G-code#M190:_Wait_for_bed_temperature_to_reach_target_temp" rel="noreferrer">M190</a> and <a href="http://reprap.org/wiki/G-code#M140:_Set_Bed_Temperature_.28Fast.29" rel="noreferrer">M140</a>. Open your g-code file and search for lines containing them. If you delete these lines then the bed temperature will be not set during print. Additionally it means that it is set by your slicer. </p> <p>In <em>Slic3r</em> you should check <em>Printer settings</em> &rarr; <em>Custom G-code</em> &rarr; <em>Start G-code</em> if it contains one of mentioned instructions and possibly remove it.</p>
<p>Sli3er will control the bed temperature during a print. The options in Pronterface can be used to pre-heat the bed and hot end, or to adjust the temperature during a print. </p> <p>The slicer will put the temperatures you set in the filament tab settings into the gcode at the appropriate layers. As the printer reads these codes it will adjust the temperatures. If you manually change the temperature, it will stay at your adjustment until it encounters a line in the gcode file that tells it to change again. Usually this only happens at the start of a print, or at the transition from the first layer to the second layer. </p> <p>When you change the filament settings in Slic3r, they do not save automatically, so if you changed them, closed the program without saving your filament settings, and opened it later, the changes would be lost. </p> <p>The other place where temperature can be changed from is in the custom gcode settings, where you can specify operations to be performed at the start of the print, in between layers, or at the end of the print. Take a look there and make sure that there are no codes to change temperature in any of these fields.</p>
204
<p>I am using PLA and I am looking for ideas on using the <code>Tune</code> option to tune my Prusa i3 MK3 to increase the speed to 300 %.</p> <p>The 300 % speed works perfectly fine for some of the models.</p> <p>However, for some of the flat surfaces, the printer cannot handle the speed. The issues are pointed in the image below:</p> <p><a href="https://i.stack.imgur.com/Hm8p0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hm8p0.jpg" alt="enter image description here" /></a></p> <p>It seems that printer is struggling to supply enough filament.</p> <p>Can I solve the issue by using the <code>Tune</code> menu by changing settings like temperature or flow?</p> <p><strong>Answer:</strong></p> <p>While @dandavis is informative, but this is how I did it:</p> <ul> <li>increasing z offset so nuzzle has enough space to dispense.</li> <li>Increase temperature +10</li> </ul> <p>Please note that this degrades the print quality, but I am just printing a few organizer boxes. Quality is not essential and not something I expect from a 300% speed.</p>
<p>extruder clicking means you're getting backed up, grinding.</p> <ul> <li>Make the hotend hotter so you can melt filament 3X faster than expected; most materials have quite a range; aim high.</li> <li>Slow down the cooling fan; a lot of them can cool the hotend.</li> <li>You have a silicone boot on the nozzle? that will help some.</li> <li>Use a larger diameter nozzle to reduce backpressure and allow thicker layers.</li> <li>Try cranking the feed rate</li> </ul> <p>Lastly, consider that you simply might not get acceptable results pushing speed THAT much.</p>
<p>Changing &quot;Flow&quot; will affect whole print. So even if it helped for the middle part (I doubt), the next it would ruin the print on sides by overextrusion. However: <strong>if sides are printed ok, then why the middle couldn't?</strong> Because walls are printed slower? Indeed, the under-extrusion may quickly rise along with speed because of plastic deformation between extruder gears under pressure and slight slipping, which actually increases with speed. The video &quot;<a href="https://youtu.be/0xRtypDjNvI?t=301" rel="nofollow noreferrer">How fast can your hotend print?</a>&quot; presents experiment on this phenomena and its outcomes.</p> <p>Then we go into master question: <strong>300% of what?</strong> Turning the speed knob during print will override all considerations that slicer took into account during calculations - and defintely override <a href="https://help.prusa3d.com/en/article/max-volumetric-speed_127176" rel="nofollow noreferrer">Max volumetric speed</a>, which is key factor to limit <strong>pressure in the nozzle</strong> (vide clicking noise).</p> <p>The real limit seems to be this middle part of print, and outer part is just cosmetics (probably calculated to print slower because of quality). So if you ensure, that printing these middle surfaces is <strong>planned (in G-Code) with similar speed</strong> as walls, then (at least in theory) you may be able to increase overall speed, playing e.g. only with temperature. (I actually mean the speed of extrusion, so this may not be simple as just setting equal speed for perimeters and infill, but this does not change the conclusion below.)</p> <p>So I say <strong>all it starts in the slicer</strong> software: increase speed there and re-caclulate. This will ensure to not exceed key limitations. Then you may manipulate maximal values in slicer for further experimentation.</p>
1,840
<p>I work for a company whose primary business is not software related. Most documentation for using source control is written with a development team writing for commercial or open source projects in mind. As someone who writes in house software I can say that work is done differently then it would be in a commercial or open source setting. In addition there are stored procedures and database scripts that need to be kept in sync with the code.</p> <p>In particular I am looking to get suggestions on how best to structure the repository with in house software in mind. Most documentation suggests trunk, branches, tags etc. And procedures for keeping production, test and development environments in sync with their respective sections in the repository etc. </p>
<p>Setting up SVN repositories can be tricky only in the sense of how you organize them. Before we setup SVN, I actually RTFM'd the online <a href="http://svnbook.red-bean.com/" rel="nofollow noreferrer">Subversion manual</a> which discusses organizational techniques for repositories and some of the gotchas you should think about in advance, namely what you cannot do after you have created your repositories if you decide to change your mind. I suggest a pass through this manual before setup.</p> <p>For us, as consultants, we do custom and in-house software development as well as some document management through SVN. It was in our interest to create one repository for each client and one for ourselves. Within each repository, we created folders for each project (software or otherwise). This allowed us to segment security access by repository and by client and even by project within a repository. Going deeper, for each software project we created 'working', 'tags' and 'branches' folders. We generally put releases in 'tags' using 'release_w.x.y.z' as the tag for a standard.</p> <p>In your case, to keep sprocs, scripts, and other related documents in synch, you can create a project folder, then under that a 'working' folder, then under that 'code' and next to it 'scripts', etc. Then when you tag the working version for release, you end up tagging it all together.</p> <pre><code>\Repository \ProjectX \Working \Code \Scripts \Notes \Tags \Branches </code></pre> <p>As for non-code, I would suggest a straight folder layout by project or document type (manuals, policies, etc.). Generally with documents and depending on how your company operates, just having the version history/logs is enough.</p> <p>We run SVN on Windows along with <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">WebSVN</a> which is a great open source repository viewer. We use it to give clients web access to their code and it's all driven by the underlying Subversion security. Internally, we use <a href="http://tortoisesvn.tigris.org/" rel="nofollow noreferrer">TortoiseSVN</a> to manage the repositories, commit, update, import, etc.</p> <p>Another thing is that training should be considered an integral part of your deployment. Users new to version control may have a hard time understanding what is going on. We found that giving them functional instructions (do this when creating a project, do this when updating, etc.) was very helpful while they learned the concepts. We created a 'sandbox' repository where users can play all they want with documents and folders to practice, you may find this useful as well to experiment on what policies to establish.</p> <p>Good luck!</p>
<p>As specified in <a href="https://stackoverflow.com/questions/49601/is-there-a-barebones-windows-version-control-system-thats-suitable-for-only-one#49722">this thread</a>, distributed VCSs (git, Mercurial) are a better model than centralized ones, due to branch creation ease, branch merging ease, no need to setup a special server, no need to have network access to work and some other advantages. If you'll work alone the DVCS allows you to incorporate people to your projects if the need arises very easily. </p> <p>Anyhow, answering directly your question, a way to set up SVN would be to have a repository per project and, depending on if stored procedures and scripts and libraries are shared or not, create a directory on each project tree for scripts and stored procedures, or a full repository for the shared code.</p>
7,421
<p>I'm using a Monoprice Maker Select v2 (a Monoprice-branded Wanhao i3 duplicator) and would like to calibrate temperature readings for my hotend.</p> <p>I used a thermal probe on my multimeter to determine the hotend is running about 5 degrees C above it's reported temperature (setting it to 200 degrees reads 205 on the multimeter). I measured this by placing the thermal problem partly into the hole where the printers thermistor resides.</p> <p>I use Marlin 1.9 for firmware and ideally would calibrate it there--I'd prefer the readouts to be accurate rather than relying on offsets to compensate. What's the process for recalibrating the hotend temperature readings?</p>
<p>Unless you are using a calibrated temperature sensor, it is a question what the temperature will be. </p> <p>Actually it doesn't really matter what the temperature exactly is, you just need to find the sweet spot for your filaments on your machine. With respect to reported temperatures by others, your settings may differ a little, but that does not matter. </p>
<p>Temperature from thermosensors gets collected as a resistance value that changes with temperature. The chip in your board decides the temperature from this value based on a temperature-resistance table.</p> <p>If you are using Marlin Firmware, the setting which table is referenced by your machine to get its values is written under the header Thermal Settings inside <code>Confinguration.h</code>.</p>
1,125
<p><br /> I need to send MMS thought a C# application. I have already found 2 interesting components: <a href="http://www.winwap.com" rel="nofollow noreferrer">http://www.winwap.com</a><br /> <a href="http://www.nowsms.com" rel="nofollow noreferrer">http://www.nowsms.com</a></p> <p>Does anyone have experience with other third party components?<br /> Could someone explain what kind of server I need to send those MMS? Is it a classic SMTP Server? </p>
<p>Typically I have always done this using a 3rd party aggregator. The messages are compiled into SMIL, which is the description language for the MMS messages. These are then sent on to the aggregator who will then send them through the MMS gateway of the Network Operator. They are typically charged on a per message basis and the aggregators will buy the messages in a block from the operators.</p> <p>If you are trying to send an MMS message without getting charged then I am not sure how to do this, or if it is possible.</p>
<p>You could use Twilio to accomplish this. You can <a href="https://www.twilio.com/docs/quickstart/csharp/sms/sending-via-rest" rel="nofollow">dive into the docs</a> for specific implementation details but using the <a href="https://www.twilio.com/docs/csharp/install" rel="nofollow">C# helper library</a> the code to send an MMS would look like this:</p> <pre><code> // Send a new outgoing MMS by POSTing to the Messages resource */ client.SendMessage( "YYY-YYY-YYYY", // From number, must be an SMS-enabled Twilio number person.Key, // To number, if using Sandbox see note above // message content string.Format("Hey {0}, Monkey Party at 6PM. Bring Bananas!", person.Value), // media url of the image new string[] {"https://demo.twilio.com/owl.png" } ); </code></pre> <p>Disclaimer: I work for Twilio.</p>
7,769
<p>I am building a 3D printer from scratch, the bed will only move on Z and the head will stay at the top of the printer and move X and Y.</p> <p>How do I modify the Marlin firmware to have the bed lower as it prints instead of lift like most printers.</p>
<p>You can control in Marlin what the direction of the stepper motor is, e.g. my Hypercube CoreXY printer (which has a similar setup like you described) has the following set (in the Marlin <a href="https://github.com/MarlinFirmware/Marlin/blob/2.0.x/Marlin/Configuration.h" rel="nofollow noreferrer"><code>Configuration.h</code></a> file) to ensure the platform raises when it has to decrease height:</p> <pre><code>// Invert the stepper direction. Change (or reverse the motor connector) // if an axis goes the wrong way. #define INVERT_Z_DIR true </code></pre> <p>Furthermore, it matters where the Z endstop is located, e.g. using a bed probe sensor or a min Z endstop, you need to home towards a decreasing height (in the direction of your probe/endstop):</p> <pre><code>// Direction of endstops when homing; 1=MAX, -1=MIN #define Z_HOME_DIR -1 </code></pre> <p>Don't forget to set a max Z height that falls within the printer volume, e.g.:</p> <pre><code>#define Z_MAX_POS 345 </code></pre> <p>If the bed is heavy, you should also prevent the steppers to lose power when not being used, so at least set Z to <code>false</code>:</p> <pre><code>// Disables axis stepper immediately when it's not being used. // WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_Z false </code></pre>
<p>To understand normal commands from a basic printer slicer, all movement commands in g-code are written to be away from the base layer as positive. Note that <em>technically</em> a &quot;lower the bed&quot; printer does violate Orthonormal coordinates unless you either swap X and Y while retaining 0 in the front-left corner or put 0 in the front-right corner, going left for +X (e.g. inverting that motor axis too) and back for -Y.</p> <h1>Hardware</h1> <p>To <em>invert</em> the movement direction of an axis without rewriting the firmware there are two main ways, from mos invasive to easiest:</p> <ul> <li>Mount the actuator &quot;upside-down&quot; as that flips the rotational normal vector.</li> <li>use a left-hand-threaded rod and nut. This does not flip rotation but how rotation affects the bed.</li> <li>alter the stepper cables by &quot;crossing&quot; one of the phases leads. The motor rotates reversed to its commands now.</li> </ul> <p><a href="https://i.stack.imgur.com/miZU6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/miZU6.jpg" alt="enter image description here" /></a></p> <h1>Firmware</h1> <p>In Marlin, you can also just flip the direction of the motor via <code>configuration.h</code> by altering the line from <code>false</code> to <code>true</code>:</p> <pre><code>#define INVERT_Z_DIR true </code></pre>
1,886
<p>This should hopefully be a simple one.</p> <p>I would like to add an extension method to the System.Web.Mvc.ViewPage&lt; T > class.</p> <p>How should this extension method look?</p> <p>My first intuitive thought is something like this:</p> <pre><code>namespace System.Web.Mvc { public static class ViewPageExtensions { public static string GetDefaultPageTitle(this ViewPage&lt;Type&gt; v) { return ""; } } } </code></pre> <p><strong>Solution</strong></p> <p>The general solution is <a href="https://stackoverflow.com/questions/68750/how-do-you-write-a-c-extension-method-for-a-generically-typed-class#68772">this answer</a>.</p> <p>The specific solution to extending the System.Web.Mvc.ViewPage class is <a href="https://stackoverflow.com/questions/68750/how-do-you-write-a-c-extension-method-for-a-generically-typed-class#68802">my answer</a> below, which started from the <a href="https://stackoverflow.com/questions/68750/how-do-you-write-a-c-extension-method-for-a-generically-typed-class#68772">general solution</a>.</p> <p>The difference is in the specific case you need both a generically typed method declaration AND a statement to enforce the generic type as a reference type.</p>
<p>I don't have VS installed on my current machine, but I think the syntax would be:</p> <pre><code>namespace System.Web.Mvc { public static class ViewPageExtensions { public static string GetDefaultPageTitle&lt;T&gt;(this ViewPage&lt;T&gt; v) { return ""; } } } </code></pre>
<p>If you want the extension to only be available for the specified type you simply just need to specify the actual type you will be handling</p> <p>something like...</p> <pre><code>public static string GetDefaultPageTitle(this ViewPage&lt;YourSpecificType&gt; v) { ... } </code></pre> <p>Note intellisense will then only display the extension method when you declare your (in this case) ViewPage with the matching type.</p> <p>Also, best not to use the System.Web.Mvc namespace, I know its convenient to not have to include your namespace in the usings section, but its far more maintainable if you create your own extensions namespace for your extension functions.</p>
9,430
<p>I am familiar with nunit for unit testing of the business layer however I am looking now to automate the test of the win forms gui layer. </p> <p>I have seen <a href="http://watin.sourceforge.net/" rel="noreferrer">watin</a> and the watin recorder for automating tests on web application by accessing the controls and automating them. However I am struggling to find a watin equivalent for windows forms (written in c# or vb.net) preferably that is open source. </p> <p>Does one exist or are all products based on recording mouse and keyboard presses?</p> <p><strong>Update:</strong> I have looked at this <a href="http://blog.benhall.me.uk/2008/02/project-white-automated-ui-testing.html" rel="noreferrer">blog post on white</a> and it seems the sort of thing I am looking for. The blog post raises some issues but as white is only in version 0.6 these may be resolved. Be interested if others have used white or any others for comparison. </p>
<p>Check out <a href="http://www.codeplex.com/white" rel="noreferrer">http://www.codeplex.com/white</a> and <a href="http://nunitforms.sourceforge.net/" rel="noreferrer">http://nunitforms.sourceforge.net/</a>. We've used the White project with success.</p> <p><em>Same Answer to a previous question</em></p> <p><strong>Edit</strong></p> <p>The White project has moved, and is now located on <a href="https://github.com/TestStack/White" rel="noreferrer">GitHub</a> as part of TestStack.</p>
<p>You may also use Winium(<a href="https://github.com/2gis/Winium" rel="nofollow noreferrer">https://github.com/2gis/Winium</a>) that works on multiple Windows platform besides Windows 10 and is similar to Selenium with extra features that support controlling the application remotely.</p>
4,498
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/361635/debugging-javascript-in-ie7">Debugging JavaScript in IE7</a> </p> </blockquote> <p>Firefox has Web Developer plugin and Firebug for troubleshooting html/css/javascript issues. Google Chrome and Safari have a very similar console and right-click options for "Inspect Element".</p> <p>Does IE7 have anything similar for troubleshooting layout/html/css issues?</p>
<p>Yes - The Internet Explorer Developer Toolbar</p> <p><a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=95E06CBE-4940-4218-B75D-B8856FCED535&amp;displaylang=en" rel="noreferrer">Download details: Internet Explorer Developer Toolbar</a></p>
<p>Actually, the best add-on for developers to IE would be <a href="http://www.fiddlertool.com/fiddler/version.asp" rel="nofollow noreferrer">Fiddler</a>. It has a number of features that the other browsers possess.</p>
8,057
<p>I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in .NET using C#. One of the issues I'm running into is getting the timer to "tick" accurately enough.</p> <p>For example, assuming an easy BPM (beats per minute) of 120, the timer should tick every .5 seconds (or 500 milliseconds). Using this as the basis for the ticks, however, isn't entirely accurate as .NET only guarantees that your timer will not tick before the elapsed time has passed.</p> <p>Currently, to get around this for the same 120 BPM example used above, I am setting the ticks to something like 100 milliseconds and only playing the click sound on every 5th timer tick. This does improve the accuracy quite a bit, but if feels like a bit of a hack.</p> <p>So, what is the best way to get accurate ticks? I know there are more timers available than the windows forms timer that is readily available in Visual Studio, but I'm not really familiar with them.</p>
<p>There are three timer classes called 'Timer' in .NET. It sounds like you're using the Windows Forms one, but actually you might find the System.Threading.Timer class more useful - but be careful because it calls back on a pool thread, so you can't directly interact with your form from the callback.</p> <p>Another approach might be to p/invoke to the Win32 multimedia timers - timeGetTime, timeSetPeriod, etc.</p> <p>A quick google found this, which might be useful <a href="http://www.codeproject.com/KB/miscctrl/lescsmultimediatimer.aspx" rel="noreferrer">http://www.codeproject.com/KB/miscctrl/lescsmultimediatimer.aspx</a></p> <p>'Multimedia' (timer) is the buzz-word to search for in this context.</p>
<p>Timer classes can start behaving strangely when the timer 'tick' event code is not finished executing by the time the next 'tick' occurs. One way to combat this is to disable the timer at the beginning of the tick event, then re-enable it at the end.</p> <p>However, this approach is not suitable in cases where the execution time of the 'tick' code is not acceptable error in the timing of the tick, since the timer will be disabled (not counting) during that time.</p> <p>If disabling the timer is an option, then you can also achieve the same effect by creating a separate thread that executes, sleeps for x milliseconds, executes, sleeps, etc...</p>
3,023
<p>I am interested in doing development on Cura. Initially I want to start with the UI rather than the Engine. I have found the <a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">repository</a> and have cloned it to my PC. I have also looked over the <a href="https://github.com/Ultimaker/Cura/wiki" rel="nofollow noreferrer">Wiki</a> and searched the web. For such a popular open-source product, I was surprised I couldn't find a build guide.</p> <p>Can someone direct me on how to get started. I have a LOT of experience in Software Development (more years and languages than I want to admit to); but, I have never used Python. Consider that in your instructions.</p>
<p>As you are an experienced developer, these links should help:</p> <p>This is a related question, but for Ubuntu <a href="https://3dprinting.stackexchange.com/questions/1309/how-to-build-curaengine">How to build CuraEngine?</a></p> <p>Wikipedia has an informative page on <a href="https://en.wikipedia.org/wiki/Cura_(software)" rel="nofollow noreferrer">Cura</a>, which lists the Github development pages:</p> <blockquote> <ul> <li><a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">Cura Github development page</a></li> <li><a href="https://github.com/daid/LegacyCura" rel="nofollow noreferrer">Cura Github legacy (pre-Ultimaker) development page</a></li> <li><a href="https://github.com/Ultimaker/CuraEngine" rel="nofollow noreferrer">Cura slicing engine Github development page</a></li> </ul> </blockquote> <p>Reading the development pages is a good place to start. The <a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">Cura Github development page</a> does contain resources for Windows.</p> <p>The top level Ultimaker <a href="https://github.com/Ultimaker" rel="nofollow noreferrer">Github page</a> contains links to all of the relevant repositories, amongst other useful resources, including:</p> <blockquote> <ul> <li><a href="https://github.com/Ultimaker/CuraEngine" rel="nofollow noreferrer">CuraEngine</a> - CuraEngine is a powerful, fast and robust engine for processing 3D models into 3D printing instruction for Ultimaker and other GCode based 3D printers. It is part of the larger open source project called "Cura".</li> <li><a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">Cura</a> - 3D printer / slicing GUI built on top of the Uranium framework</li> <li><a href="http://cura-build" rel="nofollow noreferrer">cura-build</a> - Build scripts for Cura</li> </ul> </blockquote> <hr> <p>With respect to Python, I, myself, am slowly making my way through this Python tutorial, <a href="https://www.codecademy.com/en/courses/introduction-to-python-6WeG3/0/1" rel="nofollow noreferrer">Python Code Academy</a>. However, there are a many other good Python tutorials out there, the best resource is probably <a href="https://www.python.org/" rel="nofollow noreferrer">Python.org</a>. </p> <p>One thing to note is that Python 2.x and 3.x are markedly different (see <a href="https://wiki.python.org/moin/Python2orPython3" rel="nofollow noreferrer">Should I use Python 2 or Python 3 for my development activity?</a>). <a href="http://learntocodewith.me/programming/python/python-2-vs-python-3/" rel="nofollow noreferrer">What should I learn as a beginner: Python 2 OR Python 3?</a> is also an interesting read.</p>
<p>As you are an experienced developer, these links should help:</p> <p>This is a related question, but for Ubuntu <a href="https://3dprinting.stackexchange.com/questions/1309/how-to-build-curaengine">How to build CuraEngine?</a></p> <p>Wikipedia has an informative page on <a href="https://en.wikipedia.org/wiki/Cura_(software)" rel="nofollow noreferrer">Cura</a>, which lists the Github development pages:</p> <blockquote> <ul> <li><a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">Cura Github development page</a></li> <li><a href="https://github.com/daid/LegacyCura" rel="nofollow noreferrer">Cura Github legacy (pre-Ultimaker) development page</a></li> <li><a href="https://github.com/Ultimaker/CuraEngine" rel="nofollow noreferrer">Cura slicing engine Github development page</a></li> </ul> </blockquote> <p>Reading the development pages is a good place to start. The <a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">Cura Github development page</a> does contain resources for Windows.</p> <p>The top level Ultimaker <a href="https://github.com/Ultimaker" rel="nofollow noreferrer">Github page</a> contains links to all of the relevant repositories, amongst other useful resources, including:</p> <blockquote> <ul> <li><a href="https://github.com/Ultimaker/CuraEngine" rel="nofollow noreferrer">CuraEngine</a> - CuraEngine is a powerful, fast and robust engine for processing 3D models into 3D printing instruction for Ultimaker and other GCode based 3D printers. It is part of the larger open source project called "Cura".</li> <li><a href="https://github.com/Ultimaker/Cura" rel="nofollow noreferrer">Cura</a> - 3D printer / slicing GUI built on top of the Uranium framework</li> <li><a href="http://cura-build" rel="nofollow noreferrer">cura-build</a> - Build scripts for Cura</li> </ul> </blockquote> <hr> <p>With respect to Python, I, myself, am slowly making my way through this Python tutorial, <a href="https://www.codecademy.com/en/courses/introduction-to-python-6WeG3/0/1" rel="nofollow noreferrer">Python Code Academy</a>. However, there are a many other good Python tutorials out there, the best resource is probably <a href="https://www.python.org/" rel="nofollow noreferrer">Python.org</a>. </p> <p>One thing to note is that Python 2.x and 3.x are markedly different (see <a href="https://wiki.python.org/moin/Python2orPython3" rel="nofollow noreferrer">Should I use Python 2 or Python 3 for my development activity?</a>). <a href="http://learntocodewith.me/programming/python/python-2-vs-python-3/" rel="nofollow noreferrer">What should I learn as a beginner: Python 2 OR Python 3?</a> is also an interesting read.</p>
603
<p>I want a user-privileged (not root) process to launch new processes as user <code>nobody</code>. I've tried a straight call to <code>setuid</code> that fails with -1 <code>EPERM</code> on <code>Ubuntu 8.04</code>:</p> <pre><code>#include &lt;sys/types.h&gt; #include &lt;unistd.h&gt; int main() { setuid(65534); while (1); return 0; } </code></pre> <p>How should I do this instead?</p>
<p>You <em>will</em> require assistance and a lot of trust from your system administrator. Ordinary users are not able to run the executable of their choice on behalf on other users, period.</p> <p>She may add your application to <code>/etc/sudoers</code> with proper settings and you'll be able to run it as with <code>sudo -u nobody</code>. This will work for both scripts and binary executables.</p> <p>Another option is that she will do <code>chown nobody</code> and <code>chmod +s</code> on your binary executable and you'll be able to execute it directly. This task must be repeated each time your executable changes. </p> <p>This could also work for scripts if you'll create a tiny helper executable which simply does <code>exec("/home/you/bin/your-application")</code>. This executable can be made suid-nobody (see above) and you may freely modify <code>your-application</code>.</p>
<p><a href="http://www.keltia.net/programs/calife/" rel="nofollow noreferrer"><code>calife</code></a> is an alternative to <code>sudo</code>.</p> <blockquote> <p>Calife is small program that enable a UNIX system administrator to become root (or another user) on his/her machines without giving the root password but his/her own.</p> </blockquote>
9,240
<p>So I've been using InstantRails to check out Ruby on rails. I've been using Notepad++ for the editing. Now I don't want to install Ruby or Rails on my machine. Is there any walk through/tutorial on how to integrate Radrails or Netbeans with InstantRails? </p>
<p>Here's a tutorial: <a href="http://ruby.meetup.com/73/boards/view/viewthread?thread=2203432" rel="nofollow noreferrer">http://ruby.meetup.com/73/boards/view/viewthread?thread=2203432</a><br> (I don't know if it's any good.)</p> <p>And here's one with InstantRails+Netbeans: <a href="https://web.archive.org/web/20100505044104/http://weblogs.java.net/blog/bleonard/archive/2007/03/instant_rails_w.html" rel="nofollow noreferrer">https://web.archive.org/web/20100505044104/http://weblogs.java.net/blog/bleonard/archive/2007/03/instant_rails_w.html</a></p>
<p>I recommend learning Rails and Ruby itself first, and then picking up something like InstantRails. Having too many layers when learning something new can make it hard to know what features are part of which language, and potentially confuse you when trying to determine where a bug is occurring.</p>
5,832
<p>How should I store (and present) the text on a website intended for worldwide use, with several languages? The content is mostly in the form of 500+ word articles, although I will need to translate tiny snippets of text on each page too (such as "print this article" or "back to menu").</p> <p>I know there are several CMS packages that handle multiple languages, but I have to integrate with our existing ASP systems too, so I am ignoring such solutions.</p> <p>One concern I have is that Google should be able to find the pages, even for foreign users. I am less concerned about issues with processing dates and currencies.</p> <p>I worry that, left to my own devices, I will invent a way of doing this which work, but eventually lead to disaster! I want to know what professional solutions you have actually used on real projects, not untried ideas! Thanks very much.</p> <hr> <p>I looked at RESX files, but felt they were unsuitable for all but the most trivial translation solutions (I will elaborate if anyone wants to know).</p> <p>Google will help me with translating the text, but not storing/presenting it.</p> <p>Has anyone worked on a multi-language project that relied on their own code for presentation?</p> <hr> <p>Any thoughts on serving up content in the following ways, and which is best?</p> <ul> <li><a href="http://www.website.com/text/view.asp?id=12345&amp;lang=fr" rel="nofollow noreferrer">http://www.website.com/text/view.asp?id=12345&amp;lang=fr</a></li> <li><a href="http://www.website.com/text/12345/bonjour_mes_amis.htm" rel="nofollow noreferrer">http://www.website.com/text/12345/bonjour_mes_amis.htm</a></li> <li><a href="http://fr.website.com/text/12345" rel="nofollow noreferrer">http://fr.website.com/text/12345</a></li> </ul> <p>(these are not real URLs, i was just showing examples)</p>
<p>Firstly put all code for all languages under one domain - it will help your google-rank.</p> <p>We have a fully multi-lingual system, with localisations stored in a database but cached with the web application.</p> <p>Wherever we want a localisation to appear we use:</p> <pre><code>&lt;%$ Resources: LanguageProvider, Path/To/Localisation %&gt; </code></pre> <p>Then in our web.config:</p> <pre><code>&lt;globalization resourceProviderFactoryType="FactoryClassName, AssemblyName"/&gt; </code></pre> <p><code>FactoryClassName</code> then implements <code>ResourceProviderFactory</code> to provide the actual dynamic functionality. Localisations are stored in the DB with a string key "Path/To/Localisation"</p> <p>It is important to cache the localised values - you don't want to have lots of DB lookups on each page, and we cache thousands of localised strings with no performance issues.</p> <p>Use the user's current browser localisation to choose what language to serve up.</p>
<p>If you're just worried about the article content being translated, and do not need a fully integrated option, I have used <a href="http://www.google.com/language_tools" rel="nofollow noreferrer">google translation</a> in the past and it works great on a smaller scale.</p>
9,802
<p>I've noticed that Visual Studio 2008 is placing square brackets around column names in sql. Do the brackets offer any advantage? When I hand code T-SQL I've never bothered with them.</p> <p>Example:</p> <p>Visual Studio:</p> <pre><code>SELECT [column1], [column2] etc... </code></pre> <p>My own way:</p> <pre><code>SELECT column1, column2 etc... </code></pre>
<p>The brackets are required if you use keywords or special chars in the column names or identifiers. You could name a column <code>[First Name]</code> (with a space) – but then you'd need to use brackets every time you referred to that column.</p> <p>The newer tools add them everywhere just in case or for consistency.</p>
<p>I believe it adds them there for consistency... they're only required when you have a space or special character in the column name, but it's cleaner to just include them all the time when the IDE generates SQL.</p>
7,624
<p>Got my Ender 3 v2 and stack with the bed leveling.</p> <p>Used default settings, Creality slicer 4.2, test PLA from the kit and print model <a href="https://www.thingiverse.com/thing:3013319" rel="nofollow noreferrer">https://www.thingiverse.com/thing:3013319</a> (4 squares in each corner and 1 in the middle), nozzle 200 °C, bed 60 °C.</p> <p>After some adjustments, I have good solid pieces on the bed corners but the center one has small gaps. Is it possible to fix this problem?</p> <p>Corner pice: <a href="https://i.stack.imgur.com/BGeA2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BGeA2.jpg" alt="enter image description here" /></a></p> <p>Center piece: <a href="https://i.stack.imgur.com/gfSas.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gfSas.jpg" alt="enter image description here" /></a></p>
<p>The gaps are, because the nozzle is to far from the bed at this point. It may sound like a big deal, but actually this is not leveling alone, but it looks like the bed is not a perfect plane/perfectly flat. This is normal, my ikea mirror and my stock bed show the same thing. Now here's one solution:</p> <p>Print calibration stickers, like you already did on various places around the bed to get a feel, where it is too low. Let it cool and put painters tape (the very very thin tape, that should not burn) on areas, where the bed is too low. Print more calibration rectangles and check if you have enough. Repeat until you cannot see a difference.</p> <p>It took me about 2h to level everything absolutely perfectly. This was 2 years ago and I didn't have to touch the tape below my bed ever since. It just works.</p> <p>Alternative solutions involve mesh bed leveling and buying a new bed surface or even the surface below the bed. However, I found that to neither of them work reliably, whereas the simple tuning does what it's supposed to.</p>
<p>I had exact same issues with my Ender 3 v2. Using the stock default glass the middle would be too far out and I was never able to level it just right - no matter what I did - I could have stayed on it for hours.</p> <p>In matter of fact, it wasn't just the middle, it was the middle between each of the corner points as well, meaning, imagine a plus sign going across from the dead middle of the bed vertically and horizontally, where all that area would be a little too far out.</p> <p>I did anything I could, eventually what solved it for me was tightening all of the frame once again, making sure the x-axis gantry doesn't wobble, the hotend doesn't wobble and then realign the gantry nuts below the bed, to help with this alignment I actually tilted the whole printer 90° so gravity will help the wheels get the right alignment.</p> <p>The issues such as you are describing were gone after complete overhaul tightening as mentioned above.</p>
1,709