instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>Jeff has previously blogged about <a href="https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/">using the cache</a> to perform "out of band" processing on his websites, however I was wondering what other techniques people are using to process these sorts of tasks?</p>
|
<p>Years ago, I saw Rob Howard describe a way to use an HttpModule to process tasks in the background. It doesn't seem as slick as using the Cache, but it might be better for certain circumstances.</p>
<p><strong><a href="http://blogs.telerik.com/KevinBabcock/Posts/08-07-24/Using_an_HttpModule_to_Run_a_Background_Service.aspx" rel="noreferrer">This blog post</a></strong> has the details, and there are many others that capture the same information if you look around.</p>
|
<p>Scheduled tasks, or cron jobs.</p>
| 6,441
|
<p>I've grokked the code for all the aforementioned apps and I still can't find a straightforward way to create a static directory structure from a single command.</p>
|
<p>Check out <a href="http://rubigen.rubyforge.org" rel="noreferrer">rubigen</a>. You can also view a <a href="http://rubyconf2007.confreaks.com/d3t1p1_rubigen.html" rel="noreferrer">presentation</a> by dr nic.</p>
|
<p>So what you want is to able to issue a command that will generate an entire directory tree?</p>
<pre><code>cp -r <template> <destination>
</code></pre>
<p>Or am I misunderstanding? If you want to generate a consistent directory structure, your best bet is to simply copy it from a template. Fast, easy, done.</p>
| 3,178
|
<p>I joined a new company about a month ago. The company is rather small in size and has pretty strong "start-up" feel to it. I'm working as a Java developer on a team of 3 others. The company primarily sells a service to for businesses/business-type people to use in communicating with each other.</p>
<p>One of the main things I have been, and will be working on, is the main website for the company - from which the service is sold, existing users login to check their service and pay their bills, new users can sign up for a trial, etc. Currently this is a JSP application deployed on Tomcat, with access to a database done thru a persistence layer written by the company itself.</p>
<p>A repeated and growing frustration I am having here (and I'm pretty happy with the job overall, so this isn't an "oh no I don't like my job"-type post) is the lack of any larger design or architecture for this web application. The app is made up of several dozen JSP pages, with almost no logic existing in Servlets or Beans or any other sort of framework. Many of the JSP pages are thousands of lines of code, they <code>jsp:include</code> other JSP pages, business logic is mixed in with the HTML, frequently used snippets of code (such as obtaining a web service connection) is cut and paste rather than reused, etc. In other words, the application is a mess.</p>
<p>There have been some rumblings within the company of trying to re-architect this site so that it fits MVC better; I think that the developers and higher-ups are beginning to realize that this current pattern of spaghetti code isn't sustainable or very easily scalable to add more features for the users. The higher-ups and developers are wary of completely re-writing the thing (with good reason, since this would mean several weeks or months of work re-writing existing functionality), but we've had some discussions of (slowly) re-writing certain areas of the site into a new framework.</p>
<p>What are some of the best strategies to enable moving the application and codebase into this direction? How can I as a developer really help move this along, and quickly, without seeming like the jerk-y new guy who comes into a job and tells everyone that what they've written is crap? Are there any proven strategies or experiences that you've used in your own job experience when you've encountered this sort of thing?</p>
|
<p>Your best bet is probably to refactor it slowly as you go along. Few us of have the resources that would be required to completely start from scratch with something that has so many business rules buried in it. Management really hates it when you spend months on developing an app that has more bugs than the one you replaced.</p>
<p>If you have the opportunity to build any separate apps from scratch, use all of the best practices there and use it to demonstrate how effective they are. When you can, incorporate those ideas gradually into the old application.</p>
|
<p>The best way is to print out the code, crumple it up, and throw it out. Don't even recycle the paper.</p>
<p>You've got an application that is written in 1,000+ line long JSPs. It probably has a god-awful Domain Model (if it even has one at all) and doesn't just MIX presentation with business logic, it BLENDS it and sits there and keeps stirring for hours. There is no way to take out the code that is crappy and move into an MVC Controller class and still be doing the right thing, you'll just end up with a MVC app with an anemic domain model or one that has stuff like Database calls in Controller code, you're still failing. </p>
<p>You could try a new app that does the right thing and then have the two apps talk to each other, but that's new complexity in itself. Also you're likely going to be doing the same amount of work that you were going to do if you just started from scratch, but you might have an easier time trying to convince your bosses that this is a better approach. </p>
| 6,145
|
<p>I'm looking for a dead simple mailing list (unix friendly). Robustness, fine-grained configurability, "enterprise-readiness" (whatever that means) are not requirements. I just need to set up a tiny mailing list for a few friends. Rather than hack something up myself, I was wondering if anybody knows of anything already out there with a similar goal? </p>
<p>I should note right now that I <strong>don't</strong> want an externally hosted mailing list -- it needs to be software I can install and run on my server. I know of many places I can host a mailing list at (Google/Yahoo groups), but it would be nice to keep the data local.</p>
|
<p>Mailman is one of the simplest mailing list packages I've come across, so if Mailman is more than you want to deal with I'd suggest just adding an entry into <code>/etc/aliases</code> for your mailing list.</p>
<p>Of course you have to manage it by hand, but you said it's only for a few friends so that may not be a problem. Just create an entry in <code>/etc/aliases</code> such as:</p>
<pre><code>mylist: me@somedomain.com, myfriend@somedomain.com, \
myotherfriend@differentdomain.com
</code></pre>
<p>and then run <code>newaliases</code>. It doesn't get much simpler than that. If you want an archive you can create a dummy account on your mail server and add them to the list.</p>
<p>It's not as user friendly as Mailman but it's simple and you can be up and running in 5 minutes.</p>
|
<p>If you want something easy to setup, with a user interface on top then I would recommend to check out <a href="https://wpmailster.com/" rel="nofollow noreferrer">WP Mailster</a> (WordPress plugin) or <a href="https://www.brandt-oss.com/mailster" rel="nofollow noreferrer">Mailster</a> (Joomla plugin).</p>
<p>No matter which of the two CMS you prefer, you will only need 5 minutes to have a "naked" WordPress or Joomla and the plugin installed.</p>
<p>It really works well and is easy to use. I have used Mailster for years and recently, with my site's move to WordPress have switched wo WP Mailster.</p>
| 9,219
|
<p>I've frequently encountered sites that put all of their JavaScript inside a <code>namespace</code> structure along the lines of:</p>
<pre><code>namespaces = { com : { example: { example.com's data} }
</code></pre>
<p>However, setting this up safely with respect to other namespaced frameworks seems to require a relatively hefty amount of code (defined as > 2 lines). I was wondering whether anyone knows of a concise way to do this? Furthermore, whether there's a relatively standard/consistent way to structure it? For example, is the <code>com</code> namespace directly attached to the global object, or is it attached through a namespace object?</p>
<p>[Edit: whoops, obviously <code>{com = { ... } }</code> wouldn't accomplish anything close to what I intended, thanks to Shog9 for pointing that out.] </p>
|
<p>Javascript doesn't have stand-alone namespaces. It has functions, which can provide scope for resolving names, and objects, which can contribute to the named data accessible in a given scope. </p>
<p>Here's your example, corrected:</p>
<pre><code>var namespaces = { com: { example: { /* example.com's data */ } } }
</code></pre>
<p>This is a variable <code>namespaces</code> being assigned an object literal. The object contains one property: <code>com</code>, an object with one property: <code>example</code>, an object which presumably would contain something interesting.</p>
<p>So, you can type something like <strong>namespaces.com.example.<em>somePropertyOrFunctionOnExample</em></strong> and it'll all work. Of course, it's also ridiculous. You don't have a hierarchical namespace, you have an object containing an object containing an object with the stuff you actually care about.</p>
<pre><code>var com_example_data = { /* example.com's data */ };
</code></pre>
<p>That works just as well, without the pointless hierarchy. </p>
<p><strong>Now</strong>, if you actually <em>want</em> to build a hierarchy, you can try something like this:</p>
<pre><code>com_example = com_example || {};
com_example.flags = com_example.flags || { active: false, restricted: true};
com_example.ops = com_example.ops || (function()
{
var launchCodes = "38925491753824"; // hidden / private
return {
activate: function() { /* ... */ },
destroyTheWorld: function() { /* ... */ }
};
})();
</code></pre>
<p>...which is, IMHO, reasonably concise.</p>
|
<p>Use an object literal and either the <code>this</code> object or the explicit name to do namespacing based on the sibling properties of the local variable which contains the function. For example:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var foo = { bar: function(){return this.name; }, name: "rodimus" }
var baz = { bar: function(){return this.name; }, name: "optimus" }
console.log(foo.bar());
console.log(baz.bar());</code></pre>
</div>
</div>
</p>
<p>Or without the explicit <code>name</code> property:</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-js lang-js prettyprint-override"><code>var foo = { bar: function rodimus(){return this; } }
var baz = { bar: function optimus(){return this; } }
console.log(foo.bar.name);
console.log(baz.bar.name);</code></pre>
</div>
</div>
</p>
<p>Or without using <code>this</code>:</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-js lang-js prettyprint-override"><code>var foo = { bar: function rodimus(){return rodimus; } }
var baz = { bar: function optimus(){return optimus; } }
console.log(foo.bar.name);
console.log(baz.bar.name);</code></pre>
</div>
</div>
</p>
<p>Use the <code>RegExp</code> or <code>Object</code> constructor functions to add name properties to counter variables and other common names, then use a <code>hasOwnProperty</code> test to do checking:</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-js lang-js prettyprint-override"><code> var foo = RegExp(/bar/);
/* Add property */
foo.name = "alpha";
document.body.innerHTML = String("<pre>" + ["name", "value", "namespace"] + "</pre>").replace(/,/g, "&#09;");
/* Check type */
if (foo.hasOwnProperty("name"))
{
document.body.innerHTML += String("<pre>" + ["foo", String(foo.exec(foo)), foo.name] + "</pre>").replace(/,/g, "&#09;");
}
/* Fallback to atomic value */
else
{
foo = "baz";
}
var counter = Object(1);
/* Add property */
counter.name = "beta";
if (counter.hasOwnProperty("name"))
{
document.body.innerHTML += String("<pre>" + ["counter", Number(counter), counter.name] + "</pre>").replace(/,/g, "&#09;");
}
else
{
/* Fallback to atomic value */
counter = 0;
}</code></pre>
</div>
</div>
</p>
<p>The DOM uses the following convention to namespace HTML and SVG Element interface definitions:</p>
<ul>
<li>HTMLTitleElement</li>
<li>SVGTitleElement</li>
<li>SVGScriptElement</li>
<li>HTMLScriptElement</li>
</ul>
<p>JavaScript core uses prototypes to namespace the <code>toString</code> method as a simple form of polymorphism.</p>
<p><strong>References</strong></p>
<ul>
<li><a href="https://stackoverflow.com/questions/17216847/1113772">Does javascript autobox?</a></li>
<li><a href="https://stackoverflow.com/questions/17216496/1113772">Getting sibling value of key in a JavaScript object literal</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#As_an_object_method" rel="nofollow noreferrer">MDN: JavaScript Operators - this as an object method</a></li>
<li><a href="https://www.lua.org/notes/ltn007.html" rel="nofollow noreferrer">Lua: technical note 7 - Modules and Packages</a></li>
<li><a href="https://github.com/mozilla/gecko-dev/blob/master/dom/webidl/HTMLTitleElement.webidl" rel="nofollow noreferrer">HTMLTitleElement.webidl</a></li>
<li><a href="https://github.com/mozilla/gecko-dev/blob/master/dom/webidl/SVGTitleElement.webidl" rel="nofollow noreferrer">SVGTitleElement.webidl</a></li>
<li><a href="https://github.com/mozilla/gecko-dev/blob/master/dom/webidl/SVGScriptElement.webidl" rel="nofollow noreferrer">SVGScriptElement.webidl</a></li>
<li><a href="https://github.com/mozilla/gecko-dev/blob/master/dom/webidl/HTMLScriptElement.webidl" rel="nofollow noreferrer">HTMLScriptElement.webidl</a></li>
<li><a href="http://www.2ality.com/2015/09/function-names-es6.html" rel="nofollow noreferrer">The names of functions in ES6</a></li>
<li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances-name" rel="nofollow noreferrer">ECMAScript 2015 Language Specification - 19.2.4.2 Function Instances: name | ECMA-262 6th Edition</a></li>
</ul>
| 3,406
|
<p>I've heard people referring to this table and was not sure what it was about.</p>
|
<p>It's a sort of dummy table with a single record used for selecting when you're not actually interested in the data, but instead want the results of some system function in a select statement:</p>
<p>e.g. <code>select sysdate from dual;</code></p>
<p>See <a href="http://www.adp-gmbh.ch/ora/misc/dual.html" rel="nofollow noreferrer">http://www.adp-gmbh.ch/ora/misc/dual.html</a></p>
<p>As of 23c, Oracle supports <code>select sysdate /* or other value */</code>, without <code>from dual</code>, as has been supported in MySQL for some time already.</p>
|
<p>It's a object to put in the from that return 1 empty row. For example:
select 1 from dual;
returns 1</p>
<p>select 21+44 from dual;
returns 65</p>
<p>select [sequence].nextval from dual;
returns the next value from the sequence.</p>
| 9,947
|
<p>I had a discussion with some colleagues mentioning that there are not too many projects that we do which make use of WPF for creating UI for a windows application (we almost always use Windows Forms instead).</p>
<ul>
<li>Are your experiences the same - i.e. there is not too much adoption of this technology?</li>
<li>Why do you think that is? And will we have a time when we see much more of WPF?</li>
</ul>
|
<p>Have a look at this <a href="http://www.componentfactory.com/blog/?p=322" rel="nofollow noreferrer">survey</a> it was done by a Windows Forms Contol Vendor in Australia.
Personally I have worked on two commercial projects in the last year that were using WPF to varying degrees.</p>
<p>The adoption of WPF is on the rise. Microsoft I believe is putting all their eggs into the WPF basket.</p>
|
<p>Though WPF was introduced few years ago it was too raw to use it in the real world apps. Major problem that stops WPF from wide adoption is a lack of RAD tools and out-of-box components. Currently we have Blend, more or less working Cider, but usable versions of these tools came not so long ago. Another reason is a completely different architecture which leads to longer development time as compared with WinForms due to prolonged learning\adoption period for developers.
I think we will see rising of WPF in the next few years.</p>
| 5,879
|
<p>Sorry for the Windows developers out there, this solution is for Macs only.</p>
<p>This set of applications accounts for: Usability Testing, Screen Capture (Video and Still), Version Control, Task Lists, Bug Tracking, a Developer IDE, a Web Server, A Blog, Shared Doc Editing on the Web, Team and individual Chat, Email, Databases and Continuous Integration. This does assume your team members provide their own machines, and one person has a spare old computer to be the Source Repository and Web Server. All for under $200 bucks.</p>
<p><strong>Usability</strong></p>
<p><a href="http://silverbackapp.com/" rel="nofollow noreferrer">Silverback</a> </p>
<p>Licenses = 3 x $49.95</p>
<p>"Spontaneous, unobtrusive usability testing software for designers and developers."</p>
<p><strong>Source Control Server and Clients (multiple options)</strong></p>
<p><a href="http://subversion.tigris.org/" rel="nofollow noreferrer">Subversion</a> = Free</p>
<p>Subversion is an open source version control system.</p>
<p><a href="http://versionsapp.com/" rel="nofollow noreferrer">Versions</a> (Currently in Beta) = Free</p>
<p>Versions provides a pleasant work with Subversion on your Mac.</p>
<p><a href="http://lucidmac.com/products/diffly" rel="nofollow noreferrer">Diffly</a> = Free</p>
<p>"Diffly is a tool for exploring Subversion working copies. It shows all files with changes and, clicking on a file, shows a highlighted view of the changes for that file. When you are ready to commit Diffly makes it easy to select the files you want to check-in and assemble a useful commit message."</p>
<p><strong>Bug/Feature/Defect Tracking (multiple options)</strong></p>
<p><a href="http://www.bugzilla.org/" rel="nofollow noreferrer">Bugzilla</a> = Free</p>
<p>Bugzilla is a "Defect Tracking System" or "Bug-Tracking System". Defect Tracking Systems allow individual or groups of developers to keep track of outstanding bugs in their product effectively. Most commercial defect-tracking software vendors charge enormous licensing fees.</p>
<p><a href="http://trac.edgewall.org/" rel="nofollow noreferrer">Trac</a> = Free</p>
<p>Trac is an enhanced wiki and issue tracking system for software development projects.</p>
<p><strong>Database Server & Clients</strong></p>
<p><a href="http://dev.mysql.com/downloads/mysql/?rz=gdl#downloads" rel="nofollow noreferrer">MySQL</a> = Free</p>
<p><a href="http://cocoamysql.sourceforge.net/" rel="nofollow noreferrer">CocoaMySQL</a> = Free</p>
<p><strong>Web Server</strong></p>
<p><a href="http://apache.org/" rel="nofollow noreferrer">Apache</a> = Free</p>
<p><strong>Development and Build Tools</strong></p>
<p><a href="http://www.apple.com/macosx/features/300.html#xcode3" rel="nofollow noreferrer">XCode</a> = Free</p>
<p><a href="http://cruisecontrol.sourceforge.net/" rel="nofollow noreferrer">CruiseControl</a> = Free</p>
<p>CruiseControl is a framework for a continuous build process. It includes, but is not limited to, plugins for email notification, Ant, and various source control tools. A web interface is provided to view the details of the current and previous builds.</p>
<p><strong>Collaboration Tools</strong></p>
<p><a href="http://www.writeboard.com/" rel="nofollow noreferrer">Writeboard</a> = Free</p>
<p><a href="http://www.tadalist.com/" rel="nofollow noreferrer">Ta-da List</a> = Free</p>
<p><a href="https://signup.37signals.com/campfire/free/signup/new" rel="nofollow noreferrer">Campfire Chat</a> for 4 users = Free</p>
<p><a href="http://wordpress.org/download/" rel="nofollow noreferrer">WordPress</a> = Free</p>
<p>"WordPress is a state-of-the-art publishing platform with a focus on aesthetics, web standards, and usability. WordPress is both free and priceless at the same time."</p>
<p><a href="http://www.gmail.com/" rel="nofollow noreferrer">Gmail</a> = Free</p>
<p>"Gmail is a new kind of webmail, built on the idea that email can be more intuitive, efficient, and useful."</p>
<p><strong>Screen Capture (Video / Still)</strong></p>
<p><a href="http://www.jingproject.com/" rel="nofollow noreferrer">Jing</a> = Free</p>
<p>"The concept of Jing is the always-ready program that instantly captures and shares images and video…from your computer to anywhere."</p>
<hr>
<p><strong>Lots of great responses:</strong></p>
<p>TeamCity [Yo|||]</p>
<p>Skype [Eric DeLabar]</p>
<p>FogBugz [chakrit]</p>
<p>IChatAV and Screen Sharing (built-in to OS) [amrox]</p>
<p>Google Docs [amrox]</p>
<hr>
|
<p>You've got most of it covered.</p>
<p>I always add space, time and money for 2 more things you might consider strange.</p>
<ol>
<li><p>A machine set up just like the average user. No development or debugging tools installed. Make it look like someone just bought it from the Apple store. I do image switching but I've know people who swear by switching to an external boot drive.</p></li>
<li><p>Also include a 'free' lunch for a virgin. This is someone to come in and test your program that is NOT a developer and doesn't know squat about your software. You might have to do this more than once but don't ever use the same person again.</p></li>
</ol>
<p>As an added note, make very sure the 'free' applications and web sites you use are truly free, not just free for personal use!</p>
<p>Good luck on your project!</p>
|
<p>Change CruiseControl for JetBrains' TeamCity. It's free for up to 20 users, and is more powerful and usable than CruiseControl.</p>
<p>It's easy to set up, and has some amazing features. Such as automatically sending off a build to be performed on any spare computer you may have sitting around in the office.</p>
| 9,805
|
<p>When attempting to open a project from source control on a newly formatted pc, I receive an "unable to get the project file from the web server" after getting the sln file from VSS. If I attempt to open the sln file from explorer, I also receive the same error.</p>
<p>Any pointers or ideas?</p>
<p>Thanks!</p>
|
<p>This question is very old so you have probably solved the issue, but just in case: Does the project file use IIS? If so then it is probably trying to read the project file from IIS and the virtual directory does not exist on the newly formatted computer. Also, there should be more detail about the message in the Output window when you open the solution which should help you find the cause. With VS2003, you also need to add your user account to the "Debugger Users" and "VS Developers" and possibly the account that is running the AppPool (possibly Network Server, ASPNET, or IUSER_xxx). This may depend on the type of authentication you are using as well. Occasionally I had to add those group permissions the the virtual directory location as well. It's been a while since I have used VS2003 with web projects though.</p>
|
<p>Is there anything odd in your sln file? Have you opened it with a text editor to see if it is linking to a remote resource?</p>
| 8,925
|
<p>How can I generate a (pseudo)random alpha-numeric string, something like: 'd79jd8c' in PHP?</p>
|
<p>First make a string with all your possible characters:</p>
<pre><code> $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
</code></pre>
<p>You could also use <a href="http://php.net/range" rel="noreferrer">range()</a> to do this more quickly.</p>
<p>Then, in a loop, choose a random number and use it as the index to the <code>$characters</code> string to get a random character, and append it to your string:</p>
<pre><code> $string = '';
$max = strlen($characters) - 1;
for ($i = 0; $i < $random_string_length; $i++) {
$string .= $characters[mt_rand(0, $max)];
}
</code></pre>
<p><code>$random_string_length</code> is the length of the random string.</p>
|
<p>Jeremy's answer is great. If, like me, you're unsure of how to implement range(), you can see my version using range().</p>
<pre><code><?php
$character_array = array_merge(range('a', 'z'), range(0, 9));
$string = "";
for($i = 0; $i < 6; $i++) {
$string .= $character_array[rand(0, (count($character_array) - 1))];
}
echo $string;
?>
</code></pre>
<p>This does the exact same thing as Jeremy's but uses merged arrays where he uses a string, and uses count() where he uses strlen().</p>
| 7,049
|
<p>This is the text from MSDN comment: "According to the book ATL Internals (2ed) the use of attributes is deprecated and should not be used in new ATL projects."</p>
<p>But WHY?!! </p>
|
<p>In ATL these attributes were a compiler trick. They were not a core part of the platform like attributes in C#. They were also more confusing to debug than macros's and the method of dumping generated attribute code was a hassle.</p>
<p>I suspect another issue is likely to have been C++ compiler compatibility and standards-adherence. Attributes didn't make for more beautiful C++ code, and perhaps this syntax may be used in a future version of a real C++ standard.</p>
|
<p>Appendix D of the book goes into this.</p>
<p>Attributed ATL requires compiler extensions, and the problems encountered include</p>
<ul>
<li>debugging either code generated by the attribute or the interaction between the attribute and your code</li>
<li>no control over the code generated</li>
<li>bugs, especially around connection points</li>
</ul>
| 7,303
|
<p>Older K&R (2nd ed.) and other C-language texts I have read that discuss the implementation of a dynamic memory allocator in the style of <code>malloc()</code> and <code>free()</code> usually also mention, in passing, something about data type alignment restrictions. Apparently certain computer hardware architectures (CPU, registers, and memory access) restrict how you can store and address certain value types. For example, there may be a requirement that a 4 byte (<code>long</code>) integer must be stored beginning at addresses that are multiples of four.</p>
<p>What restrictions, if any, do major platforms (Intel & AMD, SPARC, Alpha) impose for memory allocation and memory access, or can I safely ignore aligning memory allocations on specific address boundaries?</p>
|
<p>Sparc, MIPS, Alpha, and most other "classical RISC" architectures only allow aligned accesses to memory, even today. An unaligned access will cause an exception, but some operating systems will handle the exception by copying from the desired address in software using smaller loads and stores. The application code won't know there was a problem, except that the performance will be very bad.</p>
<p>MIPS has special instructions (lwl and lwr) which can be used to access 32 bit quantities from unaligned addresses. Whenever the compiler can tell that the address is likely unaligned it will use this two instruction sequence instead of a normal lw instruction.</p>
<p>x86 can handle unaligned memory accesses in hardware without an exception, but there is still a performance hit of up to 3X compared to aligned accesses.</p>
<p>Ulrich Drepper wrote a comprehensive paper on this and other memory-related topics, <A HREF="http://people.redhat.com/drepper/cpumemory.pdf" rel="noreferrer">What Every Programmer Should Know About Memory</A>. It is a very long writeup, but filled with chewy goodness.</p>
|
<p>You still need to be aware of alignment issues when laying out a class or struct in C(++). In these cases the compiler will do the right thing for you, but the overall size of the struct/class may be more wastefull than necessary</p>
<p>For example:</p>
<pre><code>struct
{
char A;
int B;
char C;
int D;
};
</code></pre>
<p>Would have a size of 4 * 4 = 16 bytes (assume Windows on x86) whereas</p>
<pre><code>struct
{
char A;
char C;
int B;
int D;
};
</code></pre>
<p>Would have a size of 4*3 = 12 bytes.</p>
<p>This is because the compiler enforces a 4 byte alignment for integers, but only 1 byte for chars.</p>
<p>In general pack member variables of the same size (type) together to minimize wasted space.</p>
| 5,705
|
<p>I am designing an part for my car. It is a panel for the rear door. I want to add it some cases for tools, but before going on, could you tell me:</p>
<p>It is a large flat panel, around 100cm by 35cm.</p>
<p><strong>Is it going to be suitable for printing in that ABS material? Is it too big?</strong></p>
<p><a href="https://i.stack.imgur.com/wqGB7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wqGB7.jpg" alt="enter image description here"></a></p>
|
<p>ABS would be fine, as a material, for the application.</p>
<p>The problem, given the scale, would be the printing device used. I would suggest that you have the piece cut to spec for you using a polycarbonate. </p>
<p>If you have access to a workshop you could do so yourself if you set up proper fencing using a larger sized bandsaw(with a very fine toothed blade), had rollers to help support the size of your piece(as it would not fit on the tool's platform) and likely need a second set of hands to help control the outfeed. You would also need to drill access for the cut out then cut the perimetre.</p>
<p>You could also consider printing(ABS) in smaller sections then fusing each section together edge to edge(solvent welding of ABS is very strong and permanent), if you were really dead set on using a typical 3D printer for this. It would, in theory, be possible, but it would be very tedious. The adhesives, and cleaner, would be available from any plumbing supply and/or (home depot, lowes, walmart et al.). If you go this route be sure to have ample ventilation and plan your work space well in advance. I would not recommend this option but it is "possible".</p>
<p>Given the scale of the piece though, and for sake of accuracy, going to a shop with CNC equipment and using polycarbonate would be your best bet.</p>
|
<p>It is a huge part that would not fit in most 3D printers, do you have access to a 3D printer this big? Even if it does fit it will take a long time to print.</p>
<p>Considering it's a simple flat shape, maybe laser cut / CNC acrylic or wood would be better, as you will have a stronger part, and most likely faster and cheaper.</p>
| 375
|
<p>I have a Windows application that uses a .NET PropertyGrid control. Is it possible to change the type of control that is used for the value field of a property?</p>
<p>I would like to be able to use a RichTextBox to allow better formatting of the input value.
Can this be done without creating a custom editor class?</p>
|
<p>To add your own custom editing when the user selects a property grid value you need to implement a class that derives from UITypeEditor. You then have the choice of showing just a small popup window below the property area or a full blown dialog box.</p>
<p>What is nice is that you can reuse the existing implementations. So to add the ability to multiline edit a string you just do this...</p>
<pre><code>[Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))]
public override string Text
{
get { return _string; }
set { _string = value; }
}
</code></pre>
<p>Another nice one they provide for you is the ability to edit an array of strings...</p>
<pre><code>[Editor("System.Windows.Forms.Design.StringArrayEditor,
System.Design, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a",
typeof(UITypeEditor))]
public string[] Lines
{
get { return _lines; }
set { _lines = value; }
}
</code></pre>
|
<p>I think what you are looking for is Custom Type Descriptors.
You could read up a bit and get started here: <a href="http://www.codeproject.com/KB/miscctrl/bending_property.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/miscctrl/bending_property.aspx</a></p>
<p>I am not sure you can do any control you want, but that article got me started on propertygrids.</p>
| 9,810
|
<p>I've been doing c# for a long time, and have never come across an easy way to just new up a hash.</p>
<p>I've recently become acquainted with the ruby syntax of hashes and wonder, does anyone know of a simple way to declare a hash as a literal, without doing all the add calls.</p>
<pre><code>{ "whatever" => {i => 1}; "and then something else" => {j => 2}};
</code></pre>
|
<p>If you're using C# 3.0 (.NET 3.5) then you can use collection initializers. They're not quite as terse as in Ruby but still an improvement.</p>
<p>This example is based on the <a href="http://msdn.microsoft.com/en-us/library/bb531208.aspx" rel="noreferrer">MSDN Example</a></p>
<pre><code>var students = new Dictionary<int, StudentName>()
{
{ 111, new StudentName {FirstName="Sachin", LastName="Karnik", ID=211}},
{ 112, new StudentName {FirstName="Dina", LastName="Salimzianova", ID=317, }},
{ 113, new StudentName {FirstName="Andy", LastName="Ruth", ID=198, }}
};
</code></pre>
|
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dictionary
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
Dictionary<object, object > d = p.Dic<object, object>("Age",32,"Height",177,"wrest",36);//(un)comment
//Dictionary<object, object> d = p.Dic<object, object>();//(un)comment
foreach(object o in d)
{
Console.WriteLine(" {0}",o.ToString());
}
Console.ReadLine();
}
public Dictionary<K, V> Dic<K, V>(params object[] data)
{
//if (data.Length == 0 || data == null || data.Length % 2 != 0) return null;
if (data.Length == 0 || data == null || data.Length % 2 != 0) return new Dictionary<K,V>(1){{ (K)new Object(), (V)new object()}};
Dictionary<K, V> dc = new Dictionary<K, V>(data.Length / 2);
int i = 0;
while (i < data.Length)
{
dc.Add((K)data[i], (V)data[++i]);
i++;
}
return dc;
}
}
}
</code></pre>
| 7,568
|
<p>Is there a good library to use for gathering user input in Linux from the mouse/keyboard/joystick that doesn't force you to create a visible window to do so? SDL lets you get user input in a reasonable way, but seems to force you to create a window, which is troublesome if you have abstracted control so the control machine doesn't have to be the same as the render machine. However, if the control and render machines are the same, this results in an ugly little SDL window on top of your display.</p>
<p><strong>Edit To Clarify</strong>:<br>
The renderer has an output window, in its normal use case, that window is full screen, except when they are both running on the same computer, just so it is possible to give the controller focus. There can actually be multiple renderers displaying a different view of the same data on different computers all controlled by the same controller, hence the total decoupling of the input from the output (Making taking advantage of the built in X11 client/server stuff for display less useable) Also, multiple controller applications for one renderer is also possible. Communication between the controllers and renderers is via sockets.</p>
|
<p>OK, if you're under X11 and you want to get the kbd, you need to do a grab.
If you're not, my only good answer is ncurses from a terminal.</p>
<p>Here's how you grab everything from the keyboard and release again:</p>
<pre>
/* Demo code, needs more error checking, compile
* with "gcc nameofthisfile.c -lX11".
/* weird formatting for markdown follows. argh! */
</pre>
<p><code>#include <X11/Xlib.h></code></p>
<pre>
int main(int argc, char **argv)
{
Display *dpy;
XEvent ev;
char *s;
unsigned int kc;
int quit = 0;
if (NULL==(dpy=XOpenDisplay(NULL))) {
perror(argv[0]);
exit(1);
}
/*
* You might want to warp the pointer to somewhere that you know
* is not associated with anything that will drain events.
* (void)XWarpPointer(dpy, None, DefaultRootWindow(dpy), 0, 0, 0, 0, x, y);
*/
XGrabKeyboard(dpy, DefaultRootWindow(dpy),
True, GrabModeAsync, GrabModeAsync, CurrentTime);
printf("KEYBOARD GRABBED! Hit 'q' to quit!\n"
"If this job is killed or you get stuck, use Ctrl-Alt-F1\n"
"to switch to a console (if possible) and run something that\n"
"ungrabs the keyboard.\n");
/* A very simple event loop: start at "man XEvent" for more info. */
/* Also see "apropos XGrab" for various ways to lock down access to
* certain types of info. coming out of or going into the server */
for (;!quit;) {
XNextEvent(dpy, &ev);
switch (ev.type) {
case KeyPress:
kc = ((XKeyPressedEvent*)&ev)->keycode;
s = XKeysymToString(XKeycodeToKeysym(dpy, kc, 0));
/* s is NULL or a static no-touchy return string. */
if (s) printf("KEY:%s\n", s);
if (!strcmp(s, "q")) quit=~0;
break;
case Expose:
/* Often, it's a good idea to drain residual exposes to
* avoid visiting Blinky's Fun Club. */
while (XCheckTypedEvent(dpy, Expose, &ev)) /* empty body */ ;
break;
case ButtonPress:
case ButtonRelease:
case KeyRelease:
case MotionNotify:
case ConfigureNotify:
default:
break;
}
}
XUngrabKeyboard(dpy, CurrentTime);
if (XCloseDisplay(dpy)) {
perror(argv[0]);
exit(1);
}
return 0;
}
</pre>
<p>Run this from a terminal and all kbd events should hit it. I'm testing it under Xorg
but it uses venerable, stable Xlib mechanisms.</p>
<p>Hope this helps.</p>
<p>BE CAREFUL with grabs under X. When you're new to them, sometimes it's a good
idea to start a time delay process that will ungrab the server when you're
testing code and let it sit and run and ungrab every couple of minutes.
It saves having to kill or switch away from the server to externally reset state.</p>
<p>From here, I'll leave it to you to decide how to multiplex renderes. Read
the XGrabKeyboard docs and XEvent docs to get started.
If you have small windows exposed at the screen corners, you could jam
the pointer into one corner to select a controller. XWarpPointer can
shove the pointer to one of them as well from code.</p>
<p>One more point: you can grab the pointer as well, and other resources. If you had one controller running on the box in front of which you sit, you could use keyboard and mouse input to switch it between open sockets with different renderers. You shouldn't need to resize the output window to less than full screen anymore with this approach, ever. With more work, you could actually drop alpha-blended overlays on top using the SHAPE and COMPOSITE extensions to get a nice overlay feature in response to user input (which might count as gilding the lily).</p>
|
<p>For the mouse you can use <a href="http://www.linuxjournal.com/article/4600" rel="nofollow noreferrer">GPM</a>.</p>
<p>I'm not sure off the top of my head for keyboard or joystick.</p>
<p>It probably wouldn't be too bad to read directly off there <code>/dev</code> files if need be. </p>
<p>Hope it helps</p>
| 7,290
|
<p>I have a process in erlang that is supposed to do something immediately after spawn, then send the result back to the parent when it is finished. How do I figure out the PID of the process that spawned it?</p>
|
<p>You should pass self() to the child as one of the arguments to the entry function.</p>
<pre><code>spawn_link(?MODULE, child, [self()]).
</code></pre>
|
<p>You can use the BIF register to give the spawning / parent process a name (an atom) then refer back to the registered name from other processes.</p>
<blockquote>
<p>FUNC() -></p>
<blockquote>
<p>%% Do something<br>
%% Then send message to parent<br>
parent ! MESSAGE.</p>
</blockquote>
<p>...</p>
<p>register(parent, self()),<br>
spawn(MODULE, FUNC, [ARGS]).</p>
</blockquote>
<p>See <a href="http://www.erlang.org/doc/getting_started/conc_prog.html#3.3" rel="nofollow noreferrer">Getting Started With Erlang §3.3</a> and <a href="http://www.erlang.org/doc/reference_manual/processes.html#10.3" rel="nofollow noreferrer">The Erlang Reference Manual §10.3</a>.</p>
| 2,629
|
<p>I have the following code:</p>
<pre><code>SELECT <column>, count(*)
FROM <table>
GROUP BY <column> HAVING COUNT(*) > 1;
</code></pre>
<p>Is there any difference to the results or performance if I replace the COUNT(*) with COUNT('x')?</p>
<p>(This question is related to a <a href="https://stackoverflow.com/questions/59294/in-sql-whats-the-difference-between-countcolumn-and-count">previous one</a>)</p>
|
<p>To say that <code>SELECT COUNT(*) vs COUNT(1)</code> results in your DBMS returning "columns" is pure bunk. That <em>may</em> have been the case long, long ago but any self-respecting query optimizer will choose some fast method to count the rows in the table - there is <strong>NO</strong> performance difference between <code>SELECT COUNT(*), COUNT(1), COUNT('this is a silly conversation')</code></p>
<p>Moreover, <code>SELECT(1) vs SELECT(*)</code> will NOT have any difference in INDEX usage -- most DBMS will actually optimize <code>SELECT( n ) into SELECT(*)</code> anyway. See the ASK TOM: Oracle has been optimizing <code>SELECT(n) into SELECT(*)</code> for the better part of a decade, if not longer:
<a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1156151916789" rel="noreferrer">http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1156151916789</a></p>
<blockquote>
<p>problem is in count(col) to count(<em>)
conversion
<strong></em> **03/23/00</strong> 05:46 pm *** one workaround is to set event 10122 to
turn off count(col) ->count(<em>)
optimization. Another work around is
to change the count(col) to count(</em>),
it means the same, when the col has a
NOT NULL constraint. The bug number is
1215372.</p>
</blockquote>
<p>One thing to note - if you are using COUNT(col) (don't!) and col is marked NULL, then it will actually have to count the number of occurrences in the table (either via index scan, histogram, etc. if they exist, or a full table scan otherwise). </p>
<p>Bottom line: if what you want is the count of rows in a table, use COUNT(*)</p>
|
<p>MySQL: According to the MySQL website, <code>COUNT(*)</code> is faster for single table queries when using MyISAM:</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_count" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_count</a></p>
<p>I'm guessing with a having clause with a count in it may change things.</p>
| 8,389
|
<p>How do I discard changes in my working copy that are not in the index?</p>
|
<p>For all <em>unstaged</em> files in current working directory use:</p>
<pre><code>git restore .
</code></pre>
<p>For a specific file use:</p>
<pre><code>git restore path/to/file/to/revert
</code></pre>
<p>That together with <code>git switch</code> replaces the overloaded <code>git checkout</code> (<a href="https://stackoverflow.com/questions/58003030/what-is-the-git-restore-command-and-what-is-the-difference-between-git-restor">see here</a>), and thus removes the argument disambiguation.</p>
<p>If a file has both staged and unstaged changes, only the unstaged changes shown in <code>git diff</code> are reverted. Changes shown in <code>git diff --staged</code> stay intact.</p>
<p><strong>Before Git 2.23</strong></p>
<p>For all unstaged files in current working directory:</p>
<pre><code>git checkout -- .
</code></pre>
<p>For a specific file:</p>
<pre><code>git checkout -- path/to/file/to/revert
</code></pre>
<p><code>--</code> here to remove ambiguity (this is known as <a href="https://git-scm.com/docs/git-checkout#_argument_disambiguation" rel="noreferrer">argument disambiguation</a>).</p>
|
<p>To delete unstaged changes I tried "git restore ." as I was told by Git but it just didn't work. A very good way is to use:</p>
<pre><code>git revert --hard
</code></pre>
<p>It works perfectly. Its Git Help explains perfectly the point:</p>
<blockquote>
<p><strong>--hard</strong>
Resets the index and working tree. <strong>Any changes to tracked files in the working tree since are discarded.</strong> Any untracked files or directories in the way of writing any tracked files are simply deleted.</p>
</blockquote>
<p>PS: I am using git version 2.35.3.windows.1. I think quite some answers here made the issue over-complicated.</p>
| 7,598
|
<p>If I have an image like the one attached, what’s the best way to create an accurate depth map of it? I have photoshop CC and 3ds Max, but I don’t know what settings work best with Slic3r. There is a plethora of settings and combinations to choose from in either programs. </p>
<p>Did anyone do this before? If so, can you share your technique?</p>
<p><img src="https://i.stack.imgur.com/9wbEP.jpg" alt="enter image description here"></p>
|
<p>From a single image from this perspective (front view) you cannot map the coin surface in detail. There is reported limited success in estimating the depth of single images, but, this is for images with a clear perspective (e.g. like a picture of a room showing the walls and floor at an angle). In order to map the surface you will need to have multiple images and preferably know the direction of lighting on that object.</p>
<p>People with one eye cannot estimate depth very well, you need two eyes and a trained brain to understand the differences in depth.</p>
|
<p>If you have a depth map (a raster file with the height at each point), OpenSCAD has the ability to read the height map and create a 3D object. That 3D object can then be exported as an .STL file, and sliced normally.</p>
<p>I have done this (maybe 3 years ago), and it worked well.</p>
<p>This <a href="http://aggregate.org/MAKE/TRACE2SCAD/" rel="nofollow noreferrer">site</a> includes a list of available tools. I probably used one of these, as I could easily convert my particular depth map to a PNG or other image file.</p>
<p>Once the file is in STL format, you can choose how best to print it for your printer.</p>
| 1,060
|
<p>We had a need for a <strong>document management solution</strong> and were hoping <code>SharePoint 2007</code> would satisfy our needs. We felt our needs were relatively simple. We needed to manage <strong>versioning</strong>, have <strong>searching capabilities</strong>, and having an <strong>approval workflow</strong>.</p>
<p><code>SharePoint</code> handled these three aspects great out of the box.</p>
<p>However, we also require that the footer on the Office 2007 (Word, Excel, and PowerPoint) documents reflect the document version, last person to modify, and last modification date. These things can be done with office automation, but we have yet to find a complete solution.</p>
<p>We first tried to do it on the checking-in and checked-in events and followed this path for a while, however, the complication we ran into was after we made the changes to the document we had to no way of preventing the save from updating the version number. This resulted in something similar to this:</p>
<p>Document checked-in – the document version should be v0.1 however it is v0.2 because we save the document after the footer is replaced. If we look in the document history we there are 2 separate versions v0.1 does not have the footer v0.2 has the footer but it says v0.1 as that is the version the document was when it was replaced.</p>
<p>This is an unacceptable solution for us as we want the process to be completely handled on the user side so they would have full control to revert back to a version where the footer would be incorrect and not contain the correct data. When we attempted to create a custom approval/check-in workflow we found that the same problem was present. The footer is necessary so that hard-copies can be traced back to their electronic counterpart.</p>
<p>Another solution that was proposed to us was to build plugins for office that would handle the replacement of the footer. This is inadequate for our needs as it requires a client side deployment of our plugins which is undesirable by our clients. What we are looking for is a clean solution to this problem.</p>
|
<p>Here is a <a href="http://www.sharepointblogs.com/johnwpowell/archive/2007/07/13/display-version-number-and-other-sharepoint-metadata-in-word-2003-documents.aspx" rel="nofollow noreferrer">blog post</a> which seem to be exactly the solution of your problem.</p>
<p>Basically they create a custom field in the document library and use event receivers to keep the current version of the document in this field.
The "trick" is that on the client side this custom field shows up as a property of the document the value of which you can easily embed into the document's contents.</p>
<p>I'm not sure why changing the field won't increase the version of the document, but I guess it is because you're only changing metadata, not the actual document. </p>
<p>They do use a little VBA script which runs on the client side, but it doesn't require any client side deployment as it is downloaded with the document. However I'm not sure if any security settings changes on the client side may be needed to allow the script to run.</p>
|
<p>Does this information need to be in the footer? A lot of the information is available within the Office 2007 application. If you click on the round button in the upper left, and select "Server", you can view the version history, a lot of the other properties are available by clicking the round button and opening the "Prepare" menu, and selecting Properties.</p>
<p>If this information must be displayed in the document footer I would investigate creating a custom Information Management Policy. <a href="http://www.sharepointblogs.com/tonstegeman/archive/2007/02/01/moss-custom-policies-part-1-creating-a-custom-information-management-policy.aspx" rel="nofollow noreferrer">This</a> may be a good place to start.</p>
| 8,370
|
<p>i am planning a simple, dual-language website and i'd like to use a .net based cms but i can't find anything suitable. i have experience with dotnetnuke and sharepoint but neither fit the bill - dotnetnuke does not do dynamic site elements multi-lingually & sharepoint is a monster PITA no matter what angle you look at it :).</p>
<p>i am on the verge of choosing Joomla! & Joom!Fish. they fit the bill nicely, with one exception: i would like to create some cms plug-ins and i would much prefer to write them in .net. any suggestions?</p>
|
<p>Have you looked at <a href="http://www.umbraco.org/" rel="nofollow noreferrer">Umbraco</a>? I have worked with it to try out for clients and it looks really good.</p>
<p>I would look to them as a possible solution.</p>
|
<p>For .NET, assuming you're comfortable with XSLT, Umbraco - <a href="http://www.umbraco.org" rel="nofollow noreferrer">www.umbraco.org</a></p>
<p>The XSLT qualification is important because that's the basis of the template (for content) system so whilst the end users have no requirement to use XSLT those defining the templates will.</p>
<hr>
<p>Edit:</p>
<p>As we roll towards the end of 2011 there is now an alternative to XSLT, support for the Razor engine is being added to Umbraco and its fair to say that Razor is probably a bit less challenging than XSLT (much as I continute to be impressed by what one can do with XSLT, it does need a different mindset).</p>
| 5,398
|
<p>I've got an ms-access application that's accessing and ms-sql db through an ODBC connection. I'm trying to force my users to update the data <em>only</em> through the application portion, but I don't care if they read the data directly or through their own custom ms-access db (they use it for creating ad hoc reports).</p>
<p>What I'm looking for is a way to make the data only editable if they are using the compiled .mde file I distribute to them. I know I can make the data read only for the general population, and editable for select users. </p>
<p>Is there a way I can get ms-sql to make the data editable only if they are accessing it through the my canned mde?</p>
<p>Thought, is there a way to get ms-access to log into the database as a different user (or change the login once connected)?</p>
<hr>
<p>@Jake,<br>
Yes, it's using forms. What I'm looking to do is just have it switch users once when I have my launchpad/mainmenu form pop up.</p>
<p>@Peter,<br>
That is indeed the direction I'm headed. What I haven't determined was how to go about switching to that second ID. I'm not so worried about the password being sniffed, the users are all internal, and on an internal LAN. If they can sniff that password, they can certainly sniff the one for my privileged ID.</p>
<p>@no one in general,<br>
Right now its security by obscurity. I've given the uses a special .mdb for doing reporting that will let them read data, but not update it. They don't know about relinking to the tables through the ODBC connection. A slightly more ms-access/DB literate user could by pass what I've done in seconds - and there a few who imagine themselves to be DBA, so they will figure it out eventually.</p>
|
<p>There is a way to do this that is effective with internal users, but can be hacked. You create two IDs for each user. One is a reporting ID that has read-only access. This is they ID that the user knows about: Fred / mypassword</p>
<p>The second is an ID that can do updates. That id is Fred_app / mypassword_mangled. They log on to your app with Fred. When your application accesses data, it uses the application id.</p>
<p>This can be sniffed, but for many applications it is sufficient.</p>
|
<p>Does you app allow for linked table updates or does it go through forms? Sounds like your idea of using a centralized user with distinct roles is the way to go. Yes, you could change users but I that may introduce more coding and once you start adding more and more code other solutions (stored procedures, etc) may sound more inviting. </p>
| 7,287
|
<p>Alright, long story but I want to provide as much detail as possible:</p>
<p>I have a heavily modded Ender 3 Pro. Mods include:</p>
<ul>
<li>Metal Extruder</li>
<li>Capricorn PTFE tube</li>
<li>Glass bed with improved leveling nuts</li>
<li>BLTouch</li>
<li>LED strip</li>
<li>Dual Z-axis motors with the recent addition of BTT E3 RRF control board (and IDEX module so that it could do <code>G34</code> auto-align) (most recent additions)</li>
</ul>
<p>I'm using Overture Brand white PLA and for the first print that messed up (pic below), I was using the default "generic PLA" Cura settings for an Ender 3 pro.</p>
<p><strong>The problem:</strong></p>
<p>Anyhow, it caused this kind of print:</p>
<p><a href="https://i.stack.imgur.com/46TAX.jpg" rel="nofollow noreferrer" title="3D benchy with printing errors"><img src="https://i.stack.imgur.com/46TAX.jpg" alt="3D benchy with printing errors" title="3D benchy with printing errors" /></a></p>
<p>There are a few angles where it actually looks pretty good. The hull is fairly smooth, the first layer went down well, the roofs and bridging look tolerable, but as you can see, especially around the "pillars" it looks I don't know... under-extruded? Like the lines don't connect very strongly. In fact, it might be hard to tell from this photo but the bottom actually ripped off when I took it off the plate, mostly due to weak connections between each layer.</p>
<p><strong>What I've tried:</strong></p>
<p>I pretty much went step by step through Teaching Tech's <a href="https://teachingtechyt.github.io/calibration.html#intro" rel="nofollow noreferrer">calibration guide</a>.</p>
<ul>
<li>I started by getting out my bubble level and 90-degree gauge and just making sure the frame/bed/everything was level and perpendicular to each other and everything.</li>
<li>I did the E-steps calibration until I reliably got 100 mm when I asked for 100 mm</li>
<li>My first layer had never been a problem (especially with BLTouch and glass bed), so I skipped that step.</li>
<li>I did the baseline print. My first one looked like the top of the cube had some under extrusion (you can see through it if you look closely in this photo
<a href="https://i.stack.imgur.com/YnEzD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YnEzD.jpg" alt="enter image description here" /></a></li>
<li>I did the slicer flow calibration and actually it came out a little tiny bit too big (which would indicate I need to turn down the flow), but as Teaching Tech mentioned at the bottom of the page, you can't always trust that so I didn't end up making any changes to flow.
<ul>
<li>Worth pointing out, in this photo of the Slicer Flow calibration cube, you can see some weird holes where the nozzle would be kinda late starting a line.
<a href="https://i.stack.imgur.com/2xyq9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2xyq9.png" alt="enter image description here" /></a></li>
</ul>
</li>
<li>The stepper motor driver current thing confuses me but I had previously set the current of both Z-axis' to the values I've seen in several YouTube videos, including Aurora.tech's channel where she covered the same BTT IDEX board and dual Z's.</li>
<li>I did the temperature tuning and it seems like for this PLA 210 °C seems to work well.</li>
<li>At this point I felt like retraction tuning was the problem and would fix everything, but with the default speeds in Teaching Tech's sample print, distances from 0-8 mm didn't seem to do anything differently in this print:
<a href="https://i.stack.imgur.com/uUyXL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uUyXL.jpg" alt="enter image description here" /></a></li>
<li>I never ended up doing the acceleration tuning</li>
<li>For the linear advance, I changed the k value to 0.4</li>
<li>I don't have a dial gauge to do the XYZ steps calibration</li>
</ul>
<p>Long story short, with those few changes I redid the calibration cube and the benchy and they look maybe 5% better but still weird.</p>
<p>My Z-axis squeaks sometimes when moving through a spot 5-10 mm off the bed, so I lubricated them according to the <a href="https://letsprint3d.net/how-to-lubricate-z-axis-lead-screw-3d-printers/" rel="nofollow noreferrer">guide here</a>, but I did that prior to that second benchy so it didn't seem to solve it.</p>
<p>After I first posted this, I decided to dive deeper into that squeaky Z-axis. I triple, super-duper checked that both Z threaded rods were parallel to each other and neither was warped/curved/etc... They seem fine. I lubricated them both a bit more and using G-code told the printer to jog the Z-axis up and down the length of the rods about 20ish times. The squeak did eventually go away so I printed another benchy. No dice. Still looks bad.</p>
<p>Per Criggie's answer, I disabled the steppers and moved the axes around to see if they moved smoothly. Both X and Y move great with steppers disabled and then are pretty firm normally. Z is pretty stiff no matter what but that may be intentional. I previously had problems with my Z-axis falling down when prints were over so I <a href="https://www.youtube.com/watch?v=Lpc1bTsSpRA" rel="nofollow noreferrer">installed anti-backlash nuts</a> and with two anti-backlash nuts (one on each rod) I'm not surprised it doesn't want to fall. But again, when I just tell it to move, it moves very smoothly.
For instance, I just got out my micrometer and measured the Z movement. I told it to move 100 mm up using OctoPrint and measured the actual movement. Seemed to be 100 on the dot.</p>
<p>I have a BTT filament sensor in the filament path prior to the extruder. I noticed it provided a little friction and I was concerned it was making it hard for the extruder to pull the filament. I removed it, but no improvement in print quality.</p>
<p>One other strange thing I've noticed is the benchy always looks bad in the same spot (the pillars). Makes me wonder WHY it's always that exact spot, not randomly all over.</p>
<p>It's got to have something to do with under-extrusion or flow. I think I ruled out the Z-axis. I made a "tall" benchy by modifying the benchy file to have a platform underneath it. This bumped it up a few cm and the problem still happened in the same spot on the pillars of the benchy (which is now in a completely different spot on the Z.
Also, given the "flow" preview in Cura:
<a href="https://i.stack.imgur.com/TNvq4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TNvq4.png" alt="enter image description here" /></a></p>
<p>That circled low flow area is where it always messes up.</p>
<p>So now to figure out why it's got low flow. Again, I calibrated the E-steps and it seems to be accurate. I've also printed benchy's where I told Cura to have 110% flow just to check. The last one I attempted didn't just fail, it failed big time and became a blob at that same spot.</p>
<p>I wonder if the extruder gear is worn and slipping and/or the Capricorn PTFE tube is too restrictive for the "budget" filament brand I'm using that might have trouble sliding through it. I have replacement steel extruder gears showing up Tuesday, will update my question then.</p>
|
<p><img src="https://i.stack.imgur.com/WpqHy.jpg" alt="enter image description here" />
It was a worn extruder gear. I didn’t think it was THAT worn, and when I loosened it a bit and slid it a few mm so that the gear hit the filament in a fresh spot it didn’t improve. But new stainless steel gears showed up today and when I installed one it worked perfect. Same file/settings/gcode that had failed several times previously when testing other things</p>
|
<p>I see positional errors in X and Y, but Z looks okay.</p>
<p>That suggests one or both of your belts is stretched, perhaps damaged, or maybe just loose.</p>
<p>Try engaging the stepper motors in the device's panel and push the head left/right or pull the bed toward/away from you. They should both resist handforce, and you then feel like it needs to be pushed with full arm/shoulder force to move it (but don't actually force anything with that level !!)</p>
<p>There should be none/almost no play in X or Y with the steppers locked/engaged.</p>
<p>Then disable the stepper motors in the same menu, and both bed and head should slide with one finger's push.</p>
<p>This test does not work for Z but that axis seems fine in your benchy print.</p>
<p>Also check the condition of the drive/tension pulleys at either end of the belts. There should be no powdered plastic from the cogs, nor rubbery bits from the belt.</p>
<p>I cannot see any over/under extrusion, so the extruder/drive is probably okay.</p>
| 2,053
|
<p>I developed a program in a mobile device (Pocket PC 2003) to access a web service, the web service is installed on a Windows XP SP2 PC with IIS, the PC has the IP 192.168.5.2. </p>
<p>The device obtains from the wireless network the IP 192.168.5.118 and the program works OK, it calls the method from the web service and executes the action that is needed. This program is going to be used in various buildings.</p>
<p>Now I have this problem, it turns that when I try to test it in another building (distances neraly about 100 mts. or 200 mts.) connected with the network, the program cannot connect to the webservice, at this moment the device gets from an Access Point the IP 192.168.10.25, and it accesses the same XP machine I stated before (192.168.5.2). I made a mobile aspx page to verify that I can reach the web server over the network and it loads it in the device, I even made a winform that access the same webservice in a PC from that building and also works there so I don't understand what is going on. I also tried to ping that 192.168.5.2 PC and it responds alive.</p>
<p>After that fail I returned to the original place where I tested the program before and it happens that it works normally.</p>
<p>The only thing that I look different here is that the third number in the IP is 10 instead of 5, another observation is that I can't ping to the mobile device. I feel confused I don't know what happens here? What could be the problem?</p>
<p>This is how I call the web service;</p>
<pre><code>//Connect to webservice
svc = new TheWebService();
svc.Credentials = new System.Net.NetworkCredential(Settings.UserName, Settings.Password);
svc.AllowAutoRedirect = false;
svc.UserAgent = Settings.UserAgent;
svc.PreAuthenticate = true;
svc.Url = Settings.Url;
svc.Timeout = System.Threading.Timeout.Infinite;
//Send information to webservice
svc.ExecuteMethod(info);
</code></pre>
<p>the content of the app.config in the mobile device is;</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="UserName" value="administrator" />
<add key="Password" value="************" />
<add key="UserAgent" value="My User Agent" />
<add key="Url" value="http://192.168.5.2/WebServices/TWUD.asmx" />
</appSettings>
</configuration>
</code></pre>
<p>Does anyone have an idea what is going on?</p>
|
<p>This looks like a network issue, unless there's an odd bug in .Net CF that doesn't allow you to traverse subnets in certain situations (I can find no evidence of such a thing from googling).</p>
<p>Can you get any support from the network/IT team? Also, have you tried it from a different subnet? I.e. not the same as the XP machine (192.168.5.x) and not the same as the one that's not worked so far (192.168.10.).</p>
<p>@Shaun Austin - that wouldn't explain why they can get at a regular web page on the XP machine from the different subnet.</p>
|
<p>Not an expert with this stuff but it looks like the first 3 parts of the address are being masked out. Is it possible that the mobile device is being given a network mask of:</p>
<pre><code>255.255.255.0
</code></pre>
<p>As to reach beyond the range of the first 3 parts you need the mask to be:</p>
<pre><code>255.255.0.0
</code></pre>
<p>This may be an oversimplification or completely wrong but that's was my gut response to the question.</p>
| 5,122
|
<p>I'd like to be able to view the event <code>log</code> for a series of <code>asp.net</code> websites running on IIS. Can I do this externally, for example, through a web interface?</p>
|
<p>No, but there are two solutions I would recommend:</p>
<ul>
<li><p>Adiscon <a href="http://www.eventreporter.com/en/" rel="nofollow noreferrer">EventLogger</a> is a third-party product that will send your Windows EventLog to a SQL database. You can either send all events or create filters. Of course, once the events are in a SQL database, you can use any of the usual tools to create a web interface.</p></li>
<li><p>You can use ASP.NET's <a href="http://msdn.microsoft.com/en-us/library/ms998306.aspx" rel="nofollow noreferrer">HealthMonitoring</a> configuration section to configure .NET to send all ASP.NET-related events directly to a SQL database. This covers exceptions, heartbeats, and a host of other event types. The <a href="http://msdn.microsoft.com/en-us/library/system.web.management.sqlwebeventprovider.aspx" rel="nofollow noreferrer">SqlWebEventProvider</a> is a cinch to setup.</p></li>
</ul>
|
<p>Do you want to know if you can home-roll something or are you looking for an app you can get off the shelf?</p>
<p>I'm not a Windows guy, but I think Microsoft's MOM/SCOM solution will probably let you view the event log over a web UI - probably really heavy and expensive if that's all you need though.</p>
<p>A quick google found <a href="http://www.codeproject.com/KB/XML/Event_Logger.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/XML/Event_Logger.aspx</a> which shows that you can get in if you want to roll your own... also an MS tool on <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en" rel="nofollow noreferrer">msdn</a></p>
<p>Sorry I can't be more help</p>
| 5,865
|
<p>I planning on getting a resin 3d printer kit, and I don't want to take any risks building it myself. Where, or who, could I hire a professional capable of constructing a 3D printer kit? They don't necessarily have to specialize in constructing 3d printers, I just need someone qualified with the mechanical and technical skills for the job.</p>
|
<p>If you have a makerspace in your area, you'll likely find individuals with reasonable mechanical skills suitable for simple kit assembly. Most kits are engineered to be reasonable assembly, not rocket surgery. Makers are by nature capable of construction, often from raw materials, and kits are typically not particularly challenging comparatively speaking.</p>
<p>Resin 3D printers are also simple in construction, as the component count is less than that of an FDM printer, or quite close in count. SLA designs involve laser modules, mirrors and alignment, while DLP designs involve light projection and light masking. Both designs involve vats and movement mechanics.</p>
<p>Even if you do not have a makerspace local to you, consider to contact one that might be nearer than farther away, as those spaces may have leads for you to locate a suitable victim/candidate.</p>
<p>Our local library makerspace often farms out contacts to me or other makers with the necessary skills to meet a patron's requirements.</p>
|
<p>I agree that a local makerspace is a good option, but I will say this...</p>
<p>Buying a kit and building it yourself, even with some frustration and learning curves, will help immensely with your ability to calibrate and troubleshoot issues later. If someone else builds it for you, chances are if something goes wrong, you'll need to seek out that person for help fixing things.</p>
<p>I just recently bought my first 3D printer (FDM) as a kit. Building it was a slight learning curve - I'm a technophile and have built things with Arduino before, but never a printer and the specifics that come along with it. Getting it to actually print reliably took me about two weeks. However, I'm MUCH more confident now to take care of issues as they arise, and keep it running smoothly. The value of this experience can not be overstated.</p>
| 719
|
<p>I have a Monthly Status database view I need to build a report based on. The data in the view looks something like this:</p>
<pre><code>Category | Revenue | Yearh | Month
Bikes 10 000 2008 1
Bikes 12 000 2008 2
Bikes 12 000 2008 3
Bikes 15 000 2008 1
Bikes 11 000 2007 2
Bikes 11 500 2007 3
Bikes 15 400 2007 4
</code></pre>
<p><br/>
... And so forth</p>
<p>The view has a product category, a revenue, a year and a month. I want to create a report comparing 2007 and 2008, showing 0 for the months with no sales. So the report should look something like this:</p>
<pre><code>Category | Month | Rev. This Year | Rev. Last Year
Bikes 1 10 000 0
Bikes 2 12 000 11 000
Bikes 3 12 000 11 500
Bikes 4 0 15 400
</code></pre>
<p><br/>
The key thing to notice is how month 1 only has sales in 2008, and therefore is 0 for 2007. Also, month 4 only has no sales in 2008, hence the 0, while it has sales in 2007 and still show up.</p>
<p>Also, the report is actually for financial year - so I would love to have empty columns with 0 in both if there was no sales in say month 5 for either 2007 or 2008.</p>
<p>The query I got looks something like this:</p>
<pre><code>SELECT
SP1.Program,
SP1.Year,
SP1.Month,
SP1.TotalRevenue,
IsNull(SP2.TotalRevenue, 0) AS LastYearTotalRevenue
FROM PVMonthlyStatusReport AS SP1
LEFT OUTER JOIN PVMonthlyStatusReport AS SP2 ON
SP1.Program = SP2.Program AND
SP2.Year = SP1.Year - 1 AND
SP1.Month = SP2.Month
WHERE
SP1.Program = 'Bikes' AND
SP1.Category = @Category AND
(SP1.Year >= @FinancialYear AND SP1.Year <= @FinancialYear + 1) AND
((SP1.Year = @FinancialYear AND SP1.Month > 6) OR
(SP1.Year = @FinancialYear + 1 AND SP1.Month <= 6))
ORDER BY SP1.Year, SP1.Month
</code></pre>
<p>The problem with this query is that it would not return the fourth row in my example data above, since we didn't have any sales in 2008, but we actually did in 2007.</p>
<p>This is probably a common query/problem, but my SQL is rusty after doing front-end development for so long. Any help is greatly appreciated!</p>
<p>Oh, btw, I'm using SQL 2005 for this query so if there are any helpful new features that might help me let me know.</p>
|
<p>The Case Statement is my best sql friend. You also need a table for time to generate your 0 rev in both months.</p>
<p>Assumptions are based on the availability of following tables:</p>
<blockquote>
<p>sales: Category | Revenue | Yearh |
Month</p>
</blockquote>
<p>and</p>
<blockquote>
<p>tm: Year | Month (populated with all
dates required for reporting)</p>
</blockquote>
<p>Example 1 without empty rows:</p>
<pre><code>select
Category
,month
,SUM(CASE WHEN YEAR = 2008 THEN Revenue ELSE 0 END) this_year
,SUM(CASE WHEN YEAR = 2007 THEN Revenue ELSE 0 END) last_year
from
sales
where
year in (2008,2007)
group by
Category
,month
</code></pre>
<p>RETURNS:</p>
<pre><code>Category | Month | Rev. This Year | Rev. Last Year
Bikes 1 10 000 0
Bikes 2 12 000 11 000
Bikes 3 12 000 11 500
Bikes 4 0 15 400
</code></pre>
<p>Example 2 with empty rows:
I am going to use a sub query (but others may not) and will return an empty row for every product and year month combo.</p>
<pre><code>select
fill.Category
,fill.month
,SUM(CASE WHEN YEAR = 2008 THEN Revenue ELSE 0 END) this_year
,SUM(CASE WHEN YEAR = 2007 THEN Revenue ELSE 0 END) last_year
from
sales
Right join (select distinct --try out left, right and cross joins to test results.
product
,year
,month
from
sales --this ideally would be from a products table
cross join tm
where
year in (2008,2007)) fill
where
fill.year in (2008,2007)
group by
fill.Category
,fill.month
</code></pre>
<p>RETURNS:</p>
<pre><code>Category | Month | Rev. This Year | Rev. Last Year
Bikes 1 10 000 0
Bikes 2 12 000 11 000
Bikes 3 12 000 11 500
Bikes 4 0 15 400
Bikes 5 0 0
Bikes 6 0 0
Bikes 7 0 0
Bikes 8 0 0
</code></pre>
<p>Note that most reporting tools will do this crosstab or matrix functionality, and now that i think of it SQL Server 2005 has pivot syntax that will do this as well.</p>
<p>Here are some additional resources.
CASE
<a href="https://web.archive.org/web/20210728081626/https://www.4guysfromrolla.com/webtech/102704-1.shtml" rel="noreferrer">https://web.archive.org/web/20210728081626/https://www.4guysfromrolla.com/webtech/102704-1.shtml</a>
SQL SERVER 2005 PIVOT
<a href="http://msdn.microsoft.com/en-us/library/ms177410.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms177410.aspx</a></p>
|
<p>Using pivot and Dynamic Sql we can achieve this result</p>
<pre><code>SET NOCOUNT ON
IF OBJECT_ID('TEMPDB..#TEMP') IS NOT NULL
DROP TABLE #TEMP
;With cte(Category , Revenue , Yearh , [Month])
AS
(
SELECT 'Bikes', 10000, 2008,1 UNION ALL
SELECT 'Bikes', 12000, 2008,2 UNION ALL
SELECT 'Bikes', 12000, 2008,3 UNION ALL
SELECT 'Bikes', 15000, 2008,1 UNION ALL
SELECT 'Bikes', 11000, 2007,2 UNION ALL
SELECT 'Bikes', 11500, 2007,3 UNION ALL
SELECT 'Bikes', 15400, 2007,4
)
SELECT * INTO #Temp FROM cte
Declare @Column nvarchar(max),
@Column2 nvarchar(max),
@Sql nvarchar(max)
SELECT @Column=STUFF((SELECT DISTINCT ','+ 'ISNULL('+QUOTENAME(CAST(Yearh AS VArchar(10)))+','+'''0'''+')'+ 'AS '+ QUOTENAME(CAST(Yearh AS VArchar(10)))
FROM #Temp order by 1 desc FOR XML PATH ('')),1,1,'')
SELECT @Column2=STUFF((SELECT DISTINCT ','+ QUOTENAME(CAST(Yearh AS VArchar(10)))
FROM #Temp FOR XML PATH ('')),1,1,'')
SET @Sql= N'SELECT Category,[Month],'+ @Column +'FRom #Temp
PIVOT
(MIN(Revenue) FOR yearh IN ('+@Column2+')
) AS Pvt
'
EXEC(@Sql)
Print @Sql
</code></pre>
<p>Result</p>
<pre><code>Category Month 2008 2007
----------------------------------
Bikes 1 10000 0
Bikes 2 12000 11000
Bikes 3 12000 11500
Bikes 4 0 15400
</code></pre>
| 3,790
|
<p>Does anyone know if you can and how to start off a scheduled Windows task on a Remote Server from within a SQL Server Integration Services (SSIS) package?</p>
|
<p>Assuming you run it on Windows Server 2003/2008 or Vista, use SSIS Execute Process Task to start SCHTASKS.EXE with appropriate params (<strong>SCHTASKS /Run /?</strong> to see details).</p>
|
<p>It should be possible as the Task Scheduler has a scriptable <a href="http://msdn.microsoft.com/en-us/library/aa383614%28VS.85%29.aspx" rel="nofollow noreferrer">COM API</a> that can be used for interacting with tasks.</p>
<p>You could therefore either create a custom task that uses COM interop to call the Task Scheduler API, or it'd probably be quicker to use an Active X Script task to do your dirty work.</p>
| 5,826
|
<p>Does anyone have some good hints for writing test code for database-backend development where there is a heavy dependency on state?</p>
<p>Specifically, I want to write tests for code that retrieve records from the database, but the answers will depend on the data in the database (which may change over time).</p>
<p>Do people usually make a separate development system with a 'frozen' database so that any given function should always return the exact same result set?</p>
<p>I am quite sure this is not a new issue, so I would be very interested to learn from other people's experience.</p>
<p>Are there good articles out there that discuss this issue of web-based development in general?</p>
<p>I usually write PHP code, but I would expect all of these issues are largely language and framework agnostic.</p>
|
<p>You should look into DBUnit, or try to find a PHP equivalent (there must be one out there). You can use it to prepare the database with a specific set of data which represents your test data, and thus each test will no longer depend on the database and some existing state. This way, each test is self contained and will not break during further database usage.</p>
<p>Update: A quick google search showed a <a href="http://www.ds-o.com/archives/63-PHPUnit-Database-Extension-DBUnit-Port.html" rel="noreferrer">DB unit extension</a> for PHPUnit.</p>
|
<p>I have the exact same problem with my work and I find that the best idea is to have a PHP script to re-create the database and then a separate script where I throw crazy data at it to see if it breaks it.</p>
<p>I have not ever used any Unit testing or suchlike so cannot say if it works or not sorry.</p>
| 2,506
|
<p>I have had an Anet A8 printer for about two months now and still have not gotten it to print good prints. </p>
<p>At first, it would only print completely solid parts and every time I would try infill from 10-90% the first layer would not stick or it would print really filmy like. As of now, it won't print the first layers for anything well but once it gets up about 10-ish layers it prints perfectly. I have tried a lot of stuff but it seems to be making it worse. </p>
<p>The pictures show my recent attempt at these settings below (Cura's default for normal quality), the print is supposed to be a 10 mm square. I have gone back to the default settings because nothing else was working.</p>
<ul>
<li>Using blue painter's tape</li>
<li>Layer Height 0.1 mm</li>
<li>In. Layer Height 0.3 mm</li>
<li>WallThicken 0.8 mm</li>
<li>Top/Bottom Thick 0.8 mm</li>
<li>Infill Density 20%</li>
<li>Grid Pattern</li>
<li>Print Temp 210°C</li>
<li>Bed Temp 65°C</li>
<li>Dia 1.75 mm</li>
<li>Flow 100%</li>
<li>Brim (raft is a little better)</li>
</ul>
<p>Any suggestions?</p>
<p><a href="https://i.stack.imgur.com/uQMNN.jpg" rel="nofollow noreferrer" title="Photo of 3D print, showing top layer with two bubble effects"><img src="https://i.stack.imgur.com/uQMNN.jpg" alt="Photo of 3D print, showing top layer with two bubble effects" title="Photo of 3D print, showing top layer with two bubble effects"></a></p>
<p>In the top picture you can also how the top layer has two bubble effects.</p>
<p><a href="https://i.stack.imgur.com/N0ZT3.jpg" rel="nofollow noreferrer" title="3D Print with brim"><img src="https://i.stack.imgur.com/N0ZT3.jpg" alt="3D Print with brim" title="3D Print with brim"></a></p>
|
<p>With respect to the filament lifting off, and/or not adhering correctly, on the first layer, see <a href="https://3dprinting.stackexchange.com/questions/4018/filament-lifts-from-the-hot-bed-while-printing">Filament lifts from the hot bed while printing</a>... in particular, you may need to clean the bed, calibrate the leveling and the nozzle height (see <a href="https://3dprinting.stackexchange.com/questions/4018/filament-lifts-from-the-hot-bed-while-printing#answer-4021">my answer</a>).</p>
<p>The fact that the prints are fine, after 10 or so layers, could be to do with the heat - at the higher layers the print is warm and no warping occurs, but below that, maybe the print bed is acting as a heat sink and making the filament cool too quickly - hence the distortion. Are you using a heated bed? If not, then maybe consider installing one.</p>
<p>Not sure about the bubbles: how do your store your filament? The bubbles could be due to water, which expands as it gets hot, thereby causing the filament to bubble. It is best to store your filament in an air tight container, to prevent it collecting moisture and dust from the air.</p>
|
<p>When I first started printing with the anet A8, I also had trash first layers.<br>
I tried (almost) everything:</p>
<ol>
<li>Leveling the bed maniacally several times (all the screws in the
frame need to be very tight) </li>
<li>Varying bed temperature and nozzle
temperature at all possible combinations. </li>
<li>Adding blue masking tape</li>
</ol>
<p>Nothing would significantly improve my first layer, except for <strong>HAIRSPRAY</strong>.</p>
<p>After discovering this secret, I went back and un-varied everything. I tried with and without tape, at high and low temperatures. With-out the hairspray it never stuck well. With the hairspray it stuck perfectly every time. A small spray is sufficient.</p>
<p>After you are done making a mess, use nail polish remover ( acetone ) to properly clean everything.</p>
<p>If you are doubting your G-code, get a pre-generated one for the A8. The ones that came on the SD card should print very well, nothing like the image you showed of the 1st layer.</p>
| 604
|
<p>I know next to nothing when it comes to the how and why of https connections. Obviously, when I'm transmitting secure data like passwords or especially credit card information, https is a critical tool. What do I need to know about it, though? What are the most common mistakes you see developers making when they implement it in their projects? Are there times when https is just a bad idea? Thanks!</p>
|
<p>An HTTPS, or Secure Sockets Layer (SSL) certificate is served for a site, and is typically signed by a Certificate Authority (CA), which is effectively a trusted 3rd party that verifies some basic details about your site, and certifies it for use in browsers. If your browser trusts the CA, then it trusts any certificates signed by that CA (this is known as the trust chain). </p>
<p>Each HTTP (or HTTPS) request consists of two parts: a request, and a response. When you request something through HTTPS, there are actually a few things happening in the background:</p>
<ul>
<li>The client (browser) does a "handshake", where it requests the server's public key and identification.
<ul>
<li>At this point, the browser can check for validity (does the site name match? is the date range current? is it signed by a CA it trusts?). It can even contact the CA and make sure the certificate is valid. </li>
</ul></li>
<li>The client creates a new pre-master secret, which is encrypted using the servers's public key (so only the server can decrypt it) and sent to the server</li>
<li>The server and client both use this pre-master secret to generate the master secret, which is then used to create a symmetric session key for the actual data exchange</li>
<li>Both sides send a message saying they're done the handshake</li>
<li>The server then processes the request normally, and then encrypts the response using the session key</li>
</ul>
<p>If the connection is kept open, the same symmetric key will be used for each.</p>
<p>If a new connection is established, and both sides still have the master secret, new session keys can be generated in an 'abbreviated handshake'. Typically a browser will store a master secret until it's closed, while a server will store it for a few minutes or several hours (depending on configuration).</p>
<p>For more on the length of sessions see <a href="https://security.stackexchange.com/a/55477/27894">How long does an HTTPS symmetric key last?</a></p>
<p><strong>Certificates and Hostnames</strong></p>
<p>Certificates are assigned a Common Name (CN), which for HTTPS is the domain name. The CN has to match exactly, eg, a certificate with a CN of "example.com" will NOT match the domain "www.example.com", and users will get a warning in their browser.</p>
<p>Before <a href="https://en.wikipedia.org/wiki/Server_Name_Indication" rel="nofollow noreferrer">SNI</a>, it was not possible to host multiple domain names on one IP. Because the certificate is fetched before the client even sends the actual HTTP request, and the HTTP request contains the Host: header line that tells the server what URL to use, there is no way for the server to know what certificate to serve for a given request. SNI adds the hostname to part of the TLS handshake, and so as long as it's supported on both client and server (and in 2015, it is widely supported) then the server can choose the correct certificate. </p>
<p>Even without SNI, one way to serve multiple hostnames is with certificates that include Subject Alternative Names (SANs), which are essentially additional domains the certificate is valid for. Google uses a single certificate to secure many of it's sites, for example.</p>
<p><a href="https://i.stack.imgur.com/3Tniz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Tniz.png" alt="Google SSL certificate"></a></p>
<p>Another way is to use wildcard certificates. It is possible to get a certificate like "<em>.example.com" in which case "www.example.com" and "foo.example.com" will both be valid for that certificate. However, note that "example.com" does not match "</em>.example.com", and neither does "foo.bar.example.com". If you use "www.example.com" for your certificate, you should redirect anyone at "example.com" to the "www." site. If they request <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a>, unless you host it on a separate IP and have two certificates, the will get a certificate error. </p>
<p>Of course, you can mix both wildcard and SANs (as long as your CA lets you do this) and get a certificate for both "example.com" and with SANs "<em>.example.com", "example.net", and "</em>.example.net", for example.</p>
<p><strong>Forms</strong></p>
<p>Strictly speaking, if you are submitting a form, it doesn't matter if the form page itself is not encrypted, as long as the submit URL goes to an https:// URL. In reality, users have been trained (at least in theory) not to submit pages unless they see the little "lock icon", so even the form itself should be served via HTTPS to get this. </p>
<p><strong>Traffic and Server Load</strong></p>
<p>HTTPS traffic is much bigger than its equivalent HTTP traffic (due to encryption and certificate overhead), and it also puts a bigger strain on the server (encrypting and decrypting). If you have a heavily-loaded server, it may be desirable to be very selective about what content is served using HTTPS. </p>
<p><strong>Best Practices</strong></p>
<ul>
<li><p>If you're not just using HTTPS for the entire site, it should automatically redirect to HTTPS as required. Whenever a user is logged in, they should be using HTTPS, and if you're using session cookies, the cookie should have the <a href="http://php.net/manual/en/function.session-set-cookie-params.php" rel="nofollow noreferrer">secure flag set</a>. This prevents interception of the session cookie, which is especially important given the popularity of open (unencrypted) wifi networks. </p></li>
<li><p>Any resources on the page should come from the same scheme being used for the page. If you try to fetch images from http:// when the page is loaded with HTTPS, the user will get security warnings. You should either use fully-qualified URLs, or another easy way is to use absolute URLs that do not include the hostname (eg, src="/images/foo.png") because they work for both. </p>
<ul>
<li>This includes external resources (eg, Google Analytics)</li>
</ul></li>
<li><p>Don't do POSTs (form submits) when changing from HTTPS to HTTP. Most browsers will flag this as a security warning.</p></li>
</ul>
|
<p>I would suggest any time <em>any</em> user data is stored in a database and communicated, use https. Consider this requirement even if the user data is mundane, because even many of these mundane details are used by that user to identify themselves on other websites. Consider all the random security questions your bank asks you (like what street do you live on?). This can be taken from address fields really easily. In this case, the data is not what you consider a password, but it might as well be. Furthermore, you can never anticipate what user data will be used for a security question elsewhere. You can also expect that with the intelligence of the average web user (think your grandmother) that that tidbit of information might make up part of that user's password somewhere else.</p>
<p>One pointer if you use https</p>
<p>make it so that if the user types
<a href="http://www.website-that-needs-https.com/etc/yadda.php" rel="nofollow noreferrer">http://www.website-that-needs-https.com/etc/yadda.php</a>
they will automatically get redirected to
<a href="https://www.website-that-needs-https.com/etc/yadda.php" rel="nofollow noreferrer">https://www.website-that-needs-https.com/etc/yadda.php</a>
(personal pet peeve)</p>
<p>However, if you're just doing a plain html webpage, that will be essentially a one-way transmission of information from the server to the user, don't worry about it. </p>
| 9,021
|
<p>If I have managed to locate and verify the existence of a file using Server.MapPath and I now want to send the user directly to that file, what is the <strong>fastest</strong> way to convert that absolute path back into a relative web path?</p>
|
<p>Perhaps this might work:</p>
<pre><code>String RelativePath = AbsolutePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty);
</code></pre>
<p><em>I'm using c# but could be adapted to vb.</em></p>
|
<p>For asp.net core i wrote helper class to get pathes in both directions.</p>
<pre><code>public class FilePathHelper
{
private readonly IHostingEnvironment _env;
public FilePathHelper(IHostingEnvironment env)
{
_env = env;
}
public string GetVirtualPath(string physicalPath)
{
if (physicalPath == null) throw new ArgumentException("physicalPath is null");
if (!File.Exists(physicalPath)) throw new FileNotFoundException(physicalPath + " doesn't exists");
var lastWord = _env.WebRootPath.Split("\\").Last();
int relativePathIndex = physicalPath.IndexOf(lastWord) + lastWord.Length;
var relativePath = physicalPath.Substring(relativePathIndex);
return $"/{ relativePath.TrimStart('\\').Replace('\\', '/')}";
}
public string GetPhysicalPath(string relativepath)
{
if (relativepath == null) throw new ArgumentException("relativepath is null");
var fileInfo = _env.WebRootFileProvider.GetFileInfo(relativepath);
if (fileInfo.Exists) return fileInfo.PhysicalPath;
else throw new FileNotFoundException("file doesn't exists");
}
</code></pre>
<p>from Controller or service inject FilePathHelper and use:</p>
<pre><code>var physicalPath = _fp.GetPhysicalPath("/img/banners/abro.png");
</code></pre>
<p>and versa</p>
<pre><code>var virtualPath = _fp.GetVirtualPath(physicalPath);
</code></pre>
| 2,535
|
<p>If I press <kbd>Ctrl</kbd>+<kbd>B</kbd> that ought to give me ASCII code 2, but <kbd>Ctrl</kbd>+<kbd>C</kbd> is going to be interpreted as a Break.</p>
<p>So I figure I've got to redirect a file in. How do I get these characters into a file?</p>
|
<p><kbd>Ctrl</kbd>-<kbd>V</kbd> escapes the next keystoke. That's how you can get a <kbd>Ctrl</kbd>-<kbd>C</kbd> out: <kbd>Ctrl</kbd>-<kbd>V</kbd> <kbd>Ctrl</kbd>-<kbd>C</kbd></p>
|
<pre><code>perl -e 'print "\xFF"'
</code></pre>
<p>where <code>FF</code> is the hex code of the ACSII code you want to print. So for ACSII code 2, it would be \x02.
</p>
| 3,634
|
<p>Here's my problem - I'd like to communicate between two websites and I'm looking for a clean solution. The current solution uses Javascript but there are nasty workarounds because of (understandable) cross-site scripting restrictions.</p>
<p>At the moment, <strong>website A</strong> opens a modal window containing <strong>website B</strong> using a <a href="http://jquery.com/" rel="noreferrer">jQuery</a> plug-in called <a href="http://dev.iceburg.net/jquery/jqModal/" rel="noreferrer">jqModal</a>. <strong>Website B</strong> does some work and returns some results to <strong>website A</strong>. To return that information we have to work around cross-site scripting restrictions - <strong>website B</strong> creates an iframe that refers to a page on <strong>website A</strong> and includes *fragment identifiers" containing the information to be returned. The iframe is polled by <strong>website A</strong> to detect the returned information. It's a <a href="http://tagneto.blogspot.com/2006/06/cross-domain-frame-communication-with.html" rel="noreferrer">common technique</a> but it's hacky.</p>
<p>There are variations such as <a href="http://www.julienlecomte.net/blog/2007/11/31/" rel="noreferrer">CrossSite</a> and I could perhaps use an HTTP POST from <strong>website B</strong> to <strong>website A</strong> but I'm trying to avoid page refreshes.</p>
<p>Does anyone have any alternatives?</p>
<p>EDIT: I'd like to avoid having to save state on <strong>website B</strong>.</p>
|
<p>My best suggestion would be to create a webservice on each site that the other could call with the information that needs to get passed. If security is necessary, it's easy to add an SSL-like authentication scheme (or actual SSL even, if you like) to this system to ensure that only the two servers are able to talk to their respective web services.</p>
<p>This would let you avoid the hackiness that's inherent in any scheme that involves one site opening windows on the other.</p>
|
<p>@jmein - you've described how to create a modal popup (which is exactly what jqModal does) however you've missed that the content of the modal window is served from another domain. The two domains involved belong to two separate companies so can't be combined in the way you describe.</p>
| 5,310
|
<p>Is there a way with WPF to get an array of elements under the mouse on a MouseMove event?</p>
|
<p>You can also try using the Mouse.DirectlyOver property to get the top-most element that is under the mouse.</p>
|
<p>Can you use the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper.hittest.aspx" rel="nofollow noreferrer">VisualTreeHelper.HitTest</a> ?</p>
<p><a href="http://lukieb.blogspot.com/2008/07/visualtreehelperhittest.html" rel="nofollow noreferrer">http://lukieb.blogspot.com/2008/07/visualtreehelperhittest.html</a></p>
| 6,782
|
<p>Given a <code>DateTime</code> representing a person's birthday, how do I calculate their age in years?</p>
|
<p>An easy to understand and simple solution.</p>
<pre class="lang-cs prettyprint-override"><code>// Save today's date.
var today = DateTime.Today;
// Calculate the age.
var age = today.Year - birthdate.Year;
// Go back to the year in which the person was born in case of a leap year
if (birthdate.Date > today.AddYears(-age)) age--;
</code></pre>
<p>However, this assumes you are looking for the <em>western</em> idea of the age and not using <a href="https://en.wikipedia.org/wiki/East_Asian_age_reckoning" rel="noreferrer"><em>East Asian reckoning</em></a>.</p>
|
<p>To calculate the age with nearest age:</p>
<pre class="lang-cs prettyprint-override"><code>var ts = DateTime.Now - new DateTime(1988, 3, 19);
var age = Math.Round(ts.Days / 365.0);
</code></pre>
| 2,232
|
<p>When you have a query or stored procedure that needs performance tuning, what are some of the first things you try?</p>
|
<p>Here is the handy-dandy list of things I always give to someone asking me about optimisation.<br>
We mainly use Sybase, but most of the advice will apply across the board. </p>
<p>SQL Server, for example, comes with a host of performance monitoring / tuning bits, but if you don't have anything like that (and maybe even if you do) then I would consider the following...</p>
<p><strong>99% of problems</strong> I have seen are caused by putting <strong>too many tables in a join</strong>. The fix for this is to do half the join (with some of the tables) and cache the results in a temporary table. Then do the rest of the query joining on that temporary table. </p>
<h2>Query Optimisation Checklist</h2>
<ul>
<li>Run UPDATE STATISTICS on the underlying tables
<ul>
<li>Many systems run this as a scheduled weekly job</li>
</ul></li>
<li>Delete records from underlying tables (possibly archive the deleted records)
<ul>
<li>Consider doing this automatically once a day or once a week. </li>
</ul></li>
<li>Rebuild Indexes</li>
<li>Rebuild Tables (bcp data out/in) </li>
<li>Dump / Reload the database (drastic, but might fix corruption) </li>
<li>Build new, more appropriate index</li>
<li>Run DBCC to see if there is possible corruption in the database</li>
<li>Locks / Deadlocks
<ul>
<li>Ensure no other processes running in database
<ul>
<li>Especially DBCC</li>
</ul></li>
<li>Are you using row or page level locking?</li>
<li>Lock the tables exclusively before starting the query</li>
<li>Check that all processes are accessing tables in the same order</li>
</ul></li>
<li>Are indices being used appropriately?
<ul>
<li>Joins will only use index if both expressions are exactly the same data type</li>
<li>Index will only be used if the first field(s) on the index are matched in the query</li>
<li>Are clustered indices used where appropriate?
<ul>
<li>range data</li>
<li>WHERE field between value1 and value2</li>
</ul></li>
</ul></li>
<li>Small Joins are Nice Joins
<ul>
<li>By default the optimiser will only consider the tables 4 at a time. </li>
<li>This means that in joins with more than 4 tables, it has a good chance of choosing a non-optimal query plan</li>
</ul></li>
<li>Break up the Join
<ul>
<li>Can you break up the join? </li>
<li>Pre-select foreign keys into a temporary table</li>
<li>Do half the join and put results in a temporary table</li>
</ul></li>
<li>Are you using the right kind of temporary table?
<ul>
<li><code>#temp</code> tables may perform much better than <code>@table</code> variables with large volumes (thousands of rows). </li>
</ul></li>
<li>Maintain Summary Tables
<ul>
<li>Build with triggers on the underlying tables</li>
<li>Build daily / hourly / etc. </li>
<li>Build ad-hoc</li>
<li>Build incrementally or teardown / rebuild </li>
</ul></li>
<li>See what the query plan is with SET SHOWPLAN ON</li>
<li>See what’s actually happenning with SET STATS IO ON </li>
<li>Force an index using the pragma: (index: myindex)</li>
<li>Force the table order using SET FORCEPLAN ON </li>
<li>Parameter Sniffing:
<ul>
<li>Break Stored Procedure into 2</li>
<li>call proc2 from proc1</li>
<li>allows optimiser to choose index in proc2 if @parameter has been changed by proc1</li>
</ul></li>
<li>Can you improve your hardware? </li>
<li>What time are you running? Is there a quieter time? </li>
<li>Is Replication Server (or other non-stop process) running? Can you suspend it? Run it eg. hourly? </li>
</ul>
|
<p>Don't prefix Stored Procedure names with "sp_" because system procedures all start with "sp_", and SQL Server will have to search harder to find your procedure when it gets called.</p>
| 3,933
|
<p>Note: The "TL smoothers" referred to in the question title are an arrangement of 8 diodes that presumably both provide a voltage drop to address the minimum current output issue of some stepper drivers described in <a href="https://hackaday.com/2016/08/29/how-accurate-is-microstepping-really/" rel="nofollow noreferrer">How Accurate Is Microstepping Really</a>, and provide flyback protection and protection of the driver from currents induced by moving the motor in the unpowered state.</p>
<p>Now, on to the question:</p>
<p>I put together a simple test part to test Y (or X) axis microstepping accuracy:</p>
<p><img src="https://i.stack.imgur.com/siHlD.png" alt="Test part design - OpenSCAD screenshot"></p>
<p>Every 1mm in the Z direction, the face steps inward 1/80 mm (corresponding to my printer's [micro]steps per mm setting) in the Y direction and 1 mm in the X direction (to clearly show where the steps happen).</p>
<p>Here are the results (two runs, near-identical output):</p>
<p><img src="https://i.stack.imgur.com/HyDve.jpg" alt="Photo of test prints lying down">
<img src="https://i.stack.imgur.com/5hJWJ.jpg" alt="Photo of test prints upright"></p>
<p>Several of the steps are missing entirely, and it's the middle vertical surface, rather than the side two stepped-vertical surfaces, that shows a step-like texture.</p>
<p>Note that layers have been printed counter-clockwise, but the design with steps on both sides is to try to reduce the impact of print orientation so as not to depend on what the slicer decides to do. Print speed was 30 mm/s for outer walls, with outer walls set to be printed first so they're not affected by already-printed inner ones.</p>
<p>This looks to me like an indication that microstepping is not working accurately, and seems to agree partly with this article: <a href="https://hackaday.com/2016/08/29/how-accurate-is-microstepping-really/" rel="nofollow noreferrer">https://hackaday.com/2016/08/29/how-accurate-is-microstepping-really/</a></p>
<p>Would TL smoothers improve this? My printer is an Ender 3, seemingly the latest revision at the time it was sold (December 2018) based on the bed and other aspects. Some threads I found suggested that this was a problem with older Ender 3s that was fixed in later revisions and that TL smoothers won't help, but it looks to me like it's not fixed.</p>
<p>Update: With settings adjusted for 0 jerk and 50 mm/s² acceleration in the outer walls, I got a somewhat improved result:</p>
<p><img src="https://i.stack.imgur.com/CtoxR.jpg" alt="New test print (lower) compared to old (upper)"></p>
<p>All steps are clearly visible, but at the reduced and more varying speed, artifacts of the extruder motor accuracy (or maybe just bowden latency) are much worse, and at the steps the "overshoot and bounce back" effect is still happening. Is this consistent with a situation where the TL smoothers I asked about could benefit?</p>
<p>Update 2: I've further tested with leaving acceleration at default (500 mm/s²) and just disabling "jerk", i.e. "instantaneous" change in speed. The results are at least as good as the above with slow acceleration. What strikes me most is that the "overshoot then bounce back" happens outward from the model on <em>both</em> edges, rather than inward on the righthand side where the (CCW moving) nozzle is turning inward. Could this indicate that there's no microstepping accuracy problem at all, and that the artifact is purely from excess extrusion as the corner is turned?</p>
<p>Updated pic (new one below):</p>
<p><img src="https://i.stack.imgur.com/jeGq0.jpg" alt="Old test piece above, new with default accel and 0 jerk below"></p>
|
<p>Is your BL Touch a v3 (likely if you've only just purchased it)? If so, make sure you're using the bugfix version of Marlin 1.1.9, which supposedly fixes the compatibility issues. I say supposedly because there's also a capacitor on the mainboard that can be removed to fix the issue, and once I removed it (and commented out the specific v3 bits in the firmware) the BLTouch performed noticeably better than when relying on the bugfix firmware alone.</p>
<p><a href="https://www.youtube.com/channel/UCbgBDBrwsikmtoLqtpc59Bw" rel="nofollow noreferrer">Teaching Tech on YouTube</a> has a few BLtouch Ender 3 videos, covering the changes for configuring the bugfix firmware and the removal of the capacitor.</p>
|
<p>I've been through the <a href="/q/6959">same sort of issues</a> and eventually found that it was attributed by the cable and connector. Re-check or re-wire the sensor, this helped me out.</p>
| 1,372
|
<p>On a quest to migrate some new UI into Managed/C# land, I have recently turned on Common Language Runtime Support (/clr) on a large legacy project, which uses MFC in a Shared DLL and relies on about a dozen other projects within our overall solution. This project is the core of our application, and would drive any managed UI code that is produced (hence the need to turn on clr support for interop). </p>
<p>After fixing a ton of little niggly errors and warnings, I finally managed to get the application to compile..
However, running the application causes an EETypeLoadException and leaves me unable to debug...</p>
<p>Doing some digging, I found the cause to be "System.TypeLoadException: Internal limitation: too many fields." which occurs right at the end of compilation. I then found <a href="http://forums.msdn.microsoft.com/en-US/vclanguage/thread/a52c3ee4-63f9-4ccd-b38c-b5cbefabc414/" rel="noreferrer">this link</a> which suggests to break the assembly down into two or more dlls. However, this is not possible in my case, as a limitation I have is that the legacy code basically remains untouched.</p>
<p>Can anyone suggest any other possible solutions? I'm really at a dead end here.</p>
|
<p>Make sure the <a href="http://msdn.microsoft.com/en-us/library/ms924287.aspx" rel="noreferrer">Enable String Pooling</a> option under C/C++ Code Generation is turned on.</p>
<p>That usually fixes this issue, which is one of those "huh?" MS limitations like the 64k limit on Excel spreadsheets. Only this one affects the number of symbols that may appear in an assembly.</p>
|
<p>I have done this with very large mixed-mode (C#/C++) applications three times (3x) and once putting the above fix into place have never seen the error again.</p>
<p>And no, if anything this should result in slightly faster run-time execution (nothing you could ever measure, however.)</p>
<p>But I agree it's somewhat of a stopgap. The internal limit on symbols didn't use to be an issue, or if it was, that limit was much higher. Then MS changed some of the loader code. I got onto MSDN and ranted about it and was told in no uncertain terms, "only an idiot would put that many symbols in a single assembly".</p>
<p>(Which is one of the reasons I no longer participate on MSDN.)</p>
<p>Well, color me stupid, but I don't think I should have to change the physical structure of my application, breaking things out into satellite DLLs, merely to get around the fact that the loader has decided 10,001 symbols is 1 too many.</p>
<p>And as you pointed out, we often don't have control over how assemblies/satellite DLLs are structure, and the sort of dependencies they contain.</p>
<p>But I don't think you'll see this error again, in any case.</p>
| 3,562
|
<p>Can anyone suggest a good implementation of a generic collection class that implements the <code>IBindingListView</code> & <code>IBindingList</code> interfaces and provides Filtering and Searching capabilities?</p>
<p>I see my current options as:<br /></p>
<ul>
<li>Using a class that someone else has written and tested</li>
<li>Inheriting from <code>BindingList<T></code>, and implementing the <code>IBindingListView</code> interfaces</li>
<li>Write a custom collection from scratch, implementing <code>IBindingListView</code> and <code>IBindingList</code>.</li>
</ul>
<p>Obviously, the first option is my preferred choice.</p>
|
<p>I used and built upon an implementation I found on and old MSDN forum post from a few years ago, but recently I searched around again and found a sourceforge project called <a href="http://blw.sourceforge.net/" rel="noreferrer">BindingListView</a>. It looks pretty nice, I just haven't pulled it in to replace my hacked version yet. </p>
<p>nuget package: <code>Equin.ApplicationFramework.BindingListView</code></p>
<p>Example code:</p>
<pre><code>var lst = new List<DemoClass>
{
new DemoClass { Prop1 = "a", Prop2 = "b", Prop3 = "c" },
new DemoClass { Prop1 = "a", Prop2 = "e", Prop3 = "f" },
new DemoClass { Prop1 = "b", Prop2 = "h", Prop3 = "i" },
new DemoClass { Prop1 = "b", Prop2 = "k", Prop3 = "l" }
};
dataGridView1.DataSource = new BindingListView<DemoClass>(lst);
// you can now sort by clicking the column headings
//
// to filter the view...
var view = (BindingListView<DemoClass>)dataGridView1.DataSource;
view.ApplyFilter(dc => dc.Prop1 == "a");
</code></pre>
|
<p>A couple of solutions I can think of:</p>
<ol>
<li><p>The <a href="http://subsonicproject.com/" rel="nofollow noreferrer">SubSonic Project </a> has a pretty nice implementation of <code>BindlingList<T></code> which is open source. Although this might require using the entire SubSonic binary to use their implementation.</p></li>
<li><p>I enjoy using the classes from the <a href="http://www.codeplex.com/PowerCollections" rel="nofollow noreferrer">Power Collections</a> project. It is fairly simple to inherit from one of the base collections there and implement <code>IBindingListView</code>.</p></li>
</ol>
| 4,879
|
<p>I want to dynamically hide/show some of the columns in a NSTableView, based on the data that is going to be displayed - basically, if a column is empty I'd like the column to be hidden. I'm currently populating the table with a controller class as the delegate for the table.</p>
<p>Any ideas? I see that I can set the column hidden in Interface Builder, however there doesn't seem to be a good time to go through the columns and check if they are empty or not, since there doesn't seem to be a method that is called before/after all of the data in the table is populated.</p>
|
<p>In Mac OS X v10.5 and later, there is the <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableColumn_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTableColumn/setHidden:" rel="noreferrer"><code>setHidden:</code> selector</a> for NSTableColumn.</p>
<p>This allows columns to be dynamically hidden / shown with the use of identifiers:</p>
<pre><code>NSInteger colIdx;
NSTableColumn* col;
colIdx = [myTable columnWithIdentifier:@"columnIdent"];
col = [myTable.tableColumns objectAtIndex:colIdx];
[col setHidden:YES];
</code></pre>
|
<p>There is no one time all the data is populated. NSTableView does not store data, it dynamically asks for it from its data source (or bound-to objects if you're using bindings). It just draws using data it gets from the data source and ditches it. You shouldn't see the table ask for data for anything that isn't visible, for example.</p>
<p>It sounds like you're using a datasource? When the data changes, it's your responsibility to call -reloadData on the table, which is a bit of a misnomer. It's more like 'invalidate everything'. </p>
<p>That is, you should already know when the data changes. That's the point at which you can compute what columns should be hidden.</p>
| 9,434
|
<p>We have several .NET applications that monitor a directory for new files, using FileSystemWatcher. The files are copied from another location, uploaded via FTP, etc. When they come in, the files are processed in one way or another. However, one problem that I have never seen a satisfactory answer for is: for large files, how does one know when the files being monitored are still being written to? Obviously, we need to wait until the files are complete and closed before we begin processing them. The event args in the FileSystemWatcher events do not seem to address this.</p>
|
<p>If you are in control on the program that is writing the files into the directory, you can have the program write the files to a temporary directory and then move them into the watched directory. The move should be an atomic operation, so the watcher shouldn't see the file until it is fully in the directory.</p>
<p>If you are not in control of what is writing to the watched directory, you can set a time in the watcher where the file is considered complete when it has remained the same size for the given time. If immediate processing isn't a concern, setting this timer to something relatively large is a fairly safe way to know that either the file is complete or it never will be.</p>
|
<p>A write lock doesn't help if the file upload failed part way through and the sender hasn't tried resending (and relocking) the file yet.</p>
| 4,994
|
<p>Presently, we've got several main projects each in their own repository. We will have to version-control up to a dozen additional projects. VisualSVN recommends to create 1 respository for our company and then vc all projects inside that. </p>
<blockquote>
<p>It's a good practice to create one repository for the entire company or department and store all your projects in this repository. Creating separate repository for each project is not a good idea because in that case you will not be able to perform Subversion operations like copy, diff and merge cross-project. <a href="http://www.visualsvn.com/support/topic/00017/" rel="nofollow noreferrer" title="Visualsvn.com">VisualSvn.com</a></p>
</blockquote>
<p>Currently we're using post-commit hooks to update the testing server with the latest commit and do other project specific actions (such as emailing certain people for one project but not for others) depending on which project has been committed.</p>
<p>As post-commit runs for the whole repository, is this still possible in such a situation? How would I go about decerning which project has changes? filter folder structure?</p>
|
<p>You can check the paths of the commited files to determine which project they belongs to. Just remember that a commit can modify several files at once, and each file could theoretically belong to a different project.</p>
|
<p>You can check the paths of the commited files to determine which project they belongs to. Just remember that a commit can modify several files at once, and each file could theoretically belong to a different project.</p>
| 9,685
|
<p>I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help menu.</p>
<p>Here is the script as it stands now:</p>
<pre><code>tell application "System Events"
tell (first process whose frontmost is true)
set helpMenuItem to menu bar item "Help" of menu bar 1
click helpMenuItem
end tell
end tell
</code></pre>
<p>And I'm thinking of something like this:</p>
<pre><code>tell application "System Events"
tell (first process whose frontmost is true)
set helpMenuItem to menu bar item "Help" of menu bar 1
set searchBox to menu item 1 of menu of helpMenuItem
if (searchBox's focused) = true then
key code 53 -- type esc
else
click helpMenuItem
end if
end tell
end tell
</code></pre>
<p>... but I get this error:</p>
<blockquote>
<p>Can’t get focused of {menu item 1 of menu "Help" of menu bar item "Help" of menu bar 1 of application process "Script Editor" of application "System Events"}.</p>
</blockquote>
<p>So is there a way I can get my script to detect whether the search box is already focused?</p>
<hr>
<p>I solved my problem by <a href="https://stackoverflow.com/questions/69391/">working around it</a>. I still don't know how to check if a menu item is selected though, so I will leave this topic open.</p>
|
<p>Using /Developer/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app you can use the built-in accessibility system to look at properties of the UI element under the mouse. Take special note of the cmd-F7 action to lock focus on an element and the Refresh button. Sadly the element and property names don't directly match those in the script suite, but you can look at the dictionary for System Events or usually guess the right terminology.</p>
<p>Using this you can determine two things. First, the <code>focused</code> property isn't on the <code>menu item</code>, but rather there is a <code>text field</code> within the <code>menu item</code> that is focused. Second, the menu item has a <code>selected</code> property.</p>
<p>With this, I came up with:</p>
<pre><code>tell application "System Events"
tell (first process whose frontmost is true)
set helpMenuItem to menu bar item "Help" of menu bar 1
-- Use reference form to avoid building intermediate object specifiers, which Accessibility apparently isn't good at resolving after the fact.
set searchBox to a reference to menu item 1 of menu of helpMenuItem
set searchField to a reference to text field 1 of searchBox
if searchField's focused is true then
key code 53 -- type esc
else
click helpMenuItem
end if
end tell
end tell
</code></pre>
<p>Though this still doesn't work. The key event isn't firing as far as I can tell, so something may still be hinky with the <code>focused</code> property on the text field.</p>
<p>Anyway, your <code>click</code> again solution seems much easier.</p>
|
<p>This worked for me to toggle between two menu items, based on which one is selected, using the "selected" property:</p>
<pre><code>tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
tell application "System Events" to tell process "System Preferences"
tell pop up button 2 of tab group 1 of window 1
click
delay 0.2
set appControl to menu item "App Controls" of menu 1
set fKeys to menu item "F1, F2, etc. Keys" of menu 1
if selected of appControl is true then
click fKeys
else
click appControl
end if
end tell
end tell
</code></pre>
| 9,448
|
<p>How can I permanently enable line numbers in IntelliJ IDEA?</p>
|
<h2>IntelliJ 14.X Onwards</h2>
<p>From version 14.0 onwards, the path to the setting dialog is slightly different, a <strong>General</strong> submenu has been added between <strong>Editor</strong> and <strong>Appearance</strong> as shown below</p>
<p><img src="https://i.stack.imgur.com/9DL9q.png" alt="enter image description here"></p>
<h2>IntelliJ 8.1.2 - 13.X</h2>
<p>From IntelliJ 8.1.2 onwards, this option is in <strong>File | Settings</strong><sup>1</sup>. Within the <strong>IDE Settings</strong> section of that dialog, you'll find it under <strong>Editor | Appearance.</strong></p>
<ol>
<li>On a Mac, these are named <strong>IntelliJ IDEA | Preferences...</strong></li>
</ol>
<p><img src="https://i.stack.imgur.com/JVZlJ.jpg" alt="enter image description here"></p>
|
<p>On Mac Intellij 12.1.2 there is no File-Settings:</p>
<p>There is an application-name menu item to the left of "File" with a "preferences" menu item:</p>
<p><img src="https://i.stack.imgur.com/veG7t.png" alt="Choosing "Preferences" on the Mac."></p>
<p>and within that is the "Settings" dialog shown by the Windows Intellij.</p>
| 3,468
|
<p>My project is based on spring framework 2.5.4. And I try to add aspects for some controllers (I use aspectj 1.5.3).</p>
<p>I've enabled auto-proxy in application-servlet.xml, just pasted these lines to the end of the xml file:</p>
<pre><code><aop:aspectj-autoproxy />
<bean id="auditLogProcessor" class="com.example.bg.web.utils.AuditLogProcessor" />
</code></pre>
<p>Created aspect:</p>
<pre><code>package com.example.bg.web.utils;
import org.apache.log4j.Logger;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class AuditLogProcessor
{
private final static Logger log = Logger.getLogger(AuditLogProcessor.class);
@After("execution(* com.example.bg.web.controllers.assets.AssetThumbnailRebuildController.rebuildThumbnail(..))")
public void afterHandleRequest() {
log.info("test111");
}
@After("execution(* com.example.bg.web.controllers.assets.AssetThumbnailRebuildController.rebuildThumbnail(..))")
public void afterRebuildThumbnail() {
log.info("test222");
}
}</code></pre>
<p>My controllers:</p>
<pre><code>class AssetAddController implements Controller
class AssetThumbnailRebuildController extends MultiActionController</code></pre>
<p>When I set brake points in aspect advisors and invoke controllers I catch only afterHandleRequest() but not afterRebildThumbnail()
What did I do wrong?</p>
<p><strong>NOTE</strong></p>
<p>I'm asking this question on behalf of my friend who doesn't have access to SO beta, and I don't have a clue what it's all about.</p>
<p><strong>EDIT</strong></p>
<p>There were indeed some misspellings, thanks Cheekysoft. But the problem still persists.</p>
|
<p>Your breakpoints aren't being hit because you are using Spring's AOP Proxies. See <a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-understanding-aop-proxies" rel="nofollow noreferrer">understanding-aop-proxies</a> for a description of how AOP Proxies are special. </p>
<p>Basically, the MVC framework is going to call the <code>handleRequest</code> method on your controller's proxy (which for example the <code>MultiActionController</code> you're using as a base class implements), this method will then make an "internal" call to its rebuildThumbnail method, but this won't go through the proxy and thus won't pick up any aspects. (This has nothing to do with the methods being final.)</p>
<p>To achieve what you want, investigate using "real" AOP via load time weaving (which Spring supports very nicely).</p>
|
<p>Is this as simple as spelling? or are there just typos in the question?
Sometimes you write <code>rebuildThumbnail</code> and sometimes you write <code>rebildThumbnail</code></p>
<p>The methods you are trying to override with advice are not final methods in the MVC framework, so whilst bpapas answer is useful, my understanding is that this is not the problem in this case. However, do make sure that the <code>rebuildThumbnail</code> controller action is not final</p>
<p>@bpapas: please correct me if I'm wrong. The programmer's own controller action is what he is trying to override. Looking at the MultiActionController source (and its parents') the only finalized method potentially in the stack is <code>MultiActionController.invokeNamedMethod</code>, although I'm not 100% sure if this would be in the stack at that time or not. Would having a finalized method higher up the stack cause a problem adding AOP advice to a method further down?</p>
| 6,073
|
<p>I recently ripped a piece off of a nitro RC car I have. Seeing as I cannot find a direct replacement at the moment, I modeled it and it seems easy to 3d print.</p>
<p>My main concern is how heat resistant the replacement will be - this is a combined structural/exhaust heat deflector piece.</p>
<p>I've previously known about 30-40% steel infused PLA, but looking at the reviews/overviews everyone states there is no structural advantage to steel/metal infused PLA.</p>
<p>That being said, are there any benefits at all, aside from styling? Temperature resistance, conductivity, stiffness, toughness?</p>
|
<blockquote>
<p>I have heard that it is best to use a raft</p>
</blockquote>
<p>Actually, it is not best to use a raft, a raft is an aid that can best be used in special cases, e.g. for filaments that shrink reasonably (PLA is not such a filament).</p>
<p>A raft always caused a rough bottom of your print and is frequently difficult to remove. A raft is an aid for adhesion if your print object geometry or choice of filament requires you to use it, but as far as printing PLA, a raft is generally not needed. You need to spend some time to level the bed properly and dial in the best nozzle to bed distance (the thickness of a sheet of plain printing paper like A4 or US Letter will work fine).</p>
<p>There are usually options available in slicer software to control the distance between the raft and the first layer of the print object. It is also reported that inserting a wait time to solidify/cool the raft is beneficial for creating less strong bonds between the raft and the print object.</p>
|
<p>Rafts fuse with models because the filament gets overheated. To avoid this, keep the temperature in the room between between 23 and 28 °C. Malfunctioning extruder fans, a heater & thermocouple, extruder printed circuit board (PCB), extruder cable, and motherboard can be also to blame.</p>
| 2,162
|
<p>I have a simple page with my <code>ScriptManager</code> and my <code>UpdatePanel</code>, and my <code>ContentTemplate</code> has one <code>ListBox</code> and one Label. I am just trying to catch its <code>OnSelectionChanged</code> so I can update the text in the <code>Label</code>. No matter what settings I try to tweak, I always get a full-page postback.</p>
<p>Is this really not going to work, or am I just screwing this up?</p>
|
<p>You need to have Sharepoint 2007 service pack 1 -- or else there's no chance.
(Sharepoint 2007 predates ajax 1.0 -- they built some support into service pack 1)</p>
<p>Next, from a trouble shooting point of view, test that the <strong>exact</strong> same code functions as expected when hosted in a regular asp.net page. (Literally copy and paste your code across into a fresh page, to rule out any typographical errors). Ruling sharepoint in or out of the problem area will help narrow down the solution space.</p>
|
<p>There's a specific problem with mixing doPostback, UpdatePanel and SharePoint -- and the symptom is exactly what you're seeing: a full-page postback instead of an asynchronous postback. See this KB article for a workaround: <a href="http://support.microsoft.com/kb/941955" rel="nofollow noreferrer">http://support.microsoft.com/kb/941955</a></p>
| 2,524
|
<p>I just started to learn Ruby and as a .Net developer, I'm wondering if I should just go straight ahead and use IronRuby, without trying some pure Ruby first.</p>
<p>What do you think? Will I be missing anything?</p>
<p>-- rauchy</p>
|
<p>I would use pure ruby (Matz Ruby Interpreter (MRI)) to start off. My understanding is that iron ruby is not quite ready yet.</p>
<p>If you are looking for a good book my current favorite (over pickaxe) is <a href="https://rads.stackoverflow.com/amzn/click/com/0596516177" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/gp/product/0596516177</a> by matz and flanagan, the book is very concise well written paragraphs and they provide great examples (in 1.8.* and 1.9) </p>
<p>Enjoy! :D</p>
|
<p>I know this is an old question, but I'd like to say that four years later (today), the JRuby implementation is certainly far enough advanced to be worth starting with.</p>
| 9,482
|
<p>How do you set up your .NET development tree? I use a structure like this:</p>
<pre><code>-projectname
--config (where I put the configuration files)
--doc (where I put all the document concerning the project: e-mails, documentation)
--tools (all the tools I use: Nunit, Moq)
--lib (all the libraries used by the solution: ninject or autofac)
--src
---app (sourcefiles)
---test (unittests)
solutionfile.sln
build.csproj
</code></pre>
<p>The sign "-" marks directories.</p>
<p>I think it's very important to have a good structure on this stuff. You should be able to get the source code from the source control system and then build the solution without opening Visual Studio or installing any third party libraries. </p>
<p>Any thoughts on this?</p>
|
<p>We use a very similar layout as covered in JP Boodhoo's blog post titled <a href="http://blog.developwithpassion.com/2007/10/01/directory-structure-for-projects/" rel="nofollow noreferrer">Directory Structure For Projects</a>.</p>
|
<p>At my place of work we have multiple projects, where each project gets its own sub-directory, like so:
-proj1<br>
--proj1.csproj<br>
-proj2<br>
--proj2.csproj<br>
-proj3<br>
--proj3.csproj<br>
solutionfile.sln </p>
<p>The rest of your setup looks okay, but I think you should figure out how you would incorporate multiple projects, for example a shared source library between multiple solutions.</p>
| 9,714
|
<p>I've written some applications than heavily use network, and I would like to test it over a slow network. I'm looking for a tool to simulate these kind of connections.</p>
<p>I'm only interested in Windows tools.</p>
|
<p>I've used <a href="http://bandwidthcontroller.com/trafficShaperXp.html" rel="nofollow noreferrer">Traffic Shaper XP</a> on my XP dev box at work. It seems to handle any connection (not just HTTP). It wasn't perfect, but worked well enough for the tests I was doing. If you're on Windows maybe it'll do enough for you.</p>
|
<p>You're right. dummynet works only in FreeBSD, it's actually built into the kernel.</p>
<p>What I did when I used it was grab an older PC nobody used anymore and install the <a href="http://www.freebsd.org/releases/7.0R/announce.html" rel="nofollow noreferrer">FreeBSD distribution</a>.</p>
| 6,016
|
<p>I have a div with <code>id="a"</code> that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with a given prefix and then add a new one. If I want to remove all of the classes that begin with "bg", how do I do that? Something like this, but that actually works:</p>
<pre><code>$("#a").removeClass("bg*");
</code></pre>
|
<p>With jQuery, the actual DOM element is at index zero, this should work</p>
<pre><code>$('#a')[0].className = $('#a')[0].className.replace(/\bbg.*?\b/g, '');
</code></pre>
|
<pre><code>$("#element").removeAttr("class").addClass("yourClass");
</code></pre>
| 8,223
|
<p>I have an option to purchase a hobby multi-purpose device (lathe/mill/drill/grinder/cutter) which is manually controlled, but easily converted for driving by stepper motors (all 3 axis are controlled by turning knobs that can be replaced by gears, with convenient mount to couple each to a stepper motor). I have the right motors and can easily obtain drivers for them.</p>
<p><a href="https://i.stack.imgur.com/7zCMv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7zCMv.jpg" alt="pic of various configurations of the machine"></a></p>
<p>That is the way to overcome the worst problem of converting Prusa to CNC: the flimsy mechanics not able to withstand stress and vibrations of machining. Then I can connect the drivers to the 3 axis of Prusa's electronics, optionally connect some driver of the spindle to the extruder output (or just control it manually), and it seems the hardware side of the device is done.</p>
<p>The problem is the rest - adapting the software. RepRap family of 3D printers being open source means their software and hardware <em>can</em> be adapted. It's only a matter of <em>how hard</em> it is.</p>
<p>Does anyone have any experience in that direction? What would such conversion involve? Just recalibration to the new gear/leadscrew ratios, or something more involved, like editing the sources to get rid of all the temperature safeguards and the likes?</p>
|
<h2>Disclaimer</h2>
<p>Questions about other machines is still in kind of a grey area right now <sup>06/2016</sup> and your question is, in my opinion, a bit too broad. However, I think it's a great topic to perhaps help direct the scope of this community.</p>
<h2>The lowdown</h2>
<ol>
<li>3D printers, CNC Mills, CNC Lathes, CNC Routers, and Lasers are all very different! There are certainly areas where each of these may overlap, but the methodology is very different overall.</li>
<li>Software is not always interchangeable across machines (even within the same machine type) due to hardware requirements/communication.</li>
<li>Hardware is not always interchangeable across machines (even within the same machine type) due to design/scope of the purpose of the machine.</li>
</ol>
<h2>Things to consider</h2>
<p><sub>(In a nut-shell)</sub></p>
<p><strong>3D Printers</strong></p>
<p><em>Hardware</em></p>
<ul>
<li>Minimal speed/torque requirements compared to subtractive machine tools.</li>
<li>Good designs focus on temperature control via enclosures and/or electronics.</li>
<li>(Typically) uses heat block/nozzle/stepper motor to control material size/flow.</li>
</ul>
<p><em>Software</em></p>
<ul>
<li>Emphasis on "plug-n-play" UI/UX</li>
<li>Conceptually easier to generate tool paths. STL's provide outlines and software fills in the blanks like a coloring book.</li>
<li>Focus is on understanding material properties and temperature variability.</li>
</ul>
<p><em>Common Variability</em></p>
<ul>
<li>Material quality/shape</li>
<li>Environment temperature</li>
</ul>
<p><strong>CNC Mills/Routers/Lathes</strong></p>
<p><em>Hardware</em></p>
<ul>
<li>Maximum speed/torque requirements.</li>
<li>Good designs focus on rigid designs and handling harmonics.</li>
<li>Tighter tolerance components to ensure mechanical repeatability.</li>
<li>Relies on cutting tool size/shape to control material size/flow.</li>
</ul>
<p><em>Software</em></p>
<ul>
<li>Requires more manual input (typically) to account for where its tool is located. The mathematics heavily depend on accurate dimensions for the cutting tools, otherwise you could damage your part or the machine.</li>
<li>Good software allows many different "canned" tool paths for efficiency, tool types, and achieving desired surface finish.</li>
<li>Focus is on variability in cutting tool and speeds/feeds (as recommended by cutting tool suppliers for materials)</li>
</ul>
<p><em>Common Variability</em></p>
<ul>
<li>Material shape/hardness</li>
<li>Cutting tool shape/hardness</li>
<li>Cutting tool path</li>
</ul>
<p><strong>Lasers</strong></p>
<p><em>Hardware</em></p>
<ul>
<li>Minimal speed/torque requirements.</li>
<li>Good designs focus on consistent beam quality and spot focus, which is relative to constant power.</li>
<li>Uses focusing lens (sets spot size) to control material size.</li>
</ul>
<p><em>Software</em></p>
<ul>
<li>Emphasis on "plug-n-play" UI/UX and interoperability.</li>
<li>Dimensions are easier to achieve as less variability in the process compared to 3D printing/machining.</li>
<li>Focus is on laser power (typically for material type and depth).</li>
</ul>
<p><em>Common Variability</em></p>
<ul>
<li>Laser type</li>
<li>Spot size</li>
<li>Power supply</li>
</ul>
<h2>Summary</h2>
<p>Overall there are many, very different variables to consider between these technologies. I only focused on variables you might see out of a hobbyist-style machine and if you've operated any of these you'll know that there are many more variables that pop up for any of these machines.</p>
<p>So, do not expect such a plug-n-play solution as each machine requires quality construction of its <em><strong>hardware</strong></em>, the ability to handle the variability of the process in its <em><strong>software</strong></em>, and, above all, an <em><strong>operator</strong></em> that understands the correlation and balance of these components.</p>
<p>All of that being said, there are some machines that seem to be tailored to this such as the machine by <a href="http://www.diyouware.com/" rel="nofollow noreferrer">Diyouware</a> and <a href="https://zmorph3d.com/" rel="nofollow noreferrer">ZMorph</a> <sub>(No affiliation, just examples)</sub>. However, notice that they have created their own software to meet a lot of these communication requirements.</p>
<p><strong>Update</strong>
I forgot to mention the fact that a kink in creating a interchangeable machine is the control interface. The controller converts the "software speak" into an easily parsed series of functions (typically G-Code) for the small computer to process its predetermined hardware processes. Ie, The slicer or CAM software determines that a layer of a circle be 3D printed, milled, routered, or lasered, so the controller should <strong>G02I2</strong> which could parse to <sub>(For all intents and purposes in javascript, not a practical language)</sub> <code>CWCircularInterpolation(2,null,null,null,null,null)</code> and run as:</p>
<pre><code>function CWCircularInterpolation(i,j,k,x,y,z){
//Some code to take current position and command to create a canned circle path
}
</code></pre>
<p>The point is that the software needs to handle the conditions and constraints of a different machining process and provide a well-equipped machine with the right commands. There are a lot of <em>different</em> things to consider in attempting to combine these machining techniques into a single machine and get quality results.</p>
|
<p>I haven't done this myself. But the temperature safeguards only apply to the 4th, the E axis for the filament. So configuring the right steps per mm would get you started.</p>
<p>The question is more what do you want to do with it and where do you get the G-Code to do that. You can not use a slicer to generate the G-Code for you.</p>
<p>But there is software for PCB Milling out there that should work with the configured Firmware.</p>
| 324
|
<p>I am facing a problem with .NET generics. The thing I want to do is saving an array of generics types (GraphicsItem):</p>
<pre><code>public class GraphicsItem<T>
{
private T _item;
public void Load(T item)
{
_item = item;
}
}
</code></pre>
<p>How can I save such open generic type in an array?</p>
|
<p>Implement a non-generic interface and use that:</p>
<pre><code>public class GraphicsItem<T> : IGraphicsItem
{
private T _item;
public void Load(T item)
{
_item = item;
}
public void SomethingWhichIsNotGeneric(int i)
{
// Code goes here...
}
}
public interface IGraphicsItem
{
void SomethingWhichIsNotGeneric(int i);
}
</code></pre>
<p>Then use that interface as the item in the list:</p>
<pre><code>var values = new List<IGraphicsItem>();
</code></pre>
|
<p>If you want to store heterogeneous GrpahicsItem's i.e. GraphicsItem< X> and GrpahicsItem< Y> you need to derive them from common base class, or implement common interface. Another option is to store them in List< object></p>
| 8,274
|
<p>I have a Tevo Tarantula 3D printer.</p>
<p>I'm trying to print a calibration cube. </p>
<p>The slicer is Cura and is set for a 1.75 mm filament extruded by a nozzle of 0.4 mm, with a heat bed temperature of 60°C and extruder 200°C. </p>
<p>As seen in the image I stopped the printer after a minute, when I noticed that the filament wasn't sticking to the hotbed. </p>
<p><a href="https://i.stack.imgur.com/zdPaw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zdPaw.jpg" alt="Photo of filament not adhering the printbed"></a></p>
<p>I've also made other tests, but the result is the same - the upper right part of the print lifts and touches the moving nozzle. </p>
<p>How could I resolve this? Any advice? </p>
|
<p>I don't have this specific printer but this used to happen to me as well on my D-Bot. The reason being bed not being leveled properly. Ensure that your bed is leveled such that the distance between the nozzle and bed is about 0.2mm after homing. Also coat your bed with something sticky like glue or hairspray. You won't need this if you are using a PEI sheet. </p>
|
<p>I've cleaned the heated bed as suggested using ethanol,
then I've tested the Z distance of the nozzle from the bed with a paper sheet and it was ok. Lastly, I tried to raise the temperature of the extruder for the first layer to 215°C. I think that this did the trick.</p>
| 591
|
<p>Hey, I'm using <a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="nofollow noreferrer">Levenshteins</a> algorithm to get distance between source and target string.</p>
<p>also I have method which returns value from 0 to 1:</p>
<pre><code>/// <summary>
/// Gets the similarity between two strings.
/// All relation scores are in the [0, 1] range,
/// which means that if the score gets a maximum value (equal to 1)
/// then the two string are absolutely similar
/// </summary>
/// <param name="string1">The string1.</param>
/// <param name="string2">The string2.</param>
/// <returns></returns>
public static float CalculateSimilarity(String s1, String s2)
{
if ((s1 == null) || (s2 == null)) return 0.0f;
float dis = LevenshteinDistance.Compute(s1, s2);
float maxLen = s1.Length;
if (maxLen < s2.Length)
maxLen = s2.Length;
if (maxLen == 0.0F)
return 1.0F;
else return 1.0F - dis / maxLen;
}
</code></pre>
<p>but this for me is not enough. Because I need more complex way to match two sentences.</p>
<p>For example I want automatically tag some music, I have original song names, and i have songs with trash, like <em>super, quality,</em> years like <em>2007, 2008,</em> etc..etc.. also some files have just <a href="http://trash..thash..song_name_mp3.mp3" rel="nofollow noreferrer">http://trash..thash..song_name_mp3.mp3</a>, other are normal. I want to create an algorithm which will work just more perfect than mine now.. Maybe anyone can help me?</p>
<p>here is my current algo:</p>
<pre><code>/// <summary>
/// if we need to ignore this target.
/// </summary>
/// <param name="targetString">The target string.</param>
/// <returns></returns>
private bool doIgnore(String targetString)
{
if ((targetString != null) && (targetString != String.Empty))
{
for (int i = 0; i < ignoreWordsList.Length; ++i)
{
//* if we found ignore word or target string matching some some special cases like years (Regex).
if (targetString == ignoreWordsList[i] || (isMatchInSpecialCases(targetString))) return true;
}
}
return false;
}
/// <summary>
/// Removes the duplicates.
/// </summary>
/// <param name="list">The list.</param>
private void removeDuplicates(List<String> list)
{
if ((list != null) && (list.Count > 0))
{
for (int i = 0; i < list.Count - 1; ++i)
{
if (list[i] == list[i + 1])
{
list.RemoveAt(i);
--i;
}
}
}
}
/// <summary>
/// Does the fuzzy match.
/// </summary>
/// <param name="targetTitle">The target title.</param>
/// <returns></returns>
private TitleMatchResult doFuzzyMatch(String targetTitle)
{
TitleMatchResult matchResult = null;
if (targetTitle != null && targetTitle != String.Empty)
{
try
{
//* change target title (string) to lower case.
targetTitle = targetTitle.ToLower();
//* scores, we will select higher score at the end.
Dictionary<Title, float> scores = new Dictionary<Title, float>();
//* do split special chars: '-', ' ', '.', ',', '?', '/', ':', ';', '%', '(', ')', '#', '\"', '\'', '!', '|', '^', '*', '[', ']', '{', '}', '=', '!', '+', '_'
List<String> targetKeywords = new List<string>(targetTitle.Split(ignoreCharsList, StringSplitOptions.RemoveEmptyEntries));
//* remove all trash from keywords, like super, quality, etc..
targetKeywords.RemoveAll(delegate(String x) { return doIgnore(x); });
//* sort keywords.
targetKeywords.Sort();
//* remove some duplicates.
removeDuplicates(targetKeywords);
//* go through all original titles.
foreach (Title sourceTitle in titles)
{
float tempScore = 0f;
//* split orig. title to keywords list.
List<String> sourceKeywords = new List<string>(sourceTitle.Name.Split(ignoreCharsList, StringSplitOptions.RemoveEmptyEntries));
sourceKeywords.Sort();
removeDuplicates(sourceKeywords);
//* go through all source ttl keywords.
foreach (String keyw1 in sourceKeywords)
{
float max = float.MinValue;
foreach (String keyw2 in targetKeywords)
{
float currentScore = StringMatching.StringMatching.CalculateSimilarity(keyw1.ToLower(), keyw2);
if (currentScore > max)
{
max = currentScore;
}
}
tempScore += max;
}
//* calculate average score.
float averageScore = (tempScore / Math.Max(targetKeywords.Count, sourceKeywords.Count));
//* if average score is bigger than minimal score and target title is not in this source title ignore list.
if (averageScore >= minimalScore && !sourceTitle.doIgnore(targetTitle))
{
//* add score.
scores.Add(sourceTitle, averageScore);
}
}
//* choose biggest score.
float maxi = float.MinValue;
foreach (KeyValuePair<Title, float> kvp in scores)
{
if (kvp.Value > maxi)
{
maxi = kvp.Value;
matchResult = new TitleMatchResult(maxi, kvp.Key, MatchTechnique.FuzzyLogic);
}
}
}
catch { }
}
//* return result.
return matchResult;
}
</code></pre>
<p>This works normally but just in some cases, a lot of titles which should match, does not match... I think I need some kind of formula to play with weights and etc, but i can't think of one.. </p>
<p>Ideas? Suggestions? Algos?</p>
<p>by the way I already know this topic (My colleague already posted it but we cannot come with a proper solution for this problem.):
<a href="https://stackoverflow.com/questions/49263/approximate-string-matching-algorithms">Approximate string matching algorithms</a></p>
|
<p>Your problem here may be distinguishing between noise words and useful data:</p>
<ul>
<li>Rolling_Stones.Best_of_2003.Wild_Horses.mp3</li>
<li>Super.Quality.Wild_Horses.mp3</li>
<li>Tori_Amos.Wild_Horses.mp3</li>
</ul>
<p>You may need to produce a dictionary of noise words to ignore. That seems clunky, but I'm not sure there's an algorithm that can distinguish between band/album names and noise.</p>
|
<p>There is a <a href="https://github.com/kdjones/fuzzystring" rel="nofollow noreferrer">GitHub repo</a> implementing several methods.</p>
| 7,695
|
<p>I'm trying to run PHP from the command line under <a href="https://en.wikipedia.org/wiki/Windows_XP" rel="nofollow noreferrer">Windows XP</a>.</p>
<p>That works, except for the fact that I am not able to provide parameters to my PHP script.</p>
<p>My test case:</p>
<pre><code>echo "param = " . $param . "\n";
var_dump($argv);
</code></pre>
<p>I want to call this as:</p>
<pre><code>php.exe -f test.php -- param=test
</code></pre>
<p>But I never get the script to accept my parameter.</p>
<p>The result I get from the above script:</p>
<blockquote>
<p>PHP Notice: Undefined variable: param in C:\test.php on line 2</p>
</blockquote>
<pre><code>param = ''
array(2) {
[0]=> string(8) "test.php"
[1]=> string(10) "param=test"
}
</code></pre>
<p>I am trying this using PHP 5.2.6. Is this a bug in PHP 5?</p>
<p>The parameter passing is handled in the <a href="http://us3.php.net/features.commandline" rel="nofollow noreferrer">online help</a>:</p>
<blockquote>
<p>Note: If you need to pass arguments to your scripts you need to pass -- as the first argument when using the -f switch.</p>
</blockquote>
<p>This seemed to be working under PHP 4, but not under PHP 5.</p>
<p>Under PHP 4 I could use the same script that could run on the server without alteration on the command line. This is handy for local debugging, for example, saving the output in a file, to be studied.</p>
|
<p>Why do you have any expectation that <em>param</em> will be set to the value?</p>
<p>You're responsible for parsing the command line in the fashion you desire, from the <em>$argv</em> array.</p>
|
<p>You can use the $argv array. Like this:</p>
<pre><code><?php
echo $argv[1];
?>
</code></pre>
<p>Remember that the first member of the <em>$argv</em> array (which is <em>$argv[0]</em>) is the name of the script itself, so in order to use the parameters for the application, you should start using members of the <em>$argv[]</em> from the '1'th index.</p>
<p>When calling the application, use this syntax:</p>
<pre><code>php myscript.php -- myValue
</code></pre>
<p>There isn't any need to put a name for the parameter. As you saw, what you called the <em>var_dump()</em> on the <em>$argv[]</em>, the second member (which is the first parameter) was the string <em>PARAM=TEST</em>. Right? So there isn't any need to put a name for the param. Just enter the <em>param</em> value.</p>
| 9,095
|
<p>I would like to have a nice template for doing this in development. How do I reset an increment identity's starting value in SQL Server?</p>
|
<pre><code>DBCC CHECKIDENT('TableName', RESEED, 0)
</code></pre>
|
<p>To set the identity to 100:</p>
<pre><code>DBCC CHECKIDENT (MyTable, RESEED, 100)
</code></pre>
| 3,769
|
<p>What is the best way to vertically center the content of a div when the height of the content is variable. In my particular case, the height of the container div is fixed, but it would be great if there were a solution that would work in cases where the container has a variable height as well. Also, I would love a solution with no, or very little use of CSS hacks and/or non-semantic markup.</p>
<p><img src="https://content.screencast.com/users/jessegavin/folders/Jing/media/ba5c2688-0aad-4e89-878a-8911946f8612/2008-09-12_1027.png" alt="alt text"></p>
|
<p>Just add</p>
<pre><code>position: relative;
top: 50%;
transform: translateY(-50%);
</code></pre>
<p>to the inner div.</p>
<p>What it does is moving the inner div's top border to the half height of the outer div (<code>top: 50%;</code>) and then the inner div up by half its height (<code>transform: translateY(-50%)</code>). This will work with <code>position: absolute</code> or <code>relative</code>.</p>
<p>Keep in mind that <code>transform</code> and <code>translate</code> have vendor prefixes which are not included for simplicity.</p>
<p>Codepen: <a href="http://codepen.io/anon/pen/ZYprdb" rel="noreferrer">http://codepen.io/anon/pen/ZYprdb</a></p>
|
<p>This is my awesome solution for a <code>div</code> with a dynamic (percentaged) height.</p>
<p><strong>CSS</strong></p>
<pre class="lang-css prettyprint-override"><code>.vertical_placer{
background:red;
position:absolute;
height:43%;
width:100%;
display: table;
}
.inner_placer{
display: table-cell;
vertical-align: middle;
text-align:center;
}
.inner_placer svg{
position:relative;
color:#fff;
background:blue;
width:30%;
min-height:20px;
max-height:60px;
height:20%;
}
</code></pre>
<p><strong>HTML</strong></p>
<pre><code><div class="footer">
<div class="vertical_placer">
<div class="inner_placer">
<svg> some Text here</svg>
</div>
</div>
</div>
</code></pre>
<p><a href="http://jsfiddle.net/hunter74/oosb3s8w/1/" rel="nofollow">Try this by yourself.</a></p>
| 8,387
|
<p>If you have two versions of the same report (.rpt) and you want to establish what the exact differences are, what is the best way to go about this? I've seen some commercial tools to do this, but I'm not too interested in forking out cash for something that should be relatively straight forward. Can I hook into the Crystal API and simply list all of the properties of every field or something? Please someone tell me that there's an Open Source project somewhere that does this... @:-)</p>
<p>@Kogus, wouldn't diffing the outputs as text hide any formatting differences?</p>
<p>@ladoucep, I don't seem to be able to export the report <em>without</em> data.</p>
|
<blockquote>
<p>Can I hook into the Crystal API and
simply list all of the properties of
every field or something? Please
someone tell me that there's an Open
Source project somewhere that does
this... @:-)</p>
</blockquote>
<p>There is in fact, such an API. I wrote a VB6 application to do just what you asked and more. I think I even migrated it to VB.Net. As it was for my own use, I didn't spend much time making it 'polished'. I've been intending to release it, but I haven't had the time...</p>
<p>Another approach that I've used in the past is to create an Access application to help manage large, report-development projects. One of it's many features includes the ability to extract the tables that are used by the report, and the SQL statements used by its Commands and SQL Expressions. It's intent is to give one a global perspective of which reports use which tables. I probably still have it somewhere...</p>
<p>** edit 1 **</p>
<p>BusinessObjects Enterprise XI (R?) has a feature named 'Meta Manager'. It will periodically examine the contents of the Repository and save the results to a database. It uses the Report-Application Service (RAS) to generate the meta data. It's an additional, 5-figure license, of course.</p>
<p>** edit 2 **</p>
<p>Consider using PowerShell to do the work: <a href="https://github.com/craibuc/PsCrystal" rel="noreferrer">PsCrystal</a>.</p>
|
<p>One helpful technique is to output both versions of the report to plain text, then diff those outputs.</p>
<p>You could write something using the crystal report component to describe every property of the report, like you described. Then you could output <em>that</em> to text, and diff <em>those</em>. I'm not aware of any open source tool that does it for you, but it would not be terribly hard to write it.</p>
<p>@question in the post:
Diffing the outputs would only show formatting changes if the <em>relative</em> positions had changed. For example, if i had this:</p>
<p>before:
First name, last name, addresss</p>
<p>after:
Last Name, First Name, Address</p>
<p>Then that would show up as a difference.</p>
<p>But if I had just bumped the address column over a few pixels, or changed it from plain text to bold, then you are right, that would not show up.</p>
| 4,030
|
<p>What's the best way to determine which version of the .NET Compact Frameworks (including Service Packs) is installed on a device through a .NET application. </p>
|
<p>I have battled this problem myself last week and consider myself somewhat of an expert now ;)</p>
<p>I'm 99% sure that not all dlls and static libraries were recompiled with the SP1 version. You need to put</p>
<pre><code>#define _BIND_TO_CURRENT_MFC_VERSION 1
#define _BIND_TO_CURRENT_CRT_VERSION 1
</code></pre>
<p>into <em>every</em> project you're using. For every project of a real-world size, it's very easy to forget some small lib that wasn't recompiled.</p>
<p>There are more flags that define what versions to bind to; it's documented on <a href="http://msdn.microsoft.com/en-us/library/cc664727%28v=vs.90%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc664727%28v=vs.90%29.aspx</a> . As an alternative to the lines above, you can also put</p>
<pre><code>#define _BIND_TO_CURRENT_VCLIBS_VERSION 1
</code></pre>
<p>which will bind to the latest version of all VC libs (CRT, MFC, ATL, OpenMP).</p>
<p>Then, check what the embedded manifest says. Download XM Resource Editor: <a href="http://www.wilsonc.demon.co.uk/d10resourceeditor.htm" rel="nofollow noreferrer">http://www.wilsonc.demon.co.uk/d10resourceeditor.htm</a>. Open every dll and exe in your solution. Look under 'XP Theme Manifest'. Check that the 'version' attribute on the right-hand side is '9.0.30729.1'. If it's '9.0.21022', some static library is pulling in the manifest for the old version.</p>
<p>What I found is that in many cases, <em>both</em> versions were included in the manifest. This means that some libraries use the sp1 version and others don't.</p>
<p>A great way to debug which libraries don't have the preprocessor directives set: temporarily modify your platform headers so that compilation stops when it tries to embed the old manifest. Open C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\include\crtassem.h. Search for the '21022' string. In that define, put something invalid (change 'define' to 'blehbleh' or so). This way, when you're compiling a project where the <code>_BIND_TO_CURRENT_CRT_VERSION</code> preprocessor flag is not set, your compilation will stop and you'll know that you need to add them or made sure that it's applied everywhere.</p>
<p>Also make sure to use Dependency Walker so that you know what dlls are being pulled in. It's easiest to install a fresh Windows XP copy with no updates (only SP2) on a virtual machine. This way you know for sure that there is nothing in the SxS folder that is being used instead of the side-by-side dlls that you supplied.</p>
|
<p>I just remembered another trick that I used to find out which static libraries were ill-behaving: 'grep' through the static libraries for the string '21022'. HOWEVER, don't use the 'normal' grep tools like wingrep because they won't show you these strings (they think it's a binary file and look for the raw, non-unicode string). Use the 'strings' utility from the resource kit (now in the Russinovich site I think). That one will grep through binaries ok. So you let this 'strings' go through your whole source tree and you'll see the binary files (dlls and static libraries) that contain references to the wrong manifest (or to the manifest with the wrong version in it).</p>
| 8,427
|
<p>I was wondering if anyone knew of any limitations to using Windows XP as a File and SQL server. I am asking because one of the applications we sell, requires the customer to setup a server for filesharing and as a SQL Server. We already allow them to use SQL Express, but we wanted to see if we can suggest Windows XP as a low cost alternative to Windows Server. The only potential problem that I could see if there were limits on the number of concurrent connections to either the files or the database. We are only thinking of recommending this for smaller sized companies who would have 10-15 users.</p>
|
<p>There is a <a href="http://support.microsoft.com/default.aspx?kbid=314882" rel="nofollow noreferrer">limit of 10 inbound connections</a> on XP professional, and 5 on XP Home. So it would only be practicable for a very small company.</p>
|
<p>Presumably you are meaning SQL Express, as you can't run SQL Server on XP, it's a server product.</p>
<p>If the customer can afford your product, they can afford a copy of Server 2003, or whatever, the file sharing's built-in. Admittedly SQL Server's fairly expensive, but if your product needs it, that's the way it goes. If cost were an issue, you shouldn't be using SQL Server as the database platform. There's no point in trying to force a server-based solution into a client OS. You'll end up with all sorts of problems before long. </p>
<p>Doesn't the client have a domain-based infrastructure already?</p>
<p>The upshot being being if the client has 5-10 users of the software, they should be on SBS anyway for a variety of other reasons. You don't get SQL Server with it though.</p>
<p>(Samba would be an option for file-sharing, but doubtless more expensive than simply buying Server 2003 in this instance).</p>
| 7,585
|
<p>When I originally was introduced to Mocks I felt the primary purpose was to mock up objects that come from external sources of data. This way I did not have to maintain an automated unit testing test database, I could just fake it.</p>
<p>But now I am starting to think of it differently. I am wondering if Mocks are more effective used to completely isolate the tested method from anything outside of itself. The image that keeps coming to mind is the backdrop you use when painting. You want to keep the paint from getting all over everything. I am only testing that method, and I only want to know how it reacts to these faked up external factors?</p>
<p>It seems incredibly tedious to do it this way but the advantage I am seeing is when the test fails it is because it is screwed up and not 16 layers down. But now I have to have 16 tests to get the same testing coverage because each piece would be tested in isolation. Plus each test becomes more complicated and more deeply tied to the method it is testing.</p>
<p>It feels right to me but it also seems brutal so I kind of want to know what others think.</p>
|
<p>I recommend you take a look at Martin Fowler's article <a href="http://www.martinfowler.com/articles/mocksArentStubs.html" rel="noreferrer"><em>Mocks Aren't Stubs</em></a> for a more authoritative treatment of Mocks than I can give you.</p>
<p>The purpose of mocks is to unit test your code in isolation of dependencies so you can truly test a piece of code at the "unit" level. The code under test is the real deal, and every other piece of code it relies on (via parameters or dependency injection, etc) is a "Mock" (an empty implementation that always returns expected values when one of its methods is called.)</p>
<p>Mocks may seem tedious at first, but they make Unit Testing far easier and more robust once you get the hang of using them. Most languages have Mock libraries which make mocking relatively trivial. If you are using Java, I'll recommend my personal favorite: <a href="http://www.easymock.org/" rel="noreferrer">EasyMock.</a></p>
<p>Let me finish with this thought: you need integration tests too, but having a good volume of unit tests helps you find out which component contains a bug, when one exists.</p>
|
<p>Mock objects are 1) often used as a means to isolate the code under test, BUT 2) as keithb already pointed out, are important to "<a href="http://blog.dannorth.net/2008/09/14/the-end-of-endotesting/#comment-7954" rel="nofollow noreferrer">focus on the relationships between collaborating objects</a>". This article gives some insights and history related to the subject: <a href="http://www.methodsandtools.com/archive/archive.php?id=90" rel="nofollow noreferrer">Responsibility Driven Design with Mock Objects</a>.</p>
| 8,373
|
<p>I know I could write scripts and create jobs to run them, but at least some of what I'm wanting it to do is beyond my programming abilities for that to be an option.</p>
<p>What I'm imagining is something that can run on a regular schedule that will examine all the databases on a server and automatically shrink data and log files (after a backup, of course) when they've reached a file size that contains too much free space. It would be nice if it could defrag index files when they've become too fragmented as well.</p>
<p>I guess what I'm probably looking for is a DBA in a box! </p>
<p>Or it could just be that I need better performance monitoring tools instead. I know how to take care of both of those issues, but it's more that I forget to check for those issues until I start seeing performance issues with my apps.</p>
|
<p>If you are using SQL Server 2005. Fire up the Management Studio and look at the Maintenance Plan section.</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/ms189036.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms187658.aspx</a> for an overview and <a href="http://msdn.microsoft.com/en-us/library/ms189036.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms189036.aspx</a> for details on the Maintenance plan wizard.</p>
<p>Finally, <a href="http://msdn.microsoft.com/en-us/library/ms140255.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms140255.aspx</a> is a list of all the maintenance tasks available.</p>
<p>I am pretty sure this is all available even in the Express Edition. I can't speak to if anything has changed in 2008, I haven't used it yet.</p>
|
<p>yeah everything you described (except maybe perf monitoring) can be done with database maintenance plans, back ups, shrinking log files etc.</p>
| 4,300
|
<p>I have been using Eclipse as an IDE for a short amount of time (about 3 months of full use) and almost every day I learn about some shortcut or feature that I had absolutely no idea about. For instance, just today I learned that <kbd>Ctrl</kbd>+<kbd>3</kbd> was the shortcut for a Quick Access window.</p>
<p>I was wondering what your most useful/favorite Eclipse features are. With the IDE being so big, it would be helpful to learn about the more commonly used parts of the program.</p>
|
<p>My most commonly used features are</p>
<p><kbd>ctrl</kbd>+<kbd>1</kbd> quick-fix / spell-checker</p>
<p>opening files</p>
<ul>
<li><kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>t</kbd> load class file by classname</li>
<li><kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>r</kbd> load any file by filename</li>
</ul>
<p>matches are made on the start of the class/filename. start your search pattern with a * to search anywhere within the filename/classname.</p>
<p>Formatting</p>
<ul>
<li><kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>f</kbd> Format source file
(set up your formatting style in Window | preferences | java | code style | formatter)</li>
<li><kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>o</kbd> Organise imports</li>
</ul>
<p>Generated code</p>
<ul>
<li><kbd>alt</kbd>+<kbd>s</kbd>,<kbd>r</kbd> to generate getters and setters</li>
<li><kbd>alt</kbd>+<kbd>s</kbd>,<kbd>v</kbd> to insert method signatures for overidden methods from superclass or interface</li>
</ul>
<p>Refactorings</p>
<ul>
<li><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>l</kbd> Extract text-selection as local variable (really handy in that it determines and inserts the type for you.</li>
<li><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>m</kbd> Extract text-selection as a method</li>
<li><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>i</kbd> inline selected method</li>
</ul>
<p>Running and debugging.</p>
<p><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>x</kbd> is a really handy prefix to run stuff in your current file.</p>
<ul>
<li><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>x</kbd>, <kbd>t</kbd> run unit tests in current file</li>
<li><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>x</kbd>, <kbd>j</kbd> run main in current file</li>
<li><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>x</kbd>, <kbd>r</kbd> run on server</li>
</ul>
<p>There are more. The options are shown to you in the lower-right popup after hitting <kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>x</kbd>.</p>
<p><kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>x</kbd> can be switched for <kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>d</kbd> in all the above examples to run in the debugger.</p>
<p>Validation</p>
<p>As of the recent Ganymede release, you can now switch of validation in specified files and folders. I've been waiting for this feature for ages.</p>
<ul>
<li>Go to Project | Properties | Validation</li>
<li>click on the ... button in the settings column of the validator you want to shut up</li>
<li>Add a rule to the <em>exclude group</em></li>
</ul>
<p>code navigation</p>
<ul>
<li>hold down <kbd>ctrl</kbd> to make all variables, methods and classnames hyperlinks to their definitions.</li>
<li><kbd>alt</kbd>+<kbd>left</kbd> to navigate back to where you clicked <kbd>ctrl</kbd></li>
<li><kbd>alt</kbd>+<kbd>right</kbd> to go "forwards" again</li>
</ul>
|
<p>I find the project-specific settings useful in Eclipse 3.3.</p>
<p>For example, if you have several developers working on a project who have different code styles for curly braces, line spacing, number of imports etc. then you can specify the style settings for the project. Then you can configure the save actions so that the code is automatically formatted when a file is saved. The result is everyone's code is formatted the same before it's checked in.</p>
| 4,088
|
<p>I hit this problem all the time. Suppose I am making a command line interface (Java or C#, the problem is the same I think, I will show C# here).</p>
<ol>
<li>I define an interface ICommand</li>
<li>I create an abstract base class CommandBase which implements ICommand, to contain common code.</li>
<li>I create several implementation classes, each extending the base class (and by extension the interface).</li>
</ol>
<p>Now - suppose that the interface specifies that all commands implement the Name property and the Execute method...</p>
<p>For Name each of my instance classes must return a string that is the name of that command. That string ("HELP", "PRINT" etc) is static to the class concerned. What I would love to be able to do is define:</p>
<p>public abstract static const string Name;</p>
<p>However (sadly) you cannot define static members in an interface.</p>
<p>I have struggled with this issue for years now (pretty much any place I have a family of similar classes) and so will post my own 3 possible solutions below for your votes. However since none of them is ideal I am hoping someone will post a more elegant solution.</p>
<hr>
<p>UPDATE:</p>
<ol>
<li>I can't get the code formatting to work properly (Safari/Mac?). Apologies.</li>
<li><p>The example I am using is trivial. In real life there are sometimes dozens of implementing classes and several fields of this semi-static type (ie static to the implementing class).</p></li>
<li><p>I forgot to mention - ideally I want to be able to query this information statically:</p>
<p>string name = CommandHelp.Name;</p></li>
</ol>
<p>2 of my 3 proposed solutions require that the class be instantiated before you can find out this static information which is ugly.</p>
|
<p>You may consider to use attributes instead of fields.</p>
<pre><code>[Command("HELP")]
class HelpCommand : ICommand
{
}
</code></pre>
|
<p>[Suggested solution #1 of 3]</p>
<ol>
<li>Define an abstract property Name in the interface to force all implementing classes to implement the name property.</li>
<li>(in c#) Add this property as abstract in the base class.</li>
<li><p>In the implementations implement like this:</p>
<pre><code>public string Name
{
get {return COMMAND_NAME;}
}
</code></pre>
<p>Where name is a constant defined in that class.</p>
<p>Advantages:</p>
<ul>
<li>Name itself defined as a constant.</li>
<li>Interface mandates the property be created.</li>
</ul>
<p>Disadvantages:</p>
<ul>
<li>Duplication (which I hate). The exact same property accessor code pasted into every one of my implementations. Why cant that go in the base class to avoid the clutter?</li>
</ul></li>
</ol>
| 9,202
|
<p>I'm working with a snippet of code that recursively calls itself and tries to pull out a MIME Type part of <code>text/html</code> from an email (if it exists) for further processing.</p>
<p>The "text/html" could exist inside other content such as <code>multipart/alternative</code>, so I'm trying to find out if there is a defined hierarchy for email MIME Types.</p>
<p>Anybody know if there is and what it is? i.e. what types can parent other types?</p>
|
<p>In theory, only multipart/ and message/ can parent other types (per RFC2046).</p>
|
<p>Your question assumes that mail clients follow the RFC standards for MIME encoding, which they don't. I'd advise you collect a bunch of mail from sources and try and process it as-it-exists. The problem you are facing is extremely difficult (perhaps impossible) to solve 100%.</p>
| 7,925
|
<p>I am trying to print a report from within an InfoPath template. So my dataset is an XML DOM that I will load into the Crystal Report at runtime.
But how do I define the dataset off which the Crystal Report is developed?
Crystal Reports has a great tool to build a dataset from an SQL database. Is there something similar for XML schema that I am missing?</p>
|
<p>right now i don't have crystal reports installed on my machine but if i remember correctly you can select as the source of your report an xml file.</p>
<p>i believe that you can also select the xsd with the data definition for your xml file.</p>
<p>in my case, since i was working with a dataset i would run my application and save the xml representation of the dataset with dataset.writexml(true) so that i would end up with an xml file that include the data definition</p>
|
<p>I see the ability to pick XML in articles about CR on the web, but I don't have it available on mine. Could this be because I am using the CR that is bundled with Visual Studio 2008?</p>
| 6,233
|
<p>I am looking for guidance regarding the best practice around the use of the Profile feature in ASP.NET.</p>
<p>How do you decide what should be kept in the built-in user Profile, or if you should create your own database table and add a column for the desired fields? For example, a user has a zip code, should I save the zip code in my own table, or should I add it to the web.config xml profile and access it via the user profile ASP.NET mechanism? </p>
<p>The pros/cons I can think of right now are that since I don't know the profile very well (it is a bit of a <em>Matrix</em> right now), I probably can do whatever I want if I go the table route (e.g., SQL to get all the users in the same zip code as the current user). I don't know if I can do the same if I use the ASP.NET profile.</p>
|
<p>Ive only built 2 applications that used the profile provider. Since then I have stayed away from using it. For both of the apps I used it to store information about the user such as their company name, address and phone number. </p>
<p>This worked fine until our client wanted to be able to find a user by one of these fields.
Searching involved looping through <strong>every</strong> users profile and comparing the information to the search criteria. As the user base grew the search time became unacceptable to our client. The only solution was to create a table to store the users information. Search speed was increased immensely.</p>
<p>I would recommend storing this type of information in its own table.</p>
|
<p>In my experience its best to keep an the info in the profile to a bare minimum, only put the essentials in there that are directly needed for authentication. Other information such as addresses should be saved in your own database by your own application logic, this approach is more extensible and maintainable.</p>
| 2,401
|
<p>I'm looking for a pre-built solution I can use in my RoR application. I'm ideally looking for something similar to the ASP.NET Forms authentication that provides email validation, sign-up controls, and allows users to reset their passwords. Oh yeah, and easily allows me to pull the user that is currently logged into the application.</p>
<p>I've started to look into the already written pieces, but I've found it to be really confusing. I've looked at LoginGenerator, RestfulAuthentication, SaltedLoginGenerator, but there doesn't seem to be one place that has great tutorials or provide a comparison of them. If there's a site I just haven't discovered yet, or if there is a de-facto standard that most people use, I'd appreciate the helping hand.</p>
|
<p>AuthLogic appears to be the new kid on the block and seems to be the next evolution of restful_authentication, easier to use, etc</p>
<p><a href="http://github.com/binarylogic/authlogic/tree/master" rel="noreferrer">http://github.com/binarylogic/authlogic/tree/master</a></p>
<p>Edit: now that Rails 3 is out, Devise seems to be the new, new kid on the block</p>
<p><a href="https://github.com/plataformatec/devise" rel="noreferrer">https://github.com/plataformatec/devise</a>
or I have been rolling my own authentication now with the <code>has_secure_password</code> built in to Rails <a href="http://railscasts.com/episodes/250-authentication-from-scratch-revised" rel="noreferrer">http://railscasts.com/episodes/250-authentication-from-scratch-revised</a></p>
<p>Side note: Ruby Toolbox is a great site for finding the current best solution in various categories (based on the number of GitHub watchers):</p>
<p><a href="http://ruby-toolbox.com/categories/rails_authentication.html" rel="noreferrer">http://ruby-toolbox.com/categories/rails_authentication.html</a></p>
|
<p>Another vote for Clearance - perhaps not as customisable or as 'in' as authlogic, but in terms of just being able to drop it in place and go, it's definitely worth having a look at.</p>
| 4,402
|
<p>I have created a PHP-script to update a web server that is live inside a local directory.
I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file is different from that of the file on the server. </p>
<p>Once I download again the file from the FTP server, the only difference is the CR/LF mark. This annoys me because the same script is comparing the size of the files to update. Also, in case it means anything, the script works perfectly in PHP vía ftp_put.</p>
<pre><code>from ftplib import FTP
ftpserver = "myserver"
ftpuser = "myuser"
ftppass = "mypwd"
locfile = "g:/test/style.css"
ftpfile = "/temp/style.css"
try:
ftp = FTP(ftpserver, ftpuser, ftppass)
except:
exit ("Cannot connect")
f = open (locfile, "r")
try:
ftp.delete (ftpfile)
except:
pass
# ftp.sendcmd ("TYPE I")
# ftp.storlines("STOR %s" % ftpfile, f)
ftp.storbinary("STOR %s" % ftpfile, f)
f.close()
ftp.dir (ftpfile)
ftp.quit()
</code></pre>
<p>Any suggestions?</p>
|
<p>Do you need to open the locfile in binary using <code>rb</code>?</p>
<pre><code>f = open (locfile, "rb")
</code></pre>
|
<p>Small files take up a whole node on the file system whatever the size is.</p>
<p>My host tends to report all small files as 4KB in ftp but gives an accurate size in a shell so it might be a 'feature' common to ftp clients.</p>
| 2,448
|
<p>I have been looking at the new <a href="http://cappuccino.org/" rel="noreferrer">Objective-J / Cappuccino</a> javascript framework from <a href="http://280north.com/" rel="noreferrer">280North</a>. They provide plug-ins for SubEthaEdit and TextMate to handle syntax highlighting, but I primarily use vi. Does anyone know of a way to get Objective-J syntax highlighting in vi, or a good way to convert whatever format the other two editors use?</p>
|
<p>The Objective-J Tools package (<a href="http://cappuccino.org/download" rel="noreferrer">http://cappuccino.org/download</a>) and the source on github now include a vim highlight module.</p>
|
<p>If regular javascript syntax highlighting is good enough, you can map that to .j files by adding something like this to your .vimrc file:</p>
<pre><code> augroup objective-j
au! BufRead,BufNewFile *.j set filetype=objective-j
au! Syntax objective-j source /usr/share/vim/vim71/syntax/javascript.vim
augroup END
</code></pre>
<p>I haven't tried this exact code, but did something similar when mapping C# syntax to .vala files on my Linux machine. (NOTE: The javascript.vim file might be located somewhere else on your computer.) You could of course make a objective-j.vim file based on that javascript.vim syntax definition instead of using it as it is.</p>
| 7,232
|
<p>I would like to make an ajax call to a different server (same domain and box, just a different port.)
e.g.</p>
<p>My page is</p>
<pre>
http://localhost/index.html
</pre>
<p>I would like to make a ajax get request to:</p>
<pre>
http://localhost:7076/?word=foo
</pre>
<p>I am getting this error:</p>
<pre>
Access to restricted URI denied (NS_ERROR_DOM_BAD_URI)
</pre>
<p>I know that you can not make an ajax request to a different domain, but it seem this also included different ports? are there any workarounds?</p>
|
<p>Have a certain page on your port 80 server proxy requests to the other port. For example:</p>
<pre><code>http://localhost/proxy?port=7076&url=%2f%3fword%3dfoo
</code></pre>
<p>Note the url encoding on the last query string argument value.</p>
|
<p>This is a browser restriction. All javascript calls must be to the same server and port of the home of the script. This will require something server-side to get around. I.E. have the process at <code>localhost</code> forward the request to <code>localhost:7076</code>.</p>
| 8,164
|
<p>I am using .NET remoting to retrieve periodic status updates from a Windows service into a 'controller' application which is used to display some live stats about what the service is doing.</p>
<p>The resulting network traffic is huge - many times the size of the data for the updates - so clearly I have implemented the remoting code incorrectly in a very inefficient way. As a first step towards fixing it, I need to monitor the traffic on the IP port the service is using to talk to the controller, so that I can establish a baseline and then verify a fix.</p>
<p>Can anyone recommend a utility and/or coding technique that I can use to get the traffic stats? A "bytes sent" count for the port would suffice.</p>
|
<p>There is an Empower program that Microsoft has available. It gives you several Premium subscriptions for cheap, with the catch that you have to be an ISV working towards an actual product.</p>
<p><a href="https://partner.microsoft.com/global/program/40066412" rel="nofollow noreferrer">This</a> (Not available anymore - broken link) gives you all the software you'll need for development, and even a few "real world" licenses for certain apps (like Office)</p>
<p>After a couple of years, you have to pay full price though. The logic being that you should have a product on the market, and can afford it. </p>
|
<p>Many MVP's have gift subscriptions that they can give away, so it pays off to be visible in the community.</p>
<p>Speak at your local user group, start (or participate) in an open source project, start a blog... just generally get your name out there.</p>
<p>Eventually you'll get one (or an MVP :)).</p>
<p>What I've found is that if you pay attention there are plenty of opportunities to snag a free copy of Office or Visual Studio at local Microsoft events.</p>
<p>Good luck!</p>
| 6,396
|
<p>Is it possible to undo the changes caused by the following command? If so, how?</p>
<pre><code>git reset --hard HEAD~1
</code></pre>
|
<p>Pat Notz is correct. You can get the commit back so long as it's been within a few days. git only garbage collects after about a month or so unless you explicitly tell it to remove newer blobs.</p>
<pre><code>$ git init
Initialized empty Git repository in .git/
$ echo "testing reset" > file1
$ git add file1
$ git commit -m 'added file1'
Created initial commit 1a75c1d: added file1
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file1
$ echo "added new file" > file2
$ git add file2
$ git commit -m 'added file2'
Created commit f6e5064: added file2
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file2
$ git reset --hard HEAD^
HEAD is now at 1a75c1d... added file1
$ cat file2
cat: file2: No such file or directory
$ git reflog
1a75c1d... HEAD@{0}: reset --hard HEAD^: updating HEAD
f6e5064... HEAD@{1}: commit: added file2
$ git reset --hard f6e5064
HEAD is now at f6e5064... added file2
$ cat file2
added new file
</code></pre>
<p>You can see in the example that the file2 was removed as a result of the hard reset, but was put back in place when I reset via the reflog.</p>
|
<p>git reset --hard - you can use to revert one page and after that you can stash or pull everything from origin again</p>
| 2,737
|
<p>The <a href="http://doi.org/" rel="noreferrer">DOI</a> system places basically no useful limitations on what constitutes <a href="http://doi.org/handbook_2000/enumeration.html#2.2" rel="noreferrer">a reasonable identifier</a>. However, being able to pull DOIs out of PDFs, web pages, etc. is quite useful for citation information, etc.</p>
<p>Is there a reliable way to identify a DOI in a block of text without assuming the 'doi:' prefix? (any language acceptable, regexes preferred, and avoiding false positives a must)</p>
|
<p>Ok, I'm currently extracting thousands of DOIs from free form text (XML) and I realized that <a href="https://stackoverflow.com/a/10300246/89771">my previous approach</a> had a few problems, namely regarding encoded entities and trailing punctuation, so I went on reading <a href="http://www.doi.org/doi_handbook/2_Numbering.html" rel="nofollow noreferrer">the specification</a> and this is the best I could come with.</p>
<hr />
<blockquote>
<p>The DOI prefix shall be composed of a directory indicator followed by
a registrant code. These two components shall be separated by a full
stop (period).</p>
<p>The directory indicator shall be "10". The directory indicator
distinguishes the entire set of character strings (prefix and suffix)
as digital object identifiers within the resolution system.</p>
</blockquote>
<p>Easy enough, the initial <code>\b</code> prevents us from "matching" a "DOI" that doesn't start with <code>10.</code>:</p>
<pre><code>$pattern = '\b(10[.]';
</code></pre>
<hr />
<blockquote>
<p>The second element of the DOI prefix shall be the registrant code. The
registrant code is a unique string assigned to a registrant.</p>
</blockquote>
<p>Also, all assigned registrant code are numeric, and at least 4 digits long, so:</p>
<pre><code>$pattern = '\b(10[.][0-9]{4,}';
</code></pre>
<hr />
<blockquote>
<p>The registrant code may be further divided into sub-elements for
administrative convenience if desired. Each sub-element of the
registrant code shall be preceded by a full stop.</p>
</blockquote>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*';</code></p>
<hr />
<blockquote>
<p>The DOI syntax shall be made up of a DOI prefix and a DOI suffix
separated by a forward slash.</p>
</blockquote>
<p>However, this isn't absolutely necessary, section 2.2.3 states that uncommon suffix systems may use other conventions (such as <code>10.1000.123456</code> instead of <code>10.1000/123456</code>), but lets cut some slack.</p>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/';</code></p>
<hr />
<blockquote>
<p>The DOI name is case-insensitive and can incorporate any printable
characters from the legal graphic characters of Unicode. The DOI
suffix shall consist of a character string of any length chosen by the
registrant. Each suffix shall be unique to the prefix element that
precedes it. The unique suffix can be a sequential number, or it might
incorporate an identifier generated from or based on another system.</p>
</blockquote>
<p>Now this is where it gets trickier, from all the DOIs I have processed, I saw the following characters (besides <code>[0-9a-zA-Z]</code> of course) in their <strong>suffixes</strong>: <code>.-()/:-</code> -- so, while it doesn't exist, the DOI <code>10.1016.12.31/nature.S0735-1097(98)2000/12/31/34:7-7</code> is completely plausible.</p>
<p>The logical choice would be to use <code>\S</code> or the <code>[[:graph:]]</code> PCRE POSIX class, so lets do that:</p>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/\S+'; // or</code></p>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/[[:graph:]]+';</code></p>
<hr />
<p>Now we have a difficult problem, the <code>[[:graph:]]</code> class is a super-set of the <code>[[:punct:]]</code> class, which includes characters easily found in free text or any markup language: <code>"'&<></code> among others.</p>
<p>Lets just filter the markup ones for now using a negative lookahead:</p>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])\S)+'; // or</code></p>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])[[:graph:]])+';</code></p>
<hr />
<p>The above should cover encoded entities (<code>&</code>), attribute quotes (<code>["']</code>) and open / close tags (<code>[<>]</code>).</p>
<p>Unlike markup languages, free text usually doesn't employ punctuation characters unless they are bounded by at least one space <em><strong>or</strong></em> placed at the end of a sentence, for instance:</p>
<blockquote>
<p>This is a long DOI:
<code>10.1016.12.31/nature.S0735-1097(98)2000/12/31/34:7-7</code><strong>!!!</strong></p>
</blockquote>
<p>The solution here is to close our capture group and assert another word boundary:</p>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])\S)+)\b'; // or</code></p>
<p><code>$pattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])[[:graph:]])+)\b';</code></p>
<p>And <em>voilá</em>, <a href="http://regexpal.com/?flags=g&regex=%5Cb(10%5B.%5D%5B0-9%5D%7B4%2C%7D(%3F%3A%5B.%5D%5B0-9%5D%2B)*%2F(%3F%3A(%3F!%5B%22%26%5C%27%3C%3E%5D)%5CS)%2B)%5Cb&input=This%20is%20a%20short%20DOI%3A%2010.1000%2F123456.%0AThis%20is%20NOT%20a%20DOI%3A%204210.1000%2F123456.%0AThis%20is%20a%20long%20DOI%3A%2010.1016.12.31%2Fnature.S0735-1097(98)2000%2F12%2F31%2F34%3A7-7!!!%0A%0A10.1007%2F978-3-642-28108-2_19%0A10.1007.10%2F978-3-642-28108-2_19%20(fictitious%20example%2C%20see%20%40Ju9OR%20comment)%0A10.1016%2FS0735-1097(98)00347-7%0A10.1579%2F0044-7447(2006)35%5C%5B89%3ARDUICP%5C%5D2.0.CO%3B2%0A%0AAlso%2C%20correctly%20discards%20some%20falsy%20(X%7CHT)ML%20stuff%20like%3A%0A%0A%3Cgeo%20coords%3D%2210.4515260%2C51.1656910%22%3E%3C%2Fgeo%3E" rel="nofollow noreferrer">here is a demo</a>.</p>
|
<p>The following regex should do the job (Perl regex syntax):</p>
<pre><code>/(10\.\d+\/\d+)/
</code></pre>
<p>You could do some additional sanity checking by opening the urls</p>
<pre><code>http://hdl.handle.net/<doi>
</code></pre>
<p>and</p>
<pre><code>http://dx.doi.org/<doi>
</code></pre>
<p>where is the candidate doi,</p>
<p>and testing that you a) get a 200 OK http status, and b) the returned page is not the "DOI not found" page for the service.</p>
| 4,757
|
<p>How can i stop the host machine entering <code>standby</code> mode while my application is running?</p>
<p>Is there any <code>win32 api</code> call to do this?</p>
|
<p>There are two APIs, depending on what version of Windows.</p>
<p>XP,2000, 2003:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa373247(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa373247(VS.85).aspx</a></p>
<p>Respond to PBT_APMQUERYSUSPEND.</p>
<p>Vista, 2008:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx</a></p>
<p>There could be many valid reasons to prevent the computer from going to sleep. For example, watching a video, playing music, compiling a long running build, downloading large files, etc. </p>
|
<p>This article <a href="http://www.codeguru.com/cpp/w-p/system/messagehandling/article.php/c6907" rel="nofollow noreferrer">http://www.codeguru.com/cpp/w-p/system/messagehandling/article.php/c6907</a> provides a demo of how to do this from C++ (thought he article is framed as if you want to do it from Java, and provides a Java wrapper).</p>
<p>The actual code in in a zip file at <a href="http://www.codeguru.com/dbfiles/get_file/standbydetectdemo_src.zip?id=6907&lbl=STANDBYDETECTDEMO_SRC_ZIP&ds=20040406" rel="nofollow noreferrer">http://www.codeguru.com/dbfiles/get_file/standbydetectdemo_src.zip?id=6907&lbl=STANDBYDETECTDEMO_SRC_ZIP&ds=20040406</a> and the C++ part of it is under com/ha/common/windows/standbydetector.</p>
<p>Hopefully it will give you enough of a direction to get started.</p>
| 7,992
|
<p>ASP.NET MVC seems to be making a pretty big entrance. Can anyone summarize how its MVC implementation stacks up against popular MVC frameworks for other languages? (I'm thinking specifically of Rails and Zend Framework, though there are obviously lots.) Observations on learning curve, common terminology, ease of use and feelgood factor welcome.</p>
<p>(For the sake of a little background, I've been avoiding using ASP.NET for some time because I really hate the webforms approach, but Jeff's prolific praise on the podcast has almost convinced me to give it a go.)</p>
|
<p>I'm just getting into ASP.NET MVC, so these are some early thoughts comparing it to Rails:</p>
<p><strong>Mostly manages to stick with static typing, at the expense of a little extra code.</strong><br>
This will either give you the warm fuzzies or make you feel slightly shackled depending on how you feel about dynamic typing. For instance, you can have your views expect particular typed data (and so get compile-time checking of your views).</p>
<p><strong>Better separation of bits of the framework.</strong><br>
So there's no prescribed data access mechanism such as ActiveRecord in Rails; you're free to choose your own. LINQ feels similar if you want something cheap, if a bit more verbose. You can use the non-WebForms parts of ASP.NET like caching and authentication.</p>
<p><strong>Still playing feature catch-up.</strong><br>
Preview 5 brought AcceptVerbs, model updaters (similar to Ruby's hash.merge) and more ways to bind forms to models. Feels like there's still more to come before they check off most of the feature set that Rails has.</p>
<p>I'm still missing a little of Rails' freedom and elegance (much of which is down to Ruby, I guess), but ASP.NET MVC really does feel quite close. </p>
|
<p>If you're already programming in the .NET idiom, it's pretty easy to pick up on a lot of what's going on in the MVC Framework. Rails, on the other hand, can be pretty easy to pick up (granted, at a basic level) if you've never set eyes on Ruby before you start.</p>
<p>It seems like you're talking about quality-as-MVC, though, and it looks to me like both frameworks (can't speak for Zend) do a very good job of separating the concerns. </p>
| 7,917
|
<p>Warning - I am very new to NHibernate. I know this question seems simple - and I'm sure there's a simple answer, but I've been spinning my wheels for some time on this one. I am dealing with a legacy db which really can't be altered structurally. I have a details table which lists payment plans that have been accepted by a customer. Each payment plan has an ID which links back to a reference table to get the plan's terms, conditions, etc. In my object model, I have an AcceptedPlan class, and a Plan class. Originally, I used a many-to-one relationship from the detail table back to the ref table to model this relationship in NHibernate. I also created a one-to-many relationship going in the opposite direction from the Plan class over to the AcceptedPlan class. This was fine while I was simply reading data. I could go to my Plan object, which was a property of my AcceptedPlan class to read the plan's details. My problem arose when I had to start inserting new rows to the details table. From my reading, it seems the only way to create a new child object is to add it to the parent object and then save the session. But I don't want to have to create a new parent Plan object every time I want to create a new detail record. This seems like unnecessary overhead. Does anyone know if I am going about this in the wrong way?</p>
|
<p>I'd steer away from having child object containing their logical parent, it can get very messy and very recursive pretty quickly when you do that. I'd take a look at how you're intending to use the domain model before you do that sort of thing. You can easily still have the ID references in the tables and just leave them unmapped.</p>
<p>Here are two example mappings that might nudge you in the right direction, I've had to adlib table names etc but it could possibly help. I'd probably also suggest mapping the StatusId to an enumeration.</p>
<p>Pay attention to the way the bag effectivly maps the details table into a collection.</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping default-cascade="save-update" xmlns="urn:nhibernate-mapping-2.2">
<class lazy="false" name="Namespace.Customer, Namespace" table="Customer">
<id name="Id" type="Int32" unsaved-value="0">
<column name="CustomerAccountId" length="4" sql-type="int" not-null="true" unique="true" index="CustomerPK"/>
<generator class="native" />
</id>
<bag name="AcceptedOffers" inverse="false" lazy="false" cascade="all-delete-orphan" table="details">
<key column="CustomerAccountId" foreign-key="AcceptedOfferFK"/>
<many-to-many
class="Namespace.AcceptedOffer, Namespace"
column="AcceptedOfferFK"
foreign-key="AcceptedOfferID"
lazy="false"
/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping default-cascade="save-update" xmlns="urn:nhibernate-mapping-2.2">
<class lazy="false" name="Namespace.AcceptedOffer, Namespace" table="AcceptedOffer">
<id name="Id" type="Int32" unsaved-value="0">
<column name="AcceptedOfferId" length="4" sql-type="int" not-null="true" unique="true" index="AcceptedOfferPK"/>
<generator class="native" />
</id>
<many-to-one
name="Plan"
class="Namespace.Plan, Namespace"
lazy="false"
cascade="save-update"
>
<column name="PlanFK" length="4" sql-type="int" not-null="false"/>
</many-to-one>
<property name="StatusId" type="Int32">
<column name="StatusId" length="4" sql-type="int" not-null="true"/>
</property>
</class>
</hibernate-mapping>
</code></pre>
|
<p>The approach I'd take to model this is as follows:</p>
<p>Customer object contains an ICollection <PaymentPlan> PaymentPlans which represent the plans that customer has accepted.</p>
<p>The PaymentPlan to the Customer would be mapped using a bag which uses the details table to establish which customer id's mapped to which PaymentPlans. Using cascade all-delete-orphan, if the customer was deleted, both the entries from details and the PaymentPlans that customer owned would be deleted.</p>
<p>The PaymentPlan object contains a PlanTerms object which represented the terms of the payment plan.</p>
<p>The PlanTerms would be mapped to a PaymentPlan using a many-to-one mapping cascading save-update which would just insert a reference to the relevant PlanTerms object in to the PaymentPlan.</p>
<p>Using this model, you could create PlanTerms independantly and then when you add a new PaymentPlan to a customer, you'd create a new PaymentPlan object passing in the relevant PlanTerms object and then add it to the collection on the relevant Customer. Finally you'd save the Customer and let nhibernate cascade the save operation.</p>
<p>You'd end up with a Customer object, a PaymentPlan object and a PlanTerms object with the Customer (customer table) owning instances of PaymentPlans (the details table) which all adhear to specific PlanTerms (the plan table).</p>
<p>I've got some more concrete examples of the mapping syntax if required but it's probably best to work it through with your own model and I don't have enough information on the database tables to provide any specific examples.</p>
| 3,211
|
<p>Here is the scenario: </p>
<p>I have a table with a margin-bottom of 19px. Below that I have a form that contains some fieldsets. One of them is floated right. The problem is that the margin-bottom is not getting the full 19px in IE7. I've gone through all of the IE7 css/margin/float bugs that I can think of and have tried remedies but have been unsuccessful. I have been googling for a while now and cannot find anything that is helping out. </p>
<p>Here is what I have tried. </p>
<ol>
<li>Wrapping the form or fieldset in an unstyled div. No apparent change.</li>
<li>Nixing the margin-bottom on the table and instead wrapping that with a div and giving it a padding-bottom of 19px. No apparent change.</li>
<li>Nixing the margin-bottom on the table and adding a div with a fixed height of 19px. No apparent change.</li>
<li>Putting a clear between the table and the fieldset.</li>
</ol>
<p>I know there are some others that I am forgetting, but those are the things I have tried out recently. This happens to each fieldset. </p>
<hr>
<p>I am using a reset style sheet and have a xhtml transitional doctype. </p>
<p><strong>Edit:</strong> I also have the IE7 web developer toolbar and Firebug. The style information for both browsers says that it has a margin-bottom: 19px; but it clearly is not for IE7.</p>
|
<p>if you have floated and unfloated elements, the only surefire way to ensure vertical space between them cross-browser is padding-top on the subsequent element.</p>
|
<p>I wouldn't know for sure without testing but try placing this between the table and the fieldset:</p>
<pre><code><br style="clear:both;" />
</code></pre>
| 3,614
|
<p>I need to generate some passwords, I want to avoid characters that can be confused for each other. Is there a definitive list of characters I should avoid? my current list is</p>
<p>il10o8B3Evu![]{}</p>
<p>Are there any other pairs of characters that are easy to confuse? for special characters I was going to limit myself to those under the number keys, though I know that this differs depending on your keyboards nationality!</p>
<p>As a rider question, I would like my passwords to be 'wordlike'do you have a favoured algorithm for that?</p>
<p>Thanks :)</p>
|
<p>Here are the character sets that Steve Gibson uses for his <a href="https://www.grc.com/ppp.htm" rel="noreferrer">"Perfect Paper Password"</a> system. They are "characters to allow" rather than "characters to avoid", but they seem pretty reasonable for what you want:</p>
<p>A standard set of 64 characters</p>
<pre><code>!#%+23456789:=?@ABCDEFGHJKLMNPRS
TUVWXYZabcdefghijkmnopqrstuvwxyz
</code></pre>
<p>A larger set of 88 characters</p>
<pre><code>!"#$%&'()*+,-./23456789:;<=>?@ABCDEFGHJKLMNO
PRSTUVWXYZ[\]^_abcdefghijkmnopqrstuvwxyz{|}~
</code></pre>
<p>For pronounceable passwords, I'm not familiar with the algorithms but you might want to look at <a href="http://www.adel.nursat.kz/apg/" rel="noreferrer">APG</a> and <a href="http://sourceforge.net/projects/pwgen/" rel="noreferrer">pwgen</a> as a starting point.</p>
|
<p>I don't love the wordlist approach. For example, in /usr/share/dict/words on OSX, there are 5110 4-character words. Using two of them with a seperator character produces ~600M combinations. But if you used the character set directly with a strong random number generator, you'd have 88^9 possible passwords, 3.16e+17 combinations. </p>
<p>Either way, the likely attack against this system is going to be against the random number generator, so make sure you're using a cryptographically strong one. If you use PHP's standard rand function, it will be attacked by registering and resetting thousands of passwords to sample the RNG state and then predict the remaining RNG state, which will reduce the number of possible passwords an attacker needs to test. </p>
| 7,935
|
<p>What do the clever programmers here do to keep track of handy programming tricks and useful information they pick up over their many years of experience? Things like useful compiler arguments, IDE short-cuts, clever code snippets, etc.</p>
<p>I sometimes find myself frustrated when looking up something that I used to know a year or two ago. My IE favorites probably represent a good chunk of the Internet in the late 1990s, so clearly that isn't effective (at least for me). Or am I just getting old?</p>
<p>So.. what do you do?
</p>
|
<p>Two Things I do:</p>
<ul>
<li>I blog about it - this allows me to go back and search my own blog.</li>
<li>We use the code snippet feature in Visual Studio.</li>
</ul>
<p>Cheers.</p>
|
<p>I agree with emailing, the wiki and the blog. Emailing is the most useful. If you can't use GMail and you're on windows, install a desktop search utility (Windows search, Google Desktop, Copernic, etc)</p>
<p>I also like to jot it into a textfile and save it in my documents folder. Whatever desktop search utility you use will be able to find it easily. e.g. </p>
<pre><code>//print spool stop.notes.txt
If the printer spooler stops, start it again by
- Services > Provision Networks > Restart Service
tags: printer provision no printer spooler cannot print remote desktop
</code></pre>
| 3,834
|
<p>We're attemtping to merge our DLL's into one for deployment, thus ILMerge. Almost everything seems to work great. We have a couple web controls that use <code>ClientScript.RegisterClientScriptResource</code> and these are 404-ing after the merge (These worked before the merge).</p>
<p>For example one of our controls would look like</p>
<pre><code>namespace Company.WebControls
{
public class ControlA: CompositeControl, INamingContainer
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.Page.ClientScript.RegisterClientScriptResource(typeof(ControlA), "Company.WebControls.ControlA.js");
}
}
}
</code></pre>
<p>It would be located in Project WebControls, assembly Company.WebControls. Underneath would be ControlA.cs and ControlA.js. ControlA.js is marked as an embedded resource. In the AssemblyInfo.cs I include the following:</p>
<pre><code>[assembly: System.Web.UI.WebResource("Company.WebControls.ControlA.js", "application/x-javascript")]
</code></pre>
<p>After this is merged into CompanyA.dll, what is the proper way to reference this web resource? The ILMerge command line is as follows (from the bin directory after the build): <code>"C:\Program Files\Microsoft\ILMerge\ILMerge.exe" /keyfile:../../CompanySK.snk /wildcards:True /copyattrs:True /out:Company.dll Company.*.dll</code></p>
|
<p>OK - I got this working. It looks like the primary assembly was the only one whose assembly attributes were being copied. With copyattrs set, the last one in would win, not a merge (as far as I can tell). I created a dummy project to reference the other DLL's and included all the web resources from those projects in the dummy assembly info - now multiple resources from multiple projects are all loading correctly.</p>
<p>Final post-build command line for dummy project:
"C:\Program Files\Microsoft\ILMerge\ILMerge.exe" /keyfile:../../Company.snk /wildcards:True /out:Company.dll Company.Merge.dll Company.*.dll</p>
|
<p>You need to set /allowMultiple along with /copyattrs. It is only then that ILMerge will merge the embedded resources from all assemblies.</p>
| 4,060
|
<p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p>
<p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names for sections (or very similar). Mess around with the numbers in the second class then with one function then reset them to be the same as in the first class. </p>
<p>The only alternative I've found is to make one aggravatingly long class with too many separate pieces of data in it to be readily usable.</p>
|
<p>A class is a template, it allows you to create a blueprint, you can then have multiple instances of a class each with different numbers, like so.</p>
<pre><code>class dog(object):
def __init__(self, height, width, lenght):
self.height = height
self.width = width
self.length = length
def revert(self):
self.height = 1
self.width = 2
self.length = 3
dog1 = dog(5, 6, 7)
dog2 = dog(2, 3, 4)
dog1.revert()
</code></pre>
|
<p>Classes don't have values. Objects do. Is what you want basically a class that can reset an instance (object) to a set of default values? </p>
<p>How about just providing a reset method, that resets the properties of your object to whatever is the default?</p>
<p>I think you should simplify your question, or tell us what you really want to do. It's not at all clear.</p>
| 8,962
|
<p>I know that you can insert multiple rows at once, is there a way to update multiple rows at once (as in, in one query) in MySQL?</p>
<p>Edit:
For example I have the following</p>
<pre><code>Name id Col1 Col2
Row1 1 6 1
Row2 2 2 3
Row3 3 9 5
Row4 4 16 8
</code></pre>
<p>I want to combine all the following Updates into one query</p>
<pre><code>UPDATE table SET Col1 = 1 WHERE id = 1;
UPDATE table SET Col1 = 2 WHERE id = 2;
UPDATE table SET Col2 = 3 WHERE id = 3;
UPDATE table SET Col1 = 10 WHERE id = 4;
UPDATE table SET Col2 = 12 WHERE id = 4;
</code></pre>
|
<p>Yes, that's possible - you can use INSERT ... ON DUPLICATE KEY UPDATE.</p>
<p>Using your example:</p>
<pre><code>INSERT INTO table (id,Col1,Col2) VALUES (1,1,1),(2,2,3),(3,9,3),(4,10,12)
ON DUPLICATE KEY UPDATE Col1=VALUES(Col1),Col2=VALUES(Col2);
</code></pre>
|
<p>The following will update all rows in one table</p>
<pre><code>Update Table Set
Column1 = 'New Value'
</code></pre>
<p>The next one will update all rows where the value of Column2 is more than 5</p>
<pre><code>Update Table Set
Column1 = 'New Value'
Where
Column2 > 5
</code></pre>
<p>There is all <a href="https://stackoverflow.com/questions/3432/multiple-updates-in-mysql#3439">Unkwntech</a>'s example of updating more than one table</p>
<pre><code>UPDATE table1, table2 SET
table1.col1 = 'value',
table2.col1 = 'value'
WHERE
table1.col3 = '567'
AND table2.col6='567'
</code></pre>
| 2,555
|
<p>I want to be able to play sound files in my program. Where should I look?</p>
|
<p>I wrote the following code that works fine. But I think it only works with <code>.wav</code> format.</p>
<pre><code>public static synchronized void playSound(final String url) {
new Thread(new Runnable() {
// The wrapper thread is unnecessary, unless it blocks on the
// Clip finishing; see comments.
public void run() {
try {
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(
Main.class.getResourceAsStream("/path/to/sounds/" + url));
clip.open(inputStream);
clip.start();
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
}).start();
}
</code></pre>
|
<p>This thread is rather old but I have determined an option that could prove useful.</p>
<p>Instead of using the Java <code>AudioStream</code> library you could use an external program like Windows Media Player or VLC and run it with a console command through Java.</p>
<pre><code>String command = "\"C:/Program Files (x86)/Windows Media Player/wmplayer.exe\" \"C:/song.mp3\"";
try {
Process p = Runtime.getRuntime().exec(command);
catch (IOException e) {
e.printStackTrace();
}
</code></pre>
<p>This will also create a separate process that can be controlled it the program. </p>
<pre><code>p.destroy();
</code></pre>
<p>Of course this will take longer to execute than using an internal library but there may be programs that can start up faster and possibly without a GUI given certain console commands. </p>
<p>If time is not of the essence then this is useful.</p>
| 4,588
|
<p>I'm printing stacked Prusa COVID-19 face shields on a modded Ender 3. It works fairly well until the second layer of masks, where we get this weird effect that's kind of like stringing. It looks like the curve is becoming "low poly." I'm sorry that I can't be more specific, but I really don't know how to describe it more than this. Please look at the pictures to get more info. </p>
<p>One of the strangest things is that it worked earlier with the same slicer and the same profile. I am using PrusaSlicer, but I tried it with Cura and it still didn't work. There are a few more problems with the prints: some under-extrusion on the supports, and some spots had little gaps between the layers. </p>
<p>Does anyone have any fixes for any of these problems? I would mainly like to know about the strange kind of stringing because that actually prevents me from stacking prints. </p>
<p>I am printing Overture PETG at 240 on the nozzle and 80 on the bed. This is at a speed of 50 mm per second. I have the Basaraba Innovations direct drive mod, the Creality silent board with TH3D Unified Firmware based on Marlin 1.1.9, and the EZABL Pro.</p>
<p>Please look at the pictures to see what is happening.
<a href="https://i.stack.imgur.com/VBYu2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VBYu2.jpg" alt=""></a>
<a href="https://i.stack.imgur.com/koHSS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/koHSS.jpg" alt=""></a>
<a href="https://i.stack.imgur.com/TveJc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TveJc.jpg" alt=""></a>
<a href="https://i.stack.imgur.com/urpmX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/urpmX.jpg" alt=""></a>
<a href="https://i.stack.imgur.com/iOLcQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iOLcQ.jpg" alt=""></a>
<a href="https://i.stack.imgur.com/T21Ng.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T21Ng.jpg" alt=""></a>
<a href="https://i.stack.imgur.com/vMDNI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vMDNI.jpg" alt=""></a>
<a href="https://i.stack.imgur.com/9PnvN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9PnvN.jpg" alt=""></a></p>
|
<p>So, after some day of yelling and disassembling, I figured out what was the issue. As many were suggesting, I indeed had an issue with the tubing lifting from the nozzle. it was lifting, so PLA was slowly infiltrating where it wasn't supposed to be to the point it created a blockage, resulting in skipping.</p>
<p>However, no amount of cleaning and reseating the tubing got rid of it. i've also changed, again, nozzle, tubing and pneumatic fittings to higher quality ones to no avail.</p>
<p>I got absolutely fed up and bought a direct drive conversion kit. One of the cheap ones, reusing most of the stock hardware, including stock extruder and gears. The idea, for me, behind it was that the mass of the extruder, and the much shorter length of tubing, meant that the tubing had no space to move around and let the PLA out.</p>
<p>It looks like it's working so far, I'm 6 hours in on a 10 hours print with no skipping at all. I also managed to ease the pressure that the extruder arm excise on the filament, so it's not being chewed anymore and I'm not seeing any PLA shavings so far.</p>
|
<p>I my case helps reducing printing speed, from 100% to 80%.
Looks like the filament is cooling noozle to fast.
In some large prints at the begining (on first layers) I'm reducing speed to 60%.
This looks like the background temperature is not the same in the center and at the borders.</p>
| 1,632
|
<p>If you're familiar with the phrase "build one to throw away", well, we seem to have done that; we’re reaching the limits of version 1 of our online app. It's time to clean things up by:</p>
<ul>
<li>Re-organizing code and UI</li>
<li>Unifying UI processes</li>
<li>Adding more functionality</li>
<li>Building for the future</li>
<li>Modifying our database structure to handle all of the above</li>
</ul>
<p>What's the best way to make this transition happen?</p>
<p>We want to avoid throwing all of our users over to a new system (once it's finished) ... they'd freak out and we couldn't handle the call load. Our users run the gamut, from technically proficient used-to-write-software types, to those that don't know what HTML is.</p>
<p>Should we start a new "installation" of our system and move users over to it gradually after we ensure this new design sufficiently solves enough of the problems with version 1?</p>
<p>Should we (somehow) change each module of our system incrementally, and phase? This may be difficult because the database layout will change, resulting in having to tweak the "core code" and the code for several surrounding modules.</p>
<p>Is it common to have a set of trusted, patient, "beta tester" clients using a cutting edge version of an app? (The goal here would be to get feedback and test for bugs on a new system)</p>
<p>Any other advice? First-hand experience?</p>
|
<p>The answer, I'm afraid, is it depends. It depends on the kind of application and the kind of users you have. Without knowing what the system is and the scope of the changes in the version, it is difficult to offer an answer. </p>
<p>That said, there are some rules of thumb.</p>
<p>Firstly, avoid the big bang launch. Any launch of a system is going to have problems. The industry is littered with projects where people thought the bang-bang launch was a great idea, only for teething problems to bring the launch to its knees. <a href="http://en.wikipedia.org/wiki/Anna_Patterson" rel="nofollow noreferrer">Cuil</a> was a recent high-profile causality of the big-bang launch.</p>
<p>In order to make the teething problems manageable, you need to work with small numbers of users initially, then slowly ratchet up the number of users. </p>
<p>Secondly, the thing that you must absolutely must positively do is <em>put the user first</em>. The user should have to do the least amount of work possible to use V2 of the system. The ideal amount of work would be zero. </p>
<p>This means that if you pick to slowly migrate users from one system to the other, <em>you</em> are responsible for making sure all their data and settings are migrated. For example, don't do anything stupid like telling the user they must use V1 for all records before 12/09/2008 and V2 for all records after.</p>
<p>The point of releasing V2 should be making the users' life easier, not making it needlessly more difficult. </p>
<p>Thirdly, have a beta program. This applies even for Intranet applications. Developing an application is much like Newton-Raphson's method for finding the root of a polynomial. You make a guess of what the user wants, you deliver it to the user, the user provides feedback and slowly but surely each iteration takes you closer to the solution to the problem.</p>
<p>A beta program will help you find the root much faster than just foisting new versions on to people without time for them to comment on the changes. Betas help get your users on-board earlier and make them feel included in the process; the importance of which I can not stress enough.</p>
|
<p>It sounds like <strong>incremental re-architecture</strong> should be your agile buzz-phrase of choice.</p>
<p>I've never done it on a web application, but I have been through some fairly radical client application changes that were done incrementally. If you invest a little bit of time up front to make sure that pieces of work are sequenced in a fairly sensible way it can work well. A small investment in good refactoring aids will be very helpful if you don't have them already. I can personally recommend <a href="http://www.jetbrains.com/resharper/index.html" rel="nofollow noreferrer">jetBrains Resharper</a> if you are using .NET, and if you are Java-based I believe IntelliJ IDEA includes similar functionality.</p>
| 8,475
|
<p>I have a makerbot, and am using their slicer program. The part I am printing has an extremely coarse thread, 5 threads per inch with a 2 mm thread height. The thread face is at a 30 degree angle (15 degrees of overhang)</p>
<p>I have printed external threads like this without issue and without support material before for various gardening tools (a flow straightener for example). I'm now trying to print an internal threaded part however the rest of the part needs to have support. I've played with the settings in the makerbot software but can't find a combination that will acomplish my goal. </p>
<p>I'm looking for an idea, a setting, or an alternate way of printing the threads without support, but still have supports for the other sections of the part that I know do need them. </p>
<p>Perhaps there is an alternate software that can do something like this, or is best practice to modify the part to have weak structural elements to support the extremely overhanging sections that I'll then break off afterwards and print the part with no supports?</p>
|
<p>There are some software tools that let you manually design support structures so you can target the areas that need them, and avoid others.</p>
<p>For example, Meshmixer can be used to add supports into your STL. I believe you still use a separate slicer.</p>
<p>Some slicers also have the ability to manually add support. I have found that CraftWare and Simplify3D have this kind of feature.</p>
|
<p>Try using simplify 3d. It's a very powerful slicing software compatible with almost every 3d printer. It does cost 150 dollars, but that would be the only drawback to using that software. You can manually place supports around your model without having he software mess it up. I think this is exactly what you're looking for.</p>
| 556
|
<p>Is <a href="http://bouncycastle.org/java.html" rel="nofollow noreferrer">Bouncy Castle API</a> Thread Safe ? Especially,</p>
<pre><code>org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher
org.bouncycastle.crypto.paddings.PKCS7Padding
org.bouncycastle.crypto.engines.AESFastEngine
org.bouncycastle.crypto.modes.CBCBlockCipher
</code></pre>
<p>I am planning to write a singleton Spring bean for basic level cryptography support in my app. Since it is a web application, there are greater chances of multiple threads accessing this component at a time. So tread safety is essential here.</p>
<p>Please let me know if you have come across such situations using Bouncy Castle.</p>
|
<p>It really does not matter if the API/Code is thread safe. CBC encryption in itself is not thread safe.
Some terminology -</p>
<pre><code>E(X) = Enctrypt message X
D(X) = Dectrypt X. (Note that D(E(X)) = X)
IV = Initialization vector. A random sequence to bootstrap the CBC algorithm
CBC = Cipher block chaining.
</code></pre>
<p>A really simple CBC implementation can look like:
P1, P2, P3 = Plain text messages</p>
<pre><code>1. Generate an IV, just random bits.
2. Calculate E( P1 xor IV) call this C1
3. Calculate E( P2 xor C1) call this C2
4. Calculate E( P3 xor C2) call this C3.
</code></pre>
<p>As you can see, the result of encrypting P1, P2 and P3 (in that order) is different from encrypting P2, P1 and P3 (in that order). </p>
<p>So, in a CBC implementation, order is important. Any algorithm where order is important can not, by definition, be thread safe. </p>
<p>You can make a Singleton factory that delivers encryption objects, but you cant trust them to be thread safe. </p>
|
<p>The J2ME version is not thread safe.</p>
| 7,208
|
<p>I've seen it mentioned in many blogs around the net, but I believe it shoud be discussed here.
What can we do when we have an MVC framework (I am interested in ZEND) in PHP but our host does not provide mod_rewrite?
Are there any "short-cuts"? Can we transfer control in any way (so that a mapping may occur between pages)? Any ideas?
Thank you :-)</p>
|
<p>Zend framework should work without <code>mod_rewrite</code>. If you can live with your URL:s looking more like "/path/to/app/index.php/controller/action". If you had mod_rewrite you could do away with the "index.php" bit, but it should work with too.</p>
<p>It's all a matter of setting up the routes to accept the index.php part.</p>
|
<p>Drupal's rewrite rules translate</p>
<p><a href="http://example.com/path/goes/here" rel="nofollow noreferrer">http://example.com/path/goes/here</a></p>
<p>into</p>
<p><a href="http://example.com/index.php?q=path/goes/here" rel="nofollow noreferrer">http://example.com/index.php?q=path/goes/here</a></p>
<p>...and has logic to decide which flavor of URLs to generate. If you can live with ugly URLs, this would let you keep all the logic of a single front controller in place w/o relying on URL rewriting.</p>
| 3,462
|
<p>I am trying to generate a report by querying 2 databases (Sybase) in classic ASP.</p>
<p>I have created 2 connection strings:<br></p>
<blockquote>
<p>connA for databaseA<br>
connB for databaseB</p>
</blockquote>
<p>Both databases are present on the same server (don't know if this matters)<br></p>
<p>Queries:</p>
<p><code>q1 = SELECT column1 INTO #temp FROM databaseA..table1 WHERE xyz="A"</code></p>
<p><code>q2 = SELECT columnA,columnB,...,columnZ FROM table2 a #temp b WHERE b.column1=a.columnB</code></p>
<p>followed by:</p>
<pre><code>response.Write(rstsql) <br>
set rstSQL = CreateObject("ADODB.Recordset")<br>
rstSQL.Open q1, connA<br>
rstSQL.Open q2, connB
</code></pre>
<p>When I try to open up this page in a browser, I get error message:</p>
<blockquote>
<p>Microsoft OLE DB Provider for ODBC Drivers error '80040e37'</p>
<p>[DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]#temp not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).</p>
</blockquote>
<p>Could anyone please help me understand what the problem is and help me fix it?</p>
<p>Thanks.</p>
|
<p>With both queries, it looks like you are trying to insert into #temp. #temp is located on one of the databases (for arguments sake, databaseA). So when you try to insert into #temp from databaseB, it reports that it does not exist.</p>
<p>Try changing it from <em>Into <strong>#temp</strong> From</em> to <em>Into <strong>databaseA.dbo.#temp</strong> From</em> in both statements. </p>
<p>Also, make sure that the connection strings have permissions on the other DB, otherwise this will not work.</p>
<p>Update: relating to the temp table going out of scope - if you have one connection string that has permissions on both databases, then you could use this for both queries (while keeping the connection alive). While querying the table in the other DB, be sure to use [DBName].[Owner].[TableName] format when referring to the table.</p>
|
<p>your temp table is out of scope, it is only 'alive' during the first connection and will not be available in the 2nd connection
Just move all of it in one block of code and execute it inside one conection</p>
| 3,716
|
<p>What are the ways to retrieve data submitted to the web server from a form in the client HTML in ASP.NET?</p>
|
<p>You can also search through both the Form and QueryString collections at the same time so that the data will be found regardless of the the request method.</p>
<pre><code>value = Request("formElementID")
</code></pre>
|
<p>In VB.NET</p>
<p>For POST requests:</p>
<pre><code>value = Request.Form("formElementID")
</code></pre>
<p>For GET requests:</p>
<pre><code>value = Request.QueryString("formElementID")
</code></pre>
| 5,064
|
<p>I have a distributed Java application running on 5 application servers. The servers all use the same Oracle 9i database running on a 6th machine.</p>
<p>The application need to prefetch a batch of 100 IDs from a sequence. It's relatively easy to do in a single-threaded, non-distributed environment, you can just issue these queries:</p>
<pre class="lang-sql prettyprint-override"><code>SELECT seq.nextval FROM dual;
ALTER SEQUENCE seq INCREMENT BY 100;
SELECT seq.nextval FROM dual;
</code></pre>
<p>The first select fetches the first sequence ID that the application can use, the second select returns the last one that can be used.</p>
<p>Things get way more interesting in a multithreaded environment. You can't be sure that before the second select another thread doesn't increase the sequence by 100 again. This issue can be solved by synchronizing the access on the Java side - you only let one thread begin fetching the IDs at one time.</p>
<p>The situation becomes really hard when you can't synchronize because parts of the application doesn't run on the same JVM, not even on the same physical machine. I found some references on forums that others have problems with solving this problem too, but none of the answers are really working not to mention being reasonable.</p>
<p>Can the community provide a solution for this problem?</p>
<p>Some more information:</p>
<ul>
<li>I can't really play with the transaction isolation levels. I use JPA and the change would affect the entire application, not only the prefetching queries and that's not acceptable for me.</li>
<li><p>On PostgreSQL I could do the following:
<code>SELECT setval('seq', NEXTVAL('seq') + n - 1)</code></p></li>
<li><p>The solution by Matthew works when you can use a fixed increment value (which is perfectly acceptable in my case). However is there a solution when you don't want to fix the size of the increment, but want to adjust it dynamically?</p></li>
</ul>
|
<p>Why not just have the sequence as increment by 100 all the time? each "nextval" gives you 100 sequence numbers to work with</p>
<pre><code>SQL> create sequence so_test start with 100 increment by 100 nocache;
Sequence created.
SQL> select so_test.nextval - 99 as first_seq, so_test.currval as last_seq from dual;
FIRST_SEQ LAST_SEQ
---------- ----------
1 100
SQL> /
FIRST_SEQ LAST_SEQ
---------- ----------
101 200
SQL> /
FIRST_SEQ LAST_SEQ
---------- ----------
201 300
SQL>
</code></pre>
<p>A note on your example.. Watch out for DDL.. It will produce an implicit commit</p>
<p><strong>Example of commit produced by DDL</strong></p>
<pre><code>SQL> select * from xx;
no rows selected
SQL> insert into xx values ('x');
1 row created.
SQL> alter sequence so_test increment by 100;
Sequence altered.
SQL> rollback;
Rollback complete.
SQL> select * from xx;
Y
-----
x
SQL>
</code></pre>
|
<p>Matthew has the correct approach here. In my opinion, it is very unusual for an application to reset a sequence's current value after every use. Much more conventional to set the increment size to whatever you need upfront.</p>
<p>Also, this way is much more performant. Selecting nextval from a sequence is a highly optimised operation in Oracle, whereas running ddl to alter the sequence is much more expensive.</p>
<p>I guess that doesn't really answer the last point in your edited question...</p>
| 6,541
|
<p>Is it possible to see the history of changes to a particular line of code in a Subversion repository?</p>
<p>I'd like, for instance, to be able to see when a particular statement was added or when that statement was changed, even if its line number is not the same any more.</p>
|
<p>I don't know a method for tracking statements through time in Subversion.</p>
<p>It is simple however to see when any particular line in a file was last changed using <code>svn blame</code>. Check the SVNBook: <a href="http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.blame.html" rel="noreferrer"><code>svn blame</code> reference</a>:</p>
<p><strong>Synopsis</strong></p>
<pre><code>svn blame TARGET[@REV]...
</code></pre>
<p><strong>Description</strong></p>
<p>Show author and revision information in-line for the specified files or URLs. Each line of text is annotated at the beginning with the author (username) and the revision number for the last change to that line.</p>
|
<p>The command you're looking for is <a href="http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.blame.html" rel="nofollow noreferrer"><code>svn blame</code></a>.</p>
| 7,716
|
<p>Scenario: Document library in SharePoint with column x of "Person or Group" type. From within a VBA macro (or VSTO add-in) we're trying to access the MetaProperty on the document to set/get the user name. Any attempt to access the value via the ContentTypeProperties collection throws a </p>
<blockquote>
<p>Type MisMatch error (13).</p>
</blockquote>
<p>The Type property of the MetaProperty object says it's <code>msoMetaPropertyTypeUser</code>. I cannot find any examples of how to work with MetaProperties of this type. Anyone have any experience with this?</p>
<p>Thanks!</p>
|
<p>Are you executing the programs directly or going through the shell? If you always launch an external program by giving the full path name to the executable and leaving the shell out of the equation, then you aren't really susceptible to any kind of command line injection.</p>
<p>EDIT: DrFloyd, the shell is responsible for evaluating things like the backtick. No shell, no shell evaluation. Obviously, you've still got to be aware of any potential security gotchas in the programs that you're calling -- but I don't think this question is about that.</p>
|
<p>Well, if you can invoke the tools programmatically without the command line, that would probably be your best option. Otherwise, you could potentially execute the command line tool via a user that has absolutely no access to do anything (except perhaps a single directory that they can't do any harm with)... though that may end up breaking the tool, depending on what the tool does.</p>
<p>Just note, I have never had to face this problem, because I have never actually had to invoke a command line tool from an externally facing application where the tool requires input from the user.</p>
| 6,659
|
<p>I need to print parts that fit together very well on the Longer LK5 Pro. However, after printing a Benchy, I noticed that whatever I print has a lot of imperfections. Is there any way I can fix this? All I know about the printing conditions was that I was printing at 230 °C nozzle temperature with 60 °C bed temperature. I was using PLA+. I was also printing the Benchy file that comes with the Longer LK5 printer. I tried tightening the Y-axis belt, that moves the bed, and the wheels on the bottom of the bed.</p>
<p>Here are pictures of my Benchy:</p>
<p><a href="https://i.stack.imgur.com/K7a2T.jpg" rel="nofollow noreferrer" title="Top View"><img src="https://i.stack.imgur.com/K7a2T.jpg" alt="Top view" title="Top View" /></a></p>
<p><a href="https://i.stack.imgur.com/Cm7Jt.jpg" rel="nofollow noreferrer" title="Left hand side view"><img src="https://i.stack.imgur.com/Cm7Jt.jpg" alt="Side view" title="Left hand side view" /></a></p>
<p><a href="https://i.stack.imgur.com/ZYNXx.jpg" rel="nofollow noreferrer" title="Bottom view"><img src="https://i.stack.imgur.com/ZYNXx.jpg" alt="Bottom view" title="Bottom view" /></a></p>
<p><a href="https://i.stack.imgur.com/3KTtu.jpg" rel="nofollow noreferrer" title="Right hand side view"><img src="https://i.stack.imgur.com/3KTtu.jpg" alt="Right hand side view" title="Right hand side view" /></a></p>
|
<p><a href="https://www.longer3d.com/products/lk5-pro-fdm-3d-printer" rel="nofollow noreferrer">Looking up your printer</a>, one thing I noticed is that it has power loss recovery. This feature writes to the SD card at the start of each new layer, stalling the print for at least a significant fraction of a second with the filament unretracted, which will make a nasty blob wherever the toolhead happens to be positioned. Absolutely turn this off. It's impossible to get quality prints with that feature on. If there's no menu option to turn it off, you'll have to rebuild the firmware or get alternate firmware from someone else.</p>
<p>It looks like you have moderate overextrusion. If the esteps were tuned, you probably adjusted them too much in the direction to increase extrusion and should reset to the factory setting and calibrate again, erring on the side of less extrusion rather than more.</p>
<p>There are a number of places (especially on the cabin) where some walls are inset relative to where the wall was supposed to be, and where it's present in other layers. This is almost surely a result of losing material to oozing in the interior of the model, as a result of "combing". See <a href="https://3dprinting.stackexchange.com/a/11005/11157">this answer</a> for details.</p>
<p>On the hull (especially the bow), it looks like you might be experiencing the consequences of numerical precision bugs in Cura, which result in erroneous tiny segments that break up smooth traversal of curves, leaving blobs where the toolhead stutters. Watch during printing and see if the nozzle is stuttering (suddenly slowing down then speeding up again) along these curves. If so, make sure the Maximum Resolution and Maximum Deviation settings are 0.5 and 0.025 respectively. These are the modern Cura defaults that avoid the problem, but some profiles (and some older versions of Cura) have values that trigger the bugs.</p>
|
<p>Just got an LK5 and printed the included Benchy gcode. It looks pretty similar to the benchy in the pics with some of the blobs in the same location. Then I downloaded the benchy from Thingiverse and sliced it with the Longer 1.3 Slicer. Pretty good results from doing that but it took longer to print.</p>
| 2,133
|
<p>Knowing an exception code, is there a way to find out more about what the actual exception that was thrown means?</p>
<p>My exception in question:
0x64487347</p>
<p>Exception address: 0x1</p>
<p>The call stack shows no information.</p>
<p>I'm reviewing a .dmp of a crash and not actually debugging in Visual Studio.</p>
|
<p>Because you're reviewing a crash dump I'll assume it came in from a customer and you cannot easily reproduce the fault with more instrumentation.</p>
<p>I don't have much help to offer save to note that the exception code 0x64487347 is ASCII "dShG", and developers often use the initials of the routine or fault condition when making up magic numbers like this.</p>
<p>A little Googling turned up one hit for dHsg in the proper context, the name of a function in a Google Book search for "Using Visual C++ 6" By Kate Gregory. Unfortunately that alone was not helpful.</p>
|
<p>If you know which block threw the exceptioon, can you put more specific handlers in the catch block to try and isolate it that way?</p>
<p>Are you throwing an exception that you rolled yourself?</p>
<p>Edit: I forgot to point you towards <a href="http://www.codeproject.com/Articles/2126/How-a-C-compiler-implements-exception-handling" rel="nofollow noreferrer">this article</a> on Visual C++ exceptions which I've found to be quite useful.</p>
<p>Rob</p>
| 8,662
|
<p>Is there a system stored procedure to get the version #?</p>
|
<p>Try </p>
<pre><code>SELECT @@VERSION
</code></pre>
<p>or for SQL Server 2000 and above the following is easier to parse :) </p>
<pre><code>SELECT SERVERPROPERTY('productversion')
, SERVERPROPERTY('productlevel')
, SERVERPROPERTY('edition')
</code></pre>
<p>From: <a href="http://support.microsoft.com/kb/321185" rel="noreferrer">http://support.microsoft.com/kb/321185</a></p>
|
<p>Try this:</p>
<pre><code>SELECT
'the sqlserver is ' + substring(@@VERSION, 21, 5) AS [sql version]
</code></pre>
| 8,404
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.