instruction
stringlengths
27
22.5k
chosen
stringlengths
27
28.2k
rejected
stringlengths
19
24.9k
__index_level_0__
int64
0
10k
<p>What's the best lifetime model for a <code>DataContext</code>? Should I just create a new one whenever I need it (aka, function level), should I keep one available in each class that would use it (class level), or should I create a static class with a static DataContext (app-domain level)? Are there any considered best practices on this?</p>
<p>You pretty much need to keep the same data context available throughout the lifetime of the operations you want to perform if you're ever going to be storing changes which are to be <code>.SubmitChanges()</code>'d later, as otherwise you will lose those changes.</p> <p>If you're just querying stuff then it's fine to create them as needed, but then if later you want to <code>.SubmitChanges()</code> you'll have to refactor your code a lot, so you may as well adopt the pattern of effectively keeping the <code>datacontext</code> global throughout your app from the beginning.</p> <p>Note the data context is <em>disconnected</em>. The connection is only made when the query data is <em>enumerated</em> (not when you first run the query, it's a 'lazy' data type so only provides data when it's needed), and then closed immediately afterwards. On <code>.SubmitChanges()</code> the connection is opened to submit the changes then closed immediately afterwards. So don't think keeping the <code>datacontext</code> around keeps a connection open, it doesn't (you can hook the <code>StateChange</code> event of the connection to confirm this for yourself, that's how I'm sure).</p> <p>There is a great article over at <a href="http://www.west-wind.com/weblog/posts/246222.aspx" rel="nofollow noreferrer">Rick Strahl's Blog</a> which covers this topic in depth, far more than my answer here provides!!</p>
<p>I think Jeff Atwood talked about this in the <a href="http://herdingcode.com/?p=36" rel="nofollow noreferrer">Herding Code podcast</a>, when he was questioned about the exact same thing. Listen to it towards the last 15-20 minutes or so.</p> <p>I think in SO, the datacontext is created in the Controller class. Not sure about a lot of details here. But that's what it looked like.</p>
5,342
<p>I know that it does in PHP, and I'm pretty sure it does in Java. I haven't used the latest versions of .NET, so I won't speak for them. It seems very awkward, but I was wondering if there was an underlying reason for this.</p>
<p>One reason is compatibility - anyone who has done 'check for existence' knows to exclude directories; changing that behaviour may confuse those who rely on that behaviour.</p> <p>Secondly, the underlying code often does a check on the operating system for existence in a catlog of filesystem entries - to the OS, a directory is the same as a file. In other words, it's looking for an entry of 'xyz' in the catalog not a file with name 'xyz' in the catalog.</p> <p>Backwards compatability is the main reason, I suspect.</p>
<p>Part of the Unix philosophy is that "<a href="http://www.cs.bgu.ac.il/~arik/usail/concepts/filesystems/everything-is-a-file.html" rel="nofollow">everything is a file</a>". This has influenced other environments as well to some degree.</p>
7,282
<p>I've heard a bit about folks using air compressors with tubing to the toolhead and outlet openings there as part cooling. One example is the <a href="https://the-makerhive.myshopify.com/products/berd-air-max" rel="nofollow noreferrer">Berd Air</a>, but from the information I can gather, it works with rather low pressures where the expansion of the compressed air is unlikely to get the air significantly below ambient temperature, so it's basically equivalent to a low-end fan. Indeed, <a href="https://www.youtube.com/watch?v=65FVQ1jArME" rel="nofollow noreferrer">this video</a> comparing such a system against the HevACS found it rather ineffective.</p> <p>If one wants to harness the cooling of compressed air to hit the part with air significantly below ambient temperature, what is the relationship between pressure needed and temperature drop? I assume one can work it out pretty closely with ideal gas law, but I don't understand how to figure in both the change in volume and pressure when the air exits the high pressure part of the system.</p>
<p>I'm an owner of both an FDM printer and a resin one:</p> <p>I've long searched a resin capable of printing durable objects even in tiny details but with poor luck. I've tried ABS-Like resins, and they provide a slightly better resistance than regular resin but do not expect great improvements; I've tryed the siraya tech Blue V2 that is for sure much more durable but eventually would fail on the smaller details...</p> <p>In the end i think I'll try the flexible resins like the Liquicreate flexible X or the Siraya tech Tenacious because those (similarly to TPU in FDM) can better absorb energy from impacts and having a smaller young's modulus can help when under load.</p>
<p>I'm an owner of both an FDM printer and a resin one:</p> <p>I've long searched a resin capable of printing durable objects even in tiny details but with poor luck. I've tried ABS-Like resins, and they provide a slightly better resistance than regular resin but do not expect great improvements; I've tryed the siraya tech Blue V2 that is for sure much more durable but eventually would fail on the smaller details...</p> <p>In the end i think I'll try the flexible resins like the Liquicreate flexible X or the Siraya tech Tenacious because those (similarly to TPU in FDM) can better absorb energy from impacts and having a smaller young's modulus can help when under load.</p>
2,014
<p>How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters.</p> <p>Any language would work, but it should be portable.</p>
<p>There are several ways to do this. Common methods use recursion, memoization, or dynamic programming. The basic idea is that you produce a list of all strings of length 1, then in each iteration, for all strings produced in the last iteration, add that string concatenated with each character in the string individually. (the variable index in the code below keeps track of the start of the last and the next iteration)</p> <p>Some pseudocode:</p> <pre><code>list = originalString.split('') index = (0,0) list = [""] for iteration n in 1 to y: index = (index[1], len(list)) for string s in list.subset(index[0] to end): for character c in originalString: list.add(s + c) </code></pre> <p>you'd then need to remove all strings less than x in length, they'll be the first (x-1) * len(originalString) entries in the list.</p>
<p>The possible string permutations can be computed using recursive function. Below is one of the possible solution.</p> <pre><code>public static String insertCharAt(String s, int index, char c) { StringBuffer sb = new StringBuffer(s); StringBuffer sbb = sb.insert(index, c); return sbb.toString(); } public static ArrayList&lt;String&gt; getPerm(String s, int index) { ArrayList&lt;String&gt; perm = new ArrayList&lt;String&gt;(); if (index == s.length()-1) { perm.add(String.valueOf(s.charAt(index))); return perm; } ArrayList&lt;String&gt; p = getPerm(s, index+1); char c = s.charAt(index); for(String pp : p) { for (int idx=0; idx&lt;pp.length()+1; idx++) { String ss = insertCharAt(pp, idx, c); perm.add(ss); } } return perm; } public static void testGetPerm(String s) { ArrayList&lt;String&gt; perm = getPerm(s,0); System.out.println(s+" --&gt; total permutation are :: "+perm.size()); System.out.println(perm.toString()); } </code></pre>
2,285
<p>Most XML parsers will give up after the first error in a document. In fact, IIRC, that's actually part of the 'official' spec for parsers. </p> <p>I'm looking for something that will break that rule. It should take a given schema (assuming a valid schema) and an xml input and attempt to keep going after the first error and either raise an event for each error or return a list when finished, so I can use it to generate some kind of a report of the errors in the document. This requirement comes from above, so let's try to keep the purist <em>"but it wouldn't make sense to keep going"</em> comments to a minimum. </p> <p>I'm looking for something that will evaluate both whether the document is well-formed <em>and</em> whether or not it conforms to the schema. Ideally it would evaluate those as different classes of error. I'd prefer a .Net solution but I could use a standalone .exe as well. If you know of one that uses a different platform go ahead and post it because someone else might find it useful.</p> <p><strong>Update:</strong> </p> <p>I expect that most of the documents where I use this will be <em>mostly</em> well-formed. Maybe an &amp; included as data instead of &amp;amp here and there, or an occasional mis-placed tag. I don't expect the parser to be able to recover from anything, just to make a best-effort to keep going. If a document is too out of whack it should spit out as much as it can followed by some kind of 'fatal, unable to continue' error. Otherwise the schema validation part is pretty easy.</p>
<p>In a different question on SO (<a href="https://stackoverflow.com/questions/41908/customizing-visual-studio">link</a>), someone mentioned the VS 2005 / VS 2008 add-in "RockScroll". It seems to provide the "error bar" feature I was inquiring about in my question above.</p> <p><a href="http://www.hanselman.com/blog/IntroducingRockScroll.aspx" rel="nofollow noreferrer">RockScroll</a></p> <p>EDIT: RockScroll also does the identical token highlighting that I was looking for! Great!</p>
<p>The "error bar" functionality is provided in JetBrains ReSharper. I'm not sure if it does highlighting of references to the currently selected identifier.</p>
5,244
<p>I'm in the middle of building a D-Bot printer, and have run into a bit of an issue when it comes to the heat bed wires. The heated bed is an aluminum plate with a silicon heater attached to it, and the heater wires are not long enough to make it through the drag chain when the Z-axis is fully extended.</p> <p>The silicon pad is 120&nbsp;V AC / 750&nbsp;W and will be turned on/off by a Fotek SSR. The heater wires are cloth-covered and are probably 22-24 AWG. (Gauge is not labelled)</p> <p>I suspect I'll need to extend the wires by putting in some sort of coupler at the top of the drag chain, but I'm not certain if there are specific requirements for the wires for an AC powered heat bed. </p> <p>To this end, I was wondering:</p> <ul> <li>Is there a specific wire gauge that I should use for the heater wires, and should it have a specific cladding?</li> <li>What type of connector would be best for connecting the wires together securely in this case?</li> </ul> <p>Thanks in advance!</p>
<p>750 W at 120 V is 6.3 A. 22-24 AWG is on the thin side for this. I would recommend 18 AWG or thicker. You don't need a specific style of insulation for this (other than something that is rated for the voltage and temperature the wire will need to withstand, but most commonly found wire should be good).</p> <p>A good way of connecting the wires would be to solder them. If you do not want to solder, there are many products on the market for connecting wires. A butt connector that you crimp could be a good option, or you could use a WAGO clamp. Whatever option you end up using, be sure to provide adequate strain relief as the connection point (be it soldered or with a connector) is more likely to fail from fatigue.</p>
<p>750 W at 120 V is around 6.3 A.</p> <p>You can use a <a href="https://www.calculator.net/voltage-drop-calculator.html" rel="nofollow noreferrer">voltage drop calculator</a> to find out how much power is lost in the wires, and therefore their temperature increase.</p> <p>I did it for you. With 10 feet (2x5 feet) 20AWG wire and 6 A current, 7 W are dissipated on the wires.</p> <p>It's 0.7 W/foot which is ok for silicone wires, also because the bed doesn't operate at 100% except for the initial heating up (and then the heat goes to the air around, which is fine anyway).</p> <p>If you use <a href="https://www.is-rayfast.com/news/wire-cable/temperature-rise-by-current/" rel="nofollow noreferrer">another website</a>, you can see that 20 AWG with 6 A current produces, in free air, around 10 degrees temperature increase. Silicone insulation will worsen that, but silicone holds well over 100 °C...</p> <p>Use thicker wires if you can, or go on if you cannot.</p> <p>The most important thing is to very effectively join the two, so that no extra resistance is introduced. I would place them next to each other and physically solder them. Then heat shrink tube around the joint.</p> <p>See for info what not to use for the joining</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/unxEdyW8RP8?start=0"></iframe> </div></div></p>
1,685
<p>I'm making a hybrid 3D printer and circuit etching (CNC milling) machine that can both 3D print and etch prototype circuit boards. I'll be using Marlin firmware with an Arduino Mega &amp; RepRap 1.4 board. It will have a 3D printer head and a milling head side by side. I'd like to have it be able to read both .gbr (for circuit etching) and .gcode (for 3D printing) files. How should I configure Marlin to read both types?</p>
<p>You can use both .gcode and .gbr files one one machine. We do it where I work.</p> <p>However, when we make prototype circuit boards, we don't print them; we acquire circuit board blanks, and then we either:</p> <ol> <li><p>Use a diode laser to burn off the top layer of garolite for isolation traces, then do a chemical dip to remove that copper, then another laser burn to expose pads for surface mount components; or</p></li> <li><p>Use a spindle tool to remove the top layer of garolite where needed for pads, as well as mill through the copper layer for isolation traces.</p></li> </ol> <p>We have not found a printable material that has the conductivity we want in a circuit board.</p> <p>Source: I work for <a href="http://hyrel3d.com" rel="nofollow noreferrer">Hyrel 3D</a></p> <p><a href="https://i.stack.imgur.com/Gk8gV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gk8gV.png" alt="enter image description here"></a></p> <p>Note: we don't use Marlin on Arduino, we use in-house firmware on STM32F429 boards. </p>
<p>Well, I'm Using pronterface to send the gcode to print the traces of my PCB with an ink pen (sharpie); since the parameter in the Marlin-Rep rap1.4 is configured to fast print, So I can easily send the code just setting the origin or Zero to print on any area of the printer. </p> <p>To set the new Zero just use the code G92, for example we need to print in the middle of the printer, so just move the spindle to that position and set G92 X0 Y0, then andjust the Z height then set G92 Z0. for your milling add a Z secure travel to avoid collide with the surface and or mechanical clamps</p> <p>This video shows a <a href="https://www.youtube.com/watch?v=arTFvzyqAwE&amp;t=49s" rel="nofollow noreferrer">PCB print</a> in the 3Dprinter, so for the milling process will be the same. The video shows also the process making the holes on the CNC; I didn't do in the 3d printer because in that time I hadn't a dremel support. </p> <p>Also Tech2C teach how you can configure the whole printer, just <a href="https://www.youtube.com/watch?v=6ipcdhXetHY&amp;t=5s" rel="nofollow noreferrer">follow this link</a></p> <p>So, be happy milling in your 3d printer</p> <blockquote> <p><strong>Note:</strong> for gbrl files I haven't tested but you can try to read and send your code thru this program (<em>pronterface</em>) probably you cand get some messages like "uknown code" just like <strong><em>gcode sender</em></strong> does while trying to send codes for laser etching (old versions).</p> </blockquote>
1,413
<p>The .NET Setup project seems to have a lot of options, but I don't see an "Uninstall" option. </p> <p>I'd prefer if people could "uninstall" from the standard "start menu" folder rather than send them to the control panel to uninstall my app, so can someone please tell me how to do this?</p> <p>Also, I am aware of non Microsoft installers that have this feature, but if possible I'd like to stay with the Microsoft toolkit.</p>
<p>You can make shortcut to:</p> <pre><code>msiexec /uninstall [path to msi or product code] </code></pre>
<p>Visual Studio 2013 allows you to create an Uninstall shortcut in the shortcut design page if you use the Installshield Add-on.</p>
8,694
<p>I am having a frequent problems with my web hosting (its shared)</p> <p>I am not able to delete or change permission for a particular directory. The response is,</p> <pre><code>Cannot delete. Directory may not be empty </code></pre> <p>I checked the permissions and it looks OK. There are 100's of files in this folder which I don't want. </p> <p>I contacted my support and they solved it saying it was permission issue. But it reappeared. Any suggestions?</p> <p>The server is Linux.</p>
<p>You can't <strong>rmdir</strong> a directory with files in it. You must first <strong>rm</strong> all files and subdirectories. Many times, the easiest solution is:</p> <pre><code>$ rm -rf old_directory </code></pre> <p>It's entirely possible that some of the files or subdirectories have permission limitations that might prevent them from being removed. Occasionally, this can be solved with:</p> <pre><code>$ chmod -R +w old_directory </code></pre> <p>But I suspect that's what your support people did earlier.</p>
<p>This could also be because your FTP client might not be showing the hidden files (like cache, or any hiddn files that your application might create), while the hidden files are preventing you from deleting the directory. (though, in your case, I am not sure if this is the cause .. .it could be permission issue with your hosting provider.. Webserver running as another user (like apache or www) combined with your directories having global write perms).</p>
9,914
<p>I've found a few (unfortunately, they are bookmarked at home and I'm at work, so no links), but I was wondering if anyone had any opinions about any of them (love it, hate it, whatever) so I could make a good decision. I think I'm going to use Cygwin for my Unix commands on Windows, but I'm not sure how well that's going to work, so I would love for alternatives and I'm sure there are people out there interested in this who aren't running Cygwin.</p>
<p>These work very well for me: <a href="http://unxutils.sourceforge.net/" rel="nofollow noreferrer">http://unxutils.sourceforge.net/</a>.</p> <p>Cygwin is not so good on Vista or 64 bit, so I stopped using it a while back.</p>
<p><a href="https://stackoverflow.com/questions/32777/what-is-the-best-and-most-complete-implementation-of-unix-system-commands#32792">Why vote down this question</a>? It's obviously meant to be tongue in cheek is it worth the voter and the receiver losing rep over? Can't you people leave anything at zero and mark up the answers you want to see float rather than mark down the funny one liners?</p> <p>In answer to the question I've used Cygwin in the past but always found it clunky and wanting. I don't think it's the tools problem but mine but I have book marked <a href="https://stackoverflow.com/questions/32777/what-is-the-best-and-most-complete-implementation-of-unix-system-commands#32785">Eric's suggestion of unxutils</a> for when my new windows machine arrives tomorrow.</p>
5,278
<p>What is the simplest way to install memcached on CentOS for someone new to the world of Linux? What is the best way to enable it for Apache and PHP</p>
<p>Unless Apache and PHP have some option to utilize memcached for internal workings (of which I am unaware of), you typically don't "enable" it for such apps. Instead, you would get a <a href="http://www.danga.com/memcached/apis.bml" rel="nofollow noreferrer">client library</a> to use memcached from within your application, then start up memcached on whatever servers you want to provide memory with, then just use the client library API to store and retrieve cached data across multiple servers.</p>
<p>The easiest way is to find a reilable source of the RPM's needed to install memcached and memcached for PHP. There is a blog post which addresses this concern:</p> <p><a href="http://blog.gahooa.com/2009/02/08/update-on-fedora-vs-redhat-enterprise-linux/" rel="nofollow noreferrer">http://blog.gahooa.com/2009/02/08/update-on-fedora-vs-redhat-enterprise-linux/</a></p> <p>We have been using EPEL (Extra Packages for Enterprise Linux) for exactly that on RedHat Enterprise 5.3. I believe it is a stated goal of EPEL to support Centos.</p> <p><a href="http://fedoraproject.org/wiki/EPEL" rel="nofollow noreferrer">http://fedoraproject.org/wiki/EPEL</a></p> <p>Essentially, it is a YUM repository which contains lots of extra packages from Fedora that were compiled for RHEL. <strong>Super easy to use.</strong></p>
4,358
<p>How do I make a tree data structure in C++ that uses iterators instead of pointers? I couldn't find anything in the STL that can do this. What I would like to do is to be able to create and manipulate trees like this:</p> <pre><code>#include &lt;iostream&gt; #include &lt;tree&gt; using namespace std; int main() { tree&lt;int&gt; myTree; tree&lt;int&gt;::iterator i = myTree.root(); *i = 42; tree&lt;int&gt;::iterator j = i.add_child(); *j = 777; j = j.parent(); if (i == myTree.root() &amp;&amp; i == j) cout &lt;&lt; "i and j are both pointing to the root\n"; return 0; } </code></pre> <hr> <p>Thank you, tree.hh seems to be just what I was looking for.</p> <blockquote> <p>If this is for gaining the benefit of a data-structure holding arbitrary index types, optimized for searching and good at insertion then consider using a map.</p> <p>A map is an associative container that has performance guarantees identical to those of a tree: logarithmic searching, logarithmic insertion, logarithmic deletion, linear space. Internally they are often implemented as red-black trees, although that is not a guarantee. Still, as an STL user all you should care about is the performance guarantees of the STL algorithms and data-structures. Whether they're implemented as trees or little green men shouldn't matter to you.</p> </blockquote> <p>I'm not sure if a map is what I need, but thanks for the info. I will remember to use maps whenever possible instead of implementing trees.</p>
<p>Here is <a href="http://www.aei.mpg.de/~peekas/tree/" rel="noreferrer">tree.hh</a> which is a bit close to what you want to do, though a bit different.</p> <p>Here is a piece of code extracted from its website.</p> <pre><code>int main(int, char **) { tree&lt;string&gt; tr; tree&lt;string&gt;::iterator top, one, two, loc, banana; top=tr.begin(); one=tr.insert(top, "one"); two=tr.append_child(one, "two"); tr.append_child(two, "apple"); banana=tr.append_child(two, "banana"); tr.append_child(banana,"cherry"); tr.append_child(two, "peach"); tr.append_child(one,"three"); loc=find(tr.begin(), tr.end(), "two"); if(loc!=tr.end()) { tree&lt;string&gt;::sibling_iterator sib=tr.begin(loc); while(sib!=tr.end(loc)) { cout &lt;&lt; (*sib) &lt;&lt; endl; ++sib; } cout &lt;&lt; endl; tree&lt;string&gt;::iterator sib2=tr.begin(loc); tree&lt;string&gt;::iterator end2=tr.end(loc); while(sib2!=end2) { for(int i=0; i&lt;tr.depth(sib2)-2; ++i) cout &lt;&lt; " "; cout &lt;&lt; (*sib2) &lt;&lt; endl; ++sib2; } } } </code></pre> <p>Now what's different? Your implementation is simpler when it comes to append a node to the tree. Though your version is indiscutably simpler, the dev of this lib probably wanted to have some info accessible without browsing the tree, such as the size of the tree for instance.</p> <p>I also assume he didn't want to store the root on all nodes for performance reason. So if you want to implement it your way, I suggest you keep most of the logic and add the link to the parent tree in the iterator and rewrite append a bit.</p>
<p>Why would you want to do that? If this is for learning purposes then you can write your own tree data structure. If this is for gaining the benefit of a data-structure holding arbitrary index types, optimized for searching and good at insertion then consider using a map.</p> <p>A map is an associative container that has performance guarantees identical to those of a tree: logarithmic searching, logarithmic insertion, logarithmic deletion, linear space. Internally they are often implemented as red-black trees, although that is not a guarantee. Still, as an STL user all you should care about is the performance guarantees of the STL algorithms and data-structures. Whether they're implemented as trees or little green men shouldn't matter to you.</p> <p>As a side note, there's no such thing as a root() function. All STL containers have the begin() function implementing the conceptual beginning of a container. The kind of iterator returned by that function depends on the characteristics of the container.</p>
3,967
<p>I was looking at purchasing the Creality CR-X or another similar dual extruder (note, NOT dual nozzle) printer. I know it was designed to print two colors of the same filament, but is it able to print two different filaments?</p> <p>I would be printing HIPS with ABS or PVA with PLA, so the two filaments would have very similar characteristics. It's ok if the printer doesn't know there's two different filaments, I can make it work by playing with the slicing settings.</p>
<p>I believe the problem is not so much that the filament is sticking to the nozzle; it's that the filament is not sticking to the bed.</p> <p>You've confirmed that you have correct clearance for the nozzle to bed distance. The next considerations are bed temperature and nozzle temperature. New brands often require new parameters.</p> <p>Consider to raise the bed temperature 5 °C. If you're not using any adhesive medium, perhaps a bit of glue stick will help to have the filament stick better/properly.</p> <p>It's unlikely that the nozzle temperature is incorrect, as too low would result in a nozzle clog, while too high would &quot;drizzle out&quot; and be everywhere, but don't reject too-high entirely.</p> <p>If you can get the bed adhesion correct, your nozzle should remain clear.</p>
<p>I believe the problem is not so much that the filament is sticking to the nozzle; it's that the filament is not sticking to the bed.</p> <p>You've confirmed that you have correct clearance for the nozzle to bed distance. The next considerations are bed temperature and nozzle temperature. New brands often require new parameters.</p> <p>Consider to raise the bed temperature 5 °C. If you're not using any adhesive medium, perhaps a bit of glue stick will help to have the filament stick better/properly.</p> <p>It's unlikely that the nozzle temperature is incorrect, as too low would result in a nozzle clog, while too high would &quot;drizzle out&quot; and be everywhere, but don't reject too-high entirely.</p> <p>If you can get the bed adhesion correct, your nozzle should remain clear.</p>
1,792
<p>On my <a href="http://rads.stackoverflow.com/amzn/click/B007KG0ZYI" rel="nofollow">Switching Power Supply</a> there is a little orange trimpot that's marked <code>VR1</code>; what does that do, and does it work similar to the ones on the stepper drivers?</p>
<p>No doubt it's just a final tuning potentiometer. Even on the pictures you linked it's described as V adj which stands for voltage adjustment. It's a way to tune your power supply's output as it can vary depending on temperature/humidity/wall-plug voltage/etc.</p> <p>It's usually set properly and doesn't need to be touched. But you can connect a multimeter to check if your power supply gives the voltage you need. </p> <p>If you are not familiar with the subject but still want to do it yourself, it's good to set your multimeter to the highest available range and make sure that AC/DC is properly chosen. Now you can measure voltage. You can set the range closer to the expected values then. Usually multimeters have a range around 20 or 30V DC which is propbably what you expect from your power supply. In such a range you should see something like 12.000. If it varies from 12.000 you can then precisely adjust it to get as close as possible to this value. But watch out... cheap power supplies can cheat you. When the are have a load on the output (your 3D printer for example) they can reduce voltage.</p>
<p>Vr usually stands for variable resistor, basically a pot. Usually by adjusting this you would adjust the voltage output on most power supplies, ensure you double check your voltage output with a meter after adjusting.</p>
261
<p>I literally just started OpenSCAD today, so please take it easy on me, but is shell scripting possible with OpenSCAD? as in, to write a script in the OpenSCAD syntax, and have it output images, or animations? with or without having to render the image.</p> <p>I've been reading the man pages, and I'm not sure if that can be done.</p>
<p>The horizontal bands are 5mm apart, which is a common pitch for the screws often used for the Z axis.</p> <p>I would look for something that binds, moves, slips, or touches once per screw revolution. The movement repeats along the screw, so if it is a screw defect I would look for a scratch or bump that affects the screw along its axis.</p> <p>If you don't see that, check for how the screw is constrained at both ends. If they are loose constraints, does the screw wiggle while it is turning?</p> <p>Move the nut to one extreme and rotate the screw. Does it appear to have any bend? Even a small degree of bending that doesn't bind the axis can add a small load to the drive.</p> <p>The Z-azis error you are looking for is subtle. It is probably 10% (or less) of the layer height.</p>
<p>Try setting the z-seam to <em>random</em> in your slicer. In Slic3r it is <em>Seam position</em> under <em>Advanced</em> near the bottom of the <em>Layer and perimeters</em> page of the <em>Print Settings</em>.</p>
2,069
<p>So our web server apps need to connect to the database, and some other apps have startup scripts that execute at boot time.</p> <p>What's the best way to store the name/password for these applications, in terms of</p> <ul> <li>security, e.g. perhaps we don't want sysadmins to know the database password</li> <li>maintainability, e.g. making the configuration easy to change when the password changes, etc.</li> </ul> <p>both windows and linux solutions appreciated!</p>
<p>The best way to secure your password is to stop using one. Use a trusted connection: <a href="http://msdn.microsoft.com/en-us/library/ms998292.aspx" rel="nofollow noreferrer">How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0</a>. Then you have nothing to hide - publish your web.config and source to the world, they still can't hit your database.</p> <p>If that won't work for you, use the built in <a href="http://msdn.microsoft.com/en-us/magazine/cc163614.aspx" rel="nofollow noreferrer">configuration encryption system in ASP.NET</a>.</p>
<p>You can bake a symmetric encryption key into your binary, and have that binary read an encrypted username/password from a file on disk when it starts up. </p> <p>However, this is not really much more than obfuscation, since your code is likely to be stored in some source repository somewhere. </p> <p>I would suggest that you would be better served to control access to your servers both physically and over the network using a firewall and a private network bubble, and store the passwords in the clear (or base-64 encoded) on disk with permissions locked down to the run user for your web app.</p> <p>You can also lock down the database server to only accept connections from your web app machines by IP.</p> <p>Ultimately, your problem is that the key (your DB username/password pair) needs to be available for programmatic, unattended use by your web apps.</p>
3,191
<p>How to implement a website with a recommendation system similar to stackoverflow/digg/reddit? I.e., users submit content and the website needs to calculate some sort of "hotness" according to how popular the item is. The flow is as follows:</p> <ul> <li>Users submit content</li> <li>Other users view and vote on the content (assume 90% of the users only views content and 10% actively votes up or down on content)</li> <li>New content is continuously submitted</li> </ul> <p>How do I implement an algorithm that calculates the "hotness" of a submitted item, preferably in real-time? Are there any best-practices or design patterns?</p> <p>I would assume that the algorithm takes the following into consideration:</p> <ul> <li>When an item was submitted</li> <li>When each vote was cast</li> <li>When the item was viewed</li> </ul> <p>E.g. an item that gets a constant trickle of votes would stay somewhat "hot" constantly while an item that receives a burst of votes when it is first submitted will jump to the top of the "hotness"-list but then fall down as the votes stop coming in.</p> <p>(I am using a MySQL+PHP but I am interested in general design patterns).</p>
<p>You could use something similar to the <a href="http://redflavor.com/reddit.cf.algorithm.png" rel="noreferrer">Reddit algorithm</a> - the basic principle of which is you compute a value for a post based on the time it was posted and the score. What's neat about the Reddit algorithm is that you only need recompute the value when the score of a post changes. When you want to display your front page, you just get the top n posts from your database based on that score. As time goes on the scores will naturally increase, so you don't have to do any special processing to remove items from the front page.</p>
<p>I developed an social bookmarking site, <a href="http://www.sites-favoritos.com" rel="nofollow noreferrer">Sites Favoritos</a>, and used a complex algoritm:</p> <ol> <li>First, the votes are finite, an user only have a limited number of votes, and the number of votes depends on the user points. To earn points each user must add links that get positive votes.</li> <li>Then, users can vote -3,-2,-1,1,2 or 3 votes for each link. As the votes are limited, each user will vote only on those links that they like.</li> <li>To prevent user to vote only on links for the same user, creating support groups, the points each vote adds to the link depends on a racio between total votes and votes to links of the owner of the voted link. If you always vote on the same users links, your votes will lose value.</li> <li>Votes lose value with time.</li> <li>New links from users who don't have points (new users) will have a starting 0 points. New links from older users will have points depending on their points. Ranging from +3 to -infinite. Links from users with negative points will have negative starting points, links from users with positive points will have positive starting points.</li> </ol> <p>Users will get random points when their links are voted. Positive votes give positive points, negative votes for negative points.</p>
9,747
<p><strong>Before the question, here is my setup;</strong> </p> <ul> <li>Prusa i3 (with mainboard Mks Gen v1.2)</li> <li>Repetier as slicer</li> <li>Marlin source code </li> </ul> <p>My main task is to convert my 3D printer into a chocolate printer. I have replaced the filament extruder with a chocolate extruder. And it is there that my issue began. Because, the new extruder is stopping slightly off the y-axis when homing. It is going out of the standard 20x20 cm bed. The other X and Z axes are OK.</p> <p>So, I have played with the <code>#defines</code> explained below, but I couldn't even make any single mm difference by homing. They are all ignored when the printer is homing. It goes and rests on the hardware end-stops and stops there eventually.</p> <p>All I want 10 mm offset for Y axis.</p> <p><strong>Started with this;</strong> </p> <pre><code>// Travel limits after homing #define X_MAX_POS 200 #define X_MIN_POS 0 #define Y_MAX_POS 190 &lt;&lt;&lt;&lt; (tested with 190 and 210) #define Y_MIN_POS 0 #define Z_MAX_POS 200 #define Z_MIN_POS 0 </code></pre> <p><strong>and this;</strong></p> <pre><code>// The position of the homing switches #define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used //Manual homing switch locations: // For deltabots this means top and center of the cartesian print volume. #define MANUAL_X_HOME_POS 0 #define MANUAL_Y_HOME_POS 10 &lt;&lt;&lt; (tested with 10 or -10) #define MANUAL_Z_HOME_POS 0 </code></pre> <p>I have also played with the <strong>slicer tool (Repetier)</strong> settings where homing related values are mentioned but no joy there as well.</p> <p>Any input highly appreciated.</p>
<p>The Y-Max setting does not help, because it is the software end stop for the other end of the axis.</p> <p>The Y Home position also doesn't help as it only changes the coordinate that the printer assumes for when it hits the home position. That is used for printers (like deltas) that home to the max end switches.</p> <p>What could help is a little bit of G-Code right after the Homing. The Homing is a G28. Just add a G1Y10 after that. That will move your Y Axis 10 mm right after homing. So it will then be in the position that you want. If you then add a G92 then this position will become the home position for the print. So adding these two lines should fix it. Cura lets you edit these start G-Codes so that it then will automatically add the modified codes to all your prints.</p> <p>You can also try a G10 (with a firmware that supports it.</p> <p>For Details on G-Codes see: <a href="http://reprap.org/wiki/Gcode" rel="noreferrer">http://reprap.org/wiki/Gcode</a></p>
<p>Now I've finally had time to look into this, since I knew it somehow existed, but wasn't sure how it worked:</p> <p>Use the M206 G-code command in Marlin, Sprinter, Smoothie, or RepRap Firmware to offset the 0,0,0 coordinate of your printbed relative to the endstops.</p> <p>The reprap.org wiki page says:</p> <blockquote> <p>The values specified are added to the endstop position when the axes are referenced. The same can be achieved with a G92 right after homing (G28, G161).</p> <p>With Marlin firmware, this value can be saved to EEPROM using the M500 command.</p> <p>A similar command is G10, aligning these two is subject to discussion.</p> <p>With Marlin 1.0.0 RC2 a negative value for z lifts(!) your printhead.</p> </blockquote> <p>We see, this basically is the same suggested by @LarsPoetter, but it comes with the great advantage that it can be saved to EEPROM, hence you don't need to add it every time or into every different sliccer (if I understand it correctly, - I haven't yet tried it myself)</p> <p>Let us know if this works for a permanent solution.</p>
336
<p>I'm trying to print a calibration cube from PLA using a 70&nbsp;&deg;C heated build platform on a Prusa i3 Pro W. This results in:</p> <p><a href="https://i.stack.imgur.com/G00Um.jpg)" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G00Um.jpg)" alt="Calibration cube print failed"></a></p> <p>Please explain why it prints like this.</p>
<p>There are multiple issues that cause this result.</p> <p>First, your nozzle is to far from the bed. This can be seen by the curly deposited filament on the build plate (I guess that is the brim or the skirt). Please properly level the bed and position the nozzle at a distance of a plain A4 paper as best as possible (should be doable as you have a glass sheet that are usually very flat as a result of the production process to make glass).</p> <p>The second problem you face is layer shift. You see that the squares are printed further and further to the left, the print head does not return to original position. Layer shift is usually caused by improper belt tension or a loose grub screw of the belt pulley. <a href="/a/8167/">This answer</a> describes layer shifting in more detail. <a href="/q/8166/">This question</a> may be helpful too, the answer contains some references to layer shifting.</p>
<p>The layer shift can also be caused by the stepper motor "skipping" when it hits an obstruction. The obstruction can be a loop or ridge of filament sticking up higher than it should be.</p> <p>As Oscar suggests, the first step is always to make the first-layer-thickness be right. This is often called "bed leveling", but really it is making sure that the bed defines the z=0 plane that the firmware is expecting. If it isn't planar, if it isn't constant Z (ie., it tilts in any direction), or it isn't at zero, problems follow.</p> <p>It seems to have mostly shifted in X, so start with that motor and belt. Have you adjusted the tension correctly? Is the motor current set correctly?</p> <p>Other things can also cause trouble, such as:</p> <ol> <li>A poorly mounted extruder that favors one direction</li> <li>Bad slicer parameters that command movement faster than the printer's ability</li> <li>Bad configuration parameters which call for acceleration or velocities beyond the printer's ability.</li> </ol> <p>Are the slicer settings matched to the printer? If this is a commercial printer, are you using a profile from the manufacturer? If this is your design, or heavily modded, have you tried de-tuning the slicer parameters and/or the configuration parameters?</p> <p>Any debugging proceeds from the first step, so adjust the Z=0 plane and see if you can print a uniform, single layer print covering the while bed. When that is good, you are most of the way to victory.</p>
1,252
<p>I came across a new Steel infused PLA from <a href="https://colorfabb.com/steelfill" rel="nofollow noreferrer">Colorfabb</a>. On the store page someone had asked, what happens if it was exposed to water, would it rust. I am actually, not sure what would happen. I am interested what the effects of leaving in the elements a 3D printed object made of the 2 most common type of fused materials. </p> <ol> <li>Wood Infill</li> <li>Metal Infill (not stainless steel)</li> </ol> <p>Would it be preserved by the PLA coating it, or would, over time, rust and dissolve? Would the wood last forever, or will the print get discolored and become mulch? </p>
<p>The main issue here (the gaps between layers) was solved by reducing combing.</p> <p>Combing was enabled without a limit on the range so a max combing distance of 10&nbsp;mm was introduced. This prevented too much filament from oozing out during travels.</p> <p>The oozing filament was causing nothing to come out of the nozzle at the beginning of an extrusion, thus creating the gaps that were consistent in location.</p>
<p>These lines could be caused by a mechanical issue with the printer; it looks as if the positioning is not up to par. </p> <p>This can be related to loose belts of the X-axis and Y-axis, or play in your system, e.g. look at the rollers of the carriage.</p> <hr> <p><em>I've experienced an issue with play between the idler mounts and the smooth linear rods on a cheap 3D printer kit myself, but that is not the case here. Just added to explain where play may come from.</em></p>
1,431
<p>I have a Prusa i3 (from FLSun). I have assembled the printer, calibrated it (fairly decently), and have successfully demonstrated extrusion manually. However, when I try to run a print job (the G-code clearly contains E commands), the extruder motor never rotates. Is this a common problem? Any suggestsions for how to resolve/troubleshoot?</p> <p>I can confirm that the extruder was pre-heated for PLA (up to a generous 220 C).</p> <p>I load an STL file into Repetier v.1.0.2, use the built-in slicer (Slic3r) to generate the G-code. I include a sample of that below:</p> <pre><code>; generated by Slic3r 1.2.9 on 2017-11-08 at 10:54:07 ; external perimeters extrusion width = 0.50mm ; perimeters extrusion width = 0.72mm ; infill extrusion width = 0.72mm ; solid infill extrusion width = 0.72mm ; top infill extrusion width = 0.72mm M107 M104 S200 ; set temperature G28 ; home all axes G1 Z5 F5000 ; lift nozzle M109 S200 ; wait for temperature to be reached G21 ; set units to millimeters G90 ; use absolute coordinates M82 ; use absolute distances for extrusion G92 E0 G1 Z0.350 F7800.000 G1 E-2.00000 F2400.00000 G92 E0 G1 X76.952 Y76.952 F7800.000 G1 E2.00000 F2400.00000 G1 X78.055 Y75.850 E2.04824 F1800.000 G1 X78.650 Y75.324 E2.07282 G1 X81.121 Y73.387 E2.16997 G1 X81.780 Y72.933 E2.19472 G1 X84.467 Y71.309 E2.29186 G1 X85.167 Y70.940 E2.31635 G1 X88.143 Y69.602 E2.41730 </code></pre> <p>As an update, I can no longer reliably get the extruder motor to run (even when I pre-heat) from the LCD. Sometimes, it works fine, but other times it doesn't seem to. Will confirm whether switching the motor connector to the z-axis to test the motor works when I get home this evening.</p> <p>I can confirm 1) that there is no tension pulling on the cable connections during the run, 2) the mainboard and motor connector aren't burned, cracked, and the mosfets have heatsinks on them, and 3) the extruder gear is fixed and rotates freely on the motor axis (I tested this by switching it over to the z-axis connection temporarily and confirming rotation).</p> <p>Here's a photo of my motherboard:</p> <p><a href="https://i.stack.imgur.com/gRdQp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/gRdQp.jpg" alt="A photo of my motherboard"></a></p>
<p>According to all the information:</p> <ul> <li>No reassignment of the extruder in the Gcode</li> <li>You can extrude if you push the filament by hand</li> <li>Extruder motor works when switched to Z driver</li> <li>Z Motor works</li> </ul> <p>I come to the conclusion that some of your electronics or the motor have fried.</p> <p>What have fried? I tried to make a step by step check:</p> <p>Switch drivers between E and Z, but plug the motors as usual:</p> <p>1) Does the extruder extrude?</p> <p>Yes: Your driver has fried</p> <p>No:</p> <p>2) Were you able to move the Z motor?</p> <p>No: Motherboard And driver has fried</p> <p>Yes: </p> <p>3) Plug in the E motor on the Z driver, can you make the E motor turn?</p> <p>Yes: Motherboard fried</p> <p>No: Motor fried</p> <p>HTH and keep us updated if it worked or not!</p>
<p>This should have been a comment: when you say "manual extrusion", do you mean moving filament by hand or using extruder position commands from printer menu? Is extruder motor working at all? You can for example plug it instead of a Z-motor to check.</p> <p>Suggested points to check:</p> <ul> <li>Motor wire connections, both on extruder and mainboard. Are plugs experiencing tension (being tilted, pulled out) from improperly fixed cables?</li> <li>Hardware on mainboard next to motor connector. Does it look burned, cracked, lacks heatsinks on mosfets?</li> <li>Is extruder gear not fixed and rotating freely on extruder motor axis? You will hear sound of working motor, but it will look like it's not pulling the filament.</li> </ul>
729
<p>I've been wrestling with a filament grinding problem for a few weeks now and I'm stuck.</p> <p>The problem manifests itself as starting a print alright then extrusion stops while the printer keeps moving. When I pull the filament out I see indents from the gear then a depression where it ground down the filament.</p> <p>Filament used is 1.75 mm Spool3D PETG on a Hictop printer, which is a clone of a Prusa i3. I don't know the exact part number though. The extruder is direct drive, and the 28 mm heatbreak is connected to a heatsink block rather than something with fins. Nozzle is standard 0.4 mm.</p> <p>My print settings are quite conservative. Speed is 20 mm/s, retraction is 20 mm/s (though it never grinds on retraction), temperature is 255 °C, which is 10 °C higher than what works in my other printers. No print cooling.</p> <p>At first I thought there was a clog, but I can push the filament though by hand quite well. I also use cleaning filament frequently and it never pulls out any debris. Heatbreak and nozzle have been changed to fresh items.</p> <p>Does anybody have any other ideas of things I can try, or should I just get a new extruder?</p>
<p>Thingieverse does respect the orientation an item was designed in, just like most slicers will. Designers will often choose any one of the three planes (XY, YZ, ZX) as their first by preference, then work out the other parts in relation to the first. This does often not take into account the actual print orientation it should be printed in.</p> <p>In the case of this box, you'd have to turn all items around the Y-axis (the front-left to back-right one) by 90°, first to the <em>front</em>, then the <em>back</em> then to the <em>front</em> again, getting almost 0 overhangs.</p>
<p>When I design parts in CAD software I pick a starting plane and go from there. And that starting plane doesn't correspond to how the part is designed to be printed. That usually comes later.</p>
1,725
<p>I'm writing a PHP script that involves scraping web pages. Currently, the script analyzes the page line by line, but it breaks if there is a tag that spans multiple lines, like </p> <pre><code>&lt;img src="example.jpg" alt="example"&gt; </code></pre> <p>If worse comes to worst, I could possibly preprocess the page by removing all line breaks, then re-inserting them at the closest <code>&gt;</code>, but this seems like a kludge.</p> <p>Ideally, I'd be able to detect a tag that spans lines, conjoin only those to lines, and continue processing.<br> So what's the best method to detect this?</p>
<p>This is one of my pet peeves: <em>never</em> parse HTML by hand. <em>Never</em> parse HTML with regexps. <em>Never</em> parse HTML with string comparisons. <em>Always</em> use an HTML parser to parse HTML – that's what they're there for.</p> <p>It's been a long time since I've done any PHP, but a quick search turned up <a href="http://SimpleHTMLDom.SourceForge.Net/" rel="noreferrer" title="PHP Simple HTML DOM">this PHP5 HTML parser</a>.</p>
<p>Why don't you read in a line, and set it to a string, then check the string for tag openings and closings, If a tag spans more then one line add the next line to the string and move the part before the opening brace to your processed string. Then just parse through the entire file doing this. Its not beautiful but it should work.</p>
5,391
<p>I need to create a quick-n-dirty knob control in Visual Basic 2005 Express, the value of which is incremented/decremented by "grabbing" it with the mouse and moving the cursor up/down. Because the knob itself doesn't move, I need to keep tracking the mouse movement outside of the rectangle of the control.</p> <p>I use a <code>Label</code> with an <code>ImageList</code> to implement this (I have a list of 127 bitmaps representing the knob in various positions).</p> <p>Which events should I react to?</p>
<p>Yeah, it is messy, I can't think of a way to avoid it though.<br> You could hide some of the messiness from the client by putting the temporary table creation in a stored procedure (and using "execute immediate" to create they table)<br> One thing you will need to watch out for is left over temporary tables (should something fail half way through a session, before you have had time to clean it up) - you could schedule an oracle job to periodically run and remove any left over tables. </p>
<p>Do you have a specific scenario in mind? For example, if the LOB holds files, and you are on a company intranet, perhaps you can write a stored procedure to extract the files to a known directory on the network and access them from there.</p>
5,902
<p>When I print with PLA, I get a perfect first layer.</p> <p>However, when I print with PETG, the first layer looks like this:</p> <p><a href="https://i.stack.imgur.com/pceRa.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/pceRa.jpg" alt="enter image description here"></a></p> <p>I've read all the info that suggests reducing the temp, speed, and increasing retraction... I've done all that which has improved things a lot, but I still get this... I can't seem to work out what's causing it.</p> <p>How do I get a perfect first layer with PETG?</p> <p>The latest settings that I've tried, and produced what you see in the picture are, using Cura 4.3 standard Dynamic Quality 0.16&nbsp;mm profile with these tweaks:</p> <ul> <li>Temp: 220&nbsp;°C</li> <li>Bed: 65&nbsp;°C</li> <li>Retraction Distance: 10&nbsp;mm (not that this would have any bearing on this flat first layer)</li> <li>Print Speed: 40&nbsp;mm/s</li> </ul> <p>One thought I had, does PETG need a different clearance between the nozzle and the bed than PLA?</p>
<blockquote> <p>One thought I had, does PETG need a different clearance between the nozzle and the bed than PLA?</p> </blockquote> <p>Short answer: "Yes, for some it does".</p> <hr> <p>The results from your image are typically seen when the initial layer height for PETG is too small. PETG likes an additional gap on top of the usual that is used to print e.g. PLA.</p> <p>For me personally I don't experience this general consensus (I've printed kilometers of PETG filament at 0.2 mm initial layer height at a glass bed with 3DLAC spray without any problems), but it is well known that if you print PETG (and if you experience problems) you need to increase the gap between the nozzle and the bed. From <a href="https://rigid.ink/blogs/news/175700615-petg-filament-heres-what-you-need-to-know" rel="nofollow noreferrer">"PETG Filament - Overview, Step-by-Step Settings &amp; Problems Resolved"</a> posted on rigid.ink, you see that they (usually) advise an additional 0.02&nbsp;-&nbsp;0.05&nbsp;mm gap:</p> <p><a href="https://i.stack.imgur.com/3kvcx.png" rel="nofollow noreferrer" title="Additional 0.02&nbsp;-&nbsp;0.05&nbsp;mm PETG gap"><img src="https://i.stack.imgur.com/3kvcx.png" alt="Additional PETG gap" title="Additional 0.02&nbsp;-&nbsp;0.05&nbsp;mm PETG gap"></a></p> <p>Bottom line, if the normal gap doesn't work for you, increase the gap to see if that works better. Note that in some slicers you can add an offset in the slicer so that you do not have to do the releveling with a thicker paper (or if you are using auto-levelling). E.g. in Ultimaker Cura you can download a plugin (for recent Cura versions from the marketplace) from user <a href="https://github.com/fieldOfView/Cura-ZOffsetPlugin" rel="nofollow noreferrer">fieldOfView</a> called "Z Offset Setting" to get the <code>Z Offset</code> setting in the <code>Build Plate Adhesion</code> section. You can also do a little trick in the G-code by redefining the height so that you can put this in a PETG start G-code or something.</p>
<p>When I print with PETG, my bed is 80 °C for first 2 layers then I drop it to 65 °C</p> <p>Extruder temp first two layers 240-250 °C and then drop to 225-230 °C.</p>
1,486
<p>My website will be using only OpenID for authentication. I'd like to pull user details down via attribute exchange, but attribute exchange seems to have caused a lot of grief for StackOverflow.</p> <p>What is the current state of play in the industry? Does any OpenID provider do a decent job of attribute exchange?</p> <p>Should I just steer away from OpenID attribute exchange altogether?</p> <p>How can I deal with inconsistent support for functionality?</p>
<p>Here on Stack Overflow, we're just using the <a href="http://openid.net/specs/openid-simple-registration-extension-1_0.html" rel="noreferrer">Simple Registration</a> extension for now, as there were some issues with Attribute Exchange (AX).</p> <p>The biggest was OpenID Providers (OP) not agreeing on which <a href="http://www.axschema.org/types/" rel="noreferrer">attribute type urls</a> to use. The finalized spec for AX says that attribute urls should come from <a href="http://www.axschema.org/" rel="noreferrer">http://www.axschema.org/</a> However, some OPs, especially our favorite <a href="http://myopenid.com" rel="noreferrer">http://myopenid.com</a>, recognize <a href="http://openid.net/pipermail/general/2008-February/004158.html" rel="noreferrer">other</a> <a href="http://rakuto.blogspot.com/2008/03/ruby-fetch-some-attributes-from.html" rel="noreferrer">urls</a>. I wasn't going to keep a list of which ones were naughty and which were nice!</p> <p>The other problem was that most of the OPs I tried just didn't return information when queried with AX - I might have been doing something wrong (happens quite frequently :) ), but I had made relevant details public on my profiles and we're using the latest, most excellent .NET library, <a href="http://code.google.com/p/dotnetopenid/" rel="noreferrer">DotNetOpenId</a>.</p> <p>We'll definitely revisit AX here on Stack Overflow when we get a little more time, as a seamless user experience is very important to us!</p>
<p>While Attribute Exchange has it's problems (I'm sure someone from SO can tell you more), it does have <a href="http://blogs.gnome.org/jamesh/2007/11/26/openid-ax/" rel="nofollow noreferrer">a lot of benefits</a>. To some extent it depends on whether you really need it or not. Simple Registration seems to do that job, and it might make sense to just ask the user for certain values. Use common sense and don't get stuck shoving everything down the One True Way.</p>
3,301
<p>I'm running WAMP v2.0 on WindowsXP and I've got a bunch of virtual hosts setup in the http-vhosts.conf file.</p> <p>This was working, but in the last week whenever I try &amp; start WAMP I get this error in the event logs:</p> <blockquote> <p>VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results.</p> </blockquote> <p>and the server won't start. I can't think of what's changed. </p> <p>I've copied the conf file below.</p> <pre><code>NameVirtualHost * &lt;VirtualHost *:80&gt; ServerName dev.blog.slaven.net.au ServerAlias dev.blog.slaven.net.au ServerAdmin user@host.com DocumentRoot "c:/Project Data/OtherProjects/slaven.net.au/blog/" ErrorLog "logs/blog.slaven.localhost-error.log" CustomLog "logs/blog.slaven.localhost-access.log" common &lt;Directory "c:/Project Data/OtherProjects/slaven.net.au/blog/"&gt; Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all &lt;/Directory&gt; &lt;/VirtualHost&gt; </code></pre> <p><strong>EDIT:</strong> I meant to add, if I change the NameVirtualHosts directive to specify a port, i.e</p> <pre><code>NameVirtualHost *:80 </code></pre> <p>I get this error:</p> <blockquote> <p>Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80 </p> </blockquote>
<blockquote> <p>NameVirtualHost *:80</p> <p>I get this error:</p> <p>Only one usage of each socket address (protocol/network address/port) is normally >permitted. : make_sock: could not bind to address 0.0.0.0:80</p> </blockquote> <p>I think this might be because you have somthing else listening to port 80. Do you have any other servers (or for example Skype) running?</p> <p>(If it was Skype: untick "Tools > Options > Advanced > Connection > Use port 80 and 443 as alternatives for incoming connections")</p>
<p>Well, it seems the problem there is the way (and order) in which you assign the ports. </p> <p>Basically, *:80 means "use port 80 for all hosts in this configuration". When you do this, Apache tries to bind that host to 0.0.0.0:80, which means that host will receive every single packet coming to the machine through port 80, regardless of what virtual host it was intended to go to. That's something you should use only once, and only if you have <em>one</em> host in that configuration.</p> <p>Thus, if you have the same *:80 directive on two hosts in the configuration file, the server won't load because it will try to bind 0.0.0.0:80 twice, failing on the second try. (which explains the "Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80" message).</p>
6,003
<p>I want to build my own custom log4j (network) adapter to solve my problem <a href="https://stackoverflow.com/questions/29505/deserialize-in-a-different-language">that I posted here.</a></p> <p>I have looked at the documentation on the log4j and I cant see where/if the developers go into how to do this.</p> <p>Can anyone point me in the right direction to get started?</p>
<p><a href="http://www.javaworld.com/javaworld/jw-12-2004/jw-1220-toolbox.html" rel="nofollow noreferrer">Write custom appenders for log4j</a></p>
<p>May I suggest that you leverage the existing SyslogAppender?</p>
6,933
<p>Recently my RAMPS power connector caught fire while heating the heated bed. I suspect this was a defect caused by the connector, and de-soldered/removed it as best I could. I'm not an electrical engineer, so I'm looking for advice on whether It is possible to re-solder the power connectors directly onto the board, or I'm just risking another fire. Here are pictures of the top and bottom.</p> <p><img src="https://i.stack.imgur.com/BFnKQ.jpg" alt="Top side of PCB and underside of power screw terminals, showing burning" title="Top side of PCB and underside of power screw terminals, showing burning" /></p> <p><img src="https://i.stack.imgur.com/oWCMH.jpg" alt="Underside of PCB" title="Underside of PCB" /></p>
<p>The blue clips stick in the connector on the extruder end of the feed tube. They are to keep it from opening as the printer extrudes and retracts filament.</p> <p>To install them, push them in between the white part of the fitting on the feed tube (not the hot end). You should only need one or two, and they are all of varying thicknesses. If you're not familiar with these fittings, I found a <a href="https://www.youtube.com/watch?v=6BummHzgf5c" rel="nofollow noreferrer">YouTube video</a> on how to use them.</p> <p><a href="https://i.stack.imgur.com/JsuQ4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JsuQ4.jpg" alt="Fitting clips on a Creality Ender-3 feed tube"></a></p>
<p>The clips or collet clips as they are called are to secure the Bowden tube more solidly to improve printer extrusion; more specifically: extruder retraction performance.</p> <p>E3D has explained this very nicely on their site under <a href="https://e3d-online.com/blog/2017/10/27/bowden-tube-physics/" rel="nofollow noreferrer">Bowden tube physics</a>:</p> <blockquote> <p>For the bowden couplings (which can have some wiggle room in them) we are introducing collet clips, which slide under the toothed collet part of the coupling that physically holds the tube and locks it into place with a little pre-tension to boot. This reduces coupling lash to near zero as the collet and tube it is holding are locked into place.</p> </blockquote> <p><a href="https://i.stack.imgur.com/YobdM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YobdM.png" alt="Bowden collet clips principle"></a></p> <p>From the <a href="https://i.imgur.com/RTWnzB5.gif" rel="nofollow noreferrer">animated gif from the E3D website</a> (animated gifs are not allowed on SE) it can be seen that without clips, the tube can move in the tube coupling: <a href="https://i.stack.imgur.com/YfzfWm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YfzfWm.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/2OpuTm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2OpuTm.png" alt="enter image description here"></a></p>
1,625
<p>I've had my Ender 3 for almost three weeks, gone through about a kilogram of PLA filament (printing a mix of upgrade parts for the Ender 3 and stuff I actually want to use) and made one PETG object, generally with good results.</p> <p>I've noticed however, as seems relatively common (per YouTubers, anyway), that my bed isn't <em>flat</em> -- that is, the build surface isn't a good approximation of a geometric plane. If I adjust the bed to have correct clearance (good adhesion and correct single-line width) at the corners, I'll get adhesion failure in the center, and if I adjust to give a correct center, the extruded filament will be squished into the build surface texture; the nozzle may even lightly scatch the surface at the corners. That indicates the corners are high, relative to the center, by roundly 0.1 to 0.15 mm.</p> <p>I'm aware of BLTouch and its clones, but in order to get full use of that system (which automatically compensates for the non-planar bed) I would need to not only install the surface sensing hardware, but flash my printer's firmware (potentially after removing the control module cover and plugging a cable and adapter into the mainboard). As a longtime builder/upgrader of my own computers, this is certainly within my capability, but I'd prefer to make my build surface flat instead of applying software corrections; I see this as upgrading from a 386 to a Core i3 because the computer is overheating -- that is, the problem will go away because of all the other stuff you have to do, but you haven't really <em>solved the problem</em>.</p> <p>My general idea more or less mimics the self-answer on <a href="https://3dprinting.stackexchange.com/questions/11996/options-for-getting-a-really-flat-build-surface">this question</a> in terms of measuring the excursion and applying shims under the build surface (I've installed the Creality magnetic sheet surface, so shims would be applied between the magnetic base sheet and the removable build surface). I plan to use household aluminum foil, standard weight, which is generally close to 0.63 mil (= .016 mm), applied with repositionable spray adhesive and laid down in layers, using a combination of feeler gages and single-layer test prints to determine where and how much foil to apply.</p> <p>I've &quot;test flown&quot; this option by putting a single Post-It sheet under the center of the removable build surface, and now I have a much closer match between the center and corners, and can (depending on my nozzle standoff) actually see the outline of the makeshift shim in the first layer where it prints over the edges of the Post-It.</p> <p>Is there anything I'm missing that would prevent this shimming method using aluminum foil from resolving the warped bed to allow me to depend on an even thickness and correctly adhered first layer?</p>
<p>I may be biased as my question/answer is the one I believe you're asking this question in reference to, but I would say that yes, it not only competes but is a far better solution. &quot;Auto-leveling&quot; systems <strong>do not level</strong> your bed. They just partially compensate for poor adhesion by adjusting the bottom layer(s) of your print to conform to the bed's errors. This of course messes up the dimensional accuracy of your prints; in a worst case it can come out <a href="https://3dprinting.stackexchange.com/questions/16284/height-of-the-prints-are-always-larger">rather absurd</a>. They also do not compensate for the change in volume (which would require differing extrusion amounts) due to changes in Z height to compensate for the non-level bed.</p> <p>The right solution is always to get your bed level and flat. Ideally if the bed/print surface is warped, you replace it with one that's not, but shimming is a reasonable alternative. ABL systems (not talking about real 3-point leveling with 3 Z motors here, but &quot;ABL&quot; stuff like BLTouch) are a gimmick for making it easy for beginners to start printing without all their prints failing due to non-adhesion from poor manual leveling. They're not a solution.</p>
<p>So, the difference between the shimming vs. auto-leveling is that auto-leveling goes around in a 4x4 grid taking measurements of the bed (you do need to set the Z calibration first, as you know) vs. the shimming method where you go to 4 corners on your build plate where you stick a piece of paper or something under there and you adjust the knob at the bottom until you can feel tension on it. What I've found to be the best for me at least is to use both. This is my method for printing every time:</p> <ol> <li><p>Clean the build plate. I will take my scrapper and scrape everything off, then I will run it under some hot water and wipe all of the residue off that is still remaining, then I might take some glass cleaner or something and wipe it down.</p> </li> <li><p>Set the Z calibration.</p> </li> <li><p>Do the shimming leveling (I would normally go through all of the corners again plus the center/Z calibration just to make sure that I didn't mess up any of the other corners.</p> </li> <li><p>I will run the auto-calibration (I use OctoPrint so I just run it through there)</p> </li> <li><p>Smear Elmer's glue over the print bed. I do this for a couple of reasons:</p> <ol> <li>I use the glass side of the bed, just because I've gotten better results this way, and</li> <li>it just makes your prints stick better. I also do this after the Z calibration and bed calibration because you get better results this way.</li> </ol> </li> <li><p>Start the print and watch the first couple of layers. If you notice that when you are printing and the brim looks stringy, like you could pick apart the individual lines, you should cancel the print, and go back to your slicer and bring your line width down my 0.1 mm, I typical print with the lines 0.1 mm or 0.2 mm below what the nozzle prints at, so a 0.5 mm nozzle I will print at 0.4 mm. And if your print messes up here I'd scrape everything off so the filament and the glue off (I'd keep the bed hot and the tip hot just so I don't have to wait 10 min. for it to heat up again) then apply more glue and reprint.</p> </li> </ol>
1,947
<p>I using SharePoint Designer to create a workflow. I'm trying to get at a sub-folder in a document library in the "Define Workflow Lookup" dialog. There are two issues with this:</p> <ol> <li>I can't look up items by URL Path. If I look up by Title, I can output the URL Path, but selecting by path doesn't work. What fields can/can't I use?</li> <li>I can't get at any sub-folders. I can get at the top-level folder, but the sub-folders don't seem to be available. Noticed the same things is true when looking at the data for a document library in the "Data Source Library" in Designer.</li> </ol> <p>To clarify, the workflow is on a different list, not on the document library.</p> <p><strong>UPD:</strong> Also, I know how to do this through the object model, the question is how to do it in SharePoint Designer without deploying code to the server.</p>
<p>I really don't have much experience with Sharepoint, but I thought I could at least provide <em>some</em> answer - even if it's the wrong one.</p> <p>From another dev I've spoken to it sounds like it's tough to get into any subfolders, so you might need to look at making your own custom workflow.</p> <p>Maybe something like LINQ to Sharepoint might be able to help you with actually getting in and enumerating the subfolders and getting to the data that you need? <a href="http://www.codeplex.com/LINQtoSharePoint" rel="nofollow noreferrer">LINQ to Sharepoint</a></p>
<p>The issue is that "folders" are not really folders as they are accessed by querystring, not a "/" as with real folders.</p>
5,340
<p>I have just started working with the <code>AnimationExtender</code>. I am using it to show a new div with a list gathered from a database when a button is pressed. The problem is the button needs to do a postback to get this list as I don't want to make the call to the database unless it's needed. The postback however stops the animation mid flow and resets it. The button is within an update panel.</p> <p>Ideally I would want the animation to start once the postback is complete and the list has been gathered. I have looked into using the <code>ScriptManager</code> to detect when the postback is complete and have made some progress. I have added two javascript methods to the page.</p> <pre><code>function linkPostback() { var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(playAnimation) } function playAnimation() { var onclkBehavior = $find("ctl00_btnOpenList").get_OnClickBehavior().get_animation(); onclkBehavior.play(); } </code></pre> <p>And I’ve changed the <code>btnOpenList.OnClientClick=”linkPostback();”</code></p> <p>This almost solves the problem. I’m still get some animation stutter. The animation starts to play before the postback and then plays properly after postback. Using the <code>onclkBehavior.pause()</code> has no effect. I can get around this by setting the <code>AnimationExtender.Enabled = false</code> and setting it to true in the buttons postback event. This however works only once as now the AnimationExtender is enabled again. I have also tried disabling the <code>AnimationExtender</code> via javascript but this has no effect.</p> <p>Is there a way of playing the animations only via javascript calls? I need to decouple the automatic link to the buttons click event so I can control when the animation is fired.</p> <p>Hope that makes sense.</p> <p>Thanks</p> <p>DG</p>
<p>The flow you are seeing is something like this:</p> <ol> <li>Click on button</li> <li>AnimationExtender catches action and call clickOn callback</li> <li>linkPostback starts asynchronous request for page and then returns flow to AnimationExtender</li> <li>Animation begins</li> <li>pageRequest returns and calls playAnimation, which starts the animation again</li> </ol> <p>I think there are at least two ways around this issue. It seems you have almost all the javascript you need, you just need to work around AnimationExtender starting the animation on a click.</p> <p>Option 1: Hide the AnimationExtender button and add a new button of your own that plays the animation. This should be as simple as setting the AE button's style to "display: none;" and having your own button call linkPostback().</p> <p>Option 2: Re-disable the Animation Extender once the animation has finished with. This should work, as long as the playAnimation call is blocking, which it probably is:</p> <pre><code>function linkPostback() { var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(playAnimation) } function playAnimation() { AnimationExtender.Enabled = true; var onclkBehavior = $find("ctl00_btnOpenList").get_OnClickBehavior().get_animation(); onclkBehavior.play(); AnimationExtender.Enabled = false; } </code></pre> <p>As an aside, it seems your general approach may face issues if there is a delay in receiving the pageRequest. It may be a bit weird to click a button and several seconds later have the animation happen. It may be better to either pre-load the data, or to pre-fill the div with some "Loading..." thing, make it about the right size, and then populate the actual contents when it arrives.</p>
<p>With help from the answer given the final solution was as follows:</p> <p>Add another button and hide it.</p> <pre><code>&lt;input id="btnHdn" runat="server" type="button" value="button" style="display:none;" /&gt; </code></pre> <p>Point the AnimationExtender to the hidden button so the firing of the unwanted click event never happens.</p> <pre><code>&lt;cc1:AnimationExtender ID="aniExt" runat="server" TargetControlID="btnHdn"&gt; </code></pre> <p>Wire the javascript to the button you want to trigger the animation after the postback is complete.</p> <pre><code>&lt;asp:ImageButton ID="btnShowList" runat="server" OnClick="btnShowList_Click" OnClientClick="linkPostback();" /&gt; </code></pre> <p>Add the required Javascript to the page.</p> <pre><code>function linkPostback() { var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(playOpenAnimation) } function playOpenAnimation() { var onclkBehavior = ind("ctl00_aniExt").get_OnClickBehavior().get_animation(); onclkBehavior.play(); var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.remove_endRequest(playOpenAnimation) } </code></pre>
7,198
<pre><code>Nozzle diameter = .4 Extrusion multiplier = 1 Extrusion Width = .45 &lt;-- I feel like this could be reduced to fix it? Layer Height = .3 </code></pre> <p>I'm using Simplify3D.</p> <p><a href="https://i.stack.imgur.com/SsiMS.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/SsiMS.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/1tTZ5.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/1tTZ5.jpg" alt="enter image description here"></a></p>
<p>If it's on each corner, and not the layer change corner, it's a combination of overshoot and the short "pause" of the printer when it changes direction. </p> <p>You can minimize it, but it won't go away 100% (due to overshoot from direction changes), usually models with a slight rounded corners work great. If you, say, increase the jerk as an experiment and they get sharper (but you obviously have to deal with potential ringing artifacts) then it's due to that pause and acceleration after a direction change.</p> <p>I would try lowering the temperature a bit to slow the flow/oozing of the nozzle and calibrate extrusion - just to keep the settings tight as possible to keep dimensional accuracy, but not under extrude obviously. </p> <p>If it's where a layer change occurs, tweak and play with retraction settings - such as coasting and extra distance on restart (you can put negative values here). Once those are set, as an advanced tweak, try to max the z speed... Obviously this involves motor current, testing for skipped steps etc... but this would make the layer change a bit quicker, to further reduce oozing, due to the delay in layer changes if retraction settings don't fix it. </p> <p>Usually, you can fix the corners with retraction settings but then it can mess up other parts of a model, since those settings are global... I wish slicers were more intelligent. </p>
<p>Your printer is over extruding.</p> <p>It looks like PLA on the photo, the preset multiplier in S3D is 0.90 (not 1.0!)</p> <p>The nozzle diameter should be the same as the extrusion width (both 0.40).</p> <p>When you set the width to auto you get a bigger width. I don't really know why, but it was told me so.</p> <p>If you print 1.75 mm you have to measure it and (the actual diameter is often around 1.78 mm, maybe less too). The multiplier of 0.9 is because PLA is softer then ABS for example. Maybe you should try other multipliers as well, maybe down to 0.85 in 0.01 steps.</p> <p>I hope you can figure this problem out. I am experimenting by myself for days now to get it as sharp as possible. The goal is to get an edge with the diameter of the nozzle - not a bit more.</p>
473
<p>How would you write (in C/C++) a macro which tests if an integer type (given as a parameter) is signed or unsigned?</p> <pre> #define is_this_type_signed (my_type) ... </pre>
<p>If what you want is a simple macro, this should do the trick:</p> <pre><code>#define is_type_signed(my_type) (((my_type)-1) &lt; 0) </code></pre>
<p>You could do this better with a template function, less macro nasty business.</p> <pre><code> template &lt;typename T&gt; bool IsSignedType() { // A lot of assumptions on T here T instanceAsOne = 1; if (-instanceAsOne &gt; 0) { return true; } else { return false; } } </code></pre> <p>Forgive the formatting...</p> <p>I would try this out and see if it works...</p>
9,051
<p>I've been working on my own DIY 3-D printer recently, and I've been trying to experiment a little with different materials for the body. Someone suggested using HDPE (high-density polyethylene), since it works well on a CNC machine, which would make creating a number of prototypes easy. I know HDPE can also be used for filament, but I've never tried it before. Does anybody have any input on HDPE, or other potential materials for the body? I'm trying to avoid using wood, as I've had some poor experiences with it.</p>
<p>I've used what is commonly described as UHMW-PE, aka, Ultra-high Molecular Weight Polyethylene for various projects. You may know this material is often used in cutting boards, as it cleans easily and doesn't cut easily.</p> <p>it does machine in a manner similar to aluminum, although the tool should be cooled/lubricated to prevent a build-up of melted plastic on the cutting edges. You can get away without coolant or lubricant if cutting speeds are slow and the swarf is cleared away from the cutter.</p> <p>I'd not considered such a material for constructing a 3d printer, as it's expensive, but I've also not compared the prices to equivalent sizes of aluminum. </p> <p>I'd consider that the use in a 3d printer would be a good substitute for lexan, as one can tighten the bolts without fear of cracking. For bolts subject to rotation or vibration, self-locking nuts are a good idea. If you have use of a broach, cutting out a pocket for the nuts would be easily accomplished.</p> <p>I have downloaded the plans for the open-source 3d printer known as DICE, which calls for aluminum, but the pricing I've found was excessive for the right quantities. I think I'll explore the same bill of materials in HDPE or UHMW-PE (which may be different names for the same substance).</p> <p>Equally useful to know is that the material is very slippery, effectively self-lubricating under the right conditions. Unfortunately, for a 3d printer application, I don't believe the self-lubricating part would work for carriages but might be fun to try with linear slides.</p> <p>It is not as stiff as aluminum, so where stiffness is needed and not provided by the architecture, a thicker piece may be indicated. I can just barely bend with my fingers a piece of 3&nbsp;mm (1/8") a small amount, but cannot do so for aluminum.</p> <p>Here's the result of a quick search for UHMWPE: <a href="https://www.interstateplastics.com/Uhmw-Natural-Virgin-Sheet-UHMNV~~SH.php?thickness=0.125&amp;dim2=12&amp;dim3=24" rel="nofollow noreferrer">https://www.interstateplastics.com/Uhmw-Natural-Virgin-Sheet-UHMNV~~SH.php?thickness=0.125&amp;dim2=12&amp;dim3=24</a> which gives a price for 1/8" white sheet 24&nbsp;x&nbsp;12" as US\$&nbsp;26.06 while the black version is available only as thin as 1/4" for about US$&nbsp;28.00</p> <p>The equivalent size in aluminum 6061T6 at onlinemetals.com is about US\$&nbsp;3.00 more expensive. That is lower than I expected, skewing the idea farther away from UHMWPE than one might hope. The equivalent for 1/4" is almost US\$&nbsp;60, quite a bit higher. </p> <p>It would appear that if you need the thicker stuff, the price is better for plastic, not so good for the aluminum.</p>
<p>I've tried this material (8 mm thickness) for a Prusa i3 clone of my own design but needed to abandon using it as it doesn't allow to be cut by laser easily on my friends laser cutting machine (not a hobby laser cutting machine, it is his business). </p> <p>HDPE requires lower speed than cutting Plexiglas or Acrylic resulting in more heat input and a small top cut and a large bottom cut width leaving the edges far from being straight.</p>
303
<p>How do I list the symbols being exported from a .so file? If possible, I'd also like to know their source (e.g. if they are pulled in from a static library).</p> <p>I'm using gcc 4.0.2, if that makes a difference.</p>
<p>The standard tool for listing symbols is <code>nm</code>, you can use it simply like this:</p> <pre><code>nm -gD yourLib.so </code></pre> <p>If you want to see symbols of a C++ library, add the "-C" option which demangle the symbols (it's far more readable demangled).</p> <pre><code>nm -gDC yourLib.so </code></pre> <p>If your .so file is in elf format, you have two options:</p> <p>Either <code>objdump</code> (<code>-C</code> is also useful for demangling C++):</p> <pre><code>$ objdump -TC libz.so libz.so: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: 0000000000002010 l d .init 0000000000000000 .init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 free 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __errno_location 0000000000000000 w D *UND* 0000000000000000 _ITM_deregisterTMCloneTable </code></pre> <p>Or use <code>readelf</code>:</p> <pre><code>$ readelf -Ws libz.so Symbol table '.dynsym' contains 112 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000002010 0 SECTION LOCAL DEFAULT 10 2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND free@GLIBC_2.2.5 (14) 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __errno_location@GLIBC_2.2.5 (14) 4: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable </code></pre>
<p>If you just want to know if there are symbols <em>present</em> you can use</p> <pre><code>objdump -h /path/to/object </code></pre> <p>or to list the debug info</p> <pre><code>objdump -g /path/to/object </code></pre>
5,510
<p>I like Tinkercad so far for it's very simple UI. (I'm new to 3D modeling and very confused by Blender and the like.) However, I'm not using it to do 3D printing just yet. For I'd like to be able to be to slap textures on the models I make and get images of that. What is the easiest beginner way to do that (for Linux OS)?</p> <p>Alternately, displaying the .obj directly in the browser with a texture would be great, too.</p>
<p>For your purposes, consider that Meshmixer (free) can open .OBJ files and display them in any position you desire.</p> <p>I use Meshmixer quite a bit for model editing, but have not used it for .OBJ files with textures. I searched my drive and found quite a few .OBJ files, but was not able to present or add textures, due to my own ignorance, I'm sure.</p> <p>I found a useful link to a <a href="https://forums.autodesk.com/t5/meshmixer/obj-import-in-meshmixer-without-texture/td-p/8007101" rel="nofollow noreferrer">support page</a> on the 'net which indicates that there has to be a texture file as well as a definition file (.MTL) in order to display the textures in Meshmixer. Using that reference, I was able to add a randomly selected .PNG file and apply the texture to a test model.</p> <p>If your creations do not include those support files, this may not be a good answer. There's little to lose, however, as the program is free and you may find use for it in the future, or you may find that it works as you require.</p>
<p>Consider using Clara.io (100% free):</p> <ul> <li>Export your Tinkercad project as OBJ.</li> <li>Import in Clara.io</li> <li>Texture and render.</li> </ul> <p>Clara.io is 100% web based. It is simple to learn if you have prior experience with other 3D renderers. If you don't, the learning curve might be steep though...</p> <p>But : you have access to VRAY which in a free-to-use package, is simply awesome...</p>
1,113
<p>I'm trying to print large objects (around 1 meter squared) with polycarbonate pellets. The problem is sometimes the print cracks. It is not due to delamination as it is a shear crack across multiple layers. I know the ideal scenario is to have a heated enclosure but I cannot do that due to the size. Any suggestions?</p> <p>I am using a robotic arm (KUKA KR360) with a custom extruder. That is why I can't build the enclosure. As for the temperature, they are 230 to 260 °C. Nozzle is 10 mm.</p> <hr /> <p><em>I like the idea of directed heat. I might try that.</em></p>
<p>Printing polycarbonate requires a high end 3D printer that is suitable for the task.</p> <p>From <a href="https://www.simplify3d.com/support/materials-guide/polycarbonate/" rel="nofollow noreferrer">Simplify3d support</a> we learn that:</p> <blockquote> <p>... requires very high temperatures for printing and will <strong>exhibit layer separation if printed at too low of a temperature or with excessive cooling enabled</strong>. Polycarbonate is frequently <strong>best printed on a machine that has an enclosed build volume</strong> and is capable of handling high bed and extruder temperatures.</p> </blockquote> <p>High temperatures and enclosed build volume are key to print polycarbonate without cracking or delamination.</p> <blockquote> <p>Any suggestions?</p> </blockquote> <p>Note that NASA has successfully printed ULTEM (even higher temperatures needed) <a href="https://ntrs.nasa.gov/citations/20170000214" rel="nofollow noreferrer">using open source hardware</a>. They have used infrared lamps directed at the build plate, this may be an option if a full enclosure is not possible. Also people seem to get good results with draft shields for printing ABS on non enclosed printers. Key is that a constant elevated temperature is created near the print, whether that works for such a large size remains to be seen. Best solution would be enclosing the printer.</p>
<p>Sounds like your problem is cooling, which would be mitigated by an enclosure to eliminate draughts and hold a higher air temperature.</p> <p>I made an enclosure using parts-on-hand and some printed PLA joiners. It doesn't have to be fancy or expensive to work well.</p> <p>Details are at <a href="https://3dprinting.stackexchange.com/a/18406/12956">https://3dprinting.stackexchange.com/a/18406/12956</a></p> <p>Next step is to sew some thermal &quot;curtains&quot; as sides and top. As it is I simply hang some coats around the frame in the short term, and use a Pi camera inside to monitor the progress from remote.</p>
2,057
<p>What is the best way people have found to do String to Lower case / Upper case in C++?</p> <p>The issue is complicated by the fact that C++ isn't an English only programming language. Is there a good multilingual method?</p>
<pre><code>#include &lt;algorithm&gt; std::string data = "Abc"; std::transform(data.begin(), data.end(), data.begin(), ::toupper); </code></pre> <p><a href="http://notfaq.wordpress.com/2007/08/04/cc-convert-string-to-upperlower-case/" rel="noreferrer">http://notfaq.wordpress.com/2007/08/04/cc-convert-string-to-upperlower-case/</a></p> <p>Also, CodeProject article for common string methods: <a href="http://www.codeproject.com/KB/stl/STL_string_util.aspx" rel="noreferrer">http://www.codeproject.com/KB/stl/STL_string_util.aspx</a></p>
<p>What Steve says is right, but I guess that if your code had to support several languages, you could have a factory method that encapsulates a set of methods that do the relevant toUpper or toLower based on that language.</p>
3,259
<p>Currently we have a project with a standard subversion repository layout of:</p> <p>./trunk<br> ./branches<br> ./tags</p> <p>However, as we're moving down the road of OSGi and a modular project, we've ended up with:</p> <p>./trunk/bundle/main<br> ./trunk/bundle/modulea<br> ./trunk/bundle/moduleb ./tags/bundle/main-1.0.0<br> ./tags/bundle/main-1.0.1<br> ./tags/bundle/modulea-1.0.0</p> <p>The 'build' is still quite monolithic in that it builds all modules in sequence, though I'm starting to wonder if we should refactor the build/repository to something more like:</p> <p>./bundle/main/trunk<br> ./bundle/main/tags/main-1.0.0<br> ./bundle/main/tags/main-1.0.1<br> ./bundle/modulea/trunk<br> ./bundle/modulea/tags/modulea-1.0.0 </p> <p>In this pattern I would imagine each module building itself, and storing its binary in a repository (maven, ivy, or another path of the subversion repository itself).</p> <p>Are there guidelines or 'best-practices' over project layouts once one goes modular?</p>
<p>The Subversion book contains two sections on this:</p> <ul> <li><a href="http://svnbook.red-bean.com/en/1.4/svn.branchmerge.maint.html#svn.branchmerge.maint.layout" rel="nofollow noreferrer">Repository Layout</a></li> <li><a href="http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout" rel="nofollow noreferrer">Planning Your Repository Organization</a></li> </ul> <p>A blog entry on the subject: <a href="http://blogs.collab.net/subversion/subversion_repo" rel="nofollow noreferrer">"Subversion Repository Layout"</a></p> <p>The short answer, though: while your mileage will vary (every situation is individual), your <code>/bundle/&lt;project&gt;/(trunk|tags|branches)</code> scheme is rather common and will likely work well for you.</p>
<p>I've answered a similar question in a StackOverflow <a href="https://stackoverflow.com/questions/16829/structure-of-projects-in-version-control#16915">Version Control Structure question</a>. It actually fits even better here since we do heavy OSGi development and have lots of bundles. I must echo Anders Sandvig comments: keep trunk/tags/branches on the root level since you will only branch a limited set of modules. It also does not interfere with modules building individually.</p> <p>I won't copy the answer I made before but it is entirely relevant to this question.</p>
3,519
<p>Assume that I have programs <code>P0</code>, <code>P1</code>, ...<code>P(n-1)</code> for some <code>n &gt; 0</code>. How can I easily redirect the output of program <code>Pi</code> to program <code>P(i+1 mod n)</code> for all <code>i</code> (<code>0 &lt;= i &lt; n</code>)?</p> <p>For example, let's say I have a program <code>square</code>, which repeatedly reads a number and than prints the square of that number, and a program <code>calc</code>, which sometimes prints a number after which it expects to be able to read the square of it. How do I connect these programs such that whenever <code>calc</code> prints a number, <code>square</code> squares it returns it to <code>calc</code>?</p> <p>Edit: I should probably clarify what I mean with "easily". The named pipe/fifo solution is one that indeed works (and I have used in the past), but it actually requires quite a bit of work to do properly if you compare it with using a bash pipe. (You need to get a not yet existing filename, make a pipe with that name, run the "pipe loop", clean up the named pipe.) Imagine you could no longer write <code>prog1 | prog2</code> and would always have to use named pipes to connect programs.</p> <p>I'm looking for something that is almost as easy as writing a "normal" pipe. For instance something like <code>{ prog1 | prog2 } &gt;&amp;0</code> would be great.</p>
<p>After spending quite some time yesterday trying to redirect <code>stdout</code> to <code>stdin</code>, I ended up with the following method. It isn't really nice, but I think I prefer it over the named pipe/fifo solution.</p> <pre><code>read | { P0 | ... | P(n-1); } &gt;/dev/fd/0 </code></pre> <p>The <code>{ ... } &gt;/dev/fd/0</code> is to redirect stdout to stdin for the pipe sequence as a whole (i.e. it redirects the output of P(n-1) to the input of P0). Using <code>&gt;&amp;0</code> or something similar does not work; this is probably because bash assumes <code>0</code> is read-only while it doesn't mind writing to <code>/dev/fd/0</code>.</p> <p>The initial <code>read</code>-pipe is necessary because without it both the input and output file descriptor are the same pts device (at least on my system) and the redirect has no effect. (The pts device doesn't work as a pipe; writing to it puts things on your screen.) By making the input of the <code>{ ... }</code> a normal pipe, the redirect has the desired effect.</p> <p>To illustrate with my <code>calc</code>/<code>square</code> example:</p> <pre><code>function calc() { # calculate sum of squares of numbers 0,..,10 sum=0 for ((i=0; i&lt;10; i++)); do echo $i # "request" the square of i read ii # read the square of i echo "got $ii" &gt;&amp;2 # debug message let sum=$sum+$ii done echo "sum $sum" &gt;&amp;2 # output result to stderr } function square() { # square numbers read j # receive first "request" while [ "$j" != "" ]; do let jj=$j*$j echo "square($j) = $jj" &gt;&amp;2 # debug message echo $jj # send square read j # receive next "request" done } read | { calc | square; } &gt;/dev/fd/0 </code></pre> <p>Running the above code gives the following output:</p> <pre><code>square(0) = 0 got 0 square(1) = 1 got 1 square(2) = 4 got 4 square(3) = 9 got 9 square(4) = 16 got 16 square(5) = 25 got 25 square(6) = 36 got 36 square(7) = 49 got 49 square(8) = 64 got 64 square(9) = 81 got 81 sum 285 </code></pre> <p>Of course, this method is quite a bit of a hack. Especially the <code>read</code> part has an undesired side-effect: termination of the "real" pipe loop does not lead to termination of the whole. I couldn't think of anything better than <code>read</code> as it seems that you can only determine that the pipe loop has terminated by try to writing write something to it.</p>
<p>I doubt sh/bash can do it. ZSH would be a better bet, with its MULTIOS and coproc features.</p>
6,146
<p>Inside an asp.net page, should I use</p> <pre><code>&lt;html&gt;&lt;title&gt;My page's title from México&lt;/title&gt;&lt;/html&gt; </code></pre> <p>Or </p> <pre><code>&lt;html&gt;&lt;title&gt;My page&amp;rsquo;s title from M&amp;eacute;xico&lt;/title&gt;&lt;/html&gt; </code></pre> <p>Both examples have the same output. Since asp.net encodes all my pages to utf-8, there is no need to use html entities, is that right?</p>
<p>I'm having a similar issue. You might be able to do something like this:</p> <pre><code>SET arithabort arith_overflow off SET @the_date = CAST(@date_string AS DATETIME) IF @the_date is NULL set @the_date = getdate() SET arithabort arith_overflow on </code></pre> <p>However, this doesn't work well in a select. It will work well in a cursor (boo) or in logic before / after a SQL batch.</p>
<p>Found <a href="http://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/" rel="nofollow noreferrer">this in the second result</a> in Google when searching for "validate date string sql".</p> <pre><code>----Invalid date SELECT ISDATE('30/2/2007') RETURNS : 0 (Zero) ----Valid date SELECT ISDATE('12/12/20007') RETURNS : 1 (ONE) ----Invalid DataType SELECT ISDATE('SQL') RETURNS : 0 (Zero) </code></pre>
3,050
<p>Get the following error periodically in an IIS application:</p> <blockquote> <p>Failed to load resources from resource file.</p> </blockquote> <p>The full error message in the Application Event Log is:</p> <blockquote> <p>Event Type: Error<br> Event Source: .NET Runtime<br> Event Category: None<br> Event ID: 0<br> Date: 8/8/2008<br> Time: 8:8:8 AM<br> User: N/A<br> Computer: BLAH123<br> Description:<br> The description for Event ID ( 0 ) in Source ( .NET Runtime ) cannot be found. The >local computer may not have the necessary registry information or message DLL files to >display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: .NET Runtime version 1.1.4322.2407- Setup Error: Failed to load resources from resource file<br> Please check your Setup.<br></p> </blockquote> <p>Application is written in .NET 1.1 but the server runs ASP.NET 2.0. Thanx.</p> <p>Update: Meant to say ASP.NET 2.0 is installed but the default website folder, and the websites inside the folder, are set to ASP.NET 1.1. On the website folder the ISAPI Filter is set to ASP.NET 2.0. My first guess about the problem was having ASP.NET 1.1 and ASP.NET 2.0 running side by side.</p> <p>Update 2: ASP.NET 2.0 is installed but all the websites run only ASP.NET 1.1 (long story and happened before I started).</p>
<p>Do you have .NET 1.1 and .NET 2.0 apps running on the web server? We had some instances of a similar nature around here and the resolution we found was to create two app pools, one for 1.1 apps and one for 2.0 apps and to assign each application accordingly.</p>
<p>Do you get a different error without the ISAPI filter in place?</p>
4,569
<p>My anet A8 stepper drivers get very hot after some time printing, so I decided to install a 5V fan to cool them down. I had the idea to get a 12V to 5V regulator to connect a 5V fan, but then i found this image:</p> <p><a href="https://i.stack.imgur.com/Ryeyj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Ryeyj.jpg" alt="anet a8 mainboard"></a></p> <p>(source: <a href="http://lokspace.eu/anet-a8-wifi-mod/" rel="noreferrer">lokspace.eu</a>)</p> <p>It looks like the Anet A8 has an ICSP and Serial header that can deliver 5 or 3.3 V directly from the board. Is this correct? If it is, how many amps can i get from this pin? Can I connect a 5V fan directly here?</p> <p>Thanks and sorry for my bad English.</p>
<p>The 5V is derived from the 12V supply by a linear regulator (L7805CD, DPAK package with 100 C/W thermal resistance). The maximum you can draw from it (without overheating the regulator) is around 200mA. Considering the electronics on the board are already using some power, the maximum would be around a 150mA fan but this would have the regulator running near its maximum limits.</p>
<p>5 V and 3.3 V are both <a href="https://learn.sparkfun.com/tutorials/logic-levels/33-v-cmos-logic-levels" rel="nofollow noreferrer">logic "highs"</a> in computing and measured against GND. If the fan simply has to know the on stance and nothing more, then you could run a fan with the logic 5 V (and probably 3.3 V for about 50% spin speed).</p>
1,379
<p>As I started to learn about 3D printing, the gist I learned was &quot;it's better to store the filaments in a drybox.&quot; As I rechecked these notes, they were to a good degree from an era when PLA was rather new to the market and ABS was the goTo.</p> <p>Then I learned &quot;PLA is not really hygroscopic and can be stored freely.&quot;<sup>1</sup></p> <p>Now, I know some materials are pretty hygroscopic, but not all. So, let's try to pin it down:</p> <p><strong>Which materials are hygroscopic enough to demand a drybox?</strong></p> <p>I know that it is good practice to store all filament <a href="https://3dprinting.stackexchange.com/questions/84/does-filament-have-to-be-stored-in-an-airtight-environment">in a somewhat dehumidified or airtight box</a>, but there are some materials out there that become <strong>unprintable</strong> and need drying before printing if improperly stored. <em><strong>This question is to point out these &quot;special storage mandatory&quot; filaments only.</strong></em> If a material can't be printed without dry storage it belongs here. If it is a nice to have, it doesn't.</p> <p>This is a <strong>Back It Up</strong> question: answers need to provide one of two:</p> <ul> <li>explain personal experience, marked as such.</li> <li>provide an authoritative source (scientific paper/videos, manufacturer papers, quote from an experienced maker).</li> </ul> <hr /> <p><sup>1 - For some time (month?). I do store my PLA in a closed but unsealed IKEA container with all the desiccant bags I can find as it is clearly <em>benefitial</em>.</sup></p>
<h1><a href="https://ultimaker.com/en/products/materials/pva" rel="nofollow noreferrer">PVA</a></h1> <p>From experience I can tell that PVA filaments need to be stored with silica beads in a plastic bag or in a specific dry-box. PVA is soluble in water and is very hygroscopic. With moisture it gets soft and swells. My Ultimaker came with an open spool of PVA which popped when heated (steam bubbles popping) resulting in very poor quality supports and clogging of the nozzle. A newly bought spool which was properly packed did not have these issues.</p> <h1>Nylon</h1> <p>Some Nylon filament brands require to be stored dry or need to be dried before printing. I have a spool of Nylon that has taken up some moisture although carefully packed, the only time it was out is when it was being printed. This experience applies to Ultimaker Nylon; I've learned now that not all Nylon filaments are behaving the same, it is suggested to look-up the specifics from the manufacturer or from reviews prior to buying.</p>
<p>Some brands of PLA+ and colors of filament seem to have issues if left in the open air for too long a period. These then need to be dried back out in a dry box. The filament seems to be softer and the hobb seems to strip it out more easily causing print failures. The colors I have had the most troubles with are transparent Blue, Dark Green, and silky Copper.</p>
1,046
<p>What's the "best" (taking both speed and readability into account) way to determine if a list is empty? Even if the list is of type <code>IEnumerable&lt;T&gt;</code> and doesn't have a Count property.</p> <p>Right now I'm tossing up between this:</p> <pre><code>if (myList.Count() == 0) { ... } </code></pre> <p>and this:</p> <pre><code>if (!myList.Any()) { ... } </code></pre> <p>My guess is that the second option is faster, since it'll come back with a result as soon as it sees the first item, whereas the second option (for an IEnumerable) will need to visit every item to return the count.</p> <p>That being said, does the second option look as readable to you? Which would you prefer? Or can you think of a better way to test for an empty list?</p> <p><strong>Edit</strong> @lassevk's response seems to be the most logical, coupled with a bit of runtime checking to use a cached count if possible, like this:</p> <pre><code>public static bool IsEmpty&lt;T&gt;(this IEnumerable&lt;T&gt; list) { if (list is ICollection&lt;T&gt;) return ((ICollection&lt;T&gt;)list).Count == 0; return !list.Any(); } </code></pre>
<p>You could do this:</p> <pre><code>public static Boolean IsEmpty&lt;T&gt;(this IEnumerable&lt;T&gt; source) { if (source == null) return true; // or throw an exception return !source.Any(); } </code></pre> <p><strong>Edit</strong>: Note that simply using the .Count method will be fast if the underlying source actually has a fast Count property. A valid optimization above would be to detect a few base types and simply use the .Count property of those, instead of the .Any() approach, but then fall back to .Any() if no guarantee can be made.</p>
<p>This extension method works for me:</p> <pre><code>public static bool IsEmpty&lt;T&gt;(this IEnumerable&lt;T&gt; enumerable) { try { enumerable.First(); return false; } catch (InvalidOperationException) { return true; } } </code></pre>
6,261
<p>Our design has one jvm that is a jboss/webapp (read/write) that is used to maintain the data via hibernate (using jpa) to the db. The model has 10-15 persistent classes with 3-5 levels of depth in the relationships.</p> <p>We then have a separate jvm that is the server using this data. As it is running continuously we just have one long db session (read only). </p> <p>There is currently no intra-jvm cache involved - so we manually signal one jvm from the other.</p> <p>Now when the webapp changes some data, it signals the server to reload the changed data. What we have found is that we need to tell hibernate to purge the data and then reload it. Just doing a fetch/merge with the db does not do the job - mainly in respect of the objects several layers down the hierarchy. </p> <p>Any thoughts on whether there is anything fundamentally wrong with this design or if anyone is doing this and has had better luck with working with hibernate on the reloads.</p> <p>Thanks, Chris</p>
<p>A Hibernate session loads all data it reads from the DB into what they call the <i>first-level cache</i>. Once a row is loaded from the DB, any subsequent fetches for a row with the same PK will return the data from this cache. Furthermore, Hibernate gaurentees reference equality for objects with the same PK in a single Session. </p> <p>From what I understand, your read-only server application never closes its Hibernate session. So when the DB gets updated by the read-write application, the Session on read-only server is unaware of the change. Effectively, your read-only application is loading an in-memory copy of the database and using that copy, which gets stale in due course.</p> <p>The simplest and best course of action I can suggest is to close and open Sessions as needed. This sidesteps the whole problem. Hibernate Sessions are intended to be a window for a short-lived interaction with the DB. I agree that there is a performance gain by not reloading the object-graph again and again; but you need to measure it and convince yourself that it is worth the pains.</p> <p>Another option is to close and reopen the Session periodically. This ensures that the read-only application works with data not older than a given time interval. But there definitely is a window where the read-only application works with stale data (although the design guarantees that it gets the up-to-date data eventually). This might be permissible in many applications - you need to evaluate your situation. </p> <p>The third option is to use a <i>second level cache</i> implementation, and use short-lived Sessions. There are various caching packages that work with Hibernate with relative merits and demerits.</p>
<p>The most used practice is to have a <a href="http://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html_single/#d0e129" rel="nofollow">Container-Managed Entity Manager</a> so that two or more applications in the same container (ie Glassfish, Tomcat, Websphere) can share the same caches. But if you don't use an Application container, because you use Play! for instance, then I would build some webservices in the <em>primary Application</em> to read/write consistently in the cache.</p> <p>I think using stale data is an open door for disaster. Just like Singletons become Multitons, read-only applications are often a <em>write sometimes</em>.</p> <p><em>Belt and braces</em> :)</p>
7,117
<p>Let's say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the <em>back</em> button appears first in the markup when you press <kbd>Enter</kbd>, it will use that button to submit the form.</p> <p>Example:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt; &lt;!-- Put your cursor in this field and press Enter --&gt; &lt;input type="text" name="field1" /&gt; &lt;!-- This is the button that will submit --&gt; &lt;input type="submit" name="prev" value="Previous Page" /&gt; &lt;!-- But this is the button that I WANT to submit --&gt; &lt;input type="submit" name="next" value="Next Page" /&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>I would like to get to decide which button is used to submit the form when a user presses <kbd>Enter</kbd>. That way, when you press <kbd>Enter</kbd> the wizard will move to the next page, not the previous. Do you have to use <code>tabindex</code> to do this?</p>
<p>I'm just doing the trick of <code>float</code>ing the buttons to the right.</p> <p>This way the <code>Prev</code> button is left of the <code>Next</code> button, but the <code>Next</code> comes first in the HTML structure:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.f { float: right; } .clr { clear: both; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="action" method="get"&gt; &lt;input type="text" name="abc"&gt; &lt;div id="buttons"&gt; &lt;input type="submit" class="f" name="next" value="Next"&gt; &lt;input type="submit" class="f" name="prev" value="Prev"&gt; &lt;div class="clr"&gt;&lt;/div&gt;&lt;!-- This div prevents later elements from floating with the buttons. Keeps them 'inside' div#buttons --&gt; &lt;/div&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>Benefits over other suggestions: no JavaScript code, accessible, and both buttons remain <code>type=&quot;submit&quot;</code>.</p>
<p>Using the example you gave:</p> <pre><code>&lt;form&gt; &lt;input type="text" name="field1" /&gt;&lt;!-- Put your cursor in this field and press Enter --&gt; &lt;input type="submit" name="prev" value="Previous Page" /&gt; &lt;!-- This is the button that will submit --&gt; &lt;input type="submit" name="next" value="Next Page" /&gt; &lt;!-- But this is the button that I WANT to submit --&gt; &lt;/form&gt; </code></pre> <p>If you click on "Previous Page", only the value of "prev" will be submitted. If you click on "Next Page" only the value of "next" will be submitted.</p> <p>If however, you press <kbd>Enter</kbd> somewhere on the form, neither "prev" nor "next" will be submitted.</p> <p>So using pseudocode you could do the following:</p> <pre><code>If "prev" submitted then Previous Page was click Else If "next" submitted then Next Page was click Else No button was click </code></pre>
2,245
<p>A simple question, but could someone provide sample code as to how would someone call a web service from within the JBoss Seam framework, and process the results?</p> <p>I need to be able to integrate with a search platform being provided by a private vendor who is exposing his functionality as a web service. So, I'm just looking for some guidance as to what the code for calling a given web service would look like. </p> <p>(Any sample web service can be chosen as an example.)</p>
<p>There's roughly a gajillion HTTP client libraries (Restlet is quite a bit more than that, but I already had that code snippet for something else), but they should all provide support for sending GET requests. Here's a rather less featureful snippet that uses <a href="http://hc.apache.org/httpclient-3.x/tutorial.html" rel="nofollow noreferrer">HttpClient</a> from Apache Commons:</p> <pre><code>HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=restbook&amp;query=HttpClient"); client.executeMethod(method); </code></pre>
<pre><code>import org.restlet.Client; import org.restlet.data.Protocol; import org.restlet.data.Reference; import org.restlet.data.Response; import org.restlet.resource.DomRepresentation; import org.w3c.dom.Node; /** * Uses YAHOO!'s RESTful web service with XML. */ public class YahooSearch { private static final String BASE_URI = "http://api.search.yahoo.com/WebSearchService/V1/webSearch"; public static void main(final String[] args) { if (1 != args.length) { System.err.println("You need to pass a search term!"); } else { final String term = Reference.encode(args[0]); final String uri = BASE_URI + "?appid=restbook&amp;query=" + term; final Response response = new Client(Protocol.HTTP).get(uri); final DomRepresentation document = response.getEntityAsDom(); document.setNamespaceAware(true); document.putNamespace("y", "urn:yahoo:srch"); final String expr = "/y:ResultSet/y:Result/y:Title/text()"; for (final Node node : document.getNodes(expr)) { System.out.println(node.getTextContent()); } } } } </code></pre> <p>This code uses <a href="http://www.restlet.org/" rel="nofollow noreferrer">Restlet</a> to make a request to Yahoo's RESTful search service. Obviously, the details of the web service you are using will dictate what your client for it looks like.</p>
8,098
<p>I would like to use nail polish to paint and smooth a PLA model. Could nail polish damage a model made out of pure PLA?</p>
<p>NO if you want to smooth your print, gently heat the plastic and with a utensil smooth out the plastic. A hair dryer is a good way of doing this but be careful to only lightly melt the outside of the model.</p>
<p>Nail polish contains acetone. It melts PLA, so yes you <em>could</em> damage it. Google acetone vapor batch to read up on a safer way to do the job.</p>
699
<p>I wrote a component that displays a filename, a thumbnail and has a button to load/play the file. The component is databound to a repeater. How can I make it so that the button event fires to the main application and tells it which file to play?</p>
<p>Maybe you should try including a fourth column, stating the table it came from, and then order and group by it:</p> <pre><code>SELECT A,B,C, "query 1" as origin FROM table WHERE field LIKE 'query%' UNION SELECT A,B,C, "query 2" as origin FROM table WHERE field LIKE '%query' UNION SELECT A,B,C, "query 3" as origin FROM table WHERE field LIKE '%query%' GROUP BY origin, B ORDER BY origin, B ASC LIMIT 5 </code></pre>
<p>If there isn't a sort that makes sense to order them you desire, don't union the results together - just return 3 separate recordsets, and deal with them accordingly in your data tier.</p>
2,589
<p>I would like to generate a random floating point number between 2 values. What is the best way to do this in C#?</p>
<p>The only thing I'd add to <a href="https://stackoverflow.com/questions/44408/how-do-you-generate-a-random-number-in-c#44428">Eric</a>'s response is an explanation; I feel that knowledge of why code works is better than knowing what code works.</p> <p>The explanation is this: let's say you want a number between 2.5 and 4.5. The range is 2.0 (4.5 - 2.5). <code>NextDouble</code> only returns a number between 0 and 1.0, but if you multiply this by the range you will get a number between 0 and <em>range</em>.</p> <p>So, this would give us random doubles between 0.0 and 2.0:</p> <pre>rng.NextDouble() * 2.0</pre> <p>But, we want them between 2.5 and 4.5! How do we do this? Add the smallest number, 2.5:</p> <pre>2.5 + rng.NextDouble() * 2.0</pre> <p>Now, we get a number between 0.0 and 2.0; if you add 2.5 to each of these values we see that the range is now between 2.5 and 4.5.</p> <p>At first I thought that it mattered if b > a or a > b, but if you work it out both ways you'll find it works out identically so long as you don't mess up the order of the variables used. I like to express it with longer variable names so I don't get mixed up:</p> <pre>double NextDouble(Random rng, double min, double max) { return min + (rng.NextDouble() * (max - min)); }</pre>
<p>How random? If you can deal with pseudo-random then simply:</p> <pre><code>Random randNum = new Random(); randNum. NextDouble(Min, Max); </code></pre> <p>If you want a "better" random number, then you probably should look at the Mersenne Twister algorithm. Plenty of people hav <a href="http://code.msdn.microsoft.com/MersenneTwister" rel="nofollow noreferrer">already implemented it</a> for you though</p>
6,619
<p>I'm relatively new in the field of 3D printing and design. By now I've created and printed some technical objects with TinkerCAD, but now I've a task, which I don't know how to solve.</p> <p>I have the following model as STL-file: <a href="https://i.stack.imgur.com/o8Bn1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/o8Bn1.jpg" alt="enter image description here"></a></p> <p>Now I want to "adjust" the arms of the model, as shown in the picture. I want the arms to hang besides the body. </p> <p>I know that I could cut and rotate the arms and then merge them again with TinkerCAD but the outcome dosn't look good and the workflow feels wrong.</p> <p>So what is the right tool/way to get this task done?</p> <p>*Disclaimer: I'm not Denis Almaral, but he released this model unter CC license. So I kept his name on the image to credit him, as requested via CC.</p>
<p>Basically there's no good easy way to do this.</p> <p>At this point you only have the mesh - a list of triangles - the 3D model you have does not contain the concept of joints or moving parts so it can't regenerate the shoulder after the rotation.</p> <p>The original author may or may not have the ability to do this, depending on his workflow and software.</p> <p>If all you have is the STL your only choice is to rotate the arm and then rebuild the shoulder from scratch and manually fix anything that doesn't look good</p>
<p>Basically there's no good easy way to do this.</p> <p>At this point you only have the mesh - a list of triangles - the 3D model you have does not contain the concept of joints or moving parts so it can't regenerate the shoulder after the rotation.</p> <p>The original author may or may not have the ability to do this, depending on his workflow and software.</p> <p>If all you have is the STL your only choice is to rotate the arm and then rebuild the shoulder from scratch and manually fix anything that doesn't look good</p>
788
<p>Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.</p> <p>I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set permissions as such:</p> <pre><code>chown apache:apache -R uploads/ chmod 755 -R uploads/ </code></pre> <p>The only problem now is that the FTP user can not modify the uploaded files at all.</p> <p>Is there a permission setting that will allow me to still upload files and then modify them later as a user other than the webserver user?</p>
<p>You can create a new group with both the apache user and FTP user as members and then make the permission on the upload folder 775. This should give both the apache and FTP users the ability to write to the files in the folder but keep everyone else from modifying them.</p>
<p>Based on the answer from <code>@Ryan Ahearn</code>, following is what I did on <code>Ubuntu</code> 16.04 to create a user <code>front</code> that only has permission for nginx's web dir <code>/var/www/html</code>.</p> <p><strong>Steps:</strong></p> <pre> * pre-steps: * basic prepare of server, * create user 'dev' which will be the owner of "/var/www/html", * * install nginx, * * * create user 'front' sudo useradd -d /home/front -s /bin/bash front sudo passwd front # create home folder, if not exists yet, sudo mkdir /home/front # set owner of new home folder, sudo chown -R front:front /home/front # switch to user, su - front # copy .bashrc, if not exists yet, cp /etc/skel/.bashrc ~front/ cp /etc/skel/.profile ~front/ # enable color, vi ~front/.bashrc # uncomment the line start with "force_color_prompt", # exit user exit * * add to group 'dev', sudo usermod -a -G dev front * change owner of web dir, sudo chown -R dev:dev /var/www * change permission of web dir, chmod 775 $(find /var/www/html -type d) chmod 664 $(find /var/www/html -type f) * * re-login as 'front' to make group take effect, * * test * * ok * </pre>
3,219
<p>What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!</p>
<p>I am using the <code>pre-revprop-change</code> hook that allows me to actually go back and edit comments and such information after the commit has been performed. This is very useful if there is missing/erroneous information in the commit comments.</p> <p>Here I post a <code>pre-revprop-change.bat</code> batch file for Windows NT or later. You can certainly enhance it with more modifications. You can also derive a <code>post-revprop-change.cmd</code> from it to back up the old <code>snv:log</code> somewhere or just to append it to the new log.</p> <p>The only tricky part was to be able to actually parse the stdin from the batch file. This is done here with the <code>FIND.EXE</code> command.</p> <p>The other thing is that I have had reports from other users of issues with the use of the <code>/b</code> with the <code>exit</code> command. You may just need to remove that <code>/b</code> in your specific application if error cases do not behave well.</p> <pre><code>@ECHO OFF set repos=%1 set rev=%2 set user=%3 set propname=%4 set action=%5 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Only allow changes to svn:log. The author, date and other revision :: properties cannot be changed :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: if /I not '%propname%'=='svn:log' goto ERROR_PROPNAME :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Only allow modifications to svn:log (no addition/overwrite or deletion) :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: if /I not '%action%'=='M' goto ERROR_ACTION :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Make sure that the new svn:log message contains some text. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: set bIsEmpty=true for /f "tokens=*" %%g in ('find /V ""') do ( set bIsEmpty=false ) if '%bIsEmpty%'=='true' goto ERROR_EMPTY goto :eof :ERROR_EMPTY echo Empty svn:log properties are not allowed. &gt;&amp;2 goto ERROR_EXIT :ERROR_PROPNAME echo Only changes to svn:log revision properties are allowed. &gt;&amp;2 goto ERROR_EXIT :ERROR_ACTION echo Only modifications to svn:log revision properties are allowed. &gt;&amp;2 goto ERROR_EXIT :ERROR_EXIT exit /b 1 </code></pre>
<p>The most common one I think is to allow people to change revision comments after comitting. </p> <p>You need to enable the 'pre-revprop-change' hook script to allow that. The example provided, if enabled allows editing only the comment property and only be the original comitter. Great for correcting typos.</p>
2,797
<p>My job would be easier, or at least less tedious if I could come up with an automated way (preferably in a Python script) to extract useful information from a FileMaker Pro database. I am working on Linux machine and the FileMaker database is on the same LAN running on an OS X machine. I can log into the webby interface from my machine.</p> <p>I'm quite handy with SQL, and if somebody could point me to some FileMaker plug-in that could give me SQL access to the data within FileMaker, I would be pleased as punch. Everything I've found only goes the other way: Having FileMaker get data from SQL sources. Not useful.</p> <p>It's not my first choice, but I'd use Perl instead of Python if there was a Perl-y solution at hand.</p> <p><em>Note</em>: XML/XSLT services (as suggested by some folks) are only available on FM Server, not FM Pro. Otherwise, that would probably be the best solution. ODBC is turning out to be extremely difficult to even get working. There is absolutely zero feedback from FM when you set it up so you have to dig through /var/log/system.log and parse obscure error messages.</p> <p><em>Conclusion</em>: I got it working by running a python script locally on the machine that queries the FM database through the ODBC connections. The script is actually a TCPServer that accepts socket connections from other systems on the LAN, runs the queries, and returns the data through the socket connection. I had to do this to bypass the fact that FM Pro only accepts ODBC connections locally (FM server is required for external connections).</p>
<p>It has been a <strong>really</strong> long time since I did anything with FileMaker Pro, but I know that it does have capabilities for an ODBC (and JDBC) connection to be made to it (however, I don't know how, or if, that translates to the linux/perl/python world though). </p> <p>This article shows how to share/expose your FileMaker data via ODBC &amp; JDBC:<br> <a href="http://www.filemaker.com/help/15-Using%20ODBC2.html" rel="noreferrer">Sharing FileMaker Pro data via ODBC or JDBC</a> </p> <p>From there, if you're able to create an ODBC/JDBC connection you could query out data as needed.</p>
<p>You'll need the FileMaker Pro installation CD to get the drivers. <a href="http://www.filemaker.com/downloads/pdf/fm9_odbc_jdbc_guide_en.pdf" rel="nofollow noreferrer">This document</a> details the process for FMP 9 - it is similar for versions 7.x and 8.x as well. Versions 6.x and earlier are completely different and I wouldn't bother trying (xDBC support in those previous versions is "minimal" at best).</p> <p>FMP 9 supports SQL-92 standard syntax (mostly). Note that rather than querying tables directly you query using the "table occurrence" name which serves as a table alias of sorts. If the data tables are stored in multiple files it is possible to create a single FMP file with table occurrences/aliases pointing to those data tables. There's an "undocumented feature" where such a file must have a table defined in it as well and that table "related" to any other table on the relationships graph (doesn't matter which one) for ODBC access to work. Otherwise your queries will always return no results.</p> <p>The PDF document details all of the limitations of using the xDBC interface FMP provides. Performance of simple queries is reasonably fast, ymmv. I have found the performance of queries specifying the "LIKE" operator to be less than stellar.</p> <p>FMP also has an XML/XSLT interface that you can use to query FMP data over an HTTP connection. It also provides a PHP class for accessing and using FMP data in web applications.</p>
4,829
<p>In my engine I have a need to be able to detect DXT1 textures that have texels with 0 alpha (e.g. a cutout for a window frame). This is easy for textures I compress myself, but I'm not sure about textures that are already compressed.</p> <p>Is there an easy way to tell from the header whether a DDS image contains alpha?</p>
<p>As far as I know, there's no way to tell from the header. There's a DDPF_ALPHAPIXELS flag, but I don't think that will get set based on what's in the pixel data. You'd need to parse the DXT1 blocks, and look for colours that have 0 alpha in them (making sure to check that the colour is actually used in the block, too, I suppose).</p>
<p>I agree with the accepted answer. Your job may be made a bit easier by using the "squish" library to decompress the blocks for you.</p> <p><a href="http://www.sjbrown.co.uk/?code=squish" rel="nofollow noreferrer">http://www.sjbrown.co.uk/?code=squish</a></p>
3,991
<p>Just a simple question about my FEP sheet getting dented after print. I just bought an Elegoo Mars 2 Pro and had trouble getting it to stick to the bed, after some painful bed leveling and realizing my exposure times were too low for maroon resin, I finally got it to stick to the bed by the 4th print.</p> <p>Now before I start my next print, I want to know what causes the indents in the FEP sheet below so I can prevent it from happening again.</p> <p><a href="https://i.stack.imgur.com/Jqxah.jpg" rel="nofollow noreferrer" title="FEP sheet with noticeable dents"><img src="https://i.stack.imgur.com/Jqxah.jpg" alt="FEP sheet with noticeable dents" title="FEP sheet with noticeable dents" /></a></p> <p>Is it too High exposure time, bed leveled too low/tight, or both? Now I will also note, that this print was with the standard rook test print the mars recommends you do first, also that my print was very hard to remove from the bed when finished, I had to use a lot of force to rip it off.</p>
<p>The rook is normally difficult to remove, it's designed this way.</p> <p>Have you tried resetting the height of you build Plate? If it makes a grinding sound when doing the first 2 or three layers your build plate might be traveling too low.</p> <p>Also try re-leveling your build plate, e.g. I pushed so hard when I tried to take my rook off that I un-leveled it.</p>
<p>You have not done anything wrong!</p> <p>Usually, each resin type is suitable for a specific VAT floor. For example, for PDMS floor you should use very specific types of resins.</p> <p>FEP is known to be very strong and difficult to ruin. But still a couple of things you need to consider:</p> <ul> <li>When the resin cures it does generate a substantial amount of heat, you definitely can decrease it by a better level (less resin) or dimming (slower chemical reaction). Some FEPs could stand 450 °C.</li> <li>Separation force, it will depend on the area being solidified and how strong the resin stick to your FEP.</li> <li>How tightened the FEP is also important. You do not want it to be very tight.</li> </ul>
2,011
<p>I own a Creality CR-10 (using Ultimaker Cura for slicing) and I am experiencing terrible printing problems.</p> <p>My problem: I am not able to print anything that takes several hours to print. For parts printed in 30 minutes or so, my printer usually works.</p> <p>The prints end up like this (unfinished and with a lot of stringing)</p> <p><a href="https://i.stack.imgur.com/OyQrG.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/OyQrG.jpg" alt="fail"></a></p> <p>This below is actually the best result I got so far.. (important note: there is no under extrusion during the print, it suddenly stops out of nowhere..) <a href="https://i.stack.imgur.com/CGeTY.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/CGeTY.jpg" alt="fail2"></a> (Although I have to use terrible retraction settings and need a lot of post processing because of all the stringing - you might have an answer for that too.. I just couldnt get the 3d printer to print parts properly with good retraction settings.)</p> <p><strong>The problem is that at some point of the print, no more (PLA) material is extruded and the printer moves without actually printing anything. The first couple of layers usually work (you can see that in the images) but after wasting almost 600 grams of PLA, I am not able to find a solution myself.</strong></p> <p>.</p> <p><strong>I have some suspicions:</strong></p> <p>Could the problem be the angle, the PLA is inserted into the feeder? (so that it is almost a 90 degree bend)? The filament comes from a spool in the right hand side. But I dont think that this would cause such a problem..</p> <p><a href="https://i.stack.imgur.com/7CHIe.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/7CHIe.jpg" alt="Angle of inserted filament"></a></p> <p>Is it a software problem? Here are all my cura settings (I even reduced the printing speed to 30mm/s at 205°C - still didnt work..) :-(</p> <p><a href="https://i.stack.imgur.com/qKcvg.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qKcvg.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/kXKwS.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/kXKwS.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/lpbKs.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/lpbKs.jpg" alt="enter image description here"></a></p> <p>Could the length of the bowden tube and it tangling up be a problem? (as you can see in the image below) <a href="https://i.stack.imgur.com/2SoCm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/2SoCm.jpg" alt="enter image description here"></a></p> <p><strong>And annother important thing: The feeder always grinds into the filament (even at those low retraction settings) and it is always very hard to pull the filament out of the bowden after a failed print. Sometimes its almost impossible and i have to use heavy tools for it.. that should be the probelem</strong> <a href="https://i.stack.imgur.com/oZnhq.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/oZnhq.jpg" alt="enter image description here"></a></p> <p>I already did some atomic pulls, replaced the nozzle and switched the bowden tube.</p> <p><strong>I have a dream: My printer printing a part without any stringing and actually finishing the print. Please help me to achieve this dream..</strong></p> <p>Thank you for your help in advance. :)</p> <p>(and the filament I used, sorry for the bad quality of the pic) <a href="https://i.stack.imgur.com/vzH9u.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/vzH9u.jpg" alt="enter image description here"></a></p>
<p><strong>Stringing?</strong></p> <p>The stringing is explained by your relatively low retraction settings, 1.5&nbsp;mm is not much for a Bowden setup. As do too high printing temperatures.</p> <p><strong>Stopping mid printing?</strong></p> <p>What you are experiencing is called clogging, the extruder cannot push the filament through the hotend and cause the grinding you report. Clogging mid printing is usually caused by insufficient cooling (for the temperature you print at) of the cold end (causing heat creep; slowly increasing temperature of the heat break), especially all-metal hotend assemblies are notoriously known for this problem. </p> <p>Your Bowden tube does make a lot of kinks, maybe you can improve the path of the Bowden tube. Also if you are concerned about the sharp filament intake angle, you could print a filament guide:</p> <p><a href="https://i.stack.imgur.com/4E5Gk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4E5Gk.jpg" alt="Creality CR-10 extruder assembly with filament guide"></a></p>
<p>I had the same thing! On my anycubic I3 mega.</p> <p>Tried a lot of stuff and got so sick of it so I installed a 10:1 gearbox on my extruder motor. So now it provides 10x more torque and since I havent got the issue anymore where the extruder is just grinding on the filament and the motor is just skipping steps. </p> <p>No because of this and because my anycubic won't connect to a pc I can't change settings on my printer so I resolve the ratio with 1000% flow in my cura settings. And other stuff is also affected.</p> <p>But at least it won't stop and just be sitting there and skipping steps.</p>
1,186
<p>I know that the following is true</p> <pre><code>int i = 17; //binary 10001 int j = i &lt;&lt; 1; //decimal 34, binary 100010 </code></pre> <p>But, if you shift too far, the bits fall off the end. Where this happens is a matter of the size of integer you are working with.</p> <p>Is there a way to perform a shift so that the bits rotate around to the other side? I'm looking for a single operation, not a for loop.</p>
<p>If you know the size of type, you could do something like:</p> <pre><code>uint i = 17; uint j = i &lt;&lt; 1 | i &gt;&gt; 31; </code></pre> <p>... which would perform a circular shift of a 32 bit value.</p> <p>As a generalization to circular shift left n bits, on a b bit variable:</p> <pre><code>/*some unsigned numeric type*/ input = 17; var result = input &lt;&lt; n | input &gt;&gt; (b - n); </code></pre> <p><hr/> @The comment, it appears that C# does treat the high bit of signed values differently. I found some info on this <a href="http://www.blackwasp.co.uk/CSharpShiftOperators.aspx" rel="noreferrer">here</a>. I also changed the example to use a uint.</p>
<p>The extension methods for rotating bits of a <code>uint</code> (32 bits):</p> <pre><code>public static uint ROR(this uint x, int nbitsShift) =&gt; (x &gt;&gt; nbitsShift) | (x &lt;&lt; (32 - nbitsShift)); public static uint ROL(this uint x, int nbitsShift) =&gt; (x &lt;&lt; nbitsShift) | (x &gt;&gt; (32 - nbitsShift)); </code></pre>
5,558
<p>What I currently do is I link the project to another location and give it the same name, then check the box where it says "Branch after share." And then I would Check out the shared project and work off it. And finally merge with the original project.</p> <p>This works okay, but it feels very clunky: I have multiple instances of the project on my drive; I have to change physical address of the website (i use asp.net 1.1) every time I work on a different branch; </p> <p>That doesn't feel like the right way to do it. How do you branch your projects with VSS?</p>
<p>I think the way you describe in the question is the only way you can do it in sourceSafe.</p> <p>I usually name the copied directory "V1.0" (or whatever is appropriate) and keep them all in a folder that is the main project name.</p>
<p>The way you described is the only supported way to do "branching". And as you pointed out it is rather clunky. In VSS it's best to avoid branching alltogether as it will destroy your source history.</p>
9,369
<p>I haven't done a lot of .NET programming, but I've examined a few of the application blocks published by Microsoft's Patterns and Practices group. I was wondering how these are typically used:</p> <ul> <li>Linked directly into applications</li> <li>Source added into applications and built with them, perhaps with some customization's</li> <li>Sample code used as reference while writing application-specific code</li> </ul> <p>I'm sure all three of these usages are common, but what are the most typical usage patterns?</p> <p>Are there a few particular application blocks that are used by "everyone?"</p> <p>Note: This question is related to, but not the same as <a href="https://stackoverflow.com/questions/53065/enterprise-library-application-blocks-or-home-grown-framework">Enterprise Library Application Blocks OR Home Grown Framework?</a>.</p>
<p>I usually put the source into my project, and then I can get better intellisense (and a better understanding of them). I don't tend to customize them at all though. I like to have them stock so I can just distribute the stock binaries anytime I need them.</p>
<p>We use the blocks by adding references to the DLLs, making sure that "copy local" is set so that they are deployed with the app into the app's bin folder. This means that we don't have to muck around with the GAC - much simpler!</p> <p>When debugging, Visual Studio can still step into the source code even if it's not directly included in your project, as long as you have the EntLib source code on your hard disk somewhere. It will prompt you for the location on first use, and remember it thereafter.</p> <p>We currently use the Caching, Exception and Logging blocks. We haven't thought of a use case for the rest yet.</p>
7,920
<p>Could somebody please do a rundown of how to programmatically encrypt a config-file in .NET, preferably in C#.</p> <p>What I would like to do is do some kind of check on an application's startup to see if a section is unprotected, and if it is, then encrypt it. This for both settings and connection-strings.</p> <p>Also if anyone could list the types of encryption-providers and what is the difference between them.</p> <p>I don't know if the code for doing this in a normal WinForms-application is transparent to doing this in ASP.NET.</p>
<p>To summarize the answers and what I've found so far, here are some good links to answer this question:</p> <ul> <li><a href="https://web.archive.org/web/20211029043331/https://aspnet.4guysfromrolla.com/articles/021506-1.aspx" rel="nofollow noreferrer">Encrypting Configuration Information in ASP.NET 2.0 Applications - 4GuysFromRolla.com</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms998280.aspx" rel="nofollow noreferrer">How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI - MSDN</a></li> </ul> <p>Please feel free to complement with other links, maybe some to WinForms- or WPF-applications.</p>
<p>I haven't used it myself, but the Microsoft Enterprise library has good encryption support that will possibly suit your needs:</p> <p><a href="http://msdn.microsoft.com/en-us/library/cc309503.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc309503.aspx</a></p>
4,198
<p>I don't want to ask off-topic and opinion questions here, but I would like to find a cadre of others dialing in their devices. Any ideas?</p>
<p>I stumbled across this forum/group, <a href="https://forum.prusaprinters.org/forum/english-forum-original-prusa-i3-mmu2s-mmu2/" rel="nofollow noreferrer">Original Prusa i3 MMU2S &amp; MMU2</a>, amongst all of the other <a href="https://forum.prusaprinters.org" rel="nofollow noreferrer">Prusa printers forums</a> on the <a href="https://blog.prusaprinters.org/prusa-i3/" rel="nofollow noreferrer">Prusaprinters blog</a>, which seems fairly active. </p> <p>In particular, the <a href="https://forum.prusaprinters.org/forum/original-prusa-i3-mmu2s-mmu2-user-mods-octoprint-enclosures-nozzles-.../" rel="nofollow noreferrer">User mods - OctoPrint, enclosures, nozzles, ...</a> page seems like it might be what you are looking for.</p>
<p>There is a lot of activity on Reddit related to 3D printing and the Prusa printers.</p>
65
<p>I know there are some ways to get notified when the page body has loaded (before all the images and 3rd party resources load which fires the <strong>window.onload</strong> event), but it's different for every browser.</p> <p>Is there a definitive way to do this on all the browsers?</p> <p>So far I know of:</p> <ul> <li><p><strong>DOMContentLoaded</strong> : On Mozilla, Opera 9 and newest WebKits. This involves adding a listener to the event:</p> <p>document.addEventListener( "DOMContentLoaded", [init function], false );</p></li> <li><p><strong>Deferred script</strong>: On IE, you can emit a SCRIPT tag with a @defer attribute, which will reliably only load after the closing of the BODY tag.</p></li> <li><p><strong>Polling</strong>: On other browsers, you can keep polling, but is there even a standard thing to poll for, or do you need to do different things on each browser?</p></li> </ul> <p>I'd like to be able to go without using document.write or external files.</p> <p>This can be done simply via jQuery:</p> <pre><code>$(document).ready(function() { ... }) </code></pre> <p>but, I'm writing a JS library and can't count on jQuery always being there.</p>
<p>There's no cross-browser method for checking when the DOM is ready -- this is why libraries like jQuery exist, to abstract away nasty little bits of incompatibility.</p> <p>Mozilla, Opera, and modern WebKit support the <code>DOMContentLoaded</code> event. IE and Safari need weird hacks like scrolling the window or checking stylesheets. The gory details are contained in jQuery's <code>bindReady()</code> function.</p>
<p>This works pretty well:</p> <pre><code>setTimeout(MyInitFunction, 0); </code></pre>
9,115
<p>In .NET perspective:</p> <ul> <li>What is a <a href="https://en.wikipedia.org/wiki/Memory_leak" rel="noreferrer">memory leak</a>?</li> <li>How can you determine whether your application leaks? What are the effects?</li> <li>How can you prevent a memory leak?</li> <li>If your application has memory leak, does it go away when the process exits or is killed? Or do memory leaks in your application affect other processes on the system even after process completion?</li> <li>And what about unmanaged code accessed via COM Interop and/or P/Invoke?</li> </ul>
<p>The best explanation I've seen is in Chapter 7 of the free <a href="http://codebetter.com/karlseguin/2008/06/25/foundations-of-programming-ebook/" rel="noreferrer">Foundations of Programming e-book</a>.</p> <p>Basically, in <strong>.NET</strong> a memory leak occurs when referenced objects are rooted and thus cannot be garbage collected. This occurs accidentally when you hold on to references beyond the intended scope.</p> <p>You'll know that you have leaks when you start getting OutOfMemoryExceptions or your memory usage goes up beyond what you'd expect (<strong>PerfMon</strong> has nice memory counters). </p> <p>Understanding <strong>.NET</strong>'s memory model is your best way of avoiding it. Specifically, understanding how the garbage collector works and how references work — again, I refer you to chapter 7 of the e-book. Also, be mindful of common pitfalls, probably the most common being events. If object <strong>A</strong> is registered to an event on object <strong>B</strong>, then object <strong>A</strong> will stick around until object <strong>B</strong> disappears because <strong>B</strong> holds a reference to <strong>A</strong>. The solution is to unregister your events when you're done. </p> <p>Of course, a good memory profile will let you see your object graphs and explore the nesting/referencing of your objects to see where references are coming from and what root object is responsible (<a href="http://www.red-gate.com/products/ants_memory_profiler/index.htm" rel="noreferrer">red-gate ants profile</a>, JetBrains dotMemory, <a href="http://memprofiler.com/" rel="noreferrer">memprofiler</a> are really good choices, or you can use the text-only <strong>WinDbg</strong> and <strong>SOS</strong>, but I'd strongly recommend a commercial/visual product unless you're a real guru).</p> <p>I believe unmanaged code is subject to its typical memory leaks, except that shared references are managed by the garbage collector. I could be wrong about this last point.</p>
<p>One definition is: <strong>Unable to release unreachable memory, which can no longer be allocated to new process during execution of allocating process. It can mostly be cured by using GC techniques or detected by automated tools.</strong></p> <p>For more information, please visit <a href="http://all-about-java-and-weblogic-server.blogspot.in/2014/01/what-is-memory-leak-in-java.html" rel="nofollow">http://all-about-java-and-weblogic-server.blogspot.in/2014/01/what-is-memory-leak-in-java.html</a>.</p>
2,254
<p>What are the different ways (programmatically and otherwise) to determine what versions of .NET are running on a system?</p>
<p>Directly from the source:</p> <p><em><a href="http://support.microsoft.com/kb/318785" rel="nofollow noreferrer">How to determine which versions and service pack levels of the Microsoft .NET Framework are installed</a></em></p>
<p><a href="http://www.hanselman.com/smallestdotnet/" rel="nofollow noreferrer">Get the smallest .NET Framework download possible</a> that will tell you based on the headers you are sending. It only works on Internet Explorer or if you have the Firefox extension installed. More info in <a href="http://www.hanselman.com/blog/SmallestDotNetOnTheSizeOfTheNETFramework.aspx" rel="nofollow noreferrer">Hanselman's blog post</a>.</p>
7,564
<p>I have a SqlServer database that I've manually filled with some test data. Now I'd like to extract this test data as insert statements and check it in to source control. The idea is that other team members should be able to create the same database, run the created insert scripts and have the same data to test and develop on.</p> <p>Is there a good tool out there to do this? I'm <strong>not</strong> looking for a tool to generate data as discussed <a href="https://stackoverflow.com/questions/16317/creating-test-data-in-a-database">here</a>.</p>
<p>EMS DB Extract for SQL Server (<a href="http://www.sqlmanager.net/en/products/mssql/extract" rel="nofollow noreferrer">http://www.sqlmanager.net/en/products/mssql/extract</a>) seems to do what you want, and it seems to be free.</p> <p>Hope this helps,</p> <p>Robin</p>
<p>This works <a href="http://www.sqlscripter.com/" rel="nofollow noreferrer">http://www.sqlscripter.com/</a></p> <p>New version of SQL Scripter (V2.1) was released last month.</p>
4,398
<p>I don't want to take the time to learn Obj-C. I've spent 7+ years doing web application programming. Shouldn't there be a way to use the WebView and just write the whole app in javascript, pulling the files right from the resources of the project?</p>
<p>I found the answer after searching around. Here's what I have done:</p> <ol> <li><p>Create a new project in XCode. I think I used the view-based app.</p></li> <li><p>Drag a WebView object onto your interface and resize.</p></li> <li><p>Inside of your WebViewController.m (or similarly named file, depending on the name of your view), in the viewDidLoad method:</p> <pre>NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; NSData *htmlData = [NSData dataWithContentsOfFile:filePath]; if (htmlData) { NSBundle *bundle = [NSBundle mainBundle]; NSString *path = [bundle bundlePath]; NSString *fullPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectory:path]; [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]]; }</pre></li> <li><p>Now any files you have added as resources to the project are available for use in your web app. I've got an index.html file including javascript and css and image files with no problems. The only limitation I've found so far is that I can't create new folders so all the files clutter up the resources folder.</p></li> <li><p>Trick: make sure you've added the file as a resource in XCode or the file won't be available. I've been adding an empty file in XCode, then dragging my file on top in the finder. That's been working for me.</p></li> </ol> <p>Note: I realize that Obj-C must not be that hard to learn. But since I already have this app existing in JS and I know it works in Safari this is a much faster dev cycle for me. Some day I'm sure I'll have to break down and learn Obj-C.</p> <p>A few other resources I found helpful:</p> <p>Calling Obj-C from javascript: <a href="http://tetontech.wordpress.com/2008/08/14/calling-objective-c-from-javascript-in-an-iphone-uiwebview/" rel="noreferrer">calling objective-c from javascript</a></p> <p>Calling javascript from Obj-C: <a href="http://dominiek.com/articles/2008/7/19/iphone-app-development-for-web-hackers" rel="noreferrer">iphone app development for web hackers</a></p> <p>Reading files from application bundle: <a href="http://iphoneincubator.com/blog/tag/uiwebview" rel="noreferrer">uiwebview</a></p>
<p>At least 2 others mentioned phonegap, but I thought I'd post this too and mention that Apple has approved the phonegap framework. So, now you won't get your app rejected by Apple just because you're using phonegap. </p> <p><a href="http://blogs.nitobi.com/jesse/2009/11/20/phonegapp-store-approval/" rel="nofollow noreferrer">Blog post about phonegap and Apple - http://blogs.nitobi.com/jesse/2009/11/20/phonegapp-store-approval/</a></p> <p><a href="http://phonegap.com/" rel="nofollow noreferrer">Phone Gap Home</a></p>
8,995
<p>I want a splash screen to show while the application is loading. I have a form with a system tray control tied to it. I want the splash screen to display while this form loads, which takes a bit of time since it's accessing a web service API to populate some drop-downs. I also want to do some basic testing for dependencies before loading (that is, the web service is available, the configuration file is readable). As each phase of the startup goes, I want to update the splash screen with progress.</p> <p>I have been reading a lot on threading, but I am getting lost on where this should be controlled from (the <code>main()</code> method?). I am also missing how <code>Application.Run()</code> works, is this where the threads for this should be created from? Now, if the form with the system tray control is the "living" form, should the splash come from there? Wouldn't it not load until the form is completed anyway?</p> <p>I'm not looking for a code handout, more of an algorithm/approach so I can figure this out once and for all :) </p>
<p>Well, for a ClickOnce app that I deployed in the past, we used the <code>Microsoft.VisualBasic</code> namespace to handle the splash screen threading. You can reference and use the <code>Microsoft.VisualBasic</code> assembly from C# in .NET 2.0 and it provides a lot of nice services.</p> <ol> <li>Have the main form inherit from <code>Microsoft.VisualBasic.WindowsFormsApplicationBase</code></li> <li><p>Override the "OnCreateSplashScreen" method like so:</p> <pre><code>protected override void OnCreateSplashScreen() { this.SplashScreen = new SplashForm(); this.SplashScreen.TopMost = true; } </code></pre></li> </ol> <p>Very straightforward, it shows your SplashForm (which you need to create) while loading is going on, then closes it automatically once the main form has completed loading.</p> <p>This really makes things simple, and the <code>VisualBasic.WindowsFormsApplicationBase</code> is of course well tested by Microsoft and has a lot of functionality that can make your life a lot easier in Winforms, even in an application that is 100% C#.</p> <p>At the end of the day, it's all IL and <code>bytecode</code> anyway, so why not use it?</p>
<p>Actually mutlithreading here is not necessary.</p> <p>Let your business logic generate an event whenever you want to update splash screen. </p> <p>Then let your form update the splash screen accordingly in the method hooked to eventhandler.</p> <p>To differentiate updates you can either fire different events or provide data in a class inherited from EventArgs.</p> <p>This way you can have nice changing splash screen without any multithreading headache.</p> <p>Actually with this you can even support, for example, gif image on a splash form. In order for it to work, call Application.DoEvents() in your handler:</p> <pre><code>private void SomethingChanged(object sender, MyEventArgs e) { formSplash.Update(e); Application.DoEvents(); //this will update any animation } </code></pre>
7,133
<p>I am a novice programmer who is trying to teach myself to code, specifically in C#. I've taken on a project from a friend of mine and I am not sure what I need to know to get the project done. I suppose the issue is I don't know what I need to know to even get the project started.</p> <p>I do have many of the basics of object oriented programming, classes, methods and what-not, but when I sit down to code-I don't know where to begin looking to accomplish even basic tasks. I don't know syntax or what the language is capable of with the tools provided. I have read some books, but they mostly seem to be about the concepts and theories about OOP within C# with minimal syntax.</p> <p>I guess the question is where do I look to learn the syntax-is there some sort of repository of classes and methods that I am missing with examples of how to use the tools it contains? I am stuck in a place of not knowing where to go/look next.</p> <p>Thanks for any help</p>
<p><a href="http://msdn.microsoft.com/en-us/library/a72418yk(VS.80).aspx" rel="nofollow noreferrer"><strong>Getting started with Visual C#</strong></a>.</p>
<p>I started with the <a href="http://www.csharp-station.com/Tutorial.aspx" rel="nofollow noreferrer">C# Station</a> tutorials. "Getting started with Visual C#" gives me the creeps...</p>
6,446
<p>Can anyone point me to a good tutorial on creating a bootable Linux CD from scratch?</p> <p>I need help with a fairly specialized problem: my firm sells an expansion card that requires custom firmware. Currently we use an extremely old live CD image of RH7.2 that we update with current firmware. Manufacturing puts the cards in a machine, boots off the CD, the CD writes the firmware, they power off and pull the cards. Because of this cycle, it's essential that the CD boot and shut down as quickly as possible.</p> <p>The problem is that with the next generation of cards, I have to update the CD to a 2.6 kernel. It's easy enough to acquire a pre-existing live CD - but those all are designed for showing off Linux on the desktop - which means they take forever to boot.</p> <p>Can anyone fix me up with a current How-To?</p> <hr /> <h3>Update:</h3> <p>So, just as a final update for anyone reading this later - the tool I ended up using was &quot;livecd-creator&quot;.</p> <p>My reason for choosing this tool was that it is available for RedHat-based distributions like CentOs, Fedora and RHEL - which are all distributions that my company supports already. In addition, while the project is very poorly documented it is extremely customizable. I was able to create a minimal LiveCD and edit the boot sequence so that it booted directly into the firmware updater instead of a bash shell.</p> <p>The whole job would have only taken an hour or two if there had been a README explaining the configuration file!</p>
<p>One key piece of advice I can give is that most LiveCDs use a compressed filesystem called squashfs to cram as much data on the CD as possible. Since you don't need compression, you could run the mksquashfs step (present in most tutorials) with -noDataCompression and -noFragmentCompression to save on decompression time. You may even be able to drop the squashfs approach entirely, but this would require some restructuring. This may actually be slower depending on your CD-ROM read speed vs. CPU speed, but it's worth looking into.</p> <p>This <a href="https://help.ubuntu.com/community/LiveCDCustomization" rel="nofollow noreferrer">Ubuntu tutorial</a> was effective enough for me to build a LiveCD based on 8.04. It may be useful for getting the feel of how a LiveCD is composed, but I would probably <strong>not</strong> recommend using an Ubuntu LiveCD. </p> <p>If at all possible, find a minimal LiveCD and build up with only minimal stripping out, rather than stripping down a huge LiveCD like Ubuntu. There are some situations in which the smaller distros are using smaller/faster <em>alternatives</em> rather than just leaving something out. If you want to get seriously hardcore, you could look at <a href="http://www.linuxfromscratch.org/" rel="nofollow noreferrer">Linux From Scratch</a>, and include <em>only</em> what you want, but that's probably more time than you want to spend.</p>
<p>Depends on your distro. Here's a good article you can check out from <a href="http://lwn.net/Articles/172132/" rel="nofollow noreferrer">LWN.net</a></p> <p>There is a book I used which covers a lot of distros, though it does not cover creating a flash-bootable image. The book is <a href="https://rads.stackoverflow.com/amzn/click/com/0132432749" rel="nofollow noreferrer" rel="nofollow noreferrer">Live Linux(R) CDs: Building and Customizing Bootables</a>. You can use it with supplemental information from your distro of choice.</p>
5,313
<p>In Visual Studio you can create a template XML document from an existing schema. The new <a href="http://msdn.microsoft.com/en-us/library/cc716766.aspx" rel="noreferrer">XML Schema Explorer</a> in VS2008 SP1 takes this a stage further and can create a sample XML document complete with data. Is there a class library in .NET to do this automatically without having to use Visual Studio? I found the <a href="http://msdn.microsoft.com/en-us/library/aa302296.aspx" rel="noreferrer">XmlSampleGenerator</a> article on MSDN but it was written in 2004 so maybe there is something already included in .NET to do this now?</p>
<p>some footwork is involved, but you could load the xsd into a DataSet object, iterate over the Tables and add a few rows in each by calling calling NewRow() on each and then adding those rows back into their respective tables.. then save the DataSet out to a file:</p> <pre><code>DataSet ds = new DataSet(); ds.ReadXmlSchema("c:/xsdfile.xsd"); foreach(DataTable t in ds.Tables) { var row = t.NewRow(); t.Rows.Add(row); } ds.WriteXml("c:/example.xml"); </code></pre> <p>P.S. A little extra work, but instead of just iterating over each table type and adding empty rows, you could build a nice winform that would allow you to drop in some data for each of the rows. I built something like this in about an hour a few weeks ago.</p>
<p>Directly, none that I can think of, other than third party add-ons. You could utilize the <a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.80).aspx" rel="nofollow noreferrer">xsd schema definition tool</a> to take your XSD and create a .NET object/class, once you have that, you could, to quote the linked page: </p> <blockquote> <p>XSD to Classes: Generates runtime classes from an XSD schema file. The generated classes can be used in conjunction with <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer(VS.80).aspx" rel="nofollow noreferrer">System.Xml.Serialization.XmlSerializer</a> to read and write XML code that follows the schema.</p> </blockquote>
6,304
<p>I've been trying to wrap my head around how threads work in Python, and it's hard to find good information on how they operate. I may just be missing a link or something, but it seems like the official documentation isn't very thorough on the subject, and I haven't been able to find a good write-up.</p> <p>From what I can tell, only one thread can be running at once, and the active thread switches every 10 instructions or so?</p> <p>Where is there a good explanation, or can you provide one? It would also be very nice to be aware of common problems that you run into while using threads with Python.</p>
<p>Yes, because of the Global Interpreter Lock (GIL) there can only run one thread at a time. Here are some links with some insights about this:</p> <ul> <li><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=214235" rel="noreferrer">http://www.artima.com/weblogs/viewpost.jsp?thread=214235</a></li> <li><a href="http://smoothspan.wordpress.com/2007/09/14/guido-is-right-to-leave-the-gil-in-python-not-for-multicore-but-for-utility-computing/" rel="noreferrer">http://smoothspan.wordpress.com/2007/09/14/guido-is-right-to-leave-the-gil-in-python-not-for-multicore-but-for-utility-computing/</a></li> </ul> <p>From the last link an interesting quote:</p> <blockquote> <p>Let me explain what all that means. Threads run inside the same virtual machine, and hence run on the same physical machine. Processes can run on the same physical machine or in another physical machine. If you architect your application around threads, you’ve done nothing to access multiple machines. So, you can scale to as many cores are on the single machine (which will be quite a few over time), but to really reach web scales, you’ll need to solve the multiple machine problem anyway.</p> </blockquote> <p>If you want to use multi core, <a href="http://www.python.org/dev/peps/pep-0371/" rel="noreferrer">pyprocessing</a> defines an process based API to do real parallelization. The <a href="http://en.wikipedia.org/wiki/Python_Enhancement_Proposal#Development" rel="noreferrer">PEP</a> also includes some interesting benchmarks.</p>
<p>Try to remember that the GIL is set to poll around every so often in order to do show the appearance of multiple tasks. This setting can be fine tuned, but I offer the suggestion that there should be work that the threads are doing or lots of context switches are going to cause problems.</p> <p>I would go so far as to suggest multiple parents on processors and try to keep like jobs on the same core(s).</p>
5,127
<p>I would like to convert the following string into an array/nested array: </p> <pre><code>str = "[[this, is],[a, nested],[array]]" newarray = # this is what I need help with! newarray.inspect # =&gt; [['this','is'],['a','nested'],['array']] </code></pre>
<p>You'll get what you want with YAML.</p> <p>But there is a little problem with your string. YAML expects that there's a space behind the comma. So we need this</p> <pre><code>str = "[[this, is], [a, nested], [array]]" </code></pre> <p>Code:</p> <pre><code>require 'yaml' str = "[[this, is],[a, nested],[array]]" ### transform your string in a valid YAML-String str.gsub!(/(\,)(\S)/, "\\1 \\2") YAML::load(str) # =&gt; [["this", "is"], ["a", "nested"], ["array"]] </code></pre>
<p>Looks like a basic parsing task. Generally the approach you are going to want to take is to create a recursive function with the following general algorithm</p> <pre><code>base case (input doesn't begin with '[') return the input recursive case: split the input on ',' (you will need to find commas only at this level) for each sub string call this method again with the sub string return array containing the results from this recursive method </code></pre> <p>The only slighlty tricky part here is splitting the input on a single ','. You could write a separate function for this that would scan through the string and keep a count of the openbrackets - closedbrakets seen so far. Then only split on commas when the count is equal to zero.</p>
5,931
<p>First of all, I know how to build a Java application. But I have always been puzzled about where to put my classes. There are proponents for organizing the packages in a strictly domain oriented fashion, others separate by tier.</p> <p>I myself have always had problems with </p> <ul> <li>naming, </li> <li>placing</li> </ul> <p>So,</p> <ol> <li>Where do you put your domain specific constants (and what is the best name for such a class)?</li> <li>Where do you put classes for stuff which is both infrastructural and domain specific (for instance I have a FileStorageStrategy class, which stores the files either in the database, or alternatively in database)?</li> <li>Where to put Exceptions?</li> <li>Are there any standards to which I can refer?</li> </ol>
<p>I've really come to like Maven's <a href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html" rel="noreferrer" title="S">Standard Directory Layout</a>.</p> <p>One of the key ideas for me is to have two source roots - one for production code and one for test code like so:</p> <pre><code>MyProject/src/main/java/com/acme/Widget.java MyProject/src/test/java/com/acme/WidgetTest.java </code></pre> <p>(here, both src/main/java and src/test/java are source roots).</p> <p>Advantages:</p> <ul> <li>Your tests have package (or "default") level access to your classes under test.</li> <li>You can easily package only your production sources into a JAR by dropping src/test/java as a source root.</li> </ul> <p>One rule of thumb about class placement and packages:</p> <p>Generally speaking, well structured projects will be free of <a href="http://en.wikipedia.org/wiki/Circular_dependency" rel="noreferrer">circular dependencies</a>. Learn when they are bad (and when they are <a href="http://beust.com/weblog/archives/000208.html" rel="noreferrer">not</a>), and consider a tool like <a href="http://www.google.ca/search?q=JDepend&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a" rel="noreferrer">JDepend</a> or <a href="http://www.hello2morrow.com/products/sonargraph" rel="noreferrer">SonarJ</a> that will help you eliminate them.</p>
<p>One thing I've done in the past - if I'm extending a class I'll try and follow their conventions. For example, when working with the Spring Framework, I'll have my MVC Controller classes in a package called com.mydomain.myapp.web.servlet.mvc If I'm not extending something I just go with what is simplest. com.mydomain.domain for Domain Objects (although if you have a ton of domain objects this package could get a bit unwieldy). For domain specific constants, I actually put them as public constants in the most related class. For example, if I have a "Member" class and have a maximum member name length constant, I put it in the Member class. Some shops make a separate Constants class but I don't see the value in lumping unrelated numbers and strings into a single class. I've seen some other shops try to solve this problem by creating SEPARATE Constants classes, but that just seems like a waste of time and the result is too confusing. Using this setup, a large project with multiple developers will be duplicating constants all over the place.</p>
2,915
<p>What are the essential vim commands? What does a new-user need to know to keep themselves from getting into trouble? One command per comment, please.</p>
<p>What I find irreplaceable (because it works in vi also, unlike vim's visual mode) are marks. You can mark various spots with <code>m</code> (lower case) and then a letter of your choice (eg x). Then you go elsewhere, and can go back with ``x<code>(backquote letter) to the exact spot, or with</code>'x` (apostrophe letter) to go to the line.</p> <p>These movements can be used as arguments to commands (yank, delete, etc). For example, you want to delete 10 lines; instead of counting and then moving to the topmost line and entering <code>10dd</code>, you go to either the start or the end of the block, press <code>mm</code> (mark m), then go to the other end of the block, and press <code>d'm</code> (delete apostrophe m). If you use backquote instead of apostrophe in this example, then the deletion will work character-wise, not line-wise. Try marking in the middle of the line with "mark m", moving to the middle of another line, then entering "d backquote m" and you will see what I mean.</p>
<p>One of my favourite commands is %G which takes to directly to the end of a file. Especially useful in log-files.</p>
9,527
<p>Coming up with good, precise names for classes is notoriously difficult. Done right, it makes code more self-documenting and provides a vocabulary for reasoning about code at a higher level of abstraction. </p> <p>Classes which implement a particular design pattern might be given a name based on the well known pattern name (e.g. FooFactory, FooFacade), and classes which directly model domain concepts can take their names from the problem domain, but what about other classes? Is there anything like a programmer's thesaurus that I can turn to when I'm lacking inspiration, and want to avoid using generic class names (like FooHandler, FooProcessor, FooUtils, and FooManager)?</p>
<p>I'll cite some passages from <a href="https://rads.stackoverflow.com/amzn/click/com/0321413091" rel="noreferrer" rel="nofollow noreferrer">Implementation Patterns</a> by Kent Beck:</p> <h2>Simple Superclass Name</h2> <blockquote> <p>&quot;[...] The names should be short and punchy. However, to make the names precise sometimes seems to require several words. A way out of this dilemma is picking a strong metaphor for the computation. With a metaphor in mind, even single words bring with them a rich web of associations, connections, and implications. For example, in the HotDraw drawing framework, my first name for an object in a drawing was <strong>DrawingObject</strong>. Ward Cunningham came along with the typography metaphor: a drawing is like a printed, laid-out page. Graphical items on a page are figures, so the class became <strong>Figure</strong>. In the context of the metaphor, <strong>Figure</strong> is simultaneously shorter, richer, and more precise than <strong>DrawingObject</strong>.&quot;</p> </blockquote> <h2>Qualified Subclass Name</h2> <blockquote> <p>&quot;The names of subclasses have two jobs. They need to communicate what class they are like and how they are different. [...] Unlike the names at the roots of hierarchies, subclass names aren’t used nearly as often in conversation, so they can be expressive at the cost of being concise. [...]</p> <p>Give subclasses that serve as the roots of hierarchies their own simple names. For example, <em>HotDraw</em> has a class <strong>Handle</strong> which presents figure- editing operations when a figure is selected. It is called, simply, <strong>Handle</strong> in spite of extending <strong>Figure</strong>. There is a whole family of handles and they most appropriately have names like <strong>StretchyHandle</strong> and <strong>TransparencyHandle</strong>. Because <strong>Handle</strong> is the root of its own hierarchy, it deserves a simple superclass name more than a qualified subclass name.</p> <p>Another wrinkle in subclass naming is multiple-level hierarchies. [...] Rather than blindly prepend the modifiers to the immediate superclass, think about the name from the reader’s perspective. What class does he need to know this class is like? Use that superclass as the basis for the subclass name.&quot;</p> </blockquote> <h2>Interface</h2> <blockquote> <p>Two styles of naming interfaces depend on how you are thinking of the interfaces. Interfaces as classes without implementations should be named as if they were classes (<em>Simple Superclass Name</em>, <em>Qualified Subclass Name</em>). One problem with this style of naming is that the good names are used up before you get to naming classes. An interface called <strong>File</strong> needs an implementation class called something like <strong>ActualFile</strong>, <strong>ConcreteFile</strong>, or (yuck!) <strong>FileImpl</strong> (both a suffix and an abbreviation). In general, communicating whether one is dealing with a concrete or abstract object is important, whether the abstract object is implemented as an interface or a superclass is less important. Deferring the distinction between interfaces and superclasses is well &gt;supported by this style of naming, leaving you free to change your mind later if that &gt;becomes necessary.</p> <p>Sometimes, naming concrete classes simply is more important to communication than hiding the use of interfaces. In this case, prefix interface names with “I”. If the interface is called <strong>IFile</strong>, the class can be simply called <strong>File</strong>.</p> </blockquote> <p>For more detailed discussion, buy the book! It's worth it! :)</p>
<p>If your "FooProcessor" really does process foos, then don't be reluctant to give it that name just because you already have a BarProcessor, BazProcessor, etc. When in doubt, obvious is best. The other developers who have to read your code may not be using the same thesaurus you are.</p> <p>That said, more specificity wouldn't hurt for this particular example. "Process" is a pretty broad word. Is it really a "FooUpdateProcessor" (which might become "FooUpdater"), for example? You don't have to get too "creative" about the naming, but if you wrote the code you probably have a fairly good idea of what it does and doesn't do.</p> <p>Finally, remember that the bare class name isn't all that you and the readers of your code have to go on - there are usually namespaces in play as well. Those can often give readers enough context to see clearly what your class if really for, even if its bare name is fairly generic.</p>
5,891
<p>I am working in Visual Basic 6 and need to sort by multiple columns in a ListView. For example, sorting a list of music tracks by artist, then album, then track number. As far as I know, VB6 does not support this out of the box. Here are the suggestions I have already heard:</p> <ul> <li>Sort the data in a SQL table first and display the data in the resulting order</li> <li>Sort the data in an ADO recordset object in memory</li> <li>Sort by the primary column and then perform a sort algorithm on the items, moving them around into the correct positions manually</li> </ul> <p>Does anyone have experience with multiple-column sorting in VB6 who could lend advice?</p>
<p>I would create a hidden column in the listview that concatenates those three columns and sort by that</p>
<p>You can try sorting using the Windows API and callbacks: <a href="http://vbnet.mvps.org/index.html?code/callback/lvsortcallback.htm" rel="nofollow noreferrer">Link</a></p> <p>Alternatively, you could try switching to a <a href="http://www.vbaccelerator.com/home/VB/Code/Controls/ListView/article.asp" rel="nofollow noreferrer">vbAccelerator ListView</a>; I highly recommend it.</p>
6,771
<p>The object on the right is a basic C channel, the outer surface should be smooth but the first ~5 mm of filament is missing after every layer change. In this example, the missing filament is reasonably consistent and extreme. The object on the left (from the same print) has a seam where the filament is also missing but it was not a layer change so it is only missing 1-2 mm.</p> <p><a href="https://i.stack.imgur.com/mepw9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mepw9.jpg" alt="enter image description here" /></a></p> <p>But when printing a benchy the gap is not as large and has different lengths. The other side of the Benchy looks great, this side has all of the seams on it.</p> <p><a href="https://i.stack.imgur.com/5UIwH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5UIwH.jpg" alt="enter image description here" /></a></p> <p>Details</p> <ul> <li>Anet A6 direct drive</li> <li>Marlin firmware with the latest Octoprint</li> <li>Heated enclosure, glass bed @ 60 °C</li> <li>eSun PLA, have used many cheaper brands all with the same issue</li> <li>Printing at 210 °C but have tested 180-220 °C</li> </ul> <p>When printing an army of Benchys, I thought this was a retraction issue and test all sorts of settings with small increments but did not fix the issue. It was after printing this C channel that the issue was more clearly highlighted.</p> <p>Things that I have attempted to resolve this</p> <ul> <li>Geomerty calerbration</li> <li>Extruder calerbration</li> <li>Filament temperature range tests</li> <li>Retraction distance and speed towers</li> <li>Retraction distance and temperature towers</li> <li>Disabling retraction (worth a short) - Disabling retraction during only Z hop (did nothing)</li> <li>Different version of Cura</li> <li>Different filament brands</li> </ul> <p>Can not seem to figure out what the issue here is and have run out of ideas on what to do next.</p>
<p><a href="https://www.instructables.com/Copper-Electroforming-on-3d-Printed-PLAABS-Objects/" rel="nofollow noreferrer">Electroforming</a> is the process of applying a conductive paint to a non-conductive surface. Once dry, the object is subjected to a process similar to electroplating, in that molecules of a conductive, more durable metal are bonded to the conductive paint, which is bonded to the 3D printed part.</p> <p>Typical metals would be nickel, which is quite conductive, as well as copper, known for conductivity. One could be somewhat absurd and perform the same process with silver and gold. The absurdity is related to the expense of those materials.</p> <p>The link covers using copper, but I believe that nickel would be more durable.</p> <p>Your joint selection is more related to the strength of the design and contact surface area and may be better suited for a more detailed separate question.</p> <p><a href="https://i.stack.imgur.com/ypefi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ypefi.png" alt="electroformed 3d printed calibration cube" /></a> As usual, image from linked site.</p>
<p>For your task you basically have several options:</p> <ol> <li><strong>Electroforming</strong> (see @fred_dot_u answer). Pros: high electrical conductivity due to actual metal layer; very low friction between polished metal layers. Cons: the process is quite dirty and requires additional materials and processing, plus some skill to produce results of appropriate quality.</li> <li><strong>Conductive filament</strong> (e.h. <a href="https://www.makerbot.com/3d-printers/materials/method-pla/" rel="nofollow noreferrer">PLA from Makerbot</a>). Pros: direct printing of any form. Cons: high price, probably tricky to print with, high current resistance.</li> <li><strong>Sliding electrical connections</strong> (e.g. as in brushed motors or magnetic USB charging cables). Pros: when properly executed will be very durable and probably could even reuse parts from existing markets (brushed motors use this trick for very long time). Cons: requires additional engineering and redesign of your existing parts.</li> <li><strong>Wireless connection</strong> (e.g. parts use radio/Bluetooth/WiFi for communicating). Pros: independent functionality of each 'limb'. Cons: independent power sources required for each limb; complex communication means.</li> <li><strong>Optical signalling</strong>. Pros: no electrical connections; depending on your use-case might fall in-between <em>wireless connection</em> (without the need of additional power source) and <em>sliding/magnetic connections</em>. Cons: requires skills and tools to work with fiberoptics, which is totally different story.</li> </ol> <p>Depending on your resources, requirements, skills and time you would chose one of above. You may also find some alternative solutions from engineering world.</p>
2,168
<p>I'm having an issue where the first layer of my support structures isn't sticking on the edges and causing the print to (eventually) fail. Any ideas on how I can fix it?</p> <p>I'm using Slic3r.</p> <p><a href="https://i.stack.imgur.com/XD4AX.jpg" rel="nofollow noreferrer" title="Photograph of first printed layer"><img src="https://i.stack.imgur.com/XD4AX.jpg" alt="Photograph of first printed layer" title="Photograph of first printed layer"></a></p>
<p>There are many things you'll need to check and/or confirm to ensure that you will have a good bond to the bed. The first is to confirm that you are using a genuine Prusa printer as it appears in the photo. Having built one recently makes it easier for me to guess that is the case.</p> <p>Have you performed the bed calibration sequence? The manual provides a series of steps which results in a zig-zag pattern of filament being placed on the bed, while the z-height is adjusted from the panel. You want to have a filament trace that is only slightly squished onto the bed, not flattened so much that it's cutting into the PEI and not so high that it's nearly cylindrical.</p> <p>The bed must be of the correct temperature for the filament selected. If in doubt, raise it five to ten degrees C. I recently assisted with the aforementioned printer that had a peeling problem and the bed temperature had to be raised to 70°C from the "standard" 55°C generated by Slic3r.</p> <p>It is critical that the bed be clean as well. Denatured alcohol is recommended, with application of a clean cloth.</p> <p>Your photo is somewhat out of focus, making it difficult to determine if the brim is being created at an excessively high z-level, which will cause peeling. The main body of the print, also out of focus appears to be heavily flattened, but that could be an artifact of the photo.</p> <p>The reflections on the bed appear to indicate that some gouges in the surface exist. If your PEI is damaged, you will have the problem you described. I've seen videos in which the bed is not quite as gouged and was refreshed with very light sandpaper or very light steel wool or both. Of course, after using such material, clean the surface thoroughly.</p> <p>I understand the PEI that is applied by the manufacturer is quite thin and can be further damaged if too much pressure is applied while refreshing. It is far better to apply too little pressure if you plan to perform this task.</p> <p>Consider to read through the manual and address all of the calibration aspects of the printer to establish a base point for the problem you are experiencing.</p>
<p>I had a similar issue where slic3r generated supports that attach directly to the bed, but didn't put enough material around the thin supports on the first layer, so they didn't stick to the bed.</p> <p>To solve this I added a brim, see "skirt and brim" under "print settings". This puts more material around both the part and also the supports on the first layer.</p> <p>I didn't need the brim round the whole part as it was sticking to the bed just fine anyway, but this was the only way I could find to give the thin supports the wide base they need to stick to the bed. I used a 5mm brim, but I am sure it would work with less than this.</p>
578
<p>I've seen conflicting advice on the correct printing temperature for Microcenter's house-brand Inland PLA+, particularly after a supplier change announced in April 2018.</p> <p>There's an <a href="https://www.reddit.com/r/3Dprinting/comments/89grfm/psa_on_our_micro_center_inland_filament/" rel="nofollow noreferrer">official post from Microcenter</a>, where they state that their PLA+ from both the suppliers they use prints best from 215-225&nbsp;&deg;C. (The label on the spool specifies 205-225&nbsp;&deg;C).</p> <p>However, I've run a series of Benchy prints with recently-purchased white inland PLA+ at different temperatures (with a Lulzbot SL toolhead and 0.1&nbsp;mm layer depth, slicing by Cura LE 3.6.10 after repairing the STL with <a href="https://tools3d.azurewebsites.net" rel="nofollow noreferrer">Microsoft's repair tool</a>, movement 30&nbsp;mm/sec), and my experience is very different:</p> <ul> <li>220&nbsp;&deg;C has very severe stringing and blobbing, including blobbing on top surfaces. The text on the base is not visible at all.</li> <li>215&nbsp;&deg;C has substantial stringing and blobbing, particularly on inside surfaces, but not on the roof of the boat (except the prow). The text on the base is partially visible.</li> <li>210&nbsp;&deg;C looks very good; there are some tiny blobs on the nameplate and the inside door, and no stringing. This was the first one that didn't require a razor blade to remove from the PEI surface. The text on the base is very clear.</li> <li>205&nbsp;&deg;C looks great.</li> </ul> <p>Is something wrong with my equipment, such that it's printing with a higher temperature than it reads? Is Microcenter's advice off? Could I have a batch that behaves differently than is expected for the same filament in general?</p> <p>More to the point -- what advice do others have to get good results with Inland PLA+?</p>
<p>Even as PLA+ contains some additives, each printer is different. We usually never know what the actual temperature of the printhead is, but if your printer prints good at 205 °C, despite the manufacturer claiming you should use a little more temperature, use it. It might be the perfect combination of temperature and speed for <strong>your</strong> printer. Your printer is not the benchmark machine the manufacturer of the filament used, and we have no idea what speeds they used if they had an enclosure and what style of hotend they used.</p>
<p>A portion of information missing from the manufacturer's specifications and in the question is the print speed. You could have slower speeds than the manufacturer used to perform the tests, which requires lower temperatures to reduce the "flow rate" of the plastic to an acceptable level. </p> <p>In some cases, I use as low as 20 mm per second print speed, others can be as high as 60 mm per second. At the higher speeds, I will increase the temperature five degrees C to ensure that the hot end can keep up with the increased filament extrusion. Alternatively, slower speeds need lower temperatures. The variation may not be larger as described for your system. You've already experienced a substantial difference based on your posted numbers.</p> <p>It would be unrealistic to collect others' experiences with a specific brand unless color choice, print speed, printer model/hot end model, etc are also collected. Let's include part cooling fan settings as well to complicate the task even more.</p> <p>You can consider to check the great Thingiverse library for temperature test models. These files are used to print various segments at different temperatures. Due to the above noted factors, you may find your result can be clustered or may find they cannot, based on color, manufacturer, age, etc. It is a valuable resource to improve your printing results, however.</p>
1,384
<p>I'm translating my C# code for YouTube video comments into PHP. In order to properly nest comment replies, I need to re-arrange XML nodes. In PHP I'm using DOMDocument and DOMXPath which closely corresponds to C# XmlDocument. I've gotten pretty far in my translation but now I'm stuck on getting the parent node of a DOMElement. A DOMElement does not have a parent_node() property, only a DOMNode provides that property.</p> <p>After determining that a comment is a reply to a previous comment based in the string "in-reply-to" in a link element, I need to get its parent node in order to nest it beneath the comment it is in reply to:</p> <pre><code>// Get the parent entry node of this link element $importnode = $objReplyXML-&gt;importNode($link-&gt;parent_node(), true); </code></pre>
<p><a href="http://no2.php.net/manual/en/class.domelement.php" rel="noreferrer">DOMElement</a> is a subclass of <a href="http://no2.php.net/manual/en/class.domnode.php" rel="noreferrer">DOMNode</a>, so it does have parent_node property. Just use $domNode->parentNode; to find the parent node.</p> <p>In your example, the parent node of $importnode is null, because it has been imported into the document, and therefore does not have a parent yet. You need to attach it to another element before it has a parent.</p>
<p>I'm not entirely sure how your code works, but it seems like you have a small error in your code. </p> <p>On the line you posted in your question you have <code>$link-&gt;parent_node()</code>, but in the answer with the entire code snippet you have <code>$link**s**-&gt;parent_node()</code>. </p> <p>I don't think the <code>s</code> should be there. </p> <p><strong>Also, I think you should use $link->parentNode, not $link->parent_node().</strong></p>
4,852
<p>Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion.</p> <p>I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net. The site itself remains ASP for the moment...</p> <p>Can anybody recommend a good way of replacing the recordset object type with a web service compatible type (like an array or something)? What do I replace below with?:</p> <pre><code>set objRS = oConn.execute(SQL) while not objRS.eof ... name = Cstr(objRS(1)) ... wend </code></pre> <p>and also mutliple recordsets can be replaced with? I'm talking :</p> <pre><code> set objRS = objRs.nextRecordset </code></pre> <p>Anybody went through this and can recommend?</p> <p><strong><em>@AdditionalInfo - you asked for it :-)</em></strong></p> <p>Let me start at the beginning. <strong>Existing Situation is</strong>: I have an old ASP website with classical hierachical content (header, section, subsection, content) pulled out of database via stored procedures and content pages are in database also (a link to html file).</p> <p>Now bad thing is, ASP code everywhere spread over many .asp files all doing their own database connections, reading, writing (u have to register for content). Recently we had problems with SQL injection attacks so I was called to fix it.</p> <p>I <em>could</em> go change all the .asp pages to prevent sql injection but that would be madness. So I thought build a data layer - all pages using this layer to access database. Once place to fix and update db access code.</p> <p>Coming to that decision I thought asp.net upgrade isn'f far away, why not start using asp.net for the data layer? This way it can be re-used when upgrading the site.</p> <p>That brings me to the questions above!</p>
<p>First my favorite advice of this week: do not treat your Web Service like it if was a local object or you are going to pay a very hefty performance price. Essentially, don't do things like this in your web application:</p> <pre><code>MyDataWebService ws = new MyDataWebService(); foreach(DataItem item in myData) { ws.Insert(item); } </code></pre> <p>You should always prefer to minimize calls to your Web Service (and SQL):</p> <pre><code>MyDataWebService ws = new MyDataWebService(); ws.Insert(myData); // Let the web service process the whole set at once. </code></pre> <p>Now, as far as the data type to use for your web service calls, you basically have two choices:</p> <ul> <li>DataSet</li> <li>Everything else (Array)</li> </ul> <p>Most collections returned from a web service (like a List&lt;MyData&gt;) actually convert to an Array during the Web Service invocation. Remember that Web Services don't return objects (data + behavior) but just data structures (or a sequence of). Therefore, there is little distinction between a List and an Array.</p> <p>DataSets are more complex classes; they use their own custom serializer and pretty much get fully recreated in the calling application. There is a cost in performance to be paid for using DataSets like that, so I don't usually recommend it for most scenarios. Using arrays to pass data back and forth tends to be more efficient, and quite frankly it's easier to do.</p> <p>Your case is a bit different; because you are converting an existing site that already uses ADO, an ADO.NET DataSet might be your best updgrade path. ADO.NET and ADO are similar enough that a straight update might be easier that way. It kind of depends how your web site is built.</p> <p>For the last part of your question, DataSets do support multiple recordsets similar to ADO's Recordset. They are called DataTables. Every DataSet has at least one DataTable and you can read them in any order.</p> <p>Good luck.</p>
<p>I'd suggest using the XmlHttp class in your ASP code.</p> <p>Assuming you have an ASMX web service similar to this, in MyService.asmx:</p> <pre><code>[WebMethod] public string HelloWorld() { return "Hello World"; } </code></pre> <p>You could call it in ASP something like this:</p> <pre><code>Dim xhr Set xhr = server.CreateObject("MSXML2.XMLHTTP") xhr.Open "POST", "/MyService.asmx/HelloWorld", false xhr.SetRequestHeader "content-type", "application/x-www-form-urlencoded" xhr.Send Response.Write(xhr.ResponseText) </code></pre> <p>ResponseText would be an XML response of:</p> <pre><code>&lt;string&gt;Hello World&lt;/string&gt; </code></pre> <p>Assuming your service returned a collection of data, you could iterate over it using XPath or any other XML processing technique/library.</p> <p>Googling around about MSXML2 will probably answer any specific questions you have, since it's specific to ASP classic.</p>
7,901
<p>Is there any way to enforce a template in Bugzilla to guide users fill in bugs descriptions ?</p> <p>Actually, i'd like to put some markup texts in the bug description field and avoid the creation of custom fields.</p> <p>I've installed version 3.2rc1.</p>
<p>Indeed, just check ../enter_bug.cgi?format=guided , which forms an example of the template feature. Half the work is already done for you.</p>
<p>The mechansism described under <a href="https://www.bugzilla.org/docs/2.18/html/cust-templates.html" rel="nofollow noreferrer">6.2.5 Particular Templates</a> (under the section called bug/create/create.html.tmpl and bug/create/comment.txt.tmpl) works pretty well for us. Even though you say you don't want to create custom fields, adding some arbitrary HTML is easy enough.</p>
8,363
<p>I'm making a simple 2 player game in XNA and started looking into saving the player's high scores.</p> <p>I want the game to work on the XBox 360 as well as Windows, so I have to use the framework to save the data.</p> <p>It seems that you save data to a particular user's gamer tag - so my question is, what to do with high scores?</p> <ul> <li>Save the user's own scores in their profile? (So you can only see your own scores if you're the only one signed in)</li> <li>Try and save other player's scores in all profiles? (Seems like a pain to try and keep this sync'd)</li> <li>Store scores online <ul> <li>The 360 seems to have a standard method for showing friend's high scores. Can this be accessed from within XNA, or is it only available to published games?</li> <li>Roll my own. (Seems excessive for such a small personal project.)</li> </ul></li> </ul>
<p>You're right -- looks like Eclipse has acknowledged it as a <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499" rel="nofollow noreferrer">bug</a>. It's fixed in 3.5.</p>
<p>I was initially thinking <kbd>Alt</kbd>-<kbd>←</kbd> and <kbd>Alt</kbd>-<kbd>→</kbd> might do what you want, but that's more for going forward and backwards in history of tabs you've viewed. Which might sort of get you what you want, but is probably just as confusing as <kbd>Alt</kbd>-<kbd>F6</kbd>.</p> <p>I think it sounds more like a bug in Eclipse, might be worth going over to eclipse.org to see if there's a pre-existing bug for this.</p>
8,698
<p>I'd like to take some RTF input and clean it to remove all RTF formatting except \ul \b \i to paste it into Word with minor format information.</p> <p>The command used to paste into Word will be something like: oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0) (with some RTF text already in the Clipboard)</p> <pre><code>{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}} {\colortbl ;\red255\green255\blue140;} \viewkind4\uc1\pard\highlight1\lang3084\f0\fs18 The company is a global leader in responsible tourism and was \ul the first major hotel chain in North America\ulnone to embrace environmental stewardship within its daily operations\highlight0\par </code></pre> <p>Do you have any idea on how I can clean up the RTF safely with some regular expressions or something? I am using VB.NET to do the processing but any .NET language sample will do.</p>
<p>I would use a hidden RichTextBox, set the Rtf member, then retrieve the Text member to sanitize the RTF in a well-supported way. Then I would use manually inject the desired formatting afterwards.</p>
<p>Regex it, it wont parse absolutely everything correctly (tables for example) but does the job in most cases.</p> <pre><code>string unformatted = Regex.Replace(rtfString, @"\{\*?\\[^{}]+}|[{}]|\\\n?[A-Za-z]+\n?(?:-?\d+)?[ ]?", ""); </code></pre> <p>Magic =)</p>
4,081
<p>I understand the difference between <code>String</code> and <code>StringBuilder</code> (<code>StringBuilder</code> being mutable) but is there a large performance difference between the two? </p> <p>The program I’m working on has a lot of case driven string appends (500+). Is using <code>StringBuilder</code> a better choice?</p>
<p>Yes, the performance difference is significant. See the KB article "<a href="http://support.microsoft.com/kb/306822" rel="noreferrer">How to improve string concatenation performance in Visual C#</a>".</p> <p>I have always tried to code for clarity first, and then optimize for performance later. That's much easier than doing it the other way around! However, having seen the enormous performance difference in my applications between the two, I now think about it a little more carefully. </p> <p>Luckily, it's relatively straightforward to run performance analysis on your code to see where you're spending the time, and then to modify it to use <code>StringBuilder</code> where needed.</p>
<p>StringBuilder will perform better, from a memory stand point. As for processing, the difference in time of execution may be negligible.</p>
9,955
<p>Is there any chance to get this work? I want my tests to be run by nunit2 task in NAnt. In addition I want to run NCover without running tests again. </p>
<p>I figured it out. You change the path of the NUnit launcher to that of TeamCity's own. Here is an example:</p> <pre><code> &lt;mkdir dir="${build}/coverage" failonerror="false"/&gt; &lt;!-- run the unit tests and generate code coverage --&gt; &lt;property name="tools.dir.tmp" value="${tools.dir}"/&gt; &lt;if test="${not path::is-path-rooted(tools.dir)}"&gt; &lt;property name="tools.dir.tmp" value="../../${tools.dir}"/&gt; &lt;/if&gt; &lt;property name="nunitpath" value="${lib.dir}/${lib.nunit.basedir}/bin/nunit-console.exe"/&gt; &lt;property name="nunitargs" value=""/&gt; &lt;if test="${property::exists('teamcity.dotnet.nunitlauncher')}"&gt; &lt;property name="nunitpath" value="${teamcity.dotnet.nunitlauncher}"/&gt; &lt;property name="nunitargs" value="v2.0 x86 NUnit-2.4.8"/&gt; &lt;/if&gt; &lt;ncover program="${tools.dir.tmp}/${tools.ncover.basedir}/ncover.console.exe" commandLineExe="${nunitpath}" commandLineArgs="${nunitargs} ${proj.name.unix}.dll" workingDirectory="${build}" assemblyList="${proj.srcproj.name.unix}" logFile="${build}/coverage/coverage.log" excludeAttributes="System.CodeDom.Compiler.GeneratedCodeAttribute" typeExclusionPatterns=".*?\{.*?\}.*?" methodExclusionPatterns="get_.*?; set_.*?" coverageFile="${build}/coverage/coverage.xml" coverageHtmlDirectory="${build}/coverage/html/" /&gt; </code></pre> <p>As you can see, I have some of my own variables in there, but you should be able to figure out what is going on. The property you are concerned with is teamcity.dotnet.nunitlauncher. You can read more about it here at <a href="http://www.jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher" rel="nofollow noreferrer">http://www.jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher</a>. </p>
<p>I am having to do the same thing. I think the best we can hope for is to break open the NUnit jar file that comes with TeamCity and writing a custom task that integrates NUnit2 and NCover. I wish this wasn't so, but the NUnit2 task does not produce any visible output, so TeamCity is obviously not reading StdOut for the test results.</p>
6,564
<p>What are good ways of dealing with the issues surrounding plugin code that interacts with outside system?</p> <p>To give a concrete and representative example, suppose I would like to use Subversion and Eclipse to develop plugins for WordPress. The main code body of WordPress is installed on the webserver, and the plugin code needs to be available in a subdirectory of that server.</p> <p>I could see how you could simply checkout a copy of your code directly under the web directory on a development machine, but how would you also then integrate this with the IDE?</p> <p>I am making the assumption here that all the code for the plugin is located under a single directory.</p> <p>Do most people just add the plugin as a project in an IDE and then place the working folder for the project wherever the 'main' software system wants it to be? Or do people use some kind of symlinks to their home directory?</p>
<p>There are a few ways to do what you need in PostgreSQL.</p> <ul> <li><p>If you can install modules, look at the tablefunc contrib. It has a connectby() function that handles traversing trees. <a href="http://www.postgresql.org/docs/8.3/interactive/tablefunc.html" rel="noreferrer">http://www.postgresql.org/docs/8.3/interactive/tablefunc.html</a></p></li> <li><p>Also check out the ltree contrib, which you could adapt your table to use: <a href="http://www.postgresql.org/docs/8.3/interactive/ltree.html" rel="noreferrer">http://www.postgresql.org/docs/8.3/interactive/ltree.html</a></p></li> <li><p>Or you can traverse the tree yourself with a PL/PGSQL function.</p></li> </ul> <p>Something like this:</p> <pre><code>create or replace function example_subtree (integer) returns setof example as 'declare results record; child record; begin select into results * from example where parent_id = $1; if found then return next results; for child in select id from example where parent_id = $1 loop for temp in select * from example_subtree(child.id) loop return next temp; end loop; end loop; end if; return null; end;' language 'plpgsql'; select sum(value) as value_sum from example_subtree(1234); </code></pre>
<p>If you need to store arbitrary graphs, not just hierarchies, you could push Postgres to the side and try a graph database such as <a href="http://agraph.franz.com/support/learning/" rel="nofollow noreferrer">AllegroGraph</a>:</p> <p>Everything in the graph database is stored as a triple (source node, edge, target node) and it gives you first class support for manipulating the graph structure and querying it using a SQL like language. </p> <p>It doesn't integrate well with something like Hibernate or Django ORM but if you are serious about graph structures (not just hierarchies like the Nested Set model gives you) check it out. </p> <p>I also believe Oracle has finally added a support for real Graphs in their latest products, but I'm amazed it's taken so long, lots of problems could benefit from this model.</p>
7,654
<p>My Y-axis on my Monoprice maker select running ramps 1.4 and Marlin makes a thud noise when moving every now and then. I have noticed a 1 to 2 mm shift in the print when this occurs. I tighten the belts and alas no joy. I ordered new bearings which should be coming Monday. I also tried slowing the print down and still get the same result. Anyone have any ideas.</p>
<p>The issue was the X-axis top smooth rod came out. this caused the extruder to bang around and shift on the Y-axis when it shifted forward. thank everyone for their help. </p>
<p>A thudding noise is usually a belt slipping through its end-restraints. A clicking noise is usually a stepper motor missing a step. Seized bearings could be the cause.</p>
734
<p>I have a collection of objects in a database. Images in a photo gallery, products in a catalog, chapters in a book, etc. Each object is represented as a row. I want to be able to arbitrarily order these images, storing that ordering in the database so when I display the objects, they will be in the right order.</p> <p>For example, let's say I'm writing a book, and each chapter is an object. I write my book, and put the chapters in the following order:</p> <blockquote> <p>Introduction, Accessibility, Form vs. Function, Errors, Consistency, Conclusion, Index</p> </blockquote> <p>It goes to the editor, and comes back with the following suggested order:</p> <blockquote> <p>Introduction, Form, Function, Accessibility, Consistency, Errors, Conclusion, Index</p> </blockquote> <p>How can I store this ordering in the database in a robust, efficient way?</p> <p>I've had the following ideas, but I'm not thrilled with any of them:</p> <ol> <li><p>Array. Each row has an ordering ID, when order is changed (via a removal followed by an insertion), the order IDs are updated. This makes retrieval easy, since it's just <code>ORDER BY</code>, but it seems easy to break.</p> <blockquote> <p><code>// REMOVAL</code><br> <code>UPDATE ... SET orderingID=NULL WHERE orderingID=removedID</code><br> <code>UPDATE ... SET orderingID=orderingID-1 WHERE orderingID &gt; removedID</code><br> <code>// INSERTION</code><br> <code>UPDATE ... SET orderingID=orderingID+1 WHERE orderingID &gt; insertionID</code><br> <code>UPDATE ... SET orderID=insertionID WHERE ID=addedID</code></p> </blockquote></li> <li><p>Linked list. Each row has a column for the id of the next row in the ordering. Traversal seems costly here, though there may by some way to use <code>ORDER BY</code> that I'm not thinking of.</p></li> <li><p>Spaced array. Set the orderingID (as used in #1) to be large, so the first object is 100, the second is 200, etc. Then when an insertion happens, you just place it at <code>(objectBefore + objectAfter)/2</code>. Of course, this would need to be rebalanced occasionally, so you don't have things too close together (even with floats, you'd eventually run into rounding errors).</p></li> </ol> <p>None of these seem particularly elegant to me. Does anyone have a better way to do it?</p>
<p>An other alternative would be (if your RDBMS supports it) to use columns of type array. While this breaks the normalization rules, it can be useful in situations like this. One database which I know about that has arrays is PostgreSQL.</p>
<p>I had the same issue and have probably spent at least a week concerning myself about the proper data modeling, but I think I've finally got it. Using the array datatype in PostgreSQL, you can store the primary key of each ordered item and update that array accordingly using insertions or deletions when your order changes. Referencing a single row will allow you to map all your objects based on the ordering in the array column.</p> <p>It's still a bit choppy of a solution but it will likely work better than option #1, since option 1 requires updating the order number of all the other rows when ordering changes. </p>
4,155
<p>This is mostly geared toward desktop application developers. <br />How do I design a caching block which plays nicely with the GC? <br />How do I tell the GC that I have just done a cache sweep and it is time to do a GC? <br />How do I get an accurate measure of when it is time to do a cache sweep?</p> <p>Are there any prebuilt caching schemes which I could borrow some ideas from?</p>
<p>Actually, the recommended way now is to use <code>mkp.yield</code>, e.g.,</p> <pre><code>src.p { mkp.yield 'Some element that has a ' strong 'child element' mkp.yield ' which seems pretty basic.' } </code></pre> <p>to produce</p> <pre><code>&lt;p&gt;Some element that has a &lt;strong&gt;child element&lt;/strong&gt; which seems pretty basic.&lt;/p&gt; </code></pre>
<p>Include a method:</p> <pre><code>void text(n){ builder.yield n } </code></pre> <p>Most likely you (I) copied this code from somewhere that had a text method, but you didn't also copy the text method. Since MarkupBuilder accepts any name for the name of a tag and browsers ignore unknown markup, it just happened to work.</p>
4,315
<p>When slicing with Slic3r Prusa edition the top layer of most models turns out pretty bad. There are usually small gaps or weird patterns. This does not happen with Ultimaker Cura, it will have a nice smooth top layer. Is there anything settings wise that I can do in Slic3r to get the same quality of top layer as Ultimaker Cura?</p> <p><a href="https://i.stack.imgur.com/HGc8C.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HGc8C.jpg" alt="Slic3r"></a></p> <p><a href="https://i.stack.imgur.com/vbDHj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vbDHj.png" alt="Cura"></a></p>
<p><strong>Yes</strong>, you can show more than 300 lines in the terminal; just <a href="https://github.com/foosel/OctoPrint/commit/e9623fdc36c658a5b8abe7769b1b308edfc3f424" rel="nofollow noreferrer">disable auto scrolling</a> (<a href="https://github.com/foosel/OctoPrint/issues/286#issuecomment-99215149" rel="nofollow noreferrer">reference</a>).</p> <blockquote> <p>Disabling Autoscroll now completely disables cutting off the lines (so you can have way more than 300 lines while that's disabled), filtering has been improved too and doesn't cause scrolling anymore.</p> </blockquote> <p>Note that with disabled autoscrolling, you will be able to see more lines up to the point that the buffer is full. If you need even more lines to monitor, just enable the logging the data to file <code>serial.log</code>. If you open the options page (OctoPrint Settings), just tick the box for "Log communication to <code>serial.log</code>" under "Serial logging" of the "Serial connection" options.</p> <p>This serial logging file is typically used for debug purposes, but as can be read from the options, it comes with a warning:</p> <blockquote> <p>While this can negatively impact performance, a <code>serial.log</code> can be incredibly useful for debugging any issues observed in the communication between OctoPrint and your printer.</p> </blockquote> <p>You can either access the log file through the OctoPrint options/setting through the "Logging" options tab, or direct download/copy from the logging directory:</p> <blockquote> <ul> <li>on Linux: ~/.octoprint/logs</li> <li>on Windows: %APPDATA%\OctoPrint\logs</li> <li>on MacOSX: ~/Library/Application Support/OctoPrint/logs</li> </ul> </blockquote>
<p><strong>Yes</strong>, you can show more than 300 lines in the terminal; just <a href="https://github.com/foosel/OctoPrint/commit/e9623fdc36c658a5b8abe7769b1b308edfc3f424" rel="nofollow noreferrer">disable auto scrolling</a> (<a href="https://github.com/foosel/OctoPrint/issues/286#issuecomment-99215149" rel="nofollow noreferrer">reference</a>).</p> <blockquote> <p>Disabling Autoscroll now completely disables cutting off the lines (so you can have way more than 300 lines while that's disabled), filtering has been improved too and doesn't cause scrolling anymore.</p> </blockquote> <p>Note that with disabled autoscrolling, you will be able to see more lines up to the point that the buffer is full. If you need even more lines to monitor, just enable the logging the data to file <code>serial.log</code>. If you open the options page (OctoPrint Settings), just tick the box for "Log communication to <code>serial.log</code>" under "Serial logging" of the "Serial connection" options.</p> <p>This serial logging file is typically used for debug purposes, but as can be read from the options, it comes with a warning:</p> <blockquote> <p>While this can negatively impact performance, a <code>serial.log</code> can be incredibly useful for debugging any issues observed in the communication between OctoPrint and your printer.</p> </blockquote> <p>You can either access the log file through the OctoPrint options/setting through the "Logging" options tab, or direct download/copy from the logging directory:</p> <blockquote> <ul> <li>on Linux: ~/.octoprint/logs</li> <li>on Windows: %APPDATA%\OctoPrint\logs</li> <li>on MacOSX: ~/Library/Application Support/OctoPrint/logs</li> </ul> </blockquote>
1,194
<p>This is a bit of a long shot, but if anyone can figure it out, you guys can...</p> <p>In Windows XP, is there any meta-data that comes with a cut and paste action, from which I can ascertain the application that provided the clipboard contents?</p> <p>Bonus question... if there is such information, is there any way I can access it through a Java app?</p>
<p>That depends on the clipboard format. If it is plain-text, then no. Unless you want to install global hooks on the clipboard.</p> <p>Which you cannot do from Java.</p>
<p>That depends on the clipboard format. If it is plain-text, then no. Unless you want to install global hooks on the clipboard.</p> <p>Which you cannot do from Java.</p>
4,146
<p>I probably spend far too much time trying to make my visual interfaces look good, and while I'm pretty adept at finding the right match between usability and style one area I am hopeless at is making nice looking icons.</p> <p>How do you people overcome this (I'm sure common) problem? I'm thinking of things like images on buttons and perhaps most important of all, the actual application icon.</p> <p>Do you rely on third party designers, in or out of house? Or do you know of some hidden website that offers lots of icons for us to use? I've tried Google but I seem to find either expensive packages that are very specific, millions of Star Trek icons or icons that look abysmal at 16x16 which is my preferred size on in-application buttons.</p> <p>Any help/advice appreciated.</p>
<p>Good icons are hard to design. I have tried to design my own, and have used in-house graphics designers as well. However, building a good icon set takes a lot of work, even for the graphic designer.</p> <p>I believe your best solution is to buy/find a set of icons for use in your projects.</p> <p>The silk icon set is a good, free set and can be found at <a href="http://famfamfam.com/lab/icons/silk/" rel="noreferrer">FamFamFam</a>. There are over 1000 icons in this set, and it is very popular.</p> <p>If you are looking for something "different", you can purchase icon sets for a couple hundred bucks. Considering the cost of having a designer create them for you, or doing them yourself, the cost of these sets is cheap!</p> <p>Here's a few icon designers I've come across of the web:</p> <ul> <li><a href="http://iconfactory.com/stockicons" rel="noreferrer">Icon Factory</a></li> <li><a href="http://www.iconexperience.com/index.php" rel="noreferrer">Icon Experience</a></li> <li><a href="http://www.iconbuffet.com/" rel="noreferrer">Icon Buffet</a></li> </ul>
<p>You can always go on <a href="http://www.elance.com/p/landing/buyer.html" rel="nofollow noreferrer">Elance</a> and hire someone to make any icons/logos for you. I've done it several times and it's pretty cheap for what you're getting. There is so much competition on that site that someone will eventually come in at your price point. I've always believed theres no point in spinning your wheels with something you don't really specialize in.</p> <p>Oh yeah and like this site, keeping it simple is always best!</p>
2,845
<p>Is there any query which can return me the number of revisions made to the structure of a database table?</p> <p>Secondly, how can I determine the number of pages (in terms of size) present in mdf or ldf files?</p>
<p>I think you need to create a <code>trigger</code> and store all changes to the table in a separate table. You can then use this table to get the revision history.</p>
<p><code>SQL Server</code> doesn't keep track of changes so it can't tell you this.</p> <p>The only way you may be able to do this is if you had a copy of all the scripts applied to the database.</p> <p>In order to be able to capture this information in the future you should look at <code>DDL triggers (v2005+)</code> which will enable you to record changes.</p>
6,030
<p>So I know there have been several clicking Extruder threads but have not found any solutions to the one I am having.</p> <p>Background: I have a custom Prusa like 3d printer fitted with an MKS board (v1.5) and an MK3 Extruder.</p> <p>The issue: <strong>While i can extrude fine when ordering some extrusion, as soon as i start to print an object the extruder just starts "clicking".</strong></p> <p>What I have tried so far:</p> <ol> <li>Changing motors: I have tried using a new motor which I know it works and the problem persists. </li> <li>I have adjusted the stepper driver voltages, and the problem persists.</li> <li>I have changed the PSU and the problem persists.</li> <li>Changing the whole board: I have changed the whole board with a brand new one and the problem persists.</li> </ol> <p>I am out of options here. So now the only logical explanation is that the both boards (the old and new) have exactly the same problem, i.e. the extruder stepper driver is bad in some way. Yet again, it works fine when simply extruding...</p> <p>Any help would be much appreciated. Thanks.</p>
<p>It took some digging, but I was able to start scripting a wrapper in C# for the RPC commands.</p> <ul> <li><a href="https://github.com/TrueAnalyticsSolutions/MakerBotAgentAdapterCore#api" rel="nofollow noreferrer">C# Wrapper</a> (MTConnect Implementation)</li> <li>Unofficial <a href="https://github.com/TrueAnalyticsSolutions/MakerBotAgentAdapterCore/wiki/JSON-RPC" rel="nofollow noreferrer">JSON-RPC Reference</a></li> </ul> <p>I still don't understand what every method does to the machine or necessarily what the results are, so a number of the methods are marked as obsolete until I can test them.</p>
<h2>The Mystery of Makerbot-Wiki</h2> <p>According to the Wayback machine, the wiki.makerbot.com went offline on <a href="https://web.archive.org/web/20121126084944/http://wiki.makerbot.com:80/" rel="nofollow noreferrer">31st December 2012</a>:</p> <blockquote> <p>Over the past three amazing years, MakerBot owners and enthusiasts around the world have shared knowledge with us and with each other. As we welcome thousands more MakerBot owners and users into the MakerBot family, we want to make sure that everyone always has the best information regarding our company and products, and that it's easily accessible.</p> <p>Here’s one thing we're doing to help: on December 31, as we close out the year, we will also turn off the lights at wiki.makerbot.com.</p> <p>The MakerBot wiki has served us well, but lately we've seen an increase in spam and a decline in community activity. Instead of continuing to maintain two separate sites, we're going to consolidate them.</p> <p>What that means is that, as of December 31st, the MakerBot wiki will no longer be available at this address. An archived version of the wiki as it stands today will be available at <a href="http://makerbot.com/support/archive" rel="nofollow noreferrer">http://makerbot.com/support/archive</a> and more former wiki content will be available at <a href="http://makerbot.com/support" rel="nofollow noreferrer">http://makerbot.com/support</a>, which already hosts PDFs of some of the most useful Thing-O-Matic and Cupcake documentation. You may see some short periods of downtime as we finish moving this content.</p> <p>An archive of forum discussions will be available, but users seeking discussion with the incredibly knowledgable MakerBot community should head over to the <a href="https://groups.google.com/forum/#!forum/makerbot" rel="nofollow noreferrer">MakerBot Operators Google Group</a>. Requests for help and questions about MakerBot products should, as always, be sent to mailto:support@makerbot.com.</p> <p>Thanks for your contributions over the past few years to the MakerBot wiki. We hope you'll all continue to share your expertise with us and other MakerBot users for many years to come.</p> </blockquote> <p><a href="https://web.archive.org/web/20121114075819/http://wiki.makerbot.com/" rel="nofollow noreferrer">Before that</a>, the makerbot wiki did tell that the Documentations had been moved:</p> <blockquote> <p>Note<br> This wiki is intended for historical MakerBot documentation and community-supported projects. The new home for MakerBot documentation is <a href="http://www.makerbot.com/docs/" rel="nofollow noreferrer">http://www.makerbot.com/docs/</a></p> </blockquote> <hr> <h2>JSON-RPC</h2> <p>There is a late 2013/early 2014 <a href="https://github.com/makerbot/jsonrpc" rel="nofollow noreferrer">github</a> that seems to work on the JSON-RPC and which might help - and still showed <a href="https://github.com/makerbot/jsonrpc/graphs/contributors" rel="nofollow noreferrer">some activity</a> past the lockup of the wiki.makerbot.com. It is only very poorly documented. The earliest activity was in 2012 with the main bulk in 2013.</p> <p>The JSON project predates the start of work on the <a href="https://github.com/gryphius/makerbot-gen5-api/graphs/contributors" rel="nofollow noreferrer">makerbot-gen5-api</a> in 2014. This might mean that it might be documented there to some degree, But it might also be present in the generation 4 API.</p>
1,233
<p>I'm dealing with a MySQL table that defines the JobName column as UNIQUE. If somebody tries to save a new Job to the database using a JobName that is already in the database, MySQL throws a warning.</p> <p>I would like to be able to detect this warning, just like an error, in my PHP script and deal with it appropriately. Ideally I would like to know what kind of warning MySQL has thrown so that I can branch the code to handle it.</p> <p>Is this possible? If not, is it because MySQL doesn't have this ability, PHP doesn't have this ability, or both?</p>
<p>For warnings to be "flagged" to PHP natively would require changes to the mysql/mysqli driver, which is obviously beyond the scope of this question. Instead you're going to have to basically check every query you make on the database for warnings:</p> <pre><code>$warningCountResult = mysql_query("SELECT @@warning_count"); if ($warningCountResult) { $warningCount = mysql_fetch_row($warningCountResult ); if ($warningCount[0] &gt; 0) { //Have warnings $warningDetailResult = mysql_query("SHOW WARNINGS"); if ($warningDetailResult ) { while ($warning = mysql_fetch_assoc($warningDetailResult) { //Process it } } }//Else no warnings } </code></pre> <p>Obviously this is going to be hideously expensive to apply en-mass, so you might need to carefully think about when and how warnings may arise (which may lead you to refactor to eliminate them).</p> <p>For reference, <a href="http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html" rel="nofollow noreferrer">MySQL SHOW WARNINGS</a> </p> <p>Of course, you could dispense with the initial query for the <code>SELECT @@warning_count</code>, which would save you a query per execution, but I included it for pedantic completeness.</p>
<p>Updated to remove the stuff about errno functions which I now realize don't apply in your situation...</p> <p>One thing in MySQL to be wary of for <code>UPDATE</code> statements: <code>mysqli_affected_rows()</code> will return zero even if the <code>WHERE</code> clause matched rows, but the <code>SET</code> clause didn't actually change the data values. I only mention this because that behaviour caused a bug in a system I once looked at--the programmer used that return value to check for errors after an update, assuming a zero meant that some error had occurred. It just meant that the user didn't change any existing values before clicking the update button.</p> <p>So I guess using <code>mysqli_affected_rows()</code> can't be relied upon to find such warnings either, unless you have something like an <code>update_time</code> column in your table that will always be assigned a new timestamp value when updated. That sort of workaround seems kinda kludgey though.</p>
6,985
<p>I'm getting into ASP.NET (C# - I know it doesn't matter for this particular question, but full disclosure and all that), and while I love that the <code>asp:</code>-style controls save me a lot of tedious HTML-crafting, I am often frustrated with certain behaviors. I encountered one last night when working with Master Pages: my <code>&lt;asp:BulletedList ID="nav"&gt;</code>, when converted into HTML, became <code>&lt;ul id="ct100_nav"&gt;</code>.</p> <p>There are other issues--I noticed that when you auto-populate a DataGrid, it adds attributes to the resulting table that I don't necessarily want there.</p> <p>I know that there is a certain amount of "convention over configuration" that you have to accept when you rely on a framework to take over some of your tedious duties, but the "conventions" in these cases aren't so much any established conventions, but rather unnecessary extras. I know <em>why</em> the ID adds the prefix, but I should be able to tweak and turn things like this off, especially since, as a bit of a web standards evangelist, I don't duplicated HTML id's in a single page anyway.</p> <p>So the question here is for those ASP.NET devs more seasoned than I: in your experiences in developing and deploying apps, how do you leverage these controls? Do you find yourself resorting back to hard-coded HTML? Do you use a blend? I don't want to design my HTML around idiosyncratic quirks in these controls, but, if possible, I'd like to leverage them when possible. </p> <p>What's a boy to do?</p>
<p>Personally, </p> <p>I think the standard ASP.NET controls are fine for inhouse stuff - quick and dirty is good in that scenario. But, I once worked with a web developer who was also a designer and he refused to use the ASP.NET controls and only code in HTML and add runat="server" tags when needed. This was more because he wanted to know exactly how his HTML was going to be rendered, and at the time anyway, some of the ASP.NET controls wouldn't render to standards compliance.</p> <p>I sit somewhere in the middle - use HTML where appropriate and not when not. You can sort of best of both worlds with the <a href="http://weblogs.asp.net/scottgu/archive/2006/05/02/444850.aspx" rel="noreferrer">CSS control Adapters</a></p>
<p>If the ID's prefix added by ASP.NET is an issue for you to access them later using JS or something... you have the .ClientID property server side.</p> <p>If the overhead added by ASP.NET you should consider ASP.NET MVC (still preview) where you have full control over the emitted html.</p> <p>I'm moving to MVC because I don't like all that stuffs added too....</p>
4,209