instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>My website will be using only OpenID for authentication. I'd like to pull user details down via attribute exchange, but attribute exchange seems to have caused a lot of grief for StackOverflow.</p> <p>What is the current state of play in the industry? Does any OpenID provider do a decent job of attribute exchange...
<p>Here on Stack Overflow, we're just using the <a href="http://openid.net/specs/openid-simple-registration-extension-1_0.html" rel="noreferrer">Simple Registration</a> extension for now, as there were some issues with Attribute Exchange (AX).</p> <p>The biggest was OpenID Providers (OP) not agreeing on which <a href=...
<p>While Attribute Exchange has it's problems (I'm sure someone from SO can tell you more), it does have <a href="http://blogs.gnome.org/jamesh/2007/11/26/openid-ax/" rel="nofollow noreferrer">a lot of benefits</a>. To some extent it depends on whether you really need it or not. Simple Registration seems to do that job...
3,301
<p>I want to load up a window using the java swing, something like <a href="http://www.java2s.com/Code/Java/Swing-JFC/ShowlinestartendoffsetsinaJTextArea.htm" rel="nofollow noreferrer">this</a></p> <p>However I want to be able to use it for text input also not just to dump data into it..</p> <p>any idea how to do it?...
<p>JTextAreas are editable by default, so input is trivial. Just put one into a test UI and see for yourself.</p> <p>From a design perspective, using the same JTextArea for both input and output strikes me as unwise. The only example I can think of is a shell interface, and that imposes stronger limits on how input ...
<p>I'm not sure if I got the point of your question, but you can get the text the user has typed in using the getText() method: </p> <p>JTextArea ta = new JTextArea(); String input = ta.getText();</p>
29,036
<p>I'm trying to wrap my head around the roles of UIViews and UIViewControllers. If I'm creating and inserting subviews programmatically, is it typical to do this from the view or the controller?</p> <p>I'm really just wondering if there's a convention/pattern for this. In my sample application, I'm loading 50 image...
<p>It depends on what you're doing. If the view represents something "packaged", then you create subviews from the view itself. If you're merely aggregating views together, then you should do it from the view controller.</p> <p>Think about traditional encapsulation. Is your subview conceptually "part" of its superview...
<p>Dummy explanation would be like this:</p> <p>Subclass UIViewController whenever you plan to display the view as modal (presentModalViewController) or inside UINavigationController (pushViewController)</p> <p>Subclass UIView whenever it is a small component inside main view... for example you wish to do custom butt...
35,397
<p>I'm using MVC to validate some html text boxes on a page, for example in my controller there is</p> <pre><code> if (String.IsNullOrEmpty(name)) { ModelState.AddModelError("name", "You must specify a name."); } if (ViewData.ModelState.IsValid) { return...
<p>Take the code you have for initializing the ViewData in the (GET) Add action, and refactor it (extract method) into a standalone, private method. Call that method from your (GET) Add action. Now in the POST action (which is, I presume, what you're showing above; it isn't clear) you can call the same, private method...
<p>I must admit, I have some confusion following exactly what you mean, so this is sort of a generic answer that might not be exact!</p> <p><a href="http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form-posting-scenarios.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/...
41,453
<p>I'm new to .Net and I'm trying to understand the basics first. What is the difference between MSIL and Java bytecode?</p>
<p>First off let me say that I don't think that the subtle differences between Java bytecode and MSIL is something that should bother a novice .NET developer. They both serve the same purpose of defining an abstract target machine which is a layer above the physical machine being used in the end.</p> <p>MSIL and Java b...
<p>Agreed, the differences are minute enough to ingore as a beginner. If you want to learn .Net starting from the basics, I'd recommend looking at the Common Language Infrastructure, and the Common Type System.</p>
12,078
<p>I remember back in the day with the old borland DOS compiler you could do something like this:</p> <pre><code>asm { mov ax,ex etc etc... } </code></pre> <p>Is there a semi-platform independent way to do this now? I have a need to make a BIOS call, so if there was a way to do this without asm code, that would be ...
<p>Using <a href="http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html" rel="noreferrer">GCC</a></p> <pre><code>__asm__("movl %edx, %eax\n\t" "addl $2, %eax\n\t"); </code></pre> <p>Using <a href="http://msdn.microsoft.com/en-us/library/4ks26t93(VS.71).aspx" rel="noreferrer">VC++</a></p> <pre><code...
<p>use of <code>asm</code> or <code>__asm__</code> function ( in compilers have difference )</p> <p>also you can write fortran codes with <code>fortran</code> function</p> <pre><code>asm(&quot;syscall&quot;); fortran(&quot;Print *,&quot;J&quot;); </code></pre>
8,650
<p>I've been <a href="https://stackoverflow.com/questions/279557/how-do-i-keep-the-wpf-gridsplitter-from-changing-the-size-of-my-grid">struggling with the GridSplitter</a>. It seems to be incompatible with the WPF WebBrowser control.</p> <p>If I resize my window and move the GridSplitter, then I can make my grid wide...
<p>I was able to reproduce this with a Border in a ScrollViewer (but not without a ScrollViewer), so my guess is that the scrolling messes it up somehow.</p> <p>Setting a MaxWidth on the left column (a very large MaxWidth that should have no practical effect) seemed to fix it:</p> <pre><code>&lt;Window xmlns="http://...
<p>I know you're probably sick of hearing this, but I can't reproduce your problem when I use the XAML above, slightly modified to be pure XAML:</p> <pre>( XAML code moved into question. )</pre> <p>Could there be something in your code-behind that is causing the behavior?</p>
49,180
<p>I've got about 200k images in a bucket. They all have expires headers of 2050 but I've read you shouldn't send an expires header older than a year. I want to schedule a script to run every month and set the headers to 6 months away. Anything out there? Obviously I'd like to avoid iterating 200k objects.</p>
<p><em>Disclaimer:</em> I am the developer of this tool, but I think it may answer your question.</p> <p><a href="http://cloudberrylab.com" rel="nofollow noreferrer">CloudBerry Explore</a>r freeware will be able to do it in the next release. </p>
<p>S3 doesn't appear to support bulk updates, as its API's contain no such operations. Some third-party tools claim bulk update capability; however, I wager that they merely automate iteration.</p>
38,348
<p>When I open a solution in VS 2008, I don't want it to open all the files that I had open last time. I just want it to open the solution. Can't see a config option for this, is it possible?</p>
<p>Delete the .suo file...</p> <p>See <a href="https://stackoverflow.com/questions/148143/is-there-anyway-to-tell-visual-studio-not-to-open-all-the-documents-when-i-load">Is there anyway to tell Visual Studio not to open all the documents when I load solution?</a></p>
<p>You can automate the process of closing all the files prior to closing a solution by adding a handler for the BeforeClosing event of EnvDTE.SolutionEvents -- this will get invoked when VS is exiting.</p> <p>In VS2005, adding the following to the EnvironmentEvents macro module will close all open documents:</p> <pr...
20,997
<p>What good components and packages are available for generating HTML reports based on report definitions? I have a truly horrific project where each report is a dedicated aspx page that builds one fantastically big HTML string, which it then assigns to a 'reportBody' Label control.</p> <p>Standard grids are not a g...
<p>You can try <a href="http://www.datadynamics.com/Products/ProductOverview.aspx?Product=ARNET3" rel="nofollow noreferrer">ActiveReports.net</a></p>
<blockquote> <p>Standard grids are not a good solution as they provide no grouping capability</p> </blockquote> <p>If you want to create your own, I can give you some advice. First, you could probably create the groups with ROLLUP or COMPUTE statements or similar in your SQL and use a grid.</p> <p>I went the fol...
25,632
<p>I use the following statement prepared and bound in ODBC:</p> <pre><code>SELECT (CASE profile WHEN ? THEN 1 ELSE 2 END) AS profile_order FROM engine_properties; </code></pre> <p>Executed in an ODBC 3.0 connection to an Oracle 10g database in AL32UTF8 charset, even after binding to a wchar_t string using <code>SQL...
<p>Rough algorithm:</p> <pre><code>Define a stack Define an array LOOP on each character in the string IF the top item of the stack is a single or double quote THEN LOOP through each character until you find a matching single or double quote, then pop it from the stack. ELSE IF "{", push onto t...
<p>Unless you can guarantee that any strings in the data will not contain "}{", you can't even safely split it without parsing the JSON at least enough to keep track of whether you are in a string or not. For example if you just split this:</p> <pre><code>{"foo": "}{", "bar": 42} </code></pre> <p>around "}{", you wou...
43,836
<p>My printer has an auto-leveling feature that works by touching the build plate with the tip of the nozzle.</p> <p>I started using a BuildTak surface and BuildTak is damaged when you push a hot nozzle into it.</p> <p>So I edited the start G-code to run the auto-leveling before heating up the hotend</p> <p>But ABS ...
<p>The G-code to delay is <code>G4</code>.</p> <p><code>G4 P60000</code> will wait for one minute. The <code>P</code> is in milliseconds. Some firmware also accept a <code>S</code> Parameter that has the seconds. So, if supported, <code>G4 S60</code> would do the same thing.</p> <p>The details for this and all other ...
<p>I´m using this code for my prints.</p> <pre><code> G29 ; Autonivel M190 S35 ; set bed temperature G1 Z4 F240 ; lift nozzle M109 S195 ; wait for temperature to be reached G21 ; set units to millimeters G90 ; use absolute coordinates M82 ; use absolute distances for extrusion M104 S210 ...
190
<p>What libraries can i use for motion and blending in game programming in c++? I need libraries regarding sound, image, expansion algorithm like 2xsai and super eagle. I need libraries like fblend and also for motion . How to compile functions of fblend in devcpp? 2d gaming... and the library should be compatible with...
<p>I use mainly these two libraries for 3d gaming:</p> <p><a href="http://www.libsdl.org/index.php" rel="noreferrer">SDL</a> </p> <blockquote> <p>Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D v...
<p>Begin using GNU Emacs (gnu.org/software/emacs) and gcc (gcc.gnu.org or mingwm.org for a windows version). Get comfortable with your OS's shell (command line), enough to create files, change directories and copy/move files.</p> <p>Read up a bit on Emacs's features (almost endless), then get started (IDE's are there ...
15,128
<p>Do moderate or large projects ever not require an architect? I have worked on a number of projects where the development company involved has choosen not to assign an application architect. Either the software is built organically and with little concern for design or the design responsibility falls to senior develo...
<p>I'm going to have to use an analogy here utilizing houses. Not too long ago (relatively) people could build houses without an architect or architected plans. They cut down some wood, used learned skills to cut and plane boards and built their houses. Cathedrals, castles, etc....they had architects and engineers, ...
<p>In the place where I work, we have architects for a large project. The architects are if you like 'the voice of sanity' and bridge the gap between a business analyst style role ('This is what we believe the industry requires') and the senior developers ('this is how it can work'). They provide a consistent view of h...
26,096
<p>Does anyone know where I can find a library of common but difficult (out of the ordinary) SQL script examples. I am talking about those examples you cannot find in the documentation but do need very often to accomplish tasks such as finding duplicates etc.</p> <p>It would be a big time saver to have something like ...
<p>You may find <a href="http://wiki.lessthandot.com/index.php/Category:Microsoft_SQL_Server" rel="noreferrer">this wiki on LessThanDot</a> useful, for the most part, it is by Denis Gobo, Microsoft SQL MVP.</p> <p>EDIT: The wiki includes <strong>100+ SQL Server Programming Hacks</strong>, the list is, I think, too lon...
<p>Forgive me for the self-advertising, but I have posted a few on my blog (<a href="http://progblog.wordpress.com" rel="nofollow noreferrer">http://progblog.wordpress.com</a>) because I'm rubbish at SQL and it's a good place to store things I know I'll need in the future :-) If anyone has anything more substantial th...
24,012
<p>I have a ‘page a’ using ‘css a’. This page has margins set in css. I also have a ‘page b’ using ‘css b’. This page also has margins set in css, of the same size as in ‘css a’ (10px).</p> <p>Is there any way I can make it so that when I am viewing ‘page a’ on its own it has margins, but when viewed in an iframe on ‘...
<p>Using one of the most fundamental XSLT design patterns: "Overriding the <a href="https://www.w3.org/TR/1999/REC-xslt-19991116#copying" rel="noreferrer"><strong>identity transformation</strong></a>" one will just write the following:</p> <pre> &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/T...
<p>The answer by <a href="https://stackoverflow.com/users/36305/dimitre-novatchev">@Dimitre Novatchev</a> is certainly both correct and elegant, but there's a generalization (that the OP didn't ask about): what if the element you want to filter also has child elements or text that you want to <em>keep</em>? </p> <p>I ...
41,662
<p>My ender3 came with a BuildTak-clone surface, and as I was a little too vigorous in getting the print off the bed (I had failed to level right and printed a bit too tight to the bed, resulting in SUPER strong adhesion), I needed to replace it.</p> <p>Peeling off the black was easy. The plastic sheet that held the g...
<p>In my experience, we deal with 3M™ Adhesive Transfer Tape 468MP; high-temperature glue residue. To remove the leftover glue from my Aluminium build plate I found that it works best if I apply <a href="https://en.wikipedia.org/wiki/Paint_thinner" rel="nofollow noreferrer">paint thinner</a>. </p> <p>I ran out of acet...
<p>Cleaning up the aluminium build platform was rather easy in a three step process as I figured out:</p> <h3>Preparation</h3> <p>Get the old bed-surface off and any film layers that stick to the original glue. Don't bother to try to scrape off the glue, it is wasted time.</p> <h3>Solvent</h3> <p>To remove the stic...
1,178
<p>I want to make an entity that has an autogenerated primary key, but also a unique compound key made up of two other fields. How do I do this in JPA?<br> I want to do this because the primary key should be used as foreign key in another table and making it compound would not be good.</p> <p>In the following snippet,...
<p>You can use <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/UniqueConstraint.html" rel="nofollow noreferrer"><code>@UniqueConstraint</code></a> something like this :</p> <pre><code>@Entity @Table(name = "dm_action_plan", uniqueConstraints={ @UniqueConstraint(columnNames= "command","model") }...
<p>Use @GeneratedValue to indicate that the key will be generated and @UniqueConstraint to express unicity</p> <pre><code>@Entity @Table(name = "dm_action_plan" uniqueConstraint = @UniqueConstraint({"command", "model"}) ) public class ActionPlan { @Id @GeneratedValue private int pk; @Column(name...
11,619
<p>I have a client/server system that performs communication using XML transferred using HTTP requests and responses with the client using Perl's LWP and the server running Perl's CGI.pm through Apache. In addition the stream is encrypted using SSL with certificates for both the server and all clients.</p> <p>This sy...
<p>I don't think you can change the Content-Length like that. It would confuse Apache, because mod_deflate wouldn't know how much compressed data to read. What about having the client add an X-Uncompressed-Length header, and then use a modified version of CGI.pm that uses X-Uncompressed-Length (if present) instead of...
<p>I am not sure if I am following you with what you want, but I have a custom get/post module, that I use to do some non standard stuff. The below code will read in anything sent via post, or STDIN.</p> <pre><code>read(STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); </code></pre> <p>Instead of using using $ENV's valu...
16,508
<p>I am looking for some good links with best practices and sample code on creating <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" rel="noreferrer">REST</a>ful web services using .NET. </p> <p>Also, any other input you might have regarding REST would be greatly appreciated.</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/cc748663.aspx?pr=blog" rel="noreferrer">ADO.Net Data Servcies</a> makes it really easy to build and <a href="http://msdn.microsoft.com/en-us/magazine/cc794279.aspx" rel="noreferrer">consume</a> RESTful web services in the .Net world but nevertheless understanding the...
<p>When I began developing REST web services I read REST API Design Rulebook from Mark Masse. Once you know the basics and the theory, you will be able to implement REST with WCF, HTTPListener or ServiceStack. All these frameworks are .NET and quite good documented... </p> <p>I would recommend to you service stack (ht...
8,537
<p>For example:</p> <p>Base class header file has:</p> <pre><code>enum FOO { FOO_A, FOO_B, FOO_C, FOO_USERSTART }; </code></pre> <p>Then the derived class has:</p> <pre><code>enum FOO { FOO_USERA=FOO_USERSTART FOO_USERB, FOO_USERC }; </code></pre> <p>Just to be clear on my usage it is for having an event handler w...
<p>No. The compiler needs to be able to decide whether the enum fits in a char, short, int or long once it sees the }.</p> <p>So if the base class header has</p> <pre><code>enum Foo { A, B, MAX = 1&lt;&lt;15 }; </code></pre> <p>a compiler may decide the enum fits in 16 bits. It can then use that, e.g. when lay...
<p>Yes, this works. To simplify your code a bit, I would suggest this, more common method of "extending" enums:</p> <pre><code>enum FOO // Base class's FOO { FOO_A, FOO_B, FOO_C, FOO_BASE_MAX // Always keep this as the last value in the base class }; enum FOO // Derived class's FOO { FOO_USERA=FOO_BASE_MAX+1, // Alwa...
33,535
<p>I have an xml web service which I use at work to make a request to. This request, an xml document, includes information such as recipients, subject, body, etc (as a newsletter would contain).</p> <p>I have an ASP.NET form to enter the above information to, to form the Xml document, and I can type foreign characters...
<pre><code>template&lt;size_t length&gt; int less(const char* left, const char* right) { return memcmp(left, right, length) &lt; 0; } std::sort(array, array + array_length, less&lt;buffer_length&gt;); </code></pre>
<p>The canonical way to sort an array of character strings in C, and therefore an available but not necessarily recommended way to do so in C++, uses a level of indirection to <code>strcmp()</code>:</p> <pre><code>static int qsort_strcmp(const void *v1, const void *v2) { const char *s1 = *(char * const *)v1; c...
40,580
<p>I am looking to manage a SQL Server 2008 DB using Management Studio 2005. The reason for this is because our server is a 64-bit machine and we only have the 64-bit version of the software. </p> <p>Is this possible? </p> <p>How about managing a SQL Server 2005 DB using Management Studio 2008?</p>
<p>UPDATE: You can use <a href="http://support.microsoft.com/kb/943656" rel="noreferrer">Cumulative update package 5</a> for SQL Server 2005 Service Pack 2 to connect to 2008.</p> <p>FIX: 50002151 946127 (<a href="http://support.microsoft.com/kb/946127/" rel="noreferrer">http://support.microsoft.com/kb/946127/</a>) FI...
<p>unless I'm mistaken and things have changed, you cannot use sql server 2008 to save a backup which restores to sql server 2005. I found this out the hard way :(</p>
7,535
<p>So I'm making my friend a Monado sword replica and I've printed the handle in 2 pieces as to fill it with electronics and then superglue the 2 halves together.</p> <p>I seem to have put too much on and it's leaked out and spread as shown in the picture..</p> <p>Does anyone know how to get the dried glue off? <a href...
<p>In agreement with what Akriss said, pretty much all &quot;super&quot; glue is CA (cyanoacrylate) glue, which is soluble in acetone. PLA itself is does not dissolve in or react with acetone, but the pigments, additives, etc. likely do, so you should wipe with a paper towel or cloth (the latter might be better to avoi...
<p>I've used Acetone before. However that said I've not had the need to remove it from PLA. Not sure how PLA reacts to Acetone.</p> <p>A link that may be of use. <a href="https://www.art-us.com/how-to-get-super-glue-off-almost-anything/" rel="nofollow noreferrer">https://www.art-us.com/how-to-get-super-glue-off-almost-...
1,799
<p>Ease of installation/use is the most important factor here - not performance.</p> <p>Small is OK as large datasets are not expected.</p>
<p>I'd also recommend <a href="http://www.openrdf.org" rel="nofollow noreferrer">sesame</a>, its lightweight, pretty easy to install, and provides good performance for small datasets. Query performance is far better with Sesame 1.2.x than Sesame 2.x because of the addition of context support to the 2.x series.</p> <p...
<p>If you are a .NET developer you may be interested in <a href="http://www.intellidimension.com/products/semantics-sdk/" rel="nofollow noreferrer">Intellidimensions Semantic SDK</a>. If you want to load a graph in memory and then execute SPARQL queries against that graph the code is as simple as:</p> <pre><code>var ...
39,207
<p>I have spent several hours trying to find a means of writing a cross platform password prompt in php that hides the password that is input by the user. While this is easily accomplished in Unix environments through the use of stty -echo, I have tried various means of passthru() and system() calls to make windows do...
<p>There doesn't seem to be an IOCTL or STTY extension for PHP. I found the following trick <a href="http://www.usenet-forums.com/php-language/35386-hide-password-input-cli-php-script.html" rel="noreferrer">here</a>:</p> <pre><code>&lt;?php echo 'Password: '; $pwd = preg_replace('/\r?\n$/', '', `stty -echo; head -n1 ...
<p>I think you cannot do that in PHP with the standard library but you can do better :</p> <p>Catch the first letter, then display a *. Catch the second one, then display two *...</p> <p>Ergonomically, this is handy because the user can see what he have entered. Security is not at risk because if somebody can see the...
38,116
<p>I am trying to have a logout page where is displays a messages and then redirects to the login page. This is in ASP.net 2.0.</p> <p>I have this in my <code>Page_Load</code>:</p> <pre><code>ClientScript.RegisterStartupScript(typeof(Page), "pageredirect", JavascriptRedirect() ); </code></pre> <p>This is my redirect...
<p>By the way: You don't need Javascript to redirect the browser to a page after a certain amount of time. Just use a plain HTML meta Tag in your <code>&lt;HEAD&gt;</code> section.</p> <pre><code>&lt;meta http-equiv="refresh" content="5; URL=login.aspx"&gt; </code></pre> <p>The number stands for the time in seconds, ...
<p>Instead of typeof(Page), try typeof(YOURPAGECLASS) -- with YOURPAGECLASS set the name of your page's classname. Page_Load is definitely not too late.</p>
14,054
<p>I was trying to access swf from javascript, so this example in livedocs is what I'm trying to modify. <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#includeExamplesSummary" rel="nofollow noreferrer">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl...
<p>The problem is that the SWF file isn't fully loaded by the time you try to call it. The flash player is probably loaded but it takes a while to load and initialise the swf file.</p> <p>What you need to do is make a call from the SWF file to a javascript function when it's loaded and put your javascript there rather...
<p>Summary of a success:</p> <hr> <p>I am using <code>AC_RunActiveContent.js</code>, as set up by Flash when published.<br> My swf is called <code>fvar_js</code>, as seen below:</p> <pre><code>AC_FL_RunContent( ... 'src', 'fvar_js', ... </code></pre> <p>I STRESS this because I NEVER had to use a...
38,902
<p>I have an <strong>"ldquo"</strong>, <strong>"rdquo"</strong> and several other entities under my RSS feed. Seems like if I add</p> <pre><code>&lt;!DOCTYPE rss [ &lt;!ENTITY % HTMLspec PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent"&gt; %HTMLspec; </code><...
<p>it doesn't seem likely that many feed readers will know what to do with that. i would recommend sticking with numbered entity references. for example, change <code>&amp;ldquo;</code> to <code>&amp;#8220;</code>. you can get the full entity reference <a href="http://www.w3.org/TR/REC-html40/sgml/entities.html" rel...
<p>Forget entities. Just use UTF-8 for all characters. </p> <p>It will work reliably regardless whether RSS clients properly parse XML or not (sadly, the latter isn't uncommon).</p>
24,803
<p>I was reading Joel's book where he was suggesting as interview question:</p> <blockquote> <p>Write a program to reverse the "ON" bits in a given byte.</p> </blockquote> <p>I only can think of a solution using C. </p> <p>Asking here so you can show me how to do in a Non C way (if possible)</p>
<blockquote> <p>What specifically does that question mean?</p> </blockquote> <p>Good question. If reversing the "ON" bits means reversing only the bits that are "ON", then you will always get 0, no matter what the input is. If it means reversing <em>all</em> the bits, i.e. changing all 1s to 0s and all 0s to 1s, w...
<p>Since the question asked for a non-C way, here's a Scheme implementation, cheerfully plagiarised from <a href="http://people.csail.mit.edu/jaffer/SLIB" rel="nofollow noreferrer">SLIB</a>:</p> <pre><code>(define (bit-reverse k n) (do ((m (if (negative? n) (lognot n) n) (arithmetic-shift m -1)) (k (+ -1 k) (...
3,113
<p>I'm currently using subversion to manage my source code and I've come to a point where I need to brand the software I'm working on for a client. All the branding is handled in the project resources so changing the look for a client is very simple. What I'm running into a problem with is maintaining the branded versi...
<p>You could make the branded relaease a seperate repo that uses the vanilla branch as an external.</p> <p>The alternative would be to keep everything in a single branch and have the build-process do the work of selecting which branding-specific files to use.</p>
<p>The branding should be the top-level project with the core part of the project as a child (or dependency depending on your project inheritance model). In subversion, you can use externals to include the core product source code in the top level product, or you can build the core product and use the top level projec...
25,380
<p>I need to write code in python language for comparing the text of document using fingerprint techniques. I do not know to take fingerprint of a document or to generate fingerprint of a document. I'm asking if anyone knows the method or has source code for generating fingerprints of documents which is stored in bits ...
<p>@konstantinos.konstantinidis.myopenid.com: your problem seems to be with the setup project not the continuous integration server. </p> <p>You have the setup project picking up the primary outputs for the project. </p> <p>Change it to use file references to the outputs. It's a little more configuration in the set...
<p>Nice to hear someone is using CruiseControl.NET. That is a nice tool. You can use a command line tool for obfuscation as RemoteSoft .NET Obfuscator and integrate a call to the tool in the build script. See example on how to execute a file below from CruiseControl.NET wiki.</p> <p><a href="http://www.remotesoft.com/...
11,654
<p>Given an object on a plain white background, does anybody know if OpenCV provides functionality to easily detect an object from a captured frame? </p> <p>I'm trying to locate the corner/center points of an object (rectangle). The way I'm currently doing it, is by brute force (scanning the image for the object) an...
<p>There's already an example of how to do rectangle detection in OpenCV (look in samples/squares.c), and it's quite simple, actually.</p> <p>Here's the rough algorithm they use:</p> <pre><code>0. rectangles &lt;- {} 1. image &lt;- load image 2. for every channel: 2.1 image_canny &lt;- apply canny edge detector to t...
<p>It is usually called blob analysis in other machine vision libraries. I haven't used opencv yet.</p>
35,305
<p>I've read many times and agree with avoiding the use of globals to keep code orthogonal. Does the use of the config file to keep read only information that your program uses similar to using Globals?</p>
<p>If you're using config files in place of globals, then yes, they are similar.</p> <p>Config files should only be used in cases where the end-user (presumably a computer-savvy user, like a developer) needs to declare settings for an application or piece of code, while keeping their hands out of the code itself.</p>
<p>Configuration files are really meant to be easily editable by the end user as a way of telling the program how to run.</p> <p>A more specialized form of configuration files, user preferences, are used to remember things between program executions.</p>
35,201
<p>I know how to use JSON to create objects, but there doesn't seem to be away to use JSON to create an object that is of a specific object type.</p> <p>Here's an example of an Object and creating an instance of it:</p> <pre><code>Person = function() { }; Person.prototype = { FirstName: null, GetFirstName: fu...
<p>I don't imagine so. I'd create a function on the Person class to initialise from a JSON object if I were you.</p> <pre><code>function Person() { this.loadFromJSON = function(json) { this.FirstName = json.FirstName; }; } </code></pre> <p>If you didn't know what class the JSON object was representing...
<p>You could allow new Person() to accept an object to populate attributes with as a parameter.</p> <pre><code>var you = new Person({ firstName: 'Mike' }); </code></pre>
22,422
<p>Whether this is possible I don't know, but it would mighty useful!</p> <p>I have a process that fails periodically (running in Windows 2000). I then have just one chance to react to it before having to restart it and painfully wait for it to fail again. I didn't write the process so don't have the source to debug. ...
<p>I think <a href="http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx" rel="nofollow noreferrer">minidump</a> is what you are looking for.</p> <p>You can also used <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=E089CA41-6A87-40C8-BF69-28AC08570B7E&amp;displaylang=en&amp;displaylan...
<p>My best bet is to start the process in a debugger (<a href="http://www.ollydbg.de/" rel="nofollow noreferrer">OllyDbg</a> being my preferred tool). The process will pause on an exception, and you can try to figure out what happened shortly before that. </p> <p>This needs some understanding of assembler and does not...
16,732
<p>Which of the following is better code in c# and why?</p> <pre><code>((DateTime)g[0]["MyUntypedDateField"]).ToShortDateString() </code></pre> <p>or</p> <pre><code>DateTime.Parse(g[0]["MyUntypedDateField"].ToString()).ToShortDateString() </code></pre> <p>Ultimately, is it better to cast or to parse?</p>
<p>If g[0]["MyUntypedDateField"] is really a DateTime object, then the cast is the better choice. If it's not really a DateTime, then you have no choice but to use the Parse (you would get an InvalidCastException if you tried to use the cast)</p>
<p>As @Brian R. Bondy pointed it depends on implementation of <strong>g[0]["MyUntypedDateField"]</strong>. Safe practice is to use <strong>DateTime.TryParse</strong> and <strong>as</strong> operator. </p>
8,701
<p>How can I convert a Char[] (of any length) to a List ?</p>
<p>First you need to understand that chars aren't bytes in .NET. To convert between chars (a textual type) and bytes (a binary type) you need to use an encoding (see System.Text.Encoding).</p> <p>Encoding will let you convert between string/char[] and byte[]. Once you've got a byte array, there are various ways of con...
<p>I have managed to use the following to get the job done:</p> <pre><code>byte[] arr = new System.Text.UTF8Encoding( true ).GetBytes( str ); List&lt;byte&gt; byteList = new List&lt;byte&gt;( arr ); </code></pre> <p>Thanks for your help</p>
19,629
<p>I want to achieve the following:</p> <pre><code>ID | Counter ------------ 0 | 343 1 | 8344 </code></pre> <p>Now say that I want to update counter for ID 1,,, what is the easiest way to do it? Do I use sequences? do I simply read the value and update? Is there any special type for it?</p> <p>I was thinking about...
<p>UPDATE Table SET Counter=Counter+1 WHERE ID=:ID;</p> <p>(where 'Table' is of course the table with the counter, and the parameter ':ID' is the id of the counter)</p> <p>Sequences are mainly used for auto-generating ID values sequentially and can have gaps. The update statement above is atomic, as update is an ato...
<p>It <em>sounds</em> like what you need is to create a <strong>view</strong> exactly along the lines of:</p> <p><code>select id, count(users) from foo group by id</code></p>
48,008
<p>I'm looking for a VS2008 Plugin or other tool that allows me to edit CSS and preview the changes in IE and Firefox.</p> <p>I'm not full time web designer, so free or open source is a plus.<br> Visual Studio integration is a big plus</p> <p>Reviewed so far:</p> <h2>CSSVista</h2> <p>Pros: </p> <ul> <li>Free</li> ...
<p>What I use to get that functionality is through the Web Developer Addon for Firefox, you can edit CSS in real time. I don't know of a functionality like that for VS.</p>
<p>For Ie-----there is one tool Iedeveloper tool For Firefox----Firebug is enough..........Using these two,,,u can edit css and u can see the preview</p>
19,032
<p>It's been a few years since I've taken a deep look at Mono. When I last took a look, it wasnt quite there as far as BCL implementation and the tools available were limited. I have a specific need now to do some cross platform development, and was wondering what the community thought about Mono as a choice in the ent...
<p>With 2.0 out now, I think it is. Our current build system depends on it and have been very happy with it. Now for releasing an actual product, Can you do it all in .NET 2.0? If so I think it is.</p>
<p>Last time I looked into it, there were several limitations. That was a couple of years ago. Scalability was our issue then.</p>
25,064
<p>Is there any way to test SMS messaging without having a texting plan? </p> <p>There isn't any way to setup the equivalent of a mock email server for the purposes of testing an SMS service is there? Are there any other ways to accomplish the task? Perhaps setting up something like a GrandCentral account that can rec...
<p>Google now has the answer for which I seek. With the roll-out of their new Google Voice (previously GrandCentral) they added the ability to received text messages to the phone number (which currently is free). While technically somewhat of a text plan, one could theoretically sign up for a few accounts and be able t...
<p>you can send email to their phone:</p> <p>18005551212@txt.att.net (IIRC)</p>
43,002
<p>I have a bunch of PDF files and my Perl program needs to do a full-text search of them to return which ones contain a specific string. To date I have been using this:</p> <pre><code>my @search_results = `grep -i -l \"$string\" *.pdf`; </code></pre> <p>where $string is the text to look for. However this fails for m...
<p>The PerlMonks thread <a href="http://www.perlmonks.org/?node_id=582868" rel="noreferrer">here</a> talks about this problem.</p> <p>It seems that for your situation, it might be simplest to get <strong>pdftotext</strong> (the command line tool), then you can do something like:</p> <pre><code>my @search_results = `p...
<p>You could try Lucene (the Perl port is called Plucene). The searches are incredibly fast and I know that PDFBox already knows how to index PDF files with Lucene. PDFBox is Java, but chances are there is something very similar somewhere in CPAN. Even if you can't find something that already adds PDF files to a Lucene...
16,827
<p>Does anyone have any experience getting MSTest to copy hibernate.cfg.xml properly to the output directory? All my MSTests fail with a cannot find hibernate.cfg.xml error (I have it set to Copy Always), but my MBUnit tests pass.</p>
<p>You can try adding the DeploymentItemAttribute to one of your tests, or edit your .testrunconfig file and add the file to the Deployment list.</p>
<p>a workaround rather than an answer: NHibernate supports <a href="http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/session-configuration.html#configuration-programmatic" rel="nofollow noreferrer">programmatic configuration</a>. so you can write your own native properties/config file and parse it int...
4,052
<p>I want to allow only users with a 3G phone to use a particular GPS function. How do I run a check on the device before allowing that feature to be used?</p>
<p>The following code with allow you to determine the exact device that is in use but I would first consider the fact that a 3G device may not actually be able to obtain a GPS lock as the process of doing so is quite slow and requires a more or less clear view of the sky.</p> <p>For an iPhone 3G the result of this met...
<p>Why would you stop 1g phone users from using location services? If you are near mapped WiFi you can get decent location results even without a GPS on the device.</p> <p>Instead you should base your choice of what to do around the current location accuracy, if that is a reason why you seek to disable anything.</p>
38,773
<p>I have a table for which I want to select top the 5 rows by some column A. I also want to have a 6th row titled 'Other' which sums the values in column A for all but the top 5 rows.</p> <p>Is there an easy way to do this? I'm starting with:</p> <pre><code>select top 5 columnB, columnA from someTable t o...
<p>Not tested, but try something like this:</p> <pre><code>select * from ( select top 5 columnB, columnA from someTable t order by columnA desc union all select null, sum(columnA) from someTable t where primaryKey not in ( select top 5...
<p>This is off the top of my head, and i will garuntee horribly efficient:</p> <pre><code>SELECT TOP 5 columnB, columnA FROM comTable t ORDER BY columnA desc UNION SELECT 'Other', (A.Sum - B.Sum) AS Summary FROM (SELECT SUM(columnA) FROM someTable) A JOIN (SELECT SUM(One) FROM (SELECT TOP 5 columnA FROM someTab...
47,560
<p>I have one table "orders" with a foreing key "ProductID".</p> <p>I want to show the orders in a grid with the <strong>product name</strong>, without <strong>LazyLoad</strong> for better performance, but I if use <strong>DataLoadOptions</strong> it retrieves <strong>all</strong> Product fields, which seams like a <s...
<p>What you are asking for is a level of optimisation the linq-to-sql does not provide. I think your best bet is to create a query that returns exactly the data you want, possibly as an anonymous type:</p> <pre><code>from order in DB.GetTable&lt;Orders&gt;() join product in DB.GetTable&lt;Products&gt;() on order.Produ...
<p>If you select only the columns you want in the linq query, and then call .ToList() on the query, it will be immedietly executed, and will only bring back the columns you are interested in. For example if you do this:</p> <pre><code>var q = from p in dataContext.products select p.ProductName; var results = q.ToList(...
4,870
<p>I was wondering if it would be possible to retrieve the complete list of security roles defined in a web.xml file in the java code? And if so how to do it?</p> <p>I am aware of the 'isUserInRole' method but I also want to handle cases where a role is requested but not defined (or spelled differently) in the web.xml...
<p>As far as I know, there's no way do do this within the Servlet API. However, you can parse web.xml directly and extract the values yourself. I used dom4j below, but you can use whatever XML processing stuff you like:</p> <pre><code>protected List&lt;String&gt; getSecurityRoles() { List&lt;String&gt; roles = n...
<p>Here is the version of Ian's answer using newer DOM API:</p> <pre><code>private List&lt;String&gt; readRoles() { List&lt;String&gt; roles = new ArrayList&lt;&gt;(); InputStream is = getServletContext().getResourceAsStream("/WEB-INF/web.xml"); try { DocumentBuilder builder = DocumentBuilderFacto...
20,098
<p>I'm sorry for this very newbish question, I'm not much given into web development. I've got this cool JavaScript in a .js file that we want to use on a small web site. (It's a script to run Cooliris on it).</p> <p>How do use the .js file or attach it to my HTML code?</p>
<p>Just include this line anywhere in your HTML page:</p> <pre><code>&lt;script type="text/javascript" src="yourfile.js"&gt;&lt;/script&gt; </code></pre> <p>Don't forget the closing tag as IE won't recongize it without a separate closing tag.</p>
<p>use this script with in head tag.and your JS file path with name of ur file</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="url+yourfilename.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;/html&gt; </code></pre>
24,450
<p>I'm using a medical records system built on an Oracle database. Our vendor just told us that we need to shut down Oracle's Enterprise Manager service when we're not using it, because it uses too much of the system's resources. I know I can get actual numbers by checking Sysinternals Process Explorer, but I was hopin...
<p>We do the same thing on our testing and production servers too. I don't have any metrics to hand, but it did make a noticeable improvement in overall database response</p>
<p>It's a hog, I like to run Oracle on Linux, and turn off the GUI after the initial install (Oracle's installer requires it).</p>
19,085
<p>What's the difference between <code>file</code> and <code>open</code> in Python? When should I use which one? (Say I'm in 2.5)</p>
<p>You should always use <code>open()</code>.</p> <p>As the <a href="http://docs.python.org/2/library/functions.html#file" rel="noreferrer" title="BuiltinFuncs Doc">documentation</a> states:</p> <blockquote> <p>When opening a file, it's preferable to use open() instead of invoking this constructor directly. fil...
<p>Only ever use open() for opening files. file() is actually being removed in 3.0, and it's deprecated at the moment. They've had a sort of strange relationship, but file() is going now, so there's no need to worry anymore.</p> <p>The following is from the Python 2.6 docs. [bracket stuff] added by me.</p> <blockquot...
13,805
<p>I would like to know which one is the best material that I can hand out to my students about "<em>C# comments</em>".</p>
<p><a href="http://www.codinghorror.com/blog/archives/000749.html" rel="noreferrer">This Post</a> by Jeff Atwood on his blog <a href="http://www.codinghorror.com" rel="noreferrer">Coding Horror</a> goes into the purpose of comments in general. Something you might think is 'duh' really isn't -- especially in the 'real ...
<h2>Inside VS</h2> <p>Comments are relatively simple.</p> <p>You can use for <strong>single line</strong> :</p> <pre><code>//This is a single line comment </code></pre> <p>You can use for <strong>multiple line</strong>:</p> <pre><code>/* Multiple lines */ </code></pre> <p>For <strong>method</strong> you can use ...
39,778
<p>I am implementing a tagging system on my website similar to one stackoverflow uses, my question is - what is the most effective way to store tags so that they may be searched and filtered?</p> <p>My idea is this:</p> <pre><code>Table: Items Columns: Item_ID, Title, Content Table: Tags Columns: Title, Item_ID </co...
<p>One item is going to have many tags. And one tag will belong to many items. This implies to me that you'll quite possibly need an intermediary table to overcome the many-to-many obstacle.</p> <p>Something like:</p> <blockquote> <p>Table: Items<br /> Columns: Item_ID, Item_Title, Content</p> </blockquote> <blockquote...
<p>Items should have an "ID" field, and Tags should have an "ID" field (Primary Key, Clustered).</p> <p>Then make an intermediate table of ItemID/TagID and put the "<a href="http://www.singingeels.com/Articles/Understanding_SQL_Many_to_Many_Relationships.aspx" rel="nofollow noreferrer">Perfect Index</a>" on there.</p>...
43,325
<p>While printing a simple model, my printer starts to layer-shift the build in a direction suddenly. I used the default setting for ultimaker Cura 3.4.1. It has done this same thing for multiple different prints. I would guess it is the software. </p> <p>How do I fix the issue? <a href="https://i.stack.imgur.com/xVXO...
<p>You have a case of layer shift. Layer shifts happened to me in 3 ways:</p> <ol> <li>The movement of the axis is hindered. Check if all cables run freely and without any chance to catch! improper cable chains can cause binding and stop the printhead or bed in movement and thus induce a shift.</li> <li>The accelerati...
<p>You have a case of layer shift. Layer shifts happened to me in 3 ways:</p> <ol> <li>The movement of the axis is hindered. Check if all cables run freely and without any chance to catch! improper cable chains can cause binding and stop the printhead or bed in movement and thus induce a shift.</li> <li>The accelerati...
1,135
<p>Let's say you have a profile page that can only be accessed by the owner of that profile. This profile page is located at:</p> <p>User/Profile/{userID}</p> <p>Now, I imagine in order to prevent access to this page by other users, you could structure your UserController class's Profile function to check the curren...
<p>I ended up going with the "UserNameFilter" shown in Kazi Manzur's <a href="http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx" rel="nofollow noreferrer">blog post</a>. Works like a charm and easy to unit test.</p>
<p>This is where mocking comes in, with a fake HttpContext.</p>
15,981
<p>I'm using MediaTemple's (dv) hosting service. How do I determine what mail-server is installed? Should I use the shell? If so, what command would be used?</p>
<p>Go to the shell and type this command:</p> <pre><code>telnet &lt;hostname&gt; 25 </code></pre> <p>This will come back with a line like so:</p> <pre><code>220 example.com ESMTP Exim 4.69 Thu, 13 Nov 2008 10:06:01 +1100 </code></pre> <p>as you can see, this sever is running EXIM.</p> <p>Then type QUIT to exit bac...
<p>Try</p> <pre><code>$ nmap -p 25 -A -T polite &lt;hostname&gt; </code></pre> <p>from a Linux box with nmap installed.</p>
36,290
<p>Desinging web application and for reporting iam using crystal reports.sometimes the crystal reports gives runtimes error. What can i do to make my report faster. Retrieving around 1MB of data. It is the month end sales report. what is the best method to solve this issue.</p>
<p>You can use <strong><a href="http://www.inetsoftware.de/products/crystal-clear" rel="nofollow noreferrer">i-net Clear Reports</a></strong> (used to be i-net Crystal-Clear). It can read Crystal Reports report files. That way, you do not need to redesign your reports. A report of 1 MB is not a problem. We have reports...
<p>1Mb sounds like far too much data for a report - I would try to filter it down more on the server</p>
10,551
<p>I want to add an ajax:TabContainer to my webpage. I don't get any build errors, but when I try to browse to the page, it gives me the error: "The Controls collection cannot be modified because the control contains code blocks (i.e. &lt;% ... %>).".</p> <p>I re-downloaded the Ajax Control Toolkit for the sample site...
<p>You can't use &lt;%= %> (write) blocks inside a control that uses the standard server rendering - you get this error.</p> <p>In order for the ASP AJAX components to work you need:</p> <pre><code>&lt;head runat="server"&gt;... </code></pre> <p>Otherwise it crashes with this error too.</p> <p>However you can <em>d...
<p>no need to do any thing just keep &lt;%=....%> Part of code which is having in Master page in</p>
46,572
<p>At the moment there are two tags related to fans:</p> <ul> <li><a href="https://3dprinting.stackexchange.com/questions/tagged/print-fan" class="post-tag" title="show questions tagged &#39;print-fan&#39;" rel="tag">print-fan</a></li> <li><a href="https://3dprinting.stackexchange.com/questions/tagged/fans" class="pos...
<p>There aren't that many topics labelled with either one of the existing tags, so re-tagging will not be a problem.</p> <p>Indeed these tags are generic tags and do not cover the range of fans specifically for the application they are used for. There are 3 types of applications for fans in 3D printers, </p> <ul> <li...
<p>3 tags is probably overly complex. I've not looked at the question list but I expect that these questions should also have a print quality or electronics tag, making the categorisation of the question fairly clear. The problem to me of having several tags is choosing which one would be relevant to a question, and al...
51
<p>I was told by a professor that using C code one could heat a single pixel on an old monitor to the point that the monitor would overheat and smoke. Have any of you come across anything that would support this? I am having a debate in my office on whether this is possible or not.</p>
<p>With old PC monochrome monitors, you could programmatically turn off the horizontal sync signal which would cause internal bits in the monitor to overheat and physically fail.</p>
<p>You could definitely burn out old (&lt; 1990 monitors) by writing bad data to the crt controller, on the old PC's. they would smoke and cease to work. I did it when I was a BIOS writer.</p> <p>Ed</p>
33,981
<p>I've heard of the idea of bootstrapping a language, that is, writing a compiler/interpreter for the language in itself. I was wondering how this could be accomplished and looked around a bit, and saw someone say that it could only be done by either</p> <ul> <li>writing an initial compiler in a different language.<...
<blockquote> <p>Is there a way to actually write a compiler in its own language?</p> </blockquote> <p>You <em>have</em> to have some existing language to write your new compiler in. If you were writing a new, say, C++ compiler, you would just write it in C++ and compile it with an existing compiler first. On the o...
<p>Some bootstrapped compilers or systems keep both the source form and the object form in their repository:</p> <ul> <li><p><a href="http://ocaml.org/" rel="nofollow">ocaml</a> is a language which has both a bytecode interpreter (i.e. a compiler to Ocaml bytecode) and a native compiler (to x86-64 or ARM, etc... assem...
3,445
<p>Is there a pure-Java equivalent to &lt;jsp:forward page="..." /&gt; that I can use within a &lt;% ... %> block?</p> <p>For example, I currently have a JSP page something like this:</p> <pre><code>&lt;% String errorMessage = SomeClass.getInstance().doSomething(); if (errorMessage != null) { session....
<p>The <code>someObject</code> you are looking for is <a href="http://java.sun.com/products/jsp/2.1/docs/jsp-2_1-pfd2/javax/servlet/jsp/PageContext.html#forward(java.lang.String)" rel="noreferrer">pageContext</a>.</p> <p>This object is implicitly defined in JSP, so you can use it like this:</p> <pre><code>pageContext...
<p>A simple approach:</p> <pre><code>&lt;%@page errorPage="Error.jsp" %&gt; &lt;% String errorMessage = SomeClass.getInstance().doSomething(); if (errorMessage != null) { throw new Exception(errorMessage); // Better throw the exception from doSomething() } pageContext.forward("index.jsp"); %&gt; Error.js...
30,419
<p>Let's say you have a class called Customer, which contains the following fields:</p> <ul> <li>UserName</li> <li>Email</li> <li>First Name</li> <li>Last Name</li> </ul> <p>Let's also say that according to your business logic, all Customer objects must have these four properties defined.</p> <p>Now, we can do this ...
<p>Two design approaches to consider</p> <p>The <a href="http://www.hillside.net/plop/plop98/final_submissions/P10.pdf" rel="noreferrer">essence</a> pattern</p> <p>The <a href="https://martinfowler.com/bliki/FluentInterface.html" rel="noreferrer">fluent interface</a> pattern</p> <p>These are both similar in intent, ...
<p>Unless it's more than 1 argument, I always use arrays or objects as constructor parameters and rely on error checking to make sure the required parameters are there.</p>
6,148
<p>Is it better in C++ to pass by value or pass by reference-to-const?</p> <p>I am wondering which is better practice. I realize that pass by reference-to-const should provide for better performance in the program because you are not making a copy of the variable.</p>
<p>It used to be generally recommended best practice<sup>1</sup> to <strong>use pass by const ref for <em>all types</em>, except for builtin types (<code>char</code>, <code>int</code>, <code>double</code>, etc.), for iterators and for function objects</strong> (lambdas, classes deriving from <code>std::*_function</code...
<p>Simple difference :- In function we have input and output parameter , so if your passing input and out parameter is same then use call by reference else if input and output parameter are different then better to use call by value .</p> <p>example <code>void amount(int account , int deposit , int total )</code></p>...
33,983
<p>I'm trying to host a subdomain for my site with a different hosting company and I'm running into issues on how to set it up.</p> <p>Here are the specifics:</p> <ul> <li>Domain is registered with GoDaddy.</li> <li>Nameservers are pointing to DiscountASP.net where ASP.NET app has been happily running for couple of yea...
<p>A sub domain is part of the domain, it's like subletting a room of an apartment. A records has to be setup on the DNS for the domain e.g</p> <p><code>mydomain.example</code> has IP 123.456.789.999 and hosted with Godaddy. Now to get the sub domain</p> <p><code>anothersite.mydomain.example</code></p> <p>of which the ...
<p>UPDATE - I do not have Total DNS enabled at GoDaddy because the domain is hosted at DiscountASP. As such, I could not add an A Record and that is why GoDaddy was only offering to forward my subdomain to a different site. I finally realized that I had to go to DiscountASP to add the A Record to point to DreamHost. No...
22,994
<p>I want to read a mac id from command line and convert it to an array of <code>uint8_t</code> values to use it in a struct. I can not get it to work. I have a vector of string for the mac id split about <code>:</code> and I want to use <code>stringstream</code> to convert them with no luck. What I am missing?</p> <...
<p>Your problem may be in the output of the parsed data. The "&lt;&lt;" operator makes decisions on how to display data based on the data type passed it, and uint8_t may be getting interpretted as a char. Make sure you cast the array values to ints when printing, or investigate in a debugger.</p> <p>The sample program...
<p>I think you are using the std::hex in the wrong place:</p> <pre><code>#include &lt;sstream&gt; #include &lt;iostream&gt; int main() { std::string h("a5"); std::stringstream s(h); int x; s &gt;&gt; std::hex &gt;&gt; x; std::cout &lt;&lt; "X(" &lt;&lt; x &lt;&lt; ")\n"; } </code></pre>
34,809
<p>IN my case i want to implement multi select auto complete combobox using html,javascript.</p> <p>Is there any body who knows how to implement it.</p> <p>Which will be similar to text field shown in stackoverflow while adding multipal tags to any question.</p>
<p>If you are talking about multiple drop down boxes that are linked, so that the selection in the first drop down menu determines the possibilities in the next, then the <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/CascadingDropDown/CascadingDropDown.aspx" rel="nofollow noreferrer">ASP.NET Toolkit has a...
<p>What do you mean by auto populate? If you want to populate the drop down box dynamically you can just use a normal HTML Select tag and use Ajax to fetch the list of values to be shown in the drop down</p>
45,014
<p>Why isn't <a href="http://java.sun.com/javase/6/docs/api/java/util/Collection.html#remove(java.lang.Object)" rel="noreferrer">Collection.remove(Object o)</a> generic? </p> <p>Seems like <code>Collection&lt;E&gt;</code> could have <code>boolean remove(E o);</code> </p> <p>Then, when you accidentally try to remove ...
<p>Josh Bloch and Bill Pugh refer to this issue in <a href="https://www.youtube.com/watch?v=wDN_EYUvUq0" rel="noreferrer"><em>Java Puzzlers IV: The Phantom Reference Menace, Attack of the Clone, and Revenge of The Shift</em></a>.</p> <p>Josh Bloch says (6:41) that they attempted to generify the get method of Map, r...
<p>Remove is not a generic method so that existing code using a non-generic collection will still compile and still have the same behavior.</p> <p>See <a href="http://www.ibm.com/developerworks/java/library/j-jtp01255.html" rel="nofollow noreferrer">http://www.ibm.com/developerworks/java/library/j-jtp01255.html</a> fo...
13,037
<p>I've just been tasked with building a web application using ASP (.net) and am looking for some advice on where to start. In a nutshell the application needs to be able to.</p> <ul> <li>Handle user verification / authentication</li> <li>Handle sessions</li> <li>Do SOAP messaging</li> </ul> <p>The application is i...
<p>Use Visual Studio 2008 if you can. Its support for Ajax client libraries and javascript intellisense is very good. (Check out the <a href="http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx" rel="nofollow noreferrer">jQuery add in</a>) </p> <p>ASP.NET has built in Login controls ...
<p>This is not directly related to your requirements, but I'd suggest you study the differences between Web Site and Web Application. The sooner the better. Everything will go smoother if you understand how the project is managed.</p> <p>You can start here: <a href="http://www.codersbarn.com/post/2008/06/ASPNET-Web-Si...
36,037
<p>I'm looking for a tool that will generate an assembly/project dependency diagram in Visio (or as close as possible) to assist me with breaking up some of our system into more manageable trunks.</p> <p>The ability to include/exclude non-project dependencies is a must (i.e. include/exclude System. assemblies).</p>
<p>Try ReSharper. (I'm not associated with the product or company, but it provides many nice features for dependency walking).</p> <p>You can also try the Depends.exe with the SysInternal toolset - now from Microsoft.</p> <p><a href="http://www.jetbrains.com/resharper/" rel="nofollow noreferrer">ReSharper by jetbrai...
<p>Visio has the ability to reverse engineer UML from your solution. You can find more information <a href="http://office.microsoft.com/en-us/visio/HP815507451033.aspx" rel="nofollow noreferrer">here</a>. It's not clear to me whether you can include the .Net assemblies, however -- since they are not really in your so...
37,502
<p>I have a user that want to be able to select a textbox and have the current text selected so that he doesn't have to highlight it all in order to change the contents. </p> <p>The contents need to be handle when enter is pushed. That part I think I have figured out but any suggestions would be welcome. </p> <p>Th...
<p>Hook into the KeyPress event on the TextBox, and when it encounters the Enter key, run your hardware setting code, and then highlight the full text of the textbox again (see below) - Windows will take care of clearing the text with the next keystroke for you.</p> <pre><code>TextBox1.Select(0, TextBox1.Text.Length);...
<p>OK, are you sure that is wise? I am picturing two scenarios here:</p> <ol> <li>There is a default button on the form, which is "clicked" when enter is pushed".</li> <li>There is no default button, and you want the user to have to press enter, regardless.</li> </ol> <p>Both of these raise the same questions:</p> <...
3,683
<p>When I purchased my China made Anet A8 printer, it came with the ball bearing style linear bearings for the 8mm guide rods. While pulling parts out of the box and putting them together, I noticed several of the small ball bearings fell out of their respective holders. At the time, I really didn't know what to think ...
<p>According to <a href="https://www.igus.eu/wpck/19864/drylin_plasticvsmetal" rel="noreferrer">igus commercial documentation</a>, these bushings:</p> <ul> <li>do not need any kind of lubrication,</li> <li>are not susceptible to humidity (but your steel rods might) </li> <li>work seamlessly in presence of dust (it get...
<p>In addition to <a href="https://3dprinting.stackexchange.com/a/6741/5740">this answer</a> and addressing <code>Anything else I'm not thinking of to worry about?</code> I would like to add that you should take care in installing the plastic bearings in suitable housings. It is best to lower the mass of the carriages ...
1,013
<p>Currently I am hosting a Django app I developed myself for my clients, but I am now starting to look at selling it to people for them to host themselves.</p> <p>My question is this: How can I package up and sell a Django app, while protecting its code from pirating or theft? Distributing a bunch of .py files doesn'...
<p>Don't try and obfuscate or encrypt the code - it will never work.</p> <p>I would suggest selling the Django application "as a service" - either host it for them, or sell them the code <em>and support</em>. Write up a contract that forbids them from redistributing it.</p> <p>That said, if you were determined to obf...
<p>One thing you might want to consider is what FogBugz does. Simply include a small binary (perhaps a C program) that is compiled for the target platforms and contains the code to validate the license. </p> <p>This way you can keep the honest people honest with minimal headache on your part.</p>
19,930
<p>What's the best way to detect an application crash in XP (produces the same pair of 'error' windows each time - each with same window title) and then restart it?</p> <p>I'm especially interested to hear of solutions that use minimal system resources as the system in question is quite old. </p> <p>I had thought of ...
<p>Best way is to use a named <a href="http://msdn.microsoft.com/en-us/library/ms684266(VS.85).aspx" rel="noreferrer">mutex</a>.</p> <ol> <li>Start your application.</li> <li>Create a new named mutex and take ownership over it</li> <li>Start a new process (process not thread) or a new application, what you preffer.</l...
<p>I realize that you're dealing with Windows XP, but for people in a similar situation under Vista, there are new <a href="http://msdn.microsoft.com/en-us/library/aa373347.aspx" rel="nofollow noreferrer">crash recovery API</a>s available. <a href="http://community.bartdesmet.net/blogs/bart/archive/2006/11/11/Windows-...
10,348
<p>I have inherited a django+fastcgi application which needs to be modified to perform a lengthy computation (up to half an hour or more). What I want to do is run the computation in the background and return a "your job has been started" -type response. While the process is running, further hits to the url should retu...
<p>Maybe you could look at the problem the other way around.</p> <p>Maybe you could try <a href="http://code.google.com/p/django-queue-service/" rel="nofollow noreferrer">DjangoQueueService</a>, and have a "daemon" listening to the queue, seeing if there's something new and process it.</p>
<p>Maybe you could look at the problem the other way around.</p> <p>Maybe you could try <a href="http://code.google.com/p/django-queue-service/" rel="nofollow noreferrer">DjangoQueueService</a>, and have a "daemon" listening to the queue, seeing if there's something new and process it.</p>
26,989
<p>I realize that this could probably be done easier in any number of other scripting languages but started to do it quick in cmd and now Im curious.</p> <p>Looking to start a process at an offset to the time that another process started. Lets say 5 minutes to keep it simple. Is there a way to add to the %TIME% vari...
<p>I just typed <code>set/?</code> and discovered cmd is much better than old bat... :-)</p> <pre><code>set h=%TIME:~0,2% set m=%TIME:~3,2% set/a m2="m+5" set t2=%h%:%m2% set t2 </code></pre> <p>Obviously, you can get 62 minutes, etc., I let you do the extra math... :-D</p>
<p>copy.cmd:</p> <pre><code>set hr=%TIME:~0,2% if %hr% leq 9 set hr=0%hr:~1,1% set mydate=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%-%hr%%TIME:~3,2%%TIME:~6,2% copy file.txt file-%mydate%.txt pause </code></pre>
38,610
<p>I find it much more difficult to manage your session in a desktop application, because you cannot take advantage of such a clear bondary like HttpContext. So how do you manage your session lifetime to take advantage of lazy loading but without having one session open for the entire application?</p>
<p>Ayende has recently written <a href="http://msdn.microsoft.com/en-us/magazine/ee819139.aspx" rel="noreferrer">a great article on the subject in MSDN</a>.</p>
<p>Maybe we can think of a Command pattern set up. Each significative event will feed and trigger a Command, and Execute it. The base AbstractCommand.Execute() implementation is in charge of initializing the session, wrapping the transaction, calling the concrete SomeCommand._Execute() implementation and closing all th...
11,588
<p>I have mixed data i nvarchar column (words and numbers). Which is fastest way to sort data in this column in Numeric Order.</p> <p>Result example:</p> <ul> <li>1</li> <li>2</li> <li>3</li> <li>...</li> <li>10</li> <li>11</li> <li>...</li> <li>aaaa</li> <li>aaab</li> <li>b</li> <li>ba</li> <li>ba</li> <li>...</li> ...
<p>Use this:</p> <pre><code>ORDER BY CASE WHEN ISNUMERIC(column) = 1 THEN 0 ELSE 1 END, CASE WHEN ISNUMERIC(column) = 1 THEN CAST(column AS INT) ELSE 0 END, column </code></pre> <p>This works as expected.</p> <hr> <p><strong>Note</strong>: You say <em>fastest way</em>. This sql was fast for me to produc...
<p>Cast it. </p> <pre><code>SELECT * FROM foo ORDER BY CAST(somecolumn AS int); </code></pre> <p>Been a while since I've touched SQL Server, so my syntax might be entirely incorrect though :)</p>
16,769
<p>Is there a quick-and-dirty way to tell programmatically, in shell script or in Perl, whether a path is located on a remote filesystem (nfs or the like) or a local one? Or is the only way to do this to parse /etc/fstab and check the filesystem type?</p>
<p><code>stat -f -c %T &lt;filename&gt;</code> should do what you want. You might also want <code>-l</code></p>
<p>On some systems, the device number is negative for NFS files. Thus,</p> <pre><code>print "remote" if (stat($filename))[0] &lt; 0 </code></pre>
37,904
<p>I'm a LINQ to XML newbie, and a KML newbie as well; so bear with me. </p> <p>My goal is to extract individual Placemarks from a KML file. My KML begins thusly:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Document xmlns="http://earth.google.com/kml/2.0"&gt; ...
<p>This works for me in C#:</p> <pre class="lang-cs prettyprint-override"><code>XDocument doc = XDocument.Load(@"TheFile.kml"); var q = doc.Descendants().Where(x =&gt; x.Name.LocalName == "Placemark"); </code></pre>
<p>You may need to add a namespace to the XElement name</p> <pre><code>Dim ns as string = "http://earth.google.com/kml/2.0" dim foo = Kml.Descendants(ns + "Document") </code></pre> <p>ignore any syntax errors, I work in c#</p> <p>You'll find there can be a difference in the <code>XElement.Name</code> vs <code>XElem...
18,260
<p>I want to print a part from Thingiverse. In the description, the creater writes that he used SBS to print it. I did some research because I never heard of SBS. I found a description on Filaments.directory that describes it as:</p> <blockquote> <p>Poly(styrene-butadiene-styrene) is a hard, durable rubber that is comm...
<p>As you found and according to this site, SBS is a <a href="https://www.pslc.ws/macrog/sbs.htm" rel="nofollow noreferrer">Styryne-Butadiene</a> polymer that only contains Styrene and Butadiene chains interlinked. This is similar to ABS, but not identical.</p> <p>Some people have access to filament manufacturing machi...
<p>This response might be way late but no, SBS is not a typo. <a href="http://generalpolymers.net/sbs.cfm" rel="nofollow noreferrer">Here are the info</a>:</p> <blockquote> <p><strong>SBS (styrene-butadiene-styrene)</strong></p> <p>Poly (styrene-butadiene-styrene) or SBS, is a hard rubber that's used to modify asphalt,...
1,754
<p>I've been using NetBeans as the XDebug interactive debugging client. But seems like it only supports attaching debuggers to scripts that are invoked via Firefox. I want to step through the request parse script when it's invoked via cURL.</p>
<p>I figured out the answer. First I attached a debugger by right-clicking on the wordpress project in netbeans and choosing "debug". This will open the blog in firefox with the "XDEBUG_SESSION_START=netbeans-xdebug" param included in the url (e.g. "<a href="http://localhost/wordpress/?XDEBUG_SESSION_START=netbeans-xde...
<p>Related XDebug docs: <a href="http://www.xdebug.org/docs/remote#browser_session" rel="nofollow noreferrer">http://www.xdebug.org/docs/remote#browser_session</a></p>
48,184
<p>I am working on a web application and I have run into the following situation.</p> <pre><code>Dim a as Object Dim i as Integer = 0 Try For i=1 to 5 a = new Object() 'Do stuff ' a = Nothing Next Catch Finally a = Nothing End Try </code></pre> <p>Do i need to do the a=Not...
<p>In .NET, you generally do not <strong>need</strong> to set a variable reference = <code>Nothing</code> (<code>null</code> in C#). The garbage collector will clean up, eventually. The reference itself will be destroyed when it goes out of scope (either when your method exits or when the object of this class is finali...
<p>The GC will clean it up.</p>
21,150
<p>My ASP.NET always starts like this with the internal server: <a href="http://localhost:50793/Website/" rel="nofollow noreferrer">http://localhost:50793/Website/</a></p> <p>I use FckEditor which points to <a href="http://localhost:50793/fckeditor" rel="nofollow noreferrer">http://localhost:50793/fckeditor</a></p> <...
<p>First thing you will need to do is compress and watermark the images before uploading them to the server. Then present those to the user. This will take the least CPU resources since they images will be static.</p> <p>I personally would then crop the images for the full size versions and put them up along side the ...
<p>I'd use <a href="http://aws.amazon.com/resources/" rel="nofollow noreferrer">S3</a> for storage. Create two buckets (public protected), give out url to the protected bucket's images once you have authorized the user to download them. S3 Urls can be made restful with an expiration date.</p> <p>With 15Mb images you...
48,964
<p>How can I create a new database from my C# application?</p> <p>I'm assuming once I create it, I can simply generate a connection string on the fly and connect to it, and the issue all the CREATE TABLE statements.</p>
<p><a href="http://support.microsoft.com/kb/307283" rel="noreferrer">KB307283</a> explains how to create a database using ADO.NET.</p> <p>From the article:</p> <pre><code>String str; SqlConnection myConn = new SqlConnection ("Server=localhost;Integrated security=SSPI;database=master"); str = "CREATE DATABASE MyDatab...
<p>CREATE DATABASE works</p>
6,125
<p>I've been searching and can't find the download files on opengl.org. can someone please point me to the right direction?</p>
<p>OpenGL is just a standard. The implementations come with your graphics card drivers and are exposed using WGL extensions in Windows. There is a 'standard' implementation in the platform SDK that is accessed by including the OpenGL headers and the windows header, but this is a basic version (1.1 in XP. I think it's 1...
<p>Windows (well, Visual Studio at least) comes with opengl, but only the older v1.1 - just </p> <pre><code>#include &lt;windows.h&gt; #include &lt;GL/gl.h&gt; #include &lt;GL/glu.h&gt; </code></pre> <p>and link with opengl32.lib, and glu32.lib and you should be ok (its been a while, I may have missed a bit in the...
17,855
<p>Do you think that writing about software (i.e. having a blog) and speaking on software (and concepts) make you a better programmer?</p>
<p>Statistically speaking yes. You only retain about 20% of what you read and hear, but 80% of what you teach.</p> <p>By writing about something or teaching about it, you force yourself to understand the concepts on a much deeper level.</p> <p><strong>UPDATE:</strong></p> <p>I wanted to update this with some links t...
<p>Absolutely, for one simple reason: It challenges your preconditions. You could write an article about how perfect .NET is for a given situation, only to find someone has used it, and it turned out badly.</p>
12,465
<p>One of the articles I really enjoyed reading recently was <a href="http://blog.last.fm/2008/08/01/quality-control" rel="nofollow noreferrer">Quality Control by Last.FM</a>. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't be...
<p>Usually you'll use an <a href="http://www.google.com/search?q=HTTPHandler+ASP.NET&amp;spell=1" rel="noreferrer">HTTP Handler</a> for this. Given a request for...</p> <blockquote> <p><a href="http://www.yoursite.com/sitemap.axd" rel="noreferrer">http://www.yoursite.com/sitemap.axd</a></p> </blockquote> <p>...your...
<p>Custom handler to generate the sitemap. </p>
3,077
<p>When the "New" menu item on a Document Library expands the default seems to be to list the document templates for that list and the "New folder" as the final element (if "New folder" has not been disabled). I have added a new custom menu item but it is displayed after "New folder" and I would like it to be shown at...
<p>The only way that I know to do this is to use JavaScript to adjust the order of the items by manipulating the DOM.</p> <p>If that's something you would consider, then I have a utility that will help: <a href="http://www.codeplex/ShUIE" rel="nofollow noreferrer">http://www.codeplex.com/ShUIE/</a></p> <p>You can use...
<p>The only way that I know to do this is to use JavaScript to adjust the order of the items by manipulating the DOM.</p> <p>If that's something you would consider, then I have a utility that will help: <a href="http://www.codeplex/ShUIE" rel="nofollow noreferrer">http://www.codeplex.com/ShUIE/</a></p> <p>You can use...
45,209
<p>I am testing a web app that writes cookies to subdomain.thisdomain.com and several subfolders within that. I'm looking for JavaScript that I can put into a bookmarklet that will delete all cookies under that subdomain, regardless of the folder in which they exist.</p> <p>Any ideas?</p>
<p>Derived from <a href="https://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript#179514">my answer here</a>:</p> <pre><code>javascript:new function(){var c=document.cookie.split(";");for(var i=0;i&lt;c.length;i++){var e=c[i].indexOf("=");var n=e&gt;-1?c[i].substr(0,e):c[i];document.cookie=n+"=;...
<p>I would recommend <a href="https://addons.mozilla.org/en-US/firefox/addon/6683" rel="nofollow noreferrer">Firecookie</a> extension to Firebug.</p>
21,483
<p>How do I go about positioning a JDialog at the center of the screen?</p>
<p>In Java 1.4+ you can do:</p> <pre><code>final JDialog d = new JDialog(); d.setSize(200,200); d.setLocationRelativeTo(null); d.setVisible(true); </code></pre> <p>Or perhaps (pre 1.4):</p> <pre><code>final JDialog d = new JDialog(); d.setSize(200, 200); final Toolkit toolkit = Toolkit.getDefaultToolkit(); final Dim...
<p>AFAIK you can pass a GraphicEnvironment to each JDialog/JFrame/JWindow constructor. This object describes the monitor to use.</p>
26,212
<p>When I print parts in ABS, acetone vapour smoothing is a good technique to get a smooth finish. Is there an equivalent solvent or process for parts printed in ASA? Ideally I'm looking for something as easy to obtain as acetone, and not so awful a chemical that I wouldn't want to work with it, but I'd still be curiou...
<p><a href="https://en.wikipedia.org/wiki/Acrylonitrile_styrene_acrylate" rel="nofollow noreferrer">ASA</a> is Acrylonitrile styrene acrylate. According to Wikipedia:</p> <blockquote> <p>ASA can be solvent-welded, using e.g. cyclohexane, 1,2-dichloroethane, methylene chloride, or 2-butanone. Such solvents can also join...
<p>From <a href="https://www.simplify3d.com/support/materials-guide/asa/" rel="nofollow noreferrer">Simplify3D - ASA</a>:</p> <blockquote> <p>ASA can be smoothed using controlled exposure to acetone vapors (a process called “vapor smoothing”).</p> </blockquote>
1,392
<p>A project I'm working on requires serializing a data structure before shutting down and restores its state from this serialized data when it start up again.</p> <p>Last year, we were building for .NET 1.1, and ran into a tricky issue where</p> <ul> <li>our code ran on .NET 2.0</li> <li>a customer upgraded with som...
<p>The chances are low (but not zero!) that there will be changes between framework versions. The intention would be that you should be able to use binary serialization and remoting to communicate between a client and a server running different framework versions. The incompatibility between .NET 1.x and 2.0 <a href=...
<p>You do not have to use XML in order to gain higher flexibility and versioning.</p> <p>I have used Simon Hewitt's open source library, see <em><a href="https://www.codeproject.com/Articles/16017/Optimizing-Serialization-in-NET-part" rel="nofollow noreferrer">Optimizing Serialization in .NET - part 2</a></em> instead...
24,919
<p>I have created a form in a WSS 3.0 site. There are a number of drop-down lists on the form. Is there a way to control the values in one drop-down based on a selected value in a previous drop down?</p>
<p>This type of question leads more to opinions than to hard and fast facts, but I would say that in this case it's definitely OK to use tables -- you're wanting a tabular display of information.</p> <p>Just use the table tag and don't let people make you feel guilty for it :-)</p>
<p>What everyone says is "you should only use tables for tabular data". So ... what does that mean?</p> <p>Here's my criterion for when something actually is tabular data: when you can only know what something is/does by reference to its <em>coordinates</em>, its position in relation to column and row headers. </p> <...
42,922
<p>There are a few ways to get class-like behavior in javascript, the most common seem to be prototype based like this:</p> <pre><code>function Vector(x, y, x) { this.x = x; this.y = y; this.z = z; return this; } Vector.prototype.length = function () { return Math.sqrt(this.x * this.x ... ); } </code>...
<p>Assigning functions to the prototype is better (for public methods) because all instances of the class will share the same copy of the method. If you assign the function inside the constructor as in the second example, every time you create a new instance, the constructor creates a new copy of the length function an...
<p>I'm a big fan of using <a href="http://ejohn.org/blog/simple-javascript-inheritance/" rel="nofollow noreferrer">John Resig's library</a> for this. Lightweight, straight-forward, and you already know how to use it if you're familiar with the 'usual' object-oriented style.</p>
2,823
<p>As a side project I'm currently writing a server for an age-old game I used to play. I'm trying to make the server as loosely coupled as possible, but I am wondering what would be a good design decision for multithreading. Currently I have the following sequence of actions:</p> <ul> <li>Startup (creates) -> </li> <...
<p>use an event stream/queue and a thread pool to maintain the balance; this will adapt better to other machines which may have more or less cores</p> <p>in general, many more active threads than you have cores will waste time context-switching</p> <p>if your game consists of a lot of short actions, a circular/recycl...
<p>I think the question you should be asking is not if 200 as a general thread number is good or bad, but rather how many of those threads are going to be active.</p> <p>If only several of them are active at any given moment, while all the others are sleeping or waiting or whatnot, then you're fine. Sleeping threads, ...
49,123
<p>I'm writing a query for an application that needs to list all the products with the number of times they have been purchased.</p> <p>I came up with this and it works, but I am not too sure how optimized it is. My SQL is really rusty due to my heavy usage of ORM's, But in this case a query is a much more elegant sol...
<p>I'm not sure about the "(SELECT *" ... business.</p> <p>This executes (always a good start) and I think is equivalent to what was posted.</p> <pre><code>SELECT products.id, products.long_name AS name, count(oi.order_id) AS sold FROM products LEFT OUTER JOIN orderitems AS oi INNER JOIN ...
<p>Well you have "LEFT OUTER JOIN" that can be a performance issue depending on your Database. Last time I remember it caused hell on MySQL, and it doesn't exist in SQLite. I think Oracle can handle it ok, and I guess DB and MSSQL too.</p> <p>EDIT: If I remember correctly LEFT OUTER JOIN can be orders of magnitude slo...
19,526
<p>I'm looking to use procedurally-generated sound and music in a Flash program I'm writing. I haven't found anything in the ActionScript 3.0 reference manual that shows how to do this. Is this possible? Have any third-party tools been developed that can do this? Or can Flash/ActionScript communicate with external ...
<p>The ability to play dynamically generated/modified sound is new to Flash 10, so make sure you're using the newest version of the AS3 reference, or you won't see the necessary APIs.</p> <p>As for examples, check the docs on <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/media/Sound.html#event:sampleDat...
<p>I found this article on the Adobe Developer Connection site: <a href="http://www.adobe.com/devnet/flash/articles/dynamic_sound_generation.html" rel="nofollow noreferrer">Generating sounds dynamically in Flash Player 10</a>. I just skimmed it, but it looks like it's based on ways you can tweak a sample.</p> <p>And <...
42,110
<p>I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to build and test first. </p>
<p>Perforce has Python wrappers around their C/C++ tools, available in binary form for Windows, and source for other platforms:</p> <p><a href="http://www.perforce.com/perforce/loadsupp.html#api" rel="noreferrer">http://www.perforce.com/perforce/loadsupp.html#api</a></p> <p>You will find their documentation of the sc...
<p>You may want to check out the P4Python module. It's available on the perforce site and it makes things very simple.</p>
22,276
<p>I have an object graph serialized to xaml. A rough sample of what it looks like is:</p> <pre><code>&lt;MyObject xmlns.... &gt; &lt;MyObject.TheCollection&gt; &lt;PolymorphicObjectOne .../&gt; &lt;HiImPolymorphic ... /&gt; &lt;/MyObject.TheCollection&gt; &lt;/MyObject&gt; </code></pre> <p>I...
<p>I am using the <code>GacInstall</code> to publish my assemblies, however once installed into the gac, I sometimes delete my ‘temporary’ copy of the assemblies.</p> <p>And then, if I ever wanted to uninstall the assemblies from the gac I do not have the files at the original path. This is causing a problem since I c...
<p>I am not exactly sure about it but I believe GacRemove should do the same thing as gacutil /u. So, it should be the path of your DLL. However it doesn't have to be the same DLL file. Copy of the original should suffice since what counts is the uniqueID of the DLL.</p>
6,773