instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Can I collapse those two "getFields" methods into one using generics (the second method is intended to package private access) or should I rename the second one into something ugly like "getFieldPackagePrivate"?</p> <pre><code>public interface IField { } class Field implements IField { // package private class ...
<p>You can write (as per my answer to your previous question):</p> <pre><code>public List&lt;? extends IField&gt; getFields() </code></pre> <p>but you can't overload by return type, and you can't expose a package-private type in a public method.</p> <p>EDIT: With the change of the question, the answer is a simple "n...
<p>After I experimented a little I found a solution based on Jon Skeet's answer</p> <p>The code looks like this.</p> <pre><code>public interface IField { } class Field implements IField { // package private class } public class IForm { public List&lt;? extends IField&gt; getFields(); } public cla...
40,528
<p>Is there an EF equivalent to LINQ to SQL's OnCreated partial? </p> <p>Several of my objects have XML fields that I would like to parse whenever the object is loaded from the db - I'd like to put the XML data into more friendly strongly-typed collections. I've already marked the XML field as private and hooked the S...
<p>There is no <code>OnLoaded</code> event or similar as far as I know. A workaround might be to expose the collections as properties and lazily create/parse the values on first access:</p> <pre><code>private List&lt;SomeData&gt; _parsedDataCache; public IList&lt;SomeData&gt; ParsedData { get { if (_parsed...
<p>You should create a partial class (as you do in LINQ to SQL) and just use the default constructor.</p>
44,328
<p>Does anyone know how I can add a class to the link rendered using the Html.RouteLink helper method in ASP.Net MVC, it has the htmlAttributes object as the last parameter which I assumed I would be able to use, but since class is obviously a reserved word, I cannot supply this as one of the properties on the object.<...
<p>Try this:</p> <pre><code>&lt;%= Html.RouteLink("Default", "Default",null, new { @class="css_class"}) %&gt; </code></pre>
<p>Please note that in the c# specificaiton, the @ special character is used in front of a variable name to allow the use of keyword as a variable name. So @class = "css_class" means setting value of the property called "class" to css_class</p>
31,549
<h2>There seems to be two major conventions for organizing project files and then many variations.</h2> <p><strong>Convention 1: High-level type directories, project sub-directories</strong></p> <p>For example, the <a href="http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk/" rel="nofollow noreferrer">wxWidgets</a> proj...
<p>[A partial answer.]</p> <p>In "Convention 2: High-level project dirs, type sub-directories," your single con is</p> <blockquote> <p>If there are dependencies between projects, you need an additional layer of build scripts above the project directories to manage the build order</p> </blockquote> <p>That ca...
<p>Consider using <a href="http://support.microsoft.com/kb/205524" rel="nofollow noreferrer">NTFS junction points</a> so you can have both organizations at once. Quick definition: "a junction point is Microsoft's implementation of symbolic links but it only works for directories."</p> <p>Use Convention 2 for the "rea...
33,376
<p>I'm doing a little bit of work on a horrid piece of software built by Bangalores best.</p> <p>It's written in mostly classic ASP/VbScript, but "ported" to ASP.NET, though most of the code is classic ASP style in the ASPX pages :(</p> <p>I'm getting this message when it tries to connect to my local database:</p> <...
<p>I ran into this a long time ago with working in ASP. I found this knowledge base article and it helped me out. I hope it solves your problem.</p> <p><a href="http://support.microsoft.com/kb/269495" rel="nofollow noreferrer">http://support.microsoft.com/kb/269495</a></p> <p>If this doesn't work and everything che...
<p>As a side note, <a href="http://connectionstrings.com" rel="nofollow noreferrer">connectionstrings.com</a> is a great site so you don't have to remember all that connection string syntax.</p>
4,438
<p>I would like to implement a robust IPC solution between a single JVM app (one process, potentially multiple threads) and a native C++ application that is linked to a C++ dll. The dll may or may not be on the same physical machine. What is the best approach for doing so?</p> <p>Any suggestions will be greatly appr...
<p>I'd use a standard TCP/IP socket, where the app listens on some port and the library connects to it to report what it has to report and expect the answers.</p> <p>The abstraction is robust, well supported and will have no interop issues.</p>
<p>mmm - DLLs are not processes, so I'm assuming you mean IPC between your Java app, and some other native application that is linked to the DLL. Sockets, for certain, are the way to go here. It will make everything easier for you.</p> <p>Another option would be to use JNI to talk to a DCOM implementation, but I don...
20,039
<p>How much traffic can one web server handle? What's the best way to see if we're beyond that?</p> <p>I have an ASP.Net application that has a couple hundred users. Aspects of it are fairly processor intensive, but thus far we have done fine with only one server to run both SqlServer and the site. It's running Window...
<p>What you need is some info on <a href="http://msdn.microsoft.com/en-us/library/ms979198.aspx" rel="noreferrer">Capacity Planning</a>..</p> <p>Capacity planning is the process of planning for growth and forecasting peak usage periods in order to meet system and application capacity requirements. It involves extensiv...
<p>On that hardware, a .NET application should be able to serve about 200-400 requests per second. If you have only a few hundred users, I doubt you are seeing even 2 requests per second, so I think you have a lot of capacity on that box, even with SQL server running.</p> <p>Without know all of the details, I would sa...
8,496
<p>I have a User object that has a Country object on it. I map this with a many-to-one tag in the User mapping file:</p> <pre><code>&lt;many-to-one name="Country" column="CountryID" cascade="none"/&gt; </code></pre> <p>How do I update a User's country?</p> <p>At the moment my UI has a dropdown of countries and the I...
<p>You can always get hold of the underlying connection and do the update manually.</p> <p><a href="http://www.darkside.co.za/archive/2008/03/03/castle-activerecord-get-the-underlying-database-connection.aspx" rel="nofollow noreferrer">http://www.darkside.co.za/archive/2008/03/03/castle-activerecord-get-the-underlying...
<pre><code>var user = session.Get&lt;User&gt;(userID); user.Country = session.Get&lt;Country&gt;(Convert.ToInt32(Request.Form["Country_ID"])); </code></pre> <p>You must retrieve the country from the database and then set it to the user</p>
31,282
<p><strong>My goal is to get Limewire(JAVA) and Songbird(XULRunner) to run together.</strong></p> <p>I was thinking the best way is to run the XUL application(songbird) inside a JAVA swing panel. Is there another way?</p> <p>Would it be better or possible to have the GUI entirely in XUL, and then access my JAVA objects...
<p>Take a look at <a href="http://jrex.mozdev.org/" rel="nofollow noreferrer">JRex</a>, as it might let you peek into a couple of ideas.</p> <p>Other than that, I'd also research about <a href="http://zelea.com/project/textbender/o/rhinohide/description.xht" rel="nofollow noreferrer">Rhinohide</a> as well.</p>
<p>I am currently researching XUL for a new product and I came across <a href="https://developer.mozilla.org/en/JavaXPCOM" rel="nofollow noreferrer" title="JavaXPCOM">JavaXPCOM</a> which allows Java code to interact with XPCOM objects. I'm still wrapping my head around the Mozilla stack, but from what I understand all...
37,685
<p>I'm using DB2, although a solution using any flavor of SQL would likely be easy enough for me to convert.</p> <p>I didn't design this database, or the application that uses the database. I haven't the power to change this application, how it works, or the data. Because it defies what I consider to be conventional...
<p>would this work:</p> <pre><code>SELECT * FROM table_name WHERE START_DATE &lt; '7/1/2005' AND (END_DATE &gt; '7/1/2005' OR END_DATE IS NULL); </code></pre>
<p>From what you've given us, this is what you want:</p> <pre><code>select * from facitities where START_DATE &lt;= @my_date and (@mydate &lt;= END_DATE or END_DATE is null) </code></pre> <p>however, I suspect you knew that, and want something different, in which case, you'll have to be more specific about what's wro...
22,214
<p>I can't for the life of me find a way to make this work.</p> <p>If I have 3 divs (a left sidebar, a main body, and a footer), how can I have the sidebar and main body sit next to each other without setting their positions as "absolute" or floating them? Doing either of these options result in the footer div not bei...
<p>You need to specify the footer to clear the float:</p> <pre><code>#footer{ clear: both; } </code></pre> <p>This forces it under floated elements.</p> <p>Other options for clear are left and right.</p>
<p>Right now you're pretty hopeless if you don't want to float anything, nor use position: absolute.</p> <p>The only alternatives left are:</p> <ul> <li>use display:inline-block for the sidebar and content divs (this is not supported by all browsers yet)</li> <li>wait for the <a href="http://www.w3.org/TR/css3-layout...
34,547
<p>I know that you need a special nozzle to extrude abrasive filament (carbon fibre, copper, ...). I do have such a nozzle (coated steel) and am printing carbon fibre and copper filament. Last time I used it to print carbon fibre PLA. It worked well, however when I removed the nozzle from the hotend I realized that I c...
<p>Abrasive filaments require a stronger nozzle indeed. They also require an all-metal hotend. If your hotend wasn't all-metal, there's a good chance you've damaged it.</p> <p>The PEEK/PTFE in your hotend doesn't like going above 240 Celsius and tends to be irreparably damaged if used too long above 250 Celsius.</p>
<p>The hotend itself consists of basically 3 parts:</p> <ul> <li>The filament path, aka Coolend. It consists of the heartbreak, cooling solution and anything up from it.</li> <li>The heater block, that holds everything together</li> <li>The nozzle, in which the filament melts and is pushed out.</li> </ul> <p>The part o...
2,037
<p>I have some code which I did not originally create that uses _beginthreadex and _endthreadex. For some reason, when it calls _endthreadex(0), the call just hangs and never returns. Any ideas as to what would normally cause this call to hang?</p>
<p>_endthreadex ends the thread, so it can't return. That's the whole point of calling it.</p> <p>EDIT: It's a bit unusual to call _endthreadex, normally you just let the thread start procedure return and the runtime calls _endthreadex for you. You may need to explain a bit more, what you are trying to do before we ca...
<p>Ok....well, endthreadex gets called in the deconstructor of my class via "delete classinstance"...and that deconstructor call never returns...so the whole thing hangs</p>
45,980
<p>What's the best mocking framework syntax-wise and capability-wise ?</p> <p>My problem: Most mocking frameworks use lambda expressions now, which are really ugly to write in VB.NET, so is there any framework that has nice syntax without lambdas or has fluent syntax that doesn't need lambdas?</p>
<p>I think capability wise Typemock is the best framework for .Net, instead of working within the runtime it hooks into the CLR and can intercept about any call. This enables you to mock and test anything you want. Some people think it's too powerful. It allows you to test anything while usually the fact that you can't...
<p>rhino mocks.</p> <p>But you could have trouble with the new lambda-expression syntax (especially when setting expectations on subs) so either use the new syntax or be prepared to work around it. </p>
29,625
<p>I'm working with dRuby and basicly I'm calling a remote method that returns me an object.</p> <p>In the clientside I have this code:</p> <pre><code>handle_error(response) if response.is_a?(Error) </code></pre> <p>where response is the DRbObject. (I've developed this code before using dRuby and I'm returning an Er...
<p>Although I'm not sure how DRb manages the remote objects, I'd expect it to modify #kind_of? to keep the class hierarchy on the remote object, so you could do:</p> <pre><code>response.kind_of?(Error) </code></pre> <p>If this doesn't work you can always ask it if it responds to an specific method and go from there...
<p>Could you not work around the problem by using <a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/78502" rel="nofollow noreferrer">Duck Typing</a>? Instead of checking for whether the object is an Error, check whether the object responds to a call to get the error information. If it does, handle th...
23,147
<p>Do you know if I can use Visio to forward-engineer a sequence diagram into code (c#)?</p> <p>Can it be done with Visio alone or do I need a plugin?</p> <p>What about other diagrams?</p>
<p>You have to get the Visio that for users of Visual Studio. See this link: <a href="http://msdn.microsoft.com/en-us/library/ms182014.aspx" rel="nofollow noreferrer">Visio for Enterprise Architects</a> for more details. The code generation capabilities are fairly weak and you might end up getting Visio into an incon...
<p>To the best of my knowledge, Visio can only forward-engineer code from class models. </p> <p>As sequence diagrams only really show paths of communication between objects, I suspect that they do not contain the necessary information, except perhaps in trivial cases, for generating code. </p> <p>Objects with any so...
4,582
<p>In Eclipse, I can switch through open editors using control-page up/down. This works great, except for editors like XML or JavaScript, where there are Design and Source tabs. For those editors, it just toggles between the different tabs. Is there any way to get Eclipse to ignore them? I know about alt-F6 for "Next E...
<p>You're right -- looks like Eclipse has acknowledged it as a <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499" rel="nofollow noreferrer">bug</a>. It's fixed in 3.5.</p>
<p>I was initially thinking <kbd>Alt</kbd>-<kbd>←</kbd> and <kbd>Alt</kbd>-<kbd>→</kbd> might do what you want, but that's more for going forward and backwards in history of tabs you've viewed. Which might sort of get you what you want, but is probably just as confusing as <kbd>Alt</kbd>-<kbd>F6</kbd>.</p> <p>I think i...
8,697
<p>I have a feeling I'm being too "webforms" with this, but I'll ask anyway. I have a form in an ASP.NET MVC project that has some input fields and two buttons on it. One button is used to 'filter' one of the list boxes. The other is used to submit the form. My view looks something like this:</p> <pre><code>&lt;%u...
<p>I would suggest multiple forms with 2 different actions. This I think is also more testable:</p> (c => c.Search(), FormMethod.Get); { %> Find (c => c.Send(), FormMethod.Post); { %> Send <p>or something like that. Then in the controller you have 2 corresponding actions. This means the responsibility i...
<p>The app I am creating needs to be massively ajax'd up, however the multiple forms problem hit as well.</p> <p>We got round it using the $.post() method from the jQuery library. </p> <pre><code>$("#update").click(function() { $.post("/Register", { name: $("#firstName").val(), su...
49,262
<p>The code currently does this and the fgetpos does handle files larger than 4GB but the seek returns an error, so any idea how to seek to the end of a <code>file &gt; 4GB</code>?</p> <pre><code>fpos_t currentpos; sok=fseek(fp,0,SEEK_END); assert(sok==0,"Seek error!"); fgetpos(fp,&amp;currentpos); m_filesize=curren...
<p>If you're in Windows, you want <a href="http://msdn.microsoft.com/en-us/library/aa364957(VS.85).aspx" rel="noreferrer">GetFileSizeEx (MSDN)</a>. The return value is a 64bit int.</p> <p>On linux <a href="http://www.manpagez.com/man/2/stat64/" rel="noreferrer">stat64 (manpage)</a> is correct. fstat if you're working ...
<p>On linux, at least, you could use lseek64 instead of fseek.</p>
13,799
<p><em>Background</em>: I am currently using custom controls within my C# project (basic controls just drawing a custom look and feel (using gdi+?)). The majoritiy of these controls have transparent segments for irregular shapes etc. </p> <p><em>Problem</em>: I am looking to overlay a semi-transparent (irregularly sha...
<p>AFAIK you can't really mix GDI+ and OpenGL/DX.</p> <p>If you're getting slow performance and are <strong>absolutely sure</strong> that it's a bottleneck in GDI+ rather than in your code, than it <em>could</em> make sense to ditch GDI+ and replace it with DX/OGL. (You would have to write your own controls, though, w...
<p>Did you try turning on DoubleBuferring on your controls to see if that gives you a performance boost?</p> <p><a href="http://www.codeproject.com/KB/graphics/DoubleBuffering.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/graphics/DoubleBuffering.aspx</a></p>
34,142
<p>I have a list view that after a double click, a record opens a new form to show the details, but the record in the list view lost the "selection".... How do I know which record was clicked ???</p> <p>Thanks </p> <p>Maria João</p>
<p>The listview control has a <em>HideSelection</em> property that defaults to True. Set this to False and the current row will remain highlighted even if the control loses focus.</p>
<p>Try setting the HideSelection property on the list view to false. It's enabled by default.</p>
30,229
<p>Can someone please remind me how to create a .Net class from an XML file?<br></p> <p>I would prefer the batch commands, or a way to integrate it into the shell.<br></p> <p>Thanks!</p>
<p>The below batch will create a .Net <strong>Class</strong> from <strong>XML</strong> in the current directory.<br> So... XML -> XSD -> VB</p> <p>(Feel free to substitute CS for Language)</p> <p>Create a <strong>Convert2Class.Bat</strong> in the %UserProfile%\SendTo directory.<br> Then copy/save the below:</p> <pre...
<p>You might be able to use the xsd.exe tool to generate a class, otherwise you probably have to implement a custom solution against your XML</p> <p><a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.80).aspx" rel="nofollow noreferrer">XML Schema Definition Tool</a></p> <p><a href="http://msdn.microsoft.com...
12,871
<p>I want to do this so that I can say something like, <code>svn mv *.php php-folder/</code>, but it does not seem to be working. Is it even possible? No mention of it is made on the relevant page in the <a href="http://svnbook.red-bean.com/en/1.0/re18.html" rel="noreferrer">svn book</a>.</p> <p>Example output of <c...
<p>Not sure about svn itself, but either your shell should be able to expand that wildcard and svn can take multiple source arguments, or you can use something like</p> <pre><code>for file in *.php; do svn mv $file php-folder/; done </code></pre> <p>in a bash shell, for example.</p>
<p>If you're in the correct checked out directory, I don't see why it wouldn't work? Your shell should expand the *.php to a list of php files, and svn move accepts multiple sources as arguments.</p>
11,304
<p>For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9.</p> <p>The version number is very important...</p>
<p>This is going to be PInvoke city...</p> <p>You'll need to PInvoke the following API's in User32.dll</p> <p>Win32::GetForegroundWindow() in returns the HWND of the currently active window.</p> <pre><code>/// &lt;summary&gt; /// The GetForegroundWindow function returns a handle to the foreground window. /// &lt;/su...
<p>This <a href="http://www.codeproject.com/KB/cs/windowhider.aspx" rel="nofollow noreferrer">project</a> demonstrates the two functions you need: <a href="http://msdn.microsoft.com/en-us/library/ms633497(VS.85).aspx" rel="nofollow noreferrer">EnumWindows</a> and <a href="http://msdn.microsoft.com/en-us/library/ms6335...
14,345
<p>I have to define the grammar of a file like the one shown below.</p> <p>//Sample file<br> NameCount = 4<br> Name = a<br> Name = b<br> Name = c<br> Name = d<br> //End of file<br></p> <p>Now I am able to define tokens for <strong>NameCount</strong> and <strong>Name</strong>. But i have to define the file structure i...
<p>This cannot be expressed in the grammar itself. If the number was fix you could express the number of expected tokens. But the token stream changes based on the value. What you can do is to include this into the lexer/parser combination. But you cannot create this construct by just the plain grammar syntax. You prob...
<p>I'm not sure this is a context free grammar. If it isn't, you cannot tell ANTLR to parse the language.</p>
39,785
<p>I'm trying to configure a dedicated server that runs ASP.NET to send mail through the local IIS SMTP server but mail is getting stuck in the Queue folder and doesn't get delivered.</p> <p>I'm using this code in an .aspx page to test:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" %&gt; &lt;% new ...
<p>I find the best thing usually depending on how much email there is, is to just forward the mail through your ISP's SMTP server. Less headaches. Looks like that's where you are having issues, from your SMTP to external servers, not asp.net to your SMTP.</p> <p>Just have your SMTP server set to send it to your ISP, o...
<p>By the looks of things your firewall isn't letting SMTP (TCP port 25) out of your network.</p>
12,330
<p>To send a message I usually press <kbd>ctrl</kbd> + <kbd>enter</kbd>. What other shortcuts do you think are important to implement into your webapplications?</p> <p>Edit: What buttons do you think are interessting to catch with js because they aren't used by the browser? </p> <p>I am not thinking of <kbd>ctrl</kbd...
<p>Shortcuts in webapps are a good idea for your power users, but there's not nearly as much agreement on them as there is on desktop app shortcuts. For desktop apps, the ctrl key standards are essentially universal:</p> <ul> <li>z (undo)</li> <li>y (redo)</li> <li>s (save)</li> <li>a (select all)</li> <li>x (cut)</li...
<p>Undo and Redo (<kbd>ctrl</kbd>-<kbd>Z</kbd> and <kbd>ctrl</kbd>-<kbd>Y</kbd>) if applicable.</p> <p>Mind you, that assumes an editing context. So it really depends on what the context is as to what short cuts are appropriate.</p>
40,125
<p>We use Tomcat to host our WAR based applications. We are servlet container compliant J2EE applications with the exception of org.apache.catalina.authenticator.SingleSignOn.</p> <p>We are being asked to move to a commercial Java EE application server.</p> <ol> <li>The first downside to changing that I see is the c...
<p>When we set out with the goal to Java EE 6 certify Apache Tomcat as <a href="http://tomee.apache.org/comparison.html">Apache TomEE</a>, here are some of the gaps we had to fill in order to finally pass the Java EE 6 TCK.</p> <p>Not a complete list, but some highlights that might not be obvious even with the existin...
<p>Cost isn't necessarily a downside as there a few free J2EE servers, e.g. JBoss and Glassfish.</p> <p>Your question assumes that (J2EE = Servlet + EJB + EAR) and therefore, there's no point in using anything more than a Servlet container if you're not using EJB or EAR. This is simply not the case, J2EE includes a lo...
33,806
<p>I have those maps in my repository. </p> <pre><code>public IQueryable&lt;AwType&gt; GetAwTypes() { return from awt in _db.AwTypes select new AwType { Id = awt.Id, Header = awt.Header, Description = awt.Description }; } public IQuerya...
<p>AwType is a reference type. It would be a bad idea to group on that reference type... Each AwType in that query is a unique reference, so n elements would yield n groups.</p> <p>Try this:</p> <pre><code>var awGroups = from aw in _repository.GetAws() group aw by aw.AwType.ID into newGroup //changed to group on I...
<p>You can group by an anonymous type, eg new { Foo, Bar }</p>
23,114
<p>Is this right for When 4 &lt; 5 and 1 &lt; 2 ?</p> <pre><code>&lt;xsl:when test="4 &amp;lt; 5 AND 1 &amp;lt; 2" &gt; &lt;!-- do something --&gt; &lt;/xsl:when&gt; </code></pre>
<p>Not quite, the AND has to be lower-case.</p> <pre><code>&lt;xsl:when test="4 &amp;lt; 5 and 1 &amp;lt; 2"&gt; &lt;!-- do something --&gt; &lt;/xsl:when&gt; </code></pre>
<p>From <a href="http://www.xml.com/pub/a/2003/04/02/trxml.html" rel="noreferrer">XML.com</a>:</p> <blockquote> <p>Like xsl:if instructions, xsl:when elements can have more elaborate contents between their start- and end-tags—for example, literal result elements, xsl:element elements, or even xsl:if and xs...
41,221
<p>I got some problems with finding a bug in php/mysql application, and I wonder if I can do something like this: <code>UPDATE table SET userid='2' WHERE userid='1'</code> - > Can I update something I state in WHERE?</p>
<p>Absolutely. You can even reference the current value of the column in the set:</p> <p>UPDATE table SET x = x + 5 WHERE x &lt; 3</p>
<p>I see no problem, and you can do a lot <a href="http://dev.mysql.com/doc/refman/5.0/en/update.html" rel="nofollow noreferrer">more</a>...</p>
26,476
<p>I'm trying to "single source" a form page which can be in edit mode or view mode. For various reasons, this isn't using the ASP.Net FormView or DetailsView controls.</p> <p>Since there is no way to disable a textbox without turning its contents gray (well, we could "eat" all of the keystrokes into it, but that isn'...
<p>This may not suit your needs, but it's a possibility.</p> <p><code>&lt;input&gt;</code> and <code>&lt;textarea&gt;</code> tags support the read-only property. The behavior of read-only fields is slightly different than disabled. Here's what the <a href="http://www.w3.org/TR/html401/" rel="nofollow noreferrer">HTML...
<p>When I've done this, I've had to "eat" each keystroke as you describe and mirror it into a "hidden" span tag that mirrors the <code>&lt;input</code> or <code>&lt;select</code> element. The span tags all have a css class that's styled using media selectors to only show for print, and the inputs have a css class that...
43,006
<p>I have a problem similar to the one found here : <a href="https://stackoverflow.com/questions/86531/jsf-selectitem-label-formatting">JSF selectItem label formatting</a>. </p> <p>What I want to do is to accept a double as a value for my and display it with two decimals. Can this be done in an easy way? </p> <p>I'v...
<p>If I'm not misunderstanding your requirement, I was able to achieve formatting of the value in the input box during the rendering of the view with:</p> <pre><code>&lt;h:inputText id="text1" value="#{...}"&gt; &lt;f:convertNumber pattern="#,###,##0.00"/&gt; &lt;/h:inputText&gt; </code></pre> <p>I was using the ...
<p>It seems you're actually formatting a currency. There already exists a specific formatter to handle currencies that you can assign many options to:</p> <pre><code>&lt;f:convertNumber type="currency" /&gt; </code></pre> <p>Some interesting attributes of this tag are: <code>locale</code>, <code>currencyCode</code>, ...
20,157
<p>What is the best way to truncate a URL when displaying it within a web page? I don't mean a link but literally displaying the URL as a value to the user, assuming that the text might be in a container of fixed width and you don't want to wrap or run outside of the container?</p> <p>Is it better to truncate from th...
<p>My preference is to display the most critical components of the URL. This is the file being requested and the domain of the request are what I consider critical, the intermediate path and the query string are things I consider non-critical.</p> <p>So if you had <a href="http://www.Example.com/archives/2005/08/09/s...
<p>I always want to see the server. There've been waves of keyloggers from suspect servers in some forums I visit, and that's given me server paranoia. </p> <p>Ideally, I can scroll around and see the entire url in the container. :-) </p>
25,355
<p>I have a similar problem to <a href="https://stackoverflow.com/questions/174535/google-maps-overlays">this post</a>. I need to display up to 1000 polygons on an embedded Google map. The polygons are in a SQL database, and I can render each one as a single KML file on the fly using a custom HttpHandler (in ASP.NET), ...
<p>For your second question: you need the <a href="http://everything2.com/index.pl?node_id=859282" rel="noreferrer">Douglas-Peucker Generalization Algorithm</a></p>
<p>I don't know much aobut KML, but I think the usual solution to question #2 involves iterating over the points, and deleting any line segments under a certain size. This will cause some "unfortunate" effects in some cases, but it's relatively fast and easy to do.</p>
23,453
<p><p>I am <b>Manoj </b>again here to ask you my doubts. <p>I heard that in turbo c when we are doing projects with more than one source file <p>then we can generate <b>list file and map file </b>. <p>What are they? <p>what do they contain? <p>And how to generate them using the commands at MS-DOS command prompt using t...
<p>The list file normally contains the assembly language code the compiler generated. It may also contain you original source code interspersed with the asm code.</p> <p>The map file contains all the static symbols (functions, globals, etc.) in your code and their relative addresses. Depending on your linker settings,...
<p>As far as I know, map files provide the mappings of functions and variables to relative memory locations. Normally they are not very useful for programmers.</p> <p>To generate them, look at the help file, all information needed should be there.</p>
28,844
<p>How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and <a href="http://python.net/crew/mhammond/win32/Downloads.html" rel="noreferrer">pywin32</a> or <a href="http://www.wxpython.org/" rel="noreferrer">wxPython</a>?</p> <p>Essentially, I need a function that called wil...
<p>Python has the lovely 'platform' module to help you out.</p> <pre><code>&gt;&gt;&gt; import platform &gt;&gt;&gt; platform.win32_ver() ('XP', '5.1.2600', 'SP2', 'Multiprocessor Free') &gt;&gt;&gt; platform.system() 'Windows' &gt;&gt;&gt; platform.version() '5.1.2600' &gt;&gt;&gt; platform.release() 'XP' </code></pr...
<p>An idea from <a href="http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html" rel="nofollow">http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html</a> might help, which can basically answer your question:</p> <pre><code>win_version = {4: "NT", 5: "2K", 6: "XP"}[os.sys.getwindowsversion(...
23,935
<p>I am looking for a regex that will find repeating letters. So any letter twice or more, for example:</p> <pre><code>booooooot or abbott </code></pre> <p>I won't know the letter I am looking for ahead of time. </p> <p>This is a question I was asked in interviews and then asked in interviews. Not so many people get...
<p>You can find any letter, then use <code>\1</code> to find that same letter a second time (or more). If you only need to know the letter, then <code>$1</code> will contain it. Otherwise you can concatenate the second match onto the first.</p> <pre><code>my $str = "Foooooobar"; $str =~ /(\w)(\1+)/; print $1; # pri...
<p>How about:</p> <pre><code>(\w)\1+ </code></pre> <p>The first part makes an unnamed group around a character, then the back-reference looks for that same character.</p>
21,557
<p>Take this simple <em>C# LINQ</em> query, and imagine that <code>db.Numbers</code> is an <em>SQL</em> table with one column <code>Number</code>:</p> <pre><code>var result = from n in db.Numbers where n.Number &lt; 5 select n.Number; </code></pre> <p>This will run very efficiently in <em>C#</em>...
<p>Look closely at <a href="http://www.sqlalchemy.org/" rel="nofollow noreferrer">SQLAlchemy</a>. This can probably do much of what you want. It gives you Python syntax for plain-old SQL that runs on the server.</p>
<p>A key factor for LINQ is the ability of the compiler to generate expression trees. I am using a macro in Nemerle that converts a given Nemerle expression into an Expression tree object. I can then pass this to the Where/Select/etc extension methods on IQueryables. It's not quite the syntax of C# and VB, but it's clo...
14,333
<p>This line:</p> <pre><code>strcat(query,*it); </code></pre> <p>(where <code>*it</code> is an iterator to a string)</p> <p>Keeps giving me this error:</p> <blockquote> <p>no matching function for call to ``strcat(char[200], const std::basic_string, std::allocator >&amp;)`' </p> </blockquote> <p>I guess it's bec...
<p><code>strcat(query,(*it).c_str())</code> should work. What's the runtime error? Are you sure that <code>query</code> is null-terminated before you make the call?</p>
<p>Try this (I assume that the runtime error is because of a NULL/invalid pointer):</p> <pre><code>for (...; it != str.end(); ++it) ... if (!it-&gt;empty()) { strcat(query, it-&gt;c_str()); } </code></pre> <p>EDIT: Sorry, c_str() never returns NULL, which I temporarily forgot, so it is always safe. Unl...
35,952
<p>Do you have a default type that you prefer to use in your dealings with the results of LINQ queries?</p> <p>By default LINQ will return an <code>IEnumerable&lt;&gt;</code> or maybe an <code>IOrderedEnumerable&lt;&gt;</code>. We have found that a <code>List&lt;&gt;</code> is generally more useful to us, so have adop...
<p><code>ToList</code> <em>always</em> evaluates the sequence immediately - not just in LINQ to SQL. If you want that, that's fine - but it's not always appropriate.</p> <p>Personally I would try to avoid declaring that you return <code>List&lt;T&gt;</code> directly - usually <code>IList&lt;T&gt;</code> is more approp...
<p>It depends if you need to modify the collection. I like to use an Array when I know that no one is going to add/delete items. I use a list when I need to sort/add/delete items. But, usually I just leave it as IEnumerable as long as I can.</p>
43,383
<p>Does anyone know of any optimization packages out there for R (similar to NUOPT for S+)?</p>
<p>R has many, many packages for optimization; check the CRAN Task view on Optimization: <a href="http://cran.r-project.org/web/views/Optimization.html" rel="noreferrer">http://cran.r-project.org/web/views/Optimization.html</a>. Of course, for nonlinear programs, there is <code>optim()</code>, which is standard and inc...
<p>I have used <a href="http://cran.r-project.org/web/packages/linprog/index.html" rel="nofollow noreferrer">linprog</a> for linear problems in the past.</p>
46,887
<p>I have a class like so:</p> <pre><code>public class ClassA { public bool MethodA() { //do something complicated to test requiring a lot of setup } public bool MethodB() { if (MethodA()) //do something else //do something else endif }...
<p>You're modifying document while it's being loaded (when browser hasn't "seen" closing tag for this element) . This causes very tricky situation in the parser and in IE it's not allowed.</p> <p><a href="http://blogs.msdn.com/ie/archive/2008/04/23/what-happened-to-operation-aborted.aspx" rel="noreferrer">IE blog</a> ...
<p>Maybe a little late, but this error also pops up if you are using SWFObject and have 2 divs with the same id.</p> <p>I had duplicate divs, [with id="flashcontent", thanks to copy&amp;paste].</p> <p>Solved by renaming the divs with unique ids.</p>
38,683
<p>I'm looking for a way to transform a genuine string into it's hexadecimal value in SQL. I'm looking something that is Informix-friendly but I would obviously prefer something database-neutral </p> <p>Here is the select I am using now:</p> <pre><code>SELECT SomeStringColumn from SomeTable </code></pre> <p>Here is ...
<p>Can you use Cast and the fn_varbintohexstr?</p> <pre><code>SELECT master.dbo.fn_varbintohexstr(CAST(SomeStringColumn AS varbinary)) FROM SomeTable </code></pre> <p>I'm not sure if you have that function in your database system, it is in MS-SQL.</p> <p>I just tried it in my SQL server MMC on one of my tables:</p>...
<p>If it is possible for you to do this in the database client in code it might be easier.</p> <p>Otherwise the error probably means that the built in hex function can't work with your values as you expect. I would double check the input value is trimmed and in the format first, it might be that simple. Then I would c...
26,982
<p>I have a problem with an application running on Fedora Core 6 with JDK 1.5.0_08.</p> <p>After some amount of uptime (usually some days) threads begin getting stuck in native methods.</p> <p>The threads are locked in something like this:</p> <pre><code>&quot;pool-2-thread-2571&quot; prio=1 tid=0x08dd0b28 nid=0x319e w...
<p>My initial suspicion would be that you are experiencing some sort of class-loader realted dead lock. I imagine, that class loading needs to be synchronized at some level because class information will become available for the entire VM, not just the thread where it was initially loaded.</p> <p>The fact that the met...
<p>Maybe you should use another jdk version.<br> For your "puzzling one", there is a bug entry for 1.5.0_08. A memory leak is reported (I do not know, if this is related to your problem):<br> <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6469701" rel="nofollow noreferrer">http://bugs.sun.com/bugdatabase/v...
5,829
<p>I have a form with many input fields.</p> <p>When I catch the submit form event with jQuery, is it possible to get all the input fields of that form in an associative array?</p>
<pre><code>$('#myForm').submit(function() { // get all the inputs into an array. var $inputs = $('#myForm :input'); // not sure if you wanted this, but I thought I'd add it. // get an associative array of just the values. var values = {}; $inputs.each(function() { values[this.name] = $(...
<p>When I needed to do an ajax call with all the form fields, I had problems with the <strong>:input</strong> selector returning all checkboxes whether or not they were checked. I added a new selector to just get the submit-able form elements:</p> <pre><code>$.extend($.expr[':'],{ submitable: function(a){ ...
20,464
<p>I am printing fairly cheap, but highly rated, PLA and not sure whether this is underextrusion or overextrusion; but it just looks bumpy and not clean. My settings:</p> <ul> <li>195 °C at 60 mm/s bed temp 50 °C</li> <li>0.4 mm nozzle at 90 % extrusion</li> <li>0.1 mm layer height</li> <li>6 mm retraction at 60 mm/s w...
<p>I have used a standard soldering iron to modify and fix 3D prints in the past. You have to keep some things in mind when doing so:</p> <ul> <li>Don't overheat your material. PLA can take a soldering iron of about 230 °C before charring.</li> <li>Don't use a tip with solder, or you will get grey deposits in the plast...
<p>Cutting materials with a 'hot knife' isn't anything new. There should be a fairly established toolset for working foam. For 3D prints, I prefer to add coatings rather than modify surfaces with a hand held tool after. I do run a drill bit through printed holes though.</p>
1,914
<p>Java &amp; Oracle both have a <em>timestamp</em> type called Date. Developers tend to manipulate these as if they were <em>calendar</em> dates, which I've seen cause nasty one-off bugs.</p> <ol> <li><p>For a basic date quantity you can simply chop off the time portion upon input, i.e., reduce the precision. But if ...
<p>Here's how we do it.</p> <ol> <li><p>Use timestamps.</p></li> <li><p>Use Half-open intervals for comparison: <code>start &lt;= now &lt; end</code>.</p></li> </ol> <p>Ignore the whiners who insist that BETWEEN is somehow essential to successful SQL.</p> <p>With this a series of date ranges is really easy to audit...
<p>Im storing all dates in milliseconds. I do not use timestamps/datetime fields at all.</p> <p>So, i have to manipulate it as longs. It means i do not use 'before', 'after', 'now' keywords in my sql queries. </p>
18,878
<p>I know the minimum layer height will effect how detailed of an item you can print and the amount of time it takes to print something, but is it necessary to have an extremely low minimum layer height if you plan to print only larger objects?</p>
<p>I believe the <a href="http://manual.slic3r.org/first-print/first-layer">Slic3r Manual</a> summarizes this quite nicely:</p> <blockquote> <p>A thicker layer height will provide more flow, and consequently more heat, making the extrusion adhere to the bed more. It also gives the benefit of giving more tolerance fo...
<p>In short: no.</p> <p>Smaller layers will make your prints look nicer. That said, in my experience, most printers can handle roughly the same layer heights, no matter what the manufacturer says it can do. With a little tinkering, you can get any printer to do what you tell it to do.</p> <p>That said, for larger pri...
84
<p>I am currently faced with a difficult sorting problem. I have a collection of events that need to be sorted against each other (a <a href="http://en.wikipedia.org/wiki/Comparison_sort" rel="nofollow noreferrer">comparison sort</a>) and against their relative position in the list.</p> <p>In the simplest terms I have...
<p>This is actually more than a sorting problem. It's a single-machine scheduling problem with release dates. Depending on what you are trying to do, the problem might be NP-Hard. For example, if you are trying to mimimize the weighted-sum of the completion times (the weight being inversely proportional to the prior...
<p>I think you should sort the list twice: first by priority and then by earliest time, using any <strong>stable</strong> sort algorithm, for instance insertion sort. That way the time will be increasing and for each time things will be sorted by priority.</p> <p>Unless you see something I don't you can completely ign...
37,993
<p>I have a data table with a variable number of columns and a data scroller. How can I enable server side sorting? I prefer that it be fired by the user clicking the column header.</p> <pre><code>&lt;rich:datascroller for="instanceList" actionListener="#{pageDataModel.pageChange}"/&gt; &lt;rich:dataTable id="instance...
<p>I ended up doing it manually. I adding a support tag to the header text tag, like so.</p> <pre><code>&lt;h:outputText value="#{column}"&gt; &lt;a4j:support event="onclick" action="#{pageDataModel.sort(idx)}" eventsQueue="instancesQueue" reRender="instanceList,instanceListScroller"/&g...
<p>Have a look at the "sortBy" property of "rich:columns", maybe that's what you're looking for. <a href="http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html_single/index.html#columns" rel="nofollow noreferrer">Richfaces Reference</a></p>
16,315
<p>I've searched around a bit, but haven't found a satisfactory answer, so I'd like to hear your opinions on this.</p> <p>I have a couple of tools which I have to update and deploy to a few servers every now and then. The source is managed in a SVN repository.</p> <p>To save myself the bother of copying the binaries ...
<p>There's nothing weird about your setup (I'm doing similar things with both build tools and build artifacts when I need to preserve the exact bits.) The layout you want is definitely possible - to "include" specific versions of other branches or tags in your tags/project1/release2, all you need to do is set <a href="...
<p>Not sure why you don't want to put the binaries under the trunk/project1/binaries tree? That said, nothing should stop you from having the tree look like this:</p> <ul> <li>trunk <ul> <li>project1</li> <li>project2</li> </ul></li> <li>built <ul> <li>project1</li> <li>project2</li> </ul></li> <li>tags <ul> <li>...
23,806
<p>I have an application where whenever a file is uploaded to a directory, I have to call SSIS to parse the XML file.</p> <p>Can I call a SSIS directly from a .NET Windows service?</p>
<p><a href="http://blogs.msdn.com/michen/archive/2007/03/22/running-ssis-package-programmatically.aspx" rel="noreferrer">Running SSIS package programmatically</a>.</p> <p>I prefer the second method:</p> <p>Start DTEXEC.EXE process. DTEXEC is command line utility for executing SSIS packages. See its command line optio...
<p>You can call SSIS programtically, execute the package and change the configuration from a .NET code using DTS runtime. <a href="http://blogs.msdn.com/b/olivier_pieri/archive/2007/05/10/run-ssis-package-programatically.aspx" rel="nofollow">Here is complete code of how you can do it</a>.</p>
21,153
<p>I have a c# application that interfaces with the database only through stored procedures. I have tried various techniques for calling stored procedures. At the root is the SqlCommand class, however I would like to achieve several things:</p> <ul> <li>make the interface between c# and sql smoother, so that procedure...
<p>You should try <a href="http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx" rel="nofollow noreferrer">LINQ to SQL</a>.</p>
<p>the simplest solution for what you want [and i'm not saying that it is better or worse than the other solutions] is to create a dataset and drag the stored procedures from the server explorer onto the dataset designer surface. This will create methods in the adapter that you can call and check for references.</p>
19,896
<p>My question pertains to multi-threading in Java. I'm translating an app I wrote in Visual Basic 2008 into Java. There is a class in VB called <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker_members.aspx" rel="nofollow noreferrer">BackgroundWorker</a>, which allows the coder to...
<p>What was the mainline again?</p> <p>Let me see if I get this right.</p> <p>The background thread fires an event the GUI can intercept to know the data is ready. </p> <p>Is that correct?</p> <p>You may use SwingUtilities.invokeLater( Runnable r );</p> <p>It inserts that runnable instance in the AWT event dispatc...
<p>Not exactly sure if this will help , but looking at the <a href="http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html" rel="nofollow noreferrer">SwingWorker</a> from Java 6 (which is new and different from the previous releases), and the Java Tutorials on the matter, it may offer something similar to w...
44,996
<p>Does anyone has sources for visual explanations of algorithms (or maths) that is even more expressive, more intuitive, maybe aesthetically appealing ? Or, animations of algorithms?</p>
<p>To start the discussion.</p> <p>I like the <strong><a href="http://www.codeproject.com/KB/database/Deadlocks4Dummy.aspx" rel="nofollow noreferrer">database / transaction deadlock</a></strong> illustrated to a non-technical person.</p> <p>You have also a lot of good animations on the <strong><a href="http://www.ans...
<p>Do a google search for [insert name of algorithm] and 'applet'. Many academics and other such people have made java applets to demonstrate algorithms working. You can probably find an example for just about any published algorithm.</p>
41,919
<p>The more we use RAII in C++, the more we find ourselves with destructors that do non-trivial deallocation. Now, deallocation (finalization, however you want to call it) can fail, in which case exceptions are really the only way to let anybody upstairs know of our deallocation problem. But then again, throwing-destru...
<p>You <b>SHOULD NOT</b> throw an exception out of a destructor.</p> <p>Note: Updated to refeclt changes in the standard:</p> <p>In C++03<br> If an exception is already propagating then the application will terminate.</p> <p>In C++11<br> If the destructor is <code>noexcept</code> (the default) then the application w...
<p>You can tell whether there is currently an exception in flight (e.g. we are between the throw and catch block performing stack unwinding, perhaps copying exception objects, or similar) by checking </p> <pre><code>bool std::uncaught_exception() </code></pre> <p>If it returns true, throwing at this point will termin...
19,260
<p>Does anyone know how I can prevent the text in a table cell from wrapping? This is for the header of a table, and the heading is a lot longer than the data under it, but I need it to display on only one line. It is okay if the column is very wide.</p> <p>The HTML of my (simplified) table looks like this:</p> <pr...
<p>Have a look at the <a href="http://www.w3.org/TR/CSS21/text.html#white-space-prop" rel="noreferrer"><code>white-space</code></a> property, used like this:</p> <pre class="lang-css prettyprint-override"><code>th { white-space: nowrap; } </code></pre> <p>This will force the contents of <code>&lt;th&gt;</code> to...
<h3>For Use with React / Material UI</h3> <p>In case you're here wondering how this works for Material UI when building in React, here's how you add this to your <code>&lt;TableHead&gt;</code> Component:</p> <pre><code>&lt;TableHead style={{ whiteSpace: 'nowrap'}}&gt; </code></pre>
38,478
<p>What software is best for the basest of n00bs when it comes to 3D parts creation?</p> <p>I have a heavy math background and know how to create explicit functions of volume, surface area, center of mass, etc. Ideally, I'd like a program that uses those strengths but I realize that most n00bs have a crippling math ph...
<p>I don't have a heavy math background, but enjoy using such skills when applicable.</p> <p>If you've not yet explored <a href="http://www.openscad.org/" rel="nofollow noreferrer">OpenSCAD</a>, you may find that it meets your qualifications. It's more or less a scripting/descriptive language "compiler" that takes ord...
<p>I would add OnShape.com to the list. The only downside of a free account is that your designs are publicly viewable.</p> <p>I would also add support for OpenSCAD. It is my go-to program for difficult problems, especially where being able to script something is far more efficient that dozens of clicks and careful ...
219
<p>This is a followup question of <a href="https://stackoverflow.com/questions/156697/how-to-encode-characters-from-oracle-to-xml">How to encode characters from Oracle to Xml?</a></p> <p>In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xm...
<p>It is getting escaped because the handler.characters function is designed to escape and the <code>&lt;![CDATA[</code> part isn't considered part of the value.</p> <p>You need to use the newly exposed methods in <code>DefaultHandler2</code> or use the <code>TransformerHandler</code> approach where you can set the ou...
<p>You should use <code>startCDATA()</code> and <code>endCData()</code> as delimiters, i.e.</p> <pre><code>xmlHandler.startElement(uri, lname, "column", attributes); xmlHandler.startCDATA(); String chars = rs.getString(i); xmlHandler.characters(chars.toCharArray(), 0, chars.length()); xmlHandler.endCDATA(); xmlHandler...
18,971
<p>I am building an application where I want to be able to click a rectangle represented by a DIV, and then use the keyboard to move that DIV by listing for keyboard events.</p> <p>Rather than using an event listener for those keyboard events at the document level, can I listen for keyboard events at the DIV level, pe...
<p>Sorted - I added tabindex attribute to the target DIV, which causes it to pick up keyboard events, for example</p> <pre><code>&lt;div id="inner" tabindex="0"&gt; this div can now have focus and receive keyboard events &lt;/div&gt; </code></pre> <p>Information gleaned from <a href="http://www.w3.org/WAI/GL/WCAG...
<p>Paul's answer works fine, but you could also use contentEditable, like this...</p> <pre><code>document.getElementById('inner').contentEditable=true; document.getElementById('inner').focus(); </code></pre> <p>Might be preferable in some cases.</p>
17,878
<p>So, we have <a href="https://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read">coding books</a>, <a href="https://stackoverflow.com/questions/5119/what-are-the-best-rss-feeds-for-programmersdevelopers">coding RSS feeds</a>, and <a href="https://stackoverflow.com/...
<p>The venerable <a href="http://www.ddj.com/" rel="noreferrer">Dr. Dobbs Journal</a> is still pretty good. It covers multiple platforms, and mixes some fairly hard-core technical articles with lighter fare (interviews with notables, a "Developer Diaries" column that profiles regular-Joe (and Jane) developers from a ra...
<p>I like Embedded Systems. Even if you don't program for embedded systems, the software articles are excellent. <a href="http://www.embedded.com/" rel="nofollow noreferrer">http://www.embedded.com/</a></p>
6,157
<p>I want to write a program in which plays an audio file that reads a text. I want to highlite the current syllable that the audiofile plays in green and the rest of the current word in red. What kind of datastructure should I use to store the audio file and the information that tells the program when to switch to th...
<p>This is a slightly left-field suggestion, but have you looked at Karaoke software? It may not be seen as "serious" enough, but it sounds very similar to what you're doing. For example, <a href="http://www.aegisub.net/" rel="nofollow noreferrer">Aegisub</a> is a subtitling program that lets you create subtitles in th...
<p>you might want to get familiar with FreeTTS -- this open source tool : <a href="http://freetts.sourceforge.net/docs/index.php" rel="nofollow noreferrer">http://freetts.sourceforge.net/docs/index.php</a> -</p> <p>You might want to feed only a few words to the TTS engine at a given point of time -- highlight them and...
20,747
<p>When designing a new system or getting your head around someone else's code, what are some tell tale signs that something has gone wrong in the design phase? Are there clues to look for on class diagrams and inheritance hierarchies or even in the code itself that just scream for a design overhaul, particularly early...
<p>The things that mostly stick out for me are "<a href="http://www.soberit.hut.fi/mmantyla/BadCodeSmellsTaxonomy.htm" rel="noreferrer">code smells</a>". </p> <p>Mostly I'm sensitive to things that go against "good practice".</p> <p>Things like:</p> <ul> <li><p>Methods that do things other than what you'd think from...
<p>Having all you objects inherit some base utility class just so you can call your utility methods without having to type so much code.</p>
44,978
<p>I want to display from cache for a long time and I want a slightly different behavior on page render vs loading the page from cache. Is there an easy way I can determine this with JavaScript?</p>
<p>One way you could do it is to include the time the page was generated in the page and then use some javascript to compare the local time to the time the page was generated. If the time is different by a threshold then the page has come from a cache. The problem with that is if the client machine has its time set i...
<p>Not directly, some browsers may have some custom command for it.</p> <p>There is a workaround that would do what you want. Use a cookie to store <code>timestamp</code> of the first visit and then use the META HTTP-EQUIV to set the length of time the file is cached (<code>cacheLength</code>). If the current time i...
32,495
<p>I have an application that is made up of the following:</p> <p>A central database containing 100k+ records A number of "client" databases each containing around 10-20k records</p> <p>The client databases contain details of contacts that each have a unique ID (contactID).<BR> The central database contains some of t...
<p>I would not go through each record in the scenario you describe. Web services are fine but you could as easily use them for bulk updates.</p> <p>From the top of my head, something like this would work a little better:</p> <ol> <li>Get a '<em>diff</em>' containing all the changes in the master database. This could ...
<p>You can ask for a file (XML) containing all the ID details from the central DB and you can get it converted in to some object mappings. Then having object list at your end you can compare and update accordingly.</p>
24,966
<p>Running ipconfig /all shows a Teredo Tunneling Pseudo-Interface. What is that? Does this have something to do with IPv4 vs IPv6? Should I get rid of it? If so how?</p>
<p>Is to do with IPv6 </p> <p>All the gory details here: <a href="http://www.microsoft.com/technet/network/ipv6/teredo.mspx" rel="noreferrer">http://www.microsoft.com/technet/network/ipv6/teredo.mspx</a> </p> <p>Some people have had issues with it, and disabled it, but as a general rule, if it aint broke...</p>
<p>Unless you have some kind of really weird problem, keep it. The number of IPv6 sites is very small, but there are some and it will let you get to them even if you're at an IPv4 only location.</p> <p>If it is causing you a problem, it's best to fix it. I've seen a number of people recommending removing it to solve...
41,791
<p>I often need to design a dialog in Delphi/C++Builder that allows various properties of an object to be modified, and the code to use it typically looks like this.</p> <pre><code>Dialog.Edit1.Text := MyObject.Username; Dialog.Edit2.Text := MyObject.Password; // ... many more of the same if (Dialog.ShowModal = mrOk)...
<p>well, something that I feel completely invaluable is the <a href="http://www.gexperts.org" rel="nofollow noreferrer">GExperts</a> plugin wizard "Reverse Statement" which is invoked after installing GExperts by pressing Shift + ALT + R</p> <p>What it does is automatically switch the assignments around for the highli...
<p>Delphi at least have 'With', though it doesn't solve the problem completely.</p> <pre><code>if (Dialog.ShowModal = mrOk) begin with MyObject do begin Username := Dialog.Edit1.Text; Password := Dialog.Edit2.Text; // ... again, many more of the same end; end; </code></pre> <p>And builder AFAIK has...
23,258
<p>I have a custom control that exposes a property. When I set it using a fixed value, everything works correctly. But if I try to set its value using the &lt;%= %> tags, it goes a little whacky:</p> <pre><code>&lt;cc:CustomControl ID="CustomControl" runat="server" Property1='&lt;%= MyProperty %&gt;' /&gt; &lt;%= My...
<p>You control is initialized from the markup during <code>OnInit</code>. So if that syntax worked, it wouldn't have the effect you wanted anyway, since <code>MyProperty</code> would be evaluated during <code>OnInit</code> and not at render time (like it is with the second usage).</p> <p>You want to use the data bind...
<p>Try &lt;%# MyProperty %> in the CustomControl and see if that works.</p>
28,000
<p>I like to have my code warning free for VS.NET and GCC, and I like to have my code 64-bit ready.</p> <p>Today I wrote a little module that deals with in memory buffers and provides access to the data via a file-style interface (e.g. you can read bytes, write bytes, seek around etc.).</p> <p>As the data-type for cu...
<p>Regarding the whether <code>size</code>_t is signed or unsigned and GCC (from an old GCC manual - I'm not sure if it's still there):</p> <blockquote> <p>There is a potential problem with the <code>size_t</code> type and versions of GCC prior to release 2.4. ANSI C requires that <code>size_t</code> always be...
<p>I am not sure if I understand the question exactly, but maybe you can do something like:</p> <pre><code>temp = value_to_be_added_to; value_to_be_added_to += value_to_add; if (temp &gt; value_to_be_added_to) { overflow... } </code></pre> <p>Since it will wrap back to lower values you can easily check if it over...
25,286
<p>I have to deploy my ASP.NET application into two seperated IIS servers. My application works over HTTPS/TLS. My ASP code has to handle client SSL certificate and it means I can't use simple forward load balancers, because I will never get such certificate from nginx or Apache Load Balancer.</p> <p>As I understand t...
<p>Windows NLB is definitely your solution - it sits in the network stack on each of your IIS servers and distributes TCP requests among the member servers. NLB works with SSL traffic, since it distributes via TCP Ports, not the contents of the traffic.</p> <p>You will need to install the same SSL certs on each serve...
<p>DNS based load balancing should take you a long way. <a href="http://content.websitegear.com/article/load_balance_dns.htm" rel="nofollow noreferrer">Click here</a> for an article on the subject. For an overview of load balancing in the IIS/ASP world, <a href="http://www.microsoft.com/technet/archive/itsolutions/ecom...
16,052
<p>I am currently developing an approval routing WCF service that will allow an user to create "rules" which determine how an request is routed. The route is determined by comparing the "ObjectToEvaluate" property of the Request class against the "ObjectToEvaluate" property of the "Rule" class. The "UnitOfMeasurement...
<p>Use an implicit type operator that checks the value of the enum. That way callers can transparently assign the objects to the types you want to represent them. Eg:</p> <pre><code>public class CastableObject { private UnitOfMeasurement eUnit; // Assign this somehow public static implicit operator int(Casta...
<p>Where are you getting the unit of measurement from? I can see the enum, but I don't see any reference to it elsewhere in the API.</p> <p>Assuming you do get it from somewhere, the easiest solution may well be a switch statement. It's a bit ugly, but:</p> <ul> <li>It'll work</li> <li>It's easy to understand</li> <l...
25,691
<p>Does having several levels of base classes slow down a class? A derives B derives C derives D derives F derives G, ...</p> <p>Does multiple inheritance slow down a class?</p>
<p>Non-virtual function-calls have absolutely no performance hit at run-time, in accordance with the c++ mantra that you shouldn't pay for what you don't use. In a virtual function call, you generally pay for an extra pointer lookup, no matter how many levels of inheritance, or number of base classes you have. Of cours...
<p>Yes, if you're referencing it like this:</p> <pre><code>// F is-a E, // E is-a D and so on A* aObject = new F(); aObject-&gt;CallAVirtual(); </code></pre> <p>Then you're working with a pointer to an A type object. Given you're calling a function that is virtual, it has to look up the function table (vtable) to g...
12,471
<p>I need to make a change to an ASP.NET web service written a couple years ago on 2.0. I call this web service from an old 1.1 web site. I need to make some changes to the web service, so am thinking, should I rewrite this into a WCF service and if so, will I still be able to use it from my 1.1 web site?</p>
<p>Yes this will work. Your service will need to be at least .net 3.0, but as long as you use a basicHttpBinding or wsHttpBinding, you can consume it like any other webservice.</p>
<p>yes you can... make sure to choose the correct bindings and authentication methods</p>
22,062
<p>I have a Wanhao Duplicator i3.</p> <p>I have done many excellent prints with this printer, and have first hand experience that it can do a pretty much flawless print.</p> <p>But... Recently, I am experiencing weird results. My "flow" seems uneven. When laying down the first layer of the raft, I can see it looks li...
<p>Write a few pieces of gcode to do this. Place it on an SD-card (I assume you have a reader) and select the file you want to execute.</p> <p>Home all:</p> <pre><code>G28 G1 Z0 </code></pre> <p>Do you really want to home it directly? I would say you want to take it down slowly and adjusting end-stops incrementally....
<p>The way I manually level my bed is by connecting a computer to the printer via USB. As far as I am aware, if you have a touchscreen this should be available on the printer options as well for marlin.</p> <p>But if you connect a computer, simply run something like pronterface or any other manual control gui and:</p>...
533
<p>So I've been thinking of going for Microsoft certification and I have to make a choice (for now) between Windows Forms and WPF for developing Windows applications. I have had good exposure to Windows Forms but never tried WPF before. Furthermore, most of the job postings where I live seem to be WinForms-oriented. Th...
<p>In "enterprise" programming, I don't see an immediate need for WPF development. The reasons for this:</p> <ol> <li>Companies are not running on the newest hardware, and tend to migrate to remote desktops (RDP/Citrix).</li> <li>A developer can design a decent interface using Windows.Forms controls. In WPF, you need ...
<p>WPF leverages XAML for the design/visual experience this is the same technology that Silverlight uses and in the future will be leveraged heavily by other aspects of .NET 4.0, specifically, WCF (web services) and WF (workflow).</p> <p>I would highly recommend learning it if you have the cycles, however for certific...
20,899
<p>Does anyone know of a web based IDE (Like VS, Eclipse, IDEA)?</p> <p>Besides <a href="http://ecco.sourceforge.net/" rel="noreferrer">ECCO</a>?</p>
<p><a href="http://shiftedit.net/" rel="noreferrer">ShiftEdit Web Based IDE</a></p>
<p>Try <a href="http://phpanywhere.net" rel="nofollow noreferrer">PHPAnywhere.net</a></p>
6,217
<p>I have a bunch of questions to post regarding the issue of separating the view from logic when creating a GUI.<br> The following is a minimal example of what I would do for a simple dialog that has a label and a button using the "Humble Dialog" approach. Pressing the button should show some text on the label. I have...
<p>When you do multiple inheritance with QObjects, the first class in the inheritance list needs to be the QObject-derived class. This is only strictly required if you plan to add signals and slots to your class, but is good practice anyway. So your class declaration:</p> <p>class MyView : public IView , public QDialo...
<p>I usually use the same pattern for my UI in C# Winforms stuff.</p> <p>You're actually not really doing multiple inheritance here. One of the classes you're inheriting from is just an empty interface. The only problem here is that C++ doesn't know the difference between a class and an interface.</p> <p>I don't thi...
29,629
<p>Continuing from my <a href="https://stackoverflow.com/questions/90751/double-and-floats-in-c">previous question</a>, is there a comprehensive document that lists all available differences between debug and release modes in a C# application, and particularly in a web application?</p> <p>What differences are there?</...
<p>"Debug" and "Release" are just names for predefined project configurations defined by Visual Studio.<br> To see the differences, look at the Build Tab in Project Properties in Visual Studio.</p> <p>The differences in VS2005 include:</p> <ul> <li><p>DEBUG constant defined in Debug configuration</p></li> <li><p>Opti...
<p>I got an error message when I distribute executable file to another machine indicating that the system missed MSVCP110D.dll.</p> <p>The solution to this issue is stated in Stack Overflow question <em><a href="https://stackoverflow.com/questions/10926790">Visual Studio MSVCP110D.dll is missing</a></em>.</p> <p>IN X...
11,618
<p>I bought an Ender 3 V2 printer and printed successfully with PLA and PLA+. Ender 3 V2 is rated at &lt;= 250 °C but when I set temperature above 200 °C to print to PLA+, I get an error message &quot;Nozzle is too lowperature&quot; and the printer freezes (the term lowperature is actual and not a typo error).</p> <p>I...
<p>This sounds like a bad thermistor. Try replacing the head thermistor, see if this fixes it.</p> <p>As for the strange error message, it looks like the word Temperature is being drawn on the wrong line, and then &quot;is too low&quot; writes over it.</p> <p>See the way the word lines up below:</p> <pre><code>nozzle t...
<p>The problem was solved after the supplier replaced the motherboard. However after that I had to try various versions of firmware as different ones had different behavior to the printer. If you face a similar situation be aware of the cabling and connections when changing the motherboard. You may have to do the plugi...
2,035
<p>I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase...
<p>You need to take some parts into mind here,</p> <ol> <li>What will you gain from re-writing</li> <li>Is it an economically wise decision</li> <li>Will the code be easier to handle for new programmers</li> <li>Performance-wise, will this be a good option?</li> </ol> <p>These four points is something that is importa...
<p>Other issues include how business critical are the applications and how hard will it be to find maintainers. If the pages are hobbies of yours then I don't see a reason why you shouldn't rewrite them since if you introduce bugs or the rewrite doesn't go according to schedule a business won't lose money. If the appli...
44,214
<p>for example, I have the following xml document:</p> <pre><code>def CAR_RECORDS = ''' &lt;records&gt; &lt;car name='HSV Maloo' make='Holden' year='2006'/&gt; &lt;car name='P50' make='Peel' year='1962'/&gt; &lt;car name='Royale' make='Bugatti' year='1931'/&gt; &lt;/records&gt; ''' </code></p...
<p>I went down a similar route to danb, but ran into problems when actually printing out the resulting XML. Then I realized that the NodeList that was returned by asking the root for all of it's "car" children isn't the same list as you get by just asking for the root's children. Even though they happen to be the sam...
<p>&lt;hand-wave> <em>these are not the codz you seek</em> &lt;/hand-wave></p> <pre><code>Node root = new XmlParser().parseText(CAR_RECORDS) NodeList carNodes = root.car Node royale = carNodes[2] carNodes.remove(royale) carNodes.add(0, royale) carNodes.add(2, new Node(root, 'car', [name:'My New Card', make:'Peel', yea...
27,800
<p>I was asked to improve and maintain an internal Web application used and approved by an important community of users. This includes performance improvements and adding features.</p> <p>Unfortunately, the code is bloated, sometimes very poorly written, and hard to read and change. This makes changes much more diffic...
<p>This will happen to most programmers. The first urge is to rewrite it. The better approach is to just do what you are being asked to do. If you go into major rewrites you are very likely to break it. </p> <p>If the changes required are simple you should implement them with as few changes as a possible, in the s...
<p>Make sure your management and users know that the code has insufficient quality from the changeability point of view. When estimating how much time you need to implement new features, always make explicit how much time you need to clean up the affected code.</p>
35,949
<p>I made a few successful prints since I got my CR-10 two weeks ago and I didn't run into any major trouble. The printer is new.</p> <p>Today I set it to "preheat" mode while I was preparing the SD card with the settings being 210°C for the nozzle and 60°C for the bed. When I wanted to start the print I noticed that ...
<p>This is not an easy one to solve, the firmware of the printer should be keeping the printer at a certain temperature depending on the temperature setting and the current value. If the firmware is not able to keep the temperature at the requested level, but goes beyond that level, that could be considered "strange". ...
<p>A similar condition occurred in my 3D printer. I solved the same. I checked all my connection and I came to know that I connected the thermistor of the extruder in the wrong port. So just check the connection of your thermistor.</p> <hr> <p>Actually my 3D printer circuit board frequently failed because of over cur...
968
<p>I have followed the instructions to setup rxtx on windows from <a href="http://www.jcontrol.org/download/readme_rxtx_en.html" rel="nofollow noreferrer">http://www.jcontrol.org/download/readme_rxtx_en.html</a>.</p> <p>What I did exactly was copy rxtxSerial.dll to "C:\Program Files\Java\jdk1.6.0_07\jre\bin" and copie...
<p>Try putting <code>rxtxSerial.dll</code> in</p> <pre><code>C:\Program Files\Java\jdk1.6.0_07\jre\lib\bin ^^^ </code></pre>
<p>@Pinheiro you might want to take a look at <a href="http://rxtx.qbang.org/wiki/index.php/Trouble_shooting#How_does_rxtx_detect_ports.3F__Can_I_override_it.3F" rel="nofollow">this</a></p>
34,541
<p>I have a table on SQL2000 with a numeric column and I need the select to return a 01, 02, 03...</p> <p>It currently returns 1,2,3,...10,11...</p> <p>Thanks.</p>
<p>Does this work?</p> <pre><code>SELECT REPLACE(STR(mycolumn, 2), ' ', '0') </code></pre> <p>From <a href="http://foxtricks.blogspot.com/2007/07/zero-padding-numeric-value-in-transact.html" rel="noreferrer">http://foxtricks.blogspot.com/2007/07/zero-padding-numeric-value-in-transact.html</a></p>
<p>John's answer works and is generalizable to any number of digits, but I would be more comfortable with</p> <pre><code>select case when mycolumn between -9 and 9 then '0' + str(mycolumn) else str(mycolumn) end </code></pre>
20,364
<p>I haven't installed Visual Studio before on my computer. However when I try to install Visual Studio 2008 Express SP1 I get an error message</p> <p>"Setup has detected that this computer does not meet the requirements to install this software. These requirements must be met before you can install Microsoft Visual C...
<p>please use the following url instruction help ....and get solution within mins...i had the same issue and resolved it in mins</p> <p><a href="http://www.openspan.com/Community/index.php/component/kb/article/why_do_i_get_an_error_installing_the_microsoft_visual_studio_2008_sp1_isolated_shell.html" rel="noreferrer">h...
<p>Maybe there is a registry entry that was placed by the program or something else. Run a registry cleaner (after backing the registry up) and try again.</p>
23,708
<p>Is it possible to use PHP's SimpleXML functions to create an XML object from scratch? Looking through the function list, there's ways to import an existing XML string into an object that you can then manipulate, but if I just want to generate an XML object programmatically from scratch, what's the best way to do th...
<p>Sure you can. Eg.</p> <pre><code>&lt;?php $newsXML = new SimpleXMLElement("&lt;news&gt;&lt;/news&gt;"); $newsXML-&gt;addAttribute('newsPagePrefix', 'value goes here'); $newsIntro = $newsXML-&gt;addChild('content'); $newsIntro-&gt;addAttribute('type', 'latest'); Header('Content-type: text/xml'); echo $newsXML-&gt;a...
<p>Please see my answer <a href="https://stackoverflow.com/questions/139650/when-writing-xml-is-it-better-to-hand-write-it-or-to-use-a-generator-such-as-si#140203">here</a>. As <a href="https://stackoverflow.com/users/15487/dreamwerxmyopenidcom">dreamwerx.myopenid.com</a> points out, it is possible to do this with <a h...
17,287
<p>What is the purpose of the <code>Using</code> block in C#? How is it different from a local variable?</p>
<p>If the type implements IDisposable, it automatically disposes that type.</p> <p>Given:</p> <pre><code>public class SomeDisposableType : IDisposable { ...implmentation details... } </code></pre> <p>These are equivalent:</p> <pre><code>SomeDisposableType t = new SomeDisposableType(); try { OperateOnType(t); } f...
<p>It is really just some syntatic sugar that does not require you to explicity call Dispose on members that implement IDisposable.</p>
26,077
<p>I've made an expose-clone for Vista that sometimes need to restore a minimized window. I've managed to do this with the SetWindowPlacement function. The problem is that this also repaints the window which looks like crap after the window nicely has slided into the screen.</p> <p>This is the code i use to bring a wi...
<p>One way to do it is to use double-buffering technique: paint to an off-screen bitmap, then restore, then blit the bitmap to the screen. But it seems like overkill if restoring a minimized window is the only scenario where it's needed. Maybe others will have better ideas?..</p> <p>Also, if you paint entire window cl...
<p>I'm OP...accidentaly ate my cookie.</p> <p>Studied how windows flip3d and the taskbar manages this a bit closer and they actually repaint the window <strong>before</strong> they start the animation of the thumb. Try to minimize a window and then restore it with flip3d, you will see a small blink on the 3d-window be...
45,589
<p>We have a pretty mature COM dll, which we test using DUnit. One of our recent tests creates a few threads, and tests the object from those threads. This test works fine when running the test using the gui front-end, but hangs when running as a console application. Here's a quick pseudo view of what we have in the te...
<p>You need to provide more data.</p> <p>Note that <code>OnTerminate</code> is called via <code>Synchronize()</code>, which requires a call to <code>CheckSynchronize()</code> at some point somewhere. <code>Application.ProcessMessages()</code> normally does this, but depending on how the VCL has been initialized, it's p...
<p>As Barry rightly pointed out, unless <code>CheckSyncronize()</code> is called, <code>Synchronize()</code> is not processed, and if <code>Synchronize()</code> is not processed, then the <code>OnTerminate</code> event is not fired.</p> <p>What seems to be happening is that when I run my unit tests as a Console applica...
34,377
<p>So I have a form that uses infopath services via sharepoint, and after multiple attempts at attempting to fix a rendering problem (tables appear WAY too wide to be readable), I think I have found the problem : date controls.</p> <p>It seems date controls within Infopath 2007 screw with rendering somehow. To test, ...
<p>I've been using caching decorators (not interceptors) with Windsor and they work great.</p> <p>Interceptors are good for this as well, see <a href="http://ayende.com/Blog/archive/2007/03/11/AOP-With-Windsor-Adding-Caching-to-IRepositoryT-based-on-Ts.aspx" rel="nofollow noreferrer">this</a> for example.</p>
<p>Windsor is great, but why use that for caching when you have several built in ways to cache data. Windsor has its foundation in other areas not necessarily caching. From the cache object to session to cookies. There are many ways to cache. More importantly in large applications you end up needing distributed caching...
12,004
<p>I have a <strong>RichTextBox</strong> control on my form. I also have this button, labeled <strong>Bold</strong>, that I want, if someone selects text in the <strong>RichTextBox</strong>, then presses the button, <strong>the selected text turns bold.</strong> Any way to do that? Simple, everyday task for end users. ...
<p>Use limit in SQL! Every time!</p> <p>Otherwise you're throwing around considerably more data than you need to, which makes your scripts unnecessarily slow, and will lead to scalability problems as the amount of data in your tables increases.</p> <p>Limit is your friend!</p>
<p>Personally, I would use the query to do it. Obviously, that can change if your dealing with AJAX and such, but just doing a basic limit in the query and outputting the results is simple and efficient.</p>
13,430
<p>Below are two ways of reading in the commandline parameters. The first is the way that I'm accustom to seeing using the parameter in the main. The second I stumbled on when reviewing code. I noticed that the second assigns the first item in the array to the path and application but the first skips this. </p> <p...
<p>Second way is better because it can be used outside the main(), so when you refactor it's one less thing to think about.</p> <p>Also I don't like the "magic" that puts the args in the method parameter for the first way.</p>
<p>The first way is better because it's simpler.</p>
10,845
<p>Some text before the code so that the question summary isn't mangled.</p> <pre><code>class Tree { public event EventHandler MadeSound; public void Fall() { MadeSound(this, new EventArgs()); } static void Main(string[] args) { Tree oaky = new Tree(); oaky.Fall(); } } </code></pr...
<p>Well, the canonical form is:</p> <pre><code>void OnMadeSound() { if (MadeSound != null) { MadeSound(this, new EventArgs()); } } public void Fall() { OnMadeSound(); } </code></pre> <p>which is <em>very slightly</em> faster that calling an empty delegate, so speed won out over programming conve...
<p>Thank you for the responses. I do understand why the NullReferenceException happens and how to get around it.</p> <blockquote> <p><strong>Gishu said</strong></p> <p>What is the point of raising an event if no one is listening?</p> </blockquote> <p>Well, maybe it's a terminology thing. The appeal of an &quot;event&qu...
25,699
<p><img src="https://cdn.shopify.com/s/files/1/0046/3781/8929/files/CR-10-Max-_2.gif" alt="Sensor" /></p> <p><a href="https://i.stack.imgur.com/9fDW1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9fDW1.jpg" alt="enter image description here" /></a> I'm just finishing the set-up of a CR-10 Max. It i...
<p>I've designed similar sensor casings, sometimes the filament catches a ridge/ledge or part of the cavity, even when it is chamfered or rounded. The arm of the limit switch pushes the filament up, away from the filament straight path.</p> <p>Have you tried cutting the filament under a very sharp angle, that may work....
<p>Here is 3D model that better explains why it was catching and how to remedy the problem:</p> <p><a href="https://i.stack.imgur.com/ooe48.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ooe48.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/dTy92.png" rel="no...
1,704
<p>I've build a 3D printer from sourced parts and mounted the hotend cooler to blow air over the heatsink. </p> <p>Talking to a friend, he said it's better to reverse the airflow over the heatsink, but couldn't give me an argument other than everywhere he saw it was like this: all coolers are mount to suck the hot air...
<p>Getting hot air from the radiator is definitely wrong idea because of few reasons:</p> <ol> <li>hot air can damage your fan (as they are usually not heatproof). Cold air cools the fan</li> <li>cold air is denser so fan can suck more cold air than hot air so cooling is more efficient (fig A)</li> <li>in terms of plu...
<p>In the case of 3D Printing, it's going to be faster to cool the radiator by blowing out the heat from the source.</p> <p>The idea is that you're trying to get rid of as much heat as possible in the quickest means possible. By blowing away from the radiator, you're allowing the ambient temperature to cool the hot ai...
481
<p>I understand the difference between <code>String</code> and <code>StringBuilder</code> (<code>StringBuilder</code> being mutable) but is there a large performance difference between the two? </p> <p>The program I’m working on has a lot of case driven string appends (500+). Is using <code>StringBuilder</code> a bett...
<p>Yes, the performance difference is significant. See the KB article "<a href="http://support.microsoft.com/kb/306822" rel="noreferrer">How to improve string concatenation performance in Visual C#</a>".</p> <p>I have always tried to code for clarity first, and then optimize for performance later. That's much easier...
<p>StringBuilder will perform better, from a memory stand point. As for processing, the difference in time of execution may be negligible.</p>
9,955
<p>I need to convert several Java classes to C#, but I have faced few problems.</p> <p>In Java I have following class hierarchy:</p> <pre><code>public abstract class AbstractObject { public String getId() { return id; } } public class ConcreteObject extends AbstractObject { public void setId(Str...
<p>I would suggest using method calls as you've already outlined to make sure that the usage of the class is clear to the caller. If you're set on implementing it using properties, then you could do the following (some documentation for the new keyword can be found <a href="http://msdn.microsoft.com/en-us/library/6fawt...
<p>When you supply only the <code>get</code> portion of a property in .Net, you are explicitly telling the compiler that this property is read-only. It's a bigger deal than just not providing a <code>set</code>. This is evident in the vb version of the property syntax, where you must also explicitly declare the prope...
35,612
<p>How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)?</p> <p>This is how far I got by now:</p> <p>Script receives image via HTML Form Post and is processed by the following code</p> <pre><code>... incomming_image = self.request.get("img") image = db.Blob(incomming_image) ....
<p>If you need more than looking at extension, one way would be to read the JPEG header, and check that it matches valid data. The format for this is:</p> <pre><code>Start Marker | JFIF Marker | Header Length | Identifier 0xff, 0xd8 | 0xff, 0xe0 | 2-bytes | "JFIF\0" </code></pre> <p>so a quick recogniser ...
<p>Use <a href="http://www.pythonware.com/products/pil/" rel="nofollow noreferrer">PIL</a>. If it can open the file, it's an image.</p> <p>From the tutorial...</p> <pre><code>&gt;&gt;&gt; import Image &gt;&gt;&gt; im = Image.open("lena.ppm") &gt;&gt;&gt; print im.format, im.size, im.mode </code></pre>
33,428