instruction stringlengths 27 22.5k | chosen stringlengths 27 28.2k | rejected stringlengths 19 24.9k | __index_level_0__ int64 0 10k |
|---|---|---|---|
<p>I'm building an application in C# using WPF. How can I bind to some keys?</p>
<p>Also, how can I bind to the <a href="http://en.wikipedia.org/wiki/Windows_key" rel="noreferrer">Windows key</a>?</p>
| <p>I'm not sure of what you mean by "global" here, but here it goes (I'm assuming you mean a command at the application level, for example, <em>Save All</em> that can be triggered from anywhere by <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>S</kbd>.)</p>
<p>You find the global <code>UIElement</code> of your cho... | <p><code>RegisterHotKey()</code> suggested by John could work - the only catch is that it requires an HWND (using <code>PresentationSource.FromVisual()</code>, and casting the result to an HwndSource). </p>
<p>However, you'll also need to respond to the <code>WM_HOTKEY</code> message - I'm not sure if there is a way t... | 7,138 |
<p>I am getting this error now that I hit version number 1.256.0:
Error 4 Invalid product version '1.256.0'. Must be of format '##.##.####'</p>
<p>The installer was fine with 1.255.0 but something with 256 (2^8) it doesn't like. I found this stated on msdn.com:
The Version property must be formatted as N.N.N, whe... | <p>Change it to:</p>
<pre><code>protected static <T extends Comparable<T>> int nullCompare(T o1, T o2) {
</code></pre>
<p>You need that because Comparable is itself a generic type.</p>
| <p>I'm not sure that genericizing this method makes sense. Currently the method works on any kind of Comparable; if you genericize it you will have to implement it (with exactly the same code) multiple times. Sometimes it is possible to compare two objects that don't have a common ancestor, and any generic version won'... | 8,359 |
<p>I want to add auto bed leveling before each print. When I enable auto bed level in <code>configuration.h</code>, it only shows <strong>auto bed</strong> in menu. I found this code in <code>cardreader.cpp</code></p>
<pre><code>void CardReader::openAndPrintFile(const char *name) {
char cmd[4 + strlen(name) + 1]; ... | <p>Rather than modifying the firmware to handle this, have you considered a pre-processing script on your computer, greping for a <code>G29</code> in the G-code, then adding a <code>G28</code>/<code>G29</code> pair at the start of the file if no <code>G29</code> is found?</p>
| <p>I'm not that fluent in G-code, but at <a href="https://www.mmsonline.com/columns/understanding-g27-g28-g29-and-g30" rel="nofollow noreferrer">Modern Machine Shop: Understanding G27, G28, G29 and G30</a> I found these descriptions of the <code>G28</code> and <code>G29</code> codes you added:</p>
<ul>
<li><p><code>G2... | 628 |
<p>Which is the simplest way to check if two integers have same sign? Is there any short bitwise trick to do this?</p>
| <p>What's wrong with</p>
<pre><code>return ((x<0) == (y<0));
</code></pre>
<p>?</p>
| <p>Thinking back to my university days, in most machine representations, isn't the left-most bit of a integer a 1 when the number is negative, and 0 when it's positive?</p>
<p>I imagine this is rather machine-dependent, though.</p>
| 9,243 |
<p>Can you suggest some good MVC framework for perl -- one I am aware of is <a href="http://www.catalystframework.org/" rel="noreferrer">catalyst</a></p>
<p>The need is to be able to expose services on the perl infrastructure which can be called by Java/.Net applications seamlessly.</p>
| <p>I'll tell you right now that Catalyst has by far the best reputation amongst Perl developers in terms of a rapid application development MVC framework. </p>
<p>In terms of "pure" MVC I'm not sure there are even that many "mature" or at least production-ready alternatives.</p>
<p>If Catalyst doesn't seem right to y... | <p>I have built some applications with <a href="https://metacpan.org/pod/Kelp" rel="nofollow">Kelp</a>, it's easy to learn and very helpful.</p>
| 6,734 |
<p>I have a list of 2-item tuples and I'd like to convert them to 2 lists where the first contains the first item in each tuple and the second list holds the second item.</p>
<p><strong>For example:</strong></p>
<pre><code>original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
# and I want to become...
result = (['a', '... | <p><a href="http://docs.python.org/library/functions.html#zip" rel="noreferrer"><code>zip</code></a> is its own inverse! Provided you use the special * operator.</p>
<pre><code>>>> zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)])
[('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
</code></pre>
<p>The way this works is by ca... | <p>Here's a simple one-line answer that produces the desired output:</p>
<pre class="lang-py prettyprint-override"><code>original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
list(zip(*original))
# [('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
</code></pre>
| 3,976 |
<p>I need to take a web page and extract the address information from the page. Some are easier than others. I'm looking for a firefox plugin, windows app, or VB.NET code that will help me get this done.</p>
<p>Ideally I would like to have a web page on our admin (ASP.NET/VB.NET) where you enter a URL and it scraps th... | <p>I've never done this, but here are a couple things you could try. First, you could implement a custom <a href="http://java.sun.com/javase/6/docs/api/java/awt/Stroke.html" rel="nofollow noreferrer">Stroke</a> that creates skinny trapezoids. The width of the end caps would be a function of the pressure at the end poin... | <p>PostScript RIPs often convert circles to curves and curves to a series of straight line segments. The number of segments depends on the flatness setting which defaults to one suitable for the raster display resolution.</p>
<p>A thick line or thick line segments can be converted to a skinny filled polygon.</p>
| 6,408 |
<p>I'm trying to run a batch file, as another user, from my web app. For some reason, the batch file hangs! I can see "cmd.exe" running in the task manager, but it just sits there forever, unable to be killed, and the batch file is not running. Here's my code:</p>
<pre><code>SecureString password = new SecureString();... | <p>I believe I've found the answer. It seems that Microsoft, in all their infinite wisdom, has blocked batch files from being executed by IIS in Windows Server 2003. Brenden Tompkins has a work-around here:</p>
<p><a href="http://codebetter.com/blogs/brendan.tompkins/archive/2004/05/13/13484.aspx" rel="noreferrer">htt... | <p>My guess would be that the build.cmd is waiting for some sort of user-interaction/reply. If you log the output of the command with the "<strong>> logfile.txt</strong>" operator at the end, it might help you find the problem.</p>
| 5,437 |
<p>I've always heard that in C you have to really watch how you manage memory. And I'm still beginning to learn C, but thus far, I have not had to do any memory managing related activities at all.. I always imagined having to release variables and do all sorts of ugly things. But this doesn't seem to be the case.</p>
... | <p>There are two places where variables can be put in memory. When you create a variable like this:</p>
<pre><code>int a;
char c;
char d[16];
</code></pre>
<p>The variables are created in the "<strong>stack</strong>". Stack variables are automatically freed when they go out of scope (that is, when the code c... | <p>Sure. If you create an object that exists outside of the scope you use it in. Here is a contrived example (bear in mind my syntax will be off; my C is rusty, but this example will still illustrate the concept):</p>
<pre><code>class MyClass
{
SomeOtherClass *myObject;
public MyClass()
{
//The object ... | 4,453 |
<p>I'm sure most of you are writing lots of automated tests and that you also have run into some common pitfalls when unit testing. </p>
<p>My question is do you follow any rules of conduct for writing tests in order to avoid problems in the future? To be more specific: What are the <strong>properties of good unit tes... | <p>Let me begin by plugging sources - <a href="http://pragprog.com/titles/utj/pragmatic-unit-testing-in-java-with-junit" rel="nofollow noreferrer">Pragmatic Unit Testing in Java with JUnit</a> (There's a version with C#-Nunit too.. but I have this one.. its agnostic for the most part. Recommended.)</p>
<p>Good Tests s... | <p>Often unit tests are based on mock object or mock data.
I like to write three kind of unit tests:</p>
<ul>
<li>"transient" unit tests: they create their own mock objects/data and test their function with it, but destroy everything and leave no trace (like no data in a test database)</li>
<li>"persistent" unit test:... | 8,660 |
<p>How can I use the Prototype library and create unobtrusive javascript to inject the onmouseover and onmouseout events to each row, rather than putting the javascript in each table row tag?</p>
<p>An answer utilizing the Prototype library (instead of mootools, jQuery, etc) would be most helpful.</p>
| <pre><code><table id="mytable">
<tbody>
<tr><td>Foo</td><td>Bar</td></tr>
<tr><td>Bork</td><td>Bork</td></tr>
</tbody>
</table>
<script type="text/javascript">
$$('#mytable tr').each(function... | <p>I found ab interesting solution for Rows background, the rows highlighting on mouse over, without JS. Here is <a href="http://www.sopov.com/joomla-wordpress-tips-and-tricks/70-how-highlight-table-row-background.html" rel="nofollow noreferrer">link</a></p>
<p>Works in all browsers. For IE6/7/8 ...</p>
<pre><code>t... | 7,548 |
<p>a colleague pointed me the other day to <a href="http://jakarta.apache.org/bcel/" rel="nofollow noreferrer">BCEL</a> which , as best I can tell from his explanation and a quick read, a way to modify at run time the byte code. My first thought was that it sounded dangerous, and my second thought was that it sounded ... | <p>It's a bit more low-level than classic monkey patching, and from what I read, the classes already loaded into the VM are not updated. It only supports saving it to class files again, not modifying run time classes.</p>
| <p>You might look at it as monkey patching. I prefer not to use it (maybe I never faced a good use case for it?), but be familiar with it (to have an idea how Spring and Hibenrate use it and why).</p>
| 6,393 |
<p>I have upgraded a MS Visual Studio Application from VS 2003 to VS 2008 (Targeting .NET 2.0). As part of the conversion process the wizard said I needed to take the additional step of Converting my Project to a Website by Right-Clicking and blah blah blah...</p>
<p>I didn't follow directions and the web application ... | <p>There are two types of web applications in ASP.NET: The Web Site and Web Application Project. The difference between the two are discussed here:</p>
<p><a href="http://www.dotnetspider.com/resources/1520-Difference-between-web-site-web-application.aspx" rel="noreferrer">Difference between web site and web applicati... | <blockquote>
<p>There are two types of web applications in ASP.NET: The Web Site and Web Application Project.
Convert to Website allows you to convert a Web Application Project to a Web Site.</p>
</blockquote>
<p>As far as I can recall, Convert to a Website does not do this, the Web Application project is a regula... | 6,465 |
<p>I'm using Ruby on Rails for an internal site. Different users of the site have access to a wide variety of data and highly disparate perspectives of the data. Within those different classes of users, there needs to be levels of access. Within the levels of access I need to be able to add features from other classes ... | <p>Another totally different approach would be to use acts_as_authenticated and authorization plugins. The tables will be built by the plugins (ie <strong>users</strong>, <strong>roles</strong> and <strong>roles</strong>_users). From the doc:</p>
<blockquote>
<p>The authorization plugin provides the following:</p>
<... | <p>Another totally different approach would be to use acts_as_authenticated and authorization plugins. The tables will be built by the plugins (ie <strong>users</strong>, <strong>roles</strong> and <strong>roles</strong>_users). From the doc:</p>
<blockquote>
<p>The authorization plugin provides the following:</p>
<... | 5,296 |
<p>I started an application in Google App Engine right when it came out, to play with the technology and work on a pet project that I had been thinking about for a long time but never gotten around to starting. The result is <a href="http://www.bowlsk.com" rel="noreferrer">BowlSK</a>. However, as it has grown, and fe... | <p>First, I would suggest you have a look at "<a href="http://sites.google.com/site/io/rapid-development-with-python-django-and-google-app-engine" rel="noreferrer">Rapid Development with Python, Django, and Google App Engine</a>"</p>
<p>GvR describes a general/standard project layout on page 10 of his <a href="http://... | <p>I am not entirely up to date on the latest best practices, et cetera when it comes to code layout, but when I did my first GAE application, I used something along your second option, where the code and templates are next to eachother.</p>
<p>There was two reasons for this - one, it kept the code and template nearby... | 7,089 |
<p>I was wondering if anyone that has experience in both this stuff can shed some light on the <em>significant</em> difference between the two if any?</p>
<p>Any specific strength of each that makes it suitable for any specific case?</p>
| <p>This question is quite dated but as it is still getting traffic and answers I though I state my point here again even so I already did it on some other (newer) questions.</p>
<p>I'm <em><strong>really really</strong></em> baffled that SimpleTest <strong>still</strong> is considered an alternative to phpunit. Maybe i... | <p>when there are thousands functions to test at one go, phpunit is way to go, simple test is falling short as it web based. </p>
<p>I am still using simple web to for small scale test . </p>
<p>But both are good</p>
| 5,452 |
<p>I'm working on a .net post-commit hook to feed data into OnTime via their Soap SDK. My hook works on Windows fine, but on our production RHEL4 subversion server, it won't work when called from a shell script.</p>
<pre>
#!/bin/sh
/usr/bin/mono $1/hooks/post-commit.exe "$@"
</pre>
<p>When I execute it with parameter... | <p>It is normal for some processes to hang around for a while after they close their stdout (ie. you get an end-of-file reading from them). You need to call <code>proc.WaitForExit()</code> after reading all the data but before checking ExitCode.</p>
| <p>Just a random thought that might help with debugging. Try changing your shell script to:</p>
<pre><code>#!/bin/sh
echo /usr/bin/mono $1/hooks/post-commit.exe "$@"
</code></pre>
<p>Check and see if the line it prints matches the command you're expecting it to run. It's possible your command line argument handling... | 7,811 |
<p>Nokia has stopped offering its Developer's Suite, relying on other IDEs, including Eclipse. Meanwhile, Nokia changed its own development tools again and EclipseMe has also changed. This leaves most documentation irrelevant. </p>
<p>I want to know what does it take to make a simple Hello-World?</p>
<p>(I already fo... | <p>Here's what's needed to make a simple hello world -</p>
<ol>
<li>Get <a href="http://www.eclipse.org/downloads/" rel="nofollow noreferrer">Eclipse</a> IDE for Java. I used Ganymede. Set it up.</li>
<li>Get Sun's <a href="http://java.sun.com/products/sjwtoolkit/download.html" rel="nofollow noreferrer">Wireless Toolk... | <p>The most annoying issue with EclipseME for me was the "broken" debugger, which just wouldn't start. This is covered in docs, but it took me about an hour to find this tip when I first installed EclipseME, and another hour when I returned to JavaME development a year later, so I decided to share this piece of knowled... | 8,792 |
<p>I am new to 3D printing and need to know if I use steel in printing, do I get the same strength (compression and shear) as steel profiles manufactured in a factory?</p>
| <p>A laser sintered part typically uses what could be described as surface bonding, as it does not melt particularly deeply into the powder. It would not have the same strength characteristics as machined steel or otherwise processed metal. A part constructed from 3d printing using feed metal/welding methods would have... | <p>In terms of FFD plastics:</p>
<p>Using metal infused filaments for FFD printing; definitely not. The properties mixed into the filament will have some affect on the final piece, stronger, heavier, etc for BronzeFill, but still the majority of the print material will be plastic.</p>
<p>However, you can use PLA pla... | 248 |
<p>What's the best way to specify a proxy with username and password for an http connection in python?</p>
| <p>This works for me: </p>
<pre><code>import urllib2
proxy = urllib2.ProxyHandler({'http': 'http://
username:password@proxyurl:proxyport'})
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
urllib2.install_opener(opener)
conn = urllib2.urlopen('http://python.org')... | <p>Or if you want to install it, so that it is always used with urllib2.urlopen (so you don't need to keep a reference to the opener around):</p>
<pre><code>import urllib2
url = 'www.proxyurl.com'
username = 'user'
password = 'pass'
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
# None, with the "WithDefault... | 5,423 |
<p>As an engineer I was initially interested in making parts. For example I designed and printed a better part for something which wasn't available locally, and even had a client who wanted 150 of them. But print time was 23 hours per part. and I didn't have full confidence in the robustness of the part. The layer line... | <blockquote>
<p>Under what circumstances</p>
</blockquote>
<p>When your part has internal geometry that would be difficult and expensive to reproduce using other methods. For example fishing lures which need internal water channels. Fittings or covers that would normally require several parts to be sealed together coul... | <p>I've only just started my journey in 3d printing, but I have a little hobbyist experience in other forms of "structural crafting". I can see a few ways you can use 3d printing to enhance other techniques - the main one being that a printed part can be used to make a mold, which you can then use to cast alu... | 2,128 |
<p>ASP.NET MVC has been <a href="https://stackoverflow.com/questions/tagged/mvc">discussed</a> on this forum a few times. I'm about to do a large <strong>migration</strong> of several websites from classic ASP/ASP.NET WebForms to ASP.NET MVC and was wondering what kind of advice those of you with experience in both tec... | <blockquote>
<p>Any pointers, tips, tricks, or
gotchas to be aware of?</p>
</blockquote>
<p>Well, I think you're probably a little ways away from thinking about tricks & gotchas :) As I'm sure you're aware, ASP.NET MVC is not some new version of ASP.NET, but a totally different paradigm from ASP.NET, you won't... | <p>My opinion is that the two technologies are so different that if you have tightly coupled code in the original Web Form applications that the best approach is to start by picking one of them and converting it by creating a new ASP.NET MVC application and ripping out code into their respective layers. Which will put... | 3,463 |
<p>It's fall of 2008, and I still hear developers say that you should not design a site that requires JavaScript.</p>
<p>I understand that you should develop sites that degrade gracefully when JS is not present/on. But at what point do you not include funcitonality that can only be powered by JS? </p>
<p>I guess th... | <p>Just as long as you're aware of the accessibility limitations you might be introducing, ie for users of screen-reading software, etc.</p>
<p>It's one thing to exclude people because they choose to turn off JS or use a browser which doesn't support it, it's entirely another to exclude them because of a disability.</... | <p>It's the 21st century. People not permitting JavaScript need to exit the last millennium, posthaste. It's a mature, widely used, and very useful technology that is one of the foundations of the recent expansion in useful web services.</p>
| 8,827 |
<p>Printer: SecKit Go w/ BMG/v6 and SKR v1.3/TMC2130 Drivers</p>
<p>Slicer: Simplify3d or Cura (problem is much worse in Cura?)</p>
<p>Long story short - after getting this printer running, I have noticed that it will underextrude ONLY on corners on an internal perimeter specifically once we're above bottom layers - ... | <p>Unsupported parts need to be printed with support. If your supports are too hard to remove, try the Tree Support setting and make sure that your support structure is set up with a gap to the actual print. As we don't know which slier you use, I can't go into more details here.</p>
| <p>You could try printing slower and/or increase cooling ( possibly even a cooler bed temp) if you absolutely want to avoid supports, or just use supports with a support interface and tweak support distance.</p>
| 1,606 |
<p>The company I used to work with has two developers working fulltime, and a handful of freelancers. They're in the process of hiring a new lead developer to try to bring order and management to the development.</p>
<p>But, currently, one of the developers has seen the light of Django (the company has only developed ... | <p>I recently introduced Python to my company, which does consulting work for the Post Office. I did this by waiting until there was a project for which I would be the only programmer, then getting permission to do this new project in Python. I then did another small project in Python with similarly impressive result... | <p>Well, python is a high level language.. its not hard to learn and if the guys already have programming knowledge it should be much easier to learn.. i like django.. i think it should be a nice try to use django .. </p>
| 4,006 |
<p>In my job we have to deploy an application on various environments. It's a standard WAR file which needs a bit of configuration, deployed on Tomcat 6.</p>
<p>Is there any way of creating a 'deployment package' with Tomcat so that you just extract it and it sets up Tomcat as well as your application? I'm not sure th... | <p>lex/flex and yacc/bison provide easy-to-use, well-understood lexer- and parser-generators, and I'd really recommend doing something like that as opposed to doing it procedurally in e.g. Perl. Regular expressions are powerful stuff for ripping apart strings with relatively-, but not totally-fixed structure. With an... | <p>In trying to find my answer, I found this on <a href="http://www.ibm.com/developerworks/edu/au-dw-au-parsingwithantlr-i.html" rel="nofollow noreferrer">ANTLR</a> - might be of use</p>
| 9,616 |
<p>How can I test the same regex against different regular expression engines?</p>
| <p>The most powerful free online regexp testing tool is by far <a href="http://regex101.com/" rel="nofollow noreferrer">http://regex101.com/</a> - lets you select the RE engine (PCRE, JavaScript, Python), has a debugger, colorizes the matches, explains the regexp on the fly, can create permalinks to the regex playgroun... | <p>RegExBuddy so far I concur with and endorse.</p>
| 5,221 |
<p>Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?</p>
| <p>The previously mentioned <code>wmic</code> command is the way to go, as it is installed by default in recent versions of Windows. </p>
<p>Here is my small improvement to generalize it, by retrieving the current name from the environment:</p>
<pre class="lang-dos prettyprint-override"><code>wmic computersystem whe... | <p>If you are looking to do this from Windows 10 IoT, then there is a built in command you can use:</p>
<p><code>setcomputername [newname]</code></p>
<p>Unfortunately, this command does <em>not exist</em> in the full build of Windows 10.</p>
| 7,868 |
<p>Should you set all the objects to <code>null</code> (<code>Nothing</code> in VB.NET) once you have finished with them? </p>
<p>I understand that in .NET it is essential to dispose of any instances of objects that implement the <code>IDisposable</code> interface to release some resources although the object can stil... | <p>Karl is absolutely correct, there is no need to set objects to null after use. If an object implements <code>IDisposable</code>, just make sure you call <code>IDisposable.Dispose()</code> when you're done with that object (wrapped in a <code>try</code>..<code>finally</code>, or, a <code>using()</code> block). But ev... | <p>Some object suppose the <code>.dispose()</code> method which forces the resource to be removed from memory.</p>
| 2,491 |
<p>I am trying to make a structured light 3D scanner using single camera, light projector and a turntable.</p>
<p>After days on Google I did not find any reliable open source project which I can get to work. <a href="https://github.com/jakobwilm/slstudio" rel="noreferrer">SLStudio</a> really seemed a good choice but ... | <p>I did find only one 3d scanner which uses structured light. There is many projects using a laser diode. And these systems are completely opensource.</p>
<h1>Structured Light</h1>
<h2>Structured Light 3D Scanning by kylemcdonald</h2>
<ul>
<li><a href="http://www.instructables.com/id/Structured-Light-3D-Scanning/?A... | <p><a href="http://www.makeralot.com/ciclop-3d-scanner-diy-kit-p196/" rel="nofollow noreferrer" title="BQ Ciclop 3D Scanner">BQ Ciclop 3D Scanner</a></p>
<ul>
<li>Scan Volume: Bigger than 5 cm x 5 cm and smaller than 20 cm x 20 cm</li>
<li>Scanning Precision: 0.5 mm</li>
</ul>
<p>All the necessary parts for Ciclop are ... | 285 |
<p>I tried printing from an STL file on the <em>QIDI TECHNOLOGY 3DP-QDA16-01 Dual Extruder Desktop 3D Printer QIDI TECH I</em>. They recommend using the MakerBot software with the <em>Replicator(Dual)</em> profile. The 3D print that I tried is messed up.</p>
<p>The material used is <strong>PLA</strong>.</p>
<p>Could ... | <p>Your print isn't cooling fast enough. With small, thin prints like this, PLA needs a fair bit of airflow to solidify before the next layer goes down. Your printer doesn't appear to have a proper print-cooling fan, so I have two suggestions:</p>
<ul>
<li>Print two or even three of the part at the same time, spaced a... | <p>I agree with <a href="https://3dprinting.stackexchange.com/questions/1511/irregular-3d-printed-part/1513#1513">RyanCarlyle</a> on this:</p>
<blockquote>
<p>Your print isn't cooling fast enough.</p>
</blockquote>
<p>Please regard <a href="https://3dprinting.stackexchange.com/questions/540/mushy-small-top-layers/5... | 343 |
<p>I have a web service that queries data from this json file, but I don't want the web service to have to access the file every time. I'm thinking that maybe I can store the data somewhere else (maybe in memory) so the web service can just get the data from there the next time it's trying to query the same data. I kin... | <p>Extending on <a href="https://stackoverflow.com/questions/11761/persisting-data-in-net-web-service-memory#11779">Ice^^Heat</a>'s idea, you might want to think about where you would cache - either cache the contents of the json file in the Application cache like so: </p>
<pre><code>Context.Cache.Insert("foo", _
... | <p>ASP.NET caching works just as well with Web services so you can implement regular caching as explained here: <a href="http://msdn.microsoft.com/en-us/library/aa478965.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa478965.aspx</a></p>
| 3,284 |
<p>I've noticed that some sites (usually banks) suppress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item?</p>
| <p>Probably using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.onpaste" rel="nofollow noreferrer"><code>onpaste</code></a> event, and either <code>return false</code> from it or use <code>e.preventDefault()</code> on the Event object.</p>
<p>Note that <code>onpaste</code> is <em>non standa... | <p>Even if it is somewhat possible to intercept the paste event in many browsers (but not all as shown at the link on the previous answer), that is quite unreliable and posible not complete (depending on the browser / OS it may be possible to do the paste operation in different ways that may not be trappable by javascr... | 5,309 |
<p>I'm looking into clustering points on a map (latitude/longitude). Are there any recommendations as to a suitable algorithm that is fast and scalable?</p>
<p>More specifically, I have a series of latitude/longitude coordinates and a map viewport. I'm trying to cluster the points that are close together in order to r... | <p>For a virtual earth application I've used the clustering described
<a href="https://web.archive.org/web/20130410092213/http://www.soulsolutions.com.au/Articles/ClusteringVirtualEarthPart1.aspx" rel="nofollow noreferrer">here</a>. It's lightning fast and easily extensible.</p>
| <p>I looked at various libraries and found them so complex couldn't understand a word so I decided to make my own clustering algorithm</p>
<p>Here goes my code in Java</p>
<pre><code>static int OFFSET = 268435456;
static double RADIUS = 85445659.4471;
static double pi = 3.1444;
public static double lonToX(do... | 9,963 |
<p>I am looking for information on handling search in different ORMs.</p>
<p>Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or ... | <p>I have recently integrated the <a href="http://www.compass-project.org/" rel="nofollow noreferrer">Compass</a> search engine into a Java EE 5 application. It is based on <a href="http://lucene.apache.org/java/docs/index.html" rel="nofollow noreferrer">Lucene Java</a> and supports different ORM frameworks as well as ... | <p>In a Propel 1.3 schema.xml file, you can specify that you'd like all your models to extend a "BaseModel" class that YOU create.</p>
<p></p>
<p>In that BaseModel, you're going to re-define the save() method to be something like this:</p>
<pre><code>public function save(PropelPDO $con = null)
{
if($this->get... | 4,245 |
<p>I have seen two ways of implementing DAO-DVO design.</p>
<p>1) DVO are objects and DAOs are instantiated using factories i.e DAOs are also objects
2) DVOs are again objects but in this case, DAOs are classes which contain only static methods which accept DVOs to perform tasks.</p>
<p>I was wondering which way is b... | <p>Try the Spring Framework. DAOs are initialized via Dependency Injection and are just plain 'ole Java objects.</p>
<p>Then, the methods on the DAO should just use Domain Objects that are used at all layers of the Application.</p>
| <p>I would strongly recommend not using that many layers unless they are really layered physically. eg if you have something like a rich client where you need to send detached objects to update the GUI, otherwise, its a world of pain.</p>
| 4,428 |
<p>I did some tests a while ago and never figured out how to make this work. </p>
<p><strong>The ingredients:</strong></p>
<ul>
<li>COM+ transactional object (developed in VB6) </li>
<li>.Net web application (with transaction) in IIS that...<br>
makes a call to the COM+ component<br>
updates a row in a SQL database... | <p>Because VB and .NET will use different SQL connections (and there is no way to make ADO and ADO.NET share the same connection), your only possibility is to enlist the DTC (Distributed Transaction Coordinator). The DTC will coordinates the two independent transactions so they commit or are rolled-back together.</p>
... | <p>How are you implementing this? If you are using EnterpriseServices to manage the .NET transaction, then both transactions should get rolled back, since you're using the same context for them both.</p>
| 4,173 |
<p>I need the month+year from the datetime in SQL Server like 'Jan 2008'. I'm grouping the query by month, year. I've searched and found functions like datepart, convert, etc., but none of them seem useful for this. Am I missing something here? Is there a function for this?</p>
| <p>If you mean you want them back as a string, in that format;</p>
<pre><code>SELECT
CONVERT(CHAR(4), date_of_birth, 100) + CONVERT(CHAR(4), date_of_birth, 120)
FROM customers
</code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/ms187928.aspx" rel="noreferrer">Here are the other format options</a></p... | <p>The following works perfectly! I just used it, try it out.</p>
<pre><code>date_format(date,'%Y-%c')
</code></pre>
| 6,744 |
<p>Instead of writing my ASP.NET C# applications in Visual Studio, I used my favorite text editor UltraEdit32.</p>
<p>Is there any way I can implement MVC without the use of VS?</p>
| <p>There is nothing VS specific with the MVC framework - it is just a bunch of DLLs that you can use. The wizards in VS just build you a quick-start framework.</p>
<p>ASP.NET MVC is "bin-deployable" - there is nothing too clever to set up on the server either - just point the wildcard ISAPI filter to ASP.NET</p>
| <p>For small to mid size mvc project <a href="http://www.microsoft.com/web/webmatrix/" rel="nofollow">WebMatrix</a> is not bad at all. Also for simple changes to the projects I often use SublimeText.</p>
| 2,434 |
<p>I have multiple projects in a couple of different workspaces. However, it seems like I can never figure out how to change my current workspace. The result is that files that I have checked out on my machine are shown to be checked out by somebody else and are not accessible.</p>
| <p>I'm going to assume you mean "workspace", not "workstation", as your question doesn't quite make sense to me otherwise.</p>
<p>In Visual Studio, go to the Source Control Explorer (View->Other Windows->Source Control Explorer). At the top of the source control explorer window you should have a toolbar with a few bu... | <p>I don't entirely understand your question.</p>
<p>Are you saying that files you check out on one machine seems to be unaccessible on another of your machines? I'd say that would be entirely by design, as now you have a file that has local modifications done on one machine, which may or may not be available on your ... | 4,223 |
<p>The most common method for corrupting compressed files is to inadvertently do an ASCII-mode FTP transfer, which causes a many-to-one trashing of CR and/or LF characters.</p>
<p>Obviously, there is information loss, and the best way to fix this problem is to transfer again, in FTP binary mode.</p>
<p>However, if th... | <p>From <a href="http://wayback.archive.org/web/jsp/Interstitial.jsp?seconds=5&date=1195189396000&url=http%3A%2F%2Fwww.bukys.com%2Fservices%2Frecovery%2Fexamples%2F&target=http%3A%2F%2Fweb.archive.org%2Fweb%2F20071116050316%2Fhttp%3A%2F%2Fwww.bukys.com%2Fservices%2Frecovery%2Fexamples%2F" rel="nofollow nore... | <p>You could try writing a little script to replace all of the CRs with CRLFs (assuming the direction of trashing was CRLF to CR), swapping them randomly per block until you had the correct crc. Assuming that the data wasn't particularly large, I guess that might not use all of your CPU until the heat death of the uni... | 8,442 |
<p>I have decided that all my WPF pages need to register a routed event. Rather than include</p>
<pre><code>public static readonly RoutedEvent MyEvent= EventManager.RegisterRoutedEvent("MyEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(BasePage));
</code></pre>
<p>on every page, I decided to creat... | <p>Here's how I've done this in my current project.</p>
<p>First I've defined a class (as @Daren Thomas said - just a plain old C# class, no associated XAML file), like this (and yes, this is a real class - best not to ask):</p>
<pre><code>public class PigFinderPage : Page
{
/* add custom events and properties he... | <p>Little update : I just tried to do it, and it didn't work. He is what I changed to solve the problem:</p>
<p>1.In many forums, you will read that the sub pages must inherit from a simple cs class, without XAML. Though it works. I do inherit from a normal XAML page without any problem.</p>
<p>2.I replaced the follo... | 6,098 |
<p>We just started running in to an odd problem with a FileSystemWatcher where the call to Dispose() appears to be hanging. This is code that has been working without any problems for a while but we just upgraded to .NET3.5 SP1 so I'm trying to find out if anyone else has seen this behavior. Here is the code that creat... | <p>Just a thought... Any chance there's a deadlock issue here?</p>
<p>You're calling TreeView.Invoke, which is a blocking call. If a filesystem change happens just as you're clicking whatever button causes the FileSystemWatcher.Dispose() call, your FileWatcherFileChanged method will get called on a background thread ... | <p>We are also having this issue. Our application runs on .Net 2.0 but is compiled by VS 2008 SP1. I have .NET 3.5 SP1 installed as well. I've got no idea why this happens either, it doesn't look like a deadlock issue on our end as no other threads are running at this point (it is during application shutdown).</p>
| 9,882 |
<p>If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be?</p>
<p>I expect this list to be varied and to cover a wide range of things.</p>
<p><strong>To search:</strong> Use the search box in the upper-right corner. To search the a... | <ul>
<li><em>Code Complete</em> (2nd edition) by Steve McConnell</li>
<li><em>The Pragmatic Programmer</em></li>
<li><em>Structure and Interpretation of Computer Programs</em></li>
<li><em>The C Programming Language</em> by Kernighan and Ritchie</li>
<li><em>Introduction to Algorithms</em> by Cormen, Leiserson, Rivest ... | <p><a href="https://rads.stackoverflow.com/amzn/click/com/0201485672" rel="nofollow noreferrer" rel="nofollow noreferrer">Refactoring</a></p>
<p><a href="https://rads.stackoverflow.com/amzn/click/com/0321127420" rel="nofollow noreferrer" rel="nofollow noreferrer">Patterns of Enterprise Application Architecture</a></p>... | 2,403 |
<p>Is there a general rule of thumb to follow when storing web application data to know what database backend should be used? Is the number of hits per day, number of rows of data, or other metrics that I should consider when choosing?</p>
<p>My initial idea is that the order for this would look something like the fo... | <p>It's not quite that easy. The only general rule of thumb is that you should look for another solution when the current one can't keep up anymore. That could include using different software (not necessarily in any globally fixed order), hardware or architecture.</p>
<p>You will probably get a lot more benefit out o... | <p>I think your list is subjective but I will play your game.</p>
<p>Flat Files </p>
<p>BDB </p>
<p>SQLite</p>
<p>MySQL</p>
<p>PostgreSQL</p>
<p>SQL Server </p>
<p>Oracle</p>
<p>Teradata</p>
| 9,992 |
<p>For certain types of sql queries, an auxiliary table of numbers can be very useful. It may be created as a table with as many rows as you need for a particular task or as a user defined function that returns the number of rows required in each query.</p>
<p>What is the optimal way to create such a function?</p>
| <p>Heh... sorry I'm so late responding to an old post. And, yeah, I had to respond because the most popular answer (at the time, the Recursive CTE answer with the link to 14 different methods) on this thread is, ummm... performance challenged at best.</p>
<p>First, the article with the 14 different solutions is fine ... | <p>edit: see Conrad's comment below.</p>
<p>Jeff Moden's answer is great ... but I find on Postgres that the Itzik method fails unless you remove the E32 row.</p>
<p>Slightly faster on postgres (40ms vs 100ms) is another method I found on <a href="http://www.sqlservercentral.com/articles/T-SQL/67899/" rel="nofollow">... | 3,198 |
<p>Jeff covered this a while back <a href="http://www.codinghorror.com/blog/archives/000811.html" rel="nofollow noreferrer">on his blog</a> in terms of 32 bit Vista.</p>
<p>Does the same 32 bit 4 GB memory cap that applies in 32 bit Vista apply to 32 bit Ubuntu? Are there any 32 bit operating systems that have creativ... | <p>In theory, all 32-bit OSes have that problem. You have 32 bits to do addressing.</p>
<pre><code>2^32 bits / 2^10 (bits per kb) / 2^10 (kb per mb) / 2^10 (mb per gb) = 2^2 = 4gb.
</code></pre>
<p>Although there are some ways around it. (Look up the jump from 16-bit computing to 32-bit computing. They hit the same p... | <p>Linux supports a technology called PAE that lets you use more than 4GB of memory, however I don't know whether Ubuntu has it on by default. You may need to compile a new kernel.</p>
<p>Edit: Some threads on the Ubuntu forums suggest that the server kernel has PAE on by default, you could try installing that.</p>
| 7,396 |
<p>Essentially I want to know if in VB.NET 2005 if using a sqlcommand and then reusing it by using the NEW is wrong. Will it cause a memory leak.</p>
<p>EG:</p>
<pre><code>try
dim mySQL as new sqlcommand(sSQL, cnInput)
// do a sql execute and read the data
mySQL = new sqlcommand(sSQLdifferent, cnInput)
// do sq... | <p>Just to extend what Longhorn213 said, here's the code for it:</p>
<pre><code>Using mysql as SqlCommand = new SqlCommand(sSql, cnInput)
' do stuff'
End Using
Using mysql as SqlCommand = new SqlCommand(otherSql, cnInput)
' do other stuff'
End Using
</code></pre>
<p>(edit) Just as an FYI, using automatically wra... | <p>No, the garbage collector will find the old version of mySql and deallocate it in due course.</p>
<p>The garbage collector should pick up anything that's been dereferenced as long as it hasn't been moved into the Large Object Heap.</p>
| 6,388 |
<p>I have a pdf file of a logo, about 1"x2" in dimension. Can anybody provide the code snippet to import that PDF logo into another PDF file using the <a href="http://framework.zend.com/manual/en/zend.pdf.html" rel="nofollow noreferrer">Zend_PDF</a> API's? </p>
<p>Ideally, I'd like to be able to place it like the PN... | <p>It looks like as of this date, there's no way to do it using the Zend_PDF API's. The Zend_Pdf_Page class has a drawContentStream() which looked promising, but when I checked into it, the method body was empty. Maybe a later release of the API will support it. </p>
<p>So, if you want place another PDF inside anot... | <p>Not what you asked for, but probably what you need (:</p>
<p>Convert the smaller logo pdf to a TIFF/PNG/WhatEver (using, for example, imagemagick's <code>convert</code>, or the GIMP). Then, place this image with the normal Zend API.</p>
<p>This conversion could also be done on the fly, using the Imagick php class,... | 9,034 |
<p>When should you use generator expressions and when should you use list comprehensions in Python?</p>
<pre><code># Generator expression
(x*2 for x in range(256))
# List comprehension
[x*2 for x in range(256)]
</code></pre>
| <p><a href="https://stackoverflow.com/a/47792/4518341">John's answer</a> is good (that list comprehensions are better when you want to iterate over something multiple times). However, it's also worth noting that you should use a list if you want to use any of the list methods. For example, the following code won't wo... | <p>For functional programming, we want to use as little indexing as possible. For this reason, If we want to continue using the elements after we take the first slice of elements, islice() is a better choice since the iterator state is saved.</p>
<pre><code>from itertools import islice
def slice_and_continue(sequence... | 7,005 |
<p>Let's say I have a .NET Array of n number of dimensions. I would like to foreach through the elements and print out something like:</p>
<pre><code>[0, 0, 0] = 2
[0, 0, 1] = 32
</code></pre>
<p>And so on. I could write a loop using some the Rank and dimension functions to come up with the indices. Is there a bui... | <p>Thanks for the answer, here is what I wrote while I waited:</p>
<pre><code>public static string Format(Array array)
{
var builder = new StringBuilder();
builder.AppendLine("Count: " + array.Length);
var counter = 0;
var dimensions = new List<int>();
for (int i = 0; i < array.Rank; i++)... | <p><a href="http://forums.msdn.microsoft.com/en-US/csharplanguage/thread/2ca85aa4-0672-40ad-b780-e181b28fcd80/" rel="nofollow noreferrer">Take a look at this:</a> might helpful for you.</p>
| 4,607 |
<p>I've noticed this on almost ever print I've ever had. On the initial first line that clears the extruder nozzle tiny little bubbles/craters seem to form on the line. While I don't think these are causing any issue with my prints I'm curious to know the reason why they form at all. </p>
<p>Is this due to water absor... | <p>Oh yeah, that's simple. You are printing too hot and are literally boiling the plastic. Else you have water. However if it was water you would hear Crackling as it printed. If it is too hot you will not hear nearly as much. I am 87.341% sure you are printing too hot.</p>
<p>Looking at your printing temps you are wit... | <p>There is only one way to find out, which is by isolating any reasons, starting from the simplest one: </p>
<ul>
<li>Firstly, clean and check, or change, your nozzle;</li>
<li>Secondly, if that does not work, then change the filament, or find a way to get it dry (some people, with some filaments, use an oven to get ... | 495 |
<p>I have a SharePoint virtual machine in one active directory domain (for example domain1) and I want to transfer all the sites it has to another active directory domain (domain2).
I don’t know which could be the best procedure to do this, if I detach and attach my virtual machine from domain1 to domain2 it probably d... | <p>There is a <a href="http://stsadm.blogspot.com/2007/09/move-web.html" rel="nofollow noreferrer">STSADM Custom Extension: move web</a> that should be what you are looking for:</p>
<blockquote>
<p>C:>stsadm -help gl-moveweb</p>
<p>stsadm -o gl-moveweb</p>
<p>Moves a web.</p>
<p>Parameters:
-... | <p>You may have some sucess by adding a local account to the administrators group and joining the server to the new domain. Then manualy updateing all of the AD accounts that are used in the server. I sould note that all of your users will then have new accounts that are not related to the old ones.</p>
<p>You sould a... | 9,920 |
<p>I need to create an Aggregate Field in a TClientDataSet, but as said in the docs:</p>
<blockquote>
<p>Choose OK. The newly defined aggregate
field is automatically added to the
client dataset and its Aggregates
property is automatically updated to
include the appropriate aggregate
specification.</p>
</b... | <p>I think you may be getting confused between TAggregate and TAggregateField objects, and the Delphi documentation probably isn't helping.</p>
<p>AFAICT, TAggregateField objects are automatically 'recalculated' and can be bound to data-aware controls like TDBText, but don't have any OnUpdate event. </p>
<p>"TAggrega... | <p>Which version of Delphi ? I just tried clean D7 application and TAggregateField was added. </p>
| 4,221 |
<p>What are the most common memory optimizations in csharp, dotnet 2.0. Wanted to see if there common things that people may not be doing by default in winform app</p>
| <ul>
<li>use structs for small wrapper objects to avoid heap fragmentation</li>
<li>think carefully about object lifetimes, especially for large objects so they do not end up on the LOH unless you intend them to</li>
<li>think about allocations inside of a loop</li>
<li>make sure dynamically sized array will be of reas... | <p>Sealing as much classes as possible should also help. AFAIK this is one trick that SmartAssembly uses to reduce memory consumption.</p>
| 8,560 |
<p>What's the easiest way to print a stacktrace from a debugging printout? Often during testing you would like to know the callstack leading up to the situation provoking a debug message.</p>
| <p><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#dumpStack()" rel="noreferrer">Thread.dumpStack();</a></p>
| <p>Just because I needed it myself:</p>
<p>As inspired by answer <a href="https://stackoverflow.com/questions/421280/in-java-how-do-i-find-the-caller-of-a-method-using-stacktrace-or-reflection">How do I find the caller of a method using stacktrace or reflection?</a> , you can retrieve the call stack using </p>
<pre><... | 7,854 |
<p>I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is t... | <p>EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters.</p>
<p>To answer the original question, one way you could do this, and mind you, this is a bit of a hack, simply <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="noreferrer... | <p>comparing with json is pretty bad. try this package to compare nested arrays and get the difference.</p>
<blockquote>
<p><a href="https://www.npmjs.com/package/deep-object-diff" rel="nofollow noreferrer">https://www.npmjs.com/package/deep-object-diff</a></p>
</blockquote>
| 4,667 |
<p>I have breakpoints set but Xcode appears to ignore them.</p>
| <p>First of all, I agree 100% with the earlier folks that said turn <strong>OFF</strong> <code>Load Symbols Lazily</code>.</p>
<p>I have two more things to add.</p>
<p>(My first suggestion sounds obvious, but the first time someone suggested it to me, my reaction went along these lines: "come on, please, you really t... | <p>I have Xcode Version 4.6.3 and Breakpoints were never working in sub-groups of included projects. The project would compile and run fine; it would even attach to the debugger and spit out NSLog output appropriately.</p>
<p>The issue was related to my Header Search Paths. I had some of them set 'recursive' instead o... | 9,040 |
<p>I'm looking at the <a href="http://www.php.net/manual/en/" rel="noreferrer">PHP Manual</a>, and I'm not seeing a section on data structures that most languages have, such as lists and sets. Am I just blind or does PHP not have anything like this built in?</p>
| <p>The only native data structure in PHP is array. Fortunately, arrays are quite flexible and can be used as hash tables as well.</p>
<p><a href="http://www.php.net/array" rel="noreferrer">http://www.php.net/array</a></p>
<p>However, there is SPL which is sort of a clone of C++ STL.</p>
<p><a href="http://www.php.ne... | <p>PHP can also have an <em>array of arrays</em> which is called a "multidimensional array" or "matrix". You can have 2-dimensional arrays, 3-dimensional arrays, etc.</p>
| 4,241 |
<p>I'm trying to do a basic "OR" on three fields using a hibernate criteria query.</p>
<p>Example</p>
<pre><code>class Whatever{
string name;
string address;
string phoneNumber;
}
</code></pre>
<p>I'd like to build a criteria query where my search string could match "name" or "address" or "phoneNumber".</p>
| <p>You want to use <code>Restrictions.disjuntion()</code>. Like so</p>
<pre><code>session.createCriteria(Whatever.class)
.add(Restrictions.disjunction()
.add(Restrictions.eq("name", queryString))
.add(Restrictions.eq("address", queryString))
.add(Restrictions.eq("phoneNumber", queryString))... | <p>The conditions can be applied using the or / and in different levels of the query
using disjunction</p>
<pre><code>Criteria query = getCriteria("ENTITY_NAME");
query.add(Restrictions.ne("column Name", current _value));
Disjunction disjunction = Restrictions.disjunction();
if (param_1 != null)
disjunction.add(... | 8,173 |
<p>My 3D prints shift along the Y-axis on my Ender 3 3D printer. I don't know what to do. My Y-axis belt is tight, So I don't think that is the problem...</p>
<p><a href="https://i.stack.imgur.com/zVtPS.png" rel="nofollow noreferrer" title="Y-axis layer shifting"><img src="https://i.stack.imgur.com/zVtPS.png" alt="Y-ax... | <p>8 mm rods and 6 mm GT2 belts are generally accepted as a good tradeoff between price and performance, an exact calculation is possible but might not be very relevant if another part is flexing. Also, generally speaking, the smaller the part the sooner it will wear out of specification. Thus your service interval mig... | <p>The 3D printing revolution started out with the idea/community project to build self-replicating machines:</p>
<blockquote>
<p>RepRap was the first of the low-cost 3D printers, and the RepRap Project started the open-source 3D printer revolution. It has become the most widely-used 3D printer among the global members... | 1,772 |
<p>So like I sayed in the title, Why can't the Anet A6 do .05 layer height? I found that some printers can do .05 layer heights, but the Anet A6 can't? I am interested to know if it is the stepper motors or the threaded rods or something. Maybe this is something I can do a small "test print" on? </p>
| <p>I'm not familiar with the Anet A6 specifically, but as many other things in a 3D printer, the minimum layer height is co-determined by a number of factors. For the Z-axis the factors I am aware of are:</p>
<ul>
<li>The number of steps in the stepper motor</li>
<li>The geometry of the lead screw</li>
<li>The tolera... | <p>I have an Anet A6 and once you get your settings dialled in, bed level accurate and belt tensioner correct you can do 0.05 mm very well (although I for some reason went with 0.06 mm and never tried the extra 0.01 mm lower but it shouldn't have an issue). Note: I did this using all the stock parts so 0... | 846 |
<p>What is the best way to disable <kbd>Alt</kbd> + <kbd>F4</kbd> in a c# win form to prevent the user from closing the form?</p>
<p>I am using a form as a popup dialog to display a progress bar and I do not want the user to be able to close it.</p>
| <p>This does the job:</p>
<pre><code>private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
</code></pre>
<p>Edit: In response to pix0rs concern - yes you are correct that you will not be able to programatically close the app. However, you can simply remove the event handler f... | <p>Hide close button on form by using the following in constructor of the form:</p>
<pre><code>this.ControlBox = false;
</code></pre>
| 3,573 |
<p>I have a project that I'm currently working on but it currently only supports the .net framework 2.0. I love linq, but because of the framework version I can't use it. What I want isn't so much the ORM side of things, but the "queryability" (is that even a word?) of Linq. </p>
<p>So far the closest is <a href="http... | <p>Have a look at this:</p>
<p><a href="http://www.albahari.com/nutshell/linqbridge.html" rel="noreferrer">http://www.albahari.com/nutshell/linqbridge.html</a></p>
<p>Linq is several different things, and I'm not 100% sure which bits you want, but the above might be useful in some way. If you don't already have a bo... | <p>There's a way to reference LINQ in the .NET 2.0 Framework, but I have to warn you that it <em>might</em> be against the terms of use/EULA of the framework:</p>
<p><a href="https://stackoverflow.com/questions/2138/linq-on-the-net-20-runtime#2146">LINQ on the .NET 2.0 Runtime</a></p>
| 2,921 |
<h2>Question</h2>
<p>Alright, I'm confused by all the buzzwords and press release bingo going on.</p>
<ul>
<li>What is the relationship between flash and flex:
<ul>
<li>Replace flash (not really compatible)</li>
<li>Enhance flash</li>
<li>The next version of flash but still basically compatible</li>
<li>Separate tec... | <p>The term <strong>Flash</strong> can include any of the other terms defined below, and I find that saying "Flash" without specifying exactly what you mean can be confusing and misleading. Case in point: I'm not sure what you specifically mean when you say "Flash" in your question. Is it Flash Player? The authoring to... | <p>"Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich Internet applications based on the proprietary Adobe Flash platform."</p>
<p><a href="http://en.wikipedia.org/wiki/Adobe_Flex" rel="nofollow noreferrer">Adobe Flex</a></p>
| 8,353 |
<p>I am following the <a href="http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx" rel="noreferrer">M-V-VM</a> pattern for my WPF UI. I would like to hook up a command to the TextChanged event of a TextBox to a command that is in my ViewModel class. The only way I can conceive of completing this task is t... | <p>First off, you've surely considered two-way data binding to your viewmodel, with an UpdateSourceTrigger of PropertyChanged? That way the property setter of the property you bind to will be called every time the text is changed?</p>
<p>If that's not enough, then I would tackle this problem using Attached Behaviours.... | <p>Can you not just handle the TextChanged event and execute the command from there?</p>
<pre><code>private void _textBox_TextChanged(object sender, EventArgs e)
{
MyCommand.Execute(null);
}
</code></pre>
<p>The alternative, as you say, is to create a <code>TextBox</code> that acts as a command source, but that d... | 7,968 |
<p>I want to make an order with this configuration</p>
<ul>
<li>Arduino MEGA 2650 R3</li>
<li>Ramps 1.6 Plus</li>
<li>2 TMC2130 </li>
<li>2 Stepper motors 17hs3401</li>
<li>1 Fan</li>
</ul>
<p><img src="https://i.stack.imgur.com/Nl0sE.png" alt="stepper_motor"></p>
<p>But I am not sure what voltage and current would ... | <p>The easiest way to know how powerful the PSU should be is to download from <a href="https://github.com/rcarlyle/StepperSim" rel="nofollow noreferrer">https://github.com/rcarlyle/StepperSim</a> the Excel workbook which simulates the power absorbed by the stepper motor. Input the motor specifications, check in the gra... | <p>Yes, A power supply that can deliver 12 volts and up to 15 Amps will work. Since that board says 12 V, that means it is designed to work at 12V. The components on the board might not survive 24V. The TMC stepper motor drivers specified can tolerate a max of 2.5 amps. That current draw is dependent on the per phase w... | 1,617 |
<p>My goal is to have a speaker inside a PLA casing to produce a nice hearable sound from a submersible item.</p>
<p>I intended to produce that sound from a Piezo buzzer stuck on a membrane held tight in hollow place between two pieces, but the result is unsatisfactory as the sound gets muffled to inaudible levels.</p>... | <p>In space, no one can hear you scream. That's because there's no air to be vibrated, which is part of the definition of sound.</p>
<p>In the case of your model, the described diaphragm will generate sound because it is surrounded by air. The vibrations in the air will transfer (and reflect) from the PLA shell you've ... | <p>I did a lot of experimentation in this a couple years ago. The limitation on the sound is the amount of energy you can apply to the plastic, and the ability of the plastic to respond (move to) that energy. I ended up using epoxy to fasten a transducer directly to the plastic wall, and while the sound quality was n... | 1,757 |
<p>If i have a simple named query defined, the preforms a count function, on one column:</p>
<pre><code> <query name="Activity.GetAllMiles">
<![CDATA[
select sum(Distance) from Activity
]]>
</query>
</code></pre>
<p>How do I get the result of a sum or any query that dont return of ... | <p>Sorry! I actually wanted a sum, not a count, which explains alot. Iv edited the post accordingly</p>
<p>This works fine:</p>
<pre><code>var criteria = session.CreateCriteria(typeof(Activity))
.SetProjection(Projections.Sum("Distance"));
return (double)criteria.UniqueResult();
</code></... | <p>I think in your original example, you just need to to query.UniqueResult(); the count will return an integer.</p>
| 9,078 |
<p>Are there any useful techniques for reducing the repetition of constants in a CSS file?</p>
<p>(For example, a bunch of different selectors which should all apply the same colour, or the same font size)?</p>
| <p>Recently, <a href="https://www.w3.org/TR/css-variables/" rel="nofollow noreferrer"><strong>variables have been added</strong></a> to the official CSS specs.</p>
<p>Variables allow you to so something like this :</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<d... | <p>You can use multiple inheritance in your html elements (e.g. <code><div class="one two"></code>) but I'm not aware of a way of having constants in the CSS files themselves.</p>
<p>This link (the first found when googling your question) seems to have a fairly indepth look at the issue:</p>
<p><a href="http://... | 5,004 |
<p>I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it.<br>
What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?</p>
| <p>Have you looked at <a href="https://linux.die.net/man/8/logrotate" rel="noreferrer">logrotate</a> - this is probably the simplest, most widely available and well understood method of achieving this. It is highly configurable and will probably do 90% of what you need.</p>
| <p>I have a module that does this for you without the need for external pipes etc :</p>
<p><a href="http://www.poptart.org/bin/view/Poptart/ModAutorotate" rel="nofollow">http://www.poptart.org/bin/view/Poptart/ModAutorotate</a></p>
<p>I've tried to add it to the Apache modules collection but that seems to have been b... | 6,568 |
<p>I have a laptop running Ubuntu that I would like to act as a Subversion server. Both for myself to commit to locally, and for others remotely. What are the steps required to get this working? Please include steps to:</p>
<ul>
<li>Get and configure Apache, and necessary modules (I know there are other ways to create... | <p>Steps I've taken to make my laptop a Subversion server. Credit must go to <a href="http://alephzarro.com/blog/" rel="noreferrer">AlephZarro</a> for his directions <a href="http://alephzarro.com/blog/2007/01/07/installation-of-subversion-on-ubuntu-with-apache-ssl-and-basicauth/" rel="noreferrer">here</a>. I now have ... | <p>For Apache:</p>
<pre><code>sudo apt-get -yq install apache2
</code></pre>
<p>For SSH:</p>
<pre><code>sudo apt-get -yq install openssh-server
</code></pre>
<p>For Subversion:</p>
<pre><code>sudo apt-get -yq install subversion subversion-tools
</code></pre>
<p>If you'd like you can combine these into one command... | 8,571 |
<p>In Flex, I have an xml document such as the following:</p>
<pre><code>var xml:XML = <root><node>value1</node><node>value2</node><node>value3</node></root>
</code></pre>
<p>At runtime, I want to create a TextInput control for each node under root, and have the values ... | <h2>Windows</h2>
<p>Some of the above values are easily available from the appropriate Win32 API, I just list them here for completeness. Others, however, need to be obtained from the Performance Data Helper library (PDH), which is a bit "unintuitive" and takes a lot of painful trial and error to get to work.... | <p>I used this following code in my C++ project and it worked fine:</p>
<pre><code>static HANDLE self;
static int numProcessors;
SYSTEM_INFO sysInfo;
double percent;
numProcessors = sysInfo.dwNumberOfProcessors;
//Getting system times information
FILETIME SysidleTime;
FILETIME SyskernelTime;
FILETIME SysuserTime; ... | 8,875 |
<p>We are currently looking at the scope definition on the Arts & Crafts site. Some 3D subject matter could be on-topic there, and we don't want to steal any thunder from the 3D Printing site. Your "what's on topic" discussion in the Help section covers a lot of subject matter beyond 3D printing per se. It also ... | <p>This answer addresses some of the things that came to mind based on your question.</p>
<ul>
<li>Post processing 3D printed objects is on topic, this includes surface treatment, weathering, annealing and connecting parts (the topic <a href="/q/276">"Game plan - What is on-topic?"</a> suggests connecting parts is off... | <p>We don't get a lot of traffic here on 3D Printing (Beta). I check every day, and often don't find questions to respond to -- and I am prone to over-responding.</p>
<p>Is the intention of SE that questioners (within one particular activity they undertake) will tend to ask questions on one site, or do we expect site... | 72 |
<p>Does anyone know of a good Command Prompt replacement? I've tried bash/Cygwin, but that does not really meet my needs at work because it's too heavy. I'd like a function-for-function identical wrapper on cmd.exe, but with highlighting, intellisense, and (critically) a tabbed interface. Powershell is okay, but the... | <p><em>Edited</em>: I've been using <strong>ConEmu</strong> (<a href="http://conemu.github.io/" rel="noreferrer">http://conemu.github.io/</a>) for quite some time now. This one is a wrapper too, since it is not really possible to replace the Windows console without rewriting the whole command interpreter. Below the lin... | <p>Nick, I know you asked this a long while ago but I've just found it while searching for something related. I have been using <a href="http://www.promptpal.com/" rel="nofollow noreferrer">PromptPal</a> and its been great. I got it about a year ago, early 2008, and it was through this discount software thing called ... | 4,015 |
<p>I've used several modules to make EXEs for Python, but I'm not sure if I'm doing it right.</p>
<p>How should I go about this, and why? Please base your answers on personal experience, and provide references where necessary.</p>
| <p><a href="https://pypi.org/project/auto-py-to-exe/" rel="noreferrer">Auto PY to EXE</a> - A .py to .exe converter using a simple graphical interface built using Eel and PyInstaller in Python.</p>
<hr>
<p><a href="http://www.py2exe.org/" rel="noreferrer">py2exe</a> is probably what you want, but it only works on Wi... | <p><a href="http://www.py2exe.org/" rel="nofollow noreferrer">py2exe</a>:</p>
<blockquote>
<p>py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.</p>
</blockquote>
| 7,157 |
<p>What are the differences between these two and which one should I use?</p>
<pre><code>string s = "Hello world!";
String s = "Hello world!";
</code></pre>
| <p><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/string" rel="noreferrer"><code>string</code></a> is an alias in C# for <a href="https://learn.microsoft.com/en-us/dotnet/api/system.string" rel="noreferrer"><code>System.String</code></a>.<br />
So technically, there is no differenc... | <p>There are at least 4 differences:</p>
<p>1- string is a reserved word, but String is just a class name. This means that string cannot be used as a variable name by itself.</p>
<p>2- you can't use String without "using System".so you write less code by using "string".</p>
<p>3- 'String' is better ... | 2,871 |
<p>I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial . </p>
<p>When i do this everything seems ... | <p><code>/dev/cu.xxxxx</code> is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. <code>/dev/tty.xxxxx</code> is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener.</p>
| <p>have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command being sent across? Also just curious, Python is sending ASCII and not UTF-8 or something else right? The reason I ask is because I noticed your quote changes for the strings and in some languages... | 2,599 |
<p>Recently, I have heard people talking about masterspool, when talking about 3D printing filament.</p>
<ul>
<li>What <em>exactly</em> is master spool?</li>
<li>Where did the idea come from and when?</li>
<li>Is it being widely adopted? Or to be specific, how many distributors/manufacturers have adopted this already,... | <p>A masterspool is the practice of printing your own spool out of filament, which will then be used to support your filament you purchase without a spool attached. The main idea is to create a reusable spool and create less waste. </p>
<p>(<em>NOTE: I'm in no way affiliated with MatterHackers.com, nor am I an endorse... | <p>One key difference between a 'masterspool' and any old spare empty reel you have left over is that the masterspool is a 2-part design which can be fitted over an existing roll of filament without needing to un-spool and re-spool the whole roll.</p>
<p>The idea being that filament can be packaged and secured for shi... | 991 |
<p>I've been aware ever since I got it that my Ender 3's X-axis isn't level. Measuring from the top of it to the top of the frame, the right-hand (positive) side is about 4.7mm higher than the left.</p>
<p>During assembly, the vertical rails were not entirely parallel, and had to be pulled together to get the X axis o... | <p>i've just bought an Ender 3 Pro and on assembly I carefully checked and deburred the uprigh rails on their bottom faces to ensure they did not splay out or in etc.</p>
<p>Once the 2 uprights are loosely attached to the base rails I laid the assembly flat onto a table on the uprights to ensure the uprights were squa... | <p>i've just bought an Ender 3 Pro and on assembly I carefully checked and deburred the uprigh rails on their bottom faces to ensure they did not splay out or in etc.</p>
<p>Once the 2 uprights are loosely attached to the base rails I laid the assembly flat onto a table on the uprights to ensure the uprights were squa... | 1,328 |
<p>Scenario: I'm cruising <a href="https://www.thingiverse.com/" rel="nofollow noreferrer">Thingiverse</a>, and I find the awesomest thing. I NEED THIS IN MY LIFE. I download it, print it, and for whatever reason, it doesn't work quite right. OK, no big deal, I'll just download the source because the maker was so k... | <p>I should start by saying that I am not a lawyer. I have been both the complainant and defendant in patent cases, and have had the role of observing copyright compliance for a performing arts organization. With that in mind, the following is my own opinion and information.</p>
<hr>
<p>Ultimately, there is no simp... | <p>When you remix, either by modifying the existing CAD files (STL or sCAD or whatever), or by rebuilding essentially the same item from scratch, that <strong>is</strong> a remix and subject to whatever restrictions the original author put on his work. </p>
<p>So the critical issue so far as copyright is concerned is... | 965 |
<p>Has anybody managed to get the Android Emulator working behind a proxy that requires authentication?</p>
<p>I've tried setting the -http-proxy argument to</p>
<pre><code>http://DOMAIN/USERNAME:PASSWORD@IP:PORT
</code></pre>
<p>but am having no success.</p>
<p>I've tried following the docs to no avail. I've also trie... | <p>I Managed to do it in the Adndroid 2.2 Emulator.</p>
<pre><code>Go to "Settings" -> "Wireless & Networks" -> "Mobile Networks" -> "Access Point Names" -> "Telkila"
</code></pre>
<p>Over there set the proxy host name in the property "Proxy"
and the Proxy port in the property "Port"</p>
| <p>I had the same problem when i use the following command:</p>
<pre><code>emulator-x86.exe -http-proxy domain\user:password@proxyIP:port -avd MyAVD
</code></pre>
<p>I got the proxy authentication error.</p>
<p>Finally, I had to bypass the proxy NTLM authentication by using the Cntlm here:</p>
<p><a href="http://so... | 4,804 |
<p>I want to put in a date and serial number that would be difficult to erase or change. Is it better to print in the number or engrave it in with a laser engraver.</p>
<p>Material will be anti-bacterial PLA.</p>
<p>It will be on free masks donated to schools, I want to make sure we can identify them when they show up ... | <p>For this specific application, it may be better to think in terms of a <strong>Lot Number</strong> for each batch instead of individual serial numbers. This will still let you trace back an item for where it was originally allocated, and greatly simplify your processing.</p>
<p>Under this plan, you create the STL fi... | <p>Have you considered using a barcode rather than text. It would be easier to print clearly as there are no curves, and would be machine readable.</p>
| 2,058 |
<p>I have two programs. One is in C# and another one in Java.
Those programs will, most probably, always run on the same machine.</p>
<p>What would be the best way to let them talk to each other?</p>
<p>So, to clarify the problem:</p>
<p>This is a personal project (so professional/costly libraries are a no go).
The ... | <p>I am author of <a href="http://jni4net.sf.net/" rel="noreferrer">jni4net</a>, open source interprocess bridge between JVM and CLR. It's build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.</p>
| <p>If they are separate programs and running as independent applications,you may use sockets. I know it's bit complex to define communication protocol but it'll be quite straight-forward.</p>
<p>However if you have just two separate programs but want to run them as single application, then I guess IKVM is a better app... | 3,739 |
<p>I am running MAMP locally on my laptop, and I like to test as much as I can locally. Unfortunately, since I work on e-commerce stuff (PHP), I normally force ssl in most of the checkout forms and it just fails on my laptop. Is there any easy configuration that I might be missing to allow "https" to run under MAMP? Pl... | <p>First, make a duplicate of /Applications/MAMP.</p>
<p>Open /Applications/MAMP/conf/apache/httpd.conf<br>
Below the line<br>
<code># LoadModule foo_module modules/mod_foo.so</code><br>
you add<br>
<code>LoadModule ssl_module modules/mod_ssl.so</code><br>
Remove all lines <code><IfDefine SSL></code> as well as ... | <p>There doesn't seem to be an easier way, <a href="http://www.rocketwerx.com/blog/8-apple/34-getting-ssl-to-work-with-mamp-pro" rel="nofollow noreferrer">unless you're willing to buy MAMP Pro</a>.</p>
<p>As far as I know, the only way to use SSL with MAMP is to <a href="http://www.macosxhints.com/article.php?story=20... | 6,251 |
<p>What is the difference between <a href="https://3dprinting.stackexchange.com/questions/tagged/post-production" class="post-tag" title="show questions tagged 'post-production'" rel="tag">post-production</a> and <a href="https://3dprinting.stackexchange.com/questions/tagged/post-processing" class="post-tag" ti... | <p>These are <strong>NOT</strong> the same in a manufacturing, which 3D printing is primarily considered a part of.</p>
<p>Post-Processing typically refers to additional steps that must/can be done to produce the nominally desired part. These steps can include deburr, grind, and other additive/subtractive processing o... | <p>Post Processing VS Post Production
<strong><a href="http://fixthephoto.com/blog/retouch-tips/editing-retouching-post-processing-post-production-difference.html" rel="nofollow noreferrer">These terms are absolute synonyms. At the same time they can be interchangeable.</a></strong></p>
<hr>
<p>In digital video, phot... | 48 |
<p>I have a web application that generates a medium sized XML dataset to be consumed by a third party.<br>
I thought it would be a good idea to provide some form of schema document for the XML that I generate so I pasted the XML into Visual Studio and got it to generate an XSD.<br>
The annoying thing is that my XML doe... | <p>Whether you choose XSD and/or Schematron depends on what you are trying to validate. XSD is probably the most common validation strategy, but there are limits on what it can validate. If all you want to do is ensure that the right type of data is in each field, XSD should work for you. If you need to assert, for exa... | <p>You will be able to validate your XML with either an XML Schema or a DTD using C#. DTDs are older standards as compared to XML Schemas.</p>
<p>So, I recommend an XML Schema approach.</p>
| 3,732 |
<p>C++ just sucks too much of my time by making me micro-manage my own memory, making me type far too much (hello <code>std::vector<Thingy>::const_iterator it = lotsOfThingys.begin()</code>), and boring me with long compile times. What's the single best alternative for serious real-time graphics programming? Ga... | <p>C# is a nice language that fits your requirements, and it is definitely suited for graphics, thanks to the efforts of Microsoft to provide it with great tools and libraries like Visual Studio and XNA.</p>
| <p>If your target is a PC, I think you can try C#, or embed <strong>Lua</strong> in your C++ app and run scripts for 'high-level' stuff. However if your target is a console, you <strong>must</strong> manage your own memory!</p>
| 9,853 |
<p>I need to <code>ShellExecute</code> something as another user, currently I start a helper process with <code>CreateProcessAsUser</code> that calls <code>ShellExecute</code>, but that seems like too much of a hack (Wrong parent process etc.) Is there a better way to do this?</p>
<p>@PabloG: ImpersonateLoggedOnUser d... | <p>The solution really depends on what your needs are, and can be pretty complex (Thanks fully to Windows Vista). This is probably going to be beyond your need, but this will help others that find this page via search.</p>
<ol>
<li>If you do not need the process to run with a GUI and you do not require elevation</li>... | <p>You can wrap the ShellExecute between ImpersonateLoggedOnUser / RevertToSelf</p>
<p>links:
ImpersonateLoggedOnUser: <a href="http://msdn.microsoft.com/en-us/library/aa378612(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa378612(VS.85).aspx</a>
RevertToSelf: <a href="http://msdn.mi... | 5,368 |
<p>I'm toying with the idea of phasing in an ORM into an application I support. The app is not very structured with no unit tests. So any change will be risky. I'm obviously concerned that I've got a good enough reason to change. The idea is that there will be less boiler plate code for data access and there for greate... | <p>I would strongly recommend getting a copy of Michael Feather's book <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="nofollow noreferrer" rel="nofollow noreferrer">Working Effectively With Legacy Code</a> (by "Legacy Code" Feathers means any system that isn't adequately covered by unit tests).... | <p>The rule for refactoring is. Do unit tests.</p>
<p>So maybe first you should place some unittests at least for the core/major things.</p>
<p>The ORM should be designed for decreasing boilerplate code. The time/trouble vs. ROI to be enterprisy is up to you to estimate :)</p>
| 4,204 |
<p>I'm pretty new to 3D printing, got my printer about 5 days ago and spent most of my time with it.</p>
<p>First off, it is an Ender 3 Pro with everything stock, haven't made any upgrades except I run it with OctoPrint from a Raspberry Pi Zero but I have determined that's not the source of the problem as it's well wit... | <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 frequen... | <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,163 |
<p>I'm working on a boot loader on an x86 machine.</p>
<p>When the BIOS copies the contents of the MBR to 0x7c00 and jumps to that address, is there a standard meaning to the contents of the registers? Do the registers have standard values?</p>
<p>I know that the segment registers are typically set to 0, but will som... | <blockquote>
<p>This early execution environment is highly implementation defined, meaning the implementation of your particular BIOS. Never make any assumptions on the contents of registers. They might be initialized to 0, but they might contain a random value just as well. </p>
</blockquote>
<p>from the <a href="h... | <p>Best option would be to assume nothing. If they have meaning, you will find that from the other side when you need the information they provide.</p>
| 4,071 |
<p>I am creating a Windows Service in C# that processes messages from a queue. I want to give ops the flexibility of partitioning the service in production according to properties of the message. For example, they should be able to say that one instance processes web orders from Customer A, another batch orders from Cu... | <p>No, but you can <strong>PEEK</strong> into the queue and decide if you really want to consume the message.</p>
| <p>Use <em>GetMessageEnumerator2()</em> like this:</p>
<pre><code>MessageEnumerator en = q.GetMessageEnumerator2();
while (en.MoveNext())
{
if (en.Current.Label == label)
{
string body = ((XmlDocument)en.Current.Body).OuterXml;
en.RemoveCurrent();
return body;
}
}
</code></pre>
| 8,970 |
<p>Some 4 years back, I followed this <a href="http://msdn.microsoft.com/en-us/library/ms973825.aspx" rel="noreferrer">MSDN article</a> for DateTime usage best practices for building a .Net client on .Net 1.1 and ASMX web services (with SQL 2000 server as the backend). I still remember the serialization issues I had wi... | <p>I think the best way of doing this is to always pass the object as UTC, and convert to local time on the clients. By doing so, there is a common reference point for all clients.</p>
<p>To convert to UTC, call ToUniversalTime on the DateTime object. Then, on the clients, call ToLocalTime to get it in their current... | <p>For cases where the datetime object should simply stay the same use JsonConvert:</p>
<pre><code>DateTime now = DateTime.Now;
string json = JsonConvert.SerializeObject(now);
DateTime nowJson = JsonConvert.DeserializeObject<DateTime>(json);
</code></pre>
| 9,093 |
<p>Embedded custom-tag in dynamic content (nested tag) not rendering.</p>
<p>I have a page that pulls dynamic content from a javabean and passes the list of objects to a custom tag for processing into html. Within each object is a bunch of html to be output that contains a second custom tag that I would like to also b... | <p>Just using </p>
<pre><code><bodycontent>JSP</bodycontent>
</code></pre>
<p>is not enough. You should do soimething like </p>
<pre><code>JspFragment body = getJspBody();
StringWriter stringWriter = new StringWriter();
StringBuffer buff = stringWriter.getBuffer();
buff.append("<h1>");
body.inv... | <p>I would be inclined to change the "architecture of your tagging" in that the data you wish to achieve should not be by tag on the inside of the class as it is "markup" designed for a page(<em>though in obscurity</em> it is possible to get the evaluating program thread of the JSP Servlet engine).</p>
<p>What you wou... | 7,177 |
<p>As an extension from <a href="https://3dprinting.stackexchange.com/questions/264/when-to-use-1-75mm-vs-3mm-filament">this</a> question, is there any reason that you would not be able to use 1.75 mm filament in a printer that takes 3mm filament? I know you would have to change the filament size in the slicing o... | <p>Typically an extruder and hot end are designed for one or the other, and cannot support the other without mechanical changes.</p>
<p>The extruder may not be able to grip a smaller diameter filament with enough force to assure even feeding and retraction.</p>
<p>The hot end, however, is much more complex. The filam... | <ol>
<li><p>It may work for a short time but you're going to fill the melt chamber quickly and possibly overflow to a point where the filament isn't constrained causing a messy jam. All the molten plastic will likely flow backwards to a point where the diameter isn't 3mm any longer (probably next to your drive gear) b... | 145 |
<p>What's the best framework for creating mock objects in Java? Why? What are the pros and cons of each framework?</p>
| <p>I've had good success using <a href="https://github.com/mockito/mockito" rel="noreferrer">Mockito</a>.</p>
<p>When I tried learning about JMock and EasyMock, I found the learning curve to be a bit steep (though maybe that's just me).</p>
<p>I like Mockito because of its simple and clean syntax that I was able to g... | <p>I started using mocks through JMock, but eventually transitioned to use EasyMock. EasyMock was just that, --easier-- and provided a syntax that felt more natural. I haven't switched since.</p>
| 4,273 |
<p>I have always used <code>||</code> (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: <code>|</code>. What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable?</p>
| <p>Just like the <code>&</code> and <code>&&</code> operator, the double Operator is a "short-circuit" operator.</p>
<p>For example:</p>
<pre><code>if(condition1 || condition2 || condition3)
</code></pre>
<p>If condition1 is true, condition 2 and 3 will NOT be checked.</p>
<pre><code>if(condition1 | con... | <p>The | operator performs a bitwise OR of its two operands (meaning both sides must evaluate to false for it to return false) while the || operator will only evaluate the second operator if it needs to.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/kxszd0kx(VS.71).aspx" rel="nofollow noreferrer">http://msdn... | 5,574 |
<p>Example: You have a shortcut <code>s</code> to <code>SomeProgram</code> in the current directory.</p>
<p>In <code>cmd.exe</code>, you can type <code>s</code> and it will launch the program.</p>
<p>In PowerShell, typing <code>s</code> gives:</p>
<blockquote>
<p><code>The term 's' is not recognized as a cmdlet, f... | <p>On my Vista system typing S won't launch a lnk file unless I have the environment variable PATHEXT set with .lnk in the list. When I do. S will work in cmd.exe and I have to do .\S in powershell.</p>
| <p>You can always use tab completion to type "s[TAB]" and press ENTER and that will execute it.</p>
| 4,257 |
<p>When 3D-printing on an 20*20cm, I've heard that the quality of the printings get worse if I fill out the board... Is it true? Should I keep it to small amounts at the time or doesn't it matter?</p>
| <p>No, that's not (entirely) true. There might be some loss of quality if you print multiple objects at once, because when the printhead "hops" from one object to another it might leave a mark or ooze out some material. Also, a large number of retractions in a short period of time might lead to inconsistent extrusion.<... | <p>Just to add to the other answers already here, I've also had problems with layer adhesion when filling up the print bed on an extrusion printer. The longer the print head spends working on details around a single layer, the more chance the layer has to cool off before the next layer gets started. I've started to s... | 424 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.