instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>In my JSF/Facelets app, here's a simplified version of part of my form:</p> <pre><code>&lt;h:form id="myform"&gt; &lt;h:inputSecret value="#{createNewPassword.newPassword1}" id="newPassword1" /&gt; &lt;h:message class="error" for="newPassword1" /&gt; &lt;h:inputSecret value="#{createNewPassword.newPassword2}"...
<p>In case anyone was curious, I was able to figure this out based on all of your responses combined!</p> <p>This is in the Facelet:</p> <pre><code>&lt;h:form id="myform"&gt; &lt;h:inputSecret value="#{createNewPassword.newPassword1}" id="newPassword1" /&gt; &lt;h:message class="error" for="newPassword1" id="newP...
<p>Simple answer, if you don't need to bind it to a specific component... </p> <p>Java:</p> <pre><code> FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Authentication failed", null); FacesContext context = FacesContext.getCurrentInstance(); context.addMessage(n...
40,778
<p>Has anyone tried the ActiveRecord <a href="http://www.castleproject.org/activerecord/gettingstarted/index.html" rel="nofollow noreferrer">Intro Sample</a> with C# 3.5? I somehow have the feeling that the sample is completely wrong or just out of date. The XML configuration is just plain wrong:</p> <pre><code>&lt;ad...
<p>(This was too long for a comment post)</p> <p>[@Tigraine] From your comments on my previous answer it looks like the error lies not with the configuration, but with one of your entities. Removing the "hibernate" corrected the configuration so that it geve you the real error, which appears to be that the entity "Pos...
<p>Delete the "<code>hibernate.</code>" part for all configuration entries. Your first example is the correct one.</p>
16,134
<p>Given the following classes and controller action method:</p> <pre><code>public School { public Int32 ID { get; set; } publig String Name { get; set; } public Address Address { get; set; } } public class Address { public string Street1 { get; set; } public string City { get; set; } public String ZipCod...
<p>From <a href="http://groups.google.com/group/jquery-en/browse_thread/thread/ba072168939b245a?pli=1" rel="noreferrer">Google Groups</a>:</p> <blockquote> <p>Use two backslashes before each special character.</p> <p>A backslash in a jQuery selector escapes the next character. But you need two of them because...
<p>Just additional information: Check this <a href="http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2403" rel="nofollow noreferrer">ASP.NET MVC issue #2403</a>.</p> <p>Until the issue is fixed, I use my own extension methods like Html.TextBoxFixed, etc. that simply replaces dots with underscores in the id...
45,591
<p>octoprint seems to have a setting that involves googles DNS server.</p> <p>my question is is that server used to access octoprint over the internet via printoid "android app" or via browser? if not then what does it mean? <a href="https://i.stack.imgur.com/MWTnq.jpg" rel="nofollow noreferrer"><img src="https://i.st...
<p>The program is pinging that address to check the internet connection to "prevent resource intensive operations if it's already clear that they won't succeed anyhow". It checks for connectivity, if it has it then it will check for update otherwise it won't check for an update.</p>
<p>That's just Google's DNS (name resolution) server. 8.8.8.8 and 8.8.4.4 are the Google values. Your ISP will also have a DNS server that you could use, which is what it says to use Google's "if you don't know what to set here".</p> <p>Using the Google values are your best bet since they'll pretty much absolutely a...
728
<p>I'm new to NHibernate (my 1st big project with it).<br> I had been using a simple method of data access by creating the ISession object within a using block to do my grab my Object or list of Objects, and in that way the session was destroyed after exiting the code block. </p> <p>This doesn't work in a situation w...
<p>Session management:</p> <p><a href="http://code.google.com/p/dot-net-reference-app/source/browse/trunk/src/Infrastructure/Impl/HybridSessionBuilder.cs" rel="nofollow noreferrer">http://code.google.com/p/dot-net-reference-app/source/browse/trunk/src/Infrastructure/Impl/HybridSessionBuilder.cs</a></p> <p>Session per...
<p>Since you are developing a Web App (presumably with ASP.NET), check out <a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">NHibernate Best Practices with ASP.NET</a> at CodeProject.</p>
5,257
<p>I'm using my printer for some baby toys. My last print was one of those <a href="https://www.thingiverse.com/thing:3556006/files" rel="nofollow noreferrer">pillars for stacking rings</a>, base 5. The basic format includes a base and a pillar coming up perpendicularly in the middle. A box with a cylinder sticking out...
<p>So you are printing at 80 mm/s speed * 0.3 mm layer height * something about 0.5 mm line width, which is about 12 mm<sup>3</sup>/s which is likely too much for many printers.</p> <p>Try keeping linear speed at 60 mm/s and, if you have a 0.4 mm nozzle, never go above 0.24 mm layer thickness if you care about strength...
<p>If you don't object to using adhesive to assemble the model, consider that you can succeed with your objective by performing a plane cut in the vertical direction. This allows you to print the model in the strongest orientation without supports. It will also result in an internal set of faces due to duplication of (...
2,096
<p>I'm using autotools to build a shared object. </p> <p>Using <code>pkglib_LTLIBRARIES</code> in my Makefile.am causes a <code>libtest.la</code> AND <code>libtest.so</code> to be built.</p> <p>I <em>only</em> want it to build/install <code>libtest.so</code>.</p> <p>Is this possible?</p>
<p>The details of generating libraries varies widely from platform to platform. For example, on OS X, your library would be called libtest.dylib rather then libtest.so. libtool is part of the autotools suite, and its job is to abstract away all the messy platform dependent details. To do this, it creates a high-level, ...
<p>Another option would be setting this in <code>configure.ac</code>:</p> <pre><code>LT_INIT([disable-static]) </code></pre> <p>See <a href="https://www.gnu.org/software/libtool/manual/libtool.html#LT_005fINIT" rel="nofollow noreferrer">documentation on LT_INIT</a>.</p>
31,886
<p>I have a site, from which you can download an HTML file. This HTML file contains a form with hidden fields, which is right away posted back to the site using JavaScript. This is a way of allowing users to download to their own machine data that they edit on the site.</p> <p>On some machines, you get an IE "yellow b...
<p>The yellow bar is because your page is executing in the Local Machine security zone in IE. On different machines, the Local Machine security zone might be configured in different ways, so you can see the yellow bar on some machines and not see it on other machines.</p> <p>To learn more about the IE's URL Security Z...
<p>I don't 100% follow what your JavaScript is submitting to, but if you're submitting back to the original site from the downloaded copy you'll have a problem using JavaScript as all browsers treat cross-domain JavaScript as a security violation.</p> <p>JavaScript isn't allowed to read or write to any site not on the...
17,231
<p>Should I include dependencies when I do releases for my common projects such as CommonUtils or should I simply specify which dependencies should be referenced when they are to be used?</p>
<p>You users do not want the work if figuring out your dependencies.</p> <ul> <li>What packages do I need?</li> <li>What if it's not available? (dead server, provider out of business)</li> <li>What version of each one do I need?</li> <li>What if it's not available? (new version)</li> <li>How do I download each one?</l...
<p>I always create two versions (might not be the perfect solution). One with only my own code and 3-tier party dll used. And a bigger version with all the Framework. This way if it's deploy on a new machine I know I will be fine. Otherwise (if update or on a machine I know that dependencies DLL are already there) I us...
27,912
<p>I expected <code>A::~A()</code> to be called in this program, but it isn't:</p> <pre><code>#include &lt;iostream&gt; struct A { ~A() { std::cout &lt;&lt; "~A()" &lt;&lt; std::endl; } }; void f() { A a; throw "spam"; } int main() { f(); } </code></pre> <p>However, if I change last line to </p> <pre><code>...
<p>The destructor is not being called because terminate() for the unhandled exception is called before the stack gets unwound.</p> <p>The specific details of what the C++ spec says is outside of my knowledge, but a debug trace with gdb and g++ seems to bear this out.</p> <p>According to the <a href="http://www.csci.c...
<p>In the second example, the dtor is called when it leaves the try{} block.</p> <p>In the first example, the dtor is called as the program shuts down after leaving the main() function --- by which time cout may already have been destroyed.</p>
27,404
<p>I'm just designing the schema for a database table which will hold details of email attachments - their size in bytes, filename and content-type (i.e. "image/jpg", "audio/mp3", etc).</p> <p>Does anybody know the maximum length that I can expect a content-type to be?</p>
<p>I hope I havn't misread, but it looks like the length is max 127/127 or <strong>255 total</strong>.</p> <p><a href="http://www.ietf.org/rfc/rfc4288.txt?number=4288" rel="noreferrer">RFC 4288</a> has a reference in 4.2 (page 6):</p> <pre><code>Type and subtype names MUST conform to the following ABNF: type-name...
<p>We run an SaaS system that allows users to upload files. We'd originally designed it to store MIME Types up to 50 characters. In the last several days we've seen several attempts to upload 71-bytes types. So, we're changing to 250. 100 seemed "good" but it's only a few more than the max we're seeing now. 500 seems s...
4,024
<p>I recently upgraded to Eclipse Ganymede from Europa and now I'm finding that when I'm editing JSP files the IDE crawls when editing HTML attributes (but not JSP attributes).</p> <p>Has anyone experienced this, or have any suggestions?</p> <p>Also if you can point me to a better place to ask Eclipse related questio...
<p>The visual editors in Eclipse are slow. I have no idea why that is; other graphics frameworks achieve mindboggling effects in Java in real time so they shouldn't be that slow.</p> <p>I suggest you open a bug report against Eclipse. This way, you can give them feedback and see what they think about it plus you can t...
<pre><code>Project &gt; Properties &gt; JavaScript &gt; Include Path &gt; Source </code></pre> <p>Delete dir with tons of <strong>js</strong> files, such as JQuery, etc... Eclipse gets lost with too many <strong>source code</strong> to <strong>compile</strong>.</p>
45,326
<p>I work on a lot of Asian Language localization projects, and am looking for a powerful text editor with the following features:</p> <p>1) Unicode support 2) Find in Files 3) Replace in Files 4) Regular expressions 5) Multiline find/replace 6) Built-in diff</p> <p>I am currently using NotePad++, but it doesn't real...
<p>I use <a href="http://www.esperanto.mv.ru/UniRed/ENG/" rel="nofollow noreferrer">UniRed</a> for Unicode-intensive stuff. (I don't use it as a general purpose editor though: jEdit). UniRed displays the hex value for the current glyph in the lower screen, which is really handy (even for ASCII).</p>
<p><a href="http://www.ultraedit.com/products/ultraedit.html" rel="nofollow noreferrer">Ultraedit</a> is my favorite text editor and it is advertised as having good Unicode support</p> <p><a href="http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/unicode.html" rel="nofollow noreferrer">http://www.ultraed...
29,045
<p>If I need to throw an exception from within my application which of the built-in .NET exception classes can I use? Are they all fair game? When should I derive my own?</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/ms173163.aspx" rel="noreferrer">Creating and Throwing Exceptions</a>.</p> <p>On throwing built-in exceptions, it says:</p> <blockquote> <p>Do not throw System.Exception, System.SystemException, System.NullReferenceException, or System.IndexOutOfRangeException ...
<p>You can create and throw pretty much any of them, but you generally shouldn't. As an example, the various argument validation exceptions (ArgumentException, ArgumentNullException, ArgumentOutOfRangeException, etc) are suitable for use in application code, but AccessViolationException isn't. ApplicationException is p...
26,837
<p>How do I get Asterisk to forward incoming calls based on matching the incoming call number with a number to forward to? Both numbers are stored in a MySQL database.</p>
<p>Sorry for the long code sample, but more than half of it is debugging code to help you get it set up.</p> <p>I'm assuming your server already has a modern version of PHP (at <code>/usr/bin/php</code>) with the PDO library, and that you have a database table named <code>fwd_table</code> with columns <code>caller_id<...
<p><a href="http://scottstuff.net/blog/articles/2004/08/09/database-driven-call-forwarding-with-asterisk" rel="nofollow noreferrer">This article</a> should do the trick. It's about 3 lines of code and some simple queries to add and remove forwarding rules.</p>
9,502
<p>In Oracle, given a simple data table:</p> <pre><code>create table data ( id VARCHAR2(255), key VARCHAR2(255), value VARCHAR2(511)); </code></pre> <p>suppose I want to "insert or update" a value. I have something like:</p> <pre><code>merge into data using dual on (id='someid' and key...
<p>I don't consider using dual to be a hack. To get rid of binding/typing twice, I would do something like:</p> <pre><code>merge into data using ( select 'someid' id, 'testKey' key, 'someValue' value from dual ) val on ( data.id=val.id and data.key=val.key ) when matche...
<p>I prefer to try the update before the insert to save having to check for an exception.</p> <pre><code>update data set ...=... where ...=...; if sql%notfound then insert into data (...) values (...); end if; </code></pre> <p>Even now we have the merge statement, I still tend to do single-row updates this way...
20,227
<p>Given that Decimal.MaxValue = 79228162514264337593543950335m</p> <p>Why does the next line give me 7922816251426433759354395034M in the Local window instead of 7922816251426433759354395033.5m as expected?</p> <p>Decimal target = Decimal.MaxValue / 10m;</p>
<p>I suspect this is a compiler error, actually.</p> <p>Here's a short but complete program to show why I think that:</p> <pre><code>using System; class Test { static void Main() { decimal constant = decimal.MaxValue / 10m; decimal calculated = decimal.MaxValue; calculated /= 10m; ...
<p>I'd guess because you are overstepping the max precision value when you are dividing by 10. <a href="http://en.wikipedia.org/wiki/Arithmetic_precision" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Arithmetic_precision</a></p>
44,432
<p>I have several aspx pages that can be opened either normally (full screen in browser), or called from another page as a popup (I am using Greybox, fwiw)</p> <p>If the page is opened as a popup in Greybox, I would like to NOT display the master page content (which displays common top and left menus, etc).</p> <p>As...
<p>Create a simplified master page for the popup. Override the OnPreInit method (of the actual page) and switch out the masterpage based on a querystring argument:</p> <pre><code>protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); if(Request["PopUp"] == "Y") { Maste...
<p>I agree. This is a server-side problem, not something to scrape into shape on the client side. It may also be valuable to organize your web pages where the common content between the pop-up and a main page is maintained separately and imported server-side into the page that has the master-page surround. Pages tha...
38,356
<p>I'm helping a customer who has a problem with a flash app. The flash app uses an XMLSocket to connect to a service running on localhost. It works fine under firefox. </p> <p>It uses the following line to setup the security policy:</p> <p>System.security.loadPolicyFile("xmlsocket://localhost:10032");</p> <p>Runnin...
<p>Are you certain the exact same version of flash is running on both browsers? The requirements for network security seem to have changed significantly between versions. It's entirely possible to have different versions of flash player installed into IE and firefox as one is an activeX control and the other a browser ...
<p>Add "new line" byte to the end of sending request to policy file. </p> <p>Like this: "" + "\n"</p>
24,838
<p>Within your organization, is every developer required to lock his workstation when leaving it?</p> <p>What do you see a risks when workstations are left unlocked, and how do you think such risks are important compared to "over-wire" (network hacking) security risks?</p> <p>What policies do you think are most effic...
<p>The primary real world risks are your co-workers <a href="http://www.codinghorror.com/blog/archives/000997.html" rel="nofollow noreferrer">"goating"</a> you. You can enforce this by setting a group policy to run the screen saver after X minutes, which can lock the computer as well.</p>
<p>I personally think the risk is low, but in my experience most of the time it's not matter of opinion -- it's often a requirement for big corporate or government clients who will actually come in and audit your security. In that case, some kind of technical (group policy) solution would be best because you can actua...
20,323
<p>How can I rewrite or is there a way to writing my own custom function that simulates the Custom System.Collections.Generic.Contains but only factors in certain Public Properties of a Custom Object?</p> <p>For example if I have a custom Object with Properties Name and ID, I would like my Unique Value List to contain...
<p>I like gmail because of the way it groups messages by conversation so I can just page down through a thread.</p>
<p>Using KDE Ia m using Kontact for my mail and RSS feeds. That gives me a nice command center.</p>
45,735
<p>I have been searching for a way to allow one element of my FileHelpers mapping class to be an array of specific length.</p> <p>For instance, I have a class like this:</p> <pre><code>[DelimitedRecord(",")] public class Example { public string code; public int month; public int day; public double h1;...
<p>FileHelpers record classes require public fields. The record class should not be considered as a normal C# class that should follow best coding practices; rather it is just a syntax for describing an import file's structure. </p> <p>The recommended procedure with FileHelpers would be to loop through the resulting <...
<p>I don't know anything about the tool in question, but (assuming it isn't a limitation of the tool) I <em>really</em> doubt the wisdom of public fields. Properties would also give you the opportunity to shim the values:</p> <pre><code>[DelimitedRecord(",")] public class Example { public string Code {get;set;} ...
33,046
<p>I'm trying to bind a datasource to a repeater, for instance, to a web service (.asmx from a different website) on page load. The webservice returns a DataSet from an sql call. What is the best way to go about doing this?</p>
<p>Because you're calling another website, you have to contend with two issues (especially if this web service is on somebody else's website or over the public internet). First, there might be a delay to retrieve the data from the other website. Second, the other website might timeout.</p> <p>At a minimum you should c...
<p>Call the webservice, take the result, and bind it to your repeater.</p> <p>If you can, you might also try to cache the information for a time on your side, if possible to help with overall performance.</p>
31,601
<p>I'm using C# and .NET 3.5. I need to generate and store some T-SQL insert statements which will be executed later on a remote server.</p> <p>For example, I have an array of Employees:</p> <pre><code>new Employee[] { new Employee { ID = 5, Name = "Frank Grimes" }, new Employee { ID = 6, Name = "Tim O'Reilly" ...
<p>Use parameterised commands. Pass the parameters along to your remote server as well, and get that to call into SQL Server, still maintaining the distinction between the SQL itself and the parameter values.</p> <p>As long as you never mix treat data as code, you should be okay.</p>
<p>To avoid injection, you need to ship the data to the remote server (perhaps in XML) and then on the remote server, the data should be converted back to appropriate data types and used in parameterized queries or stored procs.</p>
37,426
<p>I have a list of tuples like this:</p> <pre><code>[ ('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2), ('c', 1), ] </code></pre> <p>I want to iterate through this keying by the first item, so, for example, I could print something like this:</p> <pre><code>a 1 2 3 b 1 2 c 1 </code></pre> <p>How would I go about do...
<pre><code>l = [ ('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2), ('c', 1), ] d = {} for x, y in l: d.setdefault(x, []).append(y) print d </code></pre> <p>produces:</p> <pre><code>{'a': [1, 2, 3], 'c': [1], 'b': [1, 2]} </code></pre>
<p>I would just do the basic</p> <pre> answer = {} for key, value in list_of_tuples: if key in answer: answer[key].append(value) else: answer[key] = [value] </pre> <p>If it's this short, why use anything complicated. Of course if you don't mind using setdefault that's okay too.</p>
32,730
<p>I'm trying to track down an issue in our system and the following code worries me. The following occurs in our doPost() method in the primary servlet (names have been changed to protect the guilty):</p> <pre><code>... if(Single.getInstance().firstTime()){ doPreperations(); } normalResponse(); ... </code></pre> ...
<p>I found this on Sun's site: </p> <blockquote> <h3>Multiple Singletons Simultaneously Loaded by Different Class Loaders</h3> <p>When two class loaders load a class, you actually have two copies of the class, and each one can have its own Singleton instance. That is particularly relevant in servlets ...
<p>This will get only loaded once when the class is loaded by the classloader. This example provides a better Singleton implementation however, it's as lazy-loaded as possible and thread-safe. Moreover, it works in all known versions of Java. This solution is the most portable across different Java compilers and virtu...
27,927
<p>I got a table with a custom TableCellEditor (extending DefaultCellEditor) with a JFormattedTextField as the editor component.</p> <p>Now I got problem: when I press a separate button while editing. When the button is pressed, the editor remains "open and active" while I'd want it to stop editing so that the changes...
<p>You may try </p> <p><code>jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);</code></p>
<p>Had also more issues with these things, see the question <a href="https://stackoverflow.com/questions/1276769/java-swing-changing-jtree-selection-while-editingstopcellediting-how-to-get">Java Swing : changing JTree selection while editingstopCellEditing() : how to get stopCellEditing() called before TreeListeners:va...
49,497
<p>I am using python 3.6 with pySerial library to connect to the Hyrel System 30M 3D Printer. I am able to read the data from the device but unable to write any commands to it</p> <p>Here is the code:</p> <pre><code> ser = serial.Serial() ser.port = 'COM4' ser.baudrate = 38400 out = ser.readline() ...
<p>If the one in your question is your <em>complete</em> code, a possibility is that your computer is just buffering the output for the serial port, withholding it in memory. Try to add</p> <pre><code>ser.flush() </code></pre> <p>after your last line. This command will... well... <em>flush</em> anything into the bu...
<p>Sorry for the late answer, but with Repetrel v3 and later, we have the option for you to configure a secondary COM port, and relay G- or M-Code commands from your other source through the Repetrel software to the printer. Please contact us for assistance.</p> <p>Note: I work for Hyrel 3D.</p>
801
<p>With the increased power of JavaScript frameworks like YUI, JQuery, and Prototype, and debugging tools like Firebug, doing an application entirely in browser-side JavaScript looks like a great way to make simple applications like puzzle games and specialized calculators.</p> <p>Is there any downside to this other t...
<p>I've written several application in JS including a spreadsheet.</p> <p>Upside:</p> <ul> <li>great language</li> <li>short code-run-review cycle</li> <li>DOM manipulation is great for UI design</li> <li>clients on every computer (and phone)</li> </ul> <p>Downside:</p> <ul> <li>differences between browsers (especi...
<p>My RSS feeds have served me well- I found that Javascript roguelike!</p> <p>It's called <a href="http://www.icculus.org/asciiroth/" rel="nofollow noreferrer">The Tombs of Asciiroth</a>.</p>
3,592
<p>When encoding a query string to be sent to a web server - when do you use <code>escape()</code> and when do you use <code>encodeURI()</code> or <code>encodeURIComponent()</code>:</p> <p>Use escape:</p> <pre><code>escape("% +&amp;="); </code></pre> <p>OR</p> <p>use encodeURI() / encodeURIComponent()</p> <pre><co...
<h1>escape()</h1> <p>Don't use it! <code>escape()</code> is defined in section <a href="https://www.ecma-international.org/ecma-262/9.0/index.html#sec-escape-string" rel="noreferrer">B.2.1.2 escape</a> and the <a href="https://www.ecma-international.org/ecma-262/9.0/index.html#sec-additional-ecmascript-features-for-web...
<p>I have this function...</p> <pre><code>var escapeURIparam = function(url) { if (encodeURIComponent) url = encodeURIComponent(url); else if (encodeURI) url = encodeURI(url); else url = escape(url); url = url.replace(/\+/g, '%2B'); // Force the replacement of "+" return url; }; </code></pre>
10,164
<p>How can I change <code>CSS</code> from <code>javascript</code>. </p> <p>I'm using <code>jQuery-ui Dialog</code> and I want to change the style of a <code>DIV</code> from javascript.</p> <p>Thanks</p>
<p>Check out <a href="http://docs.jquery.com/CSS/css" rel="nofollow noreferrer">the jQuery documentation</a>. If you want anything it will be there.</p> <p>Anyhow, if you want to add styles to elements, you need to use the <code>css</code> function, which has a few variants.</p> <pre><code>$(selector).css(properties)...
<p>Try this.This is jquery code.</p> <pre><code> $("myDiv").css({"color":"red","display":"block"}) </code></pre> <p>If you are using vanila javacript,try this.</p> <pre><code>var myDiv = document,getElementById("myDiv"); myDiv.style.display = "block"; myDiv.style.color = "red"; </code></pre>
47,873
<p>I know 'best' is subjective, so according to you, what is the best solution for the following problem:</p> <p>Given a string of length n (say "abc"), generate all proper subsets of the string. So, for our example, the output would be {}, {a}, {b}, {c}, {ab}, {bc}, {ac}. {abc}.</p> <p>What do you think?</p>
<p>You want the <a href="http://en.wikipedia.org/wiki/Power_set" rel="noreferrer">power set</a>. It can be calculated <a href="http://en.wikipedia.org/wiki/Power_set#Algorithms" rel="noreferrer">recursively and inductively</a>. ;-)</p>
<pre><code>def subsets(s): r = [] a = [False] * len(s) while True: r.append("".join([s[i] for i in range(len(s)) if a[i]])) j = 0 while a[j]: a[j] = False j += 1 if j &gt;= len(s): return r a[j] = True print subsets("abc") ...
6,505
<p>I want to create basic low-poly 3D models to use in XNA Game Studio games. What cheap/free tools do people recommend?</p> <p>And does anyone have any links or snippets of code that show how to load 3D models of some sort into XNA and then draw them on the screen?</p>
<p>Take a look at trueSpace also, its just become free - but as Evil Activity stated; Blender is also a good sugestion i just never really got use to its interface and how to do stuff. trueSpace is a little more easy in that way, but i think that blender is more powerful.</p> <p>I guess you know <a href="http://creato...
<p>Having worked a modeler and texture artist for over 3 years, I have tried the majority of modeling tools and keep coming back to <a href="http://www.nevercenter.com/" rel="nofollow noreferrer">Nevercenter's Silo</a>. It's the most elegant, well designed sub-d polygonal modeling application I have ever had the pleasu...
13,611
<p>How do I call a function, using a string with the function's name? For example:</p> <pre><code>import foo func_name = &quot;bar&quot; call(foo, func_name) # calls foo.bar() </code></pre>
<p>Given a module <code>foo</code> with method <code>bar</code>:</p> <pre><code>import foo bar = getattr(foo, 'bar') result = bar() </code></pre> <p><a href="https://docs.python.org/library/functions.html#getattr" rel="noreferrer"><code>getattr</code></a> can similarly be used on class instance bound methods, module-le...
<p>This is a simple answer, this will allow you to clear the screen for example. There are two examples below, with eval and exec, that will print 0 at the top after cleaning (if you're using Windows, change <code>clear</code> to <code>cls</code>, Linux and Mac users leave as is for example) or just execute it, respect...
2,522
<p>Okay, I got this small program which tags (as in ID3v2.4 etc.) some music files. Now I want the user to have the option to move and/or rename those tagged files if he/she wishes to.</p> <p>Considering that I am trying to keep a fairly clean and loosely coupled design in this system (even though extensibility is not...
<p>Have you changed your development environment recently? In particular have you installed a service pack or new release of Visual Studio?</p> <p>It appears you are linking against a C++ runtime that is not available on the client's server. You can use the Windows Event Viewer to identify the DLL failing to load, or ...
<p>Not to answer my own question, but support just updated the bug with the text following this paragraph. I'm still interested in thoughts on tracking down situations like this.</p> <p>Resolved by downloading and installing the Visual C++ 2008 Redistributable Package for Windows on the IMS: <a href="http://www.micro...
22,426
<p>I think it important to have an "<strong>undo</strong>" method ala <strong>gmail</strong> when destroying records instead of displaying an annoying popup that says, "<em>Are you sure?</em>".</p> <p>The way that I've implemented this is to have a "deleted_at" timestamp column in the model which gets timestamped when...
<p>There are indeed some plugins that can be found at <a href="http://agilewebdevelopment.com/plugins" rel="nofollow noreferrer">Agile Web Development</a>.</p> <p>Here are the links and summaries for the plugins which seem to match your description:</p> <ol> <li><a href="http://agilewebdevelopment.com/plugins/acts_as...
<p>responsibility chain pattern</p> <pre><code>class Action { Perform(context); Undo(context); } </code></pre>
24,437
<p>I have a web page that uses a scrolling div to display table information. When the window is resized (and also on page load), the display is centered and the div's scrollbar positioned to the right of the page by setting its width. For some reason, the behaviour is different under firefox than IE. IE positions/sizes...
<p>You are dealing with "<a href="http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug" rel="nofollow noreferrer">one of the best-known software bugs in a popular implementation of Cascading Style Sheets (CSS)</a>" according to Wikipedia. I recommend the <a href="http://www.quirksmode.org/viewport/elementdimens...
<p>As long as you don't include a valid doctype, you can't expect consistent results, due to Quirks Mode. Go add one (HTML 4.01 Transitional is fine), then let us know if it still occurs.</p> <p>Also see <a href="http://en.wikipedia.org/wiki/Quirks_mode" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Quirks_mo...
28,862
<p>I have a page with a GridView on it that launches a popup, using Javascript. The user then selects an item, that updates the data connected to the GridView and closes the popup.</p> <p>How do I refresh the first (ie the Calling page) so that I can refresh the data shown in my Gridview?</p>
<p>Try this inside your popup:</p> <pre><code>&lt;script&gt; window.opener.location.reload() &lt;/script&gt; </code></pre> <p>That should refresh the page that opened the pop-up</p>
<p>If you simply need to trigger a postback on the calling page, this should work:</p> <pre><code>&lt;script&gt; window.parent.document.forms[0].submit(); &lt;/script&gt; </code></pre> <p>By explicitly submitting the form, you avoid the warning that appears if you just refresh the calling page.</p> <p>If you need to...
33,971
<p>I'm a jQuery novice, so the answer to this may be quite simple:</p> <p>I have an image, and I would like to do several things with it. When a user clicks on a 'Zoom' icon, I'm running the 'imagetool' plugin (<a href="http://code.google.com/p/jquery-imagetool/" rel="nofollow noreferrer">http://code.google.com/p/jque...
<p>Wehey! I've sorted it out myself...</p> <p>Turns out if I remove the containing div completely, and then rewrite it with .html, the imagetool plugin recognises it again.</p> <p>Amended code for anyone who's interested:</p> <pre><code>$(document).ready(function(){ // Product Zoom (jQuery) $("#productZoom").cl...
<p>First, i have one question, are the .altPhoto links or images? Cause if its images then this line is wrong</p> <pre><code>var altImageSrc = $(this).attr("href"); </code></pre> <p>it should be</p> <pre><code>var altImageSrc = $(this).attr("src"); </code></pre> <p>its the only thing i could find in a glance</p>
16,091
<p>I've written a simple app in C# 2.0 using the .Net Framework 2.0 Serialport class to communicate with a controller card via COM1. </p> <p>A problem occurred recently were the bytes returned by the Read method are incorrect. It returned the right amount of bytes, only the values were incorrect. A similar app written...
<p>Well, it seems as if the problem has been resolved (at least for the time being).</p> <p>Apparently a framing error caused the return of incorrect values. I wrote a VB6 app, using the MSComm control, which worked fine, and compared the log files generated by Portmon. </p> <p>I picked up the following differences</...
<p>Have you checked the settings for number of data bits, stop bits and parity?</p> <p>The parity bit is a kind of error detection mechanism. For instance: If you send using 7 data bits and one parity bit, the eighth bit will be used for detecting bit inversion errors. If the receiver expects 8 data bits and no parity...
14,353
<p>I've tried the following, but I was unsuccessful:</p> <pre><code>ALTER TABLE person ALTER COLUMN dob POSITION 37; </code></pre>
<p>"<a href="http://wiki.postgresql.org/wiki/Alter_column_position" rel="noreferrer">Alter column position</a>" in the PostgreSQL Wiki says:</p> <blockquote> <p>PostgreSQL currently defines column order based on the <code>attnum</code> column of the <code>pg_attribute</code> table. The only way to change colum...
<p>There are some workarounds to make it possible:</p> <ol> <li><p>Recreating the whole table</p></li> <li><p>Create new columns within the current table</p></li> <li><p>Create a view</p></li> </ol> <p><a href="https://tableplus.com/blog/2018/09/postgresql-is-it-possible-to-alter-column-order-position-in-a-table.html...
36,294
<p>So I was thinking of using a closed-loop motor in my 3D printer for better accuracy and high-speed printing without losing steps. I have analyzed options available including just tweaking stepper current and firmware changes to prevent step losses but I want to find the best way to do it with encoders. The problem i...
<p>You can use a magnetic position encoder.</p> <p><a href="https://ams.com/as0548b" rel="nofollow noreferrer">AS5048B High Resolution Position Sensor</a></p> <p>14-bit rotary position sensor with digital angle (interface) and PWM output</p> <p>14 bit means 16k steps/rotation. With a stepper which does 200 steps/rotati...
<p>The gearbox approach is solid, but it will be 100x slower, and you said you wanted speed.</p>
1,889
<p>I am building an enterprise application with .Net 1.1 and SQL Server 2000. I use the read committed isolation level . However changes in non-functional requirements have made it necessary to take measures against non-repeatable reads and phantoms. I see two options: </p> <ol> <li><p>Introduce row-versioning to chec...
<p>I'd suggest you upgrade to 2005/2008 and enable the read committed snapshot option. Once enabled, it makes any transaction that asks for read committed use row versioning instead of locks. It also has less of an impact on TempDB than full snapshot isolation does.</p> <p>What problems are you having with temp tables...
<p>Some thoughts on option #2:</p> <p>You wouldn't need to make an extra round-trip to the server. I can think of about 3 different ways to avoid it, including pre-pending the command to your existing query string, moving to stored procedures and setting it there, etc.<br> Also, you could bypass SQL Server 2005 and g...
24,717
<p>I know this is not directly a programming question, but people on stackoverflow seems to be able to answer any question.</p> <p>I have a server running Centos 5.2 64 bit. Pretty powerful dual core 2 server with 4GB memory. It mostly serves static files, flash and pictures. When I use lighttpd it easily serves ov...
<p>When you reload your nginx (kiil -HUP) you'll get something like this in your error logs</p> <pre> 2008/10/01 03:57:26 [notice] 4563#0: signal 1 (SIGHUP) received, reconfiguring 2008/10/01 03:57:26 [notice] 4563#0: reconfiguring 2008/10/01 03:57:26 [notice] 4563#0: using the "epoll" event method 2008/10/01 03:57:26...
<p>Suggestions: - Use 1 worker per processor. - Check the various nginx buffer settings</p>
15,317
<p>I'm currently using <a href="http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html" rel="nofollow noreferrer">Intelligencia.UrlRewriter</a> does anyone have better suggestions?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.web.routing.aspx" rel="nofollow noreferrer">System.Web.Routing</a> is <strong>part of .NET 3.5 SP1</strong> and you can use it both for your ASP.NET WebForm-application and your MVC-application.</p> <p>The <strong>official ASP.NET site</strong> has a good <a h...
<p>IIS 7 comes with a <a href="http://blogs.iis.net/bills/archive/2008/05/31/urlrewrite-module-for-iis7.aspx" rel="nofollow noreferrer">rewrite module</a></p> <p>You can find further links in <a href="http://en.wikipedia.org/wiki/Rewrite_engine#IIS" rel="nofollow noreferrer">this</a> wikipedia article</p>
15,300
<p>I'm having difficulties to answer this question. Can someone help me?</p> <p>Discuss the benefits of MYSQL and explain why it is gaining acceptance as the RDBMS of choice for many organizations worldwide.</p>
<p>Because it's free (or historically has been free) and gained critical mass on the on the open source platform stack earlier than its competitors (e.g., postgresql).</p> <p>Due to classic <a href="http://en.wikipedia.org/wiki/Network_effect#Software" rel="nofollow noreferrer">network effects in software</a>, and rdb...
<p>MYSQL is not always free. If you intend to use it for commercial purposes, a license should be bought (<a href="http://www.mysql.com/about/legal/licensing/oem/" rel="nofollow noreferrer">link1</a> <a href="https://shop.mysql.com/enterprise/?rz=s2" rel="nofollow noreferrer">link2</a>). You may want to double check.</...
47,361
<p>I've got a peculiar issue today, and was looking for some help with it.</p> <p>Of the six Ender 3s I manage at my college, one of them seems to be <strong>stretching the Y axis</strong> of all the prints I make with it.</p> <p>Some points about the issue:</p> <ul> <li>It's variable, but is much more pronounced in...
<p>If an axis doesn't print the sizes you command it there are basically 2 options causing this.</p> <ol> <li>The printer is incorrectly configured,</li> <li>The printer has an hardware issue.</li> </ol> <p>To find out which of the 2 is applicable, you need to look into your setup and into the firmware settings. E.g....
<p>It is likely you have PU belt and it is likely it stretched in some area. I had all my PU belts finally stretched with big tension and high speed printing. Now I am using reinforced rubber belts.</p>
1,613
<p>Often when I post a comment or answer on a site I like to keep an eye out for additional responses from other people, possibly replying again if appropriate. Sometimes I'll bookmark a page for a while, other times I'll end up re-googling keywords to locate the post again. I've always thought there should be somethin...
<p>For stackoverflow, I put together a little bookmarklet thing at <a href="http://stackoverflow.hewgill.com" rel="nofollow noreferrer">http://stackoverflow.hewgill.com</a>. I use it to keep track of posts that I might want to come back to later, for reference or to answer if nobody else did, or whatever. The backend a...
<p>Click on your username, then Responses.</p>
19,475
<p>I am developing a map control in WPF with C#. I am using a canvas control e.g. 400 x 200 which is assigned a map area of e.g. 2,000m x 1,000m.</p> <p>The scale of the map would be: <strong>canvas_size_in_meters / real_size_in_meters</strong>.</p> <p>I want to find the canvas_size_in_meters.</p> <p>The canvas.Act...
<blockquote> <p>How do I measure the size of a WPF control in inches EXACTLY and regardless of screen resolution and DPI setting ?</p> </blockquote> <p>This isn't actually possible, because for it to work, WPF would have to know the resolution (in terms of DPI) of your monitor. Sounds nice in theory, but in practice...
<p>Thank you for you prompt reply.</p> <p>I totally agree, but I didn't want to believe it in the first place. You see, there has to be an <strong>approximate</strong> calculation of the scale of the map if the map is used to display different layers of map data (scale dependant). Most applications use a slider contro...
38,533
<p>I have a C library with numerous math routines for dealing with vectors, matrices, quaternions and so on. It needs to remain in C because I often use it for embedded work and as a Lua extension. In addition, I have C++ class wrappers to allow for more convenient object management and operator overloading for math op...
<p>Your wrapper itself will be inlined, however, your method calls to the C library typically will not. (This would require link-time-optimizations which are technically possible, but to AFAIK rudimentary at best in todays tools)</p> <p>Generally, a function call as such is not very expensive. The cycle cost has decre...
<p>I don't think you'll notice much perf difference. Assuming your target platform support all your data types, </p> <p>I'm coding for the DS and a few other ARM devices and floating points are evil...I had to typedef float to FixedPoint&lt;16,8></p>
36,350
<p>i was just about to finish up my project and install it as a windows service. I have the installer, etc. - everything i need. When i went to choose Application Type, Windows service does not appear as an option.</p> <p>Here is the kicker. When I dev in VB.NET, i have that option. The project mentioned above is ...
<p>You need an installer class in your project, then you need a Setup project which will incorporate the output of the project's build.</p> <p>See here: <a href="http://msdn.microsoft.com/en-us/library/aa984464(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa984464(VS.71).aspx</a> for...
<p>In my copy of Visual Studio 2005, when I create a new project it's not listed directly under the C# project type, but under C#->Windows</p> <p>Here there should be a project type called "Windows Service" which sounds like what you're looking for.</p>
24,594
<p>I've read in a couple of places that the desktop wallpaper can be set to an HTML document. Has anyone had any success changing it programmatically? </p> <p>The following snippet of VB6 helps me set things up for BMPs but when I try to use it for HTML, I get a nice blue background and nothing else.</p> <pre><code>D...
<p>I think you need to make sure "Active Desktop" is turned on.</p> <p>You might try setting <code>HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ForceActiveDesktopOn</code> to <code>1</code> (found <a href="http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/93205.mspx?mfr=t...
<p>Getting closer: <a href="http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2rkbook/gp.mspx?mfr=true" rel="nofollow noreferrer">http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2rkbook/gp.mspx?mfr=true</a> <hr /> But it turns out that I was getting sidetracked in Policy space. W...
10,576
<p>I've got a problem in that changing the way I'm doing Url Rewriting in an Asp.Net application has changed the IIS log files from looking like this:</p> <p>/page/ 80 etc.. /page/anotherpage/ 80 etc...</p> <p>to</p> <p>default.aspx page=1 80 etc... default.aspx page=2 80 etc...</p> <p>I'm a bit stumped as to how t...
<p>Is the URL rewriting being done by a module? If it is, then it's possible the rewriting module is running before the logging module. You can change the order that modules run in IIS Manager. Go into <strong>Modules</strong> in IIS Manager and select <strong>View Ordered List...</strong>; then you can move modules up...
<p>I don't know what method you are using to rewrite the URLs, but I know that with Apache (and ISAPI_Rewrite on Windows) you have to add a flag to each rule in the .htaccess file (or equivalent) to tell it to log the rewritten URL and not the original.</p>
44,570
<p>Does anyone know if it's possible to use regex capture within Apache's DirectoryMatch directive? I'd like to do something like the following:</p> <pre><code>&lt;DirectoryMatch ^/home/www/(.*)&gt; AuthType Basic AuthName $1 AuthUserFile /etc/apache2/svn.passwd Require group $1 admin &lt;/DirectoryMat...
<p>You could tackle the problem from a completely different angle: enable the perl module and you can include a little perl script in your httpd.conf. You could then do something like this:</p> <pre><code>&lt;Perl&gt; my @groups = qw/ foo bar baz /; foreach ( @groups ) { push @PerlConfig, qq| &lt;Directory /home/w...
<p>What you are trying to do looks very similar to <a href="http://httpd.apache.org/docs/2.0/howto/public_html.html" rel="nofollow noreferrer">per-user home directories</a>. The way Apache handles these is through file system permissions and <a href="http://httpd.apache.org/docs/1.3/howto/htaccess.html" rel="nofollow ...
11,423
<p>I have two entities, each from a different database and therefore different edmx files. There is, however, an infered relationship between them.</p> <p><code>Foo</code> has many <code>Bar</code>s for example.</p> <p>What's the easiest way to do this join in the EntityFramework, with fewest database calls?</p> <p>...
<p>You can do this by adding cross-model navigation properties. This requires manually editing the EDMX. There is an example, including LINQ to Entities, <a href="http://blogs.msdn.com/adonet/archive/2008/11/25/working-with-large-models-in-entity-framework-part-2.aspx" rel="nofollow noreferrer" title="Working With Larg...
<p>You can do this by using Views to represent data in the other database. Read about <a href="http://www.britishdeveloper.co.uk/2010/06/cross-database-joins-entity-framework4.html" rel="nofollow noreferrer">cross database joins in EF</a></p>
49,438
<p>I would like to do something like the following:</p> <pre><code>def add(a, b): #some code def subtract(a, b): #some code operations = [add, subtract] operations[0]( 5,3) operations[1](5,3) </code></pre> <p>In python, is it possible to assign something like a function pointer?</p>
<p>Did you try it? What you wrote works exactly as written. Functions are first-class objects in Python.</p>
<p>Just a quick note that most Python operators already have an equivalent function in the <a href="http://docs.python.org/library/operator.html" rel="nofollow noreferrer">operator</a> module.</p>
39,575
<p>I was intending on use the Title attribute in the @Page directive to customise each pages title, but it simply doesn't appear to do anything.</p> <p>The site uses master pages - I don't know if that is a consideration.</p> <p>Master Page snippet:</p> <pre><code>&lt;%@ Master Language="VB" CodeFile="brightnorth.ma...
<p>Oops... A basic error! [aren't they always?]</p> <p>Anyone spot a missing <code>runat="server"</code> in the element?</p> <p>Oops.</p>
<p>You've got to use the HTML tag as well :)</p> <p>In your master page, inside the head tag you should have:</p> <pre><code>&lt;title&gt;&lt;%=Title%&gt;&lt;/title&gt; </code></pre> <p><a href="http://www.w3schools.com/TAGS/tag_title.asp" rel="nofollow noreferrer">http://www.w3schools.com/TAGS/tag_title.asp</a></p...
47,916
<p>I know how to find out the current domain name in PHP already, the problem is when I put this code into a file and then include it from another server it shows the domain name of where the file is located. Is there any way for it to find out the domain or the site containing the include() code?</p>
<p>Are you doing something like:</p> <pre><code>include 'http://example.com/script.php'; </code></pre> <p>?</p> <p>NB: This approach generally considered to be a bit of no-no from a security point of view.</p> <p>Anyway, the included script is actually being executed on the other server, then the output of the scri...
<p>If you include a PHP page from another server, the page will get parsed by the original server and the result will be sent to you - the page you receive is nothing but text, no PHP code included.</p>
27,969
<p>I'm writing code like this, doing a little quick and dirty timing:</p> <pre><code>var sw = new Stopwatch(); sw.Start(); for (int i = 0; i &lt; 1000; i++) { b = DoStuff(s); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); </code></pre> <p>Surely there's a way to call this bit of timing code as a fancy-sc...
<p>How about extending the Stopwatch class?</p> <pre><code>public static class StopwatchExtensions { public static long Time(this Stopwatch sw, Action action, int iterations) { sw.Reset(); sw.Start(); for (int i = 0; i &lt; iterations; i++) { action(); } ...
<pre><code>public static class StopWatchExtensions { public static async Task&lt;TimeSpan&gt; LogElapsedMillisecondsAsync( this Stopwatch stopwatch, ILogger logger, string actionName, Func&lt;Task&gt; action) { stopwatch.Reset(); stopwatch.Start(); await ...
28,814
<p>I have been programming for the last 3 years. When I program, I use to handle all known exceptions and alert the user gracefully. I have seen some code recently which has almost all methods wrapped inside try/catch blocks. The author says it is part of defensive programming. I wonder, is this really defensive progra...
<p>My basic rule is : Unless you can <strong>fix</strong> the problem which caused the exception, do not catch it, let it bubble up to a level where it can be dealt with.</p> <p>In my experience, 95% of all catch blocks either just ignore the exception (<code>catch {}</code>) or merely log the error and rethrow the ex...
<p>I guess the real answer is "It depends". If try-catch blocks are catching very generic exceptions then I would say it is defensive programming in the same way that never driving out of your neighborhood is defensive driving. A try-catch (imo) should be tailored to specific exceptions. </p> <p>Again, this is just my...
43,344
<p>ive got the problem that i dont know how to stop my function with mouseover and restart it with mouseout</p> <p>first here is my test-code:</p> <p> </p> <pre><code> &lt;script type="text/javascript"&gt; function fadeEngine(x) { var total_divs=3; //setze hier die nummer der gewollten di...
<p>Give all of your <code>#fade</code>X elements a class (say .faders) and then use:</p> <pre><code>$('.faders').stop(); </code></pre> <p>Or give the container div an id like <code>#faderbox</code> and say:</p> <pre><code>$('#faderbox div').stop(); </code></pre>
<p>I'm not sure exactly what you want to happen with regards to your fadeIn and fadeOut effects in your fadeEngine, however, I can give you two pieces of advice:</p> <p>You can use the jQuery effect <code>stop()</code> to stop all current jQuery animations on selected elements. For example:</p> <pre><code>$("#fade"+...
49,454
<p><strong><em>Imagine</em></strong> a base class with many constructors and a virtual method</p> <pre><code>public class Foo { ... public Foo() {...} public Foo(int i) {...} ... public virtual void SomethingElse() {...} ... } </code></pre> <p>and now i want to create a descendant class that overrid...
<p>Yes, you will have to implement the constructors that make sense for each derivation and then use the <code>base</code> keyword to direct that constructor to the appropriate base class or the <code>this</code> keyword to direct a constructor to another constructor in the same class.</p> <p>If the compiler made assum...
<p>Too many constructors is a sign of a broken design. Better a class with few constructors and the ability to set properties. If you really need control over the properties, consider a factory in the same namespace and make the property setters internal. Let the factory decide how to instantiate the class and set i...
27,531
<p>What's the best way to import/export app internal settings into a file from within an app?</p> <p>I have the Settings.settings file, winform UI tied to the settings file, and I want to import/export settings, similar to Visual Studio Import/Export Settings feature. </p>
<p>If you are using the Settings.settings file, it's saving to the config file. By calling YourNamespace.Properties.Settings.Save() after updating your settings, they will be saved to the config files.</p> <p>However, I have no idea what you mean by "multiple sets of settings." If the settings are user settings, eac...
<p>You can use DataSet, which you bind to the form. And you can save/restore it.</p>
11,367
<p>We have a web application that passes parameters in the url along the lines of this:</p> <pre><code>www.example.com/ViewCustomer?customer=3945 </code></pre> <p>Reasonably often, we will see attempts to access just:</p> <pre><code>www.example.com/ViewCustomer </code></pre> <p>Or system logs this as invalid and se...
<p>Do your logs include the referrer information? If there's any information present then it could help to pinpoint the error. If there isn't, that might indicate an "editing the URL" attempt. (I don't know how much SSL would change any of this, admittedly.)</p> <p>Browsers do sometimes <a href="http://en.wikipedia.or...
<p>Check your logs for the agent string and see if these requests are made by a search engine spider.</p>
22,559
<p> I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.</p> <p>Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL, and PHP to...
<p><strong>Data Storage</strong>:</p> <ul> <li><p>Specify the <code>utf8mb4</code> character set on all tables and text columns in your database. This makes MySQL physically store and retrieve values encoded natively in UTF-8. Note that MySQL will implicitly use <code>utf8mb4</code> encoding if a <code>utf8mb4_*</cod...
<p>Unicode support in PHP is still a huge mess. While it's capable of converting an <a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-1" rel="nofollow noreferrer">ISO 8859</a> string (which it uses internally) to UTF-8, it lacks the capability to work with Unicode strings natively, which means all the string processi...
35,264
<p>This is an almost-duplicate of <a href="https://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script">Send file using POST from a Python script</a>, but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to f...
<p>Best thing I can think of is to encode it yourself. How about this subroutine?</p> <pre><code>from urllib2 import Request, urlopen from binascii import b2a_base64 def b64open(url, postdata): req = Request(url, b2a_base64(postdata), headers={'Content-Transfer-Encoding': 'base64'}) return urlopen(req) conn = b...
<p>PyCURL provides an interface to CURL from Python.</p> <p><a href="http://curl.haxx.se/libcurl/python/" rel="nofollow noreferrer">http://curl.haxx.se/libcurl/python/</a></p> <p>Curl will do all you need. It can transfer binary files properly, and supports many encodings. However, you have to make sure that the pr...
18,142
<p>What things should be kept most in mind when writing cross-platform applications in C? Targeted platforms: 32-bit Intel based PC, Mac, and Linux. I'm especially looking for the type of versatility that Jungle Disk has in their USB desktop edition ( <a href="http://www.jungledisk.com/desktop/download.aspx" rel="noref...
<p>I maintained for a number of years an ANSI C networking library that was ported to close to 30 different OS's and compilers. The library didn't have any GUI components, which made it easier. We ended up abstracting out into dedicated source files any routine that was not consistent across platforms, and used #defi...
<p>Try to write as much as you can with POSIX. Mac and Linux support POSIX natively and Windows has a system that can run it (as far as I know - I've never actually used it). If your app is graphical, both Mac and Linux support X11 libraries (Linux natively, Mac through X11.app) and there are numerous ways of getting ...
5,625
<p>I've been reading up on conditional-style expressions in ruby. However I came across one I couldn't quite understand to define the classic FizzBuzz problem. I understand the FizzBuzz problem and even wrote my own before finding the following quick solution utilising the ternary operator. If someone can explain to me...
<p>Some parentheses might help:</p> <pre><code>puts (i%3 == 0) ? ((i%5 == 0) ? "FizzBuzz" : "Buzz") : ((i%5 == 0) ? "Fizz" : i) </code></pre> <p>So, if i is divisible by 3, then it checks whether i is also divisible by 5. If so, it prints "FizzBuzz" otherwise just "Buzz". If i is not divisible by three, then it check...
<p>Just for fun. If you wanted to do it in C#. Here's a simple way. It basically starts with your for loop that will print numbers from 1 to 100. It then asks if your index "i" is divisible by 3 and 5 if true then print to the console "FizzBuzz". Else if your index "i" is divisible by 3 if true then print to the consol...
27,815
<p>Every time that I create a new form in my application, it uses the "Microsoft Sans Serif, 8.25pt" font by default. I'm not changing it because I know that in this case my form <em>should</em> pick up whatever the default font is for the system. However, when I run my application, the font that is used is still anyth...
<p>The accepted answer doesn't really answer the question; it just explains why this behavior is occurring.</p> <p>Some of the other answers propose solid workarounds, but I've found that the best solution really is to create a base form that all of the forms in your application inherit from and set this base form's F...
<p>I've tried sample app that targets both <code>net472/net48</code> and <code>netcoreapp3.1</code>. While .net app <code>Control.DefaultFont</code> always returns Microsoft Sans Serif and not scaled. But .net core 3.1 app <code>Control.DefaultFont</code> returns exactly the system font on win7/10 and scaled well. So, ...
38,101
<p>Intuitively, it would seems that a compiler for language <code>Foo</code> cannot itself be written in Foo. More specifically, the <em>first</em> compiler for language <code>Foo</code> cannot be written in Foo, but any subsequent compiler could be written for <code>Foo</code>.</p> <p>But is this actually true? I hav...
<p>This is called "bootstrapping". You must first build a compiler (or interpreter) for your language in some other language (usually Java or C). Once that is done, you can write a new version of the compiler in language Foo. You use the first bootstrap compiler to compile the compiler, and then use this compiled co...
<p>Maybe you can write a <a href="http://en.wikipedia.org/wiki/Backus%2DNaur_form" rel="nofollow noreferrer">BNF</a> describing BNF.</p>
23,524
<p>Questions like this are <em><strong>usually</strong></em> not allowed but since the price of a brass nozzle in Switzerland is 15.90 and the average price of a nozzle from Alibaba or AliExpress is less than 0.10, and nozzles are something you exchange frequently the issue becomes of such magnitude that we <em><strong...
<p>I use cheap brass nozzles through the &quot;A&quot; place and they are almost certainly Chinese.</p> <p>When installing a new nozzle I use a drill bit in a pin vise in the large counter-drilled hole on the top side, pressing pretty hard to assure there are no drill chips in there, either loose or still attached. I f...
<p>Up until this year, I used the cheap nozzles - the original that came with my Ender 3, and both the ones that were supposedly by Creality and appeared identical to it, and similarly cheap ones off Amazon. I never had any problem with them that I attributed to nozzle quality, but I went through them fairly quickly si...
2,130
<p>Is there a way to check if the user has a different version of the CSS cached by their browser and if so force their browser to pull the new version?</p>
<p>I don´t know if it is correct usage, but I think you can force a reload of the css file using a query string:</p> <pre><code>&lt;link href="mystyle.css?SOME_UNIQUE_TEXT" type="text/css" rel="stylesheet" /&gt; </code></pre> <p>I remember I used this method years ago to force a reload of a web-cam image, but time ha...
<p>You should possibly just share a common ancestor class, then you can flick it with a single js command if need be.</p> <pre><code>&lt;body class="style2"&gt; &lt;body class="style1"&gt; </code></pre> <p>etc.</p>
12,648
<p>Can someone help me identify what the purpose of this unidentified syntax is. It is an extra little something in the constructor for this object. What I'm trying to figure out is what is the "&lt; IdT >" at the end of the class declaration line? I think that this is something I would find useful, I just need to unde...
<p>Read about Generics: <a href="http://msdn.microsoft.com/en-us/library/512aeb7t.aspx" rel="nofollow noreferrer">MSDN</a></p> <p>That is how you define a generic class. Hence calling </p> <pre><code>new DomainObject&lt;string&gt;(); </code></pre> <p>would create a domain object with an Id of type string. </p> <...
<p>right I'm somewhat aware of what generics are, have used Lists, delegates, etc. What I don't understand I guess is what effect putting "&lt; dataType >" after a class declaration does, and why you would do it. If I were to declare this object I'd do the following:</p> <p>Public class DomainObject { Public Doma...
46,547
<p>I'm using spring 2.5 and annotations to configure my spring-mvc web context. Unfortunately, I am unable to get the following to work. I'm not sure if this is a bug (seems like it) or if there is a basic misunderstanding on how the annotations and interface implementation subclassing works.</p> <p>For example,</p>...
<p>Ed is right, adding</p> <pre><code>&lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/&gt; &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/&gt; </code></pre> <p>works fine</p>
<p>The true reason you need to use 'proxy-target-class="true"' is in <code>DefaultAnnotationHandlerMapping#determineUrlsForHandler()</code> method: though it uses <code>ListableBeanFactory#findAnnotationOnBean</code> for looking up a <code>@RequestMapping</code> annotation (and this takes care about any proxy issues), ...
18,611
<p>Right now I'm developing a small canvas oriented 2D graphics engine for a game, and have been looking into several sources for hints to apply to my system's design. But obviously the most battle proven solution out there is flash, so I was wondering how is Flash architectured. I found some sources about Flash's work...
<p>Well, at the root of your Flash content is a stage object (an instance of the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Stage.html" rel="noreferrer">Stage</a> class). That stage is the root node of a tree of display objects, any of which can contain graphical assets (lines, text fields, et...
<p>The best link I've found (quite pathetic though) is this one:</p> <p><a href="http://www.adobe.com/products/flashlite/architecture/" rel="nofollow noreferrer">Architecture of Flash Lite</a></p>
41,769
<p>Is there a place I can find Backus–Naur Form or BNF grammars for popular languages? Whenever I do a search I don't turn up much, but I figure they must be published somewhere. I'm most interested in seeing one for Objective-C and maybe MySQL.</p>
<p>you have to search on tools used to create grammars: &quot;lex/yacc grammar&quot;, &quot;antlr grammar&quot; &quot;railroad diagram&quot;</p> <p><a href="http://www.antlr3.org/grammar/list.html" rel="noreferrer">http://www.antlr3.org/grammar/list.html</a></p> <p>Here's some grammar files</p> <h2>objective-c</h2> <ul...
<p>IIRC, BNF grammars are just different enough from what yacc/bison want as input to be really annoying :) If you intend to feed these files into a parser generator, you may want to look for files in the appropriate format. I recall seeing such files for Java, JavaScript and C++ at one point. Probably as part of Ec...
43,371
<p>I've got a few dozen Linux machines running <code>cron</code> and I'd like to put the crontabs in some sort of revision control system. For source control I use Mercurial (<code>hg</code>), so that'd be ideal, but if there's some other system that is better suited to this task I'd consider it.</p> <p>One aspect wh...
<p>crontab -l dumps your crontab to standard output, which you could redirect to a file. You could have a job (in cron, naturally) to redirect this to a file which is then diffed, and pushed to source control as necessary.</p>
<p>If the linux system follows the LFS (linux filesystem standard, IIRC), then /etc should only contain config files. I had pretty good experience by importing the whole of /etc into CVS. </p> <p>The only problem is that only root could commit changes, so it was a bit hard to see who broke something. This can be solve...
41,069
<p>I'm using a preformatted text file as a template for emails. The file has line breaks where I want them. I'd like to use this template to send a plain text email, but when I do I'm losing all formatting. Line breaks are stripped.</p> <p>How do I parse this file and retain line breaks? I don't want to use a <code>&l...
<p>this is what I have done...</p> <p>I take a text, or HTML file, ( I'll show text, since its smaller, but the exact same code applies ), and I put well know values into the text file that I can later replace.</p> <p>-- Begin Text File</p> <pre><code>We've generated a new password for you at your request, you can u...
<p>I would recommend using <a href="http://www.webdevbros.net/2007/06/28/template-component-for-classic-asp/" rel="nofollow noreferrer">http://www.webdevbros.net/2007/06/28/template-component-for-classic-asp/</a></p>
41,537
<p>jQuery return links are not working. I have Used jQuery and the basic Ajax feature. My jQuery returns the links from file <code>Links_ajax.php</code>.</p> <p>I giving the code samples.</p> <p>GetCustomerData.php has:</p> <pre><code>&lt;html&gt; &lt;script type="text/javascript"&gt; &lt;script src="ajax.js...
<p>First try the following:</p> <pre><code>success: function(data){ //$("#response").html(data); alert(data); } </code></pre> <p>Thus you will know if it is really returning the data or not .</p> <p>If this is working then you can replace </p> <pre><code>`$("#response").html(data)` </code></pre> <p>...
<p>First try the following:</p> <pre><code>success: function(data){ //$("#response").html(data); alert(data); } </code></pre> <p>Thus you will know if it is really returning the data or not .</p> <p>If this is working then you can replace </p> <pre><code>`$("#response").html(data)` </code></pre> <p>...
49,485
<p>I want the most performat way to read and parse a file.</p> <p>Is it possible to read a file in .NET, but not load the entire file into memory? i.e. just load the file line by line as I parse the content of each row?</p> <p>Does XmlTextReader load the entire file into memory or does it stream the file into memory...
<p>You could use the ReadLine method of StreamReader Class:</p> <pre><code>string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader("c:\\test.txt"); while((line = file.ReadLine()) != null) { Console.WriteLine (line); } file.Close(); </code></pre> <p...
<p>I'm not sure about XMLTextReader, but you can read a file line by line using the FileReader objects. )</p>
30,681
<p>Are there any good references for synchronisation algorithms?</p> <p>I'm interested in algorithms that synchronize the following kinds of data between multiple users:</p> <ul> <li>Calendars</li> <li>Documents</li> <li>Lists and outlines</li> </ul> <p>I'm not just looking for synchronization of contents of directo...
<p>There's a high-level and very broad overview of all synchronisation algorithms in <em><a href="http://www.ece.cmu.edu/~ece845/docs/optimistic-data-rep.pdf" rel="nofollow noreferrer">Optimistic Replication</a></em> (by Yasushi Saito and Marc Shapiro, <a href="http://en.wikipedia.org/wiki/Portable_Document_Format" re...
<p>I would have thought that looking at any of the open-source source code control applications would give you the right idea - merging changes between files is exactly what they do...</p>
8,414
<p>From managed C++, I am calling an unmanaged C++ method which returns a double. How can I convert this double into a managed string?</p>
<p>I assume something like</p> <pre><code>(gcnew System::Double(d))-&gt;ToString() </code></pre>
<p>C++ is definitely not my strongest skillset. Misread the question, but this should convert to a std::string, not exactly what you are looking for though, but leaving it since it was the original post....</p> <pre><code>double d = 123.45; std::ostringstream oss; oss &lt;&lt; d; std::string s = oss.str(); </code></p...
12,885
<p>Suppose you work at a medium-to-large software company with many independently-developed projects (independent coders) but which rely on each other (dependent code).</p> <p>If it were up to you, would you make sure each project produced stable branches so that the other projects could more reliably use those branch...
<p>As always, there are pros and cons for each of the options.</p> <p>Using branches may be more stable but it requires more maintenance when you're required to update to a newer branch. It also requires their development team to spent extra time when the branch is merged with the trunk.</p> <p>On the other hand, usi...
<p>Looking at other projects, it seems to me that the issue that you raise is addressed by having security branches. E.g. Debian packages. That way, you would continue using stable branch across projects. For the reasons you mention, testing / work-in-progress branches carry too much risk.</p>
18,916
<p>An XML attribute declared as xs:boolean can acceptable be "true", "false", "0" or "1". However, in .NET, Boolean.Parse() will only accept "true" or "false". If it sees a "0" or "1", it throws a "Bad Format" exception.</p> <p>So, given that, what's the best way to parse such a value into a Boolean?</p> <p>(Unfortu...
<p>I think that <a href="http://msdn.microsoft.com/en-us/library/e2104c2x.aspx" rel="noreferrer">XmlConvert</a> has all the methods for converting between common language runtime types and XML types. Especially <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.toboolean.aspx" rel="noreferrer"><code...
<p>Sanitise the data before attempting to parse it:</p> <pre><code> string InnerText = yourXmlNode.InnerText; if (InnerText.Equals("0")) InnerText = "false"; else if (InnerText.Equals("1")) InnerText = "true"; </code></pre> <p>Any other entry than <em>true</em>, <em>false</em>, <em>0</em> or <em>1</em> wi...
33,270
<p>I'm considering building a framework for VB.NET, and using the My namespace to plug it into VB seems like a reasonable idea. What is &quot;My&quot; used for?</p>
<p>The purpose of My, as I understand it, is to be an easy shortcut to certain API tasks that are common but hard-to-find or hard-to-use. You probably shouldn't completely subsume your framework under My. (For one thing, C# people using your framework may get grouchy.)</p> <p>Instead, you should design it as a norma...
<p>I don't use it a lot.</p>
23,742
<p>This is in the context of <a href="http://en.wikipedia.org/wiki/Automatic_differentiation" rel="noreferrer">Automatic Differentiation</a> - what would such a system do with a function like <code>map</code>, or <code>filter</code> - or even one of the <a href="http://en.wikipedia.org/wiki/SKI_combinator_calculus" rel...
<p>Higher-order functions are discrete. They don't have the Cartesian quality of having arguments that have well-defined mappings to points in some n-dimensional space.</p> <p>However, with your clarification on the answer, there are several things that can be said. Symbolically differentiating some higher-order funct...
<p>Higher-order functions are discrete. They don't have the Cartesian quality of having arguments that have well-defined mappings to points in some n-dimensional space.</p> <p>However, with your clarification on the answer, there are several things that can be said. Symbolically differentiating some higher-order funct...
41,539
<p>I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint.</p> <p>For example, the code stopped at a br...
<p>This feature is documented here:</p> <p><a href="http://pydev.org/manual_adv_debug_console.html" rel="noreferrer">http://pydev.org/manual_adv_debug_console.html</a></p>
<p>When I set a break point and hit F11 Eclipse launches the debugger and prompts to open the "Debug Perspective". You can then open the Window-->Show View --> Expressions which opens the expressions view, you can then right click in the Expressions view windows and choose "Add Watch Expression" to add any expression(...
34,167
<p>I am actually new to this forum and I kept trying for a few days to find an easy way to copy an entire LDAP subtree to another tree. Since I couldn't find anything useful, i thought of dropping a question here as well. Does anybody know how to do this programatically ?</p> <p>For normal operations like add, remove,...
<p>I actually don't know Spring LDAP but if your LDAP interface does not provide any high level abstraction for moving/renaming or copying an entire subtree you have to move/rename or copy all subtree nodes recursively. The LDAP API does not provide such an option directly.</p> <p>The following is pseudo-code:</p> <p...
<p>Do note that passwords are tricky to copy. You may or may not be able to read them via the LDAP API. It would depend on the LDAP implementation you are using this against.</p> <p>Thus a copy to a new location may not get everything you want or need.</p>
18,393
<p>Looking for books or other references that discuss actually <em>how</em> to write a code coverage tool in Java; some of the various techniques or tricks - source vs. byte code instrumentation. </p> <p>This is for a scripting language that generates Java byte code under the hood.</p>
<p>Does your scripting language generate bytecode? Does it generate debug metadata? If so, bytecode instrumentation is probably the way to go. In fact existing tools will probably work (perhaps with minimal modification).</p> <p>The typical problem with such tools that they are written to work with Java and assume tha...
<p>Thxm, Mc! <a href="http://asm.objectweb.org" rel="nofollow noreferrer">http://asm.objectweb.org</a>/ is another one. <em>Excellent</em> documentation on byte code instrumentation, but nothing "directly" aimed at writing a coverage tool - just some hints or ideas.</p>
2,429
<p>If I have added/removed/modified a large number of files in my local ClearCase view, how can I be certain that all the files have been added to source control?</p>
<p>Your answer is correct, for <strong><em>snapshot</em></strong> views (which you call 'local view' ?)<br> In a dynamic view, a simple</p> <pre><code>cleartool lsprivate </code></pre> <p>would suffice.</p> <p>But that would leave out <em>hijacked</em> files (which are already added to source control, but may have b...
<p>Use <code>cleartool ls -view_only -r</code> from the your local view VOB directory.</p> <p>To add any files recursively to source control that are only in the local view, see <a href="https://stackoverflow.com/questions/138321/how-can-i-use-clearcase-to-add-to-source-control-recursively">How can I use ClearCase to ...
23,306
<p>I have a WCF service and I want to expose it as both a RESTfull service and as a SOAP service. Anyone has done something like this before?</p>
<p>You can expose the service in two different endpoints. the SOAP one can use the binding that support SOAP e.g. basicHttpBinding, the RESTful one can use the webHttpBinding. I assume your REST service will be in JSON, in that case, you need to configure the two endpoints with the following behaviour configuration</p>...
<p>This is what i did to make it work. Make sure you put<br> <strong>webHttp automaticFormatSelectionEnabled="true"</strong> inside endpoint behaviour.</p> <pre><code>[ServiceContract] public interface ITestService { [WebGet(BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/product", ResponseFormat = WebMessa...
22,586
<p>You know those websites that let you type in your checking account number and the routing number, and then they can transfer money to and from your account?</p> <p>How does that work? Any good services or APIs for doing that? Any gotchas?</p>
<p>The banks do have APIs for doing this, but only approved people/companies are allowed to interface with these systems. Because it actually involves transferring money around, the security requirements are pretty high in terms of how you handle the account numbers on your system. </p> <p>Many sites that offer this...
<p>Paypal has a fairly accessible API you can use within your program to accomplish some of this.</p>
17,240
<p>I have a complete XML document in a string and would like a <code>Document</code> object. Google turns up all sorts of garbage. What is the simplest solution? (In Java 1.5)</p> <p><strong>Solution</strong> Thanks to <a href="https://stackoverflow.com/users/1322/matt-mcminn">Matt McMinn</a>, I have settled on this i...
<p>This works for me in Java 1.5 - I stripped out specific exceptions for readability.</p> <pre><code>import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import org.w3c.dom.Document; import java.io.ByteArrayInputStream; public Document loadXMLFromString(String xml) throws Except...
<p>To manipulate XML in Java, I always tend to use the Transformer API:</p> <pre><code>import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; public sta...
5,329
<p>Does anyone know of a good alternative to cron? I would like something that can be run with different time zones.</p>
<p>You may consider <a href="http://www.opensymphony.com/quartz/wikidocs/Features.html" rel="nofollow noreferrer">Quartz</a> (a java-based solution), that can take advantage of <a href="http://jira.opensymphony.com/browse/QUART%5A-540" rel="nofollow noreferrer"><code>Date</code> build in the appropriate TimeZone</a>.</...
<p>MacOS X has replaced <code>cron</code>, <code>at</code>, <code>xinet</code>, and <code>watchdog</code> with open source <code>launchd</code> (<a href="http://en.wikipedia.org/wiki/Launchd" rel="nofollow">Wikipedia</a>). Process properties are described in a XML file, which allows passing arguments. Switching timezon...
36,701
<p>Why is it so hard to do this in Java? If you want to have any kind of module system you need to be able to load JAR files dynamically. I'm told there's a way of doing it by writing your own <code>ClassLoader</code>, but that's a lot of work for something that should (in my mind at least) be as easy as calling a meth...
<p>The reason it's hard is security. Classloaders are meant to be immutable; you shouldn't be able to willy-nilly add classes to it at runtime. I'm actually very surprised that works with the system classloader. Here's how you do it making your own child classloader:</p> <pre><code>URLClassLoader child = new URLCla...
<p>I personally find that <a href="http://download.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html" rel="nofollow">java.util.ServiceLoader</a> does the job pretty well. You can get an example <a href="http://java.sun.com/developer/technicalArticles/javase/extensible/" rel="nofollow">here</a>.</p>
8,576
<p>I'm trying to write a console (as in terminal, not gaming console) pong game in python and I'm having trouble figuring how best to (re)draw the game.</p> <p>I was thinking of having an 2d array as a sort of bitmap, editing the array to reflect the ball/paddles new positions and then casting each row to a string and...
<p>It looks like there is a <a href="http://en.wikipedia.org/wiki/Curses_(programming_library)" rel="nofollow noreferrer">curses</a> port/library for Python:</p> <p><a href="https://docs.python.org/library/curses.html" rel="nofollow noreferrer">https://docs.python.org/library/curses.html</a></p>
<p>I would investigate using the <a href="http://python.org/doc/2.5/lib/module-curses.html" rel="nofollow noreferrer">curses</a> module. It will take care of a lot of the details and let you focus on the higher level stuff.</p>
13,241
<p>I have to generate two random sets of matrices Each containing 3 digit numbers ranging from 2 - 10 </p> <p>like that</p> <p>matrix 1: 994,878,129,121</p> <p>matrix 2: 272,794,378,212</p> <p>the numbers in both matrices have to be greater then 100 and less then 999</p> <p>BUT</p> <p>the mean for bo...
<p>In order to do this, you have to know how many numbers are in each list. I'm assuming from your example that there are four numbers in each.</p> <ol> <li>Fill the first list with four random numbers. <li>Calculate the mean of the first list. <li>Multiply the mean by 2 or by 3/2, whichever the user input. This is ...
<p>You have a set of random numbers, s1.</p> <pre><code>s1= [ random.randint(100,999) for i in range(n) ] </code></pre> <p>For some other set, s2, to have a different mean it's simply got to have a different range. Either you select values randomly from a different range, or you filter random values to get a differe...
29,708
<p>I just added a fan to my printer because very small layers seem to come out very badly. For example, the 5mm PLA cube that's the top level of the test shape shown below. Watching closely, I can see that the newly-extruded fiber is pushing the previous layer(s?) around pretty freely. And when the object is finished, ...
<h2>Layer Times</h2> <p>See my answer to <a href="https://3dprinting.stackexchange.com/questions/516/what-parameters-affect-cylinder-regularity">this question</a> and pay particular attention to my suggestion about a minimum layer print time. I'm not sure if all slicing engines provide this option, but I know MakerWar...
<p>I believe you might be having an issue with insufficient cooling. Remember the suggestion to have wait times per layer to let the previous layer cool? Well, I think with your setup and print not only do individual layers overheat, but individual parts of each layer. You either need to try more direct or dual fan coo...
191
<p>PERL? Perl? perl? What's good style?</p> <p>I know the answer&mdash;I just wanted to make sure the question was out there and questioners were aware that there is a correct form.</p>
<p>The correct casing is "Perl" for the language and "perl" for the executable. Using "PERL" flags you as someone who isn't particularly familiar with the language or community.</p> <p>See also <a href="http://perldoc.perl.org/perlfaq1.html#What%27s-the-difference-between-%22perl%22-and-%22Perl%22?" rel="noreferrer">W...
<p>perl or Perl is fine.</p>
9,796
<p>Anyone have any suggestions on where to start for a newbie wanting to try out some sort of source-control along with a new journey into ASP.NET? SVN, VSS, CVS...I dont even know where to start!</p>
<p>Lots of people here have suggested introductions and comprehensive how-tos, which are all good for telling you how to do what you want.</p> <p>In addition, I'd give three pieces of advice for the novice on how to know what you want:</p> <p>1) Version-control EVERYTHING (that is, everything you write). </p> <p>Ver...
<p>Visual Source Safe (VSS) is fine for a beginner, because you won't know what you're missing. When you need something more complicated, then worry about getting some other product.</p>
12,865