instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm trying to determine if there's a way in Visual Basic 2008 (Express edition if that matters) to do inline collection initialization, a la JavaScript or Python:</p> <pre><code>Dim oMapping As Dictionary(Of Integer, String) = {{1,"First"}, {2, "Second"}} </code></pre> <p>I know Visual Basic 2008 supports array in...
<p><a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET#Visual_Basic_2008_.28VB_9.0.29" rel="nofollow noreferrer">Visual Basic 9.0</a> doesn't support this yet. However, <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET#Visual_Basic_2010_.28VB_10.0.29" rel="nofollow noreferrer">Visual Basic 10.0</a> <a href="h...
<p>Here are <a href="https://msdn.microsoft.com/en-us/library/dd293617.aspx" rel="noreferrer">VB collection initializers</a> using the <strong>From</strong> keyword. (Starting with Visual Studio 2010)</p> <p><strong>List:</strong></p> <pre><code>Dim list As New List(Of String) From {"First", "Second"} </code></pre> ...
11,137
<p>On Windows I have a problem I never encountered on Unix. That is how to get a thread to sleep for less than one millisecond. On Unix you typically have a number of choices (sleep, usleep and nanosleep) to fit your needs. On Windows, however, there is only <em>Sleep</em> with millisecond granularity. </p> <p>On Unix...
<p>This indicates a mis-understanding of sleep functions. The parameter you pass is a <em>minimum</em> time for sleeping. There's no guarantee that the thread will wake up after exactly the time specified. In fact, threads don't "wake up" at all, but are rather chosen for execution by the OS scheduler. The scheduler m...
<p>On Windows the use of <code>select</code> forces you to include the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms740673(v=vs.85).aspx" rel="nofollow noreferrer">Winsock</a> library which has to be initialized like this in your application:</p> <pre><code>WORD wVersionRequested = MAKEWORD(1,0)...
11,067
<p>I'd like to know how to grab the Window title of the current active window (i.e. the one that has focus) using C#. </p>
<p>See example on how you can do this with full source code here:</p> <p><a href="http://www.csharphelp.com/2006/08/get-current-window-handle-and-caption-with-windows-api-in-c/" rel="noreferrer">http://www.csharphelp.com/2006/08/get-current-window-handle-and-caption-with-windows-api-in-c/</a></p> <pre><code>[DllImpor...
<p>you can use process class it's very easy. use this namespace </p> <pre><code>using System.Diagnostics; </code></pre> <p>if you want to make a button to get active window.</p> <pre><code>private void button1_Click(object sender, EventArgs e) { Process currentp = Process.GetCurrentProcess(); ...
14,126
<p>ASP.Net 3.5 running under IIS 7 doesn't seem to allow this out of the box.</p> <pre><code> if (!EventLog.SourceExists("MyAppLog")) EventLog.CreateEventSource("MyAppLog", "Application"); EventLog myLog = new EventLog(); myLog.Source = "MyAppLog"; myLog.WriteEntry("Message"...
<p>This is part of windows security since windows 2003.</p> <p>You need to create an entry in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application Make sure that network service or the account you impersonate has permission to this registry key.</p> <p>@CheGueVerra's link: <a h...
<p>Right click the application and choose "Run as Administrator"</p>
36,338
<p>How can I transform a time value into YYYY-MM-DD format in Java?</p> <pre><code>long lastmodified = file.lastModified(); String lasmod = /*TODO: Transform it to this format YYYY-MM-DD*/ </code></pre>
<p>Something like:</p> <pre><code>Date lm = new Date(lastmodified); String lasmod = new SimpleDateFormat("yyyy-MM-dd").format(lm); </code></pre> <p>See the javadoc for <a href="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html" rel="noreferrer">SimpleDateFormat</a>.</p>
<pre><code>Date d = new Date(lastmodified); DateFormat form = new SimpleDateFormat("yyyy-MM-dd"); String lasmod = form.format(d); </code></pre>
28,028
<p>How do you use enums in Oracle using SQL only? (No PSQL)</p> <p>In MySQL you can do:</p> <pre><code>CREATE TABLE sizes ( name ENUM('small', 'medium', 'large') ); </code></pre> <p>What would be a similar way to do this in Oracle?</p>
<p>Reading a bit about the <a href="http://dev.mysql.com/doc/refman/5.0/en/enum.html" rel="noreferrer">MySQL enum</a>, I'm guessing the closest equivalent would be a simple check constraint</p> <pre><code>CREATE TABLE sizes ( name VARCHAR2(10) CHECK( name IN ('small','medium','large') ) ); </code></pre> <p>but that...
<p>At this link you can find an alternative solution/workaround for Oracle, inspired by C language enums: <a href="http://www.petefinnigan.com/weblog/archives/00001246.htm" rel="nofollow">http://www.petefinnigan.com/weblog/archives/00001246.htm</a></p> <p>Shortly put, Pete suggests to define some integer constants and...
24,895
<p>Our website uses Perl to provide a simple mechanism for our HR people to post vacancies to our website. It was developed by a third party, but they have been long since kicked into touch, and sadly we do not have any Perl skills in-house. This is what happens when Marketing people circumvent their in-house IT team!<...
<p>A really simple way would be:</p> <pre><code>$sth-&gt;execute(); my $first = 1; while (my $ref = $sth-&gt;fetchrow_hashref()) { if( $first ) { print "We currently have the following vacancies:\n"; $first = 0; } my $temp = $template; ... } if( $first ) { print "No vacancies foun...
<p>Says perldoc DBI:</p> <pre><code> For a non-"SELECT" statement, "execute" returns the number of rows affected, if known. If no rows were affected, then "execute" returns "0E0", which Perl will treat as 0 but will regard as true. </code></pre> <p>So the answer is to check the return value of $sth->execute():</p> ...
36,974
<p>I've got nutch and lucene setup to crawl and index some sites and I'd like to use a .net website instead of the JSP site that comes with nutch.</p> <p>Can anyone recommend some solutions?</p> <p>I've seen solutions where there was an app running on the index server which the .Net site used remoting to connect to.<...
<p>Instead of using Lucene, you could use <a href="http://lucene.apache.org/solr/" rel="nofollow noreferrer">Solr</a> to index with nutch (see <a href="http://blog.foofactory.fi/2007/02/online-indexing-integrating-nutch-with.html" rel="nofollow noreferrer">here</a>), then you can connect very easily to Solr using one o...
<p>Instead of using Solr, I wrote a java based indexer that runs in a cron job, and a java based web service for querying. I actually didn't index pages so much as different types of data that the .net site uses to build the pages. So there's actually 4 different indexes each with a different document structure that ca...
25,036
<p>The software base I am developing for uses a signficant amount of yacc which I don't need to deal with. Some times I think it would be helpful in understanding some problems I find but most of the time I can get away with my complete ignorance of yacc.</p> <p>My question are there enough new projects out there that...
<p>Yes, these tools are worth learning if you ever need to create or modify code that parses a grammar. </p> <p>For many years the de facto tool for generating code to parse a grammar was yacc, or its GNU cousin, bison.</p> <p>Lately I've heard there are a couple of new kids on the block, but the principle is the sa...
<p>We are writing new yacc code at my company for shipping products. Yes, this stuff is still used.</p>
43,115
<p>In trying to understand 3D printers, I have watched some YouTube videos where the crafters make items with hinges. That in itself blows my mind. It is hard to grasp how something with moving parts can be printed. But specifically I am wondering if the concept can be extended to food printers to make, for example, a ...
<p>No, M108 does not do that. You are looking for <strong>T#</strong>, where # is the tool position you want:</p> <pre><code>T1 ; switch to tool position 1 T3 ; switch to tool position 3 </code></pre> <p>This tells the processor to send all heating, cooling and flow commands to this tool until another tool change ...
<p>As @tbm0115 has mentioned - it differs. Your <code>M108 T{index of tool}</code> command is perfectly fine on some FlashForge printers, a company known for its different sorts of proprietary code. It is indeed used for tool changing here.</p> <p>While on the common Marlin firmware (e.g. used on the popular Creality E...
539
<p>I would like a Win machine to tunnel into an SSH server whenever the machine starts up. I also want the win machine to reboot the SSH program if it ever crashes. The lighterweight &amp; more stable the SSH program, the more happier I am.</p> <p>What options do I have with this? </p>
<p>Look at using srvany to launch the SSH client as a windows service. Then you can set the service to start up automatically when Windows start.</p> <p>Essentially, srvany.exe will let you launch any program from the windows service control manager.</p> <p><a href="http://support.microsoft.com/kb/137890" rel="noref...
<p>If you desire <strong>program restarting</strong> in case of disconnection, the best I know should be a software recommendation: <a href="http://www.coretechnologies.com/products/AlwaysUp/" rel="nofollow">AlwaysUp</a> (not free on May 2015). </p> <p>It is still <strong>lighweight</strong>, 4.2MB installer and a no...
40,274
<p>I've added a custom soap header <code>&lt;MyApp:FOO&gt;</code> element to the <code>&lt;soap:Header&gt;</code> element and the requirments states that i must sign this element , how would one do that? <code>&lt;MyApp:FOO&gt;</code> contains a number of things (username, preferences, etc) that identifies a user on hi...
<p>My current version of SecureMessage seems to do the trick..</p> <pre><code> public override void SecureMessage(SoapEnvelope envelope, Security security) { //EncryptedData data = new EncryptedData(userToken); SignatureReference ssekSignature = new SignatureReference(); MessageSignature...
<p>Including supplementary articles from MSDN</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa529237.aspx" rel="nofollow noreferrer"><strong>How to: Add an Id Attribute to a SOAP Header</strong></a></p> <p><a href="http://msdn.microsoft.com/en-us/library/aa528813.aspx" rel="nofollow noreferrer"><strong>How ...
18,390
<p>I use svn:externals to reference several open source projects. I then make some local changes to one of these external projects. Obviously I cannot check these changes back into the external repository. How do I keep these changes in my repository while still maintaining the ability to easily incorporate external ch...
<p>Just in case it's still relevant, and for future users: I think you want to maintain your changes to the external project in a <a href="http://svnbook.red-bean.com/en/1.5/svn.advanced.vendorbr.html" rel="nofollow noreferrer">'vendor branch'</a>.</p> <ul> <li>import a copy of the external code into a separate projec...
<p>I support <a href="https://stackoverflow.com/questions/329843/external-repository-changes/1156028#1156028">jeroenh</a>'s answer above since you are using an "SVN Friendly" way to maintain external code. </p> <p>svk is not a solution as you cannot commit what you've changed to the external repos. If you use svk, you...
42,730
<p>Is it possible to detect a valid regular expression with another regular expression? If so please give example code below.</p>
<pre><code>/ ^ # start of string ( # first group start (?: (?:[^?+*{}()[\]\\|]+ # literals and ^, $ | \\. # escaped characters | \[ (?: \^?\\. | \^[^\\] | [^\\^...
<p>In Javascript:</p> <pre><code>SyntaxError </code></pre> <p>is thrown when an invalid regex is passed to evaluate.</p> <pre><code>// VALID ONE &gt; /yes[^]*day/ Out: /yes[^]*day/ // INVALID ONE &gt; /yes[^*day/ Out: VM227:1 Uncaught SyntaxError: Invalid regular expression: missing / </code></pre> <p>Here's the funct...
20,767
<p>How to move a sub directory from one directory to another, given that both are inside the same SVN repository? I am using tortoise SVN.</p>
<p>Select the folder/files that you want to move, then RIGHT-CLICK them and drag them to where you want to move them. A menu will come up with an option "<strong>SVN Move versioned files here</strong>"</p> <p>As clarified by <a href="https://stackoverflow.com/questions/264571/move-directory-across-svn-repository-usin...
<p>If you have renamed the parent folder before moving, you would see a "Cross/Not allowed" sign when moving. </p> <p>The workaround is to first move the child and then only re-name the parent (undo if you already renamed the parent). </p>
33,143
<p>Is there a clean, preferably standard method of trimming leading and trailing whitespace from a string in C? I'd roll my own, but I would think this is a common problem with an equally common solution.</p>
<p>If you can modify the string:</p> <pre><code>// Note: This function returns a pointer to a substring of the original string. // If the given string was allocated dynamically, the caller must not overwrite // that pointer with the returned value, since the original pointer must be // deallocated using the same alloc...
<p>Here is a function to do what you want. It should take care of degenerate cases where the string is all whitespace. You must pass in an output buffer and the length of the buffer, which means that you have to pass in a buffer that you allocate.</p> <pre><code>void str_trim(char *output, const char *text, int32 ma...
14,916
<p>I am working on creating a custom project template with Visual Studio 2008 Team System edition. I have also created a custom wizard for the custom template.</p> <p>So I have to update the vstemplate file to tell the template to use my custom wizard. But the archive is corrupted!</p> <p>7zip thinks folders within...
<p>You don't need to modify the contents of the archive to be flat.</p> <p>The trick is after editing the unzipped contents of the archive, instead of selecting the folder and zipping that, open the folder and select all the files (and folders if present), and zip those instead.</p> <p>This is what is preventing Visu...
<p>Same problem here. I solved it by using <code>&lt;ProjectItem&gt;MyFolder\MyFile.cs&lt;/ProjectItem&gt;</code> instead of <code>&lt;Folder&gt;...&lt;Folder&gt;</code>.</p> <p>PS: TargetFileName doesn't work for me in VS2008 + Windows7.</p>
33,628
<p>I've seen a number of examples that have a thread procedure that looks like this.</p> <pre><code> private void ThreadProc() { while (serviceStarted) { // do some work Thread.Sleep(new TimeSpan(0, 0, 5)); } Thread.CurrentThread.Abort(); } </code></...
<p>Calling <code>Thread.Abort()</code> does raise an exception, and if you're writing code that will be re-used (or part of a base library) it's difficult for other developers to handle <code>ThreadAbortExcpetion</code>s. </p> <p>It's explained in this article about <a href="http://msdn.microsoft.com/en-us/library/ms...
<p>Interesting question. But I would advise against it since such a statement would prevent the method from being reused easily.</p>
41,649
<p>I've worked with T-SQL for years but I've just moved to an organisation that is going to require writing some Oracle stuff, probably just simple CRUD operations at least until I find my feet. I'm not going to be migrating databases from one to the other simply interacting with existing Oracle databases from an Appli...
<p>The language difference listed so far are <strong>trivial</strong> compared to the logical differences. Anyone can lookup NVL. What's hard to lookup is </p> <p><strong>DDL</strong></p> <p>In SQL server you manipulate your schema, anywhere, anytime, with little or no fuss.</p> <p>In Oracle, we don't like DDL in st...
<p>If you're doing a one-off conversion, rather than trying to support two versions, you must look at <a href="http://www.oracle.com/technology/tech/migration/workbench/index_sqldev_omwb.html" rel="nofollow noreferrer">Oracle Migration Workbench</a>. This tool works with Oracle's SQLDeveloper (which you really should h...
6,316
<p>Let's say that you want to output or concat strings. Which of the following styles do you prefer?</p> <ul> <li><p><code>var p = new { FirstName = "Bill", LastName = "Gates" };</code></p></li> <li><p><code>Console.WriteLine("{0} {1}", p.FirstName, p.LastName);</code></p></li> <li><p><code>Console.WriteLine(p.FirstNa...
<p>Try this code.</p> <p>It's a slightly modified version of your code.<BR></p> <ol> <li>I removed Console.WriteLine as it's probably a few orders of magnitude slower than what I'm trying to measure.<BR></li> <li>I'm starting the Stopwatch before the loop and stopping it right after, this way I'm not losing precision i...
<p>Actually, I ran these tests yesterday, but it was getting late so I didnt put my responses.</p> <p>The bottom line seems that they take both the same time on average. I did the test over 100000 iterations.</p> <p>I'll try with StringBuilder as well, and I'll post the code and results when I get home.</p>
3,713
<p>I have a 100% valid Ajax model written in Javascript with a few inputs I use being, Get or Post method, What page to communicate with, What String to send to that page and What element on my own page I might be fiddling with when I receive my response. The problem is that, should I set the request to Asynchronous (H...
<p>Ho humm</p> <p>Outside of the onreadystatechange function I had a call for responsetext to check whether it existed yet, but aparently you can't do that if it doesn't exist yet so I just had to restructure some thigs. All is okay but this was the script that caused the problem</p> <pre><code>ajaxRequest(){ [.....
<p>Not sure if that's your case but I've just been struggling with this error for three hours until I found the problem. The web service class wasn't decorated with ScriptService attribute that allows methods to be called from client script! I wouldn't blame IE because IE is just strict on errors and reports everything...
49,796
<p>Why does <code>n</code> not equal to <code>8</code> in the following function?</p> <pre><code>void foo(char cvalue[8]) { int n = sizeof (cvalue); } </code></pre> <p>But <code>n</code> <em>does</em> equal to <code>8</code> in this version of the function:</p> <pre><code>void bar() { char cvalue[8]; int n = s...
<p>Because you can't pass entire arrays as function parameters in C. You're actually passing a pointer to it; the brackets are syntactic sugar. There are no guarantees the array you're pointing to has size 8, since you could pass this function any character pointer you want.</p> <pre><code>// These all do the same t...
<p>The size of the parameter on 32-bit systems will be 4 and on 64-bit systems compiled with -m64 will be 8. This is because arrays are passed as pointers in functions. The pointer is merely a memory address.</p>
7,146
<p>I have a method, which will accept a parameter of a JQuery Object and will calculate totals for a section. So if you give it a JQuery Object of a div containing the section it will calculate a total for it</p> <p>so you can do this:</p> <p>var $totalcompletion = CalculateSectionCompletion(jQuery("#Section1"));</p>...
<p>You can wrap any DOM element in $(..), as you do with $(document).</p> <p>So I think you should be able to </p> <pre><code>jQuery("div.SectionContainer").each( function(i, valueOfElement){ CalculateSectionCompletion($(valueOfElement)); }); </code></pre>
<p>You could also ignore the i and valueOfElement arguments altogether and use <strong>this</strong>.</p> <pre><code>jQuery("div.SectionContainer").each(function(){ CalculateSectionCompletion(jQuery(this)); }); </code></pre> <p>You could even make the CalculateSectionCompletion function wrap it's argument in the jQ...
46,783
<p>I've developed a "Proof of Concept" application that logs unhandled exceptions from an application to a bug-tracking system (in this case Team Foundation Server, but it could be ANY bug tracking system). A limitation of this idea is that I don't want duplicate Bug Items opened every time the same exception is throw...
<p>You could create a checksum hash of the stack trace and store that as an indexed column. That way the query to the Bug Store would be pretty fast to avoid duplicates on insert.</p>
<p>You could look at the source code for one of the existing open-source solutions that aggregate exceptions.</p> <p>For example: <a href="https://github.com/getsentry/sentry/tree/master/src/sentry" rel="nofollow">https://github.com/getsentry/sentry/tree/master/src/sentry</a></p> <p>It is not a simple problem and the...
36,307
<p>Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively complicated) work to do what seems like it should be pretty simple.</p>
<p>Here is the <a href="http://docs.python-requests.org/en/latest/" rel="noreferrer">Requests</a> way:</p> <pre><code>import requests r = requests.get('http://github.com', allow_redirects=False) print(r.status_code, r.headers['Location']) </code></pre>
<p>I second olt's pointer to <a href="http://www.diveintopython.org/http_web_services/redirects.html" rel="noreferrer">Dive into Python</a>. Here's an implementation using urllib2 redirect handlers, more work than it should be? Maybe, shrug.</p> <pre><code>import sys import urllib2 class RedirectHandler(urllib2.HTTPR...
13,575
<p>I have a custom aspx page loaded in a IFrame in one of the modules in MS CRM 4.0. This page basically has 6 textboxes (txtValue1, txtValue2 and so on..) with values in it. I want to access these values through javascript code either on the load event or save event. Does anybody know how to do it ? I tried couple of ...
<p>I know that in Ant, the junit task has options "haltonerror" and "haltonfailure" that controls this behavior.</p>
<p>I know that in Ant, the junit task has options "haltonerror" and "haltonfailure" that controls this behavior.</p>
22,869
<p>Given this HTML:</p> <pre><code>&lt;ul id="topnav"&gt; &lt;li id="topnav_galleries"&gt;&lt;a href="#"&gt;Galleries&lt;/a&gt;&lt;/li&gt; &lt;li id="topnav_information"&gt;&lt;a href="#"&gt;Information&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>And this CSS:</p> <pre class="lang-css prettyprint-overr...
<p>Try this:</p> <pre class="lang-css prettyprint-override"><code>#topnav { overflow:hidden; } #topnav li { float:left; } </code></pre> <p>And for IE you will need to add the following:</p> <pre class="lang-css prettyprint-override"><code>#topnav { zoom:1; } </code></pre> <p>Otherwise your floated &lt; ...
<p>An alternative to floating the elements left, is this:</p> <pre class="lang-css prettyprint-override"><code>#topnav li { display: inline; } </code></pre>
6,696
<p>In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more testable. (Some of the points refer to limitations of Rhino Mocks, a mocking framework for C#, but the rules may apply more generally as well.) Does anyone have any best practices that th...
<p>Definitely a good list. Here are a few thoughts on it:</p> <blockquote> <p><strong>Write the test first, then the code.</strong></p> </blockquote> <p>I agree, at a high level. But, I'd be more specific: "Write a test first, then write <em>just enough</em> code to pass the test, and repeat." Otherwise, I'd be af...
<p>Here's a another one that I thought of that I like to do.</p> <p>If you plan to run tests from the unit test Gui as opposed to from TestDriven.Net or NAnt then I've found it easier to set the unit testing project type to console application rather than library. This allows you to run tests manually and step throug...
15,108
<p>Note: I have extended my question as some of you mentioned that the question is not clear.</p> <p>I am using a RAMPS 1.4 board with an Arduino mega 2560. I need to drive a stepper motor as an extruder using either E0 or E1. I am using Repetier-Firmware and can drive the extruder (stepper motor) using the E0 (RAMPS ...
<p><strong>The edited question</strong> appears to mention that <strong>the actual extruders of the print head need to home / limit themselves</strong>. The answer is that this is not required. When operating direct or Bowden driven extruder setups, you know (or you can measure or find out experimentally) the distance ...
<p>I think the question has already been answered(if at all possible because the question is still not clear exactly what you mean), but let me try putting this a different way.</p> <p>You have to ask yourself what is homing and why are you doing it. The purpose of homing your axes is to set their 0 position in space....
876
<p>How do you create SQL Server 2005 stored procedure templates in SQL Server 2005 Management Studio?</p>
<p>Another little nugget that I think will help people developing and being more productive in their database development. I am a fan of stored procedures and functions when I develop software solutions. I like my actual CRUD methods to be implemented at the database level. It allows me to balance out my work betwee...
<p>You bring up <em>Template Explorer</em> using Ctrl+Alt+T or trough <em>View > Template Explorer</em>. Then you can right click tree nodes to add new Templates or new folders to organize your new templates.</p>
9,064
<p>What does the <code>explicit</code> keyword mean in C++?</p>
<p>The compiler is allowed to make one implicit conversion to resolve the parameters to a function. What this means is that the compiler can use constructors callable with a <strong>single parameter</strong> to convert from one type to another in order to get the right type for a parameter.</p> <p>Here's an example cla...
<p>Other answers are missing one important factor which I am going to mention here.</p> <p>Along with &quot;delete&quot; keyword, &quot;explicit&quot; allows you to control the way compiler is going to generate special member functions - default constructor, copy constructor, copy-assignment operator, destructor, move ...
14,735
<p>I've run into a few gotchas when doing C# XML serialization that I thought I'd share:</p> <ul> <li>You can't serialize items that are read-only (like KeyValuePairs)</li> <li>You can't serialize a generic dictionary. Instead, try this wrapper class (from <a href="http://weblogs.asp.net/pwelter34/archive/2006/05/03/4...
<p>I can't make comments yet, so I will comment on Dr8k's post and make another observation. Private variables that are exposed as public getter/setter properties, and do get serialized/deserialized as such through those properties. We did it at my old job al the time.</p> <p>One thing to note though is that if you ...
<blockquote> <p>Private variables/properties are not serialized in XML serialization, but are in binary serialization.</p> </blockquote> <p>I believe this also gets you if you are exposing the private members through public properties - the private members don't get serialised so the public members are all refer...
9,349
<p>I have a simple unordered list that I want to show and hide on click using the jQuery slideUp and slideDown effect. Everything seems to work fine, however in IE6 the list will slide up, flicker for a split second, and then disappear.</p> <p>Does anyone know of a fix for this?</p> <p>Thanks!</p>
<p>Apologies for the extra comment (I can't upvote or comment on Pavel's answer), but adding a DOCTYPE fixed this issue for me, and the slideUp/Down/Toggle effects now work correctly in IE7.</p> <p>See <a href="http://www.alistapart.com/articles/doctype/" rel="noreferrer">A List Apart</a> for more information on DOCTY...
<p>I posted a quick fix solution over at <a href="http://blog.clintonbeattie.com/how-to-solve-the-jquery-flickering-content-problem/" rel="nofollow noreferrer">http://blog.clintonbeattie.com/how-to-solve-the-jquery-flickering-content-problem/</a></p> <p>In short, add overflow:hidden to the containing element that you ...
13,660
<p>I've noticed that when generating a new C++ project using MS Visual Studio 2008, the <strong>Release</strong> build contains debugging symbols - specifically the following settings are enabled:</p> <ul> <li>The C++/General/Debug Information Format is set to <strong>Program Database</strong>.</li> <li>The Linker/Deb...
<p>We have turned on those settings in our commercial releases for years now with no apparent downside. The upsides are enormous,though. </p> <p>We have integrated a crash dump packager that packages the dump along with some other information and emails it (with the user's consent) to a company inbox. This has hel...
<p>The .exe will be slightly larger due to a reference to the .pdb file (i.e., an extra path). That's about it.</p>
26,849
<p>Ok, this is working on windows. My Java app is running and functioning normally</p> <pre><code>javac -classpath .;ojdbc14.jar -g foo.java java -classpath .;ojdbc14.jar foo </code></pre> <p>However, when I do the same thing on Unix I get this error: ojdbc14.jar: not found</p> <p>What am I doing wrong? I know...
<p>Use a colon (":") instead of a semicolon (";").</p> <p>See <a href="http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html" rel="nofollow noreferrer">Setting the class path (Solaris and Linux)</a> vs <a href="http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html" rel="nofollow n...
<pre><code>javac -classpath '.;ojdbc14.jar' -g foo.java java -classpath '.;ojdbc14.jar' foo </code></pre>
41,695
<p>We have a form that allows a user to dynamically add inputs for fields. For example if you have a form for tracking projects, you want to dynamically add tasks to that project. Just to clarify my language: you dynamically add inputs for the task field. The problem is, we have 50 of those fields. Our current solution...
<p>Thinking on from what @zachary suggested:</p> <p>Display the form as it was designed to the user with the default/ last saved number of fields. At the bottom of the form place a DropDownButton that has a + icon and the words Add Field (<strong>+ Add Field</strong>). </p> <p>Dropping down this button will show the ...
<p>Little + icon somewhere near the last task field with a link that says "Add new task". When clicked, new task field appears below current last task.</p>
18,447
<p>Given the following:</p> <pre><code>#light //any function returning bool * 'a let foo = let x = ref 10 fun () -&gt; x := !x - 1 if !x &lt;&gt; 0 then (true, x) else (false, x) while let (c,x) = foo() in c do print_any x;//can't access x, but would be convinen...
<p>I found a library in google code: <a href="http://code.google.com/p/php-email-address-validation/" rel="noreferrer">http://code.google.com/p/php-email-address-validation/</a></p> <p>Are there any others?</p>
<p>I'd recommend to look at the source code of Zend_Validate_EmailAddress [<a href="http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Validate/EmailAddress.php" rel="nofollow noreferrer">source</a>].</p> <p>Once you have your dependencies fixed, you can simply do the following:</p> <pre><code>$mail_va...
19,499
<p>I am designing a part with a material which can bear up to a certain stress. </p> <p>To keep the stress within the design limits, I need to ensure a certain surface of solid material per layer, in other words a minimum amount of extruded filament per layer and a smoothly changing infill ratio so that the infill can...
<p>I think you have a major XY problem. The amount of material per layer is not what determines the part strength. Unless additional material is placed in a manner that reinforces against the stress you're designing for, it's just wasted. Moreover, infill in particular is not terribly useful this way, as infill has to ...
<p>Very interesting idea! There may be a way to do this semi-automatically, but I believe it's not yet a part of any slicer.</p> <p>My suggestion would be:</p> <ul> <li>Export file as .stl (Fusion 360)</li> <li>Use a DLP slicer to create images of the layers (CHITUBox)</li> <li>Calculate the area of each of the image...
1,547
<p>I want to create an allocator which provides memory with the following attributes:</p> <ul> <li>cannot be paged to disk. </li> <li>is incredibly hard to access through an attached debugger</li> </ul> <p>The idea is that this will contain sensitive information (like licence information) which should be inaccessi...
<p>You can't really protect against memory access. You can probably prevent paging if you are running as an admin or as the system, but you cannot prevent the admin or system from reading your memory. Even if you could somehow completely block other processes from reading your memory (which you can't), another proces...
<p>@Derek: Oh, but with trusted computing, you can use <a href="http://en.wikipedia.org/wiki/Trusted_Computing#Memory_curtaining" rel="nofollow noreferrer">memory curtaining</a>! :-P&lt;/devils-advocate&gt;</p>
2,989
<p>How do you change controls' Z-order in MFC <strong>at design time</strong> - i.e. I can't use SetWindowPos or do this at runtime - I want to see the changed z-order in the designer (even if I have to resort to direct-editing the .rc code).</p> <p>I have an MFC dialog to which I am adding controls. If there is over...
<p>I think the control in front will be the last control that occurs in the rc file. In other words, the dialog editor will draw each control as it is encountered from top to bottom in the rc file, overlapping them when necessary.</p> <p>You can edit the rc file to reorder them, or you can change the tab order in the...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/a1yzfz6d(VS.80).aspx" rel="nofollow noreferrer">CWnd::SetWindowPos()</a> to control the Z order of your controls, without changing their position in the parent window.</p>
19,363
<p>In a form, I added an overload of ShowDialog(). In Visual Studio, this overload shows up in Intellisense as the third version. How can I make my overloaded function appear as #1 (i.e. the default)?</p>
<p>As far as I know, there is no way to control the order of overloads in the overload selection intellisense tip.</p>
<p>Not unless the number of parameters is less than the current #1 in the list, I believe. Ic ould be wrong, though - I often am. :)</p> <p>I am at a loss as to why you want this, though... </p> <ol> <li>It doesn't matter. and </li> <li>there are better ways to achieve what you are looking for, as answered in other ...
35,584
<p>Ok, there are a million regexes out there for validating an email address, but how about some basic email validation that can be integrated into a TSQL query for Sql Server 2005?</p> <p>I don't want to use a CLR procedure or function. Just straight TSQL.</p> <p>Has anybody tackled this already?</p>
<p><em>Very</em> basic would be:</p> <pre><code>SELECT EmailAddress, CASE WHEN EmailAddress LIKE '%_@_%_.__%' AND EmailAddress NOT LIKE '%[any obviously invalid characters]%' THEN 'Could be' ELSE 'Nope' END Validates FROM Table </code></pre> <p>This matches everything with an @ in the mi...
<p>From Tomalak's slelect</p> <pre><code>select 1 where @email not like '%[^a-z,0-9,@,.]%' and @email like '%_@_%_.__%' </code></pre>
28,447
<p><strong>Preface</strong></p> <p>I'm using the newly released Microsoft Virtual Earth SDK v6.2 which has built-in support for pushpin clustering. I realize there are custom ways of doing clustering where my question is easy to answer, but I'd like to leverage the built-in support as much as possible, so this questi...
<p>Just set the "default" value within your constructor.</p> <pre><code>public class Person { public Person() { this.FirstName = string.Empty; } public string FirstName { get; set; } } </code></pre> <p>Also, they're called Automatic Properties.</p>
<p>[DefaultValue("MyFirstName")] public string FirstName { get; set; }</p>
25,314
<p>Can you set the startup Project in the Visual Basic 6 IDE?</p> <p>I looked all through the Settings and can't find a way to do it.</p>
<p>I assume you have multiple projects in a Group e.g. a dll and a dependent exe and you want to set the exe as the 'start up' project. Do so this, select the exe project in the Project Explorer, right click and choose 'Set as Start Up' from the context menu. The 'start up' project's name will be shown as bold text in ...
<p>I'm not aware of a "startup Project" settting in VB6, but you can select the "Startup Object" by opening the Project menu, choosing the last menu item ("X properties", where X is the name of your project), and then selecting the General tab in the Project Properties window. The selector you seek is in the upper-righ...
46,758
<p>In C, are the shift operators (<code>&lt;&lt;</code>, <code>&gt;&gt;</code>) arithmetic or logical?</p>
<p>According to <a href="https://rads.stackoverflow.com/amzn/click/com/0131103628" rel="noreferrer" rel="nofollow noreferrer">K&amp;R 2nd edition</a> the results are implementation-dependent for right shifts of signed values.</p> <p><a href="http://en.wikipedia.org/wiki/Arithmetic_shift" rel="noreferrer">Wikipedia</a>...
<p>According to many <a href="/questions/tagged/c" class="post-tag" title="show questions tagged &#39;c&#39;" rel="tag">c</a> compilers:</p> <ol> <li><code>&lt;&lt;</code> is an arithmetic left shift or bitwise left shift.</li> <li><code>&gt;&gt;</code> is an arithmetic right shiftor bitwise right shift.</li> </ol>
2,918
<p>I have some function to find a value:</p> <pre><code>struct FindPredicate { FindPredicate(const SomeType&amp; t) : _t(t) { } bool operator()(SomeType&amp; t) { return t == _t; } private: const SomeType&amp; _t; }; bool ContainsValue(std::vector&lt;SomeType&gt;&amp; v, SomeType&amp; valu...
<p>The best solution is to use the <a href="http://www.keithschwarz.com/cs106l/fall2007/handouts/200_STL_Functional_Library.pdf" rel="noreferrer">STL functional library</a>. By deriving your predicate from <code>unary_function&lt;SomeType, bool&gt;</code> , you'll then be able to use the <code>not1</code> function, whi...
<p>As you are using it, you don't need the FindPredicate functor, since in the example you are only testing equality.</p> <pre><code>bool all_equal(std::vector&lt;SomeType&gt;&amp; v, SomeType&amp; valueToFind) { return v.end() == find_if(v.begin(), v.end(), std::bind1st (equal_to (), valueToFind) ); } bool all_no...
33,238
<p>Is it possible to use gcov for coverage testing of multi-threaded applications? </p> <p>I've set some trivial tests of our code-base up, but it would be nice to have some idea of the coverage we're achieving. If gcov isn't appropriate can anyone recommend an alternative tool (possible oprofile), ideally with some g...
<p>We've certainly used gcov to get coverage information on our multi-threaded application.</p> <p>You want to compile with gcc 4.3 which can do coverage on dynamic code.</p> <p>You compile with the <code>-fprofile-arcs -ftest-coverage</code> options, and the code will generate .gcda files which gcov can then process...
<p>I have not used gcov for multi-threaded coverage work. However, on MacOS the Shark tool from Apple handles multiple threads. It's primarily a profiler, but can do coverage info too.</p> <p><a href="http://developer.apple.com/tools/sharkoptimize.html" rel="nofollow noreferrer">http://developer.apple.com/tools/shar...
5,859
<p>I had svnserve configured to look at directory "Foo" for the repository it served. Now I changed the configuration from one repository to multiple repositories, all contained in one directory "Bar". I reconfigured svnserve to look at "Bar", but now my client can't find any repositories. What am I doing wrong? Do I n...
<p>Did you configure your client to use svn://svn-server/Foo ? (Assuming Foo and Foo2 are repositories in directory Bar, which you're serving)</p> <p>Since you're serving "Bar" now ("svnserve -r /repositories/Bar" instead of "svnserve -r /repositories/Bar/Foo") you should make a change on your client-side repository U...
<p>This <a href="http://svnbook.red-bean.com/en/1.0/ch06s03.html" rel="nofollow noreferrer">documentation</a> about svnserve may also come in handy for ya.</p>
30,183
<p>How would one create a Singleton class using PHP5 classes?</p>
<pre><code>/** * Singleton class * */ final class UserFactory { private static $inst = null; // Prevent cloning and de-serializing private function __clone(){} private function __wakeup(){} /** * Call this method to get singleton * * @return UserFactory */ public static...
<p>Here's my example that provides ability to call as $var = new Singleton() and also creating 3 variables to test if it creates new object: </p> <pre><code>class Singleton{ private static $data; function __construct(){ if ($this::$data == null){ $this-&gt;makeSingleton(); } ...
24,877
<p>I've been working with ASP.NET MVC for the last few weeks, learning as I go, from tutorials and mostly trial and error. </p> <p>I'm sorta groping in the dark, since I have no other experience with MVC frameworks and I'm just moving ahead blindly trying to figure things out as I move along. </p> <p>So, I'm lookin...
<p>Rob Conery has his <a href="http://blog.wekeroad.com/mvc-storefront/" rel="noreferrer">ASP.NET MVC Storefront</a> series, which is what I used to get my feet wet. It is around twenty-something parts long already.</p> <p>He takes you threw the entire conceptual design and execution of an application, which is an in...
<p>I bet that you can't find any better book than "Pro ASP NET MVC Framework" by Steven Sanderson. I read many books but never read such good book.</p>
44,285
<p>I'm relatively familiar with the concepts of DI/IOC containers having worked on projects previously where their use were already in place. However, for this new project, there is no existing framework and I'm having to pick one.</p> <p>Long story short, there are some scenarios where we'll be configuring several i...
<p>One thing that caught me the first time I was trying to resolve all implementations of a registered type was that un-named (default) type registrations will <em>not</em> be returned when you call ResolveAll(). Only named instances are returned.</p> <p>So:</p> <pre><code>IUnityContainer container = new UnityContai...
<p>So I somehow missed this my first pass looking through Unity somehow...but I'll answer my own question.</p> <p>Unity has precisely what I wanted. <a href="http://msdn.microsoft.com/en-us/library/cc440943.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc440943.aspx</a></p> <p>Also, for anyo...
40,796
<p>In <a href="https://web.archive.org/web/20141127115939/https://blogs.msmvps.com/kathleen/2008/09/05/in-praise-of-nested-classes/" rel="noreferrer">Kathleen Dollard's 2008 blog post</a>, she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn't like nested classes...
<p>Use a nested class when the class you are nesting is only useful to the enclosing class. For instance, nested classes allow you to write something like (simplified):</p> <pre><code>public class SortedMap { private class TreeNode { TreeNode left; TreeNode right; } } </code></pre> <p>You can ...
<p>As <a href="https://stackoverflow.com/a/16093091/199154">nawfal</a> mentioned implementation of Abstract Factory pattern, that code can be axtended to achieve <a href="https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaEncyclopedia/ClassClusters/ClassClusters.html" rel="nofollow noreferrer...
7,128
<p>Is there a standard idiom for comparing version numbers? I can't just use a straight String compareTo because I don't know yet what the maximum number of point releases there will be. I need to compare the versions and have the following hold true:</p> <pre><code>1.0 &lt; 1.1 1.0.1 &lt; 1.1 1.9 &lt; 1.10 </code><...
<p>Another solution for this old post (for those that it might help) :</p> <pre><code>public class Version implements Comparable&lt;Version&gt; { private String version; public final String get() { return this.version; } public Version(String version) { if(version == null) ...
<pre><code>public class VersionComparator { /* loop through both version strings * then loop through the inner string to computer the val of the int * for each integer read, do num*10+&lt;integer read&gt; * and stop when stumbling upon '.' * When '.' is encountered... * see if '.' is encou...
24,170
<p>What is a generic list manipulation function in C? (I saw this when I was going through some materials.)</p> <p>What is the difference between this function and a function which can accept elements of any kind?</p> <p>Are they same...? How can we implement them individually if they are not same?</p>
<p>A generic list is likely to be singly-linked, and probably assumes that the items in the list have a structure like this:</p> <pre><code>typedef struct list_item list_item; struct list_item { list_item *next; ...data for node... }; </code></pre> <p>Using this layout, you can write functions to manipulate ...
<p>As mentioned above, I tried using MACROS approach to create the list manipulation functions. Its easy to create the INSERT operation routine but difficult to create Delete and traverse operations. Following it the list structure and the INSERT routine signature:</p> <pre><code>#define LIST_DEFINE(type) \ struct...
42,261
<p>I'm in the process of making my PHP site Unicode-aware. I'm wondering if anyone has experience with the <code>mbstring.func_overload</code> setting, which replaces the normal string functions (e.g. <code>strlen</code>) with their multi-byte equivalents (<code>mb_strlen</code>). There aren't any comments on the PHP m...
<p>one issue you should definitely watch for is 3rd party scripts (perhaps a library or pear extension) which uses non mb-aware versions of functions. for example, libraries that use <code>strlen()</code> could cause issues if you overload it.</p> <p>as well, this <a href="http://bugs.php.net/bug.php?id=27421" rel="no...
<p>one issue you should definitely watch for is 3rd party scripts (perhaps a library or pear extension) which uses non mb-aware versions of functions. for example, libraries that use <code>strlen()</code> could cause issues if you overload it.</p> <p>as well, this <a href="http://bugs.php.net/bug.php?id=27421" rel="no...
27,470
<p>I want to implement a simple 2 part FormWizard. Form 1 will by dynamically generated something like this:</p> <pre><code>class BuyAppleForm(forms.Form): creditcard = forms.ChoiceField(widget = forms.RadioSelect) type = forms.ChoiceField(widget = forms.RadioSelect) def __init__(self,*args, **kwargs): ...
<p>I haven't used it, but for the situation you describe, it seems like you may want to try the <a href="http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-preview/#ref-contrib-formtools-form-preview" rel="nofollow noreferrer">FormPreview</a> instead of the FormWizard. From the documentation it sounds lik...
<p>Thank you krys for answering to your own question. Helped me, but I still got some remarks.</p> <p>FormPreview is not the way to go since it as far as I know does not support dynamic forms. It relies on a fixed form class to generate the from from there. But we are generating dynamically here with a function. Maybe...
46,742
<p>I'm trying to grok the purpose of .NET's SecureString. From MSDN:</p> <blockquote> <p>An instance of the System.String class is both immutable and, when no longer needed, cannot be programmatically scheduled for garbage collection; that is, the instance is read-only after it is created and it is not possible to pre...
<p>Some parts of the framework that currently use <a href="https://learn.microsoft.com/en-us/dotnet/api/system.security.securestring" rel="noreferrer"><code>SecureString</code></a>:</p> <ul> <li>WPF's <a href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.passwordbox" rel="noreferrer"><code>Syst...
<p>Another use case is when you are working with payment applications (POS) and you simply <em>can't use immutable data structures</em> in order to store sensitive data because you are careful developer. For instance: if I will store sensitive card data or authorisation metadata into immutable string there always would...
17,054
<p>I recently upgraded to <a href="https://www.creality3donline.com/creality-polypropylene-build-plate-for-ender-3-ender-5-cr20_p0124.html" rel="nofollow noreferrer">a Polypropylene</a> print bed, but I haven't actually been able to complete a print. </p> <p>Adhesion seems incredibly inconsistent, even on the same spo...
<p>When you updated the print bed, you may have affected either the manual or auto calibration of the bed height and bed leveling.</p> <p>First layer adhesion is depends critically on an accurate first layer thickness, which depends on the bed height calibration. Adding or, perhaps more critically, removing any bed s...
<p>If you are using PLA, 200 for the extruder sticks the best for me. The other issue with adhesion is the greater the difference between the extruder temperature and the bed the poorer adhesion. There are other things can help with this. Using a higher bed temperature for the first layer can help. A slower extrusio...
1,285
<p>I have an application with 5 <code>UIViewController</code>s each inside a corresponding <code>UINavigationController</code>, all tucked inside a <code>UITabBarController</code> that displays 5 tabs at the bottom of the screen.</p> <p>I want to display another <code>UIViewController</code> (inside a <code>UINavigati...
<p>It sounds as though you have a mess on your hands. A <code>UINavigationController</code> is a distinct object that is very different from a <code>UITabBarController</code>. In general, your application should have a tab controller, one of who's tab's loads a <code>UINavigationController</code> which in turn loads ...
<p>The best idea I could think of would be to either push a modal navigation controller for your view (which would hide the tab bar which you do not want), or to get the tab bar controller current selected view controller (really your navigation controller for a tab) and push your new view controller on there - and the...
36,068
<p>What is the best way to secure an intranet website developed using <code>PHP</code> from outside attacks?</p>
<p>That's a stunningly thought-provoking question, and I'm surprised that you haven't received better answers. </p> <h2>Summary</h2> <p>Everything you would do for an external-facing application, and then some. </p> <h2>Thought Process</h2> <p>If I'm understanding you correctly, then you are asking a question whi...
<p>You could only allow access from internal IPs from the php app itself. Also dont ignore the usual security and best practices. Input validation and output encoding(whitelisting only), user accounts with hashed passwords etc.</p>
16,022
<p>As I said in the title there is some issue with my z axis steppers. They will make a humming sound and vibrate a little but won't actually spin. I'm fairly sure this is an issue with the firmware (but I might be totally wrong) since they turn when the wires are switched with the ones for the Y axis and swapping the ...
<p>Try connecting Y-motor to your Z ports. If Y-motor will behave like Z-motors, then there's problem with your Z ports, be it hardware or software. I'm not a RAMPS user, but have heard that there is voltage regulator for every motor port. Sounds like your motors may be underpowered.</p>
<p>Hello it's seems to be the voltage regutaltor on the steppers drivers for the nema motors. Check to adjust the voltage with a multimeter connecting the red pin from the multimeter on the voltage regulator on the driver and the black pin on the GND pin on the ramps 12v connector.</p> <p>Also make sure that you have ...
748
<p>I would like to use the ispell-buffer command in Emacs. It uses the English language by default. Is there an easy way to switch to another dictionary (for example, another language)?</p>
<p>The following command proposes a list of installed dictionaries to use:</p> <pre><code>M-x ispell-change-dictionary </code></pre> <p>Usually, <code>M-x isp-c-d</code> expands to the above also.</p>
<p>Here is some code to remap the C-\ key to automatically toggle between multiple languages <em>and</em> to change the input method to the corresponding language. (derived from this post: <a href="https://stackoverflow.com/a/45891514/17936582">https://stackoverflow.com/a/45891514/17936582</a> )</p> <pre><code>;; Toggl...
26,885
<p>I fear this is probably a bit of a dummy question, but it has me pretty stumped.</p> <p>I'm looking for the simplest way possible to pass a method of an object into a procedure, so that the procedure can call the object's method (e.g. after a timeout, or maybe in a different thread). So basically I want to:</p> <...
<p>Just remove the Pointer stuff. Delphi will do it for you:</p> <pre><code>procedure TCallbackObject.SetupCallback; begin CallbackTheCallback(CallbackMethodImpl); end; </code></pre>
<p>The reason you don't need the pointer syntax is that you've declared the method type as a procedure of object. The compiler will figure out from the "of object" statement how to handle passing the method off the callback proc.</p>
21,462
<p>As the title suggests, is it correct or valid to import/export static data from within a C++ class?</p> <p>I found out my problem - the author of the class I was looking at was trying to export writable static data which isn't supported on this platform.</p> <p>Many thanks for the responses however.</p>
<p>Is it correct inasmuch as it'll work and do what you expect it to? Assuming that you are talking about using _declspec(dllexport/dllimport) on a class or class member, yes, you can do that and it should give you the expected result - the static data would be accessible outside your dll and other C++ code could acces...
<p>dllexport (or import) on a class's (non-static) data member does nothing. Exported "things" are either functions or global data (though this is a questionable design choice). dllexport on a class is just a shortcut for saying "export all of these functions".</p>
27,408
<p>I've been reading about the <a href="http://en.wikipedia.org/wiki/Open/closed_principle" rel="noreferrer">OCP principle</a> and how to use the strategy pattern to accomplish this.</p> <p>I was going to try and explain this to a couple of people, but the only example I can think of is using different validation class...
<p>What about this: </p> <p>You have to encrypt a file. </p> <p>For small files, you can use "in memory" strategy, where the complete file is read and kept in memory ( let's say for files &lt; 1 gb ) </p> <p>For large files, you can use another strategy, where parts of the file are read in memory and partial encrypt...
<p>From wikipedia </p> <blockquote> <p>In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, code receives run-time instructions as to which in a fam...
48,364
<p>My WCF service involves the sending of a dataset (in csv format) data between client and service. This dataset must be encrypted so that the data cannot be intercepted. I'm using wshttpbinding and trying to encrypt the message by using the following settings in web.config:</p> <pre><code>&lt;wsHttpBinding&gt; &lt...
<p>Yes, your service needs a certificate so that your encryption keys can be exchanged securely. You can create a test service authentication certificate with makecert.exe. See <a href="http://web.archive.org/web/20070306040207/http://martinparry.com/cs/blogs/mparry_software/archive/2006/10/30/97.aspx" rel="nofollow ...
<p>I am still trying to find the solution this problem. I have it too, but with signing an xml. Still to find the user IIS is running in WinXP Start > Right-Click My Computer > Manage > Services And Applications > Services > IIS Admin > Double click and in the Log on tab it will usually say Local System.</p> <p>EDIT</...
35,521
<p>What is a good error handling practice for an asp.net site? Examples? Thanks!</p>
<p>As with any .net project I find the best way is to only catch specific error types if they are may to happen on the given page. </p> <p>For example you could catch Format Exceptions for a users given input (just incase JavaScript validation fails and you have not use tryparse) but always leave the catching of the t...
<p>Well, that's pretty wide open, which is completely cool. I'll refer you to a word .doc you can download from <a href="http://www.dotnetspider.com/tutorials/BestPractices.aspx" rel="nofollow noreferrer">Dot Net Spider</a>, which is actually the basis for my small company's code standard. The standard includes some v...
18,767
<p>I have found many pieces of documentations and recommendations about <code>IEnumerator</code>, <code>IEnumerable</code>, <code>ICollection</code>, <code>IList</code> and their generic counterparts. Sadly, I didn't find yet a tutorial or book which explains the whole hierarchy of interfaces, generic implementations o...
<p>The main way I came to understand them was just by looking at their interfaces.</p> <p>The inheritance goes like this:</p> <p>IList : ICollection : IEnumerable</p> <p>When you look up IEnumerable's interface, notice that it only has the bare minimum necessary to be able to loop through a bunch of items. It doesn'...
<p>you just missed one :)</p> <p><strong>IDictionary</strong> : IList : ICollection : IEnumerable</p>
24,742
<p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" rel="nofollow noreferrer">ASP.NET Login Controls</a> and <a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" rel="nofollow noreferrer">Forms Authentication</a> for membership/credentials for an ASP.NET web application. And I'm...
<p>You pretty much need to keep the same data context available throughout the lifetime of the operations you want to perform if you're ever going to be storing changes which are to be <code>.SubmitChanges()</code>'d later, as otherwise you will lose those changes.</p> <p>If you're just querying stuff then it's fine t...
<p>I think Jeff Atwood talked about this in the <a href="http://herdingcode.com/?p=36" rel="nofollow noreferrer">Herding Code podcast</a>, when he was questioned about the exact same thing. Listen to it towards the last 15-20 minutes or so.</p> <p>I think in SO, the datacontext is created in the Controller class. Not ...
5,343
<p>Before I explain what I'm trying to do, note that I have the good fortune of only having to target Webkit (meaning, I can use lots of neat CSS).</p> <p>So, basically, I want to have a block with a flexible height, position fixed, maximum height being that of the available window height, with some elements at the to...
<p>Another modification:</p> <pre><code>function update() { $.get("response.php", function(data) { $("#some_div").html(data); window.setTimeout(update, 10000); }); } </code></pre> <p>The difference with this is that it waits 10 seconds AFTER the ajax call is one. So really the time between refreshes is 10...
<p><a href="http://plugins.jquery.com/project/Timer" rel="nofollow noreferrer">There's a jQuery Timer plugin</a> you may want to try</p>
27,188
<p>Is there any way to print an OOXML document (.docx file) without having MS Word installed? </p> <p>It works nicely via the MS Word interface but I need to find a way to use it on servers where MS Word is not installed. I've been digging through the API and haven't found anything obvious so I'm inclined to believe t...
<p>I was curious about the answer myself, so I Googled it. Seems there is support in some Novel and IBM products. Here's a link to a partial answer which seems to say support in OpenOffice is in development. <a href="http://wiki.services.openoffice.org/wiki/Office_Open_XML" rel="nofollow noreferrer">http://wiki.service...
<p>Well yes and no. Yes it is possible without MSWord but you will need an application or library that understands ooxml. There are many other products now that do support (as pointed out by Devin) but if your requirements says you cannot have any of them on the server then...use a library and do it yourself.</p> <p>I...
40,420
<p>I have all the forms in one folder and all the code modules in an other folder in VB6. How do I create a better folder structure for the source files?</p> <p>For example if I have twenty forms and twenty code modules, how can I create subfolders Main, Sales, and Employees and put the source files under those subfol...
<p>You should investigate whether some of your files could reside in a ActiveX DLL instead of the main EXE project. As Konrad pointed out the VB6 IDE project explorer doesn't support folders. Large VB6 projects, like my own, organize the classes into a hierarchy of ActiveX DLLs. For example Utility DLL which has common...
<p>well if you're talking about adding a new folder from vb6 project explorer view, i'm not sure that you can do so.</p> <p>but if you want to sort it you can apply some naming convention, i.e. module1_xxx, module1_yyy.</p>
39,154
<p>I have an assembly that is targeted for .NET 3.5.</p> <p>I have an application targeted for .NET 2.0 and wonder if I should have any trouble referencing the 3.5 assembly from the 2.0 application.</p> <p>I understand that the IL is supposedly the same, so I'm assuming that it will work, but would like to hear some ...
<p>There's no problem. There is only one runtime version executing the app. .NET Framework v2.0.</p>
<p>However - when deploying your .net2.0 application, your user will be prompted to install .net3.5 (as there is a .net 3.5 assembly referenced).</p>
48,250
<p>I'm working on a website that will switch to a new style on a set date. The site's built-in semantic HTML and CSS, so the change should just require a CSS reference change. I'm working with a designer who will need to be able to see how it's looking, as well as a client who will need to be able to review content upd...
<p>In Asp.net 3.5, you should be able to set up the Link tag in the header as a server tag. Then in the codebehind you can set the href property for the link element, based on a cookie value, querystring, date, etc.</p> <p>In your aspx file:</p> <pre><code>&lt;head&gt; &lt;link id="linkStyles" rel="stylesheet" type...
<p>I would do the following:</p> <p><a href="http://www.website.com/?stylesheet=new.css" rel="nofollow noreferrer">www.website.com/?stylesheet=new.css</a></p> <p>Then in your ASP.NET code:</p> <pre><code>if (Request.Querystring["stylesheet"] != null) { Response.Cookies["stylesheet"].Value = Request.QueryString["...
2,710
<p>I have a program in which I've lost the C++ source code. Are there any good C++ decompilers out there?</p> <p>I've already ran across <a href="http://boomerang.sourceforge.net/" rel="noreferrer">Boomerang</a>.</p>
<p>You can use <a href="http://www.hex-rays.com/idapro/" rel="noreferrer">IDA Pro</a> by <a href="http://www.hex-rays.com/" rel="noreferrer">Hex-Rays</a>. You will usually not get good C++ out of a binary unless you compiled in debugging information. Prepare to spend a <strong>lot</strong> of manual labor reversing the...
<p>Depending on how large and how well-written the original code was, it might be worth starting again in your favourite language (which might still be C++) and learning from any mistakes made in the last version. Didn't someone once say about writing one to throw away?</p> <p>n.b. Clearly if this is a huge product, t...
25,115
<p>The NUnit documentation doesn't tell me when to use a method with a <code>TestFixtureSetup</code> and when to do the setup in the constructor.</p> <pre><code>public class MyTest { private MyClass myClass; public MyTest() { myClass = new MyClass(); } [TestFixtureSetUp] public void I...
<p>Why would you need to use a constructor in your test classes?</p> <p>I use <code>[SetUp]</code> and <code>[TearDown]</code> marked methods for code to be executed before and after each test, and similarly <code>[TestFixtureSetUp]</code> and <code>[TestFixtureTearDown]</code> marked methods for code to be executed o...
<p>The constructor and the <code>SetUp</code> methods are used differently:<br> The constructor is run only once.<br> However, the <code>SetUp</code> methods are run multiple times, before every test case is executed.</p>
26,145
<p>i'm fairly new to NHibernate and although I'm finding tons of infos on NHibernate mapping on the web, I am too silly to find this piece of information.</p> <p>So the problem is, i've got the following Model:</p> <p><img src="https://i.stack.imgur.com/DihaU.jpg" alt="Datamodel"></p> <p>this is how I'd like it to l...
<p>Ok. I found the solution myself. The key is the construct in the XML configuration and it works rather nicely.</p> <p>Here is how it's done:</p> <pre><code>&lt;component name="Address" class="Address"&gt; &lt;property name="Streetname"&gt;&lt;/property&gt; &lt;property name="Zip"&gt;&lt;/property&gt; &lt;pr...
<p>you could configure this as two relations. e.g.</p> <pre><code>&lt;many-to-one name="ShippingAddress" class="Yournamespace.Address"/&gt; &lt;many-to-one name="Address" class="Yournamespace.Address"/&gt; </code></pre>
26,862
<p>I embedded a swf in my html page, but I would like it to swap to another swf when I clicked on a button in html. I used swfobject.js to embed the swf, and I use prototype to write the javascript. I thought I can just do this</p> <pre><code>$('movie').value = 'swf/bhts.swf'; alert($('movie').value); </code></pre> <...
<p>Using swfObject:</p> <pre><code>&lt;div id='flashContent'&gt; &lt;/div&gt; &lt;script type='text/javascript'&gt; // Setup your initial flash var so = new SwfObject(.....); so.write ('flashContent'); // Some event handler someElement.onclick = function () { // Load up the new ...
<p>How are you using SWFObject? If you use the swfobject.embedSWF method to add the SWF to your HTML file, then you can call that again with the same ID and it should remove the old Flash player object and add a new one with your new URL.</p> <p>You also can use the SWF's own methods to replace the URL that it's usin...
37,201
<p>I want to find a way to develop database projects quickly in Visual Studio. Any ideas?</p>
<p>I have a method of creating and updating database projects in Visual Studio 2005 that I thought was common knowledge. After asking a few coworkers if they knew how to update their database projects with this method and receiving no's, I thought I would blog about it and pass along some helpful hints and best practic...
<p>DataDude? <a href="http://msdn.microsoft.com/en-us/vsts2008/db/default.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/vsts2008/db/default.aspx</a></p>
10,942
<p>Here's my problem: I have a virtual method defined in a .h file that I want to call in a class that inherits from the base class. Sadly though, the method in the derived class doesn't get called. Is there a better way to implement what I'm trying to do?</p> <pre><code>#ifndef ofxBASE_SND_OBJ #define ofxBASE_SND_OBJ...
<p>Change this line:</p> <pre><code>string ofxSndObj::createFilter(ofxBaseSndObj obj) </code></pre> <p>to</p> <pre><code>string ofxSndObj::createFilter(ofxBaseSndObj&amp; obj) </code></pre> <p>What you are doing is passing by value (passing a copy).</p> <p>This means you are copying the object to the function. Bec...
<p>You could use dynamic_cast or type_id</p>
29,323
<p>I'm working on a project in C#. The previous programmer didn't know object oriented programming, so most of the code is in huge files (we're talking around 4-5000 lines) spread over tens and sometimes hundreds of methods, but only one class. Refactoring such a project is a huge undertaking, and so I've semi-learned ...
<p>From <a href="http://msdn.microsoft.com/en-us/library/ms973852.aspx" rel="noreferrer">here</a>, a static call is 4 to 5 times faster than constructing an instance every time you call an instance method. However, we're still only talking about tens of nanoseconds per call, so you're unlikely to notice any benefit unl...
<p>It's not valid in PHP,<br /> Object Method is faster :<br /> <a href="http://www.vanylla.it/tests/static-method-vs-object.php" rel="nofollow noreferrer">http://www.vanylla.it/tests/static-method-vs-object.php</a></p>
24,781
<p>I need a simple way to monitor multiple text log files distributed over a number of HP-UX servers. They are a mix of text and XML log files from several distributed legacy systems. Currently we just ssh to the servers and use <em>tail -f</em> and <em>grep</em>, but that doesn't scale when you have many logs to keep ...
<p>Probably the lightest-weight solution for real-time log watching is to use <a href="http://www.netfort.gr.jp/~dancer/software/dsh.html.en" rel="noreferrer">Dancer's shell</a> in concurrent mode with tail -f:</p> <pre><code>dsh -Mac -- tail -f /var/log/apache/*.log </code></pre> <ul> <li>The -a is for all machine n...
<p>Awstats provides a perl script that can merge several apache log files together. This script scales well since the memory footprint is very low, logs files are never loaded in memory. I know that si not exactly what you needs, but perhaps you can start from this script and adapt it for your needs.</p>
10,930
<ol> <li><p>I want to create a scrollable list of pictures fetched from the internet and give the user the ability to click on it. How do i go about doing it in WinForms/C#? Is it possible to add picturebox control/ controls to the listBox?</p></li> <li><p>I tried adding a list of picturebox into UserControl with AutoS...
<p>I'll answer your third question first, becuase that's the only one I REALLY know the answer to. There's a LoadAsync() method on the picture box that will load the image in a seperate thread and won't hang your app.</p> <p>As for the other questions, I too would most likely start with a user control and put the imag...
<p>Do you mind scrolling vertically? </p> <p>I would start with the DataGridView control as a base and create the following implementation:</p> <p>1) Create custom column and celltype deriving from DataGridViewImageColumn. You could call them "CronosNetImageColumn", "CronosNetImageCell".</p> <p>2) Create a class "Cr...
41,144
<p>If a hacker has access to the hashes in my DB, he has access to the rest of the information in the DB anyways. So why would he bother trying to decrypt the passwords? Should I be storing the passwords on a different server to the rest of my data? That is the only scenario in which I can envision it being useful. </p...
<ol> <li><p>Sometimes a hacker doesn't get full access to your DB. Sometimes they find a little SQL injection hole or other weakness that someone didn't code correctly, and so they can only do simple things at first like print out database cells one at a time. If they can print out a real password all of a sudden th...
<p>When a hacker access your database it does not mean that he can access the procedural code, those procedures can alter databases outside the hacked database boundaries or inclusive can alter other procedures. </p> <p>By the way now I´m going to ask you something: If a user is hacked and someone has his or her passw...
36,595
<p>If I’m writing an applet that shows a video sequence (eg. streaming from a camera, or the applet itself is running the on the camera), do my clients need to download the Java Media Framework libraries inorder to see the sequence?</p>
<p>They need to install Java Media Framework on their computers, or you'll need to bundle the JMF together with your applet somehow.</p>
<p>Did you consider to use <a href="http://javafx.com/" rel="nofollow noreferrer">Java FX</a>? This technology is dealing with this problem of downloading media libraries and so no. Of course. It is still in development. If to be first-adopter is option, it will be worth of considering this. </p>
25,603
<p>I am attempting to rewrite my <a href="http://ForestPad.com" rel="nofollow noreferrer">ForestPad</a> application utilizing WPF for the presentation layer. In WinForms, I am populating each node programmatically but I would like to take advantage of the databinding capabilities of WPF, if possible.</p> <p>In genera...
<p>Well, it would be easier if your element hierarchy was more like...</p> <pre><code>&lt;node type="forest"&gt; &lt;node type="tree"&gt; ... </code></pre> <p>...rather than your current schema.</p> <p>As-is, you'll need 4 <code>HierarchicalDataTemplate</code>s, one for each hierarchical element includin...
<p>I know this is an old post, but there's a more elegant solution. You can indeed use a single <code>HierarchicalDataTemplate</code>, if you use an XPath expression that selects all of the nodes that you want the template to use: <code>XPath=tree|branch|leaf</code>.</p> <pre><code>&lt;HierarchicalDataTemplate x:Key=&q...
22,786
<p>I'm currently building a Spring MVC application. I was looking to use JSP pages with tag libraries for handling the view layer and formatting of the HTML, but I've come across another group in my company that uses Velocity templates for the same purpose.</p> <p>From what I can see, it seems to me as if there are a ...
<p>I would prefer to use Velocity just because using JSP+JSTL can allow lazy/sloppy developers to get into trouble by adding scriptlets. There should be no reason to have java code in your view tier. It doesn't take much to understand Velocity and as a matter of fact I just picked it up in about two weeks. While I d...
<p>JSP is also more difficult to visually differentiate from the embedded HTML. With Velocity, it is very obvious.</p> <p>Also, the VelocityTools package provides a great deal of additional functionality.</p>
49,992
<p>For homework, I was given the following 8 code fragments to analyze and give a Big-Oh notation for the running time. Can anybody please tell me if I'm on the right track? </p> <pre><code>//Fragment 1 for(int i = 0; i &lt; n; i++) sum++; </code></pre> <p>I'm thinking O(N) for fragment 1</p> <pre><code>//Frag...
<p>I think fragment 5 is O(n^3), and similarly fragment 7 is O(n^5)*. It also looks like O(log(n)) for fragment 8.</p> <p>For the n * n problems, you have to execute the body of the loop n * n times, so it would be O(n^2), then you compound that with the order of the other code. Fragment 8 actually doubles the counter...
<p>You appear to be on the right track. With regards to the N*N what effect do you think it would have? It is another factor of N so it would likely be a higher order.</p> <p>Just a warning, I saw another post like this and it was extremely down voted. Be careful. <a href="https://stackoverflow.com/questions/216496/lo...
26,650
<p>I've got the bare minimum to handle the Linux/MySQL parts of the stack, but I want to have a basic grasp of PHP before I dive in. I'll be working on WordPress plugins, in case there's anything specifically interesting for that.</p> <p>PS - any recommendations regarding recommended source control/IDEs would also be...
<p>I would recomment the <a href="http://www.php.net/manual/en/" rel="noreferrer">PHP manual</a> too!</p>
<p>The best php/mysql book is probably <a href="http://ibmdw.safaribooksonline.com/9780672329166" rel="nofollow noreferrer" title="PHP and MySQL web development">PHP and MySQL web development</a> but if you already have an experience in web development you might just need something like the <a href="http://safari.oreil...
27,150
<p>I have the following Transact-Sql that I am trying to convert to LINQ ... and struggling. </p> <pre><code>SELECT * FROM Project WHERE Project.ProjectId IN (SELECT ProjectId FROM ProjectMember Where MemberId = 'a45bd16d-9be0-421b-b5bf-143d334c8155') </code></pre> <p>Any help would be greatly appreciated ... I woul...
<p>GFrizzle beat me to it. But here is a C# version</p> <pre><code>var projectsMemberWorkedOn = from p in Projects join projectMember in ProjectMembers on p.ProjectId equals projectMember.ProjectId where projectMember.MemberId == "a45bd16d-9be0-421b-b5bf-...
<p>No need for a lambda, you've just got a simple LINQ join here:</p> <pre><code>From p in db.Projects _ Join m in db.ProjectMember On p.ProjectId Equals m.ProjectId _ Where m.MemberId = "a45bd16d-9be0-421b-b5bf-143d334c8155" _ Select p </code></pre>
45,816
<p>I'm building a 3d printer of size 500 x 500 x 500 build area. For the Z axis, I'm planning to use this <a href="https://www.3dprintronics.com/Linear-Actuator-Ball-Screw-1204-p108536003" rel="nofollow noreferrer">Linear actuator</a>. </p> <p>The maximum weight Z axis might encounter is 15 Kg due to it being a clay p...
<blockquote> <p>My question is a ball screw of pitch 4mm or 5mm, will it be able to Maintain it's position when motor is deenergized under a load of 15 kg shared by two systems.</p> </blockquote> <p>The detent torque of a <a href="https://motion.schneider-electric.com/downloads/quickreference/NEMA23.pdf" rel="norefe...
<p>Adding to the other more scientific answers here. The backdriving force will move the lead screws depending on the stiction between the lead screw and the nut. If it was friction less then it will always slide. Basically you need to keep the lead screw from turning while the machine is off. You can make a basic elec...
1,043
<p>I got a new CR-10S 3D printer (I received it at Christmas). It has been printing just fine until yesterday, I was doing a print and it randomly paused, it did not restart on its own, I had to restart the print, then the item finished just fine. I am printing today, a very small item, the printer now stopped 3 times...
<p>The cr10s has a filament run-out sensor. If the microswitch doesn't function properly, or you have issues with the wiring, the print pauses.</p>
<p>It would be great if you can write what the printer says when it stops. </p> <p>I suggest you try printing other small objects. If that also stops then the printer itself has a problem. But if the printer prints other objects without stopping, then the one you want to print has bad gcode files. You also need to mak...
1,563
<p>Is it possible to develop custom PLAF themes for Swing? I would appreciate constructive suggestions in this topic Thanks</p>
<p>Yes! But don't do that. If you need just change colors. Try JGoodies or Substance and obey writing your own PLAF.</p>
<p>It is possible to create a custom PLAF using the built-in Synth Look-and-Feel. It's basically a PLAF that allows you to customize the appearance of all components (or just specific ones via component naming) via an XML configuration file. The <code>[javax.swing.plaf.synth][1]</code> package JavaDoc gives a good ov...
33,589
<p>In Python specifically, how do variables get shared between threads?</p> <p>Although I have used <code>threading.Thread</code> before I never really understood or saw examples of how variables got shared. Are they shared between the main thread and the children or only among the children? When would I need to use ...
<p>In Python, everything is shared, except for function-local variables (because each function call gets its own set of locals, and threads are always separate function calls.) And even then, only the variables themselves (the names that refer to objects) are local to the function; objects themselves are always global,...
<p>Worth mentioning <code>threading.local()</code> is not a singleton.</p> <p>You can use more of them per thread. It is <strong>not one storage</strong>.</p>
13,060
<p>We are using <a href="http://activemq.apache.org/" rel="noreferrer">ActiveMQ 5.2</a> as our implementation of choice and we picked it a while ago. It performs well enough for our use right now. Since its been a while, I was wondering what other Java Message Service implementations are in use and why? Surely there...
<p>Before delving into JMS, consider AMQP as well - might be a new standard. JMS providers I worked with (in varying degrees):</p> <p>TIBCO EMS - very quick and robust, good API support, Java friendly, native C API exists. Best commercial choice I've used.</p> <p>Websphere MQ (and its JMS implementation) - so, so. Pu...
<p>We are using SonicMQ, JBossMQ and the "micro broker" of Lotus Expeditor Integrator. We are using them for different purposes:</p> <p>-JBossMQ is used internally and to communicate out of all our Java EE applications which run on JBoss. -Lotus Expeditor is used in "remote sites" where we do only have limited resourc...
15,060
<p>I am trying to print something that might take 15 hours. I don't want to risk my printer so if I print for 15 hours, what is the worst that can happen? So far, I haven't printed anything for more than 5 hours.</p>
<p>Playing around with the nozzle height will help: back it off until just before you have first layer adhesion issues. Don't jam the filament into the bed as you might for ABS. This helps with small prints. However, my experience has been that if you have a large enough continuous contact area (i.e. more than a few...
<p>Correctly level your bed. Seriously, that's the answer. PETG does stick well, but it only gets difficult to remove if you're smashing the first layer against the bed with a nozzle that's way too close. With the bed leveled properly - using feeler gauges or test prints and a sub-0.1-mm-precision caliper - I have no t...
1,777
<p>If you have a domain object, and you want to do something useful and central to that domain object's responsibility like ensure it is valid, you sometimes need to access the state of related objects in order to perform this validation. </p> <p>How to avoid the domain object needing to call out to a Repository or Da...
<ul> <li><p>If the object is a value object, it should be immutable and validated during construction.</p></li> <li><p>If the object is a root aggregate, and that its own state is sufficient to tell you if it is valid or not, you could add a validation method on it, which cascades through the aggregation.</p></li> <li>...
<p>I answered a similar question just a few hours ago. The answer contains some guidance I use when a try to enrich my model with logic and behavior without making it dirty with dependencies to infra-tech related stuff. <a href="https://stackoverflow.com/questions/7306109/having-trouble-putting-real-world-logic-into-th...
21,439
<p>I'm trying to get a specific asp:button onclick event to fire when I press the enter key in a specific asp:textbox control.</p> <p>The other factor to be taken into account is that the button is within a asp:Login control template.</p> <p>I've no idea how to do this, suggestions on a postcard please.</p>
<p>You could look at the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.panel.defaultbutton.aspx" rel="noreferrer"><code>DefaultButton</code></a> property of the panel control.</p>
<p>You need to do it with javascript. It's really easy with <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery.</a></p> <p>You can do something like (off the top of my head, not tested):</p> <pre><code>$('#myTextBox').keypress(function(e){ if(e.which == 13) $('#myBtn').click(); }); </code></pre...
33,712
<p>My company is just starting to look at using WPF for migrating all of our 10 year old business applications. These applications will most of the time be running on computers that have limited/old hardware. We are now a little worried that the hardware might be too limited for using WPF. </p> <p>We have installed Fa...
<p>I would add several things:</p> <ol> <li><p>The first is, as Stu said, it really depends on what you are doing. In particular, we have found a noticeable difference between WPF 2D and WPF 3D. <strong>If you are doing any WPF 3D stuff at all, your performance is highly dependent on the quality of the video card</str...
<p>WPF apps will <em>generally</em> run no slower than their equivalents using other technologies. In other words, performance depends on what you're doing. If you have a basic app with some simple data entry controls and a grid or two then it'll be a lot less demanding than an app that has animated custom controls wit...
29,665
<p>I am completely on board with the ideas behind TDD, Refactoring and Patterns however it does seem like there is a huge gaping whole in these ideas, mainly that they are great for dev teams of 1, but when you start refactoring code that 10 people are working on you start getting merge conflicts all over the place and...
<p>Small changes committed often.</p> <p>As for your example, you would start by creating the class, committing that change. Then adding a similar function in the class as the old one and commit that change. Then change all the references from the old function to the new class function, commit that. Then remove the ol...
<p>Communication.</p> <p>Tools can't solve this for you, unless the specific tool is your email or IM client.</p> <p>It's the same as if you were making any other major change in a shared project -- you need to be able to tell your coworkers/collaborators "hey, hands off for a couple of hours, I have a big change to ...
9,395