instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>This issue just started recently; I am not sure if it is because of the specific part I am printing or whether something on the printer is going bad. Up until now, I have been printing all kinds of parts with no problems whatsoever.</p>
<p>I am printing a hollow sphere whose walls have fill paths that require the X and Y to change rapidly. i.e. the wall is 2 mm thick and the wall-line-count setting is set to 2.</p>
<p>When the print head is jerking back and forth to fill in this area it causes horrible vibrations and really bad Y layer shift. You can see the vibrations transferred through the flexible neck of the black LED light in the foreground.</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/T4knYy665fI?start=0"></iframe>
</div></div></p>
<p>All the Cura settings are at default- I have not tried to speed up my printing in any way by adjusting the settings.</p>
<p>The vibration seems to be coming from the Y stepper.</p>
<p>I have already tried tightening the belt; everything else seems tight.</p>
<p>It is an Ender 3 Pro with a stock mainboard and probably around 50 hours on it +/- 20 hours.</p>
<p>I have printed the same part on my other printer with no issues.</p>
<p>This is happening now on other parts that do not have particularly high jerk paths, it is shifting the Y by a full mm or more at a time.</p>
<p>Would you say the stepper motor is going bad? Or the driver? Or something else?</p>
<p>Here is the part in the video; I of course stopped the print after it started shifting:</p>
<p><a href="https://i.stack.imgur.com/DQ9JC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DQ9JC.jpg" alt="enter image description here" /></a></p>
<p>And this is how it is supposed to look:</p>
<p><a href="https://i.stack.imgur.com/Bkr03.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bkr03.jpg" alt="enter image description here" /></a></p>
<p>EDIT:</p>
<p>Here is the path that causes the problem:</p>
<p><a href="https://i.stack.imgur.com/k4rPv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k4rPv.png" alt="enter image description here" /></a></p>
|
<p>PLA is a forgiving filament, you can even print such filament without a heated bed. Although there are differences in quality between brands, PLA shouldn't need a raft to be printed. Hatchbox filament is not considered as a low quality type of filament; it is economical and has been around since 2013. A raft is a structured platform that is specifically used for high temperature and or high shrinkage types of filament, PLA is not such a filament and shouldn't need a raft. This implies that something is wrong with getting the filament sticking to the plate. Good adhesion requires a levelled bed, a correct initial nozzle to build plate distance (e.g. paper thickness) and possibly an adhesive like a glue stick, special adhesion spray, a textured bed or blue tape, etc.</p>
|
<p>Please try one (or more) of the following:</p>
<ol>
<li><p>Change the temperature of your heated bed (50 - 60 °C)</p>
</li>
<li><p>Check your nozzle height (0.15 - 0.25 mm is what I use)</p>
</li>
<li><p>Make sure your bed is level (Maybe use a leaving stick (or whatever those bubble things are called))</p>
</li>
<li><p>Use adhesion. Start with painter's tape (least damaging, easy to remove), then use a glue stick or even hair spray if necessary.</p>
</li>
<li><p>Be sure the bed is clean (I recommend glass cleaner 1-3 squirts and then a light scrub of a paper towel)</p>
</li>
</ol>
| 1,934
|
<p>If I have an HTML helper like so:</p>
<pre><code>Name:<br />
<%=Html.TextBox("txtName",20) %><br />
</code></pre>
<p>How do I apply a CSS class to it? Do I have to wrap it in a span? Or do I need to somehow utilize the HtmlAttributes property of the helper?</p>
|
<p>You can pass it into the TextBox call as a parameter.</p>
<pre><code>Name:<br/>
<%= Html.TextBox("txtName", "20", new { @class = "hello" }) %>
</code></pre>
<p>This line will create a text box with the value 20 and assign the class attribute with the value hello. I put the @ character in front of the class, because class is a reserved keyword. If you want to add other attributes, just separate the key/value pairs with commas.</p>
|
<p></p>
<p>Is it that much more work? </p>
| 6,209
|
<p>I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but that probably is not the best way to do it.</p>
<p>What is the best way to do this, within the following code?</p>
<pre><code>f = open(file)
for line in f:
if line.contains('foo'):
newline = line.replace('foo', 'bar')
# how to write this newline back to the file
</code></pre>
|
<p>I guess something like this should do it. It basically writes the content to a new file and replaces the old file with the new file:</p>
<pre><code>from tempfile import mkstemp
from shutil import move, copymode
from os import fdopen, remove
def replace(file_path, pattern, subst):
#Create temp file
fh, abs_path = mkstemp()
with fdopen(fh,'w') as new_file:
with open(file_path) as old_file:
for line in old_file:
new_file.write(line.replace(pattern, subst))
#Copy the file permissions from the old file to the new file
copymode(file_path, abs_path)
#Remove original file
remove(file_path)
#Move new file
move(abs_path, file_path)
</code></pre>
|
<p>if you remove the indent at the like below, it will search and replace in multiple line.
See below for example.</p>
<pre><code>def replace(file, pattern, subst):
#Create temp file
fh, abs_path = mkstemp()
print fh, abs_path
new_file = open(abs_path,'w')
old_file = open(file)
for line in old_file:
new_file.write(line.replace(pattern, subst))
#close temp file
new_file.close()
close(fh)
old_file.close()
#Remove original file
remove(file)
#Move new file
move(abs_path, file)
</code></pre>
| 6,013
|
<p>I am trying to get my first layer calibrating done but no matter what I do, I can not get the lines sticking to the bed.</p>
<p>My first question is the distance of the P.I.N.D.A. What I did was what Prusa recommends on <a href="https://d17kynu4zpq5hy.cloudfront.net/igi/prusa3d/KtMljQEIWfs5QXJV.medium" rel="nofollow noreferrer">this pic</a>: </p>
<p><a href="https://i.stack.imgur.com/dIH7j.jpg" rel="nofollow noreferrer" title="Annotated photo of leveling probe and printbed"><img src="https://i.stack.imgur.com/dIH7j.jpg" alt="Annotated photo of leveling probe and printbed" title="Annotated photo of leveling probe and printbed"></a></p>
<p>I am using Prusa Slic3r with PLA and all default values. I am doing the first layer calibration of the setup menu and got the lines which you can remove and the last square which the nozzle is picking up so you don't have it on the print bed. The very first line on the left corner is not really squeezed. I am looking for some greenhorn help here.</p>
|
<p>Calibrating the first layer height involves two steps:</p>
<p>The first step, as illustrated in that picture, is to adjust the PINDA probe to be roughly the right distance above the nozzle. The PINDA only has a sensing range of about a millimeter, so if it's too high, it can't detect the printbed; if it's too low, it will interfere with the printed object.</p>
<p>The second step, which you're having trouble with, is to calibrate the exact distance between the PINDA and the nozzle tip. The printer prints out a test pattern; while it's printing, you turn the the dial on the printer control panel to adjust the "live-Z" value. Typical values for a properly-assembled printer are between -0.5 and -1.0 (more-negative values are closer to the print bed). If the live-Z value is outside that range, you need to adjust the position of the PINDA probe.</p>
<p>The official Prusa procedure is good for getting a rough calibration. If you want more precision, the "<a href="https://shop.prusa3d.com/forum/assembly-and-first-prints-troubleshooting-f62/life-adjust-z-my-way-t2981.html" rel="nofollow noreferrer">Life adjust Z - my way</a>" procedure on the Prusa forums is good. Basically, you print out a large one-layer square, adjust the live-Z value halfway through, and see which half has a better first layer. Repeat until satisfied.</p>
|
<p>Your problem is that you need to define the sensor to nozzle level offset and store it in the printers memory.</p>
<p>When you have homed the printer, you should end up with the nozzle at a certain level where the sensor trigger point is now defined in relation to the bed. Next step is to relate the trigger point to the nozzle level, instruct the nozzle to go down to the build plate (placing a sheet of paper on the plate) by using the buttons of the menu to move the Z axis. When you feel friction when you pull the piece of paper, you reached the correct offset. Now store the value you read from the Z axis display as Z offset in the menu. Alternatively use G-code <code>M851 Z-x.xx</code>, where x.xx is the value you read from the display. <code>M500</code> will store it in memory.</p>
| 1,129
|
<p>Is there a keyboard shortcut in Access 2003 that will run a query while in design or sql mode?</p>
|
<p>It's not built-in. I would try a macro - AutoKeys? You should be able to make almost any keyboard short you want that way.</p>
|
<p>Does Alt Q Alt R (ie menu item selection) not suit?</p>
| 8,083
|
<p>This code is from <em>Prototype.js</em>. I've looked at probably 20 different tutorials, and I can't figure out why this is not working. The response I get is null.</p>
<pre><code>new Ajax.Request(/path/to / xml / file.xml, {
method: "get",
contentType: "application/xml",
onSuccess: function(transport) {
alert(transport.responseXML);
}
});
</code></pre>
<p>If I change the <code>responseXML</code> to <code>responseText</code>, then it alerts to me the XML file as a string. This is not a PHP page serving up XML, but an actual XML file, so I know it is not the response headers.</p>
|
<p>If transport.responseXML is null but you have a value for transport.responseText then I believe it's because it's not a valid XML file.</p>
<p><strong>Edit:</strong> I just noticed that in our code here whenever we request an XML file we set the content type to 'text/xml'. I have no idea if that makes a difference or not.</p>
|
<p>Just want to share my afternoon working on the issue with a NULL result for <strong>responseXML</strong> responses. My results were exactly as described in the question: responseText was filled with the XML file, responseXML was NULL. As i was totally sure my file is in valid XML format, the error must be somewhere different.</p>
<p>As mentioned in the <strong>Prototype v1.7</strong> documentation, i set the content type to <strong>"application/xml"</strong>. The response sent was constantly "text/html", no matter what. </p>
<p>To make it short, the problem i ran into was, that my XML file had the ending <strong>".gpx"</strong> as it's a de facto standard for GPS coordinates. The mime-types collection of my local XAMPP Apache installation only foresees the endings "xml" and "xsl". After adding "gpx" and restarting the server the program ran smoothly as it's supposed to be.</p>
<p>In my case, there are three solutions:</p>
<p>1) edit the "mime.types" file of Apache. Using an XAMPP installation, you might find it under "C:\xampp\apache\conf\mime.types". Search for the "application/xml" record and change as follows:</p>
<pre><code>application/xml xml xsl gpx
</code></pre>
<p>Don't forget to restart the server!</p>
<p>2) add the mime type in a <strong>.htaccess</strong> of the appropriate folder. Open or create a .htaccess file and add following line:</p>
<pre><code>AddType application/xml xml xsl gpx
</code></pre>
<p>3) during upload process, change file type to "xml" instead of whatever you have</p>
<p>Hope i safe some time to one of you guys.</p>
| 7,824
|
<p>How do you find a memory leak in Java (using, for example, JHat)? I have tried to load the heap dump up in JHat to take a basic look. However, I do not understand how I am supposed to be able to find the root reference (<a href="https://stackoverflow.com/questions/104/anatomy-of-a-memory-leak">ref</a>) or whatever it is called. Basically, I can tell that there are several hundred megabytes of hash table entries ([java.util.HashMap$Entry or something like that), but maps are used all over the place... Is there some way to search for large maps, or perhaps find general roots of large object trees?</p>
<p>[Edit]
Ok, I've read the answers so far but let's just say I am a cheap bastard (meaning I am more interested in learning how to use JHat than to pay for JProfiler). Also, JHat is always available since it is part of the JDK. Unless of course there is no way with JHat but brute force, but I can't believe that can be the case.</p>
<p>Also, I do not think I will be able to actually modify (adding logging of <em>all</em> map sizes) and run it for long enough for me to notice the leak.</p>
|
<p>I use following approach to finding memory leaks in Java. I've used jProfiler with great success, but I believe that any specialized tool with graphing capabilities (diffs are easier to analyze in graphical form) will work.</p>
<ol>
<li>Start the application and wait until it get to "stable" state, when all the initialization is complete and the application is idle.</li>
<li>Run the operation suspected of producing a memory leak several times to allow any cache, DB-related initialization to take place.</li>
<li>Run GC and take memory snapshot.</li>
<li>Run the operation again. Depending on the complexity of operation and sizes of data that is processed operation may need to be run several to many times.</li>
<li>Run GC and take memory snapshot.</li>
<li>Run a diff for 2 snapshots and analyze it.</li>
</ol>
<p>Basically analysis should start from greatest positive diff by, say, object types and find what causes those extra objects to stick in memory.</p>
<p>For web applications that process requests in several threads analysis gets more complicated, but nevertheless general approach still applies.</p>
<p>I did quite a number of projects specifically aimed at reducing memory footprint of the applications and this general approach with some application specific tweaks and trick always worked well.</p>
|
<p>You really need to use a memory profiler that tracks allocations. Take a look at <a href="http://www.ej-technologies.com/products/jprofiler/overview.html" rel="nofollow noreferrer">JProfiler</a> - their "heap walker" feature is great, and they have integration with all of the major Java IDEs. It's not free, but it isn't that expensive either ($499 for a single license) - you will burn $500 worth of time pretty quickly struggling to find a leak with less sophisticated tools.</p>
| 6,132
|
<p>This has inspired some discussion and I may be just splitting hairs, but I've always been confused by this strategy. The specific example I'm referring to is here: <a href="https://3dprinting.stackexchange.com/a/29/60">https://3dprinting.stackexchange.com/a/29/60</a></p>
<p>In many cases on SE, I see people post "Answers" that basically say "Don't do what you're doing. Instead you can get to your goal by doing this." While it is often helpful, this form of answer is the bane of my existence as a user of SE sites.</p>
<p>There are often cases when I am googling a difficult problem because I cannot do "alternative a" as suggested by the answerer. Then, I get to an SE question that asked about exactly the situation I am having. An answer of "Don't do that, do this instead" is upvoted, accepted, and the only answer. Thus, I am unable to solve my problem using SE. In other words, the Answer didn't apply to the question, and so SE led me down the wrong path.</p>
<p>Am I doing something wrong here? Is this an expected/accepted pattern? Or is this something I should go the route of downvoting? Or like the poster of the above answer suggests, flagging?</p>
|
<p>Sometimes, "don't try to do what you're trying to do" is the only valid answer, see e.g. <a href="https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem">XY problem</a>.</p>
|
<p>If it tries to answer the question, it's still an answer... </p>
<p>But it doesn't mean it's always a good one.</p>
<p>Generally, in these cases, you would be able to flag such an answer as Very Low Quality, especially if they would fit better in the comment space. The reason why you can't here however, is because the answer has a positive score.</p>
<p>So what can we do?</p>
<p>You can't really stop people from writing answers. If you want them to improve, leave a comment, and ask them to elaborate. Otherwise, downvote and move on.</p>
| 8
|
<p>Attempting to insert an escape character into a table results in a warning. </p>
<p>For example:</p>
<pre><code>create table EscapeTest (text varchar(50));
insert into EscapeTest (text) values ('This is the first part \n And this is the second');
</code></pre>
<p>Produces the warning:</p>
<pre><code>WARNING: nonstandard use of escape in a string literal
</code></pre>
<p>(<em>Using PSQL 8.2</em>)</p>
<p>Anyone know how to get around this?</p>
|
<p>Partially. The text is inserted, but the warning is still generated.</p>
<p>I found a discussion that indicated the text needed to be preceded with 'E', as such:</p>
<pre><code>insert into EscapeTest (text) values (E'This is the first part \n And this is the second');
</code></pre>
<p>This suppressed the warning, but the text was still not being returned correctly. When I added the additional slash as Michael suggested, it worked.</p>
<p>As such:</p>
<pre><code>insert into EscapeTest (text) values (E'This is the first part \\n And this is the second');
</code></pre>
|
<p>Really stupid question: Are you sure the string is being truncated, and not just broken at the linebreak you specify (and possibly not showing in your interface)? Ie, do you expect the field to show as</p>
<blockquote>
<p>This will be inserted \n This will not
be</p>
</blockquote>
<p>or</p>
<blockquote>
<p>This will be inserted</p>
<p>This will not be</p>
</blockquote>
<p>Also, what interface are you using? Is it possible that something along the way is eating your backslashes?</p>
| 2,336
|
<p>What is the best way to generate a Unique ID from two (or more) short ints in C++? I am trying to uniquely identify vertices in a graph. The vertices contain two to four short ints as data, and ideally the ID would be some kind of a hash of them. Prefer portability and uniqueness over speed or ease. </p>
<p>There are a lot of great answers here, I will be trying them all tonight to see what fits my problem the best. A few more words on what I'm doing. </p>
<p>The graph is a collection of samples from an audio file. I use the graph as a Markov Chain to generate a new audio file from the old file. Since each vertex stores a few samples and points to another sample, and the samples are all short ints, it seemed natural to generate an ID from the data. Combining them into a long long sounds good, but maybe something as simple as just a 0 1 2 3 <code>generateID</code> is all I need. not sure how much space is necessary to guarantee uniqueness, if each vertex stores 2 16 bit samples, there are 2^32 possible combinations correct? and so if each vertex stores 4 samples, there are 2^64 possible combinations? </p>
<p>Library and platform specific solutions not really relevant to this question. I don't want anyone else who might compile my program to have to download additional libraries or change the code to suit their OS. </p>
|
<p>A simple solution is to use a 64 bit integer where the lower 16 bits is the first vertex coordinate, next 16 bits is the second, and so on. This will be unique for all your vertices, though not very compact.</p>
<p>So here's some half-assed code to do this. Hopefully I got the casts right.</p>
<pre><code>uint64_t generateId( uint16_t v1, uint16_t v2, uint16_t v3, uint16_t v4)
{
uint64_t id;
id = v1 | (((uint64_t)v2) << 16) | (((uint64_t)v3) << 32) | (((uint64_t)v4) << 48);
return id;
}
</code></pre>
<p>Optionally this could be done with a union (great idea from Leon Timmermans, see comment). Very clean this way:</p>
<pre class="lang-cpp prettyprint-override"><code>struct vertex
{
uint16_t v1;
uint16_t v2;
uint16_t v3;
uint16_t v4;
};
union vertexWithId
{
vertex v;
uint64_t id;
};
int main()
{
vertexWithId vWithId;
// Setup your vertices
vWithId.v.v1 = 2;
vWithId.v.v2 = 5;
// Your id is automatically setup for you!
std::cout << "Id is " << vWithId.id << std::endl;
return 0;
}
</code></pre>
|
<p>off the cuff I'd say use prime numbers,</p>
<pre><code>id = 3 * value1 + 5 * value2 + .... + somePrime * valueN
</code></pre>
<p>Make sure you don't overflow your id space (long? long long?). Since you've got a fixed number of values just crap some random primes. Don't bother generating them, there are enough available in lists to get you going for awhile.</p>
<p>I'm a little sketchy on the proof though, maybe someone more mathmatical can hook me up. Probably has something to do with unique prime factorization of a number.</p>
| 9,127
|
<p>On a budget, I'm water-cooling a 3D printer. I'm using a 5 V aquarium pump (\$3). Originally I tried to only use about as much water in a can of chickpeas but then found out i needed a lot more. I have a deliberate need to water cool stepper motors in the first printer, so that I can print with a high temperature filament like PEI (the operating temp of a stepper is maxed at about 53 degrees celsius; PEI requires an enclosure temperature of 80 °C), but on another printer I'm having some other issues with the motors that I think could be solved by better heat dissipation.</p>
<p>What I am getting to is a device like <a href="https://rads.stackoverflow.com/amzn/click/com/B07DLQJKKC" rel="nofollow noreferrer" rel="nofollow noreferrer">this</a>: </p>
<p><a href="https://i.stack.imgur.com/DYx39.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DYx39.jpg" alt="e"></a></p>
<p>It is the perfect size for a stepper motor. My plan is to zip-tie one of these to each stepper motor and water cool it in a single path across my printer, including the hot end.</p>
<p>Can anyone think of a reason why this wouldn't work? i just haven't heard of anyone doing anything like this, but it makes sense to me as a chemistry minor. The specific heat of water is way higher than almost anything else. And it is way less noisy than fans. And it works inside an enclosure, while fans might not</p>
<p>Should I ziptie the aluminum block to the back part of the stepper where the metal is, or to one of the darker black sides?</p>
<p>Would I be able to 3D print a cooling block like this instead of paying for it? See also <a href="https://3dprinting.stackexchange.com/questions/11043/what-is-the-thermal-conductivity-of-various-3d-printing-filaments">this relevant question on thermal conductivity of various 3D printing filaments</a>. It should probably be metal to transfer heat better? </p>
|
<p>Cooling any single face of the motor is fine. The motor case conducts heat <em>very</em> well. Many 3d printers effectively cool the motors merely by having the output drive face of the motor bolted to a metal bracket which is bolted to the aluminum extrusion frame. That's it. That contact alone cools the motor, which is shown by how the motors overheat when people install vibration dampers, which puts rubber between the motor and the extrusion.</p>
<p>The only thing I would worry about is the surface area inside this particular style of block, and ensuring that you use an all-aluminum radiator since the block is aluminum.</p>
<p>There is another type of cheap 40x40 aluminum block with the nipples on the face instead of on the edge. That style has fins and a lot of surface area inside. This style with the nipples on the edge has a big S channel inside and not much surface area. It may still be more than enough. I'm just saying it's a significant difference and it might make a difference. If you find you're not cooling enough, all you may need to do is switch to that other style of block, not try to install 3 blocks per motor or any other exotic nonsense.</p>
<p>But no way do you have to worry about coooling more than one face of the motor, nor does it matter rwhich face it is, especially not with active water cooling like this, as long as the block is actually making good thermal contact with the motor (thermal tape, or thermal epoxy, or thermal pad & zip ties)</p>
|
<p>Your solution will not cool all sides effectively. Firstly don't use zip ties; get thermal tape.</p>
<p><a href="https://i.stack.imgur.com/uC6tD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uC6tD.jpg" alt="Thermal Tape"></a>
(<a href="https://rads.stackoverflow.com/amzn/click/com/B00QSHPH8E" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/Thermal-Interface-Products-Heat-Sink/dp/B00QSHPH8E/</a></p>
<p>Secondly, the heat will need to travel around the outside of the motor to get from the side that doesn't have the water block. Its expensive but you could use <a href="https://www.digikey.com/en/product-highlight/p/panasonic/pyrolytic-graphite-sheets" rel="nofollow noreferrer">Pyrolytic Graphite Sheets</a> to wrap around the outside of the motor, to get the heat to the water block faster.</p>
| 1,451
|
<p>I need to know about Epoll On linux System.</p>
<p>Could you recommend manual or guides about epoll library?</p>
<p>need more detailed guides. it's better to have some examples.</p>
<p>help me. and Thank you for reading.</p>
|
<p>Here's an introduction to Epoll, a pretty basic tutorial: <a href="https://kovyrin.net/2006/04/13/epoll-asynchronous-network-programming/" rel="nofollow noreferrer">http://blog.kovyrin.net/2006/04/13/epoll-asynchronous-network-programming/</a></p>
<p>A more complete example can be found here: <a href="https://web.archive.org/web/20120504033548/https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/" rel="nofollow noreferrer">https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/</a></p>
<p>Also, <a href="https://www.man7.org/linux/man-pages/man7/epoll.7.html" rel="nofollow noreferrer">the man pages</a></p>
|
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/epoll.h>
#define PORT 1500
#define MAX_CON (1200)
static struct epoll_event *events;
int main(int argc, char *argv[])
{
fd_set master;
fd_set read_fds;
struct sockaddr_in serveraddr;
struct sockaddr_in clientaddr;
int fdmax;
int listener;
int newfd;
char buf[1024];
int nbytes;
int addrlen;
int yes;
int epfd = -1;
int res = -1;
struct epoll_event ev;
int i=0;
int index = 0;
int client_fd = -1;
int SnumOfConnection = 0;
time_t Sstart, Send;
if((listener = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
perror("Server-socket() error lol!");
exit(1);
}
if(setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
{
perror("Server-setsockopt() error lol!");
exit(1);
}
serveraddr.sin_family = AF_INET;
serveraddr.sin_addr.s_addr = INADDR_ANY;
serveraddr.sin_port = htons(PORT);
memset(&(serveraddr.sin_zero), '\0', 8);
if(bind(listener, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) == -1)
{
perror("Server-bind() error lol!");
exit(1);
}
if(listen(listener, 10) == -1)
{
perror("Server-listen() error lol!");
exit(1);
}
fdmax = listener; /* so far, it's this one*/
events = calloc(MAX_CON, sizeof(struct epoll_event));
if ((epfd = epoll_create(MAX_CON)) == -1) {
perror("epoll_create");
exit(1);
}
ev.events = EPOLLIN;
ev.data.fd = fdmax;
if (epoll_ctl(epfd, EPOLL_CTL_ADD, fdmax, &ev) < 0) {
perror("epoll_ctl");
exit(1);
}
//time(&start);
for(;;)
{
res = epoll_wait(epfd, events, MAX_CON, -1);
client_fd = events[index].data.fd;
for (index = 0; index < MAX_CON; index++) {
if(client_fd == listener)
{
addrlen = sizeof(clientaddr);
if((newfd = accept(listener, (struct sockaddr *)&clientaddr, &addrlen)) == -1)
{
perror("Server-accept() error lol!");
}
else
{
// printf("Server-accept() is OK...\n");
ev.events = EPOLLIN;
ev.data.fd = newfd;
if (epoll_ctl(epfd, EPOLL_CTL_ADD, newfd, &ev) < 0) {
perror("epoll_ctl");
exit(1);
}
}
break;
}
else
{
if (events[index].events & EPOLLHUP)
{
if (epoll_ctl(epfd, EPOLL_CTL_DEL, client_fd, &ev) < 0) {
perror("epoll_ctl");
}
close(client_fd);
break;
}
if (events[index].events & EPOLLIN) {
if((nbytes = recv(client_fd, buf, sizeof(buf), 0)) <= 0)
{
if(nbytes == 0) {
// printf("socket %d hung up\n", client_fd);
}
else {
printf("recv() error lol! %d", client_fd);
perror("");
}
if (epoll_ctl(epfd, EPOLL_CTL_DEL, client_fd, &ev) < 0) {
perror("epoll_ctl");
}
close(client_fd);
}
else
{
if(send(client_fd, buf, nbytes, 0) == -1)
perror("send() error lol!");
}
break;
}
}
}
}
return 0;
}
</code></pre>
<p>I wrote this program for testing and I was able to connect more than 80k connections and I find average system load only to 0.27%.</p>
| 4,689
|
<p>I know that it's said the PLA becomes brittle when kept in a humid environment, but my case is slightly weirder:</p>
<p>I have rolls of 1.75 mm PLA that I bought years ago and they are fine. But if I leave my spool fed inside the PTFE (Teflon) tube of my 3D printer, that part that is inside the PTFE tube, and only that part, gets brittle. The filament spool is always (even when stored) in open air.</p>
<p>Is it still the humidity that somehow is better kept inside the tube, or is there a weird reaction of PLA with PTFE?</p>
|
<p>I have this exact problem as well. I am feeding filament from the dry box through the tube into the top of the hot end. After approximately 2 days I would notice that the filament is broken somewhere close to the hot end. I don't believe that it's just humidity.</p>
<p>I suspect that the filament being brittle and being made to conform to the PTFE tube's shape, having been recently on a spool, is causing the breaks.</p>
<p>As a result, I'm going to write a small script that will heat the hot end and eject 200 mm of filament every so often.</p>
<p>EDIT: Whilst the script works, the filament would just break somewhere else lower down in the tube. Therefore the amount of filament that would need to be extruded periodically would be just wasteful. A better solution would be to unload the filament, either manually or automatically (somehow).</p>
|
<p>I'm having the exact same problem - it is enough to leave the filament inside the PTFE tube for an overnight and the next day the filament inside the tube is so brittle that I'm not even able to eject the filament without disconnecting the tube and getting out all small pieces of filament manually... but from my experience, it affects only cheap PLA filaments (like Creality ST-PLA) - I never had such issue with other types of filaments (ASA, PETG) or higher-quality brands of PLA (e.g Fillamentum, Filament PM...).</p>
<p>BTW - there is a video on YouTube demonstrating the same issue: <div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/SvpSxHLotMI?start=0"></iframe>
</div></div></p>
| 1,990
|
<p>Is there any way to save an object using Hibernate if there is already an object using that identifier loaded into the session?</p>
<ul>
<li>Doing <code>session.contains(obj)</code> seems to only return true if the session contains that exact object, not another object with the same ID.</li>
<li>Using <code>merge(obj)</code> throws an exception if the object is new</li>
</ul>
|
<p>Have you tried calling .SaveOrUpdateCopy()?
It should work in all instances, if there is an entity by the same id in the session or if there is no entity at all. This is basically the catch-all method, as it converts a transient object into a persistent one (Save), updates the object if it is existing (Update) or even handles if the entity is a copy of an already existing object (Copy).</p>
<p>Failing that, you may have to identify and .Evict() the existing object before Attaching (.Update()) your "new" object.
This should be easy enough to do:</p>
<pre><code>IPersistable entity = Whatever(); // This is the object we're trying to update
// (IPersistable has an id field)
session.Evict(session.Get(entity.GetType(), entity.Id));
session.SaveOrUpdate(entity);
</code></pre>
<p>Although the above code could probably do with some null checking for the .Get() call.</p>
|
<p>How about:</p>
<pre><code>session.replicate(entity, ReplicationMode.OVERWRITE);
</code></pre>
<p>?</p>
| 4,599
|
<p>I'm looking for some "Best Practices" for automating the deployment of Stored Procedures/Views/Functions/Table changes from source control. I'm using StarTeam & ANT so the labeling is taken care of; what I am looking for is how some of you have approached automating the pull of these objects from source - not necessarily StarTeam.</p>
<p>I'd like to end up with one script that can then be executed, checked in, and labeled.</p>
<p>I'm NOT asking for anyone to write that - just some ideas or approaches that have (or haven't) worked in the past.</p>
<p>I'm trying to clean up a mess and want to make sure I get this as close to "right" as I can.</p>
<p>We are storing the tables/views/functions etc. in individual files in StarTeam and our DB is SQL 2K5.</p>
|
<p>We use SQL Compare from redgate (<a href="http://www.red-gate.com/" rel="nofollow noreferrer">http://www.red-gate.com/</a>).</p>
<p>We have a production database, a development database and each developer has their own database.</p>
<p>The development database is synchronised with the changes a developer has made to their database when they check in their changes. </p>
<p>The developer also checks in a synchronisation script and a comparison report generated by SQL Compare.</p>
<p>When we deploy our application we simply synchronise the development database with the production database using SQL Compare.</p>
<p>This works for us because our application is for in-house use only. If this isn't your scenario then I would look at SQL Packager (also from redgate).</p>
|
<p>I prefer to separate views, procedures, and triggers (objects that can be re-created at will) from tables. For views, procedures, and triggers, just write a job that will check them out and re-create the latest.</p>
<p>For tables, I prefer to have a database version table with one row. Use that table to determine what new updates have not been applied. Then each update is applied and the version number is updated. If an update fails, you have only that update to check and you can re-run know that the earlier updates will not happen again.</p>
| 7,586
|
<p>I'm building an excel template (*.xlt) for a user here, and one of the things I want to do is have it insert the current date when a new document is created (ie, when they double-click the file in windows explorer). How do I do this?</p>
<p><strong>Update:</strong> I should have added that I would prefer not to use any vba (macro). If that's the only option, then so be it, but I'd really like to avoid forcing my user to remember to click some 'allow macro content' button.</p>
|
<p>You could use the worksheet function =TODAY(), but obviously this would be updated to the current date whenever the workbook is recalculated.</p>
<p>The only other method I can think of is, as 1729 said, to code the Workbook_Open event:</p>
<pre><code>Private Sub Workbook_Open()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Value = Date
End Sub
</code></pre>
<p>You can reduce the problem of needing the user to accept macros each time by digitaly signing the template (in VBA IDE Tools | Digital Signature...) and select a digital certificate, however, you will need to get a certificate from a commercial certification authority (see <a href="http://msdn.microsoft.com/en-us/library/ms995347.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms995347.aspx</a>). The user will need to select to always trust this certificate the first time they run the template, but thereafter, they will not be prompted again.</p>
|
<p>To avoid VBA, and if you think your users might follow instructions, you could ask them to copy the date and then paste special->values to set the date so that it won't change in future.</p>
| 6,187
|
<p>I've recently taken up learning some C# and wrote a Yahtzee clone. My next step (now that the game logic is in place and functioning correctly) is to integrate some method of keeping stats across all the games played.</p>
<p>My question is this, how should I go about storing this information? My first thought would be to use a database and I have a feeling that's the answer I'll get... if that's the case, can you point me to a good resource for creating and accessing a database from a C# application?</p>
<hr>
<p>Storing in an XML file actually makes more sense to me, but I thought if I suggested that I'd get torn apart ;). I'm used to building web applications and for those, text files are generally frowned upon.</p>
<p>So, going with an XML file, what classes should I be looking at that would allow for easy manipulation?</p>
|
<p>Here is one idea: use Xml Serialization. Design your GameStats data structure and optionally use Xml attributes to influence the schema as you like. I like to use this method for small data sets because its quick and easy and all I need to do is design and manipulate the data structure.</p>
<pre><code>
using (FileStream fs = new FileStream(....))
{
// Read in stats
XmlSerializer xs = new XmlSerializer(typeof(GameStats));
GameStats stats = (GameStats)xs.Deserialize(fs);
// Manipulate stats here ...
// Write out game stats
XmlSerializer xs = new XmlSerializer(typeof(GameStats));
xs.Serialize(fs, stats);
fs.Close();
}
</code></pre>
|
<p>You can either use the <code>System::Xml</code> namespace or the <code>System::Data</code> namespace. The first gives you raw XML, the latter gives you a handy wrapper to the XML.</p>
| 4,041
|
<p>What would be the best way to draw a simple animation just before showing a modal <a href="https://docs.oracle.com/javase/9/docs/api/javax/swing/JDialog.html" rel="nofollow noreferrer">JDialog</a>? (i.e. expanding borders from the mouse click point to the dialog location). I thought it would be possible to draw on the glasspane of the parent frame on the <code>setVisible</code> method of the dialog.</p>
<p>However, since the JDialog is modal to the parent, I couldn't find a way to pump drawing events into <a href="https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html" rel="nofollow noreferrer">EDT</a> before the JDialog becomes visible, since the current event on the EDT has not been completed yet.</p>
|
<p>Are you trying to show the JDialog indepentently of the annimation? In order to get the order set properly, you may need to bundle those actions in a runnable that is passed to the EDT at once.</p>
<p>eg:</p>
<pre><code>SwingUtilities.invokeLater(new Runnable(){
public void run(){
doAnnimation();
showDialog();
}
}
</code></pre>
<p>It may be best to subclass JDialog so that you can just add the doAnnimation() logic to the setVisible(..) or show() method before calling the superclass implementation. </p>
<p>Finally, I imagine you'll need to set the dimensions of the dalog manually -- I don't remember if Java will know the actual size of the dialog before it is shown, so you may get some useless information for your annimation if you query the size before showing it.</p>
|
<p>You may be able to take @rcreswick's answer and expand on it a little to make it work.</p>
<pre><code>void myShowDialog() {
new Thread(new Runnable() {public void run() {
SwingUtilities.invokeAndWait(new Runnable() { public void run() {
doAnimation();
} } );
// Delay to wait for the animation to finish (if needed)
Thread.sleep(500);
SwingUtilities.invokeAndWait(new Runnable() { public void run() {
showDialog();
} } );
} } ).start();
}
</code></pre>
<p>It's pretty ugly and would have to be invoked in place of the basic showDialog() call, but it should work. </p>
| 6,017
|
<p>I know how to use tags in subversion. I create a tag every time I get to a release milestone.</p>
<p>What I don't quite understand is how they work. </p>
<p>Is a tag just a copy, made from what ever revision I specify? Or is a tag more like a reference, where internally subversion just says <code>GO TO /trunk/project/ Revision 5</code> or whatever.</p>
<p>The command to create a tag (<code>svn copy</code>) seems to imply that it's a copy, but I've seen other people write that subversion doesn't really copy anything.</p>
<p>Say I dump just the HEAD revision of a repository. I don't care about any history except the tags. Are those tags dumped along with the rest of the Head revision?</p>
<p>Finally, is all this just programming magic that I don't really want to know.</p>
|
<p>Yes, a svn copy (whether you are thinking of it as a tag, a branch, or copying a file in trunk) is all the same. SVN will internally create a pointer to the source location at that revision. If you then make changes to the copy (which you are likely to do if it is a branch or a copied file in trunk, but shouldn't do for tags), SVN will only store what was changed, rather than creating a whole new copy.</p>
|
<p>an example:</p>
<pre><code>$ svn copy https://jorgesysgr.com/svn/AndNews/branches \
https://jorgesysgr.com/svn/AndNews/tags/release-1.1 \
-m "release 1.1 Android News."
</code></pre>
<p>More info:: <a href="http://svnbook.red-bean.com/nightly/en/svn.branchmerge.tags.html" rel="nofollow">Creating a Simple Tag</a></p>
| 6,116
|
<p>At the moment the outside surface temperature is around 30 °C. Can I put my PETG spools outside with a fan in order to dry them cheaply?</p>
|
<p>The answer to this specific instance appeared in the comments:</p>
<blockquote>
<p>Also, <a href="https://3dprinting.stackexchange.com/a/6092/">a thorough cleaning of the nozzle/hotend</a> might also be a good idea to get rid of all the stuck ABS residue inside. – 0scar Mar 26 at 8:44</p>
<p>The problem solved !, my ABS is stuck in nozzle !!! – 3ORZ Apr 25 at 6:52</p>
</blockquote>
|
<p>That looks pretty bad for a number of reasons. If you've got an all-metal hotend, you can be pretty sure that your PLA issues are probably at least partially cooling-related. I'd recommend you try and find a better fan duct design for your hotend, if possible, and possibly upgrade to a better fan.</p>
<p>You can temporarily skirt around cooling issues with PLA in all-metal hotends by printing <em>more material</em>, which typically means one or all of the following:</p>
<ol>
<li>Faster print speeds (if your printer can move quickly enough and has good acceleration)</li>
<li>Thicker lines! Surprisingly useful. If you don't want to sacrifice print detail, then make the infill lines ridiculously thick, the inner wall lines fairly thick, and the single outer perimeter "normal" thickness.</li>
<li>Thicker layer height. Normally I printed at 0.2mm like everyone else, but with PLA in my all-metal hotend, I had to up it to 0.3 with fatter lines as well. </li>
</ol>
<p>If you can consistently keep the filament going through the hotend instead of lingering inside of it, you can basically "push" the melt zone back down into the heater block where it belongs, instead of it creeping upwards and resulting in a jam. </p>
<p>As a side note, the rippled surface of your brim there looks very similar to what used to happen to mine; the ripples are usually indicative of some form of over-extrusion on the first layer. I'd maybe look into checking your Z offset to make sure your print nozzle is far enough away from the bed, and maybe also check your flow rate is accurate for that particular filament. Check the filament diameter in a few places with a micrometer if you have access to one, and compare to your ABS prints to see if maybe you should adjust the flow rate down a few percent in your slicer.</p>
| 1,260
|
<p>I'd like to do the following and can't find an elegant way:</p>
<ol>
<li>Read an XML template into a <code>System.Xml.XmlDocument</code> </li>
<li>Populate it with data from my UI </li>
<li>Transform it with an <code>XSLT</code> I've written </li>
<li>Apply a <code>CSS</code> Stylesheet </li>
<li>Render it to a <code>WebBrowser</code> control </li>
</ol>
<p>I'm currently reading it from a file on disk, populating it, then saving it back out to disk after populating it. I reference the <code>XSLT</code> in the template, and the <code>CSS</code> in the <code>XSLT</code> and then use the <code>WebBrowser.Navigate([filename])</code> method to display the XML file.</p>
<p>Obviously, when I come to deploy this app, it'll break horribly as the file won't exist on disk, and I won't be able to reference the <code>XSLT</code> and <code>CSS</code> files in the <code>XML</code> file as they'll be resources. I'm planning to include the template as a resource, but can't find a neat way to proceed from there.</p>
<p>Any help much appreciated</p>
|
<p>Quick question. Why do you need an Xml template? If you already know the schema before hand, then simply generate the complete Xml in your code. There shouldn't be a need for loading a template file.</p>
|
<p>Check out <a href="http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx" rel="nofollow noreferrer">Linq to XML</a> - it's really good way to write and read Xml based data. Easier than the System.Xml.XmlDocument mechanisms.</p>
<p>Given that you are supplying the XSLT and the CSS, why not build the page in XHTML and inline the CSS? Alternatively just add the XSLT and CSS files as content in your installer.</p>
<p>Compiled help actually does something like what you're describing - you can copy a link from a CHM file and visit it with a normal browser. I suppose you could embed your display resources in a help file, depending on how they're used.</p>
| 5,878
|
<p>Is there a good method or tool to level the bed of 3D printers? I find myself making small adjustments a lot and it's mostly just trial-and-error. A normal bubble level is of limited help and trying to figure out if the head is the thickness of a sheet of paper from the bed in all corners is beyond the capability of my vision.</p>
|
<p>There are several ways.</p>
<p>1) Simplest is the business card/paper method.</p>
<p>This video shows how simple it is: <a href="https://www.youtube.com/watch?v=5bzAE5-QgUY" rel="noreferrer">Leveling the platform</a></p>
<p>You should feel the same amount of resistance between the hotend and the bed on all sides. On some 3D printers there are 3 screws holding the bed (eg. Solidoodle) and on others there are 4 screws on each edge (e.g. Prusa i3).
On some 3D printers you need to rotate a screw with a screwdriver to adjust it (e.g. Solidoodle 3) and on some you have a nut (mostly wing nut) (e.g. Solidoodle 4).</p>
<p>I find most people move the extruder around when adjusting the bed by controlling the motors. I think the quicker way is stopping the motors (in Repetier Host it's the "Stop Motor" button) and moving the gantry by hand.</p>
<p>Tutorial: <a href="https://www.youtube.com/watch?v=ED1Gxvw2Rmw" rel="noreferrer">3D printing guides - Bed leveling</a></p>
<p>2) Second one is just more advanced version of the above. You use a dial indicator/ micrometer attached to your extruder and make sure the number on the dial is as close as possible on all edges.</p>
<p><a href="https://www.youtube.com/watch?v=UI6eKDUzdfA" rel="noreferrer">Level the Print Bed on a RepRap / RepStrap 3D Printer with a Mitutoyo Dial Test Indicator</a></p>
<p><a href="https://www.youtube.com/watch?v=K19BaqhYD0c" rel="noreferrer">Micrometer op 3D printer</a></p>
<p>There are also digital versions of this tool.</p>
<p>You might need to print or make some other way a piece to be able to attach a micrometer to the extruder (there might be one for your 3D printer on Thingiverse already).</p>
<p>Now, remember I mentioned that you adjust the height of the edges of the print bed with a screw/nut? Well, since there is a lot of vibration during print those tend to get out of place and that might explain why you end up readjusting it over and over again. What I have found to solve this is to use a single drop of Loctite (cyanocrylate glue) in the middle of the nut/screw. A single drop will secure it in place but also not make it impossible to unscrew in the future.</p>
<p>3) Setting up auto-bed leveling on your 3D printer if it's modable enough:
<a href="https://www.youtube.com/watch?v=EcGFLwj0pnA" rel="noreferrer">3D printing guides: Setting up auto bed tramming leveling tilt compensation!</a>.</p>
<p>Finally, if you can't get the bed leveled no matter what, it might be uneven. That's usually caused by warping. Both PCB beds and aluminum beds can get warped. With the former just sandwich a glass bed on top of it and it should be fine. Warped aluminum is pretty hard to flatten. In this extreme situation you might need to get a new aluminum sheet cut and drilled, preferably a mm thicker one which is less likely to warp under the same conditions. I think this happens when you either set the bed temp too high and/or the thickness of the aluminum bed is too small (bad or cheap 3D printer design).</p>
|
<p>If you don't have an auto-leveling build plate or a depth gauge attachment for your X-Axis, you're pretty much stuck with the "piece of paper" method. To perform this easier, try shifting the paper as you adjust the bed. As soon as the paper becomes difficult to move (the nozzle is touching now), back off the build plate by about a quarter turn.</p>
<p>Please also keep in mind how your printer is constructed. If your build plate arms are plastic, they are easily susceptible to warping if you have a heated build plate. Even if the warping isn't permanent, the build plate can technically shift during a print as the arms get hotter. Some people go as far as replacing these arms with aluminum versions.</p>
| 183
|
<p>I'm trying to fix some JavaScript bugs. Firebug makes debugging these issues a lot easier when working in Firefox, but what do you do when the code works fine on Firefox but IE is complaining?</p>
|
<p>you can also check out the <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=95e06cbe-4940-4218-b75d-b8856fced535" rel="noreferrer">IE Developer Toolbar</a> which isn't a debugger but will help you analyze the contents of your code.</p>
<p><a href="http://weblogs.asp.net/scottgu/archive/2007/07/19/vs-2008-javascript-debugging.aspx" rel="noreferrer">Visual Studio</a> will help with the debugging </p>
<p><a href="http://www.fiddlertool.com/fiddler/" rel="noreferrer">Fiddler</a> should help analyse the traffic travelling to and from your browser</p>
|
<p>The IE8 beta comes with what I think is the IE Developer toolbar, but it seems to be a lot more powerful than the last time I tried the toolbar on IE7</p>
| 2,978
|
<p>When you data bind in C#, the thread that changes the data causes the control to change too. But if this thread is not the one on which the control was created, you'll get an Illegal Cross Thread Operation exception.</p>
<p>Is there anyway to prevent this?</p>
|
<p>You should be able to do something like:</p>
<pre><code>if (control.InvokeRequired)
{
control.Invoke(delegateWithMyCode);
}
else
{
delegateWithMyCode();
}
</code></pre>
<p>InvokeRequired is a property on Controls to see if you are on the correct thread, then Invoke will invoke the delegate on the correct thread.</p>
<p>UPDATE: Actually, at my last job we did something like this:</p>
<pre><code>private void SomeEventHandler(Object someParam)
{
if (this.InvokeRequired)
{
this.Invoke(new SomeEventHandlerDelegate(SomeEventHandler), someParam);
}
// Regular handling code
}
</code></pre>
<p>which removes the need for the else block and kind of tightens up the code.</p>
|
<p>If the thread call is "illegal" (i.e. the DataBind call affects controls that were not created in the thread it is being called from) then you need to create a delegate so that even if the decision / preparation for the DataBind is not done in the control-creating thread, any resultant modification of them (i.e. DataBind()) will be.</p>
<p>You would call my code from the worker thread like so:</p>
<pre><code>this.BindData.Invoke();
</code></pre>
<p>This would then cause the original thread to do the binding, which (presuming it is the thread that created the controls) should work.</p>
| 2,421
|
<p>Recently I have been investigating the possibilities of caching in ASP.NET.</p>
<p>I rolled my own "Cache", because I didn't know any better, it looked a bit like this:</p>
<pre><code>public class DataManager
{
private static DataManager s_instance;
public static DataManager GetInstance()
{
}
private Data[] m_myData;
private DataTime m_cacheTime;
public Data[] GetData()
{
TimeSpan span = DateTime.Now.Substract(m_cacheTime);
if(span.TotalSeconds > 10)
{
// Do SQL to get data
m_myData = data;
m_cacheTime = DateTime.Now;
return m_myData;
}
else
{
return m_myData;
}
}
}
</code></pre>
<p>So the values are stored for a while in a singleton, and when the time expires, the values are renewed. If time has not expired, and a request for the data is done, the stored values in the field are returned.</p>
<p>What are the benefits over using the real method (<a href="http://msdn.microsoft.com/en-us/library/aa478965.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa478965.aspx</a>) instead of this?</p>
|
<p>I think the maxim "let the computer do it; it's smarter than you" applies here. Just like memory management and other complicated things, the computer is a lot more informed about what it's doing than your are; consequently, able to get more performance than you are.</p>
<p>Microsoft has had a team of engineers working on it and they've probably managed to squeeze much more performance out of the system than would be possible for you to. It's also likely that ASP.NET's built-in caching operates at a different level (which is inaccessible to your application), making it much faster.</p>
|
<p>Caching in ASP.NET is feature rich and you can configure caching in quite a granular way. </p>
<p>In your case (data caching) one of the features you're missing out on is the ability to invalidate and refresh the cache if data on the SQL server is updated in some way (SQL Cache Dependency).</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms178604.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms178604.aspx</a></p>
| 3,232
|
<p>I saw an extruder mod on Amazon <em>"EAONE 2 Pcs PTFE Teflon Tube (2 Meters) with 4 Pcs PC4-M6 Fittings for 3D Printer 1.75mm Filament (2.0mm ID/4.0mm OD)"</em>
Anybody know how this is fitted? Is it simply tapping the feed hole on the top?</p>
|
<p>Is <a href="https://www.amazon.co.uk/EAONE-Teflon-Fittings-Printer-Filament/dp/B077X6FW97" rel="nofollow noreferrer">this</a> what you are referring to?</p>
<p>If yes, the cold end of the extruder is nomally already tapped and you simply have to screw the new fitting in it. The PTFE tube itself needs just to be fed through the hole in the fitting <strong>until it cannot go any further</strong>.</p>
<p>Failing to do so will most likely result in a clog and/or leaking.</p>
<p>It is a self-locking mechanism, in order to release the tube you have to press <em>down</em> the plastic flange on top of the fitting while pulling <em>up</em> the PTFE tube.</p>
|
<p>that item is for a bowden setup. (the a8 does not come with a bowden setup, but can be modded to have one.)
when installing the bowden setup on a a8, the first thing you will need to do is move the motor to somewhere else, there are tons of choices on thingiverse.
then the PC4-M6 fitting will screw into the black aluminum piece that the throat used to screw into.
and the other end will go into a customised hot end. again tons of choices</p>
<p>now this is oversimplified, because installing a bowden extruder on a anet a8 is a lot more complicated than explained above due to the sheer number of options.
just search anet a8 bowden and you will have lots of choices.</p>
<p>but it works as mac said, the PTFE tube slides into self locking fittings, the PC4-M6.
to release simply push the top of the fitting down and pull out the tube.</p>
<p>source, my own anet a8 modded to have a bowden setup.</p>
| 809
|
<p>I'm using Eclipse as my IDE for a C++ project, and I would love for it to tell me where a given symbol is defined and what the parameters are for a function.</p>
<p>However, there's a catch: I also use <a href="http://www.lazycplusplus.com/" rel="nofollow noreferrer">Lazy C++</a>, a tool that takes a single source file and generates the .h and the .cpp files. Those .lzz files look like headers, but this tool supports some very mild syntactic benefits, like combining nested namespaces into a qualified name. Additionally, it has some special tags to tell the tool specifically where to put what (in header or in source file).</p>
<p>So my typical SourceFile.lzz looks like this:</p>
<pre><code>$hdr
#include <iosfwd>
#include "ProjectA/BaseClass.h"
$end
$src
#include <iostream>
#include "ProjectB/OtherClass.h"
$end
// Forward declarations
namespace BigScope::ProjectB
{
class OtherClass;
}
namespace BigScope::ProjectA
{
class MyClass : public ProjectA::BaseClass
{
void SomeMethod(const ProjectB::OtherClass& Foo) { }
}
}
</code></pre>
<p>As you see, it's still recognizable C++, but with a few extras.</p>
<p>For some reason, CDT's indexer does not seem to want to index anything, and I don't know what's wrong. In the Indexer View, it shows me an empty tree, but tells me that it has some 15000 symbols and more stuff, none of which I can seem to access.</p>
<p>So here's my <strong>question</strong>: how can I make the Indexer output some more information about what it's doing and why it fails when it does so, and can I tweak it more than with just the GUI-accessible options?</p>
<p>Thanks,</p>
<p>Carl</p>
|
<p>I'd imagine its one of:</p>
<ul>
<li><p>Eclipse doesn't want to display non-C++ resources in the tree (I've had problems with this)</p></li>
<li><p>You don't have "Preferences > C/C++ > Indexer > Index All Files" enabled.</p></li>
<li><p>You want to use the "Full C/C++ Indexer" rather than the "Fast C/C++ Indexer"</p></li>
</ul>
|
<p>The CDT parser/indexer won't recognize weird extensions like that. The only thing you can do is to define macros on the Paths and Symbols property page to trick the parser. Try creating macros for <code>$hdr</code>, <code>$end</code> and <code>$src</code> that have empty bodies. That way the preprocessor will remove them and the parser won't choke on them.</p>
| 8,294
|
<p>What's the most efficient way to concatenate strings?</p>
|
<p>The <code>StringBuilder.Append()</code> method is much better than using the <code>+</code> operator. But I've found that, when executing 1000 concatenations or less, <code>String.Join()</code> is even more efficient than <code>StringBuilder</code>.</p>
<pre><code>StringBuilder sb = new StringBuilder();
sb.Append(someString);
</code></pre>
<p>The only problem with <code>String.Join</code> is that you have to concatenate the strings with a common delimiter.</p>
<p><strong>Edit:</strong> as <em>@ryanversaw</em> pointed out, you can make the delimiter <code>string.Empty</code>.</p>
<pre><code>string key = String.Join("_", new String[]
{ "Customers_Contacts", customerID, database, SessionID });
</code></pre>
|
<p>It would depend on the code.
StringBuilder is more efficient generally, but if you're only concatenating a few strings and doing it all in one line, code optimizations will likely take care of it for you. It's important to think about how the code looks too: for larger sets StringBuilder will make it easier to read, for small ones StringBuilder will just add needless clutter.</p>
| 4,140
|
<p>This is what I've got. It works. But, is there a simpler or better way?</p>
<p>ASPX Page…</p>
<pre><code><asp:Repeater ID="RepeaterBooks" runat="server">
<HeaderTemplate>
<table class="report">
<tr>
<th>Published</th>
<th>Title</th>
<th>Author</th>
<th>Price</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Literal ID="LiteralPublished" runat="server" /></td>
<td><asp:Literal ID="LiteralTitle" runat="server" /></td>
<td><asp:Literal ID="LiteralAuthor" runat="server" /></td>
<td><asp:Literal ID="LiteralPrice" runat="server" /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</code></pre>
<p>ASPX.VB Code Behind…</p>
<pre><code>Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim db As New BookstoreDataContext
RepeaterBooks.DataSource = From b In db.Books _
Order By b.Published _
Select b
RepeaterBooks.DataBind()
End Sub
Sub RepeaterBooks_ItemDataBound( ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterBooks.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim b As Book = DirectCast(e.Item.DataItem, Book)
DirectCast(e.Item.FindControl("LiteralPublished"), Literal).Text = "<nobr>" + b.Published.ToShortDateString + "</nobr>"
DirectCast(e.Item.FindControl("LiteralTitle"), Literal).Text = "<nobr>" + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) + "</nobr>"
DirectCast(e.Item.FindControl("LiteralAuthor"), Literal).Text = "<nobr>" + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) + "</nobr>"
DirectCast(e.Item.FindControl("LiteralPrice"), Literal).Text = "<nobr>" + Format(b.Price, "c") + "</nobr>"
End If
End Sub
Function TryNbsp(ByVal s As String) As String
If s = "" Then
Return "&nbsp;"
Else
Return s
End If
End Function
</code></pre>
|
<p>@Geoff</p>
<p>That sort of Eval statement was actually added in 2.0, but if performance is important Eval should be avoided since it uses Reflection.</p>
<p>The repeater is a pretty good way of doing it, although it might be faster to generate the table in code:</p>
<p>ASPX Page:</p>
<pre><code><table class="report" id="bookTable" runat="server">
<tr>
<th>Published</th>
<th>Title</th>
<th>Author</th>
<th>Price</th>
</tr>
</table>
</code></pre>
<p>Code Behind:</p>
<pre><code>Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostback Then
BuildTable()
End If
End Sub
Private Sub BuildTable()
Dim db As New BookstoreDataContext
Dim bookCollection = from b in db.Books _
Order By b.Published _
Select b
Dim row As HtmlTableRow
Dim cell As HtmlTableCell
For Each book As Books In bookCollection
row = New HtmlTableRow()
cell = New HtmlTableCell With { .InnerText = b.Published.ToShortDateString }
row.Controls.Add(cell)
cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) }
row.Controls.Add(cell)
cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author))
row.Controls.Add(cell)
cell = New HtmlTableCell With { .InnerText = Format(b.Price, "c") }
row.Controls.Add(cell)
bookTable.Controls.Add(row)
Next
</code></pre>
<p>I guess it depends on how important speed is to you. For simplicity's sake I think I would go with the Repeater.</p>
|
<blockquote>
<p><strong><a href="https://stackoverflow.com/users/1249/alassek">ALassek</a></strong> wrote:</p>
<p>…generate the table in code…</p>
</blockquote>
<p>I like the look of that! It seems MUCH less likely to produce a run-time exception due to a typo or field name change.</p>
| 6,539
|
<p>Consider the need to develop a lightweight desktop DB application on the Microsoft platforms.</p>
<p>It could be done fairly easily with MS Access but I'd like to be able to distribute it to others and I don't want to pay for a runtime license. </p>
<p>Requirements:</p>
<ul>
<li>easy distribution to others</li>
<li>no runtime licensing issues</li>
</ul>
<p>Considerations and Candidates:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/OpenOffice.org_Base" rel="noreferrer">Base from the OpenOffice suite</a>. My concerns were around its stability. </li>
<li><a href="http://dev.mysql.com/downloads/" rel="noreferrer">MySQL</a> + writing custom DB code in C++ or Python or whatever seems like a rather heavy-handed solution. </li>
</ul>
<p><strong>Question</strong>: What are the low cost or free database alternatives to MS Access?</p>
<hr>
<p><strong>See Also:</strong> <a href="https://stackoverflow.com/questions/126622/open-source-reporting-engines">Open Source Reporting Engines</a></p>
<hr>
<hr>
<p>@Schnapple</p>
<p>Bruceatk kind of hit on what I'm thinking of; it's not so much the DB engine as I want the other niceties that Access brings to the party. The nice form designer, the nice reporting engine etc. But you do raise a very good point about the installation footprint. I had considered that but I've not made any firm decisions about which way I'm going with this yet anyway. It'll probably be something fairly lightweight anyway and a small installation footprint would definitely be a plus.</p>
<hr>
<p>@Remou,</p>
<p>No I was unaware that the MS Access 2007 runtime is free; thanks for pointing that out. The last time I'd bothered to investigate it (I don't remember when it was) I think it was a fairly expensive license for the runtime because I think they were trying to sell it to Corporate IT departments.</p>
<p>And thanks to everyone else who responded as well; I was completely unaware of those other options you all pointed out.</p>
|
<p>One thing to keep in mind here is the MS Access product is much more than just the raw database engine. It provides a full application development platform, including form and menu designer, client application language and environment (VBA), and report designer. When you take all those things together, MS Access really has no peer.</p>
<p>But for the scope of this question, we're concerned with the raw database engine. With that in mind:</p>
<p><a href="http://www.sqlite.org/" rel="nofollow noreferrer">SQLlite</a>,<br>
<a href="http://www.firebirdsql.org/" rel="nofollow noreferrer">Firebird</a>,<br>
<a href="http://www.vistadb.net/" rel="nofollow noreferrer">VistaDB</a> (not free),<br>
<a href="http://www.microsoft.com/sql/editions/compact/default.mspx" rel="nofollow noreferrer">SQL Server Compact Edition</a> (not Express)<br>
and now SQL Server LocalDB<br>
all come to mind.</p>
<p>Another thought: while the original question does ask about desktop databases, its likely some people will land here looking for a database to use with a web site. It's important to remember that these are all <em>in-process</em> databases, and as such are rarely if ever appropriate for use on the web. If you want to build a web site, where it's common to need to support significant concurrent access, you generally want a database <em>server</em> engine, like MS SQL, Postgresql, MySQL, Oracle, or their brethren. At the same time, those <em>server</em> engines are rarely if ever appropriate for a single-user desktop application.</p>
|
<p>VistaDB is the only alternative if you going to run your website at shared hosting (almost all of them won't let you run your websites under Full Trust mode) and also if you need simple x-copy deployment enabled website.</p>
| 4,871
|
<p>I'm missing the boat on something here, kids. This keeps rearing its head and I don't know what's going on with it, so I hope my homeys here can help.</p>
<p>When working in Silverlight, when I create bindings in my c# code, they never hold up when the application is running. The declarative bindings from my xaml seem ok, but I'm doing something wrong when I create my bindings in C#. I'm hoping that there is something blindingly obvious I'm missing. Here's a typical binding that gets crushed:</p>
<pre><code>TextBlock tb = new TextBlock();
Binding b = new Binding("FontSize");
b.Source = this;
tb.SetBinding(TextBlock.FontSizeProperty, b);
</code></pre>
|
<p>I've just tried the exact code you just posted and it worked fine, with some changes. I believe the problem is the element you are using for the SetBinding call is not the textblock you want to bind. It should be:</p>
<pre><code>TextBlock tb = new TextBlock();
Binding b = new Binding("FontSize");
b.Source = this;
tb.SetBinding(TextBlock.FontSizeProperty, b);
</code></pre>
<p>Make sure you also have a FontSize public property of type double on "this". If "this" is a user control, I would recommend renaming the property so you don't hide the inherited member.</p>
|
<p>I've just tried the exact code you just posted and it worked fine, with some changes. I believe the problem is the element you are using for the SetBinding call is not the textblock you want to bind. It should be:</p>
<pre><code>TextBlock tb = new TextBlock();
Binding b = new Binding("FontSize");
b.Source = this;
tb.SetBinding(TextBlock.FontSizeProperty, b);
</code></pre>
<p>Make sure you also have a FontSize public property of type double on "this". If "this" is a user control, I would recommend renaming the property so you don't hide the inherited member.</p>
| 9,748
|
<p>When using the Net.Sockets.TcpListener, what is the best way to handle incoming connections (.AcceptSocket) in seperate threads?</p>
<p>The idea is to start a new thread when a new incoming connection is accepted, while the tcplistener then stays available for further incoming connections (and for every new incoming connection a new thread is created). All communication and termination with the client that originated the connection will be handled in the thread.</p>
<p>Example C# of VB.NET code is appreciated.</p>
|
<p>The code that I've been using looks like this:</p>
<pre><code>class Server
{
private AutoResetEvent connectionWaitHandle = new AutoResetEvent(false);
public void Start()
{
TcpListener listener = new TcpListener(IPAddress.Any, 5555);
listener.Start();
while(true)
{
IAsyncResult result = listener.BeginAcceptTcpClient(HandleAsyncConnection, listener);
connectionWaitHandle.WaitOne(); // Wait until a client has begun handling an event
connectionWaitHandle.Reset(); // Reset wait handle or the loop goes as fast as it can (after first request)
}
}
private void HandleAsyncConnection(IAsyncResult result)
{
TcpListener listener = (TcpListener)result.AsyncState;
TcpClient client = listener.EndAcceptTcpClient(result);
connectionWaitHandle.Set(); //Inform the main thread this connection is now handled
//... Use your TcpClient here
client.Close();
}
}
</code></pre>
|
<p>I would use a threadpool, this way you won't have to start a new thread every time (since this is kinda expensive). I would also not wait indefinetely for furhter connections, since clients may not close their connections. How do you plan to route the client to the same thread each time?</p>
<p>Sorry, don't have sample.</p>
| 8,789
|
<p>Anyone know of a way to use SVK with perforce? The docs <a href="http://svk.bestpractical.com/view/MirrorVCP" rel="nofollow noreferrer">seem to imply</a> it used to be possible, but some <a href="http://lists.bestpractical.com/pipermail/svk-devel/2007-February/000604.html" rel="nofollow noreferrer">mailing list messages</a> claim that is no longer the case?</p>
|
<p>For a private repository, you should try <a href="http://www.releng.com/p5layer.html" rel="nofollow noreferrer">P5</a></p>
|
<p>Why use SVK to mirror Perforce? Surely using a <a href="http://www.perforce.com/perforce/products/p4p.html" rel="nofollow noreferrer">Perforce Proxy</a> is the best way to make your repository distributed?</p>
| 7,602
|
<p>Resharper, RefactorPro, etc?</p>
|
<p>I have tried using Resharper for some while and also CodeRush with Refactor later on. </p>
<p>I have stayed with CodeRush/Refactor. There is one major difference - the discoverability of the commands. Their learning videos are quite nice and show you a lot.</p>
<p>Most importantly Coderush has one key/shortcut for all refactorings which makes you much more likely to actually use them. There is side window that shows you what keys to press in order to use the templates as well. I have liked Resharper's searching for usage of a method, but CodeRush has a similar feature ignited by Shift + F12 and you can also simply press Tab on a variable, function etc. to jump to its next usage.</p>
<p>I also liked the interface of CodeRush/Refactor more.</p>
<p>One of the pro's for Resharper is the integrated testing tool so yuo can run test directly from Visual Studio.</p>
|
<p>I think ReSharper is great. I've been using it for 3 years now and I just love it more and more.</p>
| 6,970
|
<p>Does anybody use the Class Designer much in Visual Studio?</p>
<p>I have downloaded the Modeling Power Toys for 2005 and have been impressed with what I've seen so far. The MSDN Class Designer Blog doesn't seem to have been updated for a while but it still looks quite useful.</p>
<p>Is the Class Designer a quick way to build the basic application or should I just work out on paper and then start coding?</p>
<p>Thanks</p>
|
<p>As a visualization tool, or for exploratory purposes (drawing up multiple options to see what they look like) it's not bad, but generally I find the object browser does fine for most stuff I care about.</p>
<p>As a code generation tool, it's a terrible idea.</p>
<p>The whole idea that we will design all our code structure first, then fill in the blanks with small bits of implementation is fundamentally broken.</p>
<p>The only time you actually know what the code structure should look like, is if you've done the <strong>exact</strong> same thing before - however then you can just <strong>use</strong> your previous code, and you don't need to draw up any new code in any kind of designer.</p>
<p>If you decide ahead of time to use a particular class structure before you've actually tried to solve the problem, there is a 100% chance that you will pick the wrong design, and shoot yourself in the foot.</p>
|
<p>I have tried it out couple of times, mainly for viewing existing classes.
If it would show all the relationships, it would be more usefull. Now it only shows inheritation.</p>
| 3,520
|
<p>I'm playing with the routing.rb code in Rails 2.1, and trying to to get it to the point where I can do something useful with the RoutingError exception that is thrown when it can't find the appropriate path.</p>
<p>This is a somewhat tricky problem, because there are some class of URLs which are just plain BAD: the /azenv.php bot attacks, the people typing /bar/foo/baz into the URL, etc... we don't want that.</p>
<p>Then there's subtle routing problems, where we do want to be notified: /artists/ for example, or ///. In these situations, we may want an error being thrown, or not... or we get Google sending us URLs which used to be valid but are no longer because people deleted them.</p>
<p>In each of these situations, I want a way to contain, analyze and filter the path that we get back, or at least some Railsy way to manage routing past the normal 'fallback catchall' url. Does this exist?</p>
<p>EDIT:</p>
<p>So the code here is: </p>
<pre><code># File vendor/rails/actionpack/lib/action_controller/rescue.rb, line 141
def rescue_action_without_handler(exception)
log_error(exception) if logger
erase_results if performed?
# Let the exception alter the response if it wants.
# For example, MethodNotAllowed sets the Allow header.
if exception.respond_to?(:handle_response!)
exception.handle_response!(response)
end
if consider_all_requests_local || local_request?
rescue_action_locally(exception)
else
rescue_action_in_public(exception)
end
end
</code></pre>
<p>So our best option is to override log_error(exception) so that we can filter down the exceptions according to the exception. So in ApplicationController</p>
<pre><code>def log_error(exception)
message = '...'
if should_log_exception_as_debug?(exception)
logger.debug(message)
else
logger.error(message)
end
end
def should_log_exception_as_debug?(exception)
return (ActionController::RoutingError === exception)
end
</code></pre>
<p>Salt for additional logic where we want different controller logic, routes, etc.</p>
|
<p>Nooooo!!! Don't implement method_missing on your controller! And please try to avoid action_missing as well.</p>
<p>The frequently touted pattern is to add a route:</p>
<pre><code>map.connect '*', :controller => 'error', :action => 'not_found'
</code></pre>
<p>Where you can show an appropriate error.</p>
<p>Rails also has a mechanism called rescue_action_in_public where you can write your own error handling logic -- we really should clean it up and encourage people to use it. PDI! :-)</p>
|
<p>There's the method_missing method. You could implement that in your Application Controller and catch all missing actions, maybe logging those and redirecting to the index action of the relevant controller. This approach would ignore everything that can't be routed to a controller, which is pretty close to what you want. </p>
<p>Alternatively, I'd just log all errors, extract the URL and sort it by # of times it occured.</p>
| 7,419
|
<p>How do I implement a draggable tab using Java Swing? Instead of the static JTabbedPane I would like to drag-and-drop a tab to different position to rearrange the tabs.</p>
<p><strong>EDIT</strong>: <a href="http://java.sun.com/docs/books/tutorial/uiswing/dnd/index.html" rel="noreferrer">The Java Tutorials - Drag and Drop and Data Transfer</a>.</p>
|
<p>Curses! Beaten to the punch by a Google search. Unfortunately it's true there is no easy way to create draggable tab panes (or any other components) in Swing. So whilst the example above is complete this one I've just written is a bit simpler. So it will hopefully demonstrate the more advanced techniques involved a bit clearer. The steps are:</p>
<ol>
<li>Detect that a drag has occurred</li>
<li>Draw the dragged tab to an offscreen buffer</li>
<li>Track the mouse position whilst dragging occurs</li>
<li>Draw the tab in the buffer on top of the component.</li>
</ol>
<p>The above example will give you what you want but if you want to really understand the techniques applied here it might be a better exercise to round off the edges of this example and add the extra features demonstrated above to it.</p>
<p>Or maybe I'm just disappointed because I spent time writing this solution when one already existed :p</p>
<pre class="lang-java prettyprint-override"><code>import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.image.BufferedImage;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
public class DraggableTabbedPane extends JTabbedPane {
private boolean dragging = false;
private Image tabImage = null;
private Point currentMouseLocation = null;
private int draggedTabIndex = 0;
public DraggableTabbedPane() {
super();
addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
if(!dragging) {
// Gets the tab index based on the mouse position
int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), e.getY());
if(tabNumber >= 0) {
draggedTabIndex = tabNumber;
Rectangle bounds = getUI().getTabBounds(DraggableTabbedPane.this, tabNumber);
// Paint the tabbed pane to a buffer
Image totalImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics totalGraphics = totalImage.getGraphics();
totalGraphics.setClip(bounds);
// Don't be double buffered when painting to a static image.
setDoubleBuffered(false);
paintComponent(totalGraphics);
// Paint just the dragged tab to the buffer
tabImage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
Graphics graphics = tabImage.getGraphics();
graphics.drawImage(totalImage, 0, 0, bounds.width, bounds.height, bounds.x, bounds.y, bounds.x + bounds.width, bounds.y+bounds.height, DraggableTabbedPane.this);
dragging = true;
repaint();
}
} else {
currentMouseLocation = e.getPoint();
// Need to repaint
repaint();
}
super.mouseDragged(e);
}
});
addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if(dragging) {
int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), 10);
if(tabNumber >= 0) {
Component comp = getComponentAt(draggedTabIndex);
String title = getTitleAt(draggedTabIndex);
removeTabAt(draggedTabIndex);
insertTab(title, null, comp, null, tabNumber);
}
}
dragging = false;
tabImage = null;
}
});
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
// Are we dragging?
if(dragging && currentMouseLocation != null && tabImage != null) {
// Draw the dragged tab
g.drawImage(tabImage, currentMouseLocation.x, currentMouseLocation.y, this);
}
}
public static void main(String[] args) {
JFrame test = new JFrame("Tab test");
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test.setSize(400, 400);
DraggableTabbedPane tabs = new DraggableTabbedPane();
tabs.addTab("One", new JButton("One"));
tabs.addTab("Two", new JButton("Two"));
tabs.addTab("Three", new JButton("Three"));
tabs.addTab("Four", new JButton("Four"));
test.add(tabs);
test.setVisible(true);
}
}
</code></pre>
|
<p>Add this to isDragAcceptable to avoid Exceptions:</p>
<pre><code>boolean transferDataFlavorFound = false;
for (DataFlavor transferDataFlavor : t.getTransferDataFlavors()) {
if (FLAVOR.equals(transferDataFlavor)) {
transferDataFlavorFound = true;
break;
}
}
if (transferDataFlavorFound == false) {
return false;
}
</code></pre>
| 8,511
|
<p>I've got some sliced models that represent the <strong>right</strong>-side arms and legs of a robot. I'm really happy with how they printed, so now I'd like to print the <strong>left</strong>-side arms and legs.</p>
<p>I was thinking it would be pretty trivial to parse the G-code file using Python and change the value of all the <code>Xn</code> commands from <code>n</code> to <code>2*h - n</code>, where <code>h</code> is in the middle of the bed, say 110 or 120 mm for an Ender 3.</p>
<p>Before I fire up my favorite IDE, are there any major gotchas I might encounter from such a naïve approach to mirroring the G-code like this? I originally sliced in Cura 4.9.1.</p>
|
<p>If your slicer does not have a mirror operation or a scale that allows negative values then mirroring in the G-code should be straightforward.</p>
<p>As long as your printer doesn't have certain specific tool change or homing or purge positions that are done in the G-code you can just transform it, otherwise you would want to skip these sections and just do the model data (it should be obvious looking at the code where model data starts).</p>
<p>In order to mirror it you just need to swap out the X coordinates in your G-code, If (0,0) is the center of your bed, as is often (but not always) the case for delta printers you will just want to negate the X, so <code>G1 X30 Y-3 Z2</code> becomes <code>G1 X-30 Y-3 Z2</code>. If your coordinates have (0,0) in a corner (often the case for orthogonal printers) then you want to subtract X from the maximum X value. for instance if your bed is 250 mm wide then in <code>G1 X30 Y10 Z3 X30</code> becomes <code>X(250-30)</code> or <code>G1 X220 Y10 Z3</code>.</p>
<p>There is only one caveat, some slicers will switch to relative movement using <code>G91</code> for certain operations and then back to absolute with <code>G90</code>, so you will want to look out for these. Between a <code>G91</code> and a <code>G90</code> you will want to negate the X, no matter where the origin of your printer is.</p>
<p>When writing your script, I'd keep track of the minimum and maximum values encountered and the new minimum and maximum values and print them at the end as a sanity check so you can see if anything is wonky.</p>
|
<p>Usage: python3 [filename.gcode] [bed-width]</p>
<pre><code>#!/usr/bin/env python3
import re
from sys import argv
#first arg is the file, second arg is the bed x width
ifilename = argv[1];
ofilename = ifilename.replace('.gcode', '-reversed.gcode');
new_data =[]
BEDX = float(argv[2])
h = BEDX # Absolute Positioning is default
with open(ifilename, 'r') as ifp:
for d in ifp:
new_d = ''
tokens = d.split()
if len(tokens) == 0:
pass
else:
if tokens[0] == 'G91': # Relative Positioning
h = 0
new_d += d
elif tokens[0] == 'G90':# Absolute Positioning
h = BEDX
new_d += d
elif tokens[0] == 'G1':
for t in tokens:
if t.startswith('X'):
if len(t) > 1:
x = h - float(t[1:])
t = 'X'+f'{x:.3f}'
new_d += t+' '
else:
new_d += d
new_data.append(new_d)
with open(ofilename, 'w') as ofp:
for d in new_data:
ofp.write(d+'\n') # how does writelines not support a line separator?
</code></pre>
<p>For those that have a problem with the script above, I think this fixes it.</p>
<p>Also there seems to be a bug with not writting G90 or G91 whenever it finds it.</p>
| 1,979
|
<p>I'm in dire need to reprint a small chunk of a print that got messed up during print because the support for it broke which I cannot explain whatsoever.</p>
<p>Anyway. I need to edit the STL file and I don't know what tool to use since Blender is definitely not user friendly for just a simple cut and past.</p>
<p>Anyone got an idea on what I should try to do? Reprinting is definitely out of question since that would take at least another 20 hours, that I haven't got, to reprint the whole thing and I would also just waste a lot of PLA.</p>
|
<p>Alright so I asked in my facebook group and a friendly fellow game me the tip to use Meshmixer from AutoCAD and then check a video on Plane cut. I only needed 3 simple cuts and the piece I needed was all ready to print. :) 40 Minutes to print and only 3g of PLA to spend :)</p>
|
<p>You could import the STL file in a 3D CAD modelling program and edit it there.</p>
<p>To not give an opinionated answer, there are many free or paid alternatives available. Loading the STL generally requires it to be scaled down to one tenth of the imported size and transform the surface model into a solid. Once you have the solid you can cut away what you do not need.</p>
| 1,146
|
<p>I have been working with our SLA printer (Facture Draken) for a couple weeks now printing in makerjuice waxcast. . I have had some successful prints, but the majority (80%) end up as pancakes stuck to the bottom of the resin tray. Some others break in half mid print. </p>
<p>I have experimented with laying my models (round circular diks) flat on the build plate, but most of the times I place them on supports which stem from a square baseplate. </p>
<p>It seems clear to me that there is allot of force being put on the models while curing on the bottom of the resin tray. I have noticed that printing objects with a larger projection area are more likely to stick in the vat. I assume this is because of the increased contact with the tray. Usually it seems ~10 layers are built before my baseplate breaks away. </p>
<p>Things I have tried</p>
<ul>
<li>Pulling out the build plate, cleaning it with Acetone. Sanding it with 80 grit sandpaper. </li>
<li>Emptying the resin tray and replacing with new resin. </li>
<li><p>Upping base-layer cure-time from from 30seconds up to 3 minutes, and variations between.</p></li>
<li><p>Upping base-layer count from 2 to 4.</p></li>
<li>Rotating model base 45% to start the tray peel process from a corner rather than from a long edge to reduce initial tear force. </li>
</ul>
<p>Anyone with experience got more suggestions on how to continue troubleshooting?</p>
|
<p>Prints could end up on tray for couple of reasons. </p>
<ul>
<li>Vacuum force on early layers - Usually you should lose pieces on the center of platform
<ul>
<li>Put holes or channels on platform</li>
<li>Very slow speed on early layers</li>
<li>Use smaller platform</li>
<li>Use tilt mechanism</li>
<li>Use larger support structures</li>
<li>Use stickier platform - Anodized aluminum is specially good </li>
</ul></li>
<li>Non-aligned platform - Pieces on side of platform end up on tray
<ul>
<li>Align platform / tray</li>
</ul></li>
<li>Low cure times - you could lose pieces around platform for DLP and whole platform for LCD ones</li>
<li>Resin related issues
<ul>
<li>Resin designed for thinner layers - Decrease layer thickness</li>
<li>Pigment settled down - Shake resin before use</li>
</ul></li>
</ul>
|
<p>I also had issues with the first layer sticking to the build plate and I did not want to sand the plate. As most people will mention you need to make sure that your plate is perfectly level and the z height is right (lots of friction on the paper). You also need the correct exposure times for your resin and the first few layers should get 60 seconds of exposure. <strong>PRO TIP to improve bed adhesion:</strong> apply a thin layer of resin to the build platform before you start to print. I have not any failed prints after I started coating the plate with resin. Also, I don't completely clean the plate between prints, I make sure it is still sticky. I hope this helps.</p>
| 646
|
<p>When trying to enter a SQL query with parameters using the Oracle OLE DB provider I get the following error:</p>
<blockquote>
<p>Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" access mode, in which the entire SQL command is stored in a variable.<br>
ADDITIONAL INFORMATION:<br>
Provider cannot derive parameter information and SetParameterInfo has not been called. (Microsoft OLE DB Provider for Oracle) </p>
</blockquote>
<p>I have tried following the suggestion here but don't quite understand what is required:<a href="http://microsoftdw.blogspot.com/2005/11/parameterized-queries-against-oracle.html" rel="noreferrer">Parameterized queries against Oracle</a></p>
<p>Any ideas?</p>
|
<p>To expand on the link given in the question:</p>
<ol>
<li>Create a package variable</li>
<li>Double click on the package variable name. (This allows you to access the properties of the variable)</li>
<li>Set the property 'EvaluateAsExpression' to true</li>
<li>Enter the query in the expression builder.</li>
<li>Set the OLE DB source query to SQL Command from Variable</li>
</ol>
<p>The expression builder can dynamically create expressions using variable to create 'parametised queries'.<br>
So the following 'normal' query:</p>
<pre><code>select * from book where book.BOOK_ID = ?
</code></pre>
<p>Can be written in the expression builder as:</p>
<pre><code>"select * from book where book.BOOK_ID = " + @[User::BookID]
</code></pre>
<p>You can then do null handling and data conversion using the expression builder.</p>
|
<p>If You use Data Flow Task and use OLE DB Source, and you need parameterize your Query : </p>
<ol>
<li>Create Variable to save "Full" of Query statement : Right Click on blank area outside the package - and Click Variables : </li>
</ol>
<p><a href="https://i.stack.imgur.com/yLvNJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yLvNJ.jpg" alt="Variables"></a></p>
<p>Click Add Variables on Variables Window : </p>
<p><a href="https://i.stack.imgur.com/AgX1w.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AgX1w.jpg" alt="enter image description here"></a></p>
<p>Make the name is <code>SQL_DTFLOW_FULL</code> or something that can you understand easily. The <code>variable data type</code> is <code>STRING</code></p>
<ol start="2">
<li>Create Variable(s) to save your parameter(s). </li>
</ol>
<p>i.e, the full of Query stamements is : </p>
<pre><code>SELECT * FROM BOOK WHERE BOOK_ID = @BookID --@BookID is SQL Parameter
</code></pre>
<p>at the sample above, I have just one parameter : @BookID, so I need to create one variable to save my parameter. Add more variables depends on your Queries. </p>
<p><a href="https://i.stack.imgur.com/M4siL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M4siL.jpg" alt="ParamAdd"></a></p>
<p>Give it name <code>SQL_DTFLOW_BOOKID</code></p>
<p>The <code>variable data type</code> is <code>STRING</code></p>
<p>So, you need make your SSIS neat, and the variables is sorted in understandable parts.</p>
<p>Try to make the variable name is <code>SQL_{TASK NAME}_{VariableName}</code></p>
<ol start="3">
<li>Make Expression for <code>SQL_DTFLOW_FULL</code> variable, click on number 1, and start fill number 2. Make Your SQL Statements to be a correct SQL Statement using string block. String block usually using "Double Quote" at the beginning and the end. Concat the variables with the string block.</li>
</ol>
<p><a href="https://i.stack.imgur.com/5UEVk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5UEVk.jpg" alt="Expression"></a></p>
<p>Click evaluate Expression, to showing result, to make sure your query is correct, copy-paste the Query result at SSMS. </p>
<p>Make sure by yourself that the variables is free from SQL Injection using your own logic. (Use your developer instinct)</p>
<ol start="4">
<li>Open the Data Flow Task, open the OLE DB Source Editor by double click the item.</li>
</ol>
<p><a href="https://i.stack.imgur.com/Vb3tM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vb3tM.jpg" alt="Data Flow"></a></p>
<ul>
<li>Select the Data Access Mode : <code>SQL Command From Variable</code></li>
<li>Select the Variable Name : <code>SQL_DTFLOW_FULL</code></li>
<li>Click Preview to make sure it works.</li>
</ul>
<p>That is all, my way to prevent this SSIS failure case. Since I use this way, I never got that problem, you know, SSIS something is weird.</p>
<p>To change the variable value, set it before Data Flow Task, the SQL Result of <code>SQL_DTFLOW_FULL</code> variable will changed every you change your variable value. </p>
| 8,290
|
<p>Is it possible to send an email from my Java application using a GMail account? I have configured my company mail server with Java app to send email, but that's not going to cut it when I distribute the application. Answers with any of using Hotmail, Yahoo or GMail are acceptable.</p>
|
<p>First download the <a href="https://java.net/projects/javamail/pages/Home" rel="noreferrer">JavaMail API</a> and make sure the relevant jar files are in your classpath.</p>
<p>Here's a full working example using GMail.</p>
<pre><code>import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class Main {
private static String USER_NAME = "*****"; // GMail user name (just the part before "@gmail.com")
private static String PASSWORD = "********"; // GMail password
private static String RECIPIENT = "lizard.bill@myschool.edu";
public static void main(String[] args) {
String from = USER_NAME;
String pass = PASSWORD;
String[] to = { RECIPIENT }; // list of recipient email addresses
String subject = "Java send mail example";
String body = "Welcome to JavaMail!";
sendFromGMail(from, pass, to, subject, body);
}
private static void sendFromGMail(String from, String pass, String[] to, String subject, String body) {
Properties props = System.getProperties();
String host = "smtp.gmail.com";
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", pass);
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props);
MimeMessage message = new MimeMessage(session);
try {
message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = new InternetAddress[to.length];
// To get the array of addresses
for( int i = 0; i < to.length; i++ ) {
toAddress[i] = new InternetAddress(to[i]);
}
for( int i = 0; i < toAddress.length; i++) {
message.addRecipient(Message.RecipientType.TO, toAddress[i]);
}
message.setSubject(subject);
message.setText(body);
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
catch (AddressException ae) {
ae.printStackTrace();
}
catch (MessagingException me) {
me.printStackTrace();
}
}
}
</code></pre>
<p>Naturally, you'll want to do more in the <code>catch</code> blocks than print the stack trace as I did in the example code above. (Remove the <code>catch</code> blocks to see which method calls from the JavaMail API throw exceptions so you can better see how to properly handle them.)</p>
<hr>
<p>Thanks to <a href="https://stackoverflow.com/users/4223/jodonnell">@jodonnel</a> and everyone else who answered. I'm giving him a bounty because his answer led me about 95% of the way to a complete answer.</p>
|
<p>An easy route would be to have the gmail account configured/enabled for POP3 access. This would allow you to send out via normal SMTP through the gmail servers. </p>
<p>Then you'd just send through smtp.gmail.com (on port 587)</p>
| 6,882
|
<p>I have created a custom dialog for Visual Studio Setup Project using the steps described
<a href="http://www.codeproject.com/KB/install/vsSetupCustomDialogs.aspx?fid=419622&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2640482&fr=26" rel="nofollow noreferrer">here</a></p>
<p>Now I have a combobox in one of my dialogs. I want to populate the combobox with a list of all SQL Server instances running on the local network. It's trivial to get the server list ... but I'm completely lost on how to make them display in the combobox. I would appreciate your help and some code might also be nice as I'm beginner :).</p>
|
<p>I've always found the custom dialogs in visual studio setup projects to be woefully limited and barely functional.</p>
<p>By contrast, I normally create custom actions that display winforms gui's for any remotely difficult tasks during setup. Works really well and you can do just about anything you want by creating a custom action and passing a few parameters across.</p>
<p>In the dayjob we built a collection of common custom actions for tasks like application config and database creation / script execution to get around custom dialog limitations.</p>
|
<p>I guess you'll have to go beyond the out-of-the-box setup and deployment package and try a third party app.</p>
<p>You may want to look at:</p>
<ul>
<li><a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">Wix</a></li>
<li><a href="http://nsis.sourceforge.net/Main_Page" rel="nofollow noreferrer">Nullsoft Scriptable Install System</a></li>
</ul>
<p>Both are free; they might give you the customization that you need.</p>
| 3,256
|
<p>I'm building an automatic warehouse system using three NEMA 17 stepper motor. </p>
<p>My problem is to move the motors with precision, since I do not have any kind of encoder on the motor and so I cannot know the position of the axes. I thought that the system could be similar to a 3D printer, since neither 3d printers have encoder on the motor. </p>
<p>Where can I find a sketch for Arduino of a 3D printer, to understand how they work? How do they move with such precision without any kind of sensor?</p>
|
<p>[For now] most of the open source 3d printer firmware written for Arduino-based hardware. This means you can just download the source and look through the relevant pieces of code.</p>
<p><a href="https://github.com/MarlinFirmware/Marlin" rel="nofollow noreferrer">Marlin</a> is the most obvious example.</p>
|
<p>A stepper motor is different from a typical electric motor. Instead of being "on" or "off", or running a some approximate variable speed, the controller sends a series of pulses to drive the motor one step at a time. This can be driven forward or backwards.</p>
<p>Based on how the motor and machine is designed, the machine will move a tiny amount. If for example, one step moves , say 0.1mm. If you send 150 pulses in the forward direction, the machine will move 15.0mm If you then send another 8 pulses in the reverse direction, the machine will be 14.2mm from the starting point.</p>
<p>To know the absolute position, you need to establish the starting point. Most printers have limit switches at their "home" position. To initialize the position, drive the motor until it hits the switch, and then set position as zero.</p>
<p>Then count the pulses up and down as you send them, you will will keep track of the machine's position.</p>
| 540
|
<p>I'm a new Windows programmer and I'm not sure where I should store user configurable application settings. I understand the need to provide a user friendly means for the user to change application settings, like an Edit | Settings form or similar. But where should I store the values after the user hits the Apply button on that form? </p>
<p>What are the pros and cons of storing settings in the Windows registry vs. storing them in a local INI file or config file or similar?</p>
|
<p><strong>Pros of config file:</strong> </p>
<ol>
<li>Easy to do. Don't need to know any Windows API calls. You just need to know the file I/O interface of your programming language. </li>
<li>Portable. If you port your application to another OS, you don't need to change your settings format. </li>
<li>User-editable. The user can edit the config file outside of the program executing.</li>
</ol>
<p><strong>Pros of registry:</strong> </p>
<ol>
<li>Secure. The user can't accidentally delete the config file or corrupt the data unless he/she knows about regedit. And then the user is just asking for trouble. </li>
<li>I'm no expert Windows programmer, but I'm sure that using the registry makes it easier to do other Windows-specific things (user-specific settings, network administration stuff like group policy, or whatever else).</li>
</ol>
<p>If you just need a simple way to store config information, I would recommend a config file, using INI or XML as the format. I suggest using the registry only if there is something specific you want to get out of using the registry.</p>
|
<p>There is one drawback to ini or config files and that is locating them if the user has the option to select where the program is installed.</p>
| 2,831
|
<p>I'd like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs.
It seems the best version number to use would just be the current revision number from Subversion. Is there an easy way to hook this number into a (C++ in my case) header file or something, which I can then get at in code? I guess this is a post commit hook or something?</p>
<p>Does anyone have any experience of implementing this (with code to share, please?), or can suggest a better alternative?
Thanks.</p>
|
<p>Two ways:</p>
<p>Embed <em>$Id$</em> or <em>$Revision$</em> within the code. Then set <em>svn:keywords="Id Revision"</em> property on the file. This will give you the last modified revision of that source file. Good for smaller projects and scripts.</p>
<p>Alternatively, use a Makefile driven process and the command line tool svnversion. (Language specific - this should work for C/C++)</p>
<pre><code>echo -n "#define VERSION 1.0.1-" > version.h
svnversion -n . >> version.h
</code></pre>
<p>Or some more complex build script with sed and version.h.in. Then just <em>#include version.h</em></p>
<p>That will give you the repository version number, which will change with every commit / update, and is probably a more appropriate version number for most projects.</p>
<p>Note: I also used a human readable version string that I manually update. The example would give: <strong>Version: 1.0.1-r13445</strong> </p>
<p>~J</p>
|
<p>A good up-to-date solution:</p>
<p>Create a <code>Makefile</code> containing the following line (in the same folder as <code>YourFile.dox</code>):</p>
<pre><code>sed "s~RevNumber~$(shell svnversion ../)~g" YourFile.dox > YourFileDummy.dox; doxygen YourFileDummy.dox
</code></pre>
<p>And <code>YourFile.dox</code> should contain this:</p>
<pre><code>...
PROJECT_NUMBER = "Revision RevNumber"
...
</code></pre>
<p>Now:</p>
<ol>
<li><code>sed</code> replaces <code>RevNumber</code> in the .dox with the output of <code>svnversion</code> (executed in the main folder of your repository) and saves the modified file to <code>YourFileDummy.dox</code></li>
<li><code>doxygen</code> is executed on <code>YourFileDummy.dox</code> to generate the documentation</li>
<li>Your documentation will now contain the revision number!</li>
</ol>
| 3,697
|
<p>I just purchased an <a href="https://www.anycubic.com/products/anycubic-photon-3d-printer" rel="nofollow noreferrer">Anycubic Photon 3S</a> LCD-based SLA 3D printer. I understand the need for cleaning and curing parts after printing. While the device is in transit, I'm looking to set up a workstation to use it with.</p>
<p>Are there any recommendations for accessories to buy?: Particular containers to store materials in, particular products for cleaning prints (or cleaning the machine), particular lamps for curing, etc.</p>
<p>I'm trying to avoid gotchas, and I've got time to visit hardware stores or make further online purchases before it arrives. I'm not asking about software or computing hardware, just things that I'll want to have "on the bench".</p>
|
<h1>Safety Gear</h1>
<p>Gloves, you want to wear them whenever handling any resin. Single-use gloves are best - dispose of them after use. Consider them contaminated after touching anything in contact with resin and toss them before handling anything that shall not get in contact with resin. That includes door handles.</p>
<p>A good idea is to also wear eye protection, as resin in the eyes could destroy them.</p>
<p>While a dust mask might not be strictly necessary, it could reduce your exposure to the fumes of resin. Some resin fumes are known to create hypersensitivity.</p>
<p>It is also a good idea to put the printer into a dedicated workspace that is well ventilated and not your primary living space. I strongly recommend reading both <a href="https://3dprinting.stackexchange.com/questions/8594/best-way-to-deal-with-resin-printers-in-your-living-space">Best way to deal with Resin Printers in your living space</a> and <a href="https://3dprinting.stackexchange.com/questions/7305/safe-way-of-disposing-resin/7307#7307">Safe way of disposing resin</a></p>
<h1>Post-Processing Station</h1>
<p>You may want to build a post-processing station. Most pieces can be sourced in any home depot store or made from household items, so I don't recommend specific brands but the requirements.</p>
<h3>Washing Station</h3>
<p>A typical post-processing station consists of at least 2 vats large enough to submerge your print volume in, so you can wash off your print in the first and then wash it with fresh liquid in the second. The typical liquids for cleaning are isopropyl alcohol and sometimes technical alcohol. Some resins demand special liquids that are specific to the type of resin. Best, the washing vats have securely sealing lids. Glass is preferably as it is easy to clean.</p>
<p>To use the least amount of cleaning liquid, you might want to have a pair of <a href="https://www.google.com/search?q=needle%20spray%20bottle" rel="nofollow noreferrer">needle spray bottles</a> - one for each bath. Label them!</p>
<p>To avoid spillage and ruining tables, a plastic table cloth can be a good addition. Fold it with the contaminated side onto itself for storage. A different solution would be to put the cleaning station onto a ceramic or steel surface, which can be easily cleaned after use.</p>
<h3>Curing Station/Chamber</h3>
<p>The next step is curing the print under direct exposure to a UV light source, somewhat akin to how gel nails are hardened. Sometimes the sun is enough.</p>
<p>Since the resin residue from washing is now in the isopropyl alcohol (or other washing liquid), treat it as chemical waste. To reduce the waste of material, flock out the resin in it by exposing the liquid to the UV light and filter the result. The result is Isopropyl Alcohol with some remaining contaminants, which can be used again for the first rinsing step.</p>
<h1>Other Tools</h1>
<p>Besides cleaning and curing the print, you need to remove the print from the plate, so you need a spatula or scraper, which is reserved only for your SLA printer. Never use it on the build platform of your FDM printers and consider it contaminated with uncured resin after use. Best cure residue on it in the UV chamber and then physically chip off the hardened resin before handling it without gloves again.</p>
<p>Similarly, a tool to stir the resin and remove flakes is often used, and some makers have special spatulas to clean the vat. Clean them well after use.</p>
<p>You will want to have some nice snippets to remove the support structures at some spots and some pliers to break them free - safety first.</p>
<p>Needle files and sanding paper for cleanup where the support stuck are a given.</p>
<h1>Resin Recovery</h1>
<p>Since the resin in the trays might harden over time, you'll want to have some sort of rig to hold the vat at a tilted angle upside down so it can flow out, back into the resin bottle. A cover might also help to reduce exposure and allow short time storage in the machine. <a href="https://www.thingiverse.com/search?q=resin%20vat&dwh=475d8d188363603" rel="nofollow noreferrer">Thingieverse has a couple of solutions</a> for lids, pouring and filtering stations as well as other accessories. Look for those that fit your printer.</p>
<p>The Resin should be stored in airtight and light-blocking bottles. As an extra security measure, you should store the resin in a closed cupboard to prevent light exposure through not totally opaque bottles.</p>
<p>More on Re-using resin can be found <a href="https://3dprinting.stackexchange.com/questions/14497/left-over-photopolymer-resins/14500#14500">here</a></p>
<h2>Further Reading/watching</h2>
<ul>
<li><a href="https://www.youtube.com/watch?v=7kHcsTG9QsM" rel="nofollow noreferrer">Angus/Makers Muse on 3D printing safety</a></li>
<li><a href="https://www.wargaming3d.com/2018/12/31/the-complete-and-utter-idiots-guide-to-3d-printing-in-resin-for-wargamers/" rel="nofollow noreferrer">A rather good guide regarding Resin 3D printing</a></li>
</ul>
|
<p>I would recommend a tub for cleaning the print, some funnels to get leftover resin back into the bottel, gloves, since you really don't want to get any uncured resin on your skin and a strong UV light for finishing the curing process after the cleaning</p>
| 1,474
|
<p>I wrote a simple Windows Forms program in C#. I want to be able to input a windows user name and password and when I click a login button to run code run as the user I've entered as input.</p>
|
<p>You can use the WindowsIdentity.Impersonate method to
achieve this. This method allows code to impersonate a different Windows
user. Here is a link for more information on this method with a good sample:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity.impersonate.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity.impersonate.aspx</a></p>
<p>Complete example:</p>
<pre><code>// This sample demonstrates the use of the WindowsIdentity class to impersonate a user.
// IMPORTANT NOTES:
// This sample can be run only on Windows XP. The default Windows 2000 security policy
// prevents this sample from executing properly, and changing the policy to allow
// proper execution presents a security risk.
// This sample requests the user to enter a password on the console screen.
// Because the console window does not support methods allowing the password to be masked,
// it will be visible to anyone viewing the screen.
// The sample is intended to be executed in a .NET Framework 1.1 environment. To execute
// this code in a 1.0 environment you will need to use a duplicate token in the call to the
// WindowsIdentity constructor. See KB article Q319615 for more information.
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Security.Permissions;
using System.Windows.Forms;
[assembly:SecurityPermissionAttribute(SecurityAction.RequestMinimum, UnmanagedCode=true)]
[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum, Name = "FullTrust")]
public class ImpersonationDemo
{
[DllImport("advapi32.dll", SetLastError=true, CharSet = CharSet.Unicode)]
public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
[DllImport("kernel32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
private unsafe static extern int FormatMessage(int dwFlags, ref IntPtr lpSource,
int dwMessageId, int dwLanguageId, ref String lpBuffer, int nSize, IntPtr *Arguments);
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public extern static bool CloseHandle(IntPtr handle);
[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public extern static bool DuplicateToken(IntPtr ExistingTokenHandle,
int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);
// Test harness.
// If you incorporate this code into a DLL, be sure to demand FullTrust.
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public static void Main(string[] args)
{
IntPtr tokenHandle = new IntPtr(0);
IntPtr dupeTokenHandle = new IntPtr(0);
try
{
string userName, domainName;
// Get the user token for the specified user, domain, and password using the
// unmanaged LogonUser method.
// The local machine name can be used for the domain name to impersonate a user on this machine.
Console.Write("Enter the name of the domain on which to log on: ");
domainName = Console.ReadLine();
Console.Write("Enter the login of a user on {0} that you wish to impersonate: ", domainName);
userName = Console.ReadLine();
Console.Write("Enter the password for {0}: ", userName);
const int LOGON32_PROVIDER_DEFAULT = 0;
//This parameter causes LogonUser to create a primary token.
const int LOGON32_LOGON_INTERACTIVE = 2;
tokenHandle = IntPtr.Zero;
// Call LogonUser to obtain a handle to an access token.
bool returnValue = LogonUser(userName, domainName, Console.ReadLine(),
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,
ref tokenHandle);
Console.WriteLine("LogonUser called.");
if (false == returnValue)
{
int ret = Marshal.GetLastWin32Error();
Console.WriteLine("LogonUser failed with error code : {0}", ret);
throw new System.ComponentModel.Win32Exception(ret);
}
Console.WriteLine("Did LogonUser Succeed? " + (returnValue? "Yes" : "No"));
Console.WriteLine("Value of Windows NT token: " + tokenHandle);
// Check the identity.
Console.WriteLine("Before impersonation: "
+ WindowsIdentity.GetCurrent().Name);
// Use the token handle returned by LogonUser.
WindowsIdentity newId = new WindowsIdentity(tokenHandle);
WindowsImpersonationContext impersonatedUser = newId.Impersonate();
// Check the identity.
Console.WriteLine("After impersonation: "
+ WindowsIdentity.GetCurrent().Name);
// Stop impersonating the user.
impersonatedUser.Undo();
// Check the identity.
Console.WriteLine("After Undo: " + WindowsIdentity.GetCurrent().Name);
// Free the tokens.
if (tokenHandle != IntPtr.Zero)
CloseHandle(tokenHandle);
}
catch(Exception ex)
{
Console.WriteLine("Exception occurred. " + ex.Message);
}
}
}
</code></pre>
|
<p>Impersonate will change the Thread context. If you want to change the identity and launch a separate process, you will have to use runas command.</p>
<p>The .NET Developer's Guide to Windows Security by Keith Brown is an excellent read which describes all the security scenarios.
<a href="http://alt.pluralsight.com/wiki/default.aspx/Keith.GuideBook.HomePage" rel="nofollow noreferrer">Online version</a> is also available.</p>
| 7,104
|
<p>I have an Ender 3 and I'm experiencing an issue where it won't print on the edges. Near the outside of the bed plastic just peels away. Bed is level - verified multiple times.</p>
<p>The nozzle appears to be dragging the freshly extruded filament away before it has a chance to cool. Straight lines and wide curves print well about 30 % of the time, and sharp corners and curves won't print at all.</p>
<p>The printer works fine in the center, but the outer 3 cm or so are unusable. Not sure what could cause this. I leveled the bed multiple times - even told the printer to move without touching it, just to eliminate incorrect leveling by slight play in the rollers. Head is the same distance from the plate in the center as it is along the edges. No irregular high or low areas - bed is perfectly flat.</p>
<p>Is this a known issue with the Ender 3? How can it be fixed?</p>
<p>I am using the stock fiberglass bed with the BuildTak surface.</p>
|
<p>I used to have the same problem. Put masking or scotch tape on the bed, it should help with adhesion. I think the problem is that the bed is very dirty with finger grease and other things.</p>
|
<p>It sounds like it may be due to uneven heating. Check with an IR thermometer to make sure. If you're sure the bed is clean and has even heating, you may want to try a different surface. G10 is cheap and almost always perfectly flat.</p>
| 2,038
|
<p>How can I calculate the value of PI using C#?</p>
<p>I was thinking it would be through a recursive function, if so, what would it look like and are there any math equations to back it up?</p>
<p>I'm not too fussy about performance, mainly how to go about it from a learning point of view.</p>
|
<p>If you want recursion:</p>
<pre><code>PI = 2 * (1 + 1/3 * (1 + 2/5 * (1 + 3/7 * (...))))
</code></pre>
<p>This would become, after some rewriting:</p>
<pre><code>PI = 2 * F(1);
</code></pre>
<p>with F(i):</p>
<pre><code>double F (int i) {
return 1 + i / (2.0 * i + 1) * F(i + 1);
}
</code></pre>
<p>Isaac Newton (you may have heard of him before ;) ) came up with this trick.
Note that I left out the end condition, to keep it simple. In real life, you kind of need one.</p>
|
<pre><code>public double PI = 22.0 / 7.0;
</code></pre>
| 6,044
|
<p>This is a very specific question regarding <strong>MySQL</strong> as implemented in <strong>WordPress</strong>.</p>
<p>I'm trying to develop a plugin that will show (select) posts that have specific '<strong>tags</strong>' and belong to specific '<strong>categories</strong>' (both multiple)</p>
<p>I was told it's impossible because of the way categories and tags are stored:</p>
<ol>
<li><code>wp_posts</code> contains a list of posts, each post have an "ID"</li>
<li><code>wp_terms</code> contains a list of terms (both categories and tags). Each term has a TERM_ID</li>
<li><code>wp_term_taxonomy</code> has a list of terms with their TERM_IDs and has a Taxonomy definition for each one of those (either a Category or a Tag)</li>
<li><code>wp_term_relationships</code> has associations between terms and posts</li>
</ol>
<p>How can I join the tables to get all posts with tags "Nuclear" <strong>and</strong> "Deals" that also belong to the category "Category1"?</p>
|
<p>I misunderstood you. I thought you wanted Nuclear or Deals. The below should give you only Nuclear and Deals.</p>
<pre><code>select p.*
from wp_posts p, wp_terms t, wp_term_taxonomy tt, wp_term_relationship tr,
wp_terms t2, wp_term_taxonomy tt2, wp_term_relationship tr2
wp_terms t2, wp_term_taxonomy tt2, wp_term_relationship tr2
where p.id = tr.object_id and t.term_id = tt.term_id and tr.term_taxonomy_id = tt.term_taxonomy_id
and p.id = tr2.object_id and t2.term_id = tt2.term_id and tr2.term_taxonomy_id = tt2.term_taxonomy_id
and p.id = tr3.object_id and t3.term_id = tt3.term_id and tr3.term_taxonomy_id = tt3.term_taxonomy_id
and (tt.taxonomy = 'category' and tt.term_id = t.term_id and t.name = 'Category1')
and (tt2.taxonomy = 'post_tag' and tt2.term_id = t2.term_id and t2.name = 'Nuclear')
and (tt3.taxonomy = 'post_tag' and tt3.term_id = t3.term_id and t3.name = 'Deals')
</code></pre>
|
<p>Thanks @Eric it works! Just a few code corrections for future reference:</p>
<ul>
<li>the first select statements misses a coma after wp_term_relationship tr2</li>
<li>In the same select statemt the following must be change:</li>
</ul>
<pre><code>wp_terms t2, wp_term_taxonomy tt2, wp_term_relationship
tr2</code></pre>
<p>should be</p>
<pre><code>wp_terms t3, wp_term_taxonomy tt3, wp_term_relationship
tr3</code></pre>
| 4,783
|
<p>I work a lot with network and serial communications software, so it is often necessary for me to have code to display or log hex dumps of data packets.</p>
<p>Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there somewhere?</p>
<p>Features I'd like:</p>
<ul>
<li>N bytes per line (where N is somehow configurable)</li>
<li>optional ASCII/UTF8 dump alongside the hex</li>
<li>configurable indentation, per-line prefixes, per-line suffixes, etc.</li>
<li>minimal dependencies (ideally, I'd like the code to all be in a header file, or be a snippet I can just paste in)</li>
</ul>
<p><strong>Edit:</strong> Clarification: I am looking for code that I can easily drop in to my own programs to write to stderr, stdout, log files, or other such output streams. I'm not looking for a command-line hex dump utility.</p>
|
<p>I often use this little snippet I've written long time ago. It's short and easy to add anywhere when debugging etc...</p>
<pre><code>#include <ctype.h>
#include <stdio.h>
void hexdump(void *ptr, int buflen) {
unsigned char *buf = (unsigned char*)ptr;
int i, j;
for (i=0; i<buflen; i+=16) {
printf("%06x: ", i);
for (j=0; j<16; j++)
if (i+j < buflen)
printf("%02x ", buf[i+j]);
else
printf(" ");
printf(" ");
for (j=0; j<16; j++)
if (i+j < buflen)
printf("%c", isprint(buf[i+j]) ? buf[i+j] : '.');
printf("\n");
}
}
</code></pre>
|
<p><a href="http://gd.tuwien.ac.at/linuxcommand.org/man_pages/xxd1.html" rel="nofollow noreferrer">xxd</a> is the 'standard' hex dump util and looks like it should solve your problems</p>
| 4,889
|
<p>I am using Windows, and I have two monitors.</p>
<p>Some applications will <em>always</em> start on my primary monitor, no matter where they were when I closed them.</p>
<p>Others will always start on the <em>secondary</em> monitor, no matter where they were when I closed them.</p>
<p>Is there a registry setting buried somewhere, which I can manipulate to control which monitor applications launch into by default?</p>
<p>@rp: I have Ultramon, and I agree that it is indispensable, to the point that Microsoft should buy it and incorporate it into their OS. But as you said, it doesn't let you control the default monitor a program launches into.</p>
|
<p>Correctly written Windows apps that want to save their location from run to run will save the results of <a href="http://msdn.microsoft.com/ru-ru/library/windows/desktop/ms633518%28v=vs.85%29.aspx" rel="noreferrer"><code>GetWindowPlacement()</code></a> before shutting down, then use <code>SetWindowPlacement()</code> on startup to restore their position.</p>
<p>Frequently, apps will store the results of <code>GetWindowPlacement()</code> in the registry as a <code>REG_BINARY</code> for easy use.</p>
<p>The <code>WINDOWPLACEMENT</code>route has many advantages over other methods:</p>
<ul>
<li>Handles the case where the screen resolution changed since the last run: <code>SetWindowPlacement()</code> will automatically ensure that the window is not entirely offscreen</li>
<li>Saves the state (minimized/maximized) but also saves the restored (normal) size and position</li>
<li>Handles desktop metrics correctly, compensating for the taskbar position, etc. (i.e. uses "workspace coordinates" instead of "screen coordinates" -- techniques that rely on saving screen coordinates may suffer from the "walking windows" problem where a window will always appear a little lower each time if the user has a toolbar at the top of the screen).</li>
</ul>
<p>Finally, programs that handle window restoration properly will take into account the <code>nCmdShow</code> parameter passed in from the shell. This parameter is set in the shortcut that launches the application (Normal, Minimized, Maximize):</p>
<pre><code>if(nCmdShow != SW_SHOWNORMAL)
placement.showCmd = nCmdShow; //allow shortcut to override
</code></pre>
<p>For non-Win32 applications, it's important to be sure that the method you're using to save/restore window position eventually uses the same underlying call, otherwise (like Java Swing's <code>setBounds()</code>/<code>getBounds()</code> problem) you'll end up writing a lot of extra code to re-implement functionality that's already there in the <code>WINDOWPLACEMENT</code> functions.</p>
|
<p>Right click the shortcut and select properties.
Make sure you are on the "Shortcut" Tab.
Select the RUN drop down box and change it to Maximized. </p>
<p>This may assist in launching the program in full screen on the primary monitor. </p>
| 7,606
|
<p>While I don't think this is easily possible I am wondering if it can be done. So my spool of filament had a tangle and got pulled into the printer head. Some got melted together and after cutting I have a few strands. Would it be possible to mend the ends together to make one continuous strand instead of many small strand?</p>
|
<p>Sure, but you need to be careful not to have wide or narrow spots. A fixture for this is probably better than freehand welding.</p>
<p>See some ideas for a homemade fuser at <a href="https://rigid.ink/blogs/news/how-to-join-or-fuse-filament-together" rel="nofollow noreferrer">https://rigid.ink/blogs/news/how-to-join-or-fuse-filament-together</a> </p>
|
<p>As @davo says in his answer, this can be done rather easily, but the main problem with this kind of approach is reliability of the joint: sure, it must last only a short time, but during that time it will have to survive bending through your bowden tube (if applicable) and withstanding the grinding of the hobbed gear pushing it through the extruder.</p>
<p>I personally only used the <a href="https://youtu.be/7Vuh4Mwm_4k" rel="nofollow noreferrer">PTFE method (plus heat gun)</a>, which is substantially identical to the tinfoil one outlined in the link provided by @davo but here's a couple of observations:</p>
<ul>
<li><strong>Freshly cut filament seem to work best</strong>. I guess this is because there is less chances for contaminants like dust, skin oil etc... to find their way to the surfaces you are trying to bond.</li>
<li>I had <strong>no problem melting together PLAs of different brands</strong>.</li>
<li><strong>You may have to tune the flow "on the fly" via the knob on the printer</strong> to accommodate for different diameters between the two spools you spliced (not applicable to your specific case of "plastic surgery" (pun intended!) on the same spool.</li>
<li>I find the bond <strong>works best if the two filaments are cut at an angle</strong> (so that the actual bonding surface is larger)</li>
<li>A <strong>light sanding to smooth out any seam and reduce the diameter</strong> of melted part a bit is in order</li>
</ul>
| 825
|
<p>I've heard that <code>SELECT *</code> is generally bad practice to use when writing SQL commands because it is more efficient to <code>SELECT</code> columns you specifically need.</p>
<p>If I need to <code>SELECT</code> every column in a table, should I use </p>
<pre><code>SELECT * FROM TABLE
</code></pre>
<p>or </p>
<pre><code>SELECT column1, colum2, column3, etc. FROM TABLE
</code></pre>
<p>Does the efficiency really matter in this case? I'd think <code>SELECT *</code> would be more optimal internally if you really need all of the data, but I'm saying this with no real understanding of database.</p>
<p>I'm curious to know what the best practice is in this case.</p>
<p><strong>UPDATE:</strong> I probably should specify that the only situation where I would really <em>want</em> to do a <code>SELECT *</code> is when I'm selecting data from one table where I know all columns will always need to be retrieved, even when new columns are added. </p>
<p>Given the responses I've seen however, this still seems like a bad idea and <code>SELECT *</code> should never be used for a lot more technical reasons that I ever though about.</p>
|
<p>One reason that selecting specific columns is better is that it raises the probability that SQL Server can access the data from indexes rather than querying the table data. </p>
<p>Here's a post I wrote about it: <a href="http://weblogs.asp.net/jgalloway/archive/2007/07/18/the-real-reason-select-queries-are-bad-index-coverage.aspx" rel="noreferrer"><strong>The real reason select queries are bad index coverage</strong></a> </p>
<p>It's also less fragile to change, since any code that consumes the data will be getting the same data structure regardless of changes you make to the table schema in the future.</p>
|
<p>There can be a huge performance gain by limiting what columns are returned if the records are traversing the internet.</p>
| 9,125
|
<p>I've been using PHP for too long, but I'm new to JavaScript integration in some places. </p>
<p>I'm trying to find the fastest way to pass database information into a page where it can be modified and displayed dynamically in JavaScript. </p>
<p>Right now, I'm looking at loading a <em>JSON with PHP</em> echo statements because it's fast and effective, but I saw that I could use PHP's JSON library (PHP 5.2). </p>
<p><strong>Has anybody tried the new JSON library, and is it better than my earlier method?</strong></p>
|
<p>Use the library. If you try to generate it manually, I predict with 99% certainty that the resulting text will be invalid in some way. Especially with more esoteric features like Unicode strings or exponential notation.</p>
|
<p>Library has worked great for me. FWIW I needed to do this on a project with earlier version of PHP lacking JSON support. Function below worked as a granted risky version of "json_encode" for arrays of strings.</p>
<pre><code>function my_json_encode($row) {
$json = "{";
$keys = array_keys($row);
$i=1;
foreach ($keys as $key) {
if ($i>1) $json .= ',';
$json .= '"'.addslashes($key).'":"'.addslashes($row[$key]).'"';
$i++;
}
$json .= "}";
return $json;
}
</code></pre>
| 6,184
|
<p>Using the Apple OS X Cocoa framework, how can I post a <em>sheet</em> (slide-down modal dialog) on the window of another process? </p>
<p><strong>Edit:</strong> Clarified a bit:</p>
<p>My application is a Finder extension to do Subversion version control (<a href="http://scplugin.tigris.org/" rel="nofollow noreferrer">http://scplugin.tigris.org/</a>). Part of my application is a plug-in (a Contextual Menu Item for Finder); the bulk of my application, however, is in a separate daemon proces. For several reasons, we've chosen to put virtually all the code into the daemon; the plug-in only defines the menu itself, and Apple-Events over to the Daemon.</p>
<p>Sometimes, the daemon needs to prompt the user for further information. It can toss a window on-screen for this, but that's disruptive (randomly positioned), and it seems to me the work flow here is legitimately modal, for example "select a file, pick 'commit' from the menu, provide commit comments, do the operation."</p>
<p>Interprocess cooperation (such as passing a reference of some kind) is acceptable: both processes are mine, but I want to avoid binding the sheet's code into the primary process.</p>
|
<p>Really, it sounds like you're trying to have your inter-process communication happen at the view level, which isn't really how Cocoa generally works. Things will be much easier if you separate your layers a bit more than that.</p>
<p>Why don't you want to put the sheet code into the other process? It's view code, and view code is inherently process-specific. The right thing to do here is probably to add somewhat generic modal-sheet support to your plugin code, and an IPC call that your daemon can make to summon that code. Trying to ship view objects over to the remote process is going to be nightmarish if you can make it work at all.</p>
<p>You're fighting the frameworks with this approach.</p>
|
<p>Please don't do this. Make the interaction nonmodal if at all possible. Especially in something like a commit, it's much nicer to be able to browse around your files while you're writing commit comments.</p>
<p>OS X does have window groups, but I don't think they can (easily) span applications.</p>
| 9,108
|
<p>I have a structure in C#:</p>
<pre><code>public struct UserInfo
{
public string str1
{
get;
set;
}
public string str2
{
get;
set;
}
}
</code></pre>
<p>The only rule is that <code>UserInfo(str1="AA", str2="BB").Equals(UserInfo(str1="BB", str2="AA"))</code></p>
<p>How to override the GetHashCode function for this structure? </p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx" rel="noreferrer">MSDN</a>:</p>
<p>A hash function must have the following properties:</p>
<blockquote>
<ul>
<li>If two objects compare as equal, the <code>GetHashCode</code> method for each object must return the same value. However, if two objects do not compare as equal, the <code>GetHashCode</code> methods for the two object do not have to return different values.</li>
<li>The <code>GetHashCode</code> method for an object must consistently return the same hash code as long as there is no modification to the object state that determines the return value of the object's <code>Equals</code> method. Note that this is true only for the current execution of an application, and that a different hash code can be returned if the application is run again.</li>
<li>For the best performance, a hash function must generate a random distribution for all input. </li>
</ul>
</blockquote>
<p>Taking it into account correct way is:</p>
<pre><code>return str1.GetHashCode() ^ str2.GetHashCode()
</code></pre>
<p><code>^</code> can be substituted with other commutative operation</p>
|
<p>Too complicated, and forgets nulls, etc. This is used for things like bucketing, so you can get away with something like</p>
<pre><code>if (null != str1) {
return str1.GetHashCode();
}
if (null != str2) {
return str2.GetHashCode();
}
//Not sure what you would put here, some constant value will do
return 0;
</code></pre>
<p>This is biased by assuming that str1 is not likely to be common in an unusually large proportion of instances.</p>
| 9,566
|
<p>I wondered if anyone uses virtualized desktop PCs (running WinXP Pro or older) to have some old applications that are seldom used available for some ongoing tasks.</p>
<p>Say you have a really old project that every once in a while needs a document update in a database system or something like that. The database application is running on a virtualized desktop that is only started when needed.</p>
<p>I think we could save energy, hardware and space if we would virtualize some of those old boxes. Any setups in your company?</p>
<hr />
<p><strong>edit</strong> Licensing could be of concern, but I guess you have a valid license for the old desktop box. Maybe the license isn't valid in a VM environment, I'd definitly check that before.</p>
<p>Sure enough, if the application is performance critic, virtualization could hurt. But I'm thinking about some kind of outdated application that is still used to perform, say a calculation every 12 weeks for a certain customer/service.</p>
|
<p>I use virtualized desktops for:</p>
<ul>
<li>Support that requires VPN software I do not want on my own desktop. This also lets a whole team share the support computer for a specific customer. </li>
<li>A legacy system which we use several different versions of (depending on customer's version) and they're not really compatible so its good to have a virtualized desktop for each version.</li>
</ul>
|
<p>We use virtualisation to test on a variety of Operating Systems - the server application runs under linux, and we have a production (real) server, and a couple of test servers, which are all VMs.</p>
<p>The client runs under Windows, which, being an OS X user I have to run in a VM, and the other developer I work with runs an XP VM on his 8-core Vista box.</p>
<p>(I also have a seperate VM for running CAD software, but that's not <em>really</em> programming)</p>
| 4,000
|
<p>How do I find duplicate addresses in a database, or better stop people already when filling in the form ? I guess the earlier the better?</p>
<p>Is there any good way of abstracting street, postal code etc so that typos and simple attempts to get 2 registrations can be detected? like: </p>
<pre><code>Quellenstrasse 66/11
Quellenstr. 66a-11
</code></pre>
<p>I'm talking German addresses...
Thanks!</p>
|
<p>The earlier you can stop people, the easier it'll be in the long run! </p>
<p>Not being too familiar with your db schema or data entry form, I'd suggest a route something like the following:</p>
<ul>
<li><p>have distinct fields in your db for each address "part", e.g. street, city, postal code, Länder, etc.</p></li>
<li><p>have your data entry form broken down similarly, e.g. street, city, etc</p></li>
</ul>
<p>The reasoning behind the above is that each part will likely have it's own particular "rules" for checking slightly-changed addressed, ("Quellenstrasse"->"Quellenstr.", "66/11"->"66a-11" above) so your validation code can check if the values as presented for each field exist in their respective db field. If not, you can have a class that applies the transformation rules for each given field (e.g. "strasse" stemmed to "str") and checks again for duplicates.</p>
<p>Obviously the above method has it's drawbacks:</p>
<ul>
<li><p>it can be slow, depending on your data set, leaving the user waiting</p></li>
<li><p>users may try to get around it by putting address "Parts" in the wrong fields (appending post code to city, etc).
but from experience we've found that introducing even simple checking like the above will prevent a large percentage of users from entering pre-existing addresses.</p></li>
</ul>
<p>Once you've the basic checking in place, you can look at optimising the db accesses required, refining the rules, etc to meet your particular schema. You might also take a look at <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html#function_match" rel="noreferrer">MySQL's match() function</a> for working out similar text.</p>
|
<p>In my opinion, assuming that you already had a lot of dirty data in your DB, </p>
<p>You have to do build your "handmade" dirty filter which may detect a maximum of german abreviation ... </p>
<p>But If you treat a lot of data, you will take the risk to find some false-positive and true-negative sample...</p>
<p>Finally a semi automated job (machine with human assist when probability of a case of false-positive or true-negative is too high) will be the best solution.</p>
<p>More you treat "exception" (because human raise exception when filling data), more your "handmade" filter will fit your requierement.</p>
<p>In the other hand, you may also use a germany address verification service on user side, and store only the verified one...</p>
| 5,831
|
<p>Say I have a linked list of numbers of length <code>N</code>. <code>N</code> is very large and I don’t know in advance the exact value of <code>N</code>. </p>
<p>How can I most efficiently write a function that will return <code>k</code> completely <em>random numbers</em> from the list?</p>
|
<p>There's a very nice and efficient algorithm for this using a method called <strong>reservoir sampling</strong>.</p>
<p>Let me start by giving you its <strong>history</strong>:</p>
<p><strong>Knuth</strong> calls this Algorithm R on p. 144 of his 1997 edition of Seminumerical Algorithms (volume 2 of The Art of Computer Programming), and provides some code for it there. Knuth attributes the algorithm to Alan G. Waterman. Despite a lengthy search, I haven't been able to find Waterman's original document, if it exists, which may be why you'll most often see Knuth quoted as the source of this algorithm.</p>
<p><strong>McLeod and Bellhouse, 1983</strong> (1) provide a more thorough discussion than Knuth as well as the first published proof (that I'm aware of) that the algorithm works.</p>
<p><strong>Vitter 1985</strong> (2) reviews Algorithm R and then presents an additional three algorithms which provide the same output, but with a twist. Rather than making a choice to include or skip each incoming element, his algorithm predetermines the number of incoming elements to be skipped. In his tests (which, admittedly, are out of date now) this decreased execution time dramatically by avoiding random number generation and comparisons on each in-coming number.</p>
<p>In <strong>pseudocode</strong> the algorithm is:</p>
<pre><code>Let R be the result array of size s
Let I be an input queue
> Fill the reservoir array
for j in the range [1,s]:
R[j]=I.pop()
elements_seen=s
while I is not empty:
elements_seen+=1
j=random(1,elements_seen) > This is inclusive
if j<=s:
R[j]=I.pop()
else:
I.pop()
</code></pre>
<p>Note that I've specifically written the code to avoid specifying the size of the input. That's one of the cool properties of this algorithm: you can run it without needing to know the size of the input beforehand and it <em>still</em> assures you that each element you encounter has an equal probability of ending up in <code>R</code> (that is, there is no bias). Furthermore, <code>R</code> contains a fair and representative sample of the elements the algorithm has considered at all times. This means you can use this as an <a href="https://en.wikipedia.org/wiki/Online_algorithm" rel="noreferrer">online algorithm</a>.</p>
<p><strong>Why does this work?</strong></p>
<p>McLeod and Bellhouse (1983) provide a proof using the mathematics of combinations. It's pretty, but it would be a bit difficult to reconstruct it here. Therefore, I've generated an alternative proof which is easier to explain.</p>
<p>We proceed via proof by induction.</p>
<p>Say we want to generate a set of <code>s</code> elements and that we have already seen <code>n>s</code> elements.</p>
<p>Let's assume that our current <code>s</code> elements have already each been chosen with probability <code>s/n</code>.</p>
<p>By the definition of the algorithm, we choose element <code>n+1</code> with probability <code>s/(n+1)</code>.</p>
<p>Each element already part of our result set has a probability <code>1/s</code> of being replaced.</p>
<p>The probability that an element from the <code>n</code>-seen result set is replaced in the <code>n+1</code>-seen result set is therefore <code>(1/s)*s/(n+1)=1/(n+1)</code>. Conversely, the probability that an element is not replaced is <code>1-1/(n+1)=n/(n+1)</code>.</p>
<p>Thus, the <code>n+1</code>-seen result set contains an element either if it was part of the <code>n</code>-seen result set and was not replaced---this probability is <code>(s/n)*n/(n+1)=s/(n+1)</code>---or if the element was chosen---with probability <code>s/(n+1)</code>.</p>
<p>The definition of the algorithm tells us that the first <code>s</code> elements are automatically included as the first <code>n=s</code> members of the result set. Therefore, the <code>n-seen</code> result set includes each element with <code>s/n</code> (=1) probability giving us the necessary base case for the induction.</p>
<p><strong>References</strong></p>
<ol>
<li><p>McLeod, A. Ian, and David R. Bellhouse. "A convenient algorithm for drawing a simple random sample." Journal of the Royal Statistical Society. Series C (Applied Statistics) 32.2 (1983): 182-184. (<a href="http://www.jstor.org/stable/10.2307/2347297" rel="noreferrer">Link</a>)</p></li>
<li><p>Vitter, Jeffrey S. "Random sampling with a reservoir." ACM Transactions on Mathematical Software (TOMS) 11.1 (1985): 37-57. (<a href="http://www.mathcs.emory.edu/~cheung/Courses/584-StreamDB/Syllabus/papers/RandomSampling/1985-Vitter-Random-sampling-with-reservior.pdf" rel="noreferrer">Link</a>)</p></li>
</ol>
|
<p>Well, you do need to know what N is at runtime at least, even if this involves doing an extra pass over the list to count them. The simplest algorithm to do this is to just pick a random number in N and remove that item, repeated k times. Or, if it is permissible to return repeat numbers, don't remove the item.</p>
<p>Unless you have a VERY large N, and very stringent performance requirements, this algorithm runs with <code>O(N*k)</code> complexity, which should be acceptable.</p>
<p>Edit: Nevermind, Tom Hawtin's method is way better. Select the random numbers first, then traverse the list once. Same theoretical complexity, I think, but much better expected runtime.</p>
| 7,767
|
<p>Being relatively new to the .net game, I was wondering, has anyone had any experience of the pros / cons between the use of LINQ and what could be considered more traditional methods working with lists / collections? </p>
<p>For a specific example of a project I'm working on : a list of unique id / name pairs are being retrieved from a remote web-service.</p>
<ul>
<li>this list will change infrequently (once per day), </li>
<li>will be read-only from the point of view of the application where it is being used</li>
<li>will be stored at the application level for all requests to access</li>
</ul>
<p>Given those points, I plan to store the returned values at the application level in a singleton class.</p>
<p>My initial approach was to iterate through the list returned from the remote service and store it in a NameValueCollection in a singleton class, with methods to retrieve from the collection based on an id:</p>
<pre><code>sugarsoap soapService = new sugarsoap();
branch_summary[] branchList = soapService.getBranches();
foreach (branch_summary aBranch in branchList)
{
branchNameList.Add(aBranch.id, aBranch.name);
}
</code></pre>
<p>The alternative using LINQ is to simply add a method that works on the list directly once it has been retrieved:</p>
<pre><code>public string branchName (string branchId)
{
//branchList populated in the constructor
branch_summary bs = from b in branchList where b.id == branchId select b;
return branch_summary.name;
}
</code></pre>
<p>Is either better than the other - is there a third way? I'm open to all answers, for both approaches and both in terms of solutions that offer elegance, and those which benefit performance.</p>
|
<p>i dont think the linq you wrote would compile, it'd have to be</p>
<pre><code>public string branchName (string branchId)
{
//branchList populated in the constructor
branch_summary bs = (from b in branchList where b.id == branchId select b).FirstOrDefault();
return branch_summary == null ? null : branch_summary.name;
}
</code></pre>
<p>note the .FirstsOrDefault()</p>
<p>I'd rather use LINQ for the reason that it can be used in other places, for writing more complex filters on your data. I also think it's easier to read than NameValueCollection alternative.</p>
<p>that's my $0.02</p>
|
<p>I'm not sure a singleton class is absolutely necessary, do you absolutely need global access at all times? Is the list large? </p>
<p>I assume you will have a refresh method on the singleton class for when the properties need to change and also that you have some way of notifying the singleton to update when the list changes.</p>
<p>Both solutions are viable. I think LINQ will populate the collection faster in the constructor (but not noticeably faster). Traditional collection based approaches are fine. Personally, I would choose the LINQ version if only because it is new tech and I like to use it. Assuming your deployment environment has .NET 3.5...</p>
<p>Do you have a method on your webservice for getting branches by Id? That would be the third option if the branch info is needed infrequently.</p>
| 7,085
|
<p>Another thing I'm seeing with my new build.
Late in a small print, the unit appears to perform operations "out of order" occasionally. Here's a picture where it's running a layer across the model.<br>
<a href="https://i.stack.imgur.com/hGIJk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hGIJk.jpg" alt="enter image description here"></a></p>
<p>These "skips" can start in the middle of a line. It always comes back and fills them in before starting the next layer - more or less accurately. But from my very limited understanding of gcode, it doesn't seem like this should happen.</p>
<p>When watching the print closely, I'll occasionally see small glitches, where the head jogs very slightly as it runs a line across.</p>
<p>This was sliced with Cura - I'm going to try a different slicer and see if I get anything similar.
Thanks!</p>
|
<p>This is just your slicer doing this. If you inspect the G-code file, you will see that the printer is faithfully doing what the slicer told it to. Most slicers use a fairly simple heuristic for determining the order in which lines are processed, which sometimes comes up with sub-optimal solutions like these.</p>
|
<p>I have seen this in Cura 2.5 when selecting different printers, then altering the specifications to suit. Changing the printer seems to change the slicing behavior. As yet there is no specific printer set up in Cura for the MEGA so you will probably have to find something that fits your needs, unless someone has the full settings. For example, is the Machine Center at Zero? Maybe try the Prusa Mk2?</p>
| 475
|
<p>I have the following code:</p>
<pre><code>Dim obj As New Access.Application
obj.OpenCurrentDatabase (CurrentProject.Path & "\Working.mdb")
obj.Run "Routine"
obj.CloseCurrentDatabase
Set obj = Nothing
</code></pre>
<p>The problem I'm experimenting is a pop-up that tells me Access can't set the focus on the other database. As you can see from the code, I want to run a Subroutine in another mdb. Any other way to achieve this will be appreciated.</p>
<p>I'm working with MS Access 2003.</p>
<p>This is an intermittent error. As this is production code that will be run only once a month, it's extremely difficult to reproduce, and I can't give you the exact text and number at this time. It is the second month this happened.</p>
<p>I suspect this may occur when someone is working with this or the other database.</p>
<p>The dataflow is to update all 'projects' once a month in one database and then make this information available in the other database.</p>
<p>Maybe, it's because of the first line in the 'Routines' code:
If vbNo = MsgBox("Do you want to update?", vbYesNo, "Update") Then
Exit Function
End If</p>
<p>I'll make another subroutine without the MsgBox.</p>
<p>I've been able to reproduce this behaviour. It happens when the focus has to shift to the called database, but the user sets the focus ([ALT]+[TAB]) on the first database. The 'solution' was to educate the user.</p>
<hr>
<p>This is an intermittent error. As this is production code that will be run only once a month, it's extremely difficult to reproduce, and I can't give you the exact text and number at this time. It is the second month this happened.</p>
<p>I suspect this may occur when someone is working with this or the other database.</p>
<p>The dataflow is to update all 'projects' once a month in one database and then make this information available in the other database.</p>
<p>Maybe, it's because of the first line in the 'Routines' code:
If vbNo = MsgBox("Do you want to update?", vbYesNo, "Update") Then
Exit Function
End If</p>
<p>I'll make another subroutine without the MsgBox.</p>
<hr>
<p>I've tried this in our development database and it works. This doesn't mean anything as the other code also workes fine in development.</p>
|
<p>You could use <a href="http://msdn.microsoft.com/en-us/library/system.string.split.aspx" rel="noreferrer" title="String.Split method msdn reference">String.Split method</a>.</p>
<pre><code>class ExampleClass
{
public ExampleClass()
{
string exampleString = "there is a cat";
// Split string on spaces. This will separate all the words in a string
string[] words = exampleString.Split(' ');
foreach (string word in words)
{
Console.WriteLine(word);
// there
// is
// a
// cat
}
}
}
</code></pre>
<p>For more information see <a href="http://www.dotnetperls.com/split" rel="noreferrer" title="C# Split String Examples by Sam Allen">Sam Allen's article about splitting strings in c#</a> (Performance, Regex)</p>
|
<p>If you are using C# 3.5 you could write an extension method to System.String that does the splitting you need. You then can then use syntax:</p>
<pre><code>string.SplitByMyTokens();
</code></pre>
<p>More info and a useful example from MS here <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb383977.aspx</a></p>
| 9,581
|
<p>I have a very frustrating problem, my extruder clogs up pretty much immediately after cleaning it from the previous clog and I cannot figure out what the hell is going wrong.</p>
<p>I use a genuine E3D V6 in direct drive configuration (dual drive) and I print only PLA.
I have tried many nozzle offsets from the bed but because I have to test so frequently I am just printing in the air for now.</p>
<p>This is what I tried:</p>
<ul>
<li>To print using the following temperatures: 200, 205, 210 and 220 °C</li>
<li>Using different brands of PLA</li>
<li>Lubricating filament</li>
<li>Installing a filament dust cleaner</li>
<li>Using both Bowden and direct configurations (my retraction setting for my direct drive setup is 0.8 mm, I am not sure what I used for the bowden but because the tube was fairly short it was probably around 3 mm. However I am not even printing I am simply running and stopping the extruder stepper, I am not using any retraction at all right now)</li>
<li>Buying a brand new E3D V6</li>
<li>Trying both 12 V and 24 V heat cartridges (with the respective power supplies of course)</li>
<li>Checking the temperature with other sensors (yes the temperature is displayed correctly)</li>
<li>Using acetone baths to clean all parts.</li>
<li>Using stronger and weaker heat sink fans and fan options</li>
<li>Push the filament manually</li>
<li>Performing PID tunes</li>
</ul>
<p>Even after all that the extruder clogs up usually mere seconds after it has been fully cleaned and inspected before being re-assembled. I make sure there is no bit of plastic or dust/dirt present before I re-assemble the extruder. I also hot tighten the nozzle but I also tried to run it without doing it but it made no difference.</p>
<p>I would love some help with this problem because I am pulling my hair out figuring out why this keeps happening.</p>
|
<p>I have had one roll of filament that did this. I'd get a jam, clean it out, and immediately jam again.</p>
<p>I got the filament from a friend who had reported problems using it, but I thought, "I have a Prusa3D i3m3-mmu2, I can print with anything." Unfortunately, I could not.</p>
<p>I threw away the filament (first I've ever jetisoned so callously), replaced the nozzle, and was back in business.</p>
<p>So, some filament just doesn't work.</p>
<p>But, there is another possible problem to check -- you might have a problem with stepper driver. Even with low current from a blown driver or badly adjusted driver, the extruder motor may spin. It may even be able to extrude filament into the air through the hot nozzle. But, the torque may not be sufficient to force the molten plastic as it pushes against the build plate. </p>
<p>Pushing the molten plastic against the build plate so that it "smooshes" well requires pressure, which comes from the push on the filament from the extruder gear, which comes from the torque of the motor, which comes from the current from the driver, which may be either blown or seriously mal-adjusted.</p>
|
<p>It turned out that the stepper driver on my duet 2 wifi board is defective which resulted in the extruder motor being poorly controlled which in turn caused the clogs, using a different stepper driver fixed the issue.</p>
<p>I am a bit bummed out that one of my drivers turned out to be defective since the board has barely been used but at least I got my printer to work.</p>
| 1,658
|
<p>My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project.</p>
<p>Building the boost libraries and bjam from source (v1.35.0), when I run bjam I get a .so in the bin/gcc-4.1.2/debug directory. I run python and "import " and I get:
ImportError: <code>libboost_python-gcc41-d-1_35.so.1.35.0</code>: cannot open shared object file: No such file or directory</p>
<p>Looking in the library directory, I have the following:
<code>libboost_python-gcc41-mt-1_35.so</code> <code>libboost_python-gcc41-mt-1_35.so.1.35.0</code> <code>libboost_python-gcc41-mt.so</code></p>
<p>Obviously I need the -d instead of the -mt libraries, or to point at the -mt libraries instead of -d, but I can't figure out how to make my Jamroot file do that.</p>
<p>When I install Debian Etch's versions of the libraries, I get "No Jamfile in /usr/include" - and there's a debian bug that says they left out the system-level jamfile.</p>
<p>I'm more hopeful about getting it working from source, so if anyone has any suggestions to resolve the library issues, I'd like to hear them.</p>
<p>Response to answer 1: Thanks for the tip. So, do you know how I'd go about getting it to use the MT libraries instead? It appears to be more of a problem with bjam or the Jamfile I am using thinking I am in debug mode, even though I can't find any flags for that. While I know how to include specific libraries in a call to GCC, I don't see a way to configure that from the Boost end.</p>
|
<p>"Google Maps Hacks" has a hack, <a href="http://safari.oreilly.com/0596101619/googlemapshks-CHP-4-SECT-3" rel="nofollow noreferrer">"Hack 30. Stay Out of Traffic Jams"</a>, on that.</p>
<p>You can also find out how to get U.S. traffic info from John Resig's <a href="http://ejohn.org/blog/traffic-conditions-data/" rel="nofollow noreferrer">"Traffic Conditions Data"</a> article.</p>
|
<p>Google is mum on what source they use for their traffic data. You might contact them directly to see if they want to implement something for you, but my guess is that they'd simply refer you to their provider if they really wanted your data.</p>
<p>Keep in mind that traffic data is available for more than just the metropolitan areas, but Google isn't using it for a variety of reasons - one of the big reasons is that the entire tile set for the traffic overlay in areas with traffic tiles has to be regenerated every 15 minutes or so. It just doesn't scale.</p>
<p>So even if you managed to get your data in their flow, it likely won't be rendered.</p>
<p>-Adam</p>
| 9,259
|
<p>What are the best settings for Ultimaker Cura to have support material that's easy to remove for my Anet A8. I have printed an object with two different spools of PLA (same manufacturer just different color). The black print was printed with 200 °C, the grey one with 210 °C both a flow of 100 %. Thee black print seems like it has a little over-extrusion while the grey print has some under-extrusion artifacts despite the higher printing temperature. The grey support was really hard to remove and looks super messy the black one not so much...</p>
<p>What would be better settings?</p>
<p><a href="https://i.stack.imgur.com/biydn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/biydn.jpg" alt="image of two prints printed at different temperatures"></a></p>
<p>Could it be that the material is so much different despite same manufacturer? The black one seems to flow much better than the grey one. Both have suggested temperature of 210 °C
<a href="https://i.stack.imgur.com/s20fN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s20fN.jpg" alt="enter image description here"></a></p>
<p>BTW the thing is 33x25 mm in size. It's rather tiny that makes printing it somewhat awkward...</p>
<p>I have finished another print with a brim and a different support setting (Cross with 50 %) and at 195 °C and an infill rate of 100 %. The support came off much better, the under-extrusion is minimal on the layers however for some reason the top layer does get messed up with open spots and the little nob at the corner was just a a mere stringy stumb that fell off instantly and the walls of the holes came out spongy while the layers of the ring and the long side are smooth and fine...</p>
<p><a href="https://i.stack.imgur.com/Rye9r.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rye9r.jpg" alt="enter image description here"></a></p>
|
<p>Cura has some settings for the support structure which may help. Somewhere in the full Preferences menu is a setting for "gap at top" or equivalent wording. If you increase that gap slightly, the support material will be less strongly bonded to the part. Be careful, since a huge gap could lead to bridging problems. </p>
|
<p>From the picture, I suggest printing with 200 °C, as the grey print lost its cohesion at a higher temperature.</p>
<h2>Why higher = worse</h2>
<p>A filament is a solid that turns into a highly viscous fluid under heating and the more you heat it, the less viscous it gets. However, it also has a very high surface tension, which means, that as it extrudes and if it is not pressed down immediately, then the filament goop will thin as the head moves, resulting in under extrusion and stringiness. Print temperatures from manufacturers have to be seen with a grain of salt, as the measurements are calibrated to their test printer, which is not your printer.</p>
<h2>Support Structures</h2>
<p>To get good support structures, the support needs to:</p>
<ul>
<li>have enough surface to not topple over
<ul>
<li>in case of thin towers, use a brim</li>
</ul></li>
<li>The density should be enough to carry but not enough to stick too well
<ul>
<li>I have had best experiences with 5 to 10% support</li>
</ul></li>
<li>don't support angles that don't need it
<ul>
<li>45° is safe, 70° is on the very hard side. I go with 50 to 60° usually.</li>
</ul></li>
</ul>
<p>In a related manner, make sure that the <code>minimum layer time</code> is set to at about 5 to 10 seconds, which allows the single tip to cool down a little and get better prints</p>
<h2>Print Geometry Analysis</h2>
<p>The part you want to print is quite complicated with the different Z-heights to start at. It might be possible to increase printability by including "sacrifice blocks" of material about 1 or 2 layer heights below the print, pretty much including a support structure into the print design itself. This way the bottom might get better supported.</p>
| 1,225
|
<p>I have the following Java 6 code:</p>
<pre><code> Query q = em.createNativeQuery(
"select T.* " +
"from Trip T join Itinerary I on (T.itinerary_id=I.id) " +
"where I.launchDate between :start and :end " +
"or ADDDATE(I.launchDate, I.equipmentPullDayOfTrip) between :start and :end",
"TripResults" );
q.setParameter( "start", range.getStart(), TemporalType.DATE );
q.setParameter( "end", range.getEnd(), TemporalType.DATE );
@SqlResultSetMapping( name="TripResults",
entities={
@EntityResult( entityClass=TripEntity.class ),
@EntityResult( entityClass=CommercialTripEntity.class )
}
)
</code></pre>
<p>I receive a syntax error on the last closing right parenthesis. Eclipse gives: "Insert EnumBody to complete block statement" and "Insert enum Identifier to complete EnumHeaderName". Similar syntax error from javac.</p>
<p>What am I doing wrong?</p>
|
<p>The Hibernate annotations docs (<a href="http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/" rel="nofollow noreferrer">http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/</a>) suggest that this should be a class-level annotation rather than occurring inline within your code. And indeed when I paste that code into my IDE and move it around, the compile errors are present when the annotation is inline, but vanish when I put it in above the class declaration:</p>
<pre><code>@SqlResultSetMapping( name="TripResults",
entities={
@EntityResult( entityClass=TripEntity.class ),
@EntityResult( entityClass=CommercialTripEntity.class )
}
)
public class Foo {
public void bogus() {
Query q = em.createNativeQuery(
"select T.* " +
"from Trip T join Itinerary I on (T.itinerary_id=I.id) " +
"where I.launchDate between :start and :end " +
"or ADDDATE(I.launchDate, I.equipmentPullDayOfTrip) between :start and :end",
"TripResults" );
q.setParameter( "start", range.getStart(), TemporalType.DATE );
q.setParameter( "end", range.getEnd(), TemporalType.DATE );
}
}
</code></pre>
<p>...obviously I have no evidence that the above code will actually work. I have only verified that it doesn't cause compile errors.</p>
|
<p>Your example comes straight out of the API docs which are unfortunately poorly presented.</p>
<p>Your annotation should be placed on some class, probably the one in which you will be creating the query to use the result set mapping. However, it actually doesn't matter where this annotation is placed. Your JPA provider will actually maintain a global list of all these mappings, so no matter where you define it, you will be able to use it anywhere.</p>
<p>This is a shortcoming of the annotation method (as opposed to specifying things in XML.) Many other things in the JPA (i.e. named queries) are defined this same way. It makes it seem like there's some kind of connection between the thing being defined and the class on which it is annotated, when it's not.</p>
| 9,205
|
<p>I’ve been trying to install Ms SQL Server 2005 for over two weeks now, and I’ve finally gotten to the point where the prerequisites all seem to be in place. Unfortunately, every time I try to install SQL Server itself, I get the following message:</p>
<p>“The SQL Server service failed to start. For more information, see the SQL Server Books Online topics, "How to: View SQL Server 2005 Setup Log Files" and "Starting SQL Server Manually."”</p>
<p>The installer then “rolls back” the install and I’m left with three uninstalled products in the Setup list: “SQL Server Database Services,” “Reporting Services,” and “Workstation Components, Books Online…”.</p>
<p>Does anyone have any thoughts? I can’t check the SQL Server Books Online topics because they don’t install, either; and I can’t make sense of the log files without them.</p>
<p>Thanks!</p>
|
<p>I had similar problem while installing SQL Server 2005 on Windows 7 Professional and got error <code>SQL server failed to start</code>. I logged in as a Administrator (my user id is administrator) in windows.</p>
<p>SOLUTION</p>
<ol>
<li><p>Go to services, from control panel -> Administrative Tools</p></li>
<li><p>Click on properties of "SQL Server (MSSQLSERVER)" </p></li>
<li><p>Go to Log On Tab, Select "This Account" </p></li>
<li><p>Enter your windows login detail (administrator and password)</p></li>
<li><p>Start the service manually, it should work fine..</p></li>
</ol>
<p>Hope this too helps..</p>
|
<p>While that error message is on the screen (before the rollback begins) go to Control Panel -> Administrative Tools -> Services and see if the service is actually installed. Also check what account it is using to run as. If it's not using Local System, then double and triple check that the account it's using has rights to the program directory where MS SQL installed to. </p>
| 8,853
|
<p>I seem to remember reading something about how it is bad for structs to implement interfaces in CLR via C#, but I can't seem to find anything about it. Is it bad? Are there unintended consequences of doing so?</p>
<pre><code>public interface Foo { Bar GetBar(); }
public struct Fubar : Foo { public Bar GetBar() { return new Bar(); } }
</code></pre>
|
<p>Since no one else explicitly provided this answer I will add the following:</p>
<p><strong>Implementing</strong> an interface on a struct has no negative consequences whatsoever.</p>
<p>Any <em>variable</em> of the interface type used to hold a struct will result in a boxed value of that struct being used. If the struct is immutable (a good thing) then this is at worst a performance issue unless you are:</p>
<ul>
<li>using the resulting object for locking purposes (an immensely bad idea any way)</li>
<li>using reference equality semantics and expecting it to work for two boxed values from the same struct.</li>
</ul>
<p>Both of these would be unlikely, instead you are likely to be doing one of the following:</p>
<h3>Generics</h3>
<p>Perhaps many reasonable reasons for structs implementing interfaces is so that they can be used within a <strong>generic</strong> context with <em><a href="http://msdn.microsoft.com/en-us/library/d5x73970.aspx" rel="noreferrer">constraints</a></em>. When used in this fashion the variable like so:</p>
<pre><code>class Foo<T> : IEquatable<Foo<T>> where T : IEquatable<T>
{
private readonly T a;
public bool Equals(Foo<T> other)
{
return this.a.Equals(other.a);
}
}
</code></pre>
<ol>
<li>Enable the use of the struct as a type parameter
<ul>
<li>so long as no other constraint like <code>new()</code> or <code>class</code> is used.</li>
</ul></li>
<li>Allow the avoidance of boxing on structs used in this way.</li>
</ol>
<p>Then this.a is NOT an interface reference thus it does not cause a box of whatever is placed into it. Further when the c# compiler compiles the generic classes and needs to insert invocations of the instance methods defined on instances of the Type parameter T it can use the <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.constrained.aspx" rel="noreferrer">constrained</a> opcode:</p>
<blockquote>
<p>If thisType is a value type and thisType implements method then ptr is passed unmodified as the 'this' pointer to a call method instruction, for the implementation of method by thisType.</p>
</blockquote>
<p>This avoids the boxing and since the value type is implementing the interface is <em>must</em> implement the method, thus no boxing will occur. In the above example the <code>Equals()</code> invocation is done with no box on this.a<sup>1</sup>.</p>
<h3>Low friction APIs</h3>
<p>Most structs should have primitive-like semantics where bitwise identical values are considered equal<sup>2</sup>. The runtime will supply such behaviour in the implicit <code>Equals()</code> but this can be slow. Also this implicit equality is <em>not</em> exposed as an implementation of <code>IEquatable<T></code> and thus prevents structs being used easily as keys for Dictionaries unless they explicitly implement it themselves. It is therefore common for many public struct types to declare that they implement <code>IEquatable<T></code> (where <code>T</code> is them self) to make this easier and better performing as well as consistent with the behaviour of many existing value types within the CLR BCL.</p>
<p>All the primitives in the BCL implement at a minimum: </p>
<ul>
<li><code>IComparable</code></li>
<li><code>IConvertible</code></li>
<li><code>IComparable<T></code></li>
<li><code>IEquatable<T></code> (And thus <code>IEquatable</code>)</li>
</ul>
<p>Many also implement <code>IFormattable</code>, further many of the System defined value types like DateTime, TimeSpan and Guid implement many or all of these as well. If you are implementing a similarly 'widely useful' type like a complex number struct or some fixed width textual values then implementing many of these common interfaces (correctly) will make your struct more useful and usable.</p>
<h2>Exclusions</h2>
<p>Obviously if the interface strongly implies <em>mutability</em> (such as <code>ICollection</code>) then implementing it is a bad idea as it would mean tat you either made the struct mutable (leading to the sorts of errors described already where the modifications occur on the boxed value rather than the original) or you confuse users by ignoring the implications of the methods like <code>Add()</code> or throwing exceptions.</p>
<p>Many interfaces do NOT imply mutability (such as <code>IFormattable</code>) and serve as the idiomatic way to expose certain functionality in a consistent fashion. Often the user of the struct will not care about any boxing overhead for such behaviour.</p>
<h2>Summary</h2>
<p>When done sensibly, on immutable value types, implementation of useful interfaces is a good idea</p>
<hr>
<h3>Notes:</h3>
<p>1: Note that the compiler may use this when invoking virtual methods on variables which are <em>known</em> to be of a specific struct type but in which it is required to invoke a virtual method. For example:</p>
<pre><code>List<int> l = new List<int>();
foreach(var x in l)
;//no-op
</code></pre>
<p>The enumerator returned by the List is a struct, an optimization to avoid an allocation when enumerating the list (With some interesting <a href="http://www.eggheadcafe.com/software/aspnet/31702392/c-compiler-challenge--s.aspx" rel="noreferrer">consequences</a>). However the semantics of foreach specify that if the enumerator implements <code>IDisposable</code> then <code>Dispose()</code> will be called once the iteration is completed. Obviously having this occur through a boxed call would eliminate any benefit of the enumerator being a struct (in fact it would be worse). Worse, if dispose call modifies the state of the enumerator in some way then this would happen on the boxed instance and many subtle bugs might be introduced in complex cases. Therefore the IL emitted in this sort of situation is:</p>
<pre>
IL_0001: newobj System.Collections.Generic.List..ctor
IL_0006: stloc.0
IL_0007: nop
IL_0008: ldloc.0
IL_0009: callvirt System.Collections.Generic.List.GetEnumerator
IL_000E: stloc.2
IL_000F: br.s IL_0019
IL_0011: ldloca.s 02
IL_0013: call System.Collections.Generic.List.get_Current
IL_0018: stloc.1
IL_0019: ldloca.s 02
IL_001B: call System.Collections.Generic.List.MoveNext
IL_0020: stloc.3
IL_0021: ldloc.3
IL_0022: brtrue.s IL_0011
IL_0024: leave.s IL_0035
IL_0026: ldloca.s 02
IL_0028: constrained. System.Collections.Generic.List.Enumerator
IL_002E: callvirt System.IDisposable.Dispose
IL_0033: nop
IL_0034: endfinally
</pre>
<p>Thus the implementation of IDisposable does not cause any performance issues and the (regrettable) mutable aspect of the enumerator is preserved should the Dispose method actually do anything! </p>
<p>2: double and float are exceptions to this rule where NaN values are not considered equal.</p>
|
<p>Structs are just like classes that live in the stack. I see no reason why they should be "unsafe".</p>
| 8,906
|
<p>This is a 3 part question regarding embedded RegEx into SQL statements. </p>
<ol>
<li><p>How do you embed a RegEx expression into an Oracle PL/SQL
select statement that will parse out
the “DELINQUENT” string in the text
string shown below?</p></li>
<li><p>What is the performance impact if used within a
mission critical business
transaction?</p></li>
<li><p>Since embedding regex
into SQL was introduced in Oracle
10g and SQL Server 2005, is it
considered a recommended practice?</p></li>
</ol>
<hr>
<p>Dear Larry :</p>
<p>Thank you for using ABC's alert service.</p>
<p>ABC has detected a change in the status of one of your products in the state of KS. Please review the
information below to determine if this status change was intended.</p>
<p>ENTITY NAME: Oracle Systems, LLC</p>
<p>PREVIOUS STATUS: --</p>
<p>CURRENT STATUS: DELINQUENT</p>
<p>As a reminder, you may contact your the ABC Team for assistance in correcting any delinquencies or, if needed, reinstating
the service. Alternatively, if the system does not intend to continue to engage this state, please notify ABC
so that we can discontinue our services.</p>
<p>Kind regards,</p>
<p>Service Team 1
ABC</p>
<p>--PLEASE DO NOT REPLY TO THIS EMAIL. IT IS NOT A MONITORED EMAIL ACCOUNT.--</p>
<p>Notice: ABC Corporation cannot independently verify the timeliness, accuracy, or completeness of the public information
maintained by the responsible government agency or other sources of data upon which these alerts are based.</p>
|
<p>Why would you need regular expressions here?
INSTR and SUBSTR will do the job perfectly.</p>
<p>But if you convinced you need Regex'es you can use:</p>
<p><a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions129.htm#i1239887" rel="nofollow noreferrer">REGEXP_INSTR</a><br>
<a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions130.htm#i1305521" rel="nofollow noreferrer">REGEXP_REPLACE</a><br>
<a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions131.htm#i1239858" rel="nofollow noreferrer">REGEXP_SUBSTR</a> </p>
<p>(only available in Oracle 10g and up)</p>
<pre><code>SELECT emp_id, text
FROM employee_comment
WHERE REGEXP_LIKE(text,'...-....');
</code></pre>
|
<p>Why not just use INSTR (for Oracle) or CHARINDEX (for SQL Server) combined with SUBSTRING? Seems a bit more straightforward (and portable, since it's supported in older versions).</p>
<p><a href="http://www.techonthenet.com/oracle/functions/instr.php" rel="nofollow noreferrer">http://www.techonthenet.com/oracle/functions/instr.php</a> and <a href="http://www.adp-gmbh.ch/ora/sql/substr.html" rel="nofollow noreferrer">http://www.adp-gmbh.ch/ora/sql/substr.html</a></p>
<p><a href="http://www.databasejournal.com/features/mssql/article.php/3071531" rel="nofollow noreferrer">http://www.databasejournal.com/features/mssql/article.php/3071531</a> and <a href="http://msdn.microsoft.com/en-us/library/ms187748.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms187748.aspx</a></p>
| 9,868
|
<p>Service Oriented Architecture seems to be more and more of a hot quote these days, but after asking around the office I have found that I seem to get many different definitions for it. How would you guys define SOA? What would you consider the official definition?</p>
|
<p>As Martin Fowler says, it means different things to different people. His article on the topic is pretty good although it isn't quite a definition.</p>
<p><a href="http://martinfowler.com/bliki/ServiceOrientedAmbiguity.html" rel="noreferrer">http://martinfowler.com/bliki/ServiceOrientedAmbiguity.html</a></p>
<p>It may explain, the difficulty coming up with a concrete definition.</p>
|
<p>I attempted to define SOA in <a href="http://vincentfazio.blogspot.com/2008/07/something-old-something-new.html" rel="nofollow noreferrer">one of my blog posts</a>. Here's an excerpt...</p>
<blockquote>
<p>For years it's been standard practice to separate functionality into functions, classes, and modules. The idea has always been that these smaller, highly specialized components are easier to share and maintain than monolithic blocks of code.</p>
<p>Functionally, SOA is not much different. The goals are the same - reusability and easy maintenance. The biggest difference - in the case of a web service SOA - is that the shared library included in your application is replaced with an HTTP call.</p>
</blockquote>
| 8,416
|
<p>I need to replace all WinAPI calls of the</p>
<ul>
<li>CreateFile, </li>
<li>ReadFile, </li>
<li>SetFilePointer,</li>
<li>CloseHandle </li>
</ul>
<p>with my own implementation (which use low-level file reading via Bluetooth).
The code, where functions will be replaced, is Video File Player and it already works with the regular hdd files.
It is also needed, that Video Player still can play files from HDD, if the file in the VideoPlayer input is a regular hdd file.</p>
<p>What is the best practice for such task?</p>
|
<p>I suggest that you follow these steps:</p>
<ol>
<li>Write a set of wrapper functions, e.g MyCreateFile, MyReadFile, etc, that initially just call the corresponding API and pass the same arguments along, unmodified.</li>
<li>Use your text editor to search for all calls to the original APIs, and replace these with calls to your new wrapper functions.</li>
<li>Test that the application still functions correctly.</li>
<li>Modify the wrapper functions to suit your own purposes.</li>
</ol>
<p>Note that CreateFile is a macro which expands to either CreateFileW or CreateFileA, depending on whether UNICODE is defined. Consider using LPCTSTR and the <a href="http://msdn.microsoft.com/en-us/library/c426s321%28VS.80%29.aspx" rel="nofollow noreferrer">TCHAR functions</a> so that your application can be built as either ANSI or Unicode.</p>
<p>Please don't use #define, as suggested in other responses here, as this will just lead to maintenance problems, and as Maximilian correctly points out, it's not a best-practice.</p>
|
<p>I don't think this is best practice but it should work if you put it in an include file that's included everywhere the function you want to change is called:</p>
<pre><code>#define CreateFile MyCreateFile
HRESULT MyCreateFile(whatever the params are);
</code></pre>
<p>Implementation of MyCreateFile looks something like this:</p>
<pre><code>#undef CreateFile
HRESULT MyCreateFile(NobodyCanRememberParamListsLikeThat params)
{
if (InputIsNormalFile())
CreateFile(params);
else
// do your thing
}
</code></pre>
<p>You basically make every CreateFile call a MyCreateFile call where you can decide if you want need to use your own implementation or the orginal one.</p>
<p>Disclaimer: I think doing this is ugly and I wouldn't do it. I'd rather search and replace all occurences or something.</p>
| 8,555
|
<p>What is a good free library for editing MP3s/FLACs. </p>
<p>By editing I mean:</p>
<ul>
<li>Cutting audio file into multiple parts</li>
<li>Joining multiple audio files together</li>
<li>Increase playback speed of file without affecting the pitch (eg. podcasts up to 1.3x)</li>
<li>Re-encoding audio file from Flac -> MP3 or vice versa</li>
</ul>
<p>I don't mean software, I mean a library that I can use within another application. Programming language agnostic.</p>
|
<p>Just about every language has bindings to C, so you'll probably want to get the applicable C libraries for encoding/decoding mp3's and FLAC files. This list might include</p>
<p>libFLAC <a href="http://flac.sourceforge.net/api/index.html" rel="nofollow noreferrer">http://flac.sourceforge.net/api/index.html</a> FLAC encoding/decoding<br>
LAME <a href="http://lame.sourceforge.net/index.php" rel="nofollow noreferrer">http://lame.sourceforge.net/index.php</a> MP3 encoding<br>
MAD <a href="http://www.underbit.com/products/mad/" rel="nofollow noreferrer">http://www.underbit.com/products/mad/</a> MP3 decoding </p>
<p>The rest of your signal processing needs could be gathered around a single popular API such as LADSPA <a href="http://www.ladspa.org/" rel="nofollow noreferrer">http://www.ladspa.org/</a>.</p>
<p>Here's a stretching / pitch shifting library: <a href="http://www.breakfastquay.com/rubberband/" rel="nofollow noreferrer">http://www.breakfastquay.com/rubberband/</a></p>
<p>Most audio processing programs have a certain internal format they use. That keeps things simple. Everything coming in gets converted to the same format. Once you've standardized the internal format, cutting and splicing audio data is about as difficult as cutting and splicing strings. You don't really need a library for that.</p>
|
<p>I use <a href="http://audacity.sourceforge.net/" rel="nofollow noreferrer">Audacity</a> for all my editing needs</p>
<blockquote>
<p>Audacity is a free, easy-to-use audio
editor and recorder for Windows, Mac
OS X, GNU/Linux and other operating
systems. You can use Audacity to:</p>
<pre><code>* Record live audio.
* Convert tapes and records into digital recordings or CDs.
* Edit Ogg Vorbis, MP3, WAV or AIFF sound files.
* Cut, copy, splice or mix sounds together.
* Change the speed or pitch of a recording.
</code></pre>
</blockquote>
| 3,986
|
<p>I was writing some <strong>ASP.NET</strong> control when I came to the scenario where I needed to remove items from a list, only when they matched a certain condition.</p>
<p>The <code>RemoveAll</code> method of the generic <code>List</code> class does a good job, but removes <em>all</em> items that match the condition, specified by the predicate.</p>
<p>What if I want to only remove a certain number of items specifying the condition? What do you think is the best way to do this?</p>
|
<p>If you want to specify both a limit for number of items to remove and a condition to select the items to remove, you can use this approach:</p>
<pre><code>int limit = 30; // Suppose you want to remove 30 items at most
list.RemoveAll(item => ShouldIRemoveThis(item) && limit-- > 0);
</code></pre>
|
<p>Can you use LINQ? If so, you can just use the .Take() method and specify how many records you want (maybe as total - N).</p>
| 3,719
|
<p>I recently asked a question about <a href="https://stackoverflow.com/questions/28377/iif-vs-if">IIf vs. If</a> and found out that there is another function in VB called <strong>If</strong> which basically does the same thing as <strong>IIf</strong> but is a short-circuit.</p>
<p>Does this <strong>If</strong> function perform better than the <strong>IIf</strong> function? Does the <strong>If</strong> statement trump the <strong>If</strong> and <strong>IIf</strong> functions?</p>
|
<p>Damn, I really thought you were talking about the operator all along. ;-) Anyway …</p>
<blockquote>
<p>Does this If function perform better than the IIf function?</p>
</blockquote>
<p>Definitely. Remember, it's built into the language. Only one of the two conditional arguments has to be evaluated, potentially saving a costly operation.</p>
<blockquote>
<p>Does the If statement trump the If and IIf functions?</p>
</blockquote>
<p>I think you can't compare the two because they do different things. If your code semantically performs an assignment you should emphasize this, instead of the decision-making. Use the <code>If</code> operator here instead of the statement. This is especially true if you can use it in the initialization of a variable because otherwise the variable will be default initialized, resulting in slower code:</p>
<pre><code>Dim result = If(a > 0, Math.Sqrt(a), -1.0)
' versus
Dim result As Double ' Redundant default initialization!
If a > 0 Then
result = Math.Sqrt(a)
Else
result = -1
End If
</code></pre>
|
<p>One very important distinct between <code>IIf()</code> and <code>If()</code> is that with <code>Option Infer On</code> the later will implicitly cast the results to the same data type in certain cases, as where <code>IIf</code> will return <code>Object</code>. </p>
<p>Example: </p>
<pre><code> Dim val As Integer = -1
Dim iifVal As Object, ifVal As Object
iifVal = IIf(val >= 0, val, Nothing)
ifVal = If(val >= 0, val, Nothing)
</code></pre>
<p>Output:<br />
<code>iifVal</code> has value of Nothing and type of Object<br />
<code>ifVal</code> has value of 0 and type of Integer, b/c it is implicitly converting Nothing to an Integer.</p>
| 4,810
|
<p>As a lot of people pointed out in <a href="https://stackoverflow.com/questions/4724/learning-lisp-why">this question</a>, Lisp is mostly used as a learning experience. Nevertheless, it would be great if I could somehow use my Lisp algorithms and combine them with my C# programs.
In college my profs never could tell me how to use my Lisp routines in a program (no, not writing a GUI in Lisp, thank you).
So how can I?</p>
|
<p>Try these .Net implementations of Lisp:</p>
<ul>
<li><a href="https://github.com/leppie/IronScheme" rel="nofollow noreferrer">IronScheme</a></li>
</ul>
<blockquote>
<p>IronScheme will aim to be a R6RS
conforming Scheme implementation based
on the Microsoft DLR.</p>
</blockquote>
<ul>
<li><a href="https://github.com/RobBlackwell/LSharp" rel="nofollow noreferrer">L Sharp .NET</a></li>
</ul>
<blockquote>
<p>L Sharp .NET is a powerful Lisp-like
scripting language for .NET. It uses a
Lisp dialect similar to Arc but
tightly integrates with the .NET
Framework which provides a rich set of
libraries.</p>
</blockquote>
|
<p>If it's merely the routines you want to use you might try LSharp, which lets you have Lisp expressions in .NET:</p>
<p><a href="http://www.lsharp.org/" rel="nofollow noreferrer">http://www.lsharp.org/</a></p>
<p>The other way around (using .NET from Lisp) would be RDNZL:</p>
<p><a href="http://www.weitz.de/rdnzl/" rel="nofollow noreferrer">http://www.weitz.de/rdnzl/</a></p>
| 9,543
|
<p>I´ve been using my Ender 3 Pro for almost 1 year now. Always using the provided SD card. For a couple of days, the printed does not read any new file that I load to the SD card, but it does with the older files (and it then prints correctly as well).</p>
<p>I tried deleting some old files that I don't need, I tried turning it on with the SD card, I tried inserting the card after turning the printer on. It's always the same.</p>
<p>I am using another SD card and it works properly.</p>
<p>Any idea?</p>
|
<p>I think I found the problem. I think there was some crosstalk between the BLTouch wires and the other wires it was tied together leading to the hotend. When I moved the BLTouch wires away from the others the problem went away.</p>
<p>I will be added a sheild to the cable in the future like in this <a href="https://www.youtube.com/watch?v=jkcrRCxPlZM&ab_channel=509Drone" rel="nofollow noreferrer">youtube video</a></p>
|
<p>The OP already found the problem and <a href="/a/16632/">answered</a> the question hinting to shielding of the cable. If this is the actual problem, of fiddling with the cables might have caused this, an alternative solution is presented as I've experienced similar behavior.</p>
<p>If one side of the bed is higher than the rest, even when rotating the glass bed, you might experience that the nozzle carriage is tilting on that side. E.g. when using a Bowden extruder assembly, a too short Bowden tube (or cables in a non-Bowden setup) the tube (or cables) pull at the carriage causing it to lift at the furthest points from the extruder; this tilting can cause the nozzle to go up a few tenths of a millimeter.</p>
| 1,969
|
<p>When I use Emacs I want to be able to easily display and navigate through a list of files I worked on from not just the current session but from previous sessions. (BTW, running Emacs 22.2 on Windows)</p>
|
<p>From <a href="http://www.joegrossberg.com/archives/000182.html" rel="noreferrer">Joe Grossberg</a>'s blog (no longer available):</p>
<blockquote>
<p>But if you're using GNU Emacs 21.2
(the latest version, which includes
this as part of the standard distro),
you can just put the following lines
into your .emacs file</p>
<pre><code>;; recentf stuff
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
</code></pre>
<p>Then, when you launch emacs, hit
<kbd>CTRL</kbd>-<kbd>X</kbd> <kbd>CTRL</kbd>-<kbd>R</kbd>. It will show a list of
the recently-opened files in a buffer.
Move the cursor to a line and press
<kbd>ENTER</kbd>. That will open the file in
question, and move it to the top of
your recent-file list.</p>
<p>(Note: Emacs records file names.
Therefore, if you move or rename a
file outside of Emacs, it won't
automatically update the list. You'll
have to open the renamed file with the
normal <kbd>CTRL</kbd>-<kbd>X</kbd> <kbd>CTRL</kbd>-<kbd>F</kbd> method.)</p>
<p>Jayakrishnan Varnam has a <a href="http://web.archive.org/web/20021114012120/http://varnam.org/e-recentf.html" rel="noreferrer">page
including screenshots</a> of how this
package works.</p>
</blockquote>
<p><em>Note:</em> You don't need the <code>(require 'recentf)</code> line.</p>
|
<p>Even if you don't have recentf turned on, Emacs is saving a list of files entered via the minibuffer in the variable <code>file-name-history</code>. Also, executing <code>(savehist-mode 1)</code> in your <code>.emacs</code> file makes that variable persist across invocations of Emacs.</p>
<p>So here's a little function that displays the files that actually exist from that list (anyone is welcome to use/build on this):</p>
<pre><code>(defun dir-of-recent-files ()
"See the list of recently entered files in a Dired buffer."
(interactive)
(dired (cons
"*Recent Files*"
(seq-filter
'file-exists-p
(delete-dups
(mapcar (lambda (s) (string-trim-right s "/*"))
file-name-history)
))))
)
</code></pre>
<p>I find this quite useful and have it bound to one of those little special function keys on my desktop keyboard. (And so I have not seen the point of turning on recentf...)</p>
| 7,321
|
<p>I'm just learning how to use a 3D printer, I have an Anycubic Mega Zero 2.0.</p>
<p>When I start printing the PLA filament doesn't want to adhere very well. I have leveled it out and all of my corners on my test print adhere well. However, when I go to print anything besides the test print I get basically a small bead - it doesn't smooth flat. If I try and adjust from there it starts pushing all the material around.</p>
<p>This lack of adhesion and bead continue throughout the print making it flimsy. It's weird because it looks nice but it's not strong.</p>
<p><a href="https://i.stack.imgur.com/8CAGr.jpg" rel="nofollow noreferrer" title="Print on bed"><img src="https://i.stack.imgur.com/8CAGr.jpg" alt="Print on bed" title="Print on bed" /></a></p>
<p><a href="https://i.stack.imgur.com/XIqlp.jpg" rel="nofollow noreferrer" title="Flimsy printed filament"><img src="https://i.stack.imgur.com/XIqlp.jpg" alt="Flimsy printed filament" title="Flimsy printed filament" /></a></p>
<p><a href="https://i.stack.imgur.com/HfpdH.jpg" rel="nofollow noreferrer" title="Finished print"><img src="https://i.stack.imgur.com/HfpdH.jpg" alt="Finished print" title="Finished print" /></a></p>
<p><a href="https://i.stack.imgur.com/R6PeV.jpg" rel="nofollow noreferrer" title="Base of finished print"><img src="https://i.stack.imgur.com/R6PeV.jpg" alt="Base of finished print" title="Base of finished print" /></a></p>
|
<p>If you look at the multiple lines of the skirt, you see that none of the printed lines are touching the other laid down lines. This is an indication for under extrusion or a too large of a gap between the nozzle and the bed (or both). Considering you are talking about a bead/drop/blob of hot filament not adhering to the bed, this might be a good indication for a too large of a distance, if the gap is too large, the filament will not adhere to the bed and forms a blob. You could consider decreasing the gap by leveling with a thinner piece of paper or feeler gauge first. An alternative that might be quick to test is to re-define the bed height prior to printing using a plug-in in Ultimaker Cura or manually inserted in your G-code file. E.g. in you start code, add a move to a certain height and define that to a different height:</p>
<pre><code>G1 Z0.2 ; move printer head to 0.2 mm height
G92 Z0.24 ; re-define 0.2 to 0.24 mm, if the first layer prints at e.g. 0.2 mm,
; the printer will move down 0.04 mm
</code></pre>
<p>The images aren't very sharp, but, from one of the top layers it looks like you are indeed suffering from under extrusion. First, check if the filament can unwind freely without too much force from the spool. Second, under extrusion should be fixed by <a href="https://3dprinting.stackexchange.com/a/6484/5740">adjusting the steps per millimeter value</a>. Beware, a new printer should have the correct value already inserted in the firmware, you should definitely check the filament path for obstructions first.</p>
<p>A glass bed should be pretty flat, but it has been reported that there are glass manufacturers that produce low quality glass beds with dents. If so, you could shim the middle of the heated bed. An alternative is to flash new firmware and mesh the glass bed and the printer will automatically adjust for the height; this is not recommended for beginners.</p>
<p>You could also increase the temperature of the bed, PLA can be printed on a cold prepared bed, but works very well on beds at 50-60 °C. You could consider using an adhesive on the glass as well, certain hairsprays, certain glue sticks, and special adhesive print sprays like 3DLAC work very well.</p>
<p>Last but not least, incorrect filament diameter can cause under extrusion, older versions of Cura are notorious for resetting the filament diameter to 2.85 mm when you need e.g. 1.75 mm.</p>
|
<p>If the print bed is contaminated with oil or fat, print bed adhesion may be too low. Cleaning with alcohol might help.</p>
| 2,001
|
<p>My first magnetic bed mat for my Ender 3 Pro is cracking underneath. On the top side there is a bubble in the middle which prevents any viable print. The layers are probably separating.</p>
<p>I am new to printing but have read many articles on hiccups to expect, fixes etc. I do understand these magnetic mats can break down. They're pretty cheap on Amazon (something like \$12 for a 2-pack). Not a huge deal. I've printed only about 1100g worth of filament over 30 prints. Despite their cheap price I don't feel I got a proper amount of mileage out of the mat. </p>
<p>I keep my bed at 60 °C and 215 °C for the filament. I'm pretty sure 60 °C is below the maximum temperature for this kind of bed. I am struggling to find articles on this issue. </p>
<p>What can I do to prolong the life of these mats? I have removed the mat (with its print) while the bed was still hot to remove items just as much as removing cold items. Am I supposed to wait until it's cold? The cracks I only assume are from flexing the mat. I'm not trying to fold it here. I do pull on the item as I'm curving the mat to break it free. I can't explain the bubble.</p>
<p>The bed deteriorated after my first large print which took 27 hours. Prior, longest print I had was about 5 hours, most prints 1-1.5 hours. Is this a factor?</p>
<p><a href="https://i.stack.imgur.com/Z69pA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z69pA.jpg" alt="gn"></a></p>
|
<p>My personal technique for removing prints (particularly larger prints) is not to flex the mat at all. Instead, I wait until it's cool and then work the spatula under an edge and move it under the model to basically peel it from the mat.</p>
<p>Smaller prints usually pop right off if I start with this technique from one end. </p>
<p>Surface area on the bed (for a single part) is most important to how much work is involved. For example, a raft or brim will greatly increase the surface area. The spatula is long enough that usually I can reach everywhere under the model so eventually it will pop free. I might have to work around the model a bit before it reaches this point.</p>
|
<p>My personal technique for removing prints (particularly larger prints) is not to flex the mat at all. Instead, I wait until it's cool and then work the spatula under an edge and move it under the model to basically peel it from the mat.</p>
<p>Smaller prints usually pop right off if I start with this technique from one end. </p>
<p>Surface area on the bed (for a single part) is most important to how much work is involved. For example, a raft or brim will greatly increase the surface area. The spatula is long enough that usually I can reach everywhere under the model so eventually it will pop free. I might have to work around the model a bit before it reaches this point.</p>
| 1,534
|
<p>I'm not entirely sure if this is possible in Ruby, but hopefully there's an easy way to do this. I want to declare a variable and later find out the name of the variable. That is, for this simple snippet:</p>
<pre><code>foo = ["goo", "baz"]
</code></pre>
<p>How can I get the name of the array (here, "foo") back? If it is indeed possible, does this work on any variable (e.g., scalars, hashes, etc.)?</p>
<p>Edit: Here's what I'm basically trying to do. I'm writing a SOAP server that wraps around a class with three important variables, and the validation code is essentially this:</p>
<pre><code> [foo, goo, bar].each { |param|
if param.class != Array
puts "param_name wasn't an Array. It was a/an #{param.class}"
return "Error: param_name wasn't an Array"
end
}
</code></pre>
<p>My question is then: Can I replace the instances of 'param_name' with foo, goo, or bar? These objects are all Arrays, so the answers I've received so far don't seem to work (with the exception of re-engineering the whole thing ala <a href="https://stackoverflow.com/questions/58482/ruby-get-a-variables-name#58870">dbr's answer</a>) </p>
|
<p>What if you turn your problem around? Instead of trying to get names from variables, get the variables from the names:</p>
<pre><code>["foo", "goo", "bar"].each { |param_name|
param = eval(param_name)
if param.class != Array
puts "#{param_name} wasn't an Array. It was a/an #{param.class}"
return "Error: #{param_name} wasn't an Array"
end
}
</code></pre>
<p>If there were a chance of one the variables not being defined at all (as opposed to not being an array), you would want to add "rescue nil" to the end of the "param = ..." line to keep the eval from throwing an exception...</p>
|
<p>You can't, you need to go back to the drawing board and re-engineer your solution.</p>
| 8,282
|
<p>I know that the actual printing time is longer than the time estimated by Cura, due to acceleration and jerk factor.</p>
<p>However, I have printed a small pyramid for which Cura estimates 4.0 minutes, while the measured printing time is 2 minutes and 40 seconds.
What reasons could produce this difference?</p>
<p>For clarity, I'm using a Delta Wasp 20 40 equipped with a clay extruder for which parameters such as E-step (for E axis) are unpredictable since I have no filament.</p>
|
<p>If you properly define your own machine with a <code>delta_wasp.def.json</code> file you can fill in the acceleration and jerk settings of your printer, so that Cura will use the correct values for print time estimation.</p>
<p>For example, take a look at <a href="https://github.com/Ultimaker/Cura/blob/master/resources/definitions/ultimaker2.def.json" rel="nofollow noreferrer">how the Ultimaker 2 is defined.</a></p>
<p>Exposing these settings to the Custom FDM Printer wizard hasn't been implemented (yet).</p>
|
<p>Estimating time for any CNC based machines are measured in this formula:</p>
<p><em>The length of pulses that machine travels x The feedrate of the pulse itself</em></p>
<p>It gives you the time for whole movements. If you're familiar with NC codes, information of any movement is listed in a single line, having its own <code>feedrate</code>, that's what we call pulses.</p>
<p>As machines are not ideal, some delay occurs between pulses, approximately <em>1 or 2 ms</em> according to machine type. That's what is not measured in the formula.</p>
<p>If you were able to measure that <code>delay time</code> and multiply it in <code>number of pulses</code>, by adding it in the <code>estimated time</code> found by machine, you could find a much more definite estimated time, for your process.</p>
| 599
|
<p>I'm struggling to get my printer up and running for a few days now. The problem is as follows. I got a test model of a cube (40x40 mm) and everytime I try to print it, the nozzle creates these 'lines' on the print which is caused by over extrusion I think? See image:</p>
<p><a href="https://i.stack.imgur.com/WRtT4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WRtT4.jpg" alt="test print aborted at bottom shell"></a></p>
<p>This goes on for every bottom layer and ultimately when it starts printing the infill the nozzle starts digging into the print and I'm forced to stop the printer, see image:</p>
<p><a href="https://i.stack.imgur.com/S2tvI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S2tvI.jpg" alt="test print aborted during infill print"></a></p>
<p>What I have tried so far:</p>
<ul>
<li>Calibrating my extruder (by marking 100 mm on filament and command extruding 100 mm, check difference and adjust E step/mm accordingly)</li>
<li>Performed an auto bed leveling</li>
<li>I even halved my flow rate in the slicer (Ultimaker Cura), this gave signs of under extrusion of the first layer but the second layer looks over extruded again</li>
<li>Tried different temperatures in the range of 190-210 °C (I'm using PLA), made no significant difference</li>
</ul>
<p>My settings and gear:</p>
<ul>
<li>HE3D K280 Delta 3D printer</li>
<li>E3D V6 Volcano hot end (original, not chinese)</li>
<li>E3D Titan Extruder (original)</li>
<li>Marlin 1.1.8 using Ultimaker Cura as slicer</li>
<li>Nozzle 0.6 mm, layer height 0.2 mm, print speed 50 mm/s</li>
<li>1.75 mm PLA</li>
</ul>
<p>If anyone could help me fixing this that would be great!</p>
|
<p>Your images look as if your initial nozzle to heat bed offset is too large. This causes the filament not to be squished. Try re-levelling and have a piece of plain printing paper have a little drag when pulled.</p>
|
<p>I think You need to re-calibrate Z steps. Sometimes Marlin default z-steps/mm won't fit for 3D printer, because it depends on the hardware(z-axis threaded rod) that used to build the 3D printer. Check whether the Z-axis moves the distance that you command it to move. (ex: command to move x distance and check whether it moves the commanded distance)</p>
| 1,326
|
<p>Some 3 mm filaments seem to actually be 3 mm - is there any way to shave off the excess and use it as 2.85 mm? </p>
|
<p>I would not recommend you to try and somehow re-size the filament, since even the smallest of irregularities and error in diameter occurring from such a process would ruin your prints with sporadic over and under extrusion. Rather, if you have the tools available, you could grind the filament into pellets, and use a filament extruder to make it anew with your desired diameter. </p>
<p>Alternatively, depending on your printer setup, you might very well extrude true 3.00 filament with your 2.85 mm filament printer. If you try to do that, make sure to:</p>
<ul>
<li>Adjust filament diameter in your slicer</li>
<li>Check that your filament isn't getting squashed by the extruder wheel</li>
<li>Check that all mechanical parts actually can pass through your filament freely</li>
</ul>
<p>I do not own a 2.85 mm printer myself, and therefore have not tried this procedure. There are, however, <a href="https://ultimaker.com/en/community/4297-30mm-pla-vs-285mm-pla">several people</a> who seem to have done this successfully.</p>
|
<p>you could put a 3 mm extruder on you're printer. or (if you're r brave) put route filament in the oven for 10 minutes and unroll it than stretch it out. if you do this outside you can attach one ent to a stride licht or something an pul on the other end, if it is hot anoth it should hold its new position. but don't get it to hot or the filament will stick to itself, you can put talk powder on it to prevent this but be shore to watch it off before using your filament. i have never tried this and not komw is it will work. you can try it on i short pease of about 2 m first to test it oud. if it works, please tell me. i would love to know.</p>
| 263
|
<p>As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?</p>
<p>I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and things on the ASP .NET site.</p>
|
<p>Here is the great thing about MVC. It works closer to the base of the framework than normal ASP.NET Web Forms. So by using MVC and understanding it, you will have a better understanding of how WebForms work. The problem with WebForms is there is a lot of magic and about 6 years of trying to make the Web work like Windows Forms, so you have the control tree hierarchy and everything translated to the Web. With MVC you get the core with out the WinForm influence.</p>
<p>So start with MVC, and you will easily be able to move in to WebForms if needed.</p>
|
<p>IMO, there are more pitfalls in normal web forms scenarios than with just MVC. Viewstate and databinding can be tricky at times.</p>
<p>But for MVC, it's just plain simple form post/render things old-school way. Not that it is bad, it is just different, and cleaner too.</p>
| 6,309
|
<p>I'm wanting extra security for a particular point in my web app. So I want to lock the database (SQL Server 2005). Any suggestions or is this even necessary with SQL Server?</p>
<p><strong>Edit on question:</strong></p>
<p>The query is failing silently with no errors messages logged, and does not occur inside of a transaction.</p>
<p><strong>Final Solution:</strong></p>
<p>I never was able to solve the problem, however what I wound up doing was switching to MySQL and using a transactional level query here. This was not the main or even a primary reason to switch. I had been having problems with SQL Server and it allowed me to have our CMS and various other tools all running on the same database. Previous we had a SQL Server and a MySQL database running to run our site. The port was a bit on the time consuming however in the long run I feel it will work much better for the site and the business.</p>
|
<p>I suppose you have three options.</p>
<ol>
<li><p>Set user permissions so that user x can only read from the database.</p></li>
<li><p>Set the database into single user mode so only one connection can access it</p>
<p>sp_dboption 'myDataBaseName', single, true</p></li>
<li><p>Set the database to readonly</p>
<p>sp_dboption 'myDataBaseName', read only, true</p></li>
</ol>
|
<p>I never was able to solve the problem, however what I wound up doing was switching to MySQL and using a transactional level query here. This was not the main or even a primary reason to switch. I had been having problems with MSSQL and it allowed me to have our CMS and various other tools all running on the same database. Previous we had a MSSQL and a MySQL database running to run our site. The port was a bit on the time consuming however in the long run I feel it will work much better for the site and the business.</p>
| 2,701
|
<p>Is there a way to unfilter an NSPasteboard for what the source application specifically declared it would provide?</p>
<p>I'm attempting to serialize pasteboard data in my application. When another application places an RTF file on a pasteboard and then I ask for the available types, I get eleven different flavors of said RTF, everything from the original RTF to plain strings to dyn.* values. </p>
<p>Saving off all that data into a plist or raw data on disk isn't usually a problem as it's pretty small, but when an image of any considerable size is placed on the pasteboard, the resulting output can be tens of times larger than the source data (with multiple flavors of TIFF and PICT data being made available via filtering).</p>
<p>I'd like to just be able to save off what the original app made available if possible.</p>
<hr>
<p>John, you are far more observant than myself or the gentleman I work with who's been doing Mac programming since dinosaurs roamed the earth. Neither of us ever noticed the text you highlighted... and I've not a clue why. Starting too long at the problem, apparently.</p>
<p>And while I accepted your answer as the correct answer, it doesn't exactly answer my original question. What I was looking for was a way to identify flavors that can become other flavors simply by placing them on the pasteboard <strong>AND</strong> to know which of these types were originally offered by the provider. While walking the types list will get me the preferred order for the application that provided them, it won't tell me which ones I can safely ignore as they'll be recreated when I refill the pasteboard later.</p>
<p>I've come to the conclusion that there isn't a "good" way to do this. <code>[NSPasteboard declaredTypesFromOwner]</code> would be fabulous, but it doesn't exist.</p>
|
<p><code>-[NSPasteboard types]</code> will return all the available types for the data on the clipboard, but it should return them <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPasteboard/types" rel="nofollow noreferrer">"in the order they were declared."</a></p>
<p>The documentation for <code>-[NSPasteboard declareTypes:owner:]</code> says that <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPasteboard/declareTypes:owner:" rel="nofollow noreferrer">"the types should be ordered according to the preference of the source application."</a></p>
<p>A properly implemented pasteboard owner should, therefore, declare the richest representation of the content (probably the original content) as the first type; so a reasonable single representation should be:</p>
<pre><code>[pb dataForType:[[pb types] objectAtIndex:0]]
</code></pre>
|
<p>You may be able to get some use out of <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html#//apple_ref/occ/clm/NSPasteboard/typesFilterableTo:" rel="nofollow noreferrer"><code>+[NSPasteboard typesFilterableTo:]</code></a>. I'm picturing a snippet like this:</p>
<pre><code>NSArray *allTypes = [pb types];
NSAssert([allTypes count] > 0, @"expected at least one type");
// We always require the first declared type, as a starting point.
NSMutableSet *requiredTypes = [NSMutableSet setWithObject:[allTypes objectAtIndex:0]];
for (NSUInteger index = 1; index < [allTypes count]; index++) {
NSString *aType = [allTypes objectAtIndex:index];
NSSet *filtersFrom = [NSSet setWithArray:[NSPasteboard typesFilterableTo:aType]];
// If this type can't be re-created with a filter we already use, add it to the
// set of required types.
if (![requiredTypes intersectsSet:filtersFrom])
[requiredTypes addObject:aType];
}
</code></pre>
<p>I'm not sure how effective this would be at picking good types, however.</p>
| 7,837
|
<p>I have a .NET web app that uses CR 2008 for reports. The server it's deployed on is saddled with McAfee, and we want to tell CR to use a temp directory other than the Windows temp dir.</p>
<p>Google found me the following registry key:</p>
<p>SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\TempDir.</p>
<p>Adding this key does result in CR creating a bunch of temp files in the directory I specified. However, at the end of the report run I get an "Operation not yet implemented" exception.</p>
<p>I'm trying to return a PDF to the browser via ExportToHttpRequest(), which works just fine if I don't change the In-process server's tempdir.</p>
<p>Has anyone run into this before? I've already given the local ASPNET account full control of the new tempdir.</p>
<p>Thanks.</p>
|
<p>The other temp directory than C:/windows/temp should be located in your web site's virtual directory. Just add that temp folder in your web site's directory and when you make its virtual path to host it on IIS , it automatically gets included. If you want to make it at some other place like at D:/CrystalTEmp, you need to add this folder in your Inetmgr, just right click this directory and enable its web sharing. And yes you need to give Network service full rights over this temp folder.</p>
<p>If your placing your web site directory in inetpub/wwwroot, then you dont need to give rights to network service.</p>
|
<p>“Operation not yet implemented”
change "Font" type from
- right click on text area.
- format setting.
- change font </p>
| 8,107
|
<p>The question sort of says it all.</p>
<p>Whether it's for code testing purposes, or you're modeling a real-world process, or you're trying to impress a loved one, what are some algorithms that folks use to generate interesting time series data? Are there any good resources out there with a consolidated list? No constraints on values (except plus or minus infinity) or dimensions, but I'm looking for examples that people have found useful or exciting in practice. </p>
<p>Bonus points for parsimonious and readable code samples. </p>
|
<p>I believe the following will work:</p>
<pre><code>Dim b As CommandButton
Set b = ocx.GetButton("btnPrint")
b = True
</code></pre>
<p><code>CommandButton</code>s actually have two functions. One is the usual click button and the other is a toggle button that acts similar to a <code>CheckBox</code>. The default property of the <code>CommandButton</code> is actually the <code>Value</code> property that indicates whether a button is toggled. By setting the property, the <code>Click</code> event is generated. This is done even if the button is not styled as a <code>ToggleButton</code> and therefore doesn't change its state.</p>
|
<p>Do you have access to the OCX code? You shouldn't really be directly invoking the click of a button. You should refactor the code so that the OCX button click code calls a function, e.g.</p>
<pre><code>CMyWindow::OnLButtonDown()
{
this->FooBar();
}
</code></pre>
<p>Then from your VB6 app, directly call the FooBar method. If you can't directly call functions from VB6 you can wrap the FooBar() method with a windows message proc function, e.g.</p>
<pre><code>#define WM_FOOBAR WM_APP + 1
</code></pre>
<p>Then use <code>SendMessage</code> in the VB6, like <code>SendMessage(WM_FOOBAR, ...)</code></p>
| 6,238
|
<p>I'm creating a <a href="http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx" rel="noreferrer">ToolTip</a> window and adding tools to it using the flags
TTF_IDISHWND | TTF_SUBCLASS. (c++, win32)</p>
<p>I have a manifest file such that my program uses the new WindowsXP themes
(comctrl32 version 6).</p>
<p>When I hover over a registered tool, the tip appears.<br>
Good.<br>
When I click the mouse, the tip disappears.<br>
Ok.<br>
However, moving away from the tool and back
again does not make the tip re-appear. I need to hover over a different tool
and then come back to my tool to get the tip to come back.</p>
<p>When I remove my manifest file (to use the older non-XP comctrl32), the
problem goes away.</p>
<p>After doing some experimentation, I discovered the following differences
between ToolTips in Comctl32 version 5 (old) and Comctl32 version 6 (new):</p>
<ul>
<li><p>New TTF_TRANSPARENT ToolTips (when used In-Place) actually return
HTCLIENT from WM_NCITTEST if a mouse button is down, thus getting
WM_LBUTTONDOWN and stealing focus for a moment before vanishing. This causes
the application's border to flash.</p></li>
<li><p>Old TTF_TRANSPARENT ToolTips always return HTTRANSPARENT from WM_NCHITTEST,
and thus never get WM_LBUTTONDOWN themselves and never steal focus. (This seems to be just aesthetic, but may impact the next point...)</p></li>
<li><p>New ToolTips seem not to get WM_TIMER events after a mouse-click, and
only resume getting (a bunch of) timer events after being de-activated and
re-activated. Thus, they do not re-display their tip window after a mouse
click and release.</p></li>
<li><p>Old ToolTips get a WM_TIMER message as soon as the mouse is moved again
after click/release, so they are ready to re-display their tip.</p></li>
</ul>
<p>Thus, as a comctl32 workaround, I had to:</p>
<ul>
<li><p>subclass the TOOLTIPS_CLASS window and always return HTTRANSPARENT from
WM_NCHITTEST if the tool asked for transparency.</p></li>
<li><p>avoid using TTF_SUBCLASS and rather process the mouse messages myself so
I could de-activate/re-activate upon receiving WM_xBUTTONUP.</p></li>
</ul>
<p>I assume that the change in internal behavior was to accommodate the new "clickable" features in ToolTips like hyperlinks, but the hover behavior appears to be thus broken.</p>
<p>Does anyone know of a better solution than my subclass workaround? Am I missing some other point?</p>
|
<p>You're not the only one who has hit compatablity issues with tooltips between these DLLS. </p>
<p>I too have had <strong>nothing but trouble</strong> with the new tooltips in the themable common controls. We have already been monkeying with mouse messages and active/deactivating the tips before adding the manifest and theming our application - so it sounds like what your doing isn't too crazy.</p>
<p>We're still living with problems with TTN_NEEDTEXT messages being send constantly as the mouse moves (not just when hovering), positioning problems with large tips (maybe not something new), and odd unicode messages being sent instead of the ANSI versions (which I plan to post as a question at some point).</p>
|
<p>I don't know, but this sounds like a really "hard" problem (in the sense that all real-world) problems are really hard. I bet the underlying problem is something to do with the setting of the focus. Windows that manually do that are evil and generally suffer from all manner of bugs.</p>
| 7,408
|
<p>According to <a href="http://groups.google.com/group/v8-users/browse_thread/thread/3f57f8d1c31806a5" rel="nofollow noreferrer">this discussion</a>, the iphone agreement says that it doesn't allow "loading of plugins or running interpreted code that has been downloaded".</p>
<p>Technically, I <strong>would</strong> like to download scripts from our server (embedded in a proprietary protocol).</p>
<p>Does this mean I wouldn't be allowed to run a runtime like v8 in an iphone app?</p>
<p>This is probably more of a legal question.</p>
|
<p>I think your interpretation is correct - You would not be allowed to download and execute JavaScript code in v8.</p>
<p>If there were some way to run the code in an interpreter already on the iPhone (i.e. the javascript engine in MobileSafari) then that would be permitted I think.</p>
|
<p>Well I embedded Lua into my application already and am programming most of the login in Lua and then downloading it to my iPhone for fast iteration, but this is only intended during development. Once I ship the scripts will be placed in the source and compiled into byte-code shipped along with the app just like any other resource.</p>
<p>I'd say this applies to V8 aswell.</p>
| 7,075
|
<p>I have an application that reads a CSV file with piles of data rows. I give the user a summary of the number of rows based on types of data, but I want to make sure that I don't read in too many rows of data and cause <code>OutOfMemoryError</code>s. Each row translates into an object. Is there an easy way to find out the size of that object programmatically? Is there a reference that defines how large primitive types and object references are for a <code>VM</code>?</p>
<p>Right now, I have code that says read up to <strong>32,000 rows</strong>, but I'd also like to have code that says read as many rows as possible until I've used <strong>32MB</strong> of memory. Maybe that is a different question, but I'd still like to know. </p>
|
<p>You can use the <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html" rel="noreferrer"><code>java.lang.instrument</code> package</a>.</p>
<p>Compile and put this class in a JAR:</p>
<pre><code>import java.lang.instrument.Instrumentation;
public class ObjectSizeFetcher {
private static Instrumentation instrumentation;
public static void premain(String args, Instrumentation inst) {
instrumentation = inst;
}
public static long getObjectSize(Object o) {
return instrumentation.getObjectSize(o);
}
}
</code></pre>
<p>Add the following to your <code>MANIFEST.MF</code>:</p>
<pre><code>Premain-Class: ObjectSizeFetcher
</code></pre>
<p>Use the <code>getObjectSize()</code> method:</p>
<pre><code>public class C {
private int x;
private int y;
public static void main(String [] args) {
System.out.println(ObjectSizeFetcher.getObjectSize(new C()));
}
}
</code></pre>
<p>Invoke with:</p>
<pre><code>java -javaagent:ObjectSizeFetcherAgent.jar C
</code></pre>
|
<p>I doubt you want to do it programmatically unless you just want to do it once and store it for future use. It's a costly thing to do. There's no sizeof() operator in Java, and even if there was, it would only count the cost of the references to other objects and the size of the primitives.</p>
<p>One way you could do it is to serialize the thing to a File and look at the size of the file, like this:</p>
<pre><code>Serializable myObject;
ObjectOutputStream oos = new ObjectOutputStream (new FileOutputStream ("obj.ser"));
oos.write (myObject);
oos.close ();
</code></pre>
<p>Of course, this assumes that each object is distinct and doesn't contain non-transient references to anything else.</p>
<p>Another strategy would be to take each object and examine its members by reflection and add up the sizes (boolean & byte = 1 byte, short & char = 2 bytes, etc.), working your way down the membership hierarchy. But that's tedious and expensive and ends up doing the same thing the serialization strategy would do.</p>
| 7,560
|
<p>I have .stl for the 3d printing. And I want to analysis wall thickness of this model before printing. I have no idea about any tools. Can I create any console or wpf app for calculating wall thickness and cost of the printing.
Please help me. </p>
|
<p>If your talking about a hollow object, such as a cube with a hollow center. The wall thickness is determined by the model.</p>
<p>If your talking about a solid object, the wall thickness is determined by your nozzle diameter multiplied by your # of walls. This is all adjusted by your splicing software. If you have a nozzle of 0.5mm and you print at 3 perimeters, your wall should be 1.5mm. If you want the wall to be 2mm, then you will adjust your perimeters to 4. Everything within those walls will be whatever you choose for infill.</p>
<p>I work with ASP.NET, Windows Forms, and Console Apps myself. I'm sure you can find libraries capable of taking 3D models but I don't think it would matter because the printed thickness is determined by your splicing settings. </p>
<p>Also for cost of printing, I recommend just using Cura which you just have to plug in some cost information about the filament and it will tell you estimated cost, mm of filament usage, and time.</p>
|
<p>If your concern is that the stl file may have walls that are too thin to print on your printer, <a href="https://www.meshmixer.com/" rel="nofollow noreferrer">MeshMixer</a> is a great tool from <a href="https://www.autodesk.com" rel="nofollow noreferrer">Autodesk</a> to help check and fix mesh issues (including wall thickness). It is free to Makers and Educators.</p>
<p>There are lots of helpful tutorials
Here is one <a href="https://all3dp.com/meshmixer-tutorial/" rel="nofollow noreferrer">https://all3dp.com/meshmixer-tutorial/</a></p>
| 730
|
<p>For my C# app, I don't want to always prompt for elevation on application start, but if they choose an output path that is UAC protected then I need to request elevation.</p>
<p>So, how do I check if a path is UAC protected and then how do I request elevation mid-execution?</p>
|
<p>The best way to detect if they are unable to perform an action is to attempt it and catch the <code>UnauthorizedAccessException</code>.</p>
<p>However as @<a href="https://stackoverflow.com/users/941/dannysmurf">DannySmurf</a> <a href="https://stackoverflow.com/questions/17533/request-vista-uac-elevation-if-path-is-protected#17544">correctly points out</a> you can only elevate a COM object or separate process.</p>
<p>There is a demonstration application within the Windows SDK Cross Technology Samples called <a href="http://msdn.microsoft.com/en-us/library/aa970890.aspx" rel="nofollow noreferrer" title="MSDN - UAC Sample">UAC Demo</a>. This demonstration application shows a method of executing actions with an elevated process. It also demonstrates how to find out if a user is currently an administrator.</p>
|
<p>If your secondary drive has it's own file permissions, like say you have an other copy of windows installed on it. It will prompt.</p>
<p>It will also prompt if files are in use, which sometimes occurs if you have windows explorer open to the same directory and the file selected with a file previewer displaying the contents... there are some other oddities, but generally you get asked for file permission if the file is in use or it's a sensitive directory. </p>
<p>If you do loop the FolderBrowserDialog , make sure to notify the user why, so they dont get mad at your app. </p>
<p>Note: it does stink there is no .net way of asking for permission, maybe p/invoke the win32 api...?</p>
| 3,816
|
<p>I am looking for a robust way to copy files over a Windows network share that is tolerant of intermittent connectivity. The application is often used on wireless, mobile workstations in large hospitals, and I'm assuming connectivity can be lost either momentarily or for several minutes at a time. The files involved are typically about 200KB - 500KB in size. The application is written in VB6 (ugh), but we frequently end up using Windows DLL calls.</p>
<p>Thanks!</p>
|
<p>I've used <a href="http://en.wikipedia.org/wiki/Robocopy" rel="noreferrer">Robocopy</a> for this with excellent results. By default, it will retry every 30 seconds until the file gets across.</p>
|
<p>SMS if it's available works.</p>
| 3,878
|
<p>I work in a biological laboratory where we have been using the FABtotum personal fabricator for several months now. The machine is good, however not flawless, and has set us back from doing experiments.</p>
<p>I have overcome many common 3D printing issues, which I find necessary to do when becoming proficient in this technique. However the printer has also had its own personal mechanical and software issues.</p>
<p>Our lab is seeking a printer that is more reliable, can produce parts relatively quick, good resolution, and it is nice if it has multiple modes (i.e FDM, SLA, and even 3D scanning is nice). This is what we figured we were getting with the FABtotum, but as I mentioned it has produced setbacks.</p>
<p>Now I would love to tinker with the printer and modify it to my needs, but unfortunately our lab is strapped for time, however we have funding for a higher quality printer if there is one.</p>
<p>Can you anyone recommend a printer fitting these needs in these budget categories?:</p>
<ul>
<li><p>3000 USD</p></li>
<li><p>5000 USD</p></li>
<li><p>8000 USD or more</p></li>
</ul>
<p>I know price doesn't equate quality, but I am saying that we are willing to pay more if that is where the quality lies.</p>
<p>For example, I have come across the Form 2, Ultimaker, and BCN3D sigma printers which seem quite nice. Any opinions are very appreciated.</p>
|
<p>I have only tried 2 different printers. I started with an Up plus printer and it was good to get started. After a few years you really want more control. I did a lot of research and ended up buying the Extrabot. It is based on the ultimaker however the guy that puts them together upgrades the motors and a few other parts to really make them work with multiple filament.</p>
<p>You have control over all the settings so using exotic filaments is a viable option.</p>
|
<p>I have only tried 2 different printers. I started with an Up plus printer and it was good to get started. After a few years you really want more control. I did a lot of research and ended up buying the Extrabot. It is based on the ultimaker however the guy that puts them together upgrades the motors and a few other parts to really make them work with multiple filament.</p>
<p>You have control over all the settings so using exotic filaments is a viable option.</p>
| 596
|
<p>What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method?</p>
<p>I know that from outside of the object you should use a getter/setter, but from within would you just do:</p>
<p>Java:</p>
<pre><code>String property = this.property;
</code></pre>
<p>PHP:</p>
<pre><code>$property = $this->property;
</code></pre>
<p>or would you do:</p>
<p>Java:</p>
<pre><code>String property = this.getProperty();
</code></pre>
<p>PHP:</p>
<pre><code>$property = $this->getProperty();
</code></pre>
<p>Forgive me if my Java is a little off, it's been a year since I programmed in Java...</p>
<p><strong>EDIT:</strong></p>
<p>It seems people are assuming I am talking about private or protected variables/properties only. When I learned OO I was taught to use getters/setters for every single property even if it was public (and actually I was told never to make any variable/property public). So, I may be starting off from a false assumption from the get go. It appears that people answering this question are maybe saying that you should have public properties and that those don't need getters and setters, which goes against what I was taught, and what I was talking about, although maybe that needs to be discussed as well. That's probably a good topic for a different question though...</p>
|
<p>This has religious war potential, but it seems to me that if you're using a getter/setter, you should use it internally as well - using both will lead to maintenance problems down the road (e.g. somebody adds code to a setter that <em>needs</em> to run every time that property is set, and the property is being set internally w/o that setter being called).</p>
|
<p>Well, it seems with C# 3.0 properties' default implementation, the decision is taken for you; you HAVE to set the property using the (possibly private) property setter.</p>
<p>I personally only use the private member-behind when not doing so would cause the object to fall in an less than desirable state, such as when initializing or when caching/lazy loading is involved.</p>
| 2,258
|
<p>Using an FDM printer and PLA or ABS, without adding support material. What modifications can I make to improve how steep an overhang my printer can print before it starts having problems?</p>
<p>The obvious first answer is to add a cooling fan, increasing the airflow over the freshly-extruded material ensuring it solidifies. What other things can improve it?</p>
<p>Does lowing the temperature help? Raising it?</p>
<p>Does speeding up or slowing down the print head help?</p>
<p>Does increasing/decreasing the extrusion diameter, or layer height help?</p>
|
<p>The two most important things you can do are:</p>
<ul>
<li>Provide adequate cooling to solidify the plastic quickly</li>
<li>Minimize layer height</li>
</ul>
<p>Cooling is really obvious. You need the plastic to solidify before it has a chance to sag. PLA in particular has to shed a lot of heat before it is fully solid. A fan and air guide setup using a "squirrel-cage" radial blower around the nozzle is optimal. A little 30mm or 40mm axial fan will not provide optimal performance. </p>
<p>Low layer height when slicing is less obvious, but is extremely effective. When you use thinner layers, two things happen:</p>
<ul>
<li>There is less melted plastic per pass and a higher surface area to volume ratio, so the fresh material cools faster. </li>
<li>A larger percentage of each strand in the overhang is supported by the previous strand. If you do 0.2mm thick by 0.4mm wide, half of each strand is unsupported. But if you do 0.1mm thick by 0.4mm wide, only a quarter of each strand is unsupported. </li>
</ul>
<p>When you combine these two effects, it is possible to exceed 70 degree overhangs with good surface quality. </p>
<p>Another lesser factor is printing shells/perimeters inside-out rather than outside-in. This helps anchor the outermost strand a little better as the overhang is built. This is pretty minor though. </p>
|
<p>There's an answer <a href="https://3dprinting.stackexchange.com/questions/519/how-to-improve-face-that-are-printed-on-support?answertab=oldest#tab-top">here</a> that holds some of the same concepts. Regarding your questions: </p>
<ul>
<li><strong>Does lowering the temperature help? Raising it?</strong> : Yes, lowering the temperature can help. I've found that it is best to stay closer to the lower end of the material's melting point and just a bit above the point. Not only does this help with potential over extrusion, but also shortens the time it takes for the material to cool (refer to the link above). <em>However</em>, this could cause clogging if your temperature is too low. Keep an eye on your drive gear to see if there is too much friction while at lower temperatures. Increasing may keep the drive gear from "eating" your filament.</li>
<li><strong>Does speeding up or slowing down the print head help?</strong> : I prefer to print slower, most of the time, to allow the material to cool a bit more to avoid curling/warping (I primarily print with ABS, so it matters more). You might be able to give and take between temperature and speed. Consider if your nozzle is cooler and your speed is up, bridging gaps might yield the same results as if you proportionately swap these two values. This concept may only matter if you are in a pinch to get the part done. Again, I prefer slowing my machine down as it allows current/previous layers to cool more before continuing. This can be especially helpful with overhangs when paired with lowering your nozzle temperature.</li>
<li><strong>Does increasing/decreasing the extrusion diameter, or layer height help</strong> - I assume that extrusion diameter equals layer height (not difference in nozzle diameter, aka swapping nozzles). I'm not completely sure, but I think this depends on the part as well as slicing engine settings. For me, MakerWare is pretty good about proportionately adjusting extrusion steps with layer height, so I see an equal change in the width of the extrusion. I would think that in general, a larger layer height would yield a larger extrusion width. This would be helpful when printing overhangs, but may not be helpful when printing bridges (a larger strand will retain heat longer than a smaller one).</li>
</ul>
<p>Hopefully this helps, please comment if you need more information/clarification.</p>
| 209
|
<p>Has anybody out there used the <a href="http://www.swig.org/exec.html" rel="noreferrer">SWIG</a> library with C#? If you have, what pitfalls did you find and what is the best way to use the library? I am thinking about using it as a wrapper for a program that was written in C and I want to wrap the header files where I can use them in my .NET application.</p>
Edit: Some clarification on target OS's.
<p>I plan on running the application on Linux and Windows, therefore the reason I am looking into SWIG. P/Invoke is not an option.</p>
|
<p>I think the mistake the earlier posters did was read the docs and not look at the examples. </p>
<p>A few hours ago I needed to interface some C++ classes to C#. I looked in my Swig dir (I already had it for other work), found the directory <code>Examples/csharp/class</code>, browsed the code, loaded the solution, grokked it, copied it, put in my code, it worked, my job was done. </p>
<p>With that said, generated P/Invoke code isn't a solution for all needs. Depending on your project, it may be just as simple to write some simple API wrappers yourself or write managed C++ (Look up SlimDX for a superb example of this). </p>
<p>For my needs, it was simple and easy - I had <code>mystuff.dll</code>, and now in addition I can ship <code>mystuffnet.dll</code>. I'll agree that the doc is difficult to get into.</p>
<p>Edit: I noticed the OP only mentioned C. For that, you don't really need Swig, just use the <a href="http://msdn.microsoft.com/en-us/library/aa288468(VS.71).aspx#pinvoke_callingdllexport" rel="noreferrer">usual C#/C DLLImport interop syntax</a>. Swig becomes useful when you want to let <strong>C++ classes</strong> be invoked from C#.</p>
|
<p>I did attempt to use SWIG to wrap a project C++ for using in .NET a few years ago.</p>
<p>I didn't get very far as it was a massive giant pain to produce the configuration that SWIG required. At the time I just wanted a solution, not to learn another language/api/etc. SWIG may be easier to use these days, I couldn't tell you.</p>
<p>We ended up using Managed C++ to wrap the C++ project. It worked really well.</p>
<p>If you're just invoking functions straight out of a dll, I'd suggest not worrying about either of the above, and just using <a href="http://msdn.microsoft.com/en-us/magazine/cc164123.aspx" rel="noreferrer">P/Invoke</a></p>
| 4,491
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.