instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I'm using a C# MailMessage to attach a wave file (8K) to an email message. I'd like to provide a player within the body of that email message that will play that wave file if the user chooses to do so. I've tried using the embedded <object> version of WMP, and a cid: reference to the file, but Outlook 2003 rejects the object tag and won't run it. If it helps, I know my users will be on Outlook 2003.</p>
|
<p>If it don't support objects tags, then try the Embed tag instead:</p>
<p><a href="http://www.mioplanet.com/rsc/embed_mediaplayer.htm" rel="nofollow noreferrer">http://www.mioplanet.com/rsc/embed_mediaplayer.htm</a></p>
<p>I don't know it if works, but it is worth a shot :)</p>
|
<p>I would try using the <a href="http://www.htmlcodetutorial.com/embeddedobjects/_EMBED.html" rel="nofollow noreferrer">EMBED</a> tag. I'm not too surprised that OBJECT doesn't work, as invoking an ActiveX control is a potential "security hole" of sorts in the email system. I'm not sure that EMBED would work either though, and that's probably by design. Many users would find that behavior undesirable (their email being able to take multimedia actions on opening in Outlook) and the expected user experience is to have attachments listed with the option to execute them on click.
The alternative might be to have a link they could click that would open a web page with the multimedia embedded, if you don't want them to have to play it locally on their associated multimedia app.</p>
| 9,980
|
<p>If you are sending work/progress reports to the project lead on a daily or weekly basis, I wondered if you would consider using <a href="http://twitter.com" rel="nofollow noreferrer">Twitter</a> or similar services for these updates.</p>
<p>Say if you're working remotely or with a distributed team and the project lead has a hard time getting an overview about the topics people are working on, and where the issues/time consumers are, would you set up some private accounts (or even a private company-internal service) to broadcast progress updates to your colleagues?</p>
<p><strong>edit</strong> Thanks for the link to those products, but do you already use one of it in your company too? For real-life professional use?</p>
|
<p>Try <a href="http://laconi.ca/" rel="nofollow noreferrer">Laconica</a>: An open source Twitter-like system you could run on your own servers.</p>
|
<p>The <a href="http://en.blog.wordpress.com/2008/01/28/introducing-prologue/" rel="nofollow noreferrer">Prologue theme</a> for WordPress was designed with this in mind.</p>
| 7,472
|
<p>I would like to intercept the event in a .NET Windows Forms TabControl when the user has changed tab by double-clicking the tab (instead of just single-clicking it).</p>
<p>Do you have any idea of how I can do that?</p>
|
<p>The MouseDoubleClick event of the TabControl seems to respond just fine to double-clicking. The only additional step I would do is set a short timer after the TabIndexChanged event to track that a new tab has been selected and ignore any double-clicks that happen outside the timer. This will prevent double-clicking on the selected tab.</p>
|
<p>How about subclassing the TabControl class and adding your own DoubleClick event? </p>
| 5,273
|
<p>I have a little dilemma that maybe you can help me sort out. </p>
<p>I've been working today in modifying ASP.NET's Membership to add a level of indirection. Basically, ASP.NET's Membership supports Users and Roles, leaving all authorization rules to be based on whether a user belongs to a Role or not. </p>
<p>What I need to do is add the concept of Function, where a user will belong to a role (or roles) and the role will have one or more functions associated with them, allowing us to authorize a specific action based on if the user belongs to a role which has a function assigned. </p>
<p>Having said that, my problem has nothing to do with it, it's a generic class design issue. </p>
<p>I want to provide an abstract method in my base RoleProvider class to create the function (and persist it), but I want to make it optional to save a description for that function, so I need to create my CreateFunction method with an overload, one signature accepting the name, and the other accepting the name and the description. </p>
<p>I can think of the following scenarios: </p>
<ol>
<li><p>Create both signatures with the abstract modifier. This has the problem that the implementer may not respect the best practice that says that one overload should call the other one with the parameters normalized, and the logic should only be in the final one (the one with all the parameters). Besides, it's not nice to require both methods to be implemented by the developer. </p></li>
<li><p>Create the first like virtual, and the second like abstract. Call the second from the first, allow the implementer to override the behavior. It has the same problem, the implementer could make "bad decisions" when overriding it. </p></li>
<li><p>Same as before, but do not allow the first to be overriden (remove the virtual modifier). The problem here is that the implementer has to be aware that the method could be called with a null description and has to handle that situation. </p></li>
</ol>
<p>I think the best option is the third one... </p>
<p>How is this scenario handled in general? When you design an abstract class and it contains overloaded methods. It isn't that uncommon I think... </p>
|
<p>I feel the best combination of DRYness and forcing the contract is as follows (in pseudocode):</p>
<pre><code>class Base {
public final constructor(name) {
constructor(name, null)
end
public abstract constructor(name, description);
}
</code></pre>
<p>or, alternatively:</p>
<pre><code>class Base {
public abstract constructor(name);
public final constructor(name, description) {
constructor(name)
this.set_description(description)
}
private final set_description(description) {
...
}
}
</code></pre>
<p>There's a rule in Java that supports this decision: "never call non-final methods from a constructor."</p>
|
<p>To answer the first part of your post, check out AzMan (Authorization Manager), which, incidentally, is built into windows. It has the capability to specify operations which can be recombined into roles or assigned directly to users.</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/cc300469.aspx" rel="nofollow noreferrer">Check out</a></p>
<p>To answer the second part of your question, I wouldn't use an Abstract class. Instead just provide the functionality in the constructor and be done with it. It appeasr you want the specified behavior, and you don't want it to change. Why force descendents to provide the implementation.</p>
| 5,518
|
<p>I just finished setting up an out-of-place build system for our existing C++ code using inherited property sheets, a feature that seems to be specific to the Visual C++ product. Building out-of-place requires that many of the project settings be changed, and the inherited property sheets allowed me to change all the necessary settings just by attaching a property sheet to the project. I am migrating our team from C++/MFC for UI to C# and WPF, but I need to provide the same out-of-place build functionality, hopefully with the same convenience. I cannot seem to find a way to do this with C# projects - I first looked to see if I could reference an MsBuild targets file, but could not find a way to do this. I know I could just use MsBuild for the whole thing, but that seems more complicated than necessary. Is there a way I can define a macro for a directory and use it in the output path, for example?</p>
|
<p>I'm not quite sure what an "out-of-place" build system is, but if you just need the ability to copy the compiled files (or other resources) to other directories you can do so by tying into the MSBuild build targets.</p>
<p>In our projects we move the compiled dlls into lib folders and put the files into the proper locations after a build is complete. To do this we've created a custom build .target file that creates the <code>Target</code>'s, <code>Property</code>'s, and <code>ItemGroup</code>'s that we then use to populate our external output folder.</p>
<p>Our custom targets file looks a bit like this:</p>
<pre><code><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectName>TheProject</ProjectName>
<ProjectDepthPath>..\..\</ProjectDepthPath>
<ProjectsLibFolder>..\..\lib\</ProjectsLibFolder>
<LibFolder>$(ProjectsLibFolder)$(ProjectName)\$(Configuration)\</LibFolder>
</PropertyGroup>
<Target Name="DeleteLibFiles">
<Delete Files="@(LibFiles-> '$(ProjectDepthPath)$(LibFolder)%(filename)%(extension)')" TreatErrorsAsWarnings="true" />
</Target>
<Target Name="CopyLibFiles">
<Copy SourceFiles="@(LibFiles)" DestinationFolder="$(ProjectDepthPath)$(LibFolder)" SkipUnchangedFiles="True" />
</Target>
<ItemGroup>
<LibFiles Include=" ">
<Visible>false</Visible>
</LibFiles>
</ItemGroup>
</Project>
</code></pre>
<p>The .csproj file in Visual Studio then integrates with this custom target file:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" ... >
...
<Import Project="..\..\..\..\build\OurBuildTargets.targets" />
<ItemGroup>
<LibFiles Include="$(OutputPath)$(AssemblyName).dll">
<Visible>false</Visible>
</LibFiles>
</ItemGroup>
<Target Name="BeforeClean" DependsOnTargets="DeleteLibFiles" />
<Target Name="AfterBuild" DependsOnTargets="CopyLibFiles" />
</Project>
</code></pre>
<p>In a nutshell, this build script first tells MSBuild to load our custom build script, then adds the compiled file to the <code>LibFiles</code> ItemGroup, and lastly ties our custom build targets, <code>DeleteLibFiles</code> and <code>CopyLibFiles</code>, into the build process. We set this up for each project in our solution so only the files that are updated get deleted/copied and each project is responsible for it's own files (dlls, images, etc).</p>
<p>I hope this helps. I apologize if I misunderstood what you mean by out-of-place build system and this is completely useless to you!</p>
|
<blockquote>
<p>Is there a way I can define a macro for a directory and use it in the output path </p>
</blockquote>
<p>Have you looked at the pre-build and post-build events of a project?</p>
| 5,271
|
<p>I currently work with an Oracle database and we use stored procedures for all our SQL queries. The problem I have is that we do not really having a coding standard for our packages. So what happens is that every developer has a different style (or in some cases no sense of style) in how they format there packages. Making them difficult to read and work on with out first reformatting. We all pretty much just use Notepad or Notepad2 to write our packages. </p>
<p>I am unfortunately not in a position to mandate a coding standard and enforce it (just a code monkey at this point) so I was hoping to find a free SQL code formatter that I can use myself, and possibly suggest to others on the team to use, to make my life easier.</p>
<p>I have considered writing a small application that would essentially take a file as input and reformat everything, but before I did this I figured I would ask if anyone new of such a tool that is already available and is free.</p>
<p>So does anyone now of any such tools available? </p>
|
<ul>
<li><a href="http://www.vim.org/scripts/script.php?script_id=492" rel="nofollow noreferrer">VIM script</a> </li>
<li><a href="http://www.aquafold.com/" rel="nofollow noreferrer">Aqua Data studio</a> $ I use this one all the time.</li>
</ul>
|
<p>I like <a href="http://www.toadsoft.com/toad_oracle.htm" rel="nofollow noreferrer">TOAD for Oracle</a>. It has a format feature that's decent. I see there's a freeware version, though I have not used it.</p>
| 5,403
|
<p>Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this:</p>
<pre><code>int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll");
</code></pre>
<p>I know that I can make a recursive function to call Directory.GetFiles , but it would be much cleaner if I could do this without all the iterating.</p>
<p><strong>EDIT:</strong> If it is not possible to do this without recursing and iterating yourself, what would be the best way to do it?</p>
|
<p>You should use the <a href="http://msdn.microsoft.com/en-us/library/ms143316.aspx" rel="noreferrer">Directory.GetFiles(path, searchPattern, SearchOption)</a> overload of Directory.GetFiles().</p>
<p>Path specifies the path, searchPattern specifies your wildcards (e.g., *, *.format) and SearchOption provides the option to include subdirectories.</p>
<p>The Length property of the return array of this search will provide the proper file count for your particular search pattern and option:</p>
<pre><code>string[] files = directory.GetFiles(@"c:\windows\system32", "*.dll", SearchOption.AllDirectories);
return files.Length;
</code></pre>
<p><strong>EDIT:</strong> Alternatively you can use <a href="https://msdn.microsoft.com/en-us/library/system.io.directory.enumeratefiles(v=vs.110).aspx" rel="noreferrer">Directory.EnumerateFiles method</a></p>
<pre><code>return Directory.EnumerateFiles(@"c:\windows\system32", "*.dll", SearchOption.AllDirectories).Count();
</code></pre>
|
<p>Someone has to do the iterating part.</p>
<p>AFAIK, there is no such method present in .NET already, so I guess that someone has to be you.</p>
| 4,718
|
<p>How can I find the origins of conflicting DNS records?</p>
|
<p>You'll want the SOA (Start of Authority) record for a given domain name, and this is how you accomplish it using the universally available <strong>nslookup</strong> command line tool:</p>
<pre><code>command line> nslookup
> set querytype=soa
> stackoverflow.com
Server: 217.30.180.230
Address: 217.30.180.230#53
Non-authoritative answer:
stackoverflow.com
origin = ns51.domaincontrol.com # ("primary name server" on Windows)
mail addr = dns.jomax.net # ("responsible mail addr" on Windows)
serial = 2008041300
refresh = 28800
retry = 7200
expire = 604800
minimum = 86400
Authoritative answers can be found from:
stackoverflow.com nameserver = ns52.domaincontrol.com.
stackoverflow.com nameserver = ns51.domaincontrol.com.
</code></pre>
<p>The <strong>origin</strong> (or <strong>primary name server</strong> on Windows) line tells you that <strong>ns51.domaincontrol</strong> is the main name server for <strong>stackoverflow.com</strong>.</p>
<p>At the end of output all authoritative servers, including backup servers for the given domain, are listed.</p>
|
<p>Unfortunately, most of these tools only return the NS record as provided by the actual name server itself. To be more accurate in determining which name servers are actually responsible for a domain, you'd have to either use "whois" and check the domains listed there OR use "dig [domain] NS @[root name server]" and run that recursively until you get the name server listings...</p>
<p>I wish there were a simple command line that you could run to get THAT result dependably and in a consistent format, not just the result that is given from the name server itself. The purpose of this for me is to be able to query about 330 domain names that I manage so I can determine exactly which name server each domain is pointing to (as per their registrar settings).</p>
<p>Anyone know of a command using "dig" or "host" or something else on *nix?</p>
| 5,892
|
<p>I am trying to convince those who set standards at my current organization that we should use jQuery rather than Prototype and/or YUI. What are some convincing advantages I can use to convince them?</p>
|
<p>The 3 main advantages of jQuery are:</p>
<ul>
<li>its light weight when compared to other javascript frameworks</li>
<li>it has a wide range of <a href="http://plugins.jquery.com/" rel="nofollow noreferrer">plugins</a> available for various specific needs</li>
<li>it is easier for a designer to learn jQuery as it uses familiar CSS syntax. jQuery is <a href="http://www.sitepoint.com/article/jquery-javascipt-designers/" rel="nofollow noreferrer">Javascript for Designers</a></li>
</ul>
|
<p>Why don't you create a quick comparison? </p>
<p>Take a task like "find all divs or tables which contain images of class foo and attach a click event to each of them which makes them expand 50%." Or something more relevant to what you're doing.</p>
<p>Then code that with jQuery, Prototype, etc, and compare. Which is shorter? Easier to read? Faster to run? (You can find a speed comparison <a href="http://mootools.net/slickspeed" rel="nofollow noreferrer">here</a>.)</p>
| 9,262
|
<p>When writing multi-threaded applications, one of the most common problems experienced are deadlocks. </p>
<p>My questions to the community are:</p>
<ol>
<li><p>What is a deadlock? </p></li>
<li><p>How do you detect them? </p></li>
<li><p>Do you handle them? </p></li>
<li><p>And finally, how do you prevent them from occurring?</p></li>
</ol>
|
<p>A <strong>lock</strong> occurs when multiple processes try to access the same resource at the same time.</p>
<p>One process loses out and must wait for the other to finish.</p>
<p>A <strong>deadlock</strong> occurs when the waiting process is still holding on to another resource that the first needs before it can finish.</p>
<p>So, an example:</p>
<p>Resource A and resource B are used by process X and process Y</p>
<ul>
<li>X starts to use A.</li>
<li>X and Y try to start using B</li>
<li>Y 'wins' and gets B first</li>
<li>now Y needs to use A</li>
<li>A is locked by X, which is waiting for Y</li>
</ul>
<p>The best way to avoid deadlocks is to avoid having processes cross over in this way. Reduce the need to lock anything as much as you can.</p>
<p>In databases avoid making lots of changes to different tables in a single transaction, avoid triggers and switch to optimistic/dirty/nolock reads as much as possible.</p>
|
<p>Mutex in essence is a lock, providing protected access to shared resources. Under Linux, the thread mutex data type is pthread_mutex_t. Before use, initialize it.</p>
<p>To access to shared resources, you have to lock on the mutex. If the mutex already on the lock, the call will block the thread until the mutex is unlocked. Upon completion of the visit to shared resources, you have to unlock them.</p>
<p>Overall, there are a few unwritten basic principles:</p>
<ul>
<li><p>Obtain the lock before using the shared resources.</p></li>
<li><p>Holding the lock as short time as possible.</p></li>
<li><p>Release the lock if the thread returns an error.</p></li>
</ul>
| 5,479
|
<p>I am consuming the Twitter API and want to convert all URLs to hyperlinks. </p>
<p>What is the most effective way you've come up with to do this?</p>
<p>from</p>
<pre><code>string myString = "This is my tweet check it out http://tinyurl.com/blah";
</code></pre>
<p>to</p>
<pre><code>This is my tweet check it out <a href="http://tinyurl.com/blah">http://tinyurl.com/>blah</a>
</code></pre>
|
<p>Regular expressions are probably your friend for this kind of task:</p>
<pre><code>Regex r = new Regex(@"(https?://[^\s]+)");
myString = r.Replace(myString, "<a href=\"$1\">$1</a>");
</code></pre>
<p>The regular expression for matching URLs might need a bit of work.</p>
|
<p>/cheer for RedWolves</p>
<blockquote>
<p>from: this.replace(/[A-Za-z]+://[A-Za-z0-9-<em>]+.[A-Za-z0-9-</em>:%&\?/.=]+/, function(m){...</p>
<p>see: /[A-Za-z]+://[A-Za-z0-9-<em>]+.[A-Za-z0-9-</em>:%&\?/.=]+/</p>
</blockquote>
<p>There's the code for the addresses "anyprotocol"://"anysubdomain/domain"."anydomainextension and address", </p>
<p>and it's a perfect example for other uses of string manipulation. you can slice and dice at will with .replace and insert proper "a href"s where needed.</p>
<p>I used jQuery to change the attributes of these links to "target=_blank" easily in my content-loading logic even though the .link method doesn't let you customize them.</p>
<p>I personally love tacking on a custom method to the string object for on the fly string-filtering (the String.prototype.linkify declaration), but I'm not sure how that would play out in a large-scale environment where you'd have to organize 10+ custom linkify-like functions. I think you'd definitely have to do something else with your code structure at that point.</p>
<p>Maybe a vet will stumble along here and enlighten us.</p>
| 5,260
|
<p>What is the nest PHP thumbnailer/resizer class that preferably works on most shared hosts?</p>
<p>Clarification: I'm looking for a PHP class/wrapper (eg. <a href="http://phpthumb.sourceforge.net/" rel="nofollow noreferrer">phpThumb()</a>, <a href="http://en.wikipedia.org/wiki/Asido" rel="nofollow noreferrer">Asido</a>), so I don't have to run <a href="http://en.wikipedia.org/wiki/GD_Graphics_Library" rel="nofollow noreferrer">GD</a> or <a href="http://en.wikipedia.org/wiki/ImageMagick" rel="nofollow noreferrer">ImageMagick</a> functions directly. I'm specifically looking for resizing and framing functions.</p>
|
<p>I have good experiences with both <a href="http://sourceforge.net/projects/phpthumb/" rel="nofollow noreferrer">phpThumb</a> and <a href="http://sourceforge.net/projects/wideimage/" rel="nofollow noreferrer">Wideimage</a>. Wideimage is the more modern PHP5 approach while phpThumb has much more features.</p>
|
<p>GD is supported on many hosts
<a href="http://uk3.php.net/manual/en/book.image.php" rel="nofollow noreferrer">http://uk3.php.net/manual/en/book.image.php</a></p>
| 9,059
|
<p>Reading over the responses to this question <a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development">Disadvantages of Test Driven Development?</a> I got the impression there is alot of misunderstanding on what TDD is and how it should be conducted. It may prove useful to address these issues here.</p>
|
<p>I feel the accepted answer was one of the weakest (<a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#67184">Disadvantages of Test Driven Development?</a>), and the most up-modded answer smells of someone who might be writing over specified tests.</p>
<blockquote>
<p>Big time investment: for the simple
case you lose about 20% of the actual
implementation, but for complicated
cases you lose much more.</p>
</blockquote>
<p>TDD is an investment. I've found that once I was fully into TDD, the time I lost is very very little, and what time I did lose was more than made up when it came to maintence time.</p>
<blockquote>
<p>For complex cases your test cases are
harder to calculate, I'd suggest in
cases like that to try and use
automatic reference code that will run
in parallel in the debug version /
test run, instead of the unit test of
simplest cases.</p>
</blockquote>
<p>If your test are becoming very complex, it might be time to review your design. TDD should lead you down the path smaller, less complex units of code working together</p>
<blockquote>
<p>Sometimes you the design is not clear at the start and evolves as you go along - this will force you to redo your test which will generate a big time lose. I would suggest postponing unit tests in this case until you have some grasp of the design in mind.</p>
</blockquote>
<p>This is the worst point of them all! TDD should really be "Test Driven <strong>Design</strong>". TDD is about design, not testing. To fully realise the value of benefits of TDD, you have toy <strong>drive</strong> your design from your tests. So you should be <em>redoing</em> your production code to make your tests pass, not the other way round as this point suggests</p>
<p>Now the currently most upmodded: <a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#64381">Disadvantages of Test Driven Development?</a></p>
<blockquote>
<p>When you get to the point where you have a large number of tests, changing the system might require re-writing some or all of your tests, depending on which ones got invalidated by the changes. This could turn a relatively quick modification into a very time-consuming one.</p>
</blockquote>
<p>Like the accepted answers first point, this seems like over specification in the tests and a general lack of understanding of the TDD process. When making changes, start from your test. Change the test for what the new code should do, and make the change. If that change breaks other tests, then your tests are doing what their supposed to do, failing. Unit Tests, for me, are designed to fail, hence why the RED stage is first, and should never be missed.</p>
|
<p>The misconception that I often see is that TDD ensures good results.</p>
<p>Often times tests are written off of flawed requirements, and therefore, the developers produce a product that does not do what the user is expecting. Key to TDD is, in my opinion, working with the users to define requirements while helping manage their expectations.</p>
| 9,771
|
<p>Are there good reasons why it's a better practice to have only one return statement in a function? </p>
<p>Or is it okay to return from a function as soon as it is logically correct to do so, meaning there may be many return statements in the function?</p>
|
<p>I often have several statements at the start of a method to return for "easy" situations. For example, this:</p>
<pre class="lang-java prettyprint-override"><code>public void DoStuff(Foo foo)
{
if (foo != null)
{
...
}
}
</code></pre>
<p>... can be made more readable (IMHO) like this:</p>
<pre class="lang-java prettyprint-override"><code>public void DoStuff(Foo foo)
{
if (foo == null) return;
...
}
</code></pre>
<p>So yes, I think it's fine to have multiple "exit points" from a function/method.</p>
|
<p>I'm usually in favor of multiple return statements. They are easiest to read.</p>
<p>There are situations where it isn't good. Sometimes returning from a function can be very complicated. I recall one case where all functions had to link into multiple different libraries. One library expected return values to be error/status codes and others didn't. Having a single return statement can save time there.</p>
<p>I'm surprised that no one mentioned goto. Goto is not the bane of programming that everyone would have you believe. If you must have just a single return in each function, put it at the end and use gotos to jump to that return statement as needed. Definitely avoid flags and arrow programming which are both ugly and run slowly.</p>
| 5,731
|
<p>I recently installed an original BLTouch V3 on my Ender 3 pro and ever since I can’t seem to get a decent print. My first layers are horrible.</p>
<p>The install wasn’t so bad, I really thought it would be plug and play thereafter. </p>
<p>I currently have:</p>
<ul>
<li>Version 1.1.4 board with non silent steppers</li>
<li>Marlin 1.1.9 with bug fix as per the teaching tech video</li>
<li>Printing on glass, bed @ 60 °C, extruder @ 200 °C</li>
</ul>
<p>I have checked</p>
<ul>
<li>Bed is level.</li>
<li>X gantry is squared/straight.</li>
<li>Belts seem tight. </li>
<li>Tried my best at getting the Z offset right.</li>
<li>Checked E steps are correct.</li>
<li>BLTouch seems to be working - not 100 % sure as it’s my first time using an auto level sensor.</li>
</ul>
<p><a href="https://i.stack.imgur.com/PwByv.jpg" rel="nofollow noreferrer" title="First layer view of print with BLTouch V3"><img src="https://i.stack.imgur.com/PwByv.jpg" alt="First layer view of print with BLTouch V3" title="First layer view of print with BLTouch V3"></a></p>
<hr>
<p><sub>
<a href="https://imgur.com/a/8l3QkGY" rel="nofollow noreferrer">More pictures here</a> for those who can help.
</sub></p>
<hr>
<p>I have reset the offset and still having difficulty I’m hoping the following pics would help. They bed level squares that prints squares on all four corners and the centre of the bed plate. If I raise the offset any higher I have difficulty with prints sticking. See <a href="https://imgur.com/a/OzfrXm7" rel="nofollow noreferrer">here</a>.</p>
<p><a href="https://i.stack.imgur.com/TOnxu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TOnxu.jpg" alt="enter image description here"></a></p>
|
<p>I manage to get the printer working, it was an hotend issue. Was clogged, replaced nozzle and working as expected. </p>
<p>Thank you all for the guidance!</p>
|
<p>So the weird ridges around each line look like a form of over-extrusion that happens when your nozzle is too close to the bed. The gaps on the other side may be areas that were so thin that they didn't survive removal from the bed, or just areas that the plastic couldn't reach because the nozzle was basically dragging. I don't personally have any experiences with touch sensors (yet! got an inductive probe I'll be installing soon) but I can only assume that you have the ability to set the probe's Z offset from the nozzle. If that is the case, try setting your Z offset such that the nozzle is further away from the bed after probing. </p>
<p>I'd suggest starting by raising the nozzle about 0.2 mm, and fine-tuning from there. If you continue to get the raised ridges adjacent to each printed line, keep raising the nozzle until you don't get them anymore. At some point you should actually get to a point where there's gaps between the lines because the nozzle is <em>too</em> far, and at that point you can start bumping the offset back down again to try and perfect that Z offset.</p>
<p>Alternately you could do what I do and print on a raft with a 50% density first layer, but I get the feeling if you're printing on glass you probably want to be able to just print on the glass.</p>
| 1,399
|
<p>I'd like to use a database to store i18n key/value pairs so we can modify / reload the i18n data at runtime. Has anyone done this? Or does anyone have an idea of how to implement this? I've read several threads on this, but I haven't seen a workable solution.</p>
<p>I'm specifically refering to something that would work with the jstl tags such as</p>
<pre><code><fmt:setlocale>
<fmt:bundle>
<fmt:setBundle>
<fmt:message>
</code></pre>
<p>I think this will involve extending ResourceBundle, but when I tried this I ran into problems that had to do with the way the jstl tags get the resource bundle.</p>
|
<p>I finally got this working with danb's help above.</p>
<p>This is my resource bundle class and resource bundle control class.</p>
<p>I used this code from @[danb]'s.</p>
<pre><code>ResourceBundle bundle = ResourceBundle.getBundle("AwesomeBundle", locale, DbResourceBundle.getMyControl());
javax.servlet.jsp.jstl.core.Config.set(actionBeanContext.getRequest(), Config.FMT_LOCALIZATION_CONTEXT, new LocalizationContext(bundle, locale));
</code></pre>
<p>and wrote this class.</p>
<pre><code>public class DbResourceBundle extends ResourceBundle
{
private Properties properties;
public DbResourceBundle(Properties inProperties)
{
properties = inProperties;
}
@Override
@SuppressWarnings(value = { "unchecked" })
public Enumeration<String> getKeys()
{
return properties != null ? ((Enumeration<String>) properties.propertyNames()) : null;
}
@Override
protected Object handleGetObject(String key)
{
return properties.getProperty(key);
}
public static ResourceBundle.Control getMyControl()
{
return new ResourceBundle.Control()
{
@Override
public List<String> getFormats(String baseName)
{
if (baseName == null)
{
throw new NullPointerException();
}
return Arrays.asList("db");
}
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException,
InstantiationException, IOException
{
if ((baseName == null) || (locale == null) || (format == null) || (loader == null))
throw new NullPointerException();
ResourceBundle bundle = null;
if (format.equals("db"))
{
Properties p = new Properties();
DataSource ds = (DataSource) ContextFactory.getApplicationContext().getBean("clinicalDataSource");
Connection con = null;
Statement s = null;
ResultSet rs = null;
try
{
con = ds.getConnection();
StringBuilder query = new StringBuilder();
query.append("select label, value from i18n where bundle='" + StringEscapeUtils.escapeSql(baseName) + "' ");
if (locale != null)
{
if (StringUtils.isNotBlank(locale.getCountry()))
{
query.append("and country='" + escapeSql(locale.getCountry()) + "' ");
}
if (StringUtils.isNotBlank(locale.getLanguage()))
{
query.append("and language='" + escapeSql(locale.getLanguage()) + "' ");
}
if (StringUtils.isNotBlank(locale.getVariant()))
{
query.append("and variant='" + escapeSql(locale.getVariant()) + "' ");
}
}
s = con.createStatement();
rs = s.executeQuery(query.toString());
while (rs.next())
{
p.setProperty(rs.getString(1), rs.getString(2));
}
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException("Can not build properties: " + e);
}
finally
{
DbUtils.closeQuietly(con, s, rs);
}
bundle = new DbResourceBundle(p);
}
return bundle;
}
@Override
public long getTimeToLive(String baseName, Locale locale)
{
return 1000 * 60 * 30;
}
@Override
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)
{
return true;
}
};
}
</code></pre>
|
<p>Actuly what ScArcher2 needed is davids response which is not marked a correct or helpfull.</p>
<p>The solution ScArcher2 chose to use is imo terrible mestake:) Loading ALL the translations at one time... in any bigger application its gonna kill it. Loading thousends of translations each request...</p>
<p>david's method is more commonly used in real production environments.
Sometimes to limit db calls, which is with every message translated, you can create groups of translations by topic, functionality etc. to preload them. But this is little bit more complex and can be substituted with good cache system.</p>
| 3,973
|
<p>If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?</p>
<p>For example, if I inherit from the Exception class I want to do something like this:</p>
<pre><code>class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extraInfo)
{
//This is where it's all falling apart
base(message);
}
}
</code></pre>
<p>Basically what I want is to be able to pass the string message to the base Exception class.</p>
|
<p>Modify your constructor to the following so that it calls the base class constructor properly:</p>
<pre><code>public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}
</code></pre>
<p>Note that a constructor is not something that you can call anytime within a method. That's the reason you're getting errors in your call in the constructor body.</p>
|
<p>Using newer C# features, namely <code>out var</code>, you can get rid of the static factory-method.
I just found out (by accident) that out var parameter of methods called inse base-"call" flow to the constructor body.</p>
<p>Example, using this base class you want to derive from:</p>
<pre><code>public abstract class BaseClass
{
protected BaseClass(int a, int b, int c)
{
}
}
</code></pre>
<p>The non-compiling pseudo code you want to execute:</p>
<pre><code>public class DerivedClass : BaseClass
{
private readonly object fatData;
public DerivedClass(int m)
{
var fd = new { A = 1 * m, B = 2 * m, C = 3 * m };
base(fd.A, fd.B, fd.C); // base-constructor call
this.fatData = fd;
}
}
</code></pre>
<p>And the solution by using a static private helper method which produces all required base arguments (plus additional data if needed) and without using a static factory method, just plain constructor to the outside:</p>
<pre><code>public class DerivedClass : BaseClass
{
private readonly object fatData;
public DerivedClass(int m)
: base(PrepareBaseParameters(m, out var b, out var c, out var fatData), b, c)
{
this.fatData = fatData;
Console.WriteLine(new { b, c, fatData }.ToString());
}
private static int PrepareBaseParameters(int m, out int b, out int c, out object fatData)
{
var fd = new { A = 1 * m, B = 2 * m, C = 3 * m };
(b, c, fatData) = (fd.B, fd.C, fd); // Tuples not required but nice to use
return fd.A;
}
}
</code></pre>
| 3,315
|
<p>What is the best practice of Unicode processing in C++?</p>
|
<ul>
<li>Use <a href="http://www.icu-project.org/" rel="noreferrer">ICU</a> for dealing with your data (or a similar library)</li>
<li>In your own data store, make sure everything is stored in the same encoding</li>
<li>Make sure you are always using your unicode library for mundane tasks like string length, capitalization status, etc. Never use standard library builtins like <code>is_alpha</code> unless that is the definition you want.</li>
<li>I can't say it enough: <em><strong>never iterate over the indices of a <code>string</code> if you care about correctness, always use your unicode library for this.</strong></em></li>
</ul>
|
<p>Use IBM's <a href="http://www.icu-project.org/" rel="nofollow noreferrer">International Components for Unicode</a></p>
| 7,946
|
<p>I found an example in the <a href="http://msdn2.microsoft.com/en-us/bb330936.aspx" rel="noreferrer">VS2008 Examples</a> for Dynamic LINQ that allows you to use a SQL-like string (e.g. <code>OrderBy("Name, Age DESC"))</code> for ordering. Unfortunately, the method included only works on <code>IQueryable<T></code>. Is there any way to get this functionality on <code>IEnumerable<T></code>?</p>
|
<p>Just stumbled into this oldie...</p>
<p>To do this without the dynamic LINQ library, you just need the code as below. This covers most common scenarios including nested properties.</p>
<p>To get it working with <code>IEnumerable<T></code> you could add some wrapper methods that go via <code>AsQueryable</code> - but the code below is the core <code>Expression</code> logic needed.</p>
<pre><code>public static IOrderedQueryable<T> OrderBy<T>(
this IQueryable<T> source,
string property)
{
return ApplyOrder<T>(source, property, "OrderBy");
}
public static IOrderedQueryable<T> OrderByDescending<T>(
this IQueryable<T> source,
string property)
{
return ApplyOrder<T>(source, property, "OrderByDescending");
}
public static IOrderedQueryable<T> ThenBy<T>(
this IOrderedQueryable<T> source,
string property)
{
return ApplyOrder<T>(source, property, "ThenBy");
}
public static IOrderedQueryable<T> ThenByDescending<T>(
this IOrderedQueryable<T> source,
string property)
{
return ApplyOrder<T>(source, property, "ThenByDescending");
}
static IOrderedQueryable<T> ApplyOrder<T>(
IQueryable<T> source,
string property,
string methodName)
{
string[] props = property.Split('.');
Type type = typeof(T);
ParameterExpression arg = Expression.Parameter(type, "x");
Expression expr = arg;
foreach(string prop in props) {
// use reflection (not ComponentModel) to mirror LINQ
PropertyInfo pi = type.GetProperty(prop);
expr = Expression.Property(expr, pi);
type = pi.PropertyType;
}
Type delegateType = typeof(Func<,>).MakeGenericType(typeof(T), type);
LambdaExpression lambda = Expression.Lambda(delegateType, expr, arg);
object result = typeof(Queryable).GetMethods().Single(
method => method.Name == methodName
&& method.IsGenericMethodDefinition
&& method.GetGenericArguments().Length == 2
&& method.GetParameters().Length == 2)
.MakeGenericMethod(typeof(T), type)
.Invoke(null, new object[] {source, lambda});
return (IOrderedQueryable<T>)result;
}
</code></pre>
<hr>
<p>Edit: it gets more fun if you want to mix that with <code>dynamic</code> - although note that <code>dynamic</code> only applies to LINQ-to-Objects (expression-trees for ORMs etc can't really represent <code>dynamic</code> queries - <code>MemberExpression</code> doesn't support it). But here's a way to do it with LINQ-to-Objects. Note that the choice of <code>Hashtable</code> is due to favorable locking semantics:</p>
<pre><code>using Microsoft.CSharp.RuntimeBinder;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Runtime.CompilerServices;
static class Program
{
private static class AccessorCache
{
private static readonly Hashtable accessors = new Hashtable();
private static readonly Hashtable callSites = new Hashtable();
private static CallSite<Func<CallSite, object, object>> GetCallSiteLocked(
string name)
{
var callSite = (CallSite<Func<CallSite, object, object>>)callSites[name];
if(callSite == null)
{
callSites[name] = callSite = CallSite<Func<CallSite, object, object>>
.Create(Binder.GetMember(
CSharpBinderFlags.None,
name,
typeof(AccessorCache),
new CSharpArgumentInfo[] {
CSharpArgumentInfo.Create(
CSharpArgumentInfoFlags.None,
null)
}));
}
return callSite;
}
internal static Func<dynamic,object> GetAccessor(string name)
{
Func<dynamic, object> accessor = (Func<dynamic, object>)accessors[name];
if (accessor == null)
{
lock (accessors )
{
accessor = (Func<dynamic, object>)accessors[name];
if (accessor == null)
{
if(name.IndexOf('.') >= 0) {
string[] props = name.Split('.');
CallSite<Func<CallSite, object, object>>[] arr
= Array.ConvertAll(props, GetCallSiteLocked);
accessor = target =>
{
object val = (object)target;
for (int i = 0; i < arr.Length; i++)
{
var cs = arr[i];
val = cs.Target(cs, val);
}
return val;
};
} else {
var callSite = GetCallSiteLocked(name);
accessor = target =>
{
return callSite.Target(callSite, (object)target);
};
}
accessors[name] = accessor;
}
}
}
return accessor;
}
}
public static IOrderedEnumerable<dynamic> OrderBy(
this IEnumerable<dynamic> source,
string property)
{
return Enumerable.OrderBy<dynamic, object>(
source,
AccessorCache.GetAccessor(property),
Comparer<object>.Default);
}
public static IOrderedEnumerable<dynamic> OrderByDescending(
this IEnumerable<dynamic> source,
string property)
{
return Enumerable.OrderByDescending<dynamic, object>(
source,
AccessorCache.GetAccessor(property),
Comparer<object>.Default);
}
public static IOrderedEnumerable<dynamic> ThenBy(
this IOrderedEnumerable<dynamic> source,
string property)
{
return Enumerable.ThenBy<dynamic, object>(
source,
AccessorCache.GetAccessor(property),
Comparer<object>.Default);
}
public static IOrderedEnumerable<dynamic> ThenByDescending(
this IOrderedEnumerable<dynamic> source,
string property)
{
return Enumerable.ThenByDescending<dynamic, object>(
source,
AccessorCache.GetAccessor(property),
Comparer<object>.Default);
}
static void Main()
{
dynamic a = new ExpandoObject(),
b = new ExpandoObject(),
c = new ExpandoObject();
a.X = "abc";
b.X = "ghi";
c.X = "def";
dynamic[] data = new[] {
new { Y = a },
new { Y = b },
new { Y = c }
};
var ordered = data.OrderByDescending("Y.X").ToArray();
foreach (var obj in ordered)
{
Console.WriteLine(obj.Y.X);
}
}
}
</code></pre>
|
<pre><code>var result1 = lst.OrderBy(a=>a.Name);// for ascending order.
var result1 = lst.OrderByDescending(a=>a.Name);// for desc order.
</code></pre>
| 6,255
|
<p>Using <a href="http://pyobjc.sourceforge.net/" rel="noreferrer">PyObjC</a>, you can use Python to write Cocoa applications for OS X. Can I write native iPhone apps using Python and if so, how?</p>
|
<p>Not currently, currently the only languages available to access the iPhone SDK are C/C++, Objective C and Swift.</p>
<p>There is no technical reason why this could not change in the future but I wouldn't hold your breath for this happening in the short term.</p>
<p>That said, Objective-C and Swift really are not too scary...</p>
<blockquote>
<h1>2016 edit</h1>
<p>Javascript with NativeScript framework is available to use now.</p>
</blockquote>
|
<p>The only significant "external" language for iPhone development that I'm aware of with semi-significant support in terms of frameworks and compatibility is <a href="http://monotouch.net/" rel="nofollow noreferrer">MonoTouch</a>, a C#/.NET environment for developing on the iPhone.</p>
| 6,491
|
<p>This one will take some explaining. What I've done is create a specific custom message queue in SQL Server 2005. I have a table with messages that contain timestamps for both acknowledgment and completion. The stored procedure that callers execute to obtain the next message in their queue also acknowledges the message. So far so good. Well, if the system is experiencing a massive amount of transactions (thousands per minute), isn't it possible for a message to be acknowledged by another execution of the stored procedure while another is prepared to so itself? Let me help by showing my SQL code in the stored proc:</p>
<pre><code>--Grab the next message id
declare @MessageId uniqueidentifier
set @MessageId = (select top(1) ActionMessageId from UnacknowledgedDemands);
--Acknowledge the message
update ActionMessages
set AcknowledgedTime = getdate()
where ActionMessageId = @MessageId
--Select the entire message
...
...
</code></pre>
<p>In the above code, couldn't another stored procedure running at the same time obtain the same id and attempt to acknowledge it at the same time? Could I (or should I) implement some sort of locking to prevent another stored proc from acknowledging messages that another stored proc is querying? </p>
<p>Wow, did any of this even make sense? It's a bit difficult to put to words...</p>
|
<p>Something like this</p>
<pre><code>--Grab the next message id
begin tran
declare @MessageId uniqueidentifier
select top 1 @MessageId = ActionMessageId from UnacknowledgedDemands with(holdlock, updlock);
--Acknowledge the message
update ActionMessages
set AcknowledgedTime = getdate()
where ActionMessageId = @MessageId
-- some error checking
commit tran
--Select the entire message
...
...
</code></pre>
|
<p>You want to wrap your code in a transaction, then SQL server will handle locking the appropriate rows or tables.</p>
<pre><code>begin transaction
--Grab the next message id
declare @MessageId uniqueidentifier
set @MessageId = (select top(1) ActionMessageId from UnacknowledgedDemands);
--Acknowledge the message
update ActionMessages
set AcknowledgedTime = getdate()
where ActionMessageId = @MessageId
commit transaction
--Select the entire message
...
</code></pre>
| 8,198
|
<p>I am currently developing a .NET application, which consists of 20 projects. Some of those projects are compiled using .NET 3.5, some others are still .NET 2.0 projects (so far no problem).</p>
<p>The problem is that if I include an external component I always get the following warning:</p>
<blockquote>
<p>Found conflicts between different versions of the same dependent assembly.</p>
</blockquote>
<p>What exactly does this warning mean and is there maybe a possibility to exclude this warning (like using #pragma disable in the source code files)?</p>
|
<p>This warning means that two projects reference the same assembly (e.g. <code>System.Windows.Forms</code>) but the two projects require different versions. You have a few options:</p>
<ol>
<li><p>Recompile all projects to use the same versions (e.g. move all to .Net 3.5). This is the preferred option because all code is running with the versions of dependencies they were compiled with.</p></li>
<li><p>Add a <a href="http://msdn.microsoft.com/en-us/library/433ysdt1.aspx" rel="noreferrer">binding redirect</a>. This will suppress the warning. However, your .Net 2.0 projects will (at runtime) be bound to the .Net 3.5 versions of dependent assemblies such as <code>System.Windows.Forms</code>. You can quickly add a binding redirect by double-clicking on error in Visual Studio.</p></li>
<li><p>Use <code>CopyLocal=true</code>. I'm not sure if this will suppress the warning. It will, like option 2 above, mean that all projects will use the .Net 3.5 version of System.Windows.Forms.</p></li>
</ol>
<p>Here are a couple of ways to identify the offending reference(s):</p>
<ul>
<li>You can use a utility such as the one found at
<a href="https://gist.github.com/1553265" rel="noreferrer">https://gist.github.com/1553265</a> </li>
<li>Another simple method is to set Build
output verbosity (Tools, Options, Projects and Solutions, Build and
Run, MSBuild project build output verbosity, Detailed) and after
building, search the output window for the warning, and look at the
text just above it. <em>(Hat tip to <a href="https://stackoverflow.com/users/44547/pauloya">pauloya</a> who suggested this in the
comments on this answer)</em>.</li>
</ul>
|
<p>This happened to me too. One dll was referenced twice: once directly (in references) and once indirectly (referenced by another referenced project).
I removed direct reference, cleaned & rebuilt solution. Problem fixed.</p>
| 3,840
|
<p>Is it possible to add a custom tab to a project properties page in the Visual Studio 2008?
What I want to do is to be able to add a custom tab to properties page for the projects created from default project templates (WPF Application, WPF custom controls library, etc).</p>
|
<p>Keith,</p>
<p>I'm working on VS add-in for WPF applications localization. I want to be able to manage project specific settings via "project properties" page. I did some research and it seems that it is not possible to extend existing projects in this way.</p>
|
<p>It seems that during the time this question was asked, this feature was not implemented in Visual Studio SDK.</p>
<p>There's answer for similar question <a href="https://stackoverflow.com/a/5325158/2617201">https://stackoverflow.com/a/5325158/2617201</a> which refers to Microsoft Documentation at <a href="https://learn.microsoft.com/en-us/visualstudio/extensibility/adding-and-removing-property-pages?view=vs-2015&redirectedfrom=MSDN" rel="nofollow noreferrer">Adding and Removing Property Pages</a>. The article refers to Visual Studio 2015 (later versions should have the same feature).</p>
| 3,110
|
<p>How do I create a unique constraint on an existing table in SQL Server 2005?</p>
<p>I am looking for both the TSQL and how to do it in the Database Diagram.</p>
|
<p>The SQL command is:</p>
<pre><code>ALTER TABLE <tablename> ADD CONSTRAINT
<constraintname> UNIQUE NONCLUSTERED
(
<columnname>
)
</code></pre>
<p>See the full syntax <a href="http://msdn.microsoft.com/en-us/library/ms190273.aspx" rel="noreferrer">here</a>.</p>
<p>If you want to do it from a Database Diagram:</p>
<ul>
<li>right-click on the table and select 'Indexes/Keys'</li>
<li>click the Add button to add a new index</li>
<li>enter the necessary info in the Properties on the right hand side:
<ul>
<li>the columns you want (click the ellipsis button to select)</li>
<li>set Is Unique to Yes</li>
<li>give it an appropriate name</li>
</ul></li>
</ul>
|
<p>In some situations, it could be desirable to ensure the Unique key does not exists before create it. In such cases, the script below might help:</p>
<pre><code>IF Exists(SELECT * FROM sys.indexes WHERE name Like '<index_name>')
ALTER TABLE dbo.<target_table_name> DROP CONSTRAINT <index_name>
GO
ALTER TABLE dbo.<target_table_name> ADD CONSTRAINT <index_name> UNIQUE NONCLUSTERED (<col_1>, <col_2>, ..., <col_n>)
GO
</code></pre>
| 9,065
|
<p>I need to be able to get at the full URL of the page I am on from a user control. Is it just a matter of concatenating a bunch of Request variables together? If so which ones? Or is there a more simpiler way?</p>
|
<p>I usually use <code>Request.Url.ToString()</code> to get the full url (including querystring), no concatenation required.</p>
|
<p>If you need the port number also, you can use</p>
<pre><code>Request.Url.Authority
</code></pre>
<p>Example:</p>
<pre><code>string url = Request.Url.Authority + HttpContext.Current.Request.RawUrl.ToString();
if (Request.ServerVariables["HTTPS"] == "on")
{
url = "https://" + url;
}
else
{
url = "http://" + url;
}
</code></pre>
| 6,191
|
<ul>
<li>What types of applications have you used <a href="http://en.wikipedia.org/wiki/Model_checking" rel="noreferrer">model checking</a> for?</li>
<li>What model checking tool did you use?</li>
<li>How would you summarize your experience w/ the technique, specifically in evaluating its effectiveness in delivering higher quality software? </li>
</ul>
<p>In the course of my studies, I had a chance to use <a href="http://spinroot.com/spin/whatispin.html" rel="noreferrer">Spin</a>, and it aroused my curiosity as to how much actual model checking is going on and how much value are organizations getting out of it. In my work experience, I've worked on business applications, where there is (naturally) no consideration of applying formal verification to the logic. I'd really like to learn about SO folks model checking experience and thoughts on the subject. Will model checking ever become a more widely used developing practice that we should have in our toolkit?</p>
|
<p>I just finished a class on model checking and the big tools we used were <a href="http://spinroot.com/spin/whatispin.html" rel="nofollow noreferrer">Spin</a> and <a href="http://www.cs.cmu.edu/~modelcheck/smv.html" rel="nofollow noreferrer">SMV</a>. We ended up using them to check properties on common synchronization problems, and I found SMV just a little bit easier to use.</p>
<p>Although these tools were fun to use, I think they really shine when you combine them with something that dynamically enforces constraints on your program (so that it's a bit easier to verify 'useful' things about your program). We ended up taking the <a href="http://www.springframework.org/webflow" rel="nofollow noreferrer">Spring WebFlow framework</a>, which uses XML to write a state-machine like file that specifies which web pages can transition to which other ones, and using SMV to be able to perform verification on said applications (<a href="http://cs.ucsb.edu/~cgb/mvcVerification.html" rel="nofollow noreferrer">shameless plug here</a>).</p>
<p>To answer your last question, I think model checking is definitely useful to have, but I lean more towards using unit testing as a technique that makes me feel comfortable about delivering my final product.</p>
|
<p>I used SPIN to find a concurrency issue in PLC software. It found an unsuspected race condition that would have been very tough to find by inspection or testing.</p>
<p>By the way, is there a "SPIN for Dummies" book? I had to learn it out of "The SPIN Model Checker" book and various on-line tutorials.</p>
| 4,475
|
<p>When I try to use an <strong>ssh</strong> command in a shell script, the command just sits there. Do you have an example of how to use <strong>ssh</strong> in a shell script?</p>
|
<p>Depends on what you want to do, and how you use it. If you just want to execute a command remotely and safely on another machine, just use</p>
<pre><code>ssh user@host command
</code></pre>
<p>for example</p>
<pre><code>ssh user@host ls
</code></pre>
<p>In order to do this safely you need to either ask the user for the password during runtime, or set up keys on the remote host.</p>
|
<p>The easiest way is using a certificate for the user that runs the script.</p>
<p>A more complex one implies adding to stdin the password when the shell command asks for it. Expect, perl libraries, show to the user the prompt asking the password (if is interactive, at least), there are a lot of choices.</p>
| 4,873
|
<p>I have a regex that is going to end up being a bit long and it'd make it much easier to read to have it across multiple lines.</p>
<p>I tried this but it just barfs.</p>
<pre><code>preg_match(
'^J[0-9]{7}:\s+
(.*?) #Extract the Transaction Start Date msg
\s+J[0-9]{7}:\s+Project\sname:\s+
(.*?) #Extract the Project Name
\s+J[0-9]{7}:\s+Job\sname:\s+
(.*?) #Extract the Job Name
\s+J[0-9]{7}:\s+',
$this->getResultVar('FullMessage'),
$atmp
);
</code></pre>
<p>Is there are way to pass a regex in the above form to preg_match?</p>
|
<p>You can use the extended syntax:</p>
<pre><code>preg_match("/
test
/x", $foo, $bar);
</code></pre>
|
<p>In PHP the comment syntax looks like this:<pre>(?# Your comment here)</pre></p>
<pre><code>preg_match('
^J[0-9]{7}:\s+
(.*?) (?#Extract the Transaction Start Date msg)
\s+J[0-9]{7}:\s+Project\sname:\s+
(.*?) (?#Extract the Project Name)
\s+J[0-9]{7}:\s+Job\sname:\s+
(.*?) (?#Extract the Job Name)
\s+J[0-9]{7}:\s+
', $this->getResultVar('FullMessage'), $atmp);
</code></pre>
<p>For more information see the <a href="http://nl.php.net/manual/en/regexp.reference.php" rel="nofollow noreferrer">PHP Regular Expression Syntax Reference</a></p>
<p>You can also use the PCRE_EXTENDED (or 'x') <a href="http://nl.php.net/manual/en/reference.pcre.pattern.modifiers.php" rel="nofollow noreferrer">Pattern Modifier</a> as Mark shows in his example.</p>
| 4,259
|
<p>I am looking for a way to generate 2D horizontal templates for manually carving an object. My thought was to produce an STL of the model, generate the G-code, and then transform that into slices. Appreciate any suggestions for where to start. I'm not afraid of getting my hands dirty with python, R, matlab, whatever.</p>
|
<h1>Carving decorative patterns?</h1>
<p>If your templates needs to be used like one does a stencil, that's doable... but paper-thin is not as you can't make that with an FDM printer.</p>
<p>But if you allow 0.2 or even better, 0.5 mm thickness, it is as simple as making a vector graphic, importing it into a suitable CAD package, then extruding it to the relevant thickness, and sending it into the printer.</p>
<p>If you really need it to be thinner, invest in a vinyl cutter, and use the same vector graphic to cut a foil template for one use. Upside: you could use the vinyl to <em>etch</em> the patterns in metal.</p>
<h1>Carving figurines?</h1>
<p>Yes, that's possible too, even easier! Make a 3D model of the finished object in a CAD or 3D modeling software. Either cut up the model right there and export each slice as STL for the printer, or export the whole model and use a secondary software such as MeshMixer to do plane cuts onto the model.</p>
<p>The slices should be at least 0.5 mm thick to allow handling.</p>
<p>It might <em>also</em> be a good idea to use the same model and cut it from a cube, which then is sliced up - that way you get a pattern to press against the outside of the model.</p>
|
<p>I would approach following way. I saw interesting example of using <em>Autodesk Fusion 360</em> to generate moves (G-Code) for carving in vertical slices. Fusion generated moves like for CNC tool in "parallel mode". You can see details in the video <a href="https://www.youtube.com/watch?v=CkRDLPbVNo4" rel="nofollow noreferrer">3D printer cutting styrofoam like CNC router</a> (software setup is presented at 11:00-14:30). Steps/settings important for manual work would be:</p>
<ul>
<li>selecting parallel strategy</li>
<li>steup length and width of tool - reflecting "depth/width of slice"</li>
<li>check the simulation</li>
<li>create NC program - creating the G-Code file</li>
</ul>
<p>I think that even if really working manually, the benefit of such approach would be that you focus on one layer/slice at time, and carve in one depth from the top of "material block" to the line defined be two points (the move in G-Code). The trouble could be actual number of such "G-Code lines": there will be probably too many of them, e.g. to measure each by hand and draw on the sufrface. But maybe this could be reduced with resolution (and quality). You could try to use any G-Code visualizer to project lines (of given single layer/slice) with beamer on the material sufrace.</p>
<p>The depth (real width of slice) could be controlled only manually, to avoid carving too deep.</p>
<p>The video uses parallel carving strategy to work in vertical slices. "Adaptive cleanring" strategy could be used to work horizontally.</p>
| 1,831
|
<p>I got myself the Ender 3. The Home position is about 1 mm left and 2 mm in front of the front left corner. Now, the hotend center axis is 11 mm from the carrier plate with the "Mk 10" cooler mounted right onto a pair of 5 mm pegs that are part of the plate. As I want to change to an e3D v6, which has a diameter of 22 mm, I will have to move out some distance (ca. 13 mm) to the current Z axis. This means, that any Y command will be off by this distance.</p>
<p><strong>How do I reconfigure the Home position to have an offset to the 0-positions gained from the limit switches?</strong></p>
<p>According to Repetier Host it runs on <strong>Marlin 1.0</strong>. Creality offers the firmware on <a href="https://www.creality3d.cn/download/firmware_c0001" rel="nofollow noreferrer">their website</a> as a <strong>.hex</strong> file - which is hard to edit.</p>
|
<p>When homing the printer, the hot end carriage will be instructed to hit the (mechanical or optical) end stops. From this point a well configured firmware knows where to find the origin of the heat bed. </p>
<p>For the printer to know the origin of the bed, offsets are defined in the firmware from the end stop locations to the actual origin of the heat bed. </p>
<p>E.g. in Marlin Firmware this is defined by</p>
<pre><code> #define X_MIN_POS -35 ; move the head 35 mm to the right to place the
; nozzle at X = 0
#define Y_MIN_POS -8 ; move the head 8 mm to the back (or the plate
; forward) to place the nozzle at Y = 0
</code></pre>
<p>When you change the hardware (e.g. carriage), you need to re-calibrate the movement from the end stop location to the origin of the bed. Note that any arbitrary point on the heat bed can be used to re-calibrate this. E.g. the center of the bed can also be used, and is frequently much more easy to re-calibrate as the heated beds usually have rounded corners or are slightly larger than the actual print area (e.g. I have a 300 x 300 mm heat bed that actually measures 315 x 315 mm). Printing a large square on the heat bed will therefore give you a good impression of the offset of the nozzle due to your new carriage design. </p>
<p>Note that, if you cannot or will not flash new firmware, an alternative solution exists to set new incremental offset values using the <a href="https://reprap.org/wiki/G-code#M206:_Offset_axes" rel="noreferrer"><code>M206</code></a> command <strong>IF</strong> <a href="https://reprap.org/wiki/G-code#M206:_Offset_axes" rel="noreferrer">your current firmware supports</a> this.</p>
<p>A detailed description to re-calibrate is found in answer <a href="https://3dprinting.stackexchange.com/a/6376/5740">How to center my prints on the build platform?</a> or in external link <a href="https://www.thingiverse.com/thing:2280529" rel="noreferrer">Bed center calibration</a>.</p>
|
<p><em>Following on from 0scar's answer</em></p>
<hr />
<p>To change or obtain your EEPROM settings you need to open Repetier Host (for Linux or Windows, v2.1.3 - the OSX version I tried, v1.1.0, didn't seem to have this functionality).</p>
<h3>To change existing settings</h3>
<p>From <a href="https://forum.repetier.com/discussion/4641/how-to-make-changes-to-the-eeprom-data" rel="nofollow noreferrer">How to make changes to the EEPROM data</a>. Apparently there is an EEPROM editor available (in Repetier Host). From <a href="https://forum.repetier.com/discussion/comment/18712/#Comment_18712" rel="nofollow noreferrer">this post</a>:</p>
<blockquote>
<p>If you see it in eeprom editor just change them. If it is repetier-firmware based it will store changes in eeprom on pressing "ok".</p>
</blockquote>
<h3>To retrieve existing settings</h3>
<p><a href="https://forum.repetier.com/discussion/comment/2817/#Comment_2817" rel="nofollow noreferrer">This post</a> from <a href="https://forum.repetier.com/discussion/933/retrieval-of-existing-settings" rel="nofollow noreferrer">retrieval of existing settings...</a>, shows how:</p>
<blockquote>
<p>To copy eeprom data:</p>
<ul>
<li>Connect with host</li>
<li>Open eeprom settings</li>
<li>Select export eeprom settings. That saves all data in a epr file and you can later use import eepsom settings to rewrite it.</li>
</ul>
</blockquote>
<p>An example of the resulting file is shown in the question, <a href="https://3dprinting.stackexchange.com/questions/4184/help-with-repetier-firmware-variables-dimension-dual-delta-j-group-robotics">Help with Repetier firmware variables (Dimension Dual Delta - J Group Robotics)</a>, a sample of which I have included below:</p>
<pre><code><Repetier-Firmware-EEPROM>
<epr pos="1028" type="0" value="0">Language</epr>
<epr pos="75" type="2" value="115200">Baudrate</epr>
<epr pos="129" type="3" value="32.752">Filament printed [m]</epr>
<epr pos="125" type="2" value="21644">Printer active [s]</epr>
<epr pos="79" type="2" value="0">Max. inactive time [ms,0=off]</epr>
</code></pre>
<hr />
<p>However, you would appear to have to be running Repetier firmware for these two solutions to work, and not Marlin (but I may be wrong).</p>
| 963
|
<p>I'm working on a <strong>multithreaded</strong> C++ application that is corrupting the heap. The usual tools to locate this corruption seem to be inapplicable. Old builds (18 months old) of the source code exhibit the same behaviour as the most recent release, so this has been around for a long time and just wasn't noticed; on the downside, source deltas can't be used to identify when the bug was introduced - there are <em>a lot</em> of code changes in the repository.</p>
<p>The prompt for crashing behaviuor is to generate throughput in this system - socket transfer of data which is munged into an internal representation. I have a set of test data that will periodically cause the app to exception (various places, various causes - including heap alloc failing, thus: heap corruption).</p>
<p>The behaviour seems related to CPU power or memory bandwidth; the more of each the machine has, the easier it is to crash. Disabling a hyper-threading core or a dual-core core reduces the rate of (but does not eliminate) corruption. This suggests a timing related issue.</p>
<p>Now here's the rub:<br>
When it's run under a lightweight debug environment (say <code>Visual Studio 98 / AKA MSVC6</code>) the heap corruption is reasonably easy to reproduce - ten or fifteen minutes pass before something fails horrendously and exceptions, like an <code>alloc;</code> when running under a sophisticated debug environment (Rational Purify, <code>VS2008/MSVC9</code> or even Microsoft Application Verifier) the system becomes memory-speed bound and doesn't crash (Memory-bound: CPU is not getting above <code>50%</code>, disk light is not on, the program's going as fast it can, box consuming <code>1.3G</code> of 2G of RAM). So, <strong>I've got a choice between being able to reproduce the problem (but not identify the cause) or being able to idenify the cause or a problem I can't reproduce.</strong></p>
<p>My current best guesses as to where to next is:</p>
<ol>
<li>Get an insanely grunty box (to replace the current dev box: 2Gb RAM in an <code>E6550 Core2 Duo</code>); this will make it possible to repro the crash causing mis-behaviour when running under a powerful debug environment; or</li>
<li>Rewrite operators <code>new</code> and <code>delete</code> to use <code>VirtualAlloc</code> and <code>VirtualProtect</code> to mark memory as read-only as soon as it's done with. Run under <code>MSVC6</code> and have the OS catch the bad-guy who's writing to freed memory. Yes, this is a sign of desperation: who the hell rewrites <code>new</code> and <code>delete</code>?! I wonder if this is going to make it as slow as under Purify et al.</li>
</ol>
<p>And, no: Shipping with Purify instrumentation built in is not an option.</p>
<p>A colleague just walked past and asked "Stack Overflow? Are we getting stack overflows now?!?"</p>
<p>And now, the question: <strong>How do I locate the heap corruptor?</strong></p>
<hr>
<p>Update: balancing <code>new[]</code> and <code>delete[]</code> seems to have gotten a long way towards solving the problem. Instead of 15mins, the app now goes about two hours before crashing. Not there yet. Any further suggestions? The heap corruption persists.</p>
<p>Update: a release build under Visual Studio 2008 seems dramatically better; current suspicion rests on the <code>STL</code> implementation that ships with <code>VS98</code>.</p>
<hr>
<blockquote>
<ol start="3">
<li>Reproduce the problem. <code>Dr Watson</code> will produce a dump that might be helpful in further analysis. </li>
</ol>
</blockquote>
<p>I'll take a note of that, but I'm concerned that Dr Watson will only be tripped up after the fact, not when the heap is getting stomped on.</p>
<blockquote>
<p>Another try might be using <code>WinDebug</code> as a debugging tool which is quite powerful being at the same time also lightweight.</p>
</blockquote>
<p>Got that going at the moment, again: not much help until something goes wrong. I want to catch the vandal in the act.</p>
<blockquote>
<p>Maybe these tools will allow you at least to narrow the problem to certain component.</p>
</blockquote>
<p>I don't hold much hope, but desperate times call for...</p>
<blockquote>
<p>And are you sure that all the components of the project have correct runtime library settings (<code>C/C++ tab</code>, Code Generation category in VS 6.0 project settings)?</p>
</blockquote>
<p>No I'm not, and I'll spend a couple of hours tomorrow going through the workspace (58 projects in it) and checking they're all compiling and linking with the appropriate flags.
<hR>
Update: This took 30 seconds. Select all projects in the <code>Settings</code> dialog, unselect until you find the project(s) that don't have the right settings (they all had the right settings).</p>
|
<p>My first choice would be a dedicated heap tool such as <a href="https://support.microsoft.com/en-us/kb/286470" rel="noreferrer">pageheap.exe</a>.</p>
<p>Rewriting new and delete might be useful, but that doesn't catch the allocs committed by lower-level code. If this is what you want, better to Detour the <code>low-level alloc API</code>s using Microsoft Detours.</p>
<p>Also sanity checks such as: verify your run-time libraries match (release vs. debug, multi-threaded vs. single-threaded, dll vs. static lib), look for bad deletes (eg, delete where delete [] should have been used), make sure you're not mixing and matching your allocs.</p>
<p>Also try selectively turning off threads and see when/if the problem goes away.</p>
<p>What does the call stack etc look like at the time of the first exception?</p>
|
<p>Graeme's suggestion of custom malloc/free is a good idea. See if you can characterize some pattern about the corruption to give you a handle to leverage.</p>
<p>For example, if it is always in a block of the same size (say 64 bytes) then change your malloc/free pair to always allocate 64 byte chunks in their own page. When you free a 64 byte chunk then set the memory protection bits on that page to prevent reads and wites (using VirtualQuery). Then anyone attempting to access this memory will generate an exception rather than corrupting the heap.</p>
<p>This does assume that the number of outstanding 64 byte chunks is only moderate or you have a lot of memory to burn in the box!</p>
| 2,350
|
<p>Inversion of Control (IoC) can be quite confusing when it is first encountered.</p>
<ol>
<li>What is it?</li>
<li>Which problem does it solve?</li>
<li>When is it appropriate to use and when not?</li>
</ol>
|
<p>The <strong><code>Inversion-of-Control</code> (IoC)</strong> pattern, is about providing <em>any kind</em> of <code>callback</code> (which controls reaction), instead of acting ourself directly (in other words, inversion and/or redirecting control to external handler/controller). The <strong><code>Dependency-Injection</code> (DI)</strong> pattern is a more specific version of IoC pattern, and is all about removing dependencies from your code.</p>
<blockquote>
<p>Every <code>DI</code> implementation can be considered <code>IoC</code>, but one should not call it <code>IoC</code>, because implementing Dependency-Injection is harder than callback (Don't lower your product's worth by using general term "IoC" instead).</p>
</blockquote>
<p>For DI example, say your application has a text-editor component, and you want to provide spell checking. Your standard code would look something like this:</p>
<pre class="lang-cs prettyprint-override"><code>public class TextEditor {
private SpellChecker checker;
public TextEditor() {
this.checker = new SpellChecker();
}
}
</code></pre>
<p>What we've done here creates a dependency between the <code>TextEditor</code> and the <code>SpellChecker</code>.
In an IoC scenario we would instead do something like this:</p>
<pre class="lang-cs prettyprint-override"><code>public class TextEditor {
private IocSpellChecker checker;
public TextEditor(IocSpellChecker checker) {
this.checker = checker;
}
}
</code></pre>
<p>In the first code example we are instantiating <code>SpellChecker</code> (<code>this.checker = new SpellChecker();</code>), which means the <code>TextEditor</code> class directly depends on the <code>SpellChecker</code> class.</p>
<p>In the second code example we are creating an abstraction by having the <code>SpellChecker</code> dependency class in <code>TextEditor</code>'s constructor signature (not initializing dependency in class). This allows us to call the dependency then pass it to the TextEditor class like so:</p>
<pre class="lang-cs prettyprint-override"><code>SpellChecker sc = new SpellChecker(); // dependency
TextEditor textEditor = new TextEditor(sc);
</code></pre>
<p>Now the client creating the <code>TextEditor</code> class has control over which <code>SpellChecker</code> implementation to use because we're injecting the dependency into the <code>TextEditor</code> signature.</p>
|
<p>Inversion of control is an indicator for a shift of responsibility in the program.</p>
<p>There is an inversion of control every time when a dependency is granted ability to directly act on the caller's space.</p>
<p>The smallest IoC is passing a variable by reference, lets look at non-IoC code first:</p>
<pre><code>function isVarHello($var) {
return ($var === "Hello");
}
// Responsibility is within the caller
$word = "Hello";
if (isVarHello($word)) {
$word = "World";
}
</code></pre>
<p>Let's now invert the control by shifting the responsibility of a result from the caller to the dependency:</p>
<pre><code>function changeHelloToWorld(&$var) {
// Responsibility has been shifted to the dependency
if ($var === "Hello") {
$var = "World";
}
}
$word = "Hello";
changeHelloToWorld($word);
</code></pre>
<hr />
<p>Here is another example using OOP:</p>
<pre><code><?php
class Human {
private $hp = 0.5;
function consume(Eatable $chunk) {
// $this->chew($chunk);
$chunk->unfoldEffectOn($this);
}
function incrementHealth() {
$this->hp++;
}
function isHealthy() {}
function getHungry() {}
// ...
}
interface Eatable {
public function unfoldEffectOn($body);
}
class Medicine implements Eatable {
function unfoldEffectOn($human) {
// The dependency is now in charge of the human.
$human->incrementHealth();
$this->depleted = true;
}
}
$human = new Human();
$medicine = new Medicine();
if (!$human->isHealthy()) {
$human->consume($medicine);
}
var_dump($medicine);
var_dump($human);
</code></pre>
<p><sub>*) Disclaimer: The real world human uses a message queue.</sub></p>
| 2,521
|
<p>I printed a G1/8 thread in PLA where I can connect a compressor to have a small pressure container. Even though all measurements are correct and it screws in fine, it still leaks air.</p>
<p>Is there a way to make 3D prints airtight?</p>
|
<p>Yes.</p>
<p>The issue is, that there are small gaps between the layers. But you can coat the print in an airtight material. While epoxy and similar materials work very well, they are somewhat too viscous and take a long time to cure.</p>
<p>My special recipe for coating PLA prints with a fast-curing airtight thin layer is:</p>
<ol>
<li>Dissolve 1 g Paraloid B-72 in 20 ml acetone.</li>
<li>Dip or otherwise evenly coat the print and dry at room temperature for 10-20 minutes.</li>
</ol>
|
<p>Yes.</p>
<p>The issue is, that there are small gaps between the layers. But you can coat the print in an airtight material. While epoxy and similar materials work very well, they are somewhat too viscous and take a long time to cure.</p>
<p>My special recipe for coating PLA prints with a fast-curing airtight thin layer is:</p>
<ol>
<li>Dissolve 1 g Paraloid B-72 in 20 ml acetone.</li>
<li>Dip or otherwise evenly coat the print and dry at room temperature for 10-20 minutes.</li>
</ol>
| 2,165
|
<p>I noticed that the most popular tag (82 questions tagged) is <a href="https://3dprinting.stackexchange.com/questions/tagged/3d-printer">3d-printer</a>, and that we also have a <a href="https://3dprinting.stackexchange.com/questions/tagged/3d-printing">3d-printing</a> tag (23 questions). These seem extremely redundant to me, given that they <em>should</em> apply to any question that is on-topic and thus serve no practical purpose. These tags are simply too broad.</p>
<p>The usage guidance for 3d-printer is quite board ("Questions about a specific brand, model, or type of 3D printer.") and 3d-printing does not even have one.</p>
<p>I would suggest to get rid of these tags. For comparison, <a href="https://stackoverflow.com/tags">Stack Exchange</a> does not have a programming tag either. However, they do have various tags that end in "-programming", such as "functional-programming", "linear-programming", etc... Our equivalents would be fdm(-printing), sla(-printing),...</p>
|
<p>This tag has been removed from the system and made intrinsic. </p>
<p><a href="https://3dprinting.stackexchange.com/questions/tagged/untagged">Please cleanup the questions that now have no tags...</a></p>
|
<p>The fact that there is a synonym appears to be the reason that both tags are still hanging around, in the <a href="https://3dprinting.stackexchange.com/tags/synonyms">list of synonyms</a>:</p>
<blockquote>
<p><a href="https://i.stack.imgur.com/RpBnK.png" rel="nofollow noreferrer" title="Synonyms"><img src="https://i.stack.imgur.com/RpBnK.png" alt="Synonyms" title="Synonyms"></a></p>
</blockquote>
<p>and on the tag page</p>
<blockquote>
<p><a href="https://i.stack.imgur.com/oxuXK.png" rel="nofollow noreferrer" title="3d-printer tag"><img src="https://i.stack.imgur.com/oxuXK.png" alt="3d-printer tag" title="3d-printer tag"></a></p>
</blockquote>
<p>I have deleted the synonym and hopefully that will clear things up once and for all.</p>
| 35
|
<p>I am trying to upload a file or stream of data to our web server and I cant find a decent way of doing this. I have tried both <code>WebClient</code> and <code>WebRequest</code> both have their problems. </p>
<p><strong>WebClient</strong><br>
Nice and easy but you do not get any notification that the asynchronous upload has completed, and the <code>UploadProgressChanged</code> event doesnt get called back with anything useful. The alternative is to convert your binary data to a string and use <code>UploadStringASync</code> because then at least you get a <code>UploadStringCompleted</code>, problem is you need a lot of ram for big files as its encoding all the data and uploading it in one go.</p>
<p><strong>HttpWebRequest</strong><br>
Bit more complicated but still does what is needed, problem I am getting is that even though it is called on a background thread (supposedly), it still seems to be blocking my UI and the whole browser until the upload has completed which doesnt seem quite right.</p>
<p>Normal .net does have some appropriate <code>WebClient</code> methods for <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient.onuploaddatacompleted.aspx" rel="nofollow noreferrer">OnUploadDataCompleted</a> and progress but these arent available in Silverlight .net ... big omission I think!</p>
<p>Does anyone have any solutions, I need to upload multiple binary files preferrably with a progress but I need to perform some actions when the files have completed their upload.</p>
<p>Look forward to some help with this.</p>
|
<p>The way i get around it is through INotifyPropertyChanged and event notification.</p>
<p>The essentials:</p>
<pre><code> public void DoIt(){
this.IsUploading = True;
WebRequest postRequest = WebRequest.Create(new Uri(ServiceURL));
postRequest.BeginGetRequestStream(new AsyncCallback(RequestOpened), postRequest);
}
private void RequestOpened(IAsyncResult result){
WebRequest req = result.AsyncState as WebRequest;
req.BeginGetResponse(new AsyncCallback(GetResponse), req);
}
private void GetResponse(IAsyncResult result)
{
WebRequest req = result.AsyncState as WebRequest;
string serverresult = string.Empty;
WebResponse postResponse = req.EndGetResponse(result);
StreamReader responseReader = new StreamReader(postResponse.GetResponseStream());
this.IsUploading= False;
}
private Bool_IsUploading;
public Bool IsUploading
{
get { return _IsUploading; }
private set
{
_IsUploading = value;
OnPropertyChanged("IsUploading");
}
}
</code></pre>
<p>Right now silverlight is a PiTA because of the double and triple Async calls. </p>
|
<p>Matt Berseth had some thoughts in this, might help:</p>
<p><a href="http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html" rel="nofollow noreferrer">http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html</a></p>
<p><strong>@Dan</strong> - Apologies mate, I coulda sworn Matt's article was about Silverlight, but it's quite clearly not. Blame it on those two big glasses of Chilean red I just downed. :-) </p>
| 3,372
|
<p>A fellow maker has tried printing a 3D model in clear PLA (<5% infill, 1 or 2 perimeters), burying it most of the way into casting sand, and then pouring molten aluminum. This melts and burns the PLA, and the aluminum takes the space that the printed model used to take.</p>
<p>There's plenty of room for improvement in his process, but I'm asking about what he can do in terms of the 3D printing process to make his prints more casting-friendly.</p>
<p>What print settings are (generally) best for use in this sort of casting?</p>
<p>What materials, if any, would work better than unpigmented PLA? (Must be a material that a typical thermoplastic FDM printer can handle.)</p>
<p>Any other tips or considerations?</p>
|
<p>Print a two part negative (mold) of your objects.
<a href="http://www.thingiverse.com/thing:31581" rel="nofollow">http://www.thingiverse.com/thing:31581</a></p>
<p><a href="https://pinshape.com/blog/how-to-generate-a-3d-printed-mold-for-an-object/" rel="nofollow">https://pinshape.com/blog/how-to-generate-a-3d-printed-mold-for-an-object/</a></p>
<p>Melt and pour wax into the mold. Praffin wax melts at only 37C, not an issue for both PLA and ABS.
Use the wax object for casting, not ABS/PLA/etc.
The mold is also reusable this way.</p>
<p>To prevent the wax from sticking to the mold, something might be applied to the surface. Oil maybe?</p>
|
<p>I believe casting typically uses a wax for the positive when using casting sand. So, I would suggest using <a href="http://www.machinablewax.com/product.php?product=52" rel="nofollow">wax filament</a> in your 3D printer.</p>
<p>I would try to shy away from hard polymers like PLA/ABS/Nylon (all typical 3D printing filaments) if the goal is to "melt it away" because a certain amount of the plastic material will either bind itself with the metal or large chunks of plastic will cause inclusions in your part. Both of these side effects will potentially degrade the quality/strength of your part.</p>
<p>I haven't personally used wax filament, so I can't tell you what the correct setting are. However, you can get most of the necessary information from whichever supplier you go through. I might suggest running your machine slower when using a low-melting filament such as wax or PVA (water soluble).</p>
| 128
|
<p>By default the webjump hotlist has the following which I use quite often:</p>
<pre><code>M-x webjump RET Google
M-x webjump RET Wikipedia
</code></pre>
<p>How can I add 'Stackoverflow' to my list?</p>
|
<p>Here's some example code in <a href="http://www.opensource.apple.com/darwinsource/10.0/emacs-39/emacs/lisp/webjump.el" rel="nofollow noreferrer">a webjump.el file on a site run by Apple:</a></p>
<pre><code>;; (require 'webjump)
;; (global-set-key "\C-cj" 'webjump)
;; (setq webjump-sites
;; (append '(
;; ("My Home Page" . "www.someisp.net/users/joebobjr/")
;; ("Pop's Site" . "www.joebob-and-son.com/")
;; )
;; webjump-sample-sites))
</code></pre>
|
<p>Here's some example code in <a href="http://www.opensource.apple.com/darwinsource/10.0/emacs-39/emacs/lisp/webjump.el" rel="nofollow noreferrer">a webjump.el file on a site run by Apple:</a></p>
<pre><code>;; (require 'webjump)
;; (global-set-key "\C-cj" 'webjump)
;; (setq webjump-sites
;; (append '(
;; ("My Home Page" . "www.someisp.net/users/joebobjr/")
;; ("Pop's Site" . "www.joebob-and-son.com/")
;; )
;; webjump-sample-sites))
</code></pre>
| 8,408
|
<p>I know that there are a few (automatic) ways to create a data access layer to manipulate an existing database (LINQ to SQL, Hibernate, etc...). But I'm getting kind of tired (and I believe that there should be a better way of doing things) of stuff like:</p>
<ol>
<li>Creating/altering tables in Visio</li>
<li>Using Visio's "Update Database" to create/alter the database</li>
<li>Importing the tables into a "LINQ to SQL classes" object</li>
<li>Changing the code accordingly</li>
<li>Compiling</li>
</ol>
<p>What about a way to generate the database schema from the objects/entities definition? I can't seem to find good references for tools like this (and I would expect some kind of built-in support in at least some frameworks).</p>
<p>It would be perfect if I could just:</p>
<ol>
<li>Change the object definition</li>
<li>Change the code that manipulates the object</li>
<li>Compile (the database changes are done auto-magically)</li>
</ol>
|
<p>Check out <a href="http://wiki.dataobjects.net" rel="nofollow noreferrer">DataObjects.Net</a> - is is designed to support exactly this case. Code only, and nothing else. Its <a href="http://wiki.dataobjects.net/index.php?title=Schema_upgrade" rel="nofollow noreferrer">schema upgrade layer</a> is probably the most featured one you can find, and it really fully abstracts schema upgrade SQL.</p>
<p>Check out <a href="http://wiki.dataobjects.net/index.php?title=Video" rel="nofollow noreferrer">product video</a> - you'll notice nothing additional is made to sync the schema. Schema upgrade sample shows the intended usage of this feature.</p>
|
<p>Some of the really big dogs, such as <a href="http://ca.com/us/products/product.aspx?id=260" rel="nofollow noreferrer">ERwin Data Modeler</a>, will go object to DB. You need to have the big bucks to afford the product though.</p>
| 4,883
|
<p>I have a Creality Ender 5 Pro which has been working properly for some time. During my last print, the axis motors just suddenly stopped working while the extruder motor continued to work properly.</p>
<p>In fact, when I connect the extruder motor wire to any of the axis motors, they respond correctly (mimicking the extruder motor) but neither works or moves when connected to its own wire(s). As a result the printer does not print anymore.</p>
<p>Here's what I've tried:</p>
<ul>
<li>Switching the wires around to check if any motors are damaged (none are).</li>
<li>Restarting the Creality</li>
<li>Checking the output on the power source (which is 24 V and about 14 A)</li>
<li>Checking to make sure all motor wires are connected correctly on the SKR MINI CONTROLLER (all seem fine) and checking that the board is powered.</li>
<li>All external connections also seem fine.</li>
</ul>
<p>I'm quite confused why the axis motors would not be working all of a sudden. I'll appreciate your help if you've faced this problem before.</p>
|
<p>The Creality V1.1.5 board was fried. I replaced it with a BIGTREETECH SKR MINI E3 V2.0 32BIT CONTROLLER. After struggling to find a corresponding firmware for the Ender 5 pro, the axis motors worked correctly.</p>
|
<p>Usually, steppers not working can be found when the lines are broken. Often this is an unplugged Stepper, but OP checked that.</p>
<p>That 3 steppers at once failed could indicate a bad firmware update, which OP didn't do. So it is sadly a case of blue smoke from the board. Most likely the stepper drivers are either shortened out or get no signal.</p>
<p>I am sorry, but replacement seems necessary.</p>
| 1,866
|
<p>Maven spews out far too many lines of output to my taste (I like the Unix way: no news is good news).</p>
<p>I want to get rid of all <code>[INFO]</code> lines, but I couldn't find any mention of an argument or config settings that controls the verbosity of Maven.</p>
<p>Is there no LOG4J-like way to set the log level?</p>
|
<p>You can try the <a href="http://maven.apache.org/ref/current/maven-embedder/cli.html" rel="noreferrer"><code>-q</code> switch</a>.</p>
<blockquote>
<p><code>-q</code>,<code>--quiet</code> Quiet output - only show errors</p>
</blockquote>
|
<p>Maven 3.1.x uses SLF4j for logging, you can find instructions how to configure it at <a href="https://maven.apache.org/maven-logging.html" rel="nofollow noreferrer">https://maven.apache.org/maven-logging.html</a></p>
<p>In short: Either modify <code>${MAVEN_HOME}/conf/logging/simplelogger.properties</code>, or set the same properties via the <code>MAVEN_OPTS</code> environment variable.</p>
<p>For example: setting <code>MAVEN_OPTS</code> to <code>-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn</code> configures the logging of the batch mode transfer listener, and <code>-Dorg.slf4j.simpleLogger.defaultLogLevel=warn</code> sets the default log level.</p>
| 9,650
|
<p>Grails makes it very easy to configure datasources for different environments (development, test, production) in its DataSources.groovy file, but there seems to be no facility for configuring multiple datasources in one environment. What to I do if I need to access several databases from the same Grails application?</p>
|
<p>Connecting different databases in different domain classes is very easy in Grails 2.x.x.</p>
<p>for example </p>
<pre><code>development {
dataSource {//DEFAULT data source
.
.
}
dataSource_admin { //Convention is dataSource_name
url = "//db url"
driverClassName = "oracle.jdbc.driver.OracleDriver"
username = "test"
password = 'test123'
}
dataSource_users {
}
}
</code></pre>
<p>You can use any datasources in your domain classes by </p>
<pre><code>class Role{
static mapping = {
datasource 'users'
}
}
class Product{
static mapping = {
datasource 'admin'
}
}
</code></pre>
<p><a href="http://healthycoder.in/multiple-data-sources-in-grails-2-0/">For more details look at this</a></p>
|
<p>The following post seems to be the best source of information on the subject:</p>
<p><a href="http://www.nabble.com/How-to-get-multi-dataSource-in-grails--td12291409.html#a12322879" rel="nofollow noreferrer">How to get mutli-dataSource in grails</a></p>
<p>It boils down to:</p>
<ul>
<li>Define datasource1 in DevelopmentDataSource</li>
<li>Define datasource2 in resources.xml</li>
<li>Write a DAO for CRUD of the domain objects using datasource2</li>
<li>In hibernate.cfg.xml, list all domain objects. </li>
</ul>
<p>Only the first datasource will have dynamic finder methods.</p>
<p>If its a really simple query you are after and don't mind not having the ORM features you could use Groovy SQL or the native SQL features of Hibernate.</p>
| 6,230
|
<p>Basically I'm going to go a bit broad here and ask a few questions to get a bit of a picture of how people are handling UI these days.</p>
<p>Lately I've found it pretty easy to do some fancy things with UI design and with WPF specifically we're finding new ways to do layouts that are better looking and more functional for the user, but in contrast one of the business focused guys at our local .NET User Group wouldn't even think of using WPF until it had a datagrid that he could use to make Excel like input forms.</p>
<ol>
<li><p>So basically, have you rethought the design of your business apps as you move to Web/WPF/Silverlight designs, because for us at least - in winforms we kept things fairly functional and uniform, or are you trying to keep that "known" UI?</p></li>
<li><p>Would a dedicated design guy (for larger teams), or a dev with more design chops rank higher when looking at hiring these days? (Check out what a designer did for <a href="http://www.hanselman.com/blog/LearningWPFWithBabySmashManuallyManagingClickOnceAndSomeMoreDesignerGoodness.aspx" rel="nofollow noreferrer">Scott Hanselman's BabySmash</a> and <a href="http://codebetter.com/blogs/glenn.block/archive/2008/05/08/wpf-from-this-to-that-wow.aspx" rel="nofollow noreferrer">Microsoft's Prism demo</a>)</p></li>
<li><p>Are there any design hints/tips/guidelines you use for your UI - especially for WPF?</p></li>
<li><p>What sites would you recommend for design?</p></li>
</ol>
|
<p>I recommend that you read <a href="https://rads.stackoverflow.com/amzn/click/com/0789723107" rel="nofollow noreferrer" rel="nofollow noreferrer">Steve Krug's Don't Make Me Think</a> first. The book has a great checklist of things that you have to take into consideration when designing your UIs. While it's focused on web usability, a lot of the lessons therein are valuable even to desktop application designers.</p>
<p>That being said, whether you use Windows forms or WPF or Flash or whatever new and shiny thing that comes around is, it is of utmost importance to hire either a) a real designer, or b) a development guy with a lot of UI design experience, either of which who can provide you a serious URL for their design portfolio. It will help a lot not only in improving the design of your application but also unburdening your developers from thinking about UI design, and allow them to focus on the back-end code.</p>
<p>As for "business focused" guys -- it would be really great if you would get the opinion of actual customers and stake holders, and have them do some usability testing for your application. It's their opinion that would matter most.</p>
<p>I think it would not be difficult to get a good designer up to speed on <a href="http://www.microsoft.com/expression/products/Overview.aspx?key=blend" rel="nofollow noreferrer">Microsoft Expression Blend</a> to whip up some good XAML designs that your team could use to come up with a really good product.</p>
|
<p>@David H Aust That's part of the reason for asking the question - with these newer tools like WPF that lend themselves to providing newer, more intricate, and at the same time simpler for the user, interfaces that we might need to adapt to new ways of doing things.</p>
<p>And trying to find out who else is adapting/interested and what they are doing, and where they get some inspiration, knowledge or help :)</p>
<p>IE: This is me being proactive about change in possibly the slackest manner ever, short of actively googling :) </p>
<p>^ That was a joke, to make it clear, I'm actually pretty active about learning new stuff, I'm just finding some of the crowdsourcing stackoverflow vs googling pretty interesting :)</p>
| 6,214
|
<p>I'm responsible for some test database servers. Historically, too many other poeple have access to them. They run on <code>SQL Server 2005</code>. </p>
<p>I've been writing queries and wrapping them in scripts so I can run a regular audit of rights. Finding out which users had Administrator rights on the server itself was fine, as was finding out who had the <code>sysadmin</code> role on their login - it was a single line query for the latter.</p>
<p>But how to find out which logins have a User Mapping to a particular (or any) database? </p>
<p>I can find the <code>sys.database_principals</code> and <code>sys.server_principals</code> tables. I have located the <code>sys.databases table</code>. I haven't worked out how to find out which users have rights on a database, and if so, what. </p>
<p>Every Google search brings up people manually using the User Mapping pane of the Login dialog, rather than using a query to do so. Any ideas?</p>
|
<p>Check out this msdn reference article on <a href="http://msdn.microsoft.com/en-us/library/ms189802.aspx" rel="nofollow noreferrer">Has_Perms_By_Name</a>. I think you're really interested in examples D, F and G</p>
<hr>
<p>Another idea... I fired up SQL profiler and clicked on the ObjectExplorer->Security->Users. This resulted in (approx) the following query being issued.</p>
<pre><code>SELECT *
FROM
sys.database_principals AS u
LEFT OUTER JOIN sys.database_permissions AS dp
ON dp.grantee_principal_id = u.principal_id and dp.type = N'CO'
WHERE (u.type in ('U', 'S', 'G', 'C', 'K'))
ORDER BY [Name] ASC
</code></pre>
|
<pre><code>
select * from Master.dbo.syslogins l inner join sys.sysusers u on l.sid = u.sid
</code></pre>
<p>This will get you what users are mapped to which logins within a single database.</p>
| 9,180
|
<p>On a Creality CR-10 Max, there is a bag of unidentified spares, which include three unmarked nozzles.</p>
<p>There is a needle that is exactly 0.4 mm in diameter, which needle fits exactly inside one of nozzles. It also fits loosely in the largest nozzle, which diameter looks like it's really close to 0.8 mm on my digital caliper. The smallest one has only room for the tip of the needle, and the digital caliper reads 0.34 mm on the tip of the needle when pushed from the inside of the nozzle.</p>
<p>I assume the sizes are: 0.8 mm, 0.4 mm and 0.3 mm.</p>
<p>Can you tell me how to measure the diameter with better accuracy?</p>
|
<p>I've designed similar sensor casings, sometimes the filament catches a ridge/ledge or part of the cavity, even when it is chamfered or rounded. The arm of the limit switch pushes the filament up, away from the filament straight path.</p>
<p>Have you tried cutting the filament under a very sharp angle, that may work.</p>
|
<p>Here is 3D model that better explains why it was catching and how to remedy the problem:</p>
<p><a href="https://i.stack.imgur.com/ooe48.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ooe48.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/dTy92.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dTy92.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/m4Y91.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m4Y91.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/Pv4Op.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pv4Op.png" alt="enter image description here" /></a></p>
<p>The filament is likely to have some twists and the bevel you create may not be in the correct orientation once it catches the ridge.</p>
<p>The out hole is not chamfered on the inside, as it is drilled from the outside, and I guess a chamfer on the inside is not available at this price range.</p>
<p>I found that twisting the filament 90° at most one way or the other always helps the filament finds its way. It can be tricky because of the small diameter/stiffness of the filament, with the spool still attached to the other end.</p>
| 1,706
|
<p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><strong>NOTE:</strong> It should not include methods. Only fields.</p>
|
<p>Note that best practice in Python 2.7 is to use <em><a href="https://www.python.org/doc/newstyle/" rel="noreferrer">new-style</a></em> classes (not needed with Python 3), i.e.</p>
<pre><code>class Foo(object):
...
</code></pre>
<p>Also, there's a difference between an 'object' and a 'class'. To build a dictionary from an arbitrary <em>object</em>, it's sufficient to use <code>__dict__</code>. Usually, you'll declare your methods at class level and your attributes at instance level, so <code>__dict__</code> should be fine. For example:</p>
<pre class="lang-python prettyprint-override"><code>>>> class A(object):
... def __init__(self):
... self.b = 1
... self.c = 2
... def do_nothing(self):
... pass
...
>>> a = A()
>>> a.__dict__
{'c': 2, 'b': 1}
</code></pre>
<p>A better approach (suggested by <a href="https://stackoverflow.com/users/409638/robert">robert</a> in comments) is the builtin <a href="https://docs.python.org/3/library/functions.html#vars" rel="noreferrer"><code>vars</code></a> function:</p>
<pre class="lang-python prettyprint-override"><code>>>> vars(a)
{'c': 2, 'b': 1}
</code></pre>
<p>Alternatively, depending on what you want to do, it might be nice to inherit from <code>dict</code>. Then your class is <em>already</em> a dictionary, and if you want you can override <code>getattr</code> and/or <code>setattr</code> to call through and set the dict. For example:</p>
<pre><code>class Foo(dict):
def __init__(self):
pass
def __getattr__(self, attr):
return self[attr]
# etc...
</code></pre>
|
<h2>PYTHON 3:</h2>
<pre><code>class DateTimeDecoder(json.JSONDecoder):
def __init__(self, *args, **kargs):
JSONDecoder.__init__(self, object_hook=self.dict_to_object,
*args, **kargs)
def dict_to_object(self, d):
if '__type__' not in d:
return d
type = d.pop('__type__')
try:
dateobj = datetime(**d)
return dateobj
except:
d['__type__'] = type
return d
def json_default_format(value):
try:
if isinstance(value, datetime):
return {
'__type__': 'datetime',
'year': value.year,
'month': value.month,
'day': value.day,
'hour': value.hour,
'minute': value.minute,
'second': value.second,
'microsecond': value.microsecond,
}
if isinstance(value, decimal.Decimal):
return float(value)
if isinstance(value, Enum):
return value.name
else:
return vars(value)
except Exception as e:
raise ValueError
</code></pre>
<p>Now you can use above code inside your own class :</p>
<pre><code>class Foo():
def toJSON(self):
return json.loads(
json.dumps(self, sort_keys=True, indent=4, separators=(',', ': '), default=json_default_format), cls=DateTimeDecoder)
Foo().toJSON()
</code></pre>
| 8,675
|
<p>When you execute a SQL query, you have to clean your strings or users can execute malicious SQL on your website.</p>
<p>I usually just have a function escape_string(blah), which:</p>
<ul>
<li>Replaces escapes (<code>\</code>) with double escapes (<code>\\</code>).</li>
<li>Replaces single quotes (<code>'</code>) with an escaped single quote (<code>\'</code>). </li>
</ul>
<p>Is this adequate? Is there a hole in my code? Is there a library which can do this quickly and reliably for me?</p>
<p>I'd like to see graceful solutions in Perl, Java, and PHP.</p>
|
<p>For maximum security, performance, and correctness use prepared statements.
Here's how to do this with lots of examples in different languages, including PHP:</p>
<p><a href="https://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks">https://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks</a></p>
|
<p>I am not sure if MySQL supports parameterized queries, if so, you should make an effort to go this route. This will ensure the users input can't do anything malicious.</p>
<p>Otherwise some "bad" characters in addition to what you mentioned would be semicolon (;) and comments (-- and /* */).</p>
| 2,478
|
<p>Programmatic solution of course...</p>
|
<p><a href="http://www.daveamenta.com/2008-05/c-delete-a-file-to-the-recycle-bin/" rel="noreferrer">http://www.daveamenta.com/2008-05/c-delete-a-file-to-the-recycle-bin/</a></p>
<p>From above:</p>
<pre><code>using Microsoft.VisualBasic;
string path = @"c:\myfile.txt";
FileIO.FileSystem.DeleteDirectory(path,
FileIO.UIOption.OnlyErrorDialogs,
RecycleOption.SendToRecycleBin);
</code></pre>
|
<p>You need to delve into unmanaged code. Here's a static class that I've been using:</p>
<pre><code>public static class Recycle
{
private const int FO_DELETE = 3;
private const int FOF_ALLOWUNDO = 0x40;
private const int FOF_NOCONFIRMATION = 0x0010;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
public struct SHFILEOPSTRUCT
{
public IntPtr hwnd;
[MarshalAs(UnmanagedType.U4)]
public int wFunc;
public string pFrom;
public string pTo;
public short fFlags;
[MarshalAs(UnmanagedType.Bool)]
public bool fAnyOperationsAborted;
public IntPtr hNameMappings;
public string lpszProgressTitle;
}
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
static extern int SHFileOperation(ref SHFILEOPSTRUCT FileOp);
public static void DeleteFileOperation(string filePath)
{
SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
fileop.wFunc = FO_DELETE;
fileop.pFrom = filePath + '\0' + '\0';
fileop.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
SHFileOperation(ref fileop);
}
}
</code></pre>
<p>Addendum:</p>
<ul>
<li>Tsk tsk @ Jeff for "using Microsoft.VisualBasic" in C# code.</li>
<li>Tsk tsk @ MS for putting all the goodies in VisualBasic namespace.</li>
</ul>
| 3,821
|
<p>Are you aware of any tool that creates diagrams showing the branch/merge activity in a SVN repository?</p>
<p>We've all seen these diagrams in various tutorials. Some good, some not so good. Can they be created automatically (or maybe with a little prodding -- you might have to tell it what if your branching philosophy is dev-test-prod, branch-per-release, etc.)</p>
<p>I'm looking at the TortoiseSVN Revision Graph right now, but it has more detail than I want and the wrong layout.</p>
<hr>
<p>Orion, thanks for the response. I guess since branching and merging are more a convention for managing files in a repository than a "built in feature of SVN, it would be pretty tough. I'll stick with the poorly-drawn diagram at the top of the whiteboard in our team's office.</p>
|
<p>Check this out <a href="http://svnmapper.tigris.org/" rel="noreferrer">SvnMapper from Tigris.org</a></p>
<p><img src="https://i.stack.imgur.com/tlCvQ.png" alt="enter image description here"></p>
|
<p>prior to SVN 1.5 (which has been out all of a month or so), it didn't track merges at all, so the bits where branches 'reconnect' to the trunk are impossible for it to do anyway</p>
| 3,152
|
<p>Do you normally set your compiler to optimize for maximum speed or smallest code size? or do you manually configure individual optimization settings? Why?</p>
<p>I notice most of the time people tend to just leave compiler optimization settings to their default state, which with visual c++ means max speed.
I've always felt that the default settings had more to do with looking good on benchmarks, which tend to be small programs that will fit entirely within the L2 cache than what's best for overall performance, so I normally set it optimize for smallest size.</p>
|
<p>As a Gentoo user I have tried quite a few optimizations on the complete OS and there have been endless discussions on the <a href="http://forums.gentoo.org/" rel="noreferrer">Gentoo forums</a> about it. Some good flags for GCC can be found in the <a href="http://gentoo-wiki.com/Safe_Cflags" rel="noreferrer">wiki</a>.</p>
<p>In short, optimizing for size worked best on an old Pentium3 laptop with limited ram, but on my main desktop machine with a Core2Duo, -O2 gave better results over all.</p>
<p>There's also a <a href="http://www.pixelbeat.org/scripts/gcccpuopt" rel="noreferrer">small script</a> if you are interested in the x86 (32 bit) specific flags that are the most optimized.</p>
<p>If you use gcc and really want to optimize a specific application, try <a href="http://www.coyotegulch.com/products/acovea/" rel="noreferrer">ACOVEA</a>. It runs a set of benchmarks, then recompile them with all possible combinations of compile flags. There's an example using Huffman encoding on the site (lower is better):</p>
<pre><code>A relative graph of fitnesses:
Acovea Best-of-the-Best: ************************************** (2.55366)
Acovea Common Options: ******************************************* (2.86788)
-O1: ********************************************** (3.0752)
-O2: *********************************************** (3.12343)
-O3: *********************************************** (3.1277)
-O3 -ffast-math: ************************************************** (3.31539)
-Os: ************************************************* (3.30573)
</code></pre>
<p>(Note that it found -Os to be the slowest on this Opteron system.)</p>
|
<p>We always use maximize for optimal speed but then, all the code I write in C++ is somehow related to bioinformatics algorithms and speed is crucial while the code size is relatively small.</p>
| 7,739
|
<p>Simple one really. In SQL, if I want to search a text field for a couple of characters, I can do:</p>
<pre><code>SELECT blah FROM blah WHERE blah LIKE '%text%'
</code></pre>
<p>The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem?</p>
|
<p>BigTable, which is the database back end for App Engine, will scale to millions of records. Due to this, App Engine will not allow you to do any query that will result in a table scan, as performance would be dreadful for a well populated table.</p>
<p>In other words, every query must use an index. This is why you can only do <code>=</code>, <code>></code> and <code><</code> queries. (In fact you can also do <code>!=</code> but the API does this using a a combination of <code>></code> and <code><</code> queries.) This is also why the development environment monitors all the queries you do and automatically adds any missing indexes to your <code>index.yaml</code> file.</p>
<p>There is no way to index for a <code>LIKE</code> query so it's simply not available.</p>
<p>Have a watch of <a href="http://sites.google.com/site/io/under-the-covers-of-the-google-app-engine-datastore" rel="noreferrer">this Google IO session</a> for a much better and more detailed explanation of this.</p>
|
<p>If the <code>LIKE '%text%'</code> always compares to a word or a few (think permutations) and your data changes slowly (slowly means that it's not prohibitively expensive - both price-wise and performance-wise - to create and updates indexes) then Relation Index Entity (RIE) may be the answer. </p>
<p>Yes, you will have to build additional datastore entity and populate it appropriately. Yes, there are some constraints that you will have to play around (one is 5000 limit on the length of list property in GAE datastore). But the resulting searches are lightning fast. </p>
<p>For details see my <a href="http://novyden.blogspot.com/2011/02/efficient-keyword-search-with-relation.html" rel="nofollow">RIE with Java and Ojbectify</a> and <a href="http://novyden.blogspot.com/2011/09/efficient-keyword-search-with-relation.html" rel="nofollow">RIE with Python</a> posts. </p>
| 7,004
|
<p>I'm querying a bunch of information from cisco switches using SNMP. For instance, I'm pulling information on neighbors detected using CDP by doing an snmpwalk on .1.3.6.1.4.1.9.9.23</p>
<p>Can I use this OID across different cisco models? What pitfalls should I be aware of? To me, I'm a little uneasy about using numeric OIDs - it seems like I should be using a MIB database or something and using the named OIDs, in order to gain cross-device compatibility, but perhaps I'm just imagining the need for that.</p>
|
<p>Once a MIB has been published it won't move to a new OID. Doing so would break network management tools and cause support calls, which nobody wants. To continue your example, the CDP MIB has been published at Cisco's <A HREF="http://tools.cisco.com/Support/SNMP/do/BrowseMIB.do?local=en&step=2&mibName=CISCO-CDP-MIB" rel="nofollow noreferrer">SNMP Object Navigator.</A></p>
<p>For general code cleanliness it would be good to define the OIDs in a central place, especially since you don't want to duplicate the full OID for every single table you need to access.</p>
<p>The place you need to be most careful is a unique MIB in a product which Cisco recently acquired. The OID will change, if nothing else to move it into their own Enterprise OID space, but the MIB may also change to conform to Cisco's SNMP practices.</p>
|
<ul>
<li>I would avoid putting in numeric OIDs and instead use 'OID names' and leave that hard work (of translating) to whatever SNMP API you are using. </li>
</ul>
<p>If that is not possible, then it is okay to use OIDs as they should not change per the SNMP MIB guidelines. Unless the device itself changes but that requires a new MIB anyway which can't reuse old OIDs. </p>
<ul>
<li>This is obvious, but be sure to look at the attributes of the SNMP MIB variable. Be sure not to query variables that have a status of 'obsolete'.</li>
</ul>
<p>Jay..</p>
| 9,148
|
<p>Given a relatively simple CSS:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>div {
width: 150px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
12333-2333-233-23339392-332332323
</div></code></pre>
</div>
</div>
</p>
<blockquote>
<p>How do I make it so that the string stays constrained to the <code>width</code>
of <strong>150</strong>, and wraps to a new line on the <em>hyphen</em>?</p>
</blockquote>
|
<p>Replace your hyphens with this:</p>
<pre><code>&shy;
</code></pre>
<p>It's called a "soft" hyphen.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>div {
width: 150px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
12333&shy;2333&shy;233&shy;23339392&shy;332332323
</div></code></pre>
</div>
</div>
</p>
|
<p>The non-breaking hyphen works well.</p>
<p><strong>HTML Entity (decimal)</strong> </p>
<pre><code>&#8209;
</code></pre>
| 2,334
|
<p>I have been using my Anet A2 for about a year. A few problems but none that I haven't been able to resolve. Today it suddenly stopped auto homing.</p>
<p>Using the position commands I can advance the X and Y positively but not negatively (after I manually re-position the carriages before turning the printer on). Also the Y stepper motor makes an unusual noise and it will over advance the Y axis. This behavior was preceded by a feed fault. The print started fine but the stepper motor stopped feeding shortly after the print started. </p>
<p>I am printing from an SD card as I always have. I changed SD cards thinking it might be a connection problem and I checked the G-code and all the commands including the E commands seem to be there. I have checked all the electrical connections - they seem to be fine.</p>
<p>Any suggestions to solve this?</p>
|
<p>The fuse rating is same as described on the board - so that shall be no issue with it.</p>
<p><strong>My main concern is why the fuse is down?</strong></p>
<p>Was there a short-circuit? As this is mains fuse - that suggest a big-bang, so, please check carefully hot-end and bed heater connections before restarting the device, to avoid replacing another fuse.</p>
|
<p>To add to the answer of <em>@profesor79</em> (which you <strong>absolutely need to address first</strong> (find the cause why it blew); else the fuse might blow again), you might be interested in installing fuse clamps. As <em>@fred_dot_u</em> mentions:</p>
<blockquote>
<p>use caution when soldering leads to the fuse that you do not de-solder
the internal fuse from the caps</p>
</blockquote>
<p>is that if you incorrectly solder the fuse, you might de-solder the caps, soldering the clamps is easier.</p>
<p><em>Example of fuse clamp:</em><br>
<a href="https://i.stack.imgur.com/HwRFQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HwRFQ.jpg" alt="5 mm fuse clamp"></a></p>
| 948
|
<p>Is there a way to select data where any one of multiple conditions occur on the same field?</p>
<p>Example: I would typically write a statement such as:</p>
<pre><code>select * from TABLE where field = 1 or field = 2 or field = 3
</code></pre>
<p>Is there a way to instead say something like:</p>
<pre><code>select * from TABLE where field = 1 || 2 || 3
</code></pre>
<p>Any help is appreciated.</p>
|
<p>Sure thing, the simplest way is this:</p>
<pre><code>select foo from bar where baz in (1,2,3)
</code></pre>
|
<p>while <code>in</code> is a shortcut for <code>or</code> and I wasn't sure how I could combine <code>in</code> with <code>and</code>, I did it this way</p>
<pre><code> SELECT * FROM table
WHERE column1='x' AND (column2='y' OR column2='z');
</code></pre>
| 3,845
|
<p>I'd like to implement a simple class (in Java) that would allow me to register and deregister strings, and on the basis of the current set of strings auto-complete a given string. So, the interface would be:</p>
<ul>
<li>void add(String)</li>
<li>void remove(String)</li>
<li>String complete(String)</li>
</ul>
<p>What's the best way to do this in terms of algorithms and data-structures?</p>
|
<p>you should consider to use a PATRICIA trie for the data structure. Search for 'patricia trie' on google and you'll find a lot of information...</p>
|
<p>Regular expressions.</p>
| 9,877
|
<p>Most of my part is printing very well, but I have problems in the bottom layer and in layers that are the first layers, but not necessarily layer 0.</p>
<p>Looking at the <a href="https://www.simplify3d.com/support/print-quality-troubleshooting/" rel="nofollow noreferrer">print quality troubleshooting</a>, I can't find a problem that fits my needs. Using the terms over there, I would describe it as "gaps in bottom layer".</p>
<p>Photo from part A (RPi case top piece):</p>
<p><a href="https://i.stack.imgur.com/0JkO3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0JkO3.jpg" alt="rough and sunken"></a></p>
<p>Photos from part B (RPi case bottom):</p>
<p>There is a really ugly screwhole (sorry for the blurry picture):</p>
<p><a href="https://i.stack.imgur.com/B0Yyw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B0Yyw.jpg" alt="Ugly screwhole"></a></p>
<p>But in the same part, there's an <strike>almost perfect</strike> much better screwhole:</p>
<p><a href="https://i.stack.imgur.com/zsYWQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zsYWQ.jpg" alt="Perfect screwhole"></a></p>
<p>For the location on the print bed, it's here (both parts):</p>
<p><a href="https://i.stack.imgur.com/HoXaU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HoXaU.png" alt="Problematic region"></a></p>
<p>I have seen the question <a href="https://3dprinting.stackexchange.com/questions/2943/first-bottom-layer-has-gaps">First bottom layer has gaps</a>, where the OP has already tried a lot.</p>
<p>My thoughts so far:</p>
<ul>
<li>I don't want to generally lower the Z height, since it prints fine over a large area with a really flat and smooth surface.</li>
<li>I'm not sure I should change the temperature settings. I use the i3 MK3 printer and I use Prusa PLA filament with Slic3r Prusa PLA filament settings.</li>
<li>I don't understand many of the extrusion width / extrusion multiplier options of that question.</li>
<li>I thought I might have had a fingerprint on the print plate. I typically avoid that by wearing gloves and cleaning the print bed with alcohol every fifth print or so. However, I didn't clean before any of the two parts. (I cleaned now)</li>
</ul>
<p><strong>Given the description and the pictures, can you name the problem and suggest the most likely solution?</strong></p>
<p>Printer and filament details:</p>
<ul>
<li>Prusa i3 MK3</li>
<li><a href="https://shop.prusa3d.com/de/filament/224-perlblaues-pla-filament-1kg.html" rel="nofollow noreferrer">Prusa PLA filament 1.75 mm, pearl blue</a></li>
<li>0.20 mm SPEED setting</li>
<li>20% infill</li>
<li>5mm Brim</li>
<li>215°C first layer, 210°C other layers</li>
<li>60°C bed temperature</li>
<li>Prusa PLA default filament settings</li>
</ul>
<p>I use a Prusa spring steel print bed. No special adhesion, tape or anything. Closest I could find in the shop is <a href="https://shop.prusa3d.com/en/mk3-and-mk3s-printer-parts/216-spring-steel-sheet-smooth-pei.html" rel="nofollow noreferrer">smooth PEI</a>, but mine looks more golden.</p>
|
<p>I know you said you don't want to change the Z height, but it does look like you're printing a bit too far from the plate. I would recommend adjusting your Z-offset if you can, or adjusting the limit switch (or whatever your Z-homing mechanism is)</p>
|
<p>Definitely the corner of your bed where print was worse is slightly unleveled (a little too low), because if you look the hole, it has artifacts too, probably because the nozzle was depositing the melted filament from a higher distance than on the "good" part.</p>
<p>You can see later in that hole, that the layers finally catch up with the rest, so:</p>
<ul>
<li>You need to correct the bed leveling on that corner (too low)</li>
</ul>
<p>Also, the better part doesn't look right either. You can see the ring around the good hole doesn't close because the filament din't stick at the beginning of the circular movement. Plus, your first layer should be smoother than that, not wormy-like.</p>
<p>To experiment how to get a better first layer you need to tweak in very small amounts:</p>
<ul>
<li>The first layer height (I may need to be lower for you)</li>
<li>The temperature (I don't think you need more temp for your first layer, probably the fans start blowing after the second layer anyways)</li>
<li>The % of extruded material (you may increase it in very small amounts only for the first layer [and only after a lower layer height didn't worked])</li>
<li>The speed of the first layer (it may need to be lower. imagine your nozzle is trying to print with chewing gum and what would happen if speeds are too high, PLA has a rubbery consistency when melted)</li>
</ul>
<p>Also:</p>
<ul>
<li>Be sure the surface is clean</li>
</ul>
<p>Dust and oils from manipulation on certain spots can cause the filament not to stick, even when you think is clean. I use alcohol when printing on a bare surface, change the masking tape, or use just a paper towel (when I'm using PEI sheet)</p>
<p>If that doesn't give you a a better first layer, but it is at least even, you will need to adjust your z-axis offset or level the entire bed up a little.</p>
| 1,281
|
<p>Last Friday where I work, an oracle client was upgarded and our IIS server from version 9 to version 10. Now that its on version 10, we are seeing a lot of connections being open up to the database. It is opening up so many connections that we cannot log onto the database using tools like PlSQL developer or Toad. We never had an issue like this when the oracle client was at version 9. Because of the number of clients that exists on this particular box, i dont think it will be possible to revert back to the Oracle 9 client.
Is anyone aware of this problem or know of any possible work arounds?</p>
<p>Any help is greatly appreciated</p>
|
<p>lex/flex and yacc/bison provide easy-to-use, well-understood lexer- and parser-generators, and I'd really recommend doing something like that as opposed to doing it procedurally in e.g. Perl. Regular expressions are powerful stuff for ripping apart strings with relatively-, but not totally-fixed structure. With any real programming language, the size of your state machine gets to be simply unmanageable with anything short of a Real Lexer/Parser (tm). Imagine dealing with all possible interleavings of keywords, identifiers, operators, extraneous parentheses, extraneous semicolons, and comments that are allowed in something like Verilog AMS, with regular expressions and procedural code alone.</p>
<p>There's no denying that there's a substantial learning curve there, but writing a grammar that you can use for flex and bison, and doing something useful on the syntax tree that comes out of bison, will be a much better use of your time than writing a ton of special-case string-processing code that's more naturally dealt with using a syntax-tree in the first place. Also, what you learn writing it this way will truly broaden your skillset in ways that writing a bunch of hacky Perl code just won't, so if you have the means, I highly recommend it ;-)</p>
<p>Also, if you're lazy, check out the Eclipse plugins that do syntax highlighting and basic refactoring for Verilog and VHDL. They're in an incredibly primitive state, last I checked, but they may have some of the code you're looking for, or at least a baseline piece of code to look at to better inform your approach in rolling your own.</p>
|
<p>In trying to find my answer, I found this on <a href="http://www.ibm.com/developerworks/edu/au-dw-au-parsingwithantlr-i.html" rel="nofollow noreferrer">ANTLR</a> - might be of use</p>
| 9,615
|
<p>I would like to make a nightly cron job that fetches my stackoverflow page and diffs it from the previous day's page, so I can see a change summary of my questions, answers, ranking, etc.</p>
<p>Unfortunately, I couldn't get the right set of cookies, etc, to make this work. Any ideas?</p>
<p>Also, when the beta is finished, will my status page be accessible without logging in?</p>
|
<p>Your status page is available now without logging in (click <a href="https://stackoverflow.com/users/logout?returnurl=%2fquestions%2f2815%2fhow-to-curl-or-wget-a-stackoverflow-page">logout</a> and try it). When the beta-cookie is disabled, there will be nothing between you and your status page.</p>
<p>For wget:</p>
<pre><code>wget --no-cookies --header "Cookie: soba=(LookItUpYourself)" https://stackoverflow.com/users/30/myProfile.html
</code></pre>
|
<p>Nice idea :)</p>
<p>I presume you've used wget's</p>
<pre><code>--load-cookies (filename)
</code></pre>
<p>might help a little but it might be easier to use something like Mechanize (in Perl or python) to mimic a browser more fully to get a good spider.</p>
| 2,497
|
<p>I have a PS/2 touchpad which I would like to write a driver for (I'm just a web guy so this is unfamiliar territory to me). The touchpad comes with a Windows XP driver, which apparently sends messages to enable/disable tap-to-click. I'm trying to find out what message it is sending but I'm not sure how to start. Would software like "Syser Debugger" work? I want to intercept outgoing messages being sent to the PS/2 bus.</p>
|
<p>IDA Pro won't be much use to you if you want to find out what 'messages' are being sent. You should realise that this is a very big step up for most web developers, but you already knew that?</p>
<p>I would start by deciding if you really need to work at the driver-level, often this is the Kernel level. The user mode level may be where you want to look first. Use a tool like WinSpy or other Windows debug tool to find out what <a href="http://msdn.microsoft.com/en-us/library/ms644927.aspx" rel="nofollow noreferrer">messages</a> are getting passed around by your driver software, and the mouse configuration applet in control panel. You can use the Windows API function called <a href="http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx" rel="nofollow noreferrer">SendMessage()</a> to send your messages to the application from user mode.</p>
<p>Your first stop for device driver development should be the <a href="http://www.microsoft.com/whdc/devtools/wdk/default.mspx" rel="nofollow noreferrer">Windows DDK docs</a> and <a href="http://www.osronline.com/" rel="nofollow noreferrer">OSR Online</a>.</p>
|
<p>Have a look at <a href="http://www.hex-rays.com/idapro/" rel="nofollow noreferrer">IDA Pro</a> - The Interactive Disassembler. It is an amazing disassembler.</p>
<p>If you want to debug, not just reverse engineer, try PEBrowse Professional Interactive from <a href="http://www.smidgeonsoft.prohosting.com/pebrowse-pro-interactive-debugger.html" rel="nofollow noreferrer">SmidgeonSoft</a></p>
| 7,383
|
<p>I have a file in the following format:</p>
<pre>
Data Data
Data
[Start]
Data I want
[End]
Data
</pre>
<p>I'd like to grab the <code>Data I want</code> from between the <code>[Start]</code> and <code>[End]</code> tags using a Regex. Can anyone show me how this might be done?</p>
|
<pre><code>\[start\](.*?)\[end\]
</code></pre>
<p>Zhich'll put the text in the middle within a capture.</p>
|
<p>Refer to this question to pull out text between tags with space characters and dots (<code>.</code>)</p>
<p><code>[\S\s]</code> is the one I used </p>
<p><a href="https://stackoverflow.com/questions/8303488/regex-to-match-any-character-including-new-lines">Regex to match any character including new lines</a></p>
| 2,363
|
<p>I'm trying to use some data from a PlanPlusOnline account. They only provide a java web services API. The server for the site where the data will be used does not allow me to install Tomcat (edit: or a JVM for that matter). I'm not going to lie, I am a Java software engineer, and I do some web work on the side. I'm not familiar with web services or servlets, but I was willing to give it a shot. I'd much rather they have JSON access to the data, but as far as I know they don't. Any ideas?</p>
<p>EDIT: to clarify. The web service provided by planplusonline is Java based. I am trying to access the data from this web service without using Java. I believe this is possible now, but I need to do more research. Anyone who can help point me in the right direction is appreciated.</p>
|
<p>To follow up with jodonnell's comment, a Web service connection can be made in just about any server-side language. It is just that the API example they provided was in Java probably because PlanPlusOnline is written in Java. If you have a URL for the service, and an access key, then all you really need to do is figure out how to traverse the XML returned. If you can't do Java, then I suggest PHP because it could be already installed, and have the proper modules loaded. This link might be helpful:</p>
<p><a href="http://www.onlamp.com/pub/a/php/2007/07/26/php-web-services.html" rel="nofollow noreferrer">http://www.onlamp.com/pub/a/php/2007/07/26/php-web-services.html</a></p>
|
<p>Are you trying to implement a client to a web service hosted somewhere else? If so, Java's not necessary. You can do web service clients in <a href="http://www.dotnetjunkies.ddj.com/Tutorial/4D13CEFA-D0FD-44BE-8749-8D17B5757564.dcik" rel="nofollow noreferrer">.NET</a>, <a href="http://sourceforge.net/projects/nusoap/" rel="nofollow noreferrer">PHP</a>, <a href="http://raa.ruby-lang.org/project/soap4r" rel="nofollow noreferrer">Ruby</a>, or pretty much any modern web technology out there. All you need is a WSDL document to provide metadata about how to invoke the services.</p>
| 7,671
|
<p>I am considering buying a 3D printer for work (scientific research). On paper, the Makerbot 5th generation seems to be the best option, because the price is right for my budget, and also because I'm generally pretty busy, so I want something that's as close to "plug and play" as reasonably possible. This will be my first 3D printer and I have no prior experience with the technology.</p>
<p>However, any search for "Makerbot" brings up a raft of negative reviews from around the time of the 5th generation's first release, which mostly focus on issues with the smart extruder constantly failing and needing to be replaced under warranty. Many of these reviews point out that this may be an initial "teething" issue which might be fixed in later versions of the model, but now, one year later, I'm unable to find any information about whether this was indeed the case.</p>
<p>So: are the initial issues with the Makerbot 5th generation's smart extruder generally considered resolved, or is it an underlying flaw of the model that won't be fixed until the next generation?</p>
<p><sub>I imagine that people might want to suggest alternative models in the same price range. That would be welcome, but I have an extra constraint, which is that I can only buy models that are available in Japan without a long delivery time - this probably limits my options quite a bit.</sub></p>
|
<p>Makerbot claims the problems are fixed. I have heard from a number of resellers that the problems are fixed. Unfortunately, both of those are somewhat biased sources. It's surprisingly hard to get good info on the subject -- very few credible people are talking about recent experiences with the product line. </p>
<p><strong>Issue #1:</strong> The main surviving user forum (<a href="https://groups.google.com/forum/#!forum/makerbot-users">https://groups.google.com/forum/#!forum/makerbot-users</a>) has had the torrent of people reporting 5th gen issues more or less dry up. There ARE still people posting issues, but at a fairly low level that is not far outside what you would expect for an average hobbyist printer. What we DON'T know is whether the flood of complaints has slowed because they're working better, or because very few people are actually buying them any more. </p>
<p><strong>Issue #2:</strong> The power-users and community leaders that typically evaluate and review 3d printers are all avoiding the 5th gen line like the plague. Makerbot burned up a lot of community good-will by going closed source with the Replicator 2, and lost more good-will through a series of misunderstandings over patent applications and the Thingiverse terms of service (Takerbot scandals), and put the nail in the coffin by <strong>knowingly</strong> releasing a non-functional 5th gen product line. Very few credible people are willing to give them a chance at this point, so there is a severe shortage of unbiased reviews.</p>
<p><strong>Issue #3:</strong> Makerbot has a proven history of buying off journalists and reviewers to get positive 5th gen press. Some verifiable examples:</p>
<ul>
<li>Hundreds of fake 5-star Amazon reviews from paid review accounts. A relevant analysis: <a href="http://www.amazon.com/review/R2JI8LRRXZYNX1/">http://www.amazon.com/review/R2JI8LRRXZYNX1/</a> (Not verified, but related: a widely-believed rumor states that the German Amazon site actually wiped all of Makerbot's 5th Gen reviews because of blatant tampering: <a href="http://www.amazon.de/MakerBot-MP05825-Replicator-5th-H%C3%B6he/dp/B0183TP806/">http://www.amazon.de/MakerBot-MP05825-Replicator-5th-H%C3%B6he/dp/B0183TP806/</a>)</li>
<li>The CES awards initially given to the 5th Gen line were given before Makerbot had functional firmware. None of the 5th Gens at the CES launch were functional. All demo prints shown were made on Replicator 2s. How could a non-functional product win awards? Not hard to figure that one out. </li>
<li>Historical positive press in the 3DP journalism media (3ders, Make Magazine, etc) has been directly proportional to the volume of ad-buys from Makerbot or the parent company Stratasys. </li>
</ul>
<p>I could keep going, but you get the idea. </p>
<p>So it's hard to evaluate the reality of the situation. <strong>But even IF the Smart Extruder issues are truly all fixed</strong> (jams, leveling issues, thermocouple connection, filament encoder failures, etc), <strong>there are still meaningful problems with the product line.</strong> </p>
<ul>
<li>The print quality is not impressive. The motion mechanics, which have not been appreciably changed to my knowledge, are not great. The Smart Extruder is basically a giant pendulum wobbling off the side of a non-optimal gantry selection of an H-bot architecture. Makerbot has addressed the floppy construction via firmware tweaks to significantly slow down the machine to give marginally-acceptable print quality. According to most reports I have seen, a Replicator 5th Gen will print significantly slower than a Replicator 2, for example. Expect in the neighborhood of perhaps 30-40% longer print times than comparable printers.</li>
<li>The price tag is roughly double or even triple the current market price for the size and print quality output of the machine. There are so many great printers on the market now for significantly less money that it's kind of nuts to drop the cash on a Makerbot.</li>
<li>It is marketed as a PLA-only machine. That's fine if you're printing art and trinkets, but it's not a great option for mechanical parts. While you CAN print other materials, this is not technically supported. </li>
<li>The support plan structure has quite frankly become abusive. Makerbot used to have really helpful phone tech support, but the crushingly massive volume of 5th gen troubleshooting requests forced them into a paid tech support model. Around the same time, Makerbot shut down their user community forum and deleted links to external technical resources off their website. So unless you know the right places to go, support is scarce. For official tech support you must buy "Makercare" or pay for each help ticket. This is completely out of line with industry norms for a hobbyist/consumer 3d printer. They essentially took their biggest liability -- unreliable printers -- and tried to twist it into a profit center. I personally think this is a significant reason to avoid the company entirely. </li>
</ul>
<p>Is it possible to get good results from a Replicator 5th Gen? Sure. But it's a poor value for the cost, from a company that has spent the last few years systematically driving away its former loyal user base. I would recommend staying away until there's some significant change in the product line at minimum.</p>
|
<p>I own a 5th gen printer and after teaching myself how to dismantle and clear the smart extruder of jammed filament I can attest to the machine working better than any other 3D printer I have used. I run the 3D printing section at Tampa Hakerspace and the MakerBot is much more reliable than the prusa or wanhao which we use at the space. I had problems with the machine initially but now it works like a champ</p>
| 196
|
<p>I've got some Japanese in the ALT attribute, but the tooltip is showing me the ugly block characters in the tooltip. The rest of the content on the page renders correctly. So far, it seems to be limited to the tooltips.</p>
|
<p>This is because the font used in the tooltip doesn't include the characters you are trying to display. Try installing a font pack that includes those characters. I'm affraid you can't do much for your site's visitors other than implementating a tooltip yourself using javascript.</p>
|
<p>Can you sanitize the alt text so that it doesn't have the characters in it, preferably by replacing the entire text with something useful (rather than just filtering the string)? That's not ideal, but neither is displaying broken characters, or telling your users to install a new font pack.</p>
| 3,278
|
<p>Is there a way to fall through multiple case statements without stating <code>case value:</code> repeatedly?</p>
<p>I know this works:</p>
<pre><code>switch (value)
{
case 1:
case 2:
case 3:
// Do some stuff
break;
case 4:
case 5:
case 6:
// Do some different stuff
break;
default:
// Default stuff
break;
}
</code></pre>
<p>but I'd like to do something like this:</p>
<pre><code>switch (value)
{
case 1,2,3:
// Do something
break;
case 4,5,6:
// Do something
break;
default:
// Do the Default
break;
}
</code></pre>
<p>Is this syntax I'm thinking of from a different language, or am I missing something?</p>
|
<p>There is no syntax in C++ nor C# for the second method you mentioned. </p>
<p>There's nothing wrong with your first method. If however you have very big ranges, just use a series of if statements.</p>
|
<p>For this, you would use a goto statement. Such as:</p>
<pre><code> switch(value){
case 1:
goto case 3;
case 2:
goto case 3;
case 3:
DoCase123();
//This would work too, but I'm not sure if it's slower
case 4:
goto case 5;
case 5:
goto case 6;
case 6:
goto case 7;
case 7:
DoCase4567();
}
</code></pre>
| 9,409
|
<p>What data structures would you use to represent a chessboard for a computer chess program?</p>
|
<p>Initially, use an <strong>8 * 8 integer array</strong> to represent the chess board.</p>
<p>You can start programing using this notation. Give point values for the pieces. For example:</p>
<pre><code>**White**
9 = white queen
5 = white rook
3 = bishop
3 = knight
1 = pawn
**black**
-9 = white queen
-5 = white rook
-3 = bishop
-3 = knight
-1 = pawn
White King: very large positive number
Black King: very large negative number
</code></pre>
<p>etc. (Note that the points given above are approximations of trading power of each chess piece)</p>
<p>After you develop the basic backbones of your application and clearly understand the working of the algorithms used, try to improve the performance by using bit boards.</p>
<p>In bit boards, you use eight 8 -bit words to represent the boards. This representation needs a board for each chess piece. In one bit board you will be storing the position of the rook while in another you will be storing the position of the knight... etc</p>
<p>Bit boards can improve the performance of your application very much because manipulating the pieces with bit boards are very easy and fast.</p>
<p>As you pointed out,</p>
<blockquote>
<p>Most chessprograms today, especially
those that run on a 64 bit CPU, use a
bitmapped approach to represent a
chessboard and generate moves. x88 is
an alternate board model for machines
without 64 bit CPUs.</p>
</blockquote>
|
<p>An array would probably be fine. If you wanted more convenient means of "traversing" the board, you could easily build methods to abstract away the details of the data structure implementation.</p>
| 6,103
|
<p>How would you refactor these two classes to abstract out the similarities? An abstract class? Simple inheritance? What would the refactored class(es) look like?</p>
<pre><code>public class LanguageCode
{
/// <summary>
/// Get the lowercase two-character ISO 639-1 language code.
/// </summary>
public readonly string Value;
public LanguageCode(string language)
{
this.Value = new CultureInfo(language).TwoLetterISOLanguageName;
}
public static LanguageCode TryParse(string language)
{
if (language == null)
{
return null;
}
if (language.Length > 2)
{
language = language.Substring(0, 2);
}
try
{
return new LanguageCode(language);
}
catch (ArgumentException)
{
return null;
}
}
}
public class RegionCode
{
/// <summary>
/// Get the uppercase two-character ISO 3166 region/country code.
/// </summary>
public readonly string Value;
public RegionCode(string region)
{
this.Value = new RegionInfo(region).TwoLetterISORegionName;
}
public static RegionCode TryParse(string region)
{
if (region == null)
{
return null;
}
if (region.Length > 2)
{
region = region.Substring(0, 2);
}
try
{
return new RegionCode(region);
}
catch (ArgumentException)
{
return null;
}
}
}
</code></pre>
|
<p>It depends, if they are not going to do much more, then I would probably leave them as is - IMHO factoring out stuff is likely to be more complex, in this case.</p>
|
<p>This is a rather simple question and to me smells awefully like a homework assignment.</p>
<p>You can obviously see the common bits in the code and I'm pretty sure you can make an attempt at it yourself by putting such things into a super-class.</p>
| 9,606
|
<p>I'm creating a plugin framework, where my application loads a series of plugin DLL's, then creates a new window and pass this new window's handle to the plugin. The plugin can, then, use this handle to create their own GUI.</p>
<p>Everything seems to be working very well. The only problem is that when I press TAB on a plugin widget (An editbox, for example), it doen't jump to another widget. I figured out that some Windows messages are passed, and some others aren't. The WM_KEYDOWN is passed for other keys, because I can type on the editbox, but this message doesn't handle TAB key.</p>
<p>Hope somebody has a hint.</p>
<p>I'm using Borland VCL with CBuilder, but I think I could use any framework under WIN32 to create these plugins, since they never know how their parent windows were created.</p>
|
<p>It's very complex matter indeed.</p>
<p>When you hit TAB focus jumps to another control only when these controls belong to a Modal Dialog Box. In fact there are some buttons like ESC, LEFT, RIGHT, DOWN, UP, TAB which modal dialog message function treats in a special way. If you want these keys to behave in similar way with modeless dialog box or any other window you should change you message processing function and use IsDialogMessage inside. You'll find more information about <a href="http://msdn.microsoft.com/en-us/library/ms645498(VS.85).aspx" rel="nofollow noreferrer">IsDialogMessage</a> function in MSDN also to better understand this stuff you may check as well <a href="http://msdn.microsoft.com/en-us/library/ms632588(VS.85).aspx" rel="nofollow noreferrer">Dialog Boxes</a> section.</p>
<p>And, as was mentioned before, you should set <a href="http://msdn.microsoft.com/en-us/library/czada357(VS.80).aspx" rel="nofollow noreferrer">WS_TABSTOP</a> and <a href="http://msdn.microsoft.com/en-us/library/czada357(VS.80).aspx" rel="nofollow noreferrer">WS_GROUP</a> styles when needed.</p>
<p>Good luck!</p>
|
<p>I believe you'll have to take the following steps:</p>
<ol>
<li><a href="http://msdn.microsoft.com/en-us/library/ms997565.aspx" rel="nofollow noreferrer">Subclass</a> your edit controls (and other controls as needed).</li>
<li>Capture the <a href="http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx" rel="nofollow noreferrer">WM_KEYDOWN</a> message in your edit control's WndProc.</li>
<li>Check to see if the shift key is currently held down (using <a href="http://msdn.microsoft.com/en-us/library/ms646301(VS.85).aspx" rel="nofollow noreferrer">GetKeyState</a> or similar).</li>
<li>Call <a href="http://msdn.microsoft.com/en-us/library/ms633515(VS.85).aspx" rel="nofollow noreferrer">GetWindow</a>, passing in a handle to your edit control and either GW_HWNDPREV or GW_HWNDNEXT depending on whether shift is held down. This will give you the handle to the window that should receive focus.</li>
<li>Call <a href="http://msdn.microsoft.com/en-us/library/ms646312(VS.85).aspx" rel="nofollow noreferrer">SetFocus</a> and pass in the window handle you got in step 4.</li>
</ol>
<p>Make sure you handle the case where your edit controls are multiline, as you might want to have a real tab character appear instead of moving to the next control.</p>
<p>Hope that helps!</p>
| 3,622
|
<p>I recently asked a question (<a href="https://3dprinting.stackexchange.com/questions/5699/is-there-any-public-and-reasonably-accurate-3d-scan-from-a-cray-2-computer">Is there any public and reasonably accurate 3D scan from a Cray-2 computer?</a>) about where to find (if there is any, because I tried and there seems not to be) a 3D model of a specific object I could use as a starting point for printable model and printable parts and it was flagged as off-topic and closed. Has this type of question proved to be troublesome in the past? </p>
|
<p>This topic is actually up for debate <em>possibly</em>. I don't personally know if this sort of question has been actually <em>troublesome</em>. I remember your question well and whilst it didn't fit into the scope <em>as it is currently defined</em>, it seemed (IMHO) a reasonable question nevertheless. It was unfortunate that you did not get a suitable answer before your question was closed.</p>
<p>I have include this question in the new meta post about what should and shouldn't be on-topic, <a href="https://3dprinting.meta.stackexchange.com/questions/276/game-plan-what-is-on-topic">Game plan - What is on-topic?</a>.</p>
|
<p>mostly this is an off-topic question, as per <a href="https://3dprinting.stackexchange.com/help/dont-ask">question rules - click</a> </p>
<p>That means your question is not about solving a technical problem.</p>
| 46
|
<p>How can you beta test an iPhone app? I can get it on my own device, and anyone that gives me a device, I can run it on theirs, but is there a way to do a limited release via the app store for beta testing?</p>
<p>Related: Also, see <a href="https://stackoverflow.com/questions/37464/iphone-app-minus-app-store">this question</a> on getting your app onto phones without using the App Store.</p>
|
<h1>Creating ad-hoc distribution profiles</h1>
<p>The <a href="http://developer.apple.com/library/mac/#documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html" rel="noreferrer">instructions that Apple provides are here</a>, but here is how I created a general provisioning profile that will work with multiple apps, and added a beta tester.</p>
<p>My setup:</p>
<ul>
<li>Xcode 3.2.1</li>
<li>iPhone SDK 3.1.3</li>
</ul>
<p>Before you get started, make sure that..</p>
<ul>
<li>You can run the app on your own iPhone through Xcode.</li>
</ul>
<h2>Step A: Add devices to the Provisioning Portal</h2>
<ol>
<li><p>Send an email to each beta tester with the following message:</p>
<blockquote>
<p>To get my app on onto your iPhone I need some information about your phone. Guess what, there is an app for that!</p>
<p>Click on the below link and install and then run the app.</p>
<p><a href="http://itunes.apple.com/app/ad-hoc-helper/id285691333?mt=8" rel="noreferrer">http://itunes.apple.com/app/ad-hoc-helper/id285691333?mt=8</a></p>
<p>This app will create an email. Please send it to me.</p>
</blockquote></li>
<li><p>Collect all the UDIDs from your testers.</p></li>
<li><p>Go to the <a href="http://developer.apple.com/iphone/manage/overview/index.action" rel="noreferrer">Provisioning Portal</a>.</p></li>
<li><p>Go to the section <strong>Devices</strong>.</p></li>
<li><p>Click on the button <strong>Add Devices</strong> and add the devices previously collected.</p></li>
</ol>
<h2>Step B: Create a new provisioning profile</h2>
<ol>
<li><p>Start the Mac OS utility program <strong>Keychain Access</strong>.</p></li>
<li><p>In its main menu, select <strong>Keychain Access / Certificate Assistant / Request a Certificate From a Certificate Authority...</strong></p></li>
<li><p>The dialog that pops up should aready have your email and name it it.</p></li>
<li><p>Select the radio button <strong>Saved to disk</strong> and Continue.</p></li>
<li><p>Save the file to disk.</p></li>
<li><p>Go back to the <a href="http://developer.apple.com/iphone/manage/overview/index.action" rel="noreferrer">Provisioning Portal</a>.</p></li>
<li><p>Go to the section <strong>Certificates</strong>.</p></li>
<li><p>Go to the tab <strong>Distribution</strong>.</p></li>
<li><p>Click the button <strong>Request Certificate</strong>.</p></li>
<li><p>Upload the file you created with Keychain Access: <strong>CertificateSigningRequest.certSigningRequest</strong>.</p></li>
<li><p>Click the button <strong>Aprove</strong>.</p></li>
<li><p>Refresh your browser until the status reads <strong>Issued</strong>.</p></li>
<li><p>Click the <strong>Download button</strong> and save the file <strong>distribution_identify.cer</strong>.</p></li>
<li><p>Doubleclick the file to add it to the Keychain.</p></li>
<li><p>Backup the certificate by selecting its <em>private key</em> and the <strong>File / Export Items...</strong>.</p></li>
<li><p>Go back to the <a href="http://developer.apple.com/iphone/manage/overview/index.action" rel="noreferrer">Provisioning Portal</a> again.</p></li>
<li><p>Go to the section <strong>Provisioning</strong>.</p></li>
<li><p>Go to the tab <strong>Distribution</strong>.</p></li>
<li><p>Click the button <strong>New Profile</strong>.</p></li>
<li><p>Select the radio button <strong>Ad hoc</strong>.</p></li>
<li><p>Enter a profile name, I named mine <em>Evertsson Common Ad Hoc</em>.</p></li>
<li><p>Select the app id. I have a common app id to use for multiple apps: <em>Evertsson Common</em>.</p></li>
<li><p>Select the devices, in my case my own and my tester's.</p></li>
<li><p>Submit.</p></li>
<li><p>Refresh the browser until the status field reads <strong>Active</strong>.</p></li>
<li><p>Click the button <strong>Download</strong> and save the file to disk.</p></li>
<li><p>Doubleclick the file to add it to Xcode.</p></li>
</ol>
<h2>Step C: Build the app for distribution</h2>
<ol>
<li><p>Open your project in Xcode.</p></li>
<li><p>Open the <em>Project Info</em> pane: In <strong>Groups & Files</strong> select the topmost item and press <strong>Cmd+I</strong>.</p></li>
<li><p>Go to the tab <strong>Configuration</strong>.</p></li>
<li><p>Select the configuration <strong>Release</strong>.</p></li>
<li><p>Click the button <strong>Duplicate</strong> and name it <strong>Distribution</strong>.</p></li>
<li><p>Close the Project Info pane.</p></li>
<li><p>Open the <em>Target Info</em> pane: In <em>Groups & Files</em> expand <em>Targets</em>, select your target and press <strong>Cmd+I</strong>.</p></li>
<li><p>Go to the tab <strong>Build</strong>.</p></li>
<li><p>Select the <em>Configuration</em> named <strong>Distribution</strong>.</p></li>
<li><p>Find the section <strong>Code Signing</strong>.</p></li>
<li><p>Set the value of <strong>Code Signing Identity / Any iPhone OS Device</strong> to <strong>iPhone Distribution</strong>.</p></li>
<li><p>Close the Target Info pane.</p></li>
<li><p>In the main window select the <em>Active Configuration</em> to <strong>Distribution</strong>.</p></li>
<li><p>Create a new file from the file template <em>Code Signing / Entitlements</em>.</p></li>
<li><p>Name it <strong>Entitlements.plist</strong>.</p></li>
<li><p>In this file, uncheck the checkbox <strong>get-task-allow</strong>.</p></li>
<li><p>Bring up the <em>Target Info</em> pane, and find the section <strong>Code Signing</strong> again.</p></li>
<li><p>After <strong>Code Signing Entitlements</strong> enter the file name <strong>Entitlements.plist</strong>.</p></li>
<li><p>Save, clean, and build the project.</p></li>
<li><p>In <em>Groups & Files</em> find the folder <strong>MyApp / Products</strong> and expand it.</p></li>
<li><p>Right click the app and select <strong>Reveal in Finder</strong>.</p></li>
<li><p>Zip the .app file and the .mobileprovision file and send the archive to your tester.</p>
<blockquote>
<p>Here is my app. To install it onto your phone:</p>
<ol>
<li><p>Unzip the archive file.</p></li>
<li><p>Open iTunes.</p></li>
<li><p>Drag both files into iTunes and drop them on the Library group.</p></li>
<li><p>Sync your phone to install the app.</p></li>
</ol>
</blockquote></li>
</ol>
<p>Done! Phew. This worked for me. So far I've only added one tester.</p>
|
<p><em>(As the official guide is still missing in this thread..)</em></p>
<p><a href="https://developer.apple.com/app-store/testflight/" rel="nofollow">TestFlight</a>, acquired by Apple and now (iOS8+) available for beta testing makes it easy to hand your app to beta testers without the need to collect device UUIDs beforehand (you only need email addresses of your testers). An extensive guide explaining all necessary steps may be found in the <a href="https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/BetaTestingTheApp.html" rel="nofollow">iTunes Connect Developer Guide</a>.</p>
| 6,138
|
<p>I have built a web page which contains a Crystal Report built using the Crystal libraries included in Visual Studio 2008. </p>
<p>It '<a href="http://jcooney.net/archive/2007/02/01/42999.aspx" rel="noreferrer">works on my machine</a>' but when deployed to the web server the icons (Export, Print etc) on the Crystal Report toolbar do not display or work. Just seeing the 'red X' where the button image should be and clicking does nothing.</p>
<p>I have checked that the toolbar images are actually in the location being looked at on the web server:
(C:/Inetpub/wwwroot/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer4/images/toolbar/)<br>
They are all there. </p>
<p>I have checked the permissions on the above mentioned folder on the web server.
Gave 'full control' to every user just to test it. </p>
<p>I have also intalled/run the 'CRRedist2008_x86.msi' on the web server. </p>
<p>Some people have mentioned ensuring that 'crystalreportviewers115' folder is added to my '\wwwroot\aspnet_client\system_web\2_0_50727' folder on the web server but I have been unable to find the 'crystalreportviewers115' to copy it.</p>
<p>Appreciate any help or ideas you may be able to offer. </p>
<p>Update - OK, so obviously I hadn't checked well enough that the images were in the correct location. </p>
|
<p>Doh! Someone else here at work figured this out. It was really simple and I should have been able to sort it, but hey, that's how it goes sometimes.</p>
<p>Here the fix:<br>
On the web server, copy the 'aspnet_client' folder from 'C:\Inetpub\wwwroot' to 'C:\Inetpub\wwwroot\your-website-name'. </p>
<p>That's all we did and it's now working. </p>
<p>Hope this saves someone from all the fuss I just went through.</p>
|
<p>I took over maintaining some code produced by another developer who had left and suffered this issue too. In my case the compiled report was looking for the images in the crystalreportview115 folder which existed in my local development path and therefore worked locally. The only folder on on the target server was the CrystalReportWebFormViewer4 (I assume from a previous server installation or site deployment). Simply adding the ...115 folder sorted the problem out for me. </p>
<p>The root cause for us would appear to be the version of Crystal installed on the developers machine. Not sure that helps anyone but thought I'd mention it!</p>
| 7,674
|
<p>How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses?</p>
|
<p>Several connectors are configured, and each connector has an optional "address" attribute where you can set the IP address.</p>
<ol>
<li>Edit <code>tomcat/conf/server.xml</code>.</li>
<li>Specify a bind address for that connector: <pre>
<Connector
port="8080"
protocol="HTTP/1.1"
address="127.0.0.1"
connectionTimeout="20000"
redirectPort="8443"
/>
</pre></li>
</ol>
|
<p>It may be worth mentioning that running tomcat as a non root user (which you should be doing) will prevent you from using a port below 1024 on *nix. If you want to use TC as a standalone server -- as its performance no longer requires it to be fronted by Apache or the like -- you'll want to bind to port 80 along with whatever IP address you're specifying. </p>
<p>You can do this by using IPTABLES to redirect port 80 to 8080.</p>
| 3,916
|
<p>I am quite new to 3D printing, and having difficulty printing first layer of an object with support. The object has a few curved surfaces that touch the print bed, so not a big starting foot print.</p>
<p>I am printing on a genuine Prusa i3 mk2s, using PLA, 210 °C (clean from what I can tell) nozzle, 60 °C (clean, good condition) heat bed. My model is an STL from Thingiverse, and I sliced it with Prusa Control. Settings: 0.3 mm layers, 30 % infill, Support from build plate, brim on. I have run the printer calibration, z-axis calibration, etc. Only thing that might be a bit out is my z-axis might be a <em>fraction</em> too low. I have no issues when printing objects without support, and usually don't have issues printing objects with support (although typically these have a larger contact area of the object to the print bed as well)</p>
<p>After it prints the brim (which adheres well), it tries to print the support layers for the "actual" layers that will get printed first. These layers do not touch the outer brim. They go down with a little bit of "squeeze out" when the printer does a 180-degree turn. (this can be seen on the right hand end of first picture).</p>
<p>Then, it attempts to print the whole-of-base support structure (refer to pic 3 and 4 for details). Where these support layers touch the outer brim, they adhere well. When they touch the initial support layer sections, it tears them up, leaving a big mess.</p>
<p>What appears to me to be happening, is the small sections that get printed first (circled in red) are either not adhering well enough, or somehow getting "ruffled up", or are printed too close to the subsequent, broader strokes of the rest of the support layer, such that when the rest of the support layer is printed, it is tearing up the initial small sections. Having 2 densities of support layer per layer seems to be causing issues.</p>
<p>Failed print, still on the bed. At the right, there is a section of "fine" support material that sort of survived.</p>
<p><a href="https://i.stack.imgur.com/NKa4E.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NKa4E.jpg" alt="failed first layer"></a></p>
<p>Close up of the failed first layer. The broad strokes seem to adhere well except for when they meet where the fine layer was - after that it's just a big mess.</p>
<p><a href="https://i.stack.imgur.com/rEmXD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rEmXD.jpg" alt="failed first layer close up"></a></p>
<p>Slicing in Prusa control (part 1): shows the different support structures and very minimal contact of actual object to the bed (orange) </p>
<p><a href="https://i.stack.imgur.com/RMFL5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RMFL5.png" alt="prusa control first layer 1"></a></p>
<p>Close up of other problem area in PC slicing. No actual contact of object to bed here. Also, as a side note, why the funny diagonal line cutting through the rest of the support structure here?</p>
<p><a href="https://i.stack.imgur.com/4belv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4belv.png" alt="Prusa control first layer 2"></a></p>
|
<p><strong>Quick, low-tech solution:</strong></p>
<p>There might be several issues in your question, but in relation to bed adhesion, I'll share one of the most useful tips I wish someone had told me when I started out: <em>Spread some glue-stick over the area to be printed</em>.</p>
<p>I used ordinary school/craft glue stick (which I stole from my daughter's school pencil case) - the kind for gluing paper. I use a purple one, so it's easy to see and easy to clean up. I apply a little glue then smear it around with a wet finger to make it a bit uniform.</p>
<p>I have a heated bed (FlashForge Creator Pro) and have used this little trick with a range of filaments. In almost every case, it helps adhesion enormously. Parts and supports stick like mad! But they still come off easily enough the usual way. It is a weak glue, so it won't lock the part to the bed. Once the part is off, the purple glue is visible when wet, so it is dead easy to clean up the part and the bed in a minute or two.</p>
<p>This trick is so easy that it is worth trying first for any adhesion issues, before digging deeper.</p>
|
<p>It is hard to determine the exact source of the problem as there are few possibilities (I am assuming that you have a single nozzle and only one filament in use):</p>
<ol>
<li><p>One of the hardest issues for me to get on my printer was fact that my auto-level sensor was mounted about 0.5mm too high - so please check that as this will give you a bit higher Z than expected.</p></li>
<li><p>Printing speed matters - for some prints I was slowing my printer to 20% of nominal speed to get adhesion</p></li>
<li><p>a hair-spray layer or a masking tape on the bed could help with getting the grip</p></li>
<li><p>also you could play with nozzle temperature de/increasing by 5 degrees and see how it is going</p></li>
</ol>
| 863
|
<p>I want to test the behavior of a certain piece of .NET code in partial trust environments. What's the fastest way to set this up? Feel free to assume that I (and other readers) are total CAS noobs.</p>
<p>@Nick: Thanks for the reply. Alas, the tool in question is explicitly for unmanaged code. I didn't say "managed" in my question, and should not have assumed that people would infer it from the ".NET" tag.</p>
|
<p>This is an excellent question, especially from a TDD point of view and validating code under different trust scenarios. </p>
<p>I think the way I'd approach this would be something along the lines of - </p>
<ul>
<li><p>Create an AppDomain in my TDD code using the AppDomain.CreateDomain() overload that allows you to pass in a PermissionSet. The PermissionSet would be constructed to match the different trust scenarios you'd want to test against.</p></li>
<li><p>Load the assembly containing logic under test into the app domain</p></li>
<li><p>Create instances of types/call methods etc in app domain, trap security exceptions</p></li>
</ul>
<p>Something kinda like that. I've not had time to knock up a proof of concept yet.</p>
|
<p>Use the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=bd02c19c-1250-433c-8c1b-2619bd93b3a2&displaylang=en" rel="nofollow noreferrer">Microsoft Application Verifier</a>.</p>
<p>AppVerifier helps to determine:</p>
<ul>
<li>When the application is using APIs correctly:
(Unsafe TerminateThread APIs., Correct use of Thread Local Storage (TLS) APIs., o Correct use of virtual space manipulations (for example, VirtualAlloc, MapViewOfFile).</li>
<li>Whether the application is hiding access violations using structured exception handling.</li>
<li>Whether the application is attempting to use invalid handles.</li>
<li>Whether there are memory corruptions or issues in the heap.</li>
<li>Whether the application runs out of memory under low resources.</li>
<li>Whether the correct usage of critical sections is occurring.</li>
<li>Whether an application running in an administrative environment will run well in an environment with less privilege.</li>
<li>Whether there are potential problems when the application is running as a limited user.</li>
<li>Whether there are uninitialized variables in future function calls in a thread's context.</li>
</ul>
| 4,103
|
<p>So right now my project has a few custom dialogs that do things like prompt the user for his birthday, or whatever. Right now they're just doing things like setting a <code>this.Birthday</code> property once they get an answer (which is of type <code>DateTime?</code>, with the null indicating a "Cancel"). Then the caller inspects the <code>Birthday</code> property of the dialog it created to figure out what the user answered.</p>
<p>My question is, <em>is there a more standard pattern for doing stuff like this?</em> I know we can set <code>this.DialogResult</code> for basic OK/Cancel stuff, but is there a more general way in Windows Forms for a form to indicate "here's the data I collected"?</p>
|
<p>I would say exposing properties on your custom dialog is the idiomatic way to go because that is how standard dialogs (like the Select/OpenFileDialog) do it. Someone could argue it is more explicit and intention revealing to have a ShowBirthdayDialog() method that returns the result you're looking for, but following the framework's pattern is probably the wise way to go.</p>
|
<p>I've always done it exactly the way you're describing. I'm curious to see if there's a more accepted approach.</p>
| 5,760
|
<p>I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response:</p>
<blockquote>
<p>The data types text and varchar are incompatible in the not equal to operator.</p>
</blockquote>
<p>Is there a special function to determine whether the value of a text column is not null but empty?</p>
|
<pre><code>where datalength(mytextfield)=0
</code></pre>
|
<p>I would test against <a href="http://msdn.microsoft.com/en-us/library/ms187748.aspx" rel="nofollow noreferrer">SUBSTRING</a>(textColumn, 0, 1)</p>
| 5,345
|
<p>I'm looking for a graph algorithm with some unusual properties.</p>
<p>Each edge in the graph is either an "up" edge or a "down" edge.</p>
<p>A valid path can go an indefinite number of "up"'s followed by an indefinite number of "down"'s, or vice versa. However it cannot change direction more than once.</p>
<p>E.g., a valid path might be A "up" B "up" C "down" E "down" F
an invalid path might be A "up" B "down" C "up" D</p>
<p>What is a good algorithm for finding the shortest valid path between two nodes? What about finding all of the equal length shortest paths?</p>
|
<p>Assuming you don't have any heuristics, a variation of <a href="http://en.wikipedia.org/wiki/Dijkstra's_algorithm" rel="nofollow noreferrer">dijkstra's algorithm</a> should suffice pretty well. Every time you consider a new edge, store information about its "ancestors". Then, check for the invariant (only one direction change), and backtrack if it is violated.</p>
<p>The ancestors here are all the edges that were traversed to get to the current node, along the shortest path. One good way to store the ancestor information would be as a pair of numbers. If U is up, and D is down, a particular edge's ancestors could be <code>UUUDDDD</code>, which would be the pair <code>3, 4</code>. You will not need a third number, because of the invariant.</p>
<p>Since we have used dijkstra's algorithm, finding multiple shortest paths is already taken care of.</p>
|
<p>If you have a standard graph search function, say <code>Graph.shortest(from, to)</code> in a library, you can loop and minimize, in C#/pseudocode: </p>
<pre><code>[ (fst.shortest(A, C) + nxt.shortest(C, B))
for C in nodes , (fst, nxt) in [(up, down), (down, up)] ].reduce(min)
</code></pre>
<p>If you need to remember the minimum path/paths and it so happens that your standard function returns you the data, you could also pronounce </p>
<pre><code>[ [fst, nxt, C, fst.shortest(A, C), nxt.shortest(C,B)]
for C in nodes , (fst, nxt) in [(up, down), (down, up)] ].reduce(myMin)
</code></pre>
<p>where <code>myMin</code> should compare two <code>[fst, nxt, C, AC, BD]</code> tuples and leave the one that has lower distance, or both and assuming <code>reduce</code> is a smart function.</p>
<p>This has some memory overhead if our graphs are large and don't use memory at all (which is possible if they are generated dynamically), but not really any speed overhead, imho.</p>
| 7,623
|
<p>I have been searching on the web for some example code on how we can write a custom ActiveX Control for use in Excel using .NET but so far I have found old articles suggesting that it is not supported. </p>
<p>The application we are building uses Excel as a report writer so we which to add some custom controls to the worksheets to provide a richer experience. From the research I have done so far it appears that some ActiveX Controls can only be hosted in IE and hence I need to ensure that any approach taken works with Excel as a host.</p>
<p>The link <a href="http://www.codeproject.com/KB/miscctrl/exposingdotnetcontrols.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/miscctrl/exposingdotnetcontrols.aspx</a> mentions the following:</p>
<p><strong>CAVEAT</strong>: As this support has been dropped from Beta2 of .NET, don't blame me if it fries your PC or toasts the cat.</p>
<p>Can anybody give me an indication if it is possible using .NET 1.1 and if so to any pointers on best practices?</p>
|
<p>Andrew Whitechapel writes about managed controls as ActiveX controls in Office documents. You can read his article here:</p>
<blockquote>
<p><strong><a href="http://blogs.msdn.com/andreww/archive/2008/11/24/using-managed-controls-as-activex-controls.aspx" rel="nofollow noreferrer">Using Managed Controls as ActiveX Controls</a></strong></p>
</blockquote>
|
<p>I would thought that you're out of luck, but did find this:</p>
<p><a href="http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx" rel="nofollow noreferrer">http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx</a></p>
<p>Gives me the willies... but it might just right for you.</p>
| 8,502
|
<p>I've found syntax highlighters that highlight pre-existing code, but I'd like to do it as you type with a WYSIWYG-style editor. I don't need auto-completed functions, just the highlighting.</p>
<p>As a follow-up question, what is the WYSIWYG editor that stackoverflow uses?</p>
<p>Edit: Thanks to the answer below, I found two that look like they might suit my needs:
<a href="http://www.cdolivet.net/editarea/" rel="nofollow noreferrer">EditArea</a> and <a href="http://codepress.sourceforge.net/" rel="nofollow noreferrer">CodePress</a></p>
<p>EDIT: See this question also:<br>
<a href="https://stackoverflow.com/questions/379185/free-syntax-highlighting-editor-control-in-javascript">https://stackoverflow.com/questions/379185/free-syntax-highlighting-editor-control-in-javascript</a></p>
|
<p>Here is a really interesting article about how to write one: (Even better, he gives the full source to a JavaScript formatter and colorizer.)</p>
<p><a href="http://marijn.haverbeke.nl/codemirror/story.html" rel="noreferrer">Implementing a syntax-higlighting JavaScript editor in JavaScript</a>
or
A brutal odyssey to the dark side of the DOM tree</p>
<blockquote>
<p>How does one do decent syntax
highlighting? A very simple scanning
can tell the difference between
strings, comments, keywords, and other
code. But this time I wanted to
actually be able to recognize regular
expressions, so that I didn't have any
blatant incorrect behaviour anymore.</p>
</blockquote>
<p>Importantly, it handles regex correctly. Also of interest is that he used a continuation passing style lexer/parser instead of the more typical lex (or regex) based lexers that you'll see in the wild.</p>
<p>As a bonus he discusses a lot of real-world issues you'll run into when working with JavaScript in the browser.</p>
|
<p>I dont program a lot of javascript but JSEclipse has been pretty helpful for me in the past. It comes as an Eclipse plug-in.</p>
<p>I've been using it for years for free</p>
<p><a href="http://www.interaktonline.com/products/eclipse/jseclipse/overview/" rel="nofollow noreferrer">http://www.interaktonline.com/products/eclipse/jseclipse/overview/</a></p>
<p>I also rely heavily on FireBug for Firefox whenever I deal with Javascript</p>
| 8,688
|
<p>If I call <code>finalize()</code> on an object from my program code, will the <strong>JVM</strong> still run the method again when the garbage collector processes this object?</p>
<p>This would be an approximate example:</p>
<pre><code>MyObject m = new MyObject();
m.finalize();
m = null;
System.gc()
</code></pre>
<p>Would the explicit call to <code>finalize()</code> make the <strong>JVM</strong>'s garbage collector not to run the <code>finalize()</code> method on object <code>m</code>?</p>
|
<p>According to this simple test program, the JVM will still make its call to finalize() even if you explicitly called it:</p>
<pre><code>private static class Blah
{
public void finalize() { System.out.println("finalizing!"); }
}
private static void f() throws Throwable
{
Blah blah = new Blah();
blah.finalize();
}
public static void main(String[] args) throws Throwable
{
System.out.println("start");
f();
System.gc();
System.out.println("done");
}
</code></pre>
<p>The output is:</p>
<blockquote>
<p>start<br>
finalizing!<br>
finalizing!<br>
done</p>
</blockquote>
<p>Every resource out there says to never call finalize() explicitly, and pretty much never even implement the method because there are no guarantees as to if and when it will be called. You're better off just closing all of your resources manually.</p>
|
<p>The finalize method is never invoked more than once by a JVM for any given object. You shouldn't be relying on finalize anyway because there's no guarantee that it will be invoked. If you're calling finalize because you need to execute clean up code then better to put it into a separate method and make it explicit, e.g:</p>
<pre><code>public void cleanUp() {
.
.
.
}
myInstance.cleanUp();
</code></pre>
| 4,847
|
<p>In a web application, I have a page that contains a DIV that has an auto-width depending on the width of the browser window.</p>
<p>I need an auto-height for the object. The DIV starts about 300px from the top screen, and its height should make it stretch to the bottom of the browser screen. I have a max height for the container DIV, so there would have to be minimum-height for the div. I believe I can just restrict that in CSS, and use Javascript to handle the resizing of the DIV.</p>
<p>My javascript isn't nearly as good as it should be. Is there an easy script I could write that would do this for me?</p>
<p>Edit:
The DIV houses a control that does it's own overflow handling (implements its own scroll bar).</p>
|
<p>Try this simple, specific function:</p>
<pre><code>function resizeElementHeight(element) {
var height = 0;
var body = window.document.body;
if (window.innerHeight) {
height = window.innerHeight;
} else if (body.parentElement.clientHeight) {
height = body.parentElement.clientHeight;
} else if (body && body.clientHeight) {
height = body.clientHeight;
}
element.style.height = ((height - element.offsetTop) + "px");
}
</code></pre>
<p>It does not depend on the current distance from the top of the body being specified (in case your 300px changes).</p>
<hr>
<p>EDIT: By the way, you would want to call this on that div every time the user changed the browser's size, so you would need to wire up the event handler for that, of course.</p>
|
<p>If I understand what you're asking, this should do the trick:</p>
<pre><code>// the more standards compliant browsers (mozilla/netscape/opera/IE7) use
// window.innerWidth and window.innerHeight
var windowHeight;
if (typeof window.innerWidth != 'undefined')
{
windowHeight = window.innerHeight;
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the first
// line in the document)
else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth != 'undefined'
&& document.documentElement.clientWidth != 0)
{
windowHeight = document.documentElement.clientHeight;
}
// older versions of IE
else
{
windowHeight = document.getElementsByTagName('body')[0].clientHeight;
}
document.getElementById("yourDiv").height = windowHeight - 300 + "px";
</code></pre>
| 5,306
|
<p>I'm working on a cross platform application in Java which currently works nicely on Windows, Linux and MacOS X. I'm trying to work out a nice way to do detection (and handling) of 'crashes'. Is there an easy, cross-platform way to detect 'crashes' in Java and to do something in response?</p>
<p>I guess by 'crashes' I mean uncaught exceptions. However the code does use some JNI so it'd be nice to be able to catch crashes from bad JNI code, but I have a feeling that's JVM specific.</p>
|
<p>For simple catch-all handling, you can use the following static method in <a href="http://java.sun.com/javase/6/docs/api/java/lang/Thread.html" rel="nofollow noreferrer">Thread</a>. From the Javadoc:</p>
<blockquote>
<p>static void <a href="http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)" rel="nofollow noreferrer"><strong>setDefaultUncaughtExceptionHandler</strong></a>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/Thread.UncaughtExceptionHandler.html" rel="nofollow noreferrer">Thread.UncaughtExceptionHandler</a> eh) <br/> Set the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread.</p>
</blockquote>
<p>This is a very broad way to deal with errors or unchecked exceptions that may not be caught anywhere else.</p>
<p><strong>Side-note:</strong> It's better if the code can catch, log and/or recover from exceptions closer to the source of the problem. I would reserve this kind of generalized crash handling for totally unrecoverable situations (i.e. subclasses of <a href="http://java.sun.com/javase/6/docs/api/java/lang/Error.html" rel="nofollow noreferrer">java.lang.Error</a>). Try to avoid the possibility of a <a href="http://java.sun.com/javase/6/docs/api/java/lang/RuntimeException.html" rel="nofollow noreferrer">RuntimeException</a> ever going completely uncaught, since it might be possible--and preferable--for the software to survive that.</p>
|
<p>Not sure if this is what you needing, but you can also detect if an exception has occurred from within your native code. See <a href="http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp5234" rel="nofollow noreferrer">http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp5234</a> for more info.</p>
| 8,699
|
<p>I haven't ran into the issue yet, but I am sort of expecting it to here soon towards the end of my print. Actually, I am not even sure if it should be something that I should be worried about or not.</p>
<p>Basically I have some overhang on a helmet piece (it's a vent piece) and I see that there is a 90 % degree overhang. It doesn't look too big but just curious if this should be something that I should be worried about. I forgot to add support in the vent, it's my own fault and I'm definitely going to fix this in my next print for sure, but do you all think it will fail if I keep the current print going?</p>
<p><a href="https://i.stack.imgur.com/r3LV5.png" rel="nofollow noreferrer" title="Screenshot showing unsupported overhanging vent"><img src="https://i.stack.imgur.com/r3LV5.png" alt="Screenshot showing unsupported overhanging vent" title="Screenshot showing unsupported overhanging vent" /></a></p>
<p>I use Cura, Meshmaker, and I have an Ender 3 printer.</p>
<p>I'm just getting started with 3D printing so I wasn't sure if I should be concerned or not.</p>
|
<p>That depends on various parameters if an overhang will work or not, material, hotend temperature, speed, cooling, size of the overhang, etc.</p>
|
<p>Many parameters will influence success. That overhang, as flat as it is and unsupported, will need to have support-structures enabled to become printable.</p>
| 1,809
|
<p>I want to embed a wikipedia article into a page but I don't want all the wrapper (navigation, etc.) that sits around the articles. I saw it done here: <a href="http://www.dayah.com/periodic/" rel="nofollow noreferrer">http://www.dayah.com/periodic/</a>. Click on an element and the iframe is displayed and links to the article only (no wrapper). So how'd they do that? Seems like JavaScript handles showing the iframe and constructing the href but after browsing the pages javascript (<a href="http://www.dayah.com/periodic/Script/interactivity.js" rel="nofollow noreferrer">http://www.dayah.com/periodic/Script/interactivity.js</a>) I still can't figure out how the url is built. Thanks.</p>
|
<p>The periodic table example loads the printer-friendly version of the wiki artice into an iframe. <a href="http://en.wikipedia.org/wiki/Potasium" rel="noreferrer">http://en.wikipedia.org/wiki/Potasium</a>?<b>printable=yes</b></p>
<p>it's done in <i>function click_wiki(e)</i> (line 534, interactivity.js)</p>
<blockquote><pre>
var article = el.childNodes[0].childNodes[n_name].innerHTML;
...
window.frames["WikiFrame"].location.replace("http://" + language + ".wikipedia.org/w/index.php?title=" + encodeURIComponent(article) + "&printable=yes");
</pre></blockquote>
|
<p>You could always download the site and scrap it. I think everything inside <code><div id="bodyContent"></code> is the content of the article - sans navigation, header, footer, etc..</p>
<p>Don't forget to credit. ;)</p>
| 8,723
|
<p>I understand that heater blocks act as kind of “low-pass-filter” on the temperature change of the hotend, but why do we need that?</p>
<p>Wouldn’t it be better to have as little metal as possible in order to be able to control temperature changes quickly and precisely (using PID, PWM plus maybe some predictions based on printed G-code)?</p>
|
<p>Let's look at the elements and what they do:</p>
<p>The <em>Heater Cartridge</em> (blue) is the device that converts electric to thermal energy to melt the plastic. 30 and 40 W are common.</p>
<p>The <em>Thermosensor</em> (red) is there to give feedback to the mainboard.</p>
<p>The <em>Filament Path</em> (gold) in this area is made up of the <em>nozzle</em> and the <em>heatbreak</em>, it contains the <em>meltzone</em>.</p>
<p>The <em>Heater Block</em> (transparent green) is the mounting for all parts. It also acts as the medium to transfer the thermal energy from the <em>Heater Cartidge</em> to the <em>Thermo Sensor</em> and the <em>Filament Path</em>. It also acts as a dampener for the control circuit.</p>
<p>Now, let's put things together and omit the wires and cold end (and internal geometry of the filament path, cause I am lazy):</p>
<p><a href="https://i.stack.imgur.com/b0nE1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b0nE1.png" alt="Mock up of a hotend assembly" /></a></p>
<p>Now, the construction gives us several reasons for the shape of the heater block:</p>
<ul>
<li>Ease of construction. Taking a simple block and adding a couple of holes and one cut allows very fast production.</li>
<li>Maximum contact surface. To get the maximum contact surface to the heater cartrige, the heater block has to make contact along its whole length, dictating a minimum size in 2 direction. The same is true for the thermosensor.</li>
<li>The heater block transmits temperature pretty much radially from the heater cartridge. Because it is metal, the gradient between areas is very low, but it is measureable. These would be the thermal equivalent lines on heating up:</li>
</ul>
<p><a href="https://i.stack.imgur.com/LL01Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LL01Q.png" alt="Heating lines around the Heater Cartridge" /></a></p>
<p>You may easily notice that the temperature lines appear more straight as they come closer to the filament path and thermosensor. This helps to give the filament in the heatbreak and nozzle more even heating and better printing.</p>
<p>The mockup I made has a deliberate flaw though: a change in temperature first affects the filament and then shows up on the sensor, making the temperature in the filament path wobble to the extreme. The Heater Block acts pretty much as a transmitter just as much as a time dilation between the heating command and the pickup.</p>
<p>Because this arrangement is not very good, let's swap sensor and filament path around and look at the same lines.</p>
<p><a href="https://i.stack.imgur.com/cTqqo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cTqqo.png" alt="Arrangement 2 of a Hotend assembly" /></a></p>
<p>Now we have a much shorter feedback loop, allowing our printer to react quicker to temperature changes and the filament path also gets heated more evenly. The temperature inside the filament path does change less around the target temperature. The whole block now acts mostly as a distribution medium but also as a storage for heat energy:</p>
<p>Up to this point, we did not take into account a very simple fact: the hotend drains thermal energy via two areas:</p>
<ul>
<li>The outer surface of the heater block emits heat to the air.</li>
<li>Filament gets molten and extruded.</li>
</ul>
<p>Factor 1 is simple and here a bigger heater block actually is positive: The thermal 'storage' capacity is dependant on the volume, so goes with <span class="math-container">$xyz \approx a^3$</span>. The surface to emit heat from goes with <span class="math-container">$2\times(xy+xz+yz)\approx 6\times a^2$</span>. Plotting a graph of that shows us the square-cube law: the capacity increase for one unit does increase the surface just by a fraction of that, so the storage gets better the larger the heater block is.</p>
<p>Factor 2 is why we need to have a storage of thermal energy in the first place: the flow of filament is not exactly the same all the time. Of course, we have moments of even flow, but we also have moments of low or no flow when the printer moves between parts of the print. This alteration of the drain of thermal energy from the heater block means that if we would go down to a bare minimum size, we'd heat up the block fast whenever we are on a move action and cool as the extrusion starts till equilibrium is achieved again. The more thermal capacity is there to store energy, the less the lack of extrusion will immediately affect the print and the more even the temperature will be in the filament path.</p>
<h2>Fast printing?!</h2>
<p>How is faster printing achieved with a special hotend? Well, 4 factors are used in hotends meant for very fast or very hot printing:</p>
<ul>
<li>Longer, more powerful heater cartridge.</li>
<li>Longer filament path.</li>
<li>Extra large Heater Block to even out the temperature changes under extrusion more.</li>
<li>Insulating the Heater Block to the air.</li>
</ul>
<p>One of the prime examples would be an e3D-Volcano.</p>
|
<p>I think the idea is to <em>not</em> change the temperature fast. You want it to maintain a certain temperature so you have consistent flow. The extra mass at the hot end provides the mass which is needed to maintain the heat. If you don't maintain the heat while you print, you'll have inconsistent filament flow, which will screw up your print.</p>
| 1,335
|
<p>I'm using Visual C++ 2005 and would like to know the simplest way to connect to a MS SQL Server and execute a query.</p>
<p>I'm looking for something as simple as ADO.NET's SqlCommand class with it's ExecuteNonQuery(), ExecuteScalar() and ExecuteReader().</p>
<p>Sigh offered an answer using CDatabase and ODBC.</p>
<p>Can anybody demonstrate how it would be done using ATL consumer templates for OleDb?</p>
<p>Also what about returning a scalar value from the query?</p>
|
<p>With MFC use CDatabase and ExecuteSQL if going via a ODBC connection.</p>
<pre><code>CDatabase db(ODBCConnectionString);
db.Open();
db.ExecuteSQL(blah);
db.Close();
</code></pre>
|
<p>Try the Microsoft Enterprise Library. A version should be available <a href="http://www.codeplex.com/entlib" rel="nofollow noreferrer">here</a> for C++. The SQlHelper class impliments the methods you are looking for from the old ADO days. If you can get your hands on version 2 you can even use the same syntax.</p>
| 4,513
|
<p>What libraries/methods do you know of that can do some basic HTML representation in Swing? Can you comment on your experience?</p>
|
<p>Many of the Swing controls (like JLabel) can render basic HTML content. <a href="http://java.sun.com/javase/6/docs/api/javax/swing/JEditorPane.html" rel="nofollow noreferrer">JEditorPane</a> can be used to display HTML pages. However, these controls are limited to <a href="http://www.w3.org/TR/REC-html32" rel="nofollow noreferrer">HTML 3.2</a> support.</p>
<p>For a richer experience, I would use the <a href="https://java.net/projects/jdic/" rel="nofollow noreferrer">JDesktop Integration Components</a>.</p>
<blockquote>
<p>JDIC provides Java applications with
access to functionalities and
facilities provided by the native
desktop. It consists of a collection
of Java packages and tools. JDIC
supports a variety of features such as
<strong>embedding the native browser</strong>,
launching the desktop applications,
creating tray icons on the desktop,
registering file type associations,
creating JNLP installer packages, etc.</p>
</blockquote>
|
<p>Came across <a href="http://lobobrowser.org/java-browser.jsp" rel="nofollow noreferrer">Lobo</a> java web browser the other day.</p>
<blockquote>
<p>Lobo is being actively developed with the aim to fully support HTML 4, Javascript and CSS2.</p>
</blockquote>
<p>No experience with it though, but thought it may fit the bill for you.</p>
| 4,615
|
<p>I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS.</p>
<blockquote>
<p>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\odbcss.h(430) :
error C2371: 'WCHAR' : redefinition; different basic types 1><br>
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winnt.h(289) :
see declaration of 'WCHAR'</p>
</blockquote>
<p>I don't see any defines in odbcss.h that I could set to avoid this. Has anyone else seen this? </p>
|
<p>This is a known bug - see the Microsoft Connect website:</p>
<p><a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98699" rel="nofollow noreferrer">http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98699</a></p>
<p>The error doesn't occur if you compile your app as Unicode instead of MBCS.</p>
|
<p>This error happens when you redeclare a variable of the same name as a variable that has already been declared. Have you looked to see if odbcss.h has declared a variable you already have?</p>
| 6,352
|
<pre><code>class Foo
{
static bool Bar(Stream^ stream);
};
class FooWrapper
{
bool Bar(LPCWSTR szUnicodeString)
{
return Foo::Bar(??);
}
};
</code></pre>
<p><code>MemoryStream</code> will take a <code>byte[]</code> but I'd <em>like</em> to do this without copying the data if possible.</p>
|
<p>You can avoid the copy if you use an <a href="http://msdn.microsoft.com/en-us/library/system.io.unmanagedmemorystream.aspx" rel="nofollow noreferrer"><code>UnmanagedMemoryStream()</code></a> instead (class exists in .NET FCL 2.0 and later). Like <code>MemoryStream</code>, it is a subclass of <code>IO.Stream</code>, and has all the usual stream operations.</p>
<p>Microsoft's description of the class is:</p>
<blockquote>
<p>Provides access to unmanaged blocks of memory from managed code.</p>
</blockquote>
<p>which pretty much tells you what you need to know. Note that <code>UnmanagedMemoryStream()</code> is not CLS-compliant.</p>
|
<p>If I had to copy the memory, I think the following would work:</p>
<pre><code>
static Stream^ UnicodeStringToStream(LPCWSTR szUnicodeString)
{
//validate the input parameter
if (szUnicodeString == NULL)
{
return nullptr;
}
//get the length of the string
size_t lengthInWChars = wcslen(szUnicodeString);
size_t lengthInBytes = lengthInWChars * sizeof(wchar_t);
//allocate the .Net byte array
array^ byteArray = gcnew array(lengthInBytes);
//copy the unmanaged memory into the byte array
Marshal::Copy((IntPtr)(void*)szUnicodeString, byteArray, 0, lengthInBytes);
//create a memory stream from the byte array
return gcnew MemoryStream(byteArray);
}</code></pre>
| 6,392
|
<p>I'm trying to find <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" rel="noreferrer">ab - Apache HTTP server benchmarking tool</a> for Ubuntu, I'm hoping there's a package I can install for it. I decided I need to do some simple load testing on my applications.</p>
|
<pre><code>% sudo apt-get install apache2-utils</code></pre>
<p>The command-not-found package in Ubuntu provides some slick functionality where if you type a command that can't be resolved to an executable (or bash function or whatever) it will query your apt sources and find a package that contains the binary you tried to execute. So, in this case, I typed <code>ab</code> at the command prompt:</p>
<pre>
<code>
% ab
The program 'ab' is currently not installed. You can install it by typing:
sudo apt-get install apache2-utils
bash: ab: command not found
</code>
</pre>
|
<p>Another way to search for missing files, e.g. if you use zsh, want to disable command-not-found (slows things down when you misstype commandnames), or are looking for a file that is not an executable:</p>
<pre><code>$ sudo aptitude install apt-file
$ sudo apt-file update
$ apt-file search bin/ab
</code></pre>
| 9,209
|
<p>Am I correct in assuming that the only difference between "windows files" and "unix files" is the linebreak?</p>
<p>We have a system that has been moved from a windows machine to a unix machine and are having troubles with the format.</p>
<p>I need to automate the translation between unix/windows before the files get delivered to the system in our "transportsystem". I'll probably need something to determine the current format and something to transform it into the other format.
If it's just the newline thats the big difference then I'm considering just reading the files with the java.io. As far as I know, they are able to handle both with readLine. And then just write each line back with</p>
<pre><code>while (line = readline)
print(line + NewlineInOtherFormat)
....
</code></pre>
<hr />
<h2>Summary:</h2>
<blockquote>
<p><a href="https://stackoverflow.com/users/1908/samjudson">samjudson</a>:</p>
<blockquote>
<p><i>This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR.</i></p>
</blockquote>
<p>to which <a href="https://stackoverflow.com/users/1612/cebjyre">Cebjyre</a> elaborates:</p>
<blockquote>
<p><i>OS X uses LF, the same as UNIX - MacOS 9 and below did use CR though</i></p>
</blockquote>
<p><a href="https://stackoverflow.com/users/1870/mo">Mo</a></p>
<blockquote>
<p><i>There could also be a difference in character encoding for national characters. There is no "unix-encoding" but many linux-variants use UTF-8 as the default encoding. Mac OS (which is also a unix) uses its own encoding (macroman). I am not sure, what windows default encoding is.</i></p>
</blockquote>
<p><a href="https://stackoverflow.com/users/304/mcdowell">McDowell</a></p>
<blockquote>
<p><i>In addition to the new-line differences, the byte-order mark can cause problems if files are treated as Unicode on Windows.</i></p>
</blockquote>
<p><a href="https://stackoverflow.com/users/1820/cheekysoft">Cheekysoft</a></p>
<blockquote>
<p><i>However, another set of problems that you may come across can be related to single/multi-byte character encodings. If you see strange unexpected chars (not at end-of-line) then this could be the reason. Especially if you see square boxes, question marks, upside-down question marks, extra characters or unexpected accented characters.</i></p>
</blockquote>
<p><a href="https://stackoverflow.com/users/1000/sadie">Sadie</a></p>
<blockquote>
<p><i>On unix, files that start with a . are hidden. On windows, it's a filesystem flag that you probably don't have easy access to. This may result in files that are supposed to be hidden now becoming visible on the client machines.</p>
<p>File permissions vary between the two. You will probably find, when you copy files onto a unix system, that the files now belong to the user that did the copying and have limited rights. You'll need to use chown/chmod to make sure the correct users have access to them.</i></p>
</blockquote>
</blockquote>
<p>There exists tools to help with the problem:</p>
<blockquote>
<p><a href="https://stackoverflow.com/users/755/pauldoo">pauldoo</a></p>
<blockquote>
<p><i>If you are just interested in the content of text files, then yes the line endings are different. Take a look at something like dos2unix, it may be of help here.</i></p>
</blockquote>
<p><a href="https://stackoverflow.com/users/1820/cheekysoft">Cheekysoft</a></p>
<blockquote>
<p><i>As pauldoo suggests, tools like dos2unix can be very useful. Note that these may be on your linux/unix system as fromdos or tofrodos, or perhaps even as the general purpose toolbox recode.</i></p>
</blockquote>
</blockquote>
<p>Help for java coding</p>
<blockquote>
<p><a href="https://stackoverflow.com/users/1820/cheekysoft">Cheekysoft</a></p>
<blockquote>
<p><i>When writing to files or reading from files (that you are in control of), it is often worth specifying the encoding to use, as most Java methods allow this. However, also ensuring that the system locale matches can save a lot of pain</i></p>
</blockquote>
</blockquote>
|
<p>This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR.</p>
<p>Binary files there should be no difference (i.e. a JPEG on a windows machine will be byte for byte the same as the same JPEG on a unix box.)</p>
|
<p>In addition to the new-line differences, the <a href="http://en.wikipedia.org/wiki/Byte_Order_Mark" rel="nofollow noreferrer">byte-order mark</a> can cause problems if files are treated as Unicode on Windows.</p>
| 3,823
|
<p>I have an action like this:</p>
<pre><code>public class News : System.Web.Mvc.Controller
{
public ActionResult Archive(int year)
{
/ *** /
}
}
</code></pre>
<p>With a route like this:</p>
<pre><code>routes.MapRoute(
"News-Archive",
"News.mvc/Archive/{year}",
new { controller = "News", action = "Archive" }
);
</code></pre>
<p>The URL that I am on is:</p>
<pre><code>News.mvc/Archive/2008
</code></pre>
<p>I have a form on this page like this:</p>
<pre><code><form>
<select name="year">
<option value="2007">2007</option>
</select>
</form>
</code></pre>
<p>Submitting the form should go to News.mvc/Archive/2007 if '2007' is selected in the form.</p>
<p>This requires the form 'action' attribute to be "News.mvc/Archive".</p>
<p>However, if I declare a form like this:</p>
<pre><code><form method="get" action="<%=Url.RouteUrl("News-Archive")%>">
</code></pre>
<p>it renders as:</p>
<pre><code><form method="get" action="/News.mvc/Archive/2008">
</code></pre>
<p>Can someone please let me know what I'm missing?</p>
|
<p>You have a couple problems, I think.</p>
<p>First, your route doesn't have a default value for "year", so the URL "/News.mvc/Archive" is actually not valid for routing purposes.</p>
<p>Second, you're expect form values to show up as route parameters, but that's not how HTML works. If you use a plain form with a select and a submit, your URLs will end up having "?year=2007" on the end of them. This is just how GET-method forms are designed to work in HTML.</p>
<p>So you need to come to some conclusion about what's important.</p>
<ul>
<li>If you want the user to be able to select something from the dropdown and that changes the submission URL, then you're going to have to use Javascript to achieve this (by intercepting the form submit and formulating the correct URL).</li>
<li>If you're okay with /News.mvc/Archive?year=2007 as your URL, then you should remove the {year} designator from the route entirely. You can still leave the "int year" parameter on your action, since form values will also populate action method parameters.</li>
</ul>
|
<p>I think I've worked out why - the route includes {year} so the generated routes always will too..</p>
<p>If anyone can confirm this?</p>
| 7,165
|
<p>I have some code with multiple functions very similar to each other to look up an item in a list based on the contents of one field in a structure. The only difference between the functions is the type of the structure that the look up is occurring in. If I could pass in the type, I could remove all the code duplication.</p>
<p>I also noticed that there is some mutex locking happening in these functions as well, so I think I might leave them alone...</p>
|
<p>If you ensure that the field is placed in the same place in each such structure, you can simply cast a pointer to get at the field. This technique is used in lots of low level system libraries e.g. BSD sockets.</p>
<pre><code>struct person {
int index;
};
struct clown {
int index;
char *hat;
};
/* we're not going to define a firetruck here */
struct firetruck;
struct fireman {
int index;
struct firetruck *truck;
};
int getindexof(struct person *who)
{
return who->index;
}
int main(int argc, char *argv[])
{
struct fireman sam;
/* somehow sam gets initialised */
sam.index = 5;
int index = getindexof((struct person *) &sam);
printf("Sam's index is %d\n", index);
return 0;
}
</code></pre>
<p>You lose type safety by doing this, but it's a valuable technique.</p>
<p>[ I have now actually tested the above code and fixed the various minor errors. It's much easier when you have a compiler. ]</p>
|
<p>I'm a little rusty on c, but try using a void* pointer as the variable type in the function parameter. Then pass the address of the structure to the function, and then use it he way that you would.</p>
<pre><code>void foo(void* obj);
void main()
{
struct bla obj;
...
foo(&obj);
...
}
void foo(void* obj)
{
printf(obj -> x, "%s")
}
</code></pre>
| 9,335
|
<p>Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is <a href="http://jtauber.com/blog/2008/05/18/creating_gradients_programmatically_in_python/" rel="noreferrer">this blog entry</a>, but the example code seems to be missing, or at least it was as of this posting. Anything helps, algorithms, code examples, whatever. This will be written in Java, but the display layer is already taken care of, I just need to figure out how to figure out what to display.</p>
|
<p>you want an interpolation between the first and the second colour. Interpolating colours is easy by calculating the same interpolation for each of its components (R, G, B). There are many ways to interpolate. The easiest is to use linear interpolation: just take percentage <em>p</em> of the first colour and percentage 1 - <em>p</em> of the second:</p>
<pre><code>R = firstCol.R * p + secondCol.R * (1 - p)
</code></pre>
<p>There's <a href="https://stackoverflow.com/questions/25007/conditional-formatting-percentage-to-color-conversion">another question</a> related to this.</p>
<p>There are other methods of interpolation that sometimes work better. For example, using a <a href="http://en.wikipedia.org/wiki/Sigmoid_function" rel="noreferrer">bell-shaped (sigmoidal)</a> interpolation function makes the transition smoother.</p>
<p>/EDIT: Oops, you mean using a predefined function. OK, even easier. The blog post you linked now has an example code in Python.</p>
<p>In Java, you could use the <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/GradientPaint.html" rel="noreferrer"><code>GradientPaint</code></a>.</p>
|
<p>I've been using <a href="http://blog.logeek.fr/2008/10/21/generating-gradients-for-your-css-using-rmagick" rel="nofollow noreferrer">RMagick for that</a>. If you need to go further the simple gradient, ImageMagick and one of its wrappers (like RMagick or <a href="http://sourceforge.net/projects/jmagick/" rel="nofollow noreferrer">JMagick</a> for Java) could be useful.</p>
| 4,712
|
<p>When I'm creating a user for my web application, an SMTP email (using ASP.NET's SmtpClient) is sent to the user with the
automatically generated password. However, sometimes what I notice is that it times out and the new user simply won't receive the email with the password.</p>
<p>Alright, so I'll display a message indicating that the mail did not go through but the user is created.</p>
<p>Therefore, the sys admin has 2 options so far:</p>
<ol>
<li>Reset the password for the user and hope another SMTP mail is sent with the auto-generated password.</li>
<li>Delete and recreate the user.</li>
</ol>
<p>I could rollback the user creation if the smtp is not sent but what is the best practice to tackle this problem?</p>
<p>I'm thinking that I should retry sending the email 3 times with a timeout period of 5 seconds each. So 15 seconds would be the worse case scenario.</p>
<p>Is this the way to go?</p>
|
<p>Well, depending on your platform, if you can just hand off your mail to a local MTA, it should handle the retries and such. Your program can just queue the mail and move on, not worry about dealing with timeouts and graylists etc.</p>
<p>If the message still can't be delivered, you could always try resending it (via a password reset feature). If that fails as well, most likely there was a mistake in the email address, and I would suggest deleting the account, causing the user to re-register.</p>
<p>This, of course, might not be possible on some systems, depending what can be done with an unconfirmed user - that really depends on what you allow people to do before their email is validated.</p>
|
<p>IMHO you should notify the user, asking him to verify the email, without retries. </p>
<p>If the user does not verify the email and leaves the page, you better roll back the account since the user can not access it anyway. </p>
<p>Most cases of timeout would be caused by invalid email accounts. Users either made a mistake or gave you a non existent email addressto avoid being spammed. </p>
<p>If at all possible, do not ask for your users emails. Yhe number one rule of programming should be: DO NOT annoy the user.</p>
| 8,148
|
<p>I would like to create a folder that users who do not have privileges to view the rest of the site can see. This user group would be granted access to the site, but I only want them to be able to view one particular page.</p>
<p>Is this possible to do without going to every single page and removing the new user group's access?</p>
|
<p>yeah, you should be able to create a new group and add the users to that list/subweb/whatever and just that. This is assuming that you didn't grant access to all users somewhere. If you did, then hopefully the default access is granted to a default user group (like sharepoint visitors) and you can alter that group to exclude the users you only want to access the limited part of the site. </p>
<p>If created correctly the new group shouldn't have access to the rest of the site. </p>
|
<p>If you are getting thrown off by the fact that the user/group is listed as having "Limited Access" on the ACLs on, say, the parent site/web. That's just a placeholder SharePoint uses to make sure people have access to at least the bare minimum set of objects (e.g. theme and other UI files and the parent web itself) to get to the list or item you actually want them to have access to. </p>
<p>As long as the group only has access on a single list, you should have to worry about them having access to anything else.</p>
| 7,948
|
<p>I've got a problem similar to,but subtly different from, that described <a href="https://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies">here</a> (Loading assemblies and their dependencies).</p>
<p>I have a C++ DLL for 3D rendering that is what we sell to customers. For .NET users we will have a CLR wrapper around it. The C++ DLL can be built in both 32 and 64bit versions, but I think this means we need to have two CLR wrappers since the CLR binds to a specific DLL? </p>
<p>Say now our customer has a .NET app that can be either 32 or 64bit, and that it being a pure .NET app it leaves the CLR to work it out from a single set of assemblies. The question is how can the app code dynamically choose between our 32 and 64bit CLR/DLL combinations at run-time?</p>
<p>Even more specifically, is the suggested answer to the aforementioned question applicable here too (i.e. create a ResolveEvent handler)?</p>
|
<p>I finally have an answer for this that appears to work.</p>
<p>Compile both 32 & 64 bit versions - both managed & unmanaged - into separate folders. Then have the .NET app choose at run time which directory to load the assemblies from.</p>
<p>The problem with using the ResolveEvent is that it only gets called if assemblies aren't found, so it is all to easy to accidentally end up with 32 bit versions. Instead use a second AppDomain object where we can change the ApplicationBase property to point at the right folder. So you end up with code like:</p>
<pre><code>static void Main(String[] argv)
{
// Create a new AppDomain, but with the base directory set to either the 32-bit or 64-bit
// sub-directories.
AppDomainSetup objADS = new AppDomainSetup();
System.String assemblyDir = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
switch (System.IntPtr.Size)
{
case (4): assemblyDir += "\\win32\\";
break;
case (8): assemblyDir += "\\x64\\";
break;
}
objADS.ApplicationBase = assemblyDir;
// We set the PrivateBinPath to the application directory, so that we can still
// load the platform neutral assemblies from the app directory.
objADS.PrivateBinPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
AppDomain objAD = AppDomain.CreateDomain("", null, objADS);
if (argv.Length > 0)
objAD.ExecuteAssembly(argv[0]);
else
objAD.ExecuteAssembly("MyApplication.exe");
AppDomain.Unload(objAD);
}
</code></pre>
<p>You end up with 2 exes - your normal app and a second switching app that chooses which bits to load.
Note - I can't take credit for the details of this myself. One of my colleagues sussed that out given my initial pointer. If and when he signs up to StackOverflow I'll assign the answer to him</p>
|
<p>I encountered a similar scenario a while back. A toolkit I was using did not behave well in a 64-bit environment and I wasn't able to find a way to dynamically force the assemblies to bind as 32 bit.</p>
<p>It is possible to force your assemblies to work in 32 bit mode, but this requires patching the CLR header, (there is a tool that does that in the Framework) and if your assemblies are strongly-named, this does not work out.</p>
<p>I'm afraid you'll need to build and publish two sets of binaries for 32 and 64 bit platforms.</p>
| 4,232
|
<p>I notice that if I print from Cura without preheating the printer, it will first raise the bed temperature and then raise the extruder temperature. The G-code it generates is:</p>
<pre><code>M140 S55 ; set bed temperature to 55 C
M105 ; report temperatures
M190 S55 ; wait for bed temperature to reach 55 C
M104 S210 ; set hot end temperature to 210 C
M105 ; report temperatures
M109 S210 ; wait for hot end temperature to reach 210 C
</code></pre>
<p>The "Preheat" feature of Cura presumably send the "set temperature" commands without the corresponding "wait" command.</p>
<p>Wouldn't it be more efficient to do something like this:</p>
<pre><code>M104 S210 ; set hot end temperature to 210 C
M140 S55 ; set bed temperature to 55 C
M105 ; report temperatures
M109 S210 ; wait for hot end temperature to reach 210 C
M105 ; report temperatures
M190 S55 ; wait for bed temperature to reach 55 C
</code></pre>
<p>Then the bed and extruder heat up simultaneously, and we wait for the higher temperature one <em>first</em> assuming that the other will reach its target temperature in the meanwhile.</p>
<p>If this is sound, is there a way to set this in Cura, or would I need to submit a patch?</p>
|
<p>This can be achieved with start G-code adaptations, this requires no software changes. Cura, and most slicers, have the ability to use placeholders (basically variables or maybe better: constants). These placeholders are substituted with the correct value upon slicing.</p>
<p>To sequentially heat the bed and hotend you would need to add the following into your start G-code:</p>
<pre>
M117 Heating bed 1st...
M190 S{material_bed_temperature_layer_0}
M117 Heating core 2nd...
M109 S{material_print_temperature_layer_0}
</pre>
<p>For simultaneous heating you need to add:</p>
<pre>
M140 S{material_bed_temperature_layer_0} ; set bed temperature to e.g. 55 °C and continue
M104 S{material_print_temperature_layer_0} ; set hot end temperature to e.g. 210 °C and continue
M190 S{material_bed_temperature_layer_0} ; wait for bed temperature to reach e.g. 55 °C
M109 S{material_print_temperature_layer_0} ; wait for hot end temperature to reach e.g. 210 °C
</pre>
<p>Note that Cura is very limited in using placeholders. E.g. Slic3r allows for arithmetic using the placeholders. The following example shows heating the bed first to the bed first layer temperature minus 10 degrees Celsius; then the hotend starts heating and heatbed starts further heating up to the final temperature. For my machine this results in the bed and hotend being at final temperature at the same time; so no time is wasted and printing can start.</p>
<pre>
M117 Heating bed...
M190 S{[first_layer_bed_temperature]-10}
M140 S[first_layer_bed_temperature]
M117 Heating core...
M109 S[first_layer_temperature_0]
M190 S[first_layer_bed_temperature]
</pre>
|
<p>It is a little annoying, what <code>Cura</code> is doing for me is forcing to wait. On start G-code I have:</p>
<pre><code>; Ender 3 Custom Start G-code
G92 E0 ; Reset Extruder
;*** Start Dual Nozzle/Bed Preheating ***
M140 S60 ; start preheating the bed
M104 S200 T0 ; start preheating hotend
G28 ; home
M190 S60 ; heat to Cura Bed setting
M109 S200
;*** End Preheating ***M420 S1; Load Mesh Bed Level
</code></pre>
<p>But on the generated G-code I have:</p>
<pre><code>;Generated with Cura_SteamEngine 4.9.0
M140 S60
M105
M190 S60
M104 S200
M105
M109 S200
M82 ;absolute extrusion mode
; Ender 3 Custom Start G-code
G92 E0 ; Reset Extruder
;*** Start Dual Nozzle/Bed Preheating ***
M140 S60 ; start preheating the bed
M104 S200 T0 ; start preheating hotend
G28 ; home
M190 S60 ; heat to Cura Bed setting
M109 S200
</code></pre>
<p>In the end I'm changing it directly on G-code what is a pain</p>
| 1,610
|
<p>I've been using make and makefiles for many many years, and although the concept
is sound, the implementation has something to be desired.</p>
<p>Has anyone found any good alternatives to make that don't overcomplicate
the problem?</p>
|
<p>check out <a href="http://www.scons.org/" rel="noreferrer">SCons</a>. For example Doom 3 and Blender make uses of it.</p>
|
<p>I'm not sure if you are asking the correct question here.</p>
<p>Are you after a simplified make? In which case, you need to get someone who is very familiar with make to create a series of (M|m)akefiles that will simplify your problem.</p>
<p>Or are you wanting to look at the underlying technology? Are we wanting to enforce a design-by-contract type architecture which is built in to, and enforced in, the code design? Or possibly, the language itself, e.g. Ada and its concept of specs (interfaces) and bodies (implementations)?</p>
<p>Which direction you are after will definitely affect the potential results of such a question?</p>
<p>Basically, new ways of building systems from only those components that have really changed versus adoption of new technologies that have such mechanisms built in by design.</p>
<p>Sorry it's not a direct answer. Just wanted to try and get you to evaluate which path you wanted to head down.</p>
<p>cheers,</p>
<p>Rob</p>
| 9,235
|
<p>Is Boost the only way for VS2005 users experience TR2? Also is there a idiot proof way of downloading only the TR2 related packages?</p>
<p>I was looking at the boost installer provided by BoostPro Consulting. If I select the options for all the threading options with all the packages for MSVC8 it requires 1.1GB. While I am not short of space, it seems ridiculous that a <strong>library</strong> needs over a gigabyte of space and it takes BPC a long time to catch up with the current release.</p>
<p>What packages do I need? I'm really only interested in those that comprise std::tr2 and can find that out by comparing those on offer to those in from the TR2 report and selecting those from the list but even then it isn't clear what is needed and the fact that it is a version behind annoys me. </p>
<p>I know from previous encounters with Boost (1.33.1) that self compiling is a miserable experience: A lot of time wasted to get it started and then a hoard of errors passes across your screen faster than you can read, so what you are left with is an uneasy feeling that something is broken but you don't quite know what. </p>
<p>I've never had these problems with any Apache library but that is another rant...</p>
|
<p>I believe you're actually referring to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1745.pdf" rel="nofollow noreferrer">TR1</a>, rather than TR2. The call for proposals for TR2 is open, but don't expect to see much movement until the new C++ standard is out. Also, although boost is a provider of an implementation of TR1, dinkumware and the GNU FSF are other providers - on VC2005 boost is probably the easiest way to access this functionality. </p>
<p>The libraries from boost which are likely to be of most importance are</p>
<ul>
<li>reference</li>
<li>smart pointer </li>
<li>bind </li>
<li>type traits</li>
<li>array</li>
<li>regular expressions</li>
</ul>
<p>The documentation for building boost has been gradually improving for the last few releases, the current <a href="http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html" rel="nofollow noreferrer">getting started guide</a> is quite detailed. smart pointer and bind, should work from header files, and IMO, these are the most useful elements of TR1.</p>
|
<p>The libraries I am most interested in from TR1/TR2 are <a href="http://www.open-std.org/JTC1/sc22/wg21/docs/papers/2007/n2320.html" rel="nofollow noreferrer">threads</a> and the related <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html" rel="nofollow noreferrer">atomics</a>.</p>
| 3,782
|
<p>Currently, I am writing up a bit of a product-based CMS as my first project.</p>
<p>Here is my question. How can I add additional data (products) to my Product model?</p>
<p>I have added '/admin/products/add' to my urls.py, but I don't really know where to go from there. How would i build both my view and my template? Please keep in mind that I don't really know all that much Python, and i am very new to Django</p>
<p>How can I do this all without using this existing django admin interface.</p>
|
<p>You will want to wire your URL to the Django <a href="https://docs.djangoproject.com/en/1.4/ref/generic-views/#django-views-generic-create-update-create-object" rel="nofollow noreferrer">create_object generic view</a>, and pass it either "model" (the model you want to create) or "form_class" (a customized <a href="https://docs.djangoproject.com/en/1.1/topics/forms/modelforms/#topics-forms-modelforms" rel="nofollow noreferrer">ModelForm</a> class). There are a number of <a href="https://docs.djangoproject.com/en/1.4/ref/generic-views/#django-views-generic-create-update-create-object" rel="nofollow noreferrer">other arguments</a> you can also pass to override default behaviors.</p>
<p>Sample URLconf for the simplest case:</p>
<pre><code>from django.conf.urls.defaults import *
from django.views.generic.create_update import create_object
from my_products_app.models import Product
urlpatterns = patterns('',
url(r'^admin/products/add/$', create_object, {'model': Product}))
</code></pre>
<p>Your template will get the context variable "form", which you just need to wrap in a <form> tag and add a submit button. The simplest working template (by default should go in "my_products_app/product_form.html"):</p>
<pre><code><form action="." method="POST">
{{ form }}
<input type="submit" name="submit" value="add">
</form>
</code></pre>
<p>Note that your Product model must have a get_absolute_url method, or else you must pass in the post_save_redirect parameter to the view. Otherwise it won't know where to redirect to after save.</p>
|
<p>Follow the Django tutorial for setting up the "admin" part of an application. This will allow you to modify your database.</p>
<p><a href="https://docs.djangoproject.com/en/dev/intro/tutorial02/" rel="nofollow noreferrer">Django Admin Setup</a></p>
<p>Alternatively, you can just connect directly to the database using the standard tools for whatever database type you are using.</p>
| 5,740
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.