instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Suppose I have <a href="http://www.eia.doe.gov/emeu/aer/txt/ptb0808.html" rel="nofollow noreferrer">a table</a>. Now, I'm interested in Getting Useful Data Easily. This means I'd rather not drop it into Excel and go through contortions, nor somehow get it into CSV and then into a DB, and then into SQL.</p> <p>I'd l...
<p>There's no tool to query an HTML table with SQL as far as I know, but <a href="http://www.w3schools.com/xquery/" rel="nofollow noreferrer">XQuery</a> is a standard language you can use to find elements in an XML or XHTML source in a manner very similar to using SQL to query databases.</p>
<p>No, there is absolutely no tool that lets you run SQL queries against an HTML table... but you could easily write some simple JavaScript if you had a specific query you wanted done.</p>
30,899
<p>What are the best workarounds for using a SQL <code>IN</code> clause with instances of <code>java.sql.PreparedStatement</code>, which is not supported for multiple values due to SQL injection attack security issues: One <code>?</code> placeholder represents one value, rather than a list of values.</p> <p>Consider t...
<p>An analysis of the various options available, and the pros and cons of each is available in Jeanne Boyarsky's <em><a href="http://www.javaranch.com/journal/200510/Journal200510.jsp#a2" rel="nofollow noreferrer">Batching Select Statements in JDBC</a></em> entry on JavaRanch Journal.</p> <p>The suggested options are:<...
<p>My workaround (JavaScript)</p> <pre><code> var s1 = " SELECT " + "FROM table t " + " where t.field in "; var s3 = '('; for(var i =0;i&lt;searchTerms.length;i++) { if(i+1 == searchTerms.length) { s3 = s3+'?)'; } else { s3 = s3+'?, ' ; } } var query = s1...
21,511
<p>What's a nice way to merge two sorted arrays in ActionScript (specifically ActionScript 3.0)? The resulting array should be sorted and without duplicates.</p>
<p>To merge (concatenate) arrays, use <code>.concat()</code>.</p> <p>Below are two examples of how you can concatenate arrays and remove duplicates at the same time.</p> <p>More convenient way: (you can use <code>ArrayUtil.createUniqueCopy()</code> from <a href="http://code.google.com/p/as3corelib/" rel="noreferrer">...
<p>Please follow the below step to get your answer:</p> <ol> <li>Concat two array using "Concat" Methos.</li> <li>New Array (concated) sort using "Sort" method which provided as API in Array Class</li> <li>Make user defined function to remove duplicates (see below functions)</li> <li>> function removeDuplicates(p_arr:...
43,498
<p>I am trying to debug an asp.net web form that requires a value from the querystring. I just want to debug that page without having to go through the entire process to create the querystring value and sending the request.</p> <p>Any suggestions on how to attach a querystring value in VS2008 when I start the debuggi...
<p>Visual Studio has an option to select which page to start when debugging.</p> <p>It's under Properties -> Web -> Start Url</p> <p>There you can enter the exact url you want.</p>
<p>Woot, this helped me greatly!</p> <p>Simply right-click on your web project from the solution explorer, click properties (or alt-enter), click the Web left-side-tab, and set a specific start page (including your qs param)!</p>
41,631
<p>I'd like to have it yell hooray whenever an assert statement succeeds, or at the very least have it display the number of successful assert statements that were encountered.</p> <p>I'm using JUnit4.</p> <p>Any suggestions?</p>
<p>If you want to see some output for each successful assertion, another simple approach which requires no external dependencies or source code, would be to define your own Assert class which delegates all methods to the standard JUnit Assert class, as well as logging successful assertions (failed assertions will be re...
<p>junit's javadoc unfortunately says that only failed assertions are recorded (<a href="http://junit.sourceforge.net/javadoc_40/index.html" rel="nofollow noreferrer">http://junit.sourceforge.net/javadoc_40/index.html</a>)</p> <p>so it seems it would not be possible</p>
21,762
<p>I'm not much of a Visual Basic person, but I am tasked with maintaining an old VB6 app. Whenever I check out a file, the editor will replace a bunch of the uppercase variable names with lowercase automatically. How can I make this stop!? I don't want to have to change them all back, and it's a pain to have these ...
<p>Continuing from <a href="https://stackoverflow.com/questions/248760/vb6-editor-changing-case-of-variable-names#248773">DJ's answer</a>...</p> <p>And it won't only change the case of variables in the same scope either.</p> <p>It will change the case of all variables with the same name in your entire project. So eve...
<p>DJ is spot on... VB always changes the case of variables to match the original declaration. It's a 'feature'.</p>
30,916
<p>I recall reading somewhere that using references to smart pointers can cause memory corruption. Is this simply because of using the reference of the smart pointer after its been destroyed? Or does the reference counting get messed up?</p> <p>Thanks for clarifying</p>
<p>Assuming you are talking about shared_ptr here...</p> <blockquote> <p>Is this simply because of using the reference of the smart pointer after its been destroyed?</p> </blockquote> <p>This is a good answer. You may not know absolutely the lifetime of the pointer your reference refers too. </p> <p>To get aro...
<p>We have custom made smartpointers and we always make a habit of passing a 'const refsomething &amp;'</p> <p>it doesn't increment or decrement the smart pointer, and as such - and more importantly - calls to InterLockedIncrement/Decrement are avoided which in turns avoids a <a href="http://en.wikipedia.org/wiki/Memo...
21,598
<p>I have a table with a binary column which stores files of a number of different possible filetypes (PDF, BMP, JPEG, WAV, MP3, DOC, MPEG, AVI etc.), but no columns that store either the name or the type of the original file. Is there any easy way for me to process these rows and determine the type of each file store...
<p>you can use these tools to find the file format.</p> <p>File Analyser <a href="http://www.softpedia.com/get/Programming/Other-Programming-Files/File-Analyzer.shtml" rel="nofollow noreferrer">http://www.softpedia.com/get/Programming/Other-Programming-Files/File-Analyzer.shtml</a></p> <p>What Format <a href="http://...
<p>A lot of filetypes have well defined headers that begin the file. You could check the first few bytes to check to see how the file begins.</p>
41,223
<p>I have a project that I have been working on for a while, just one of those little pet projects that I would like to one day release to open source. </p> <p>Now I started the project about 12 months ago but I was only working on it lightly, I have just started to concentrate a lot more of my time on it(almost every...
<p>In my opinion, it's never too late to adopt a better practice - or to drop a worse one - so I'd say "Yes, you should start".</p> <p>However ... (there's always a "but") ...</p> <p>... one of the biggest gains of TDD is that it impacts on your design, encouraging you to keep reponsibilties separate, interactions cl...
<p>Absolutely.</p> <p>Introduce TDD to new code and if time allows, introduce "Comment Driven Design" with your existing code if it's not already tested.</p> <ul> <li>Comment out the block of existing code you need to test</li> <li>Write your test</li> <li>Uncomment your original code one statement at a time (if you ...
37,653
<p>Is it possible to integrate my PHP web-based ecommerce application with Quickbook Online Edition?</p> <p>When I make a sale on my web site, I would like to be able to make the corresponding journal entry in my accounting books.</p> <p>Note, I'm referring to Quickbook <strong>Online Edition</strong>, <strong>not</s...
<p>I now have built a set of PHP classes that facilitates communication with QuickBooks Online Edition. It makes communicating with QuickBooks Online Edition as easy as: </p> <pre><code>// Create the connection to QuickBooks $API = new QuickBooks_API(...); // Build the Customer object $Customer = new QuickBooks_Objec...
<p>It looks like Quickbooks OE has an XML-based SDK, available at:</p> <p><a href="http://developer.intuit.com/technical_resources/default.aspx?id=1492" rel="nofollow noreferrer">http://developer.intuit.com/technical_resources/default.aspx?id=1492</a></p>
24,047
<p>I have one large access database that I need to normalize into five tables and a lookup table. I understand the theory behind normalization and have already sketched out the look of the tables but I am lost on how to transform my table to get the database normalized. The table analyzers doesn't offer the the breakdo...
<p>If you have a single table, add an Autonumber field to it.</p> <p>Then create your other tables, and use the Autonumber value from the original single table as the foreign key to join them back to the original data.</p> <p>If you had tblPerson:</p> <pre><code> tblPerson LastName, FirstName, WorkPhone, HomePhon...
<p>Can queries, particularly Union queries, offer a solution? Where are you seeing a problem?</p>
34,902
<p>I would like to access the work items in our TFS programmatically. Shouldn't there be an obvious command line tool to extract such information? Or a WebService I can just call? I already have checked into using Excel - this is neat, but I want more hardcore...</p>
<p>Take a look at the TFS API (<a href="http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx</a>). Access to the same code used by Microsoft to create the Visual Studio integration and their version control command line too...
<p>If you download <a href="http://msdn.microsoft.com/sv-se/tfs2008/bb980963(en-us).aspx" rel="nofollow noreferrer">tfs power tools</a> you can use "tfpt query" to your advantage.</p>
25,030
<p>The following code snippet illustrates a memory leak when opening XPS files. If you run it and watch the task manager, it will grow and not release memory until the app exits.</p> <p>'****** Console application BEGINS.</p> <pre><code>Module Main Const DefaultTestFilePath As String = "D:\Test.xps" Const De...
<p>Well, I found it. It IS a bug in the framework and to work around it you add a call to UpdateLayout. Using statement can be changed to the following to provide a fix;</p> <pre><code> Using XPSItem As New Windows.Xps.Packaging.XpsDocument(PathToTestXps, System.IO.FileAccess.Read) Dim FixedDocSeque...
<p>I can't give you any authoritative advice, but I did have a few thoughts:</p> <ul> <li>If you want to watch your memory inside the loop, you need to be collecting memory inside the loop as well. Otherwise you will <em>appear</em> to leak memory by design, since it's more efficient to collect larger blocks less fre...
26,906
<p>Our app is made up of several Modules, and we would like to take advantage of the XP feature that would allow these to be grouped together. For example all windows in "Module A" would be grouped together, separately from windows in "Module B". </p> <p>I've tried setting the AssemblyTitle attribute in the project's...
<p>In addition to what Eoin says, Windows will only group taskbar buttons on a process-by-process basis. In other words, all the windows in your app will appear under one group.</p> <p>The only way to get them into separate groups is to define one process for each of the groups you want. Then use [assembly: AssemblyDe...
<p>IMo that feature is about the worst feature in XP and i am so glad that i can disable it.</p> <p>But that aside, if you have the group option enabled in your taskbar then windows should do it automaticly. In our company we have Java applications and all different java windows are always grouped becuase they are a...
30,546
<p>I have a somewhat complicated branching structure at work (at least for me). It is something like this:</p> <pre> Main | 1 | 2 | \ 3 \ Ver2 | 1 | \ 2 \ | ProjectA 3 | 1 </pre> <p>There are 2 branches off of main. "Ver2" which has everyone's ...
<p>Mentioning the dragon book and antlr means you've answered your own question.</p> <p>If you're looking for other parser generators you could also check out boost::spirit (<a href="http://spirit.sourceforge.net/" rel="noreferrer">http://spirit.sourceforge.net/</a>).</p> <p>Depending on what you're trying to achieve...
<p>Hmm … your request is a bit unspecific. While there are many recent developments in this general area, they're all quite specialized (naturally, since the field has matured). The original parsing approaches haven't really changed, though. You might want to read up on changes in parser creation tools (<a href="http:/...
30,285
<p>I would like to construct a query that displays all the results in a table, but is offset by 5 from the start of the table. As far as I can tell, MySQL's <code>LIMIT</code> requires a limit as well as an offset. Is there any way to do this?</p>
<p>From the <a href="http://dev.mysql.com/doc/refman/5.0/en/select.html#id4651990" rel="noreferrer">MySQL Manual on LIMIT</a>:</p> <blockquote> <p>To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all r...
<p>Just today I was reading about the best way to get huge amounts of data (more than a million rows) from a mysql table. One way is, as suggested, using <code>LIMIT x,y</code> where <code>x</code> is the offset and <code>y</code> the last row you want returned. However, as I found out, it isn't the most efficient way ...
31,882
<p>I have an action handling a form post, but I want to make sure they are authenticated before the action. The problem is that the post data is lost because they user is redirected to the login page, and then back. </p> <pre><code> [AcceptVerbs(HttpVerbs.Post)] [Authorize] public ActionResult AskQuestion(s...
<p>You need to serialize your form values and a RedirectUrl to a hidden field.</p> <p>After authentication deserialize the data in your hidden field and redirect based on the value of the RedirectUrl.</p> <p>You will need a custom Authorize class to handle this.</p>
<p>You can also use the session to save the information...</p>
49,457
<p>I have written some code in my VB.NET application to send an HTML e-mail (in this case, a lost password reminder).</p> <p>When I test the e-mail, it gets eaten by my spam filter. One of the things that it's scoring badly on is because of the following problem:</p> <pre>MIME_QP_LONG_LINE RAW: Quoted-printable lin...
<p>Quoted printable expands 8 bit characters to "={HEX-Code}", thus making the messages longer. Maybe you are just hitting this limit?</p> <p>Have you tried to break the message at, say, 70 characters? That should provide space for a couple of characters per line.</p> <p>Or you just encode the email with Base64 - all...
<p>This is a bug in the implementation of the Quoted-Printable encoding in System.Net.Mail.MailMessage, which has been there for a long time, but is apparently now fixed, as of .Net 4 Beta 2.</p> <p><a href="http://connect.microsoft.com/VisualStudio/feedback/details/156052/mailmessage-body-encoding-quoted-printable-vi...
8,304
<p>I would very much like to integrate <a href="http://www.logilab.org/857" rel="noreferrer">pylint</a> into the build process for my python projects, but I have run into one show-stopper: One of the error types that I find extremely useful--:<code>E1101: *%s %r has no %r member*</code>--constantly reports errors when...
<p>Do not disable or weaken Pylint functionality by adding <code>ignores</code> or <code>generated-members</code>.<br> Use an actively developed Pylint plugin that <strong>understands</strong> Django.<br> <a href="https://github.com/landscapeio/pylint-django" rel="noreferrer">This Pylint plugin for Django</a> works qui...
<p>For heroku users, you can also use <a href="https://stackoverflow.com/a/31000713/527489">Tal Weiss's answer to this question</a> using the following syntax to run pylint with the pylint-django plugin (replace <code>timekeeping</code> with your app/package):</p> <pre><code># run on the entire timekeeping app/package ...
14,135
<p>One mentor I respect suggests that a simple bean is a waste of time - that value objects 'MUST' contain some business logic to be useful. </p> <p>Another says such code is difficult to maintain and that all business logic must be externalized. </p> <p>I realize this question is subjective. Asking anyway - want to ...
<p>The idea of putting data and business logic together is to promote encapsulation, and to expose as little internal state as possible to other objects. That way, clients can rely on an interface rather than on an implementation. See the <a href="http://www.pragmaticprogrammer.com/articles/tell-dont-ask" rel="noreferr...
<p>My personal preference is to put all business logic in the domain model itself, that is in the "true" domain objects. So when Data Transfer Objects are created they are mostly just a (immutable) state representation of domain objects and hence contain no business logic. They can contain methods for cloning and compa...
13,556
<p>How do we filter an xml document based on another xml document. I have to remove all the elements which are not there in the lookup xml. Both the input xml and lookup xml has the same root elements, we are using XSLT 1.0.</p> <p>Ex Input</p> <pre><code>&lt;Root&gt; &lt;E1 a="1"&gt;V1&lt;/E1&gt; &lt;E2&gt;V...
<p>Here is the required transformation:</p> <pre> &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:z="inline:text.xml" exclude-result-prefixes="z" > &lt;xsl:output omit-xml-declaration="yes" indent="yes"/> &lt;xsl:strip-space elements="*"/> &lt;z:filter> ...
<p>Hmmm, you're sort of talking about merging (assuming your filter doc is variable). There's a couple of possibilities which vary with the language you're implementing all of this in. Could you provide more info about the app?</p> <p>Otherwise I suggest a quick google on "xslt +merge" and see if some result there gra...
43,656
<p><em>Omitting details of methods to calculate primes, and methods of factorisation.</em></p> <h3>Why bother to factorise ?</h3> <h3>What are its applications ?</h3>
<p>Wow, so much fighting in this thread.</p> <p>Ironically, this question HAS a major valid answer.</p> <p>Factorization is actually used heavily in encryption/decryption algorithms, so much so that the RSA regularly conducts competitions wherein the task is to factorize certain large numbers that are multiples of ve...
<p>It can be used to crack some types of encryption (if they key was small enough).</p> <p>You would also need it for some types of scientific software.</p> <p>One more application is to answer <a href="http://projecteuler.net/" rel="nofollow noreferrer">ProjectEuler</a> Questions.</p>
30,044
<p>I normally don't work on Windows development, and am completely unfamiliar with the toolchain and build system. My embedded product includes some Windows DLLs from a third party in its filesystem (which are used by a Windows machine which mounts the filesystem).</p> <p>I have a problem: the most recent release of t...
<p>Generally the debug info itself is built as a separate <code>*.pdb</code> file (Program DataBase), instead of being appended onto the binary as in unix. If the developers did indeed build a debug version of the library, a more serious problem might be that of dependencies. If a release version of a binary links to <...
<p>Ignoring for the moment the other suggestions such as getting a release version, which is valid. The tool the developers would be looking for is actually <code>link.exe</code> from Visual Studio (or the SDK or WDK).</p> <p>If they would like you to be able to make use of a debugger together with their code they cou...
22,874
<p>Knuth <a href="http://www-cs-faculty.stanford.edu/~knuth/news08.html" rel="nofollow noreferrer">recently objected</a> to 64-bit systems, saying that for programs which fit in 4 gigs of memory, "they effectively throw away half of the cache" because the pointers are twice as big as on a 32-bit system.</p> <p>My que...
<p>The answer is: yes it can to a certain extent, although the performance difference is unlikely to be great.</p> <p>Any benchmark to test this will have to do a lot of pointer resolution, which will be difficult to separate out from the noise. Designing a benchmark that will not optimise away is difficult. <a href...
<p>i've seen somewhere that the best mix (on x86 CPUs) is to use a 64-bit OS and 32-bit applications.</p> <p>with a 64-bit OS you get:</p> <ul> <li>ability to handle more than 4GB of address space</li> <li>more, bigger registers to help in data-copying operations</li> </ul> <p>with a 32-bit app you get:</p> <ul> <l...
31,732
<p>I need to pass an ID and a password to a batch file at the time of running rather than hardcoding them into the file.</p> <p>Here's what the command line looks like:</p> <pre><code>test.cmd admin P@55w0rd &gt; test-log.txt </code></pre>
<p>Another useful tip is to use <code>%*</code> to mean &quot;all&quot;. For example:</p> <pre><code>echo off set arg1=%1 set arg2=%2 shift shift fake-command /u %arg1% /p %arg2% %* </code></pre> <p>When you run:</p> <pre><code>test-command admin password foo bar </code></pre> <p>The above batch file will run:</p> <pre...
<p>If you're worried about security/password theft (that led you to design this solution that takes login credentials at execution instead of static hard coding without the need for a database), then you could store the api or half the code of password decryption or decryption key in the program file, so at run time, u...
4,610
<p>I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of concept application. This page uses the ASP.NET AJAX UpdatePanel to do partial page updates. The page allows a user to drop an item into a trashcan div, which will invoke a postback that deletes a record from the database, then rebi...
<p>@arilanto - I include this script after my jquery scripts. Performance wise, it's not the best solution, but it is a quick easy work around.</p> <pre><code>function IESafeOffsetParent(elem) { try { return elem.offsetParent; } catch(e) { return document.body; } } // The...
<p>i tried the following workaround for the <strong>getBoundingClientRect()</strong> unspecified error whilst drag n drop, and it works fine.</p> <p>in the jquery.1.4.2.js (<em>i.e base jquery file, where the error is thrown exactly</em>)</p> <p>replace the <strong>elem.getBoundingClientRect()</strong> function call ...
48,547
<p>I'm using VisualSVN Server to host an SVN repo, and for some automation work, I'd like to be able to get specific versions via the http[s] layer.</p> <p>I can get the HEAD version simply via an http[s] request to the server (httpd?) - but is there any ability to specify the revision, perhaps as a query-string? I ca...
<p>Better late than never; <a href="https://entire/Path/To/Folder/file/?p=REV" rel="noreferrer">https://entire/Path/To/Folder/file/?p=REV</a></p> <p>?p=Rev specifies the revision</p>
<p>Subversion does not publicly document the Uris it uses internally to access that information. (And where it is documented, it is explicitly stated that this can change in future versions)</p> <p>To access this information on the web you could use a web viewer (E.g. <a href="http://websvn.tigris.org" rel="nofollow n...
19,062
<p>I am trying to unlock a file from a C# program, using unlocker.</p> <p>In my UI, I put a button to unlock the file the app couldn't delete. When the user pushes the button, I want unlocker (the famous app) to be opened.</p> <p>I have read about in the Unlocker web, and there is some explanations about the commandl...
<p>If unlocker comes with parameters -L and -U, I don't think L would be the one you want to unlock with. Probably U is for unlocking ;)</p> <p>If you have any control of the application that is locking the file, it would be a better solution to have that program free the file rather than a third party app rip it awa...
<p>Look at the documentation for the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx" rel="nofollow noreferrer">System.Diagnostics.Process</a> class and the related ProcessStartInfo class.</p>
42,458
<p>Other than pencil &amp; paper? I found freemind, the mapping tool very useful. Any other ideas?</p>
<p>Personally I like physical paper notebooks and pencils to workout ideas :-), but some times I use <a href="http://freemind.sourceforge.net/" rel="nofollow noreferrer">FreeMind</a>.</p> <p>Check this list of <a href="http://en.wikipedia.org/wiki/List_of_mind_mapping_software" rel="nofollow noreferrer">Mind Mapping ...
<p>A whiteboard and a camera to capture what's on the whiteboard quickly, to be able to move on to the next thing.</p>
44,601
<p>Since both a <code>Table Scan</code> and a <code>Clustered Index Scan</code> essentially scan all records in the table, why is a Clustered Index Scan supposedly better?</p> <p>As an example - what's the performance difference between the following when there are many records?:</p> <pre><code>declare @temp table( ...
<p>In a table without a clustered index (a heap table), data pages are not linked together - so traversing pages requires a <a href="http://msdn.microsoft.com/en-us/library/ms188270.aspx" rel="noreferrer">lookup into the Index Allocation Map</a>.</p> <p>A clustered table, however, has it's <a href="http://msdn.microso...
<p>A table scan has to examine every single row of the table. The clustered index scan only needs to scan the index. It doesn't scan every record in the table. That's the point, really, of indices.</p>
3,930
<p>I have been working in a web project(asp.net) for around six months. The final product is about to go live. The project uses SQL Server as the database. We have done performance testing with some large volumes of data, results show that performance degrades when data becomes too large, say 2 million rows (timeout is...
<p>In the scheme of things, a few million rows is not a particulary large Database.</p> <p>Assuming we are talking about an OLTP database, denormalising without first identifying the root cause of your bottlenecks is a <strong>very, very bad idea</strong>. </p> <p>The first thing you need to do is profile your query ...
<p>We've always tried to develop using a database that is as close to the "real world" as possible. That way you avoid a lot of gotcha's like this one, since any ol' developer would go mental if his connection kept timing out during debugging. The best way to debug Sql performance problems IMO is what Mitch Wheat sugge...
20,048
<p>I'd like to convert a Parallels Virtual Machine image on my mac into an image usable by Virtual PC 2007. Does anyone know how to do that, or if it is possible?</p>
<p>It looks like qemu-img from <a href="http://bellard.org/qemu/" rel="nofollow noreferrer">qemu</a> can do this, at least looking at its commandline help on a Ubuntu 8.04 machine where it claims support for, among others, the "parallels" and the "vpc" format.</p> <p>Have not tried myself, though. Hope this helps.</p>...
<p>If it's a Windows image, I would mount the VM using a tool like <a href="http://www.prowesscorp.com/support/help/smartdeploy_vdc/Welcome_to_SmartVDK_v1.0.htm" rel="nofollow noreferrer">SmartVDK</a>, then capture the VM with ImageX to a WIM file. You can then mount a blank VHD with SmartVDK and apply the image using...
8,998
<p>The market is flooded with VPS (virtual private server) hosting options. It seems everyone and their mother has a overloaded server in his/her closet. Enterprise options always seem priced insanely high, which make the ones that are cheap and claim enterprise level seem shaky.</p> <p>What do you look for in a qua...
<p>Most virtual hosting platforms will have a trial period in which you can test out their reliability. They will also give you a list of their high profile sites on their systems. Most keep track of the traffic hogs as it's a great way for them to attest their own stability.</p> <p>I would recommend <a href="http://w...
<p>I've tried quite a few of them. The only one that I can recommend wholeheartedly is <a href="http://www.slicehost.com/" rel="nofollow noreferrer">Slicehost</a>. They are incredibly good at what they do. I have many clients running on their systems.</p>
13,487
<p>I've got menu items that look like this</p> <pre><code>&lt;ul&gt; &lt;li&gt;Item1&lt;span class="context-trigger"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;Item2&lt;span class="context-trigger"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;Item3&lt;span class="context-trigger"&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; </co...
<p>try using </p> <pre><code>white-space: nowrap; </code></pre> <p>in the css definition of your context-trigger class.</p> <p>Edit: I think patmortech is correct though, putting nowrap on the span does not work, because there is no "white space" content. It might also be that sticking the style on the LI element do...
<p>If you float the <code>&lt;li&gt;</code> elements, you should get the effect you want.</p>
32,802
<p>We have a system that is concurrently inserted a large amount of data from multiple stations while also exposing a data querying interface. The schema looks something like this (sorry about the poor formatting):</p> <pre><code>[SyncTable] SyncID StationID MeasuringTime [DataTypeTable] TypeID TypeName ...
<ol> <li><p>What type of disk system will you be using? If you have a large striped RAID array, writes should perform well. If you can estimate your required reads and writes per second, you can plug those numbers into a formula and see if your disk subsystem will keep up. Maybe you have no control over hardware...</...
<ol> <li><p>What type of disk system will you be using? If you have a large striped RAID array, writes should perform well. If you can estimate your required reads and writes per second, you can plug those numbers into a formula and see if your disk subsystem will keep up. Maybe you have no control over hardware...</...
36,528
<p>We have an intranet site backed by SVN, such that the site is a checkout out copy of the repository (working folder used only by IIS). Something on the site has been causing problems today, and I want to know how to find out what was checked out to that working folder in the last 48 hours.</p> <p><strong>Update:</...
<p>All the code in the web folder should be backed by SVN commits, shouldn't it?</p> <p>If this is the case you should easily be able to track the problem down just by looking through your SVN logs at the last few changes that got committed. <code>svn info</code> will tell you which revision the working copy currently...
<p>I would run a <em>svn st</em> in the web folder (to find any files that are changed since the checkout) and compare that to the repository.</p>
7,882
<p>Can anyone give an idea of how should I implement undo/redo of cutting/copying/pasting of files (dirs, subdirs) mapped in a treeview in C#?</p> <p>It would be great to have some code samples.</p>
<p>Undo / redo is typically implemented using the so-called "command pattern". Search with Google or read the following article:</p> <blockquote> <p><a href="http://blogs.vbcity.com/jspano/articles/198.aspx" rel="noreferrer">http://blogs.vbcity.com/jspano/articles/198.aspx</a></p> </blockquote>
<p>For a quick linear undo/redo, you can use <a href="http://www.dofactory.com/Patterns/PatternMemento.aspx" rel="nofollow noreferrer">Memento pattern</a> using zip of file as memento.</p>
48,049
<p>I came across this snippet of code on MSDN:</p> <pre><code>entityBuilder.Metadata = @"res://*/AdventureWorksModel.csdl| res://*/AdventureWorksModel.ssdl| res://*/AdventureWorksModel.msl"; </code></pre> <p>What does the <code>res://*/</code> mean and how does ...
<p>You've got the right idea:</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa767740.aspx" rel="nofollow noreferrer" title="res protocol">res protocol</a></p> <p>EDIT: Incidentally, you should check <a href="http://searchdotnet.com/" rel="nofollow noreferrer" title="searchdotnet">searchdotnet</a> for techni...
<p>The 'res' protocol allows only access to unmanaged win32 resources, for managed .net assemblies use the new 'resx' protocol: <a href="http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/097794c5-6acd-4563-8237-5e385ca7e563" rel="nofollow">MSDN</a></p>
39,318
<p>Coming from <a href="https://stackoverflow.com/questions/356778/php-query-single-value-per-iteration-or-fetch-all-at-start-and-retrieve-from-ar">another question of mine</a> where I learnt not to EVER use db queries within loops I consequently have to learn how to fetch all the data in a convenient way before I loop...
<p>The query should look something like this:</p> <pre><code>SELECT * FROM scales INNER JOIN items ON scales.id = items.scale_id </code></pre> <p>If you want to iterate through with nested loops, you'll need to pull this data into an array - hopefully you're not pulling back so much that it'll eat up too much memory....
<p>It might be easier to first get all the scales, then all the items.</p> <pre><code>//first get scales while ($row = fetchrowfunctionhere()) { $scale = $scales-&gt;createFromArray($row); } //then get items $lastId = null; while ($row = fetchrowfunctionhere()) { $scaleId = $row['scaleID']; if ($lastId !=...
46,571
<p>I have a project where multiple developers are using a copy of the same windows Virtual PC image (W2K3 SE SP2). Because our solution is tied to the machine-name (less than ideal, i know) all of the developers have the same machine name.</p> <p>We use a VPN to connect to a remote system, upon connection we get the ...
<p>You can't. The compiler needs to know the size of the object when declaring the class.</p> <p>References are an alternative, although they have to be instantiated at construction time, so it's not always feasible.</p> <p>Another alternative are smart pointers, but I suppose that's technically still a pointer.</p> ...
<p>If you are able to use a reference, you can retain the same use syntax. However, your reference has to be initialised straight away in the constructor, so your ctor absolutely must be defined out-of-line. (You will also need to free the object in the destructor too.)</p> <pre><code>// bar.h class foo; class bar { ...
39,347
<p>Using only ANSI C, is there any way to measure time with milliseconds precision or more? I was browsing time.h but I only found second precision functions.</p>
<p>There is no ANSI C function that provides better than 1 second time resolution but the POSIX function <a href="http://www.opengroup.org/onlinepubs/000095399/functions/gettimeofday.html" rel="noreferrer"><code>gettimeofday</code></a> provides microsecond resolution. The clock function only measures the amount of tim...
<p>Under windows:</p> <pre><code>SYSTEMTIME t; GetLocalTime(&amp;t); swprintf_s(buff, L"[%02d:%02d:%02d:%d]\t", t.wHour, t.wMinute, t.wSecond, t.wMilliseconds); </code></pre>
47,159
<p>For example, referencing something as System.Data.Datagrid as opposed to just Datagrid. Please provide examples and explanation. Thanks.</p>
<p>The benefit is that you don't need to add an import for everything you use, especially if it's the only thing you use from a particular namespace, it also prevents collisions.</p> <p>The downside, of course, is that the code balloons out in size and gets harder to read the more you use specific qualifiers.</p> <p>...
<p>I don't think there is really a downside, just readability vs actual time spent coding. In general if you don't have namespaces with ambiguous object I don't think it's really needed. Another thing to consider is level of use. If you have one method that uses reflection and you are alright with typeing System.Ref...
12,452
<p>OK, this begins to drive me crazy. I have an asp.net webapp. Pretty straightforward, most of the code in the .aspx.vb, and a few classes in App_Code.</p> <p>The problem, which has begun to occur only today (even though most of the code was already written), is that once in a while, I have this error message :</p> ...
<p>I think I found the problem.</p> <p>My code was like that :</p> <pre><code>Imports CMS Sub Whatever() Dim a as new Arbo.MyObject() ' Arbo is a namespace inside CMS Dim b as new Util.MyOtherObject() ' Util is a namespace inside Util End Sub </code></pre> <p>I'm not sure why I wrote it like that, but it tu...
<p>Sounds like it happens every time the website spins up (the app gets recycled every time you touch app_code and probably you have IIS configured to shut down the website after X minutes of inactivity).</p> <p>I bet it has something to do with the asp.net worker process not having the correct access rights on the se...
11,063
<p>We've just "upgraded" our production database server from 32-bit to 64-bit. It's running SQL Server 2005 Standard on Windows Server 2003. During the night after the upgrade the server was unavailable for nearly an hour - client requests were timing out. The problem then seemed to fix itself. The only clue I have as ...
<p>2GB is certainly not very much. In fact I believe Microsoft recommends that you have 2GB of memory just to run the OS and other tasks.</p> <p><a href="http://blogs.msdn.com/slavao/archive/2006/11/13/q-a-does-sql-server-always-respond-to-memory-pressure.aspx" rel="nofollow noreferrer">Check this blog posting</a> and...
<p>There's been some sporadic reports of MSSQL allocating enough memory to cause page faulting to disk<a href="http://support.microsoft.com/kb/918483/en-us" rel="nofollow noreferrer">1</a> - which, of course, results in drastically decreased performance.</p> <p>Though I haven't seen anything official from MS, reports ...
23,034
<p>Most ASP.NET hosts give you a single website in IIS. Then, they let you set subfolders as applications. Are there any shared ASP.NET 3.5 hosts that give you multiple websites with a single account?</p> <p>I have several low traffic websites that don't use much bandwidth.</p>
<p>WebHost4Life offers this, though there's a small charge per domain. ($15/year or so). I'm sure most hosts can do this, but fees vary.</p>
<p>I find that for low bandwidth websites that the lower end packages at <a href="http://www.vpsland.com/ezwin.html" rel="nofollow noreferrer">http://www.vpsland.com/ezwin.html</a> You get the control of Remote Desktop and loading pretty much anything you want starting at $18. The only issue I had with them was their ...
37,283
<p>I need my .net application to use the .html extension instead of .aspx </p> <p>I'm converting a php app and there are external applications which depend on that extension to function.</p> <p>What is the best way to do this?</p> <p>Thanks</p>
<p>In IIS, when you create the application for the virtual directory, click on "Configuration" for the application, and edit "App mappings", i.e. add a new mapping for html.</p> <p>Or, in your web.config, in add this sections:</p> <pre><code>&lt;httpHandlers&gt; &lt;remove verb="*" path="*.html" /&gt; &lt;add ...
<p>Note that I am not 100% sure this will work with the PHP extension, we are using this procedure for a custom extension here.</p> <p>You can change the IIS configuration: Open the IIS Console (right click on My Computer > Manage... > Services and applications)</p> <ul> <li>If you are in a website, open the websites...
29,757
<p>I have an application that uses a cron like job to update a set of data. The update process happens once a minute and doesn't last long. A servlet exposes this data set to the users. My problem is that during the update process, the servlet requests should block and wait for the process to complete. </p> <p>In bott...
<p>You can use a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReadWriteLock.html" rel="nofollow noreferrer">ReadWriteLock</a> instead of synchronize. </p> <blockquote> <p>A ReadWriteLock maintains a pair of associated locks, one for read-only operations and one for writing. The read lo...
<p>You need to synchronize access on the data.</p> <pre><code>public void updateData() { synchronized (updateLock) { /* do stuff. */ } } public List getData() { List data; synchronized (updateLock) { data = getRealData(); } /* process/return data. */ } </code></pre>
48,481
<p>Is anyone using the business intelligence tool Inetsoft Style Report ? I'm stuck with it and was wondering if anyone has advice on tuning and/or best practices for server admin? We are running on a fast Solaris box using Tomcat with a db2 database. </p>
<p>You have my sympathy. We run ours on a dual Xeon with 4G ram, and it's still a pig. One of our programmers is an ex-Inetsoft employee and has done everything known to optimize it.</p> <p>My only suggestion is if your organization is considering StyleReport, run!</p>
<p>One thing you can check is whether the CPU is fully utilized when the server is running. If it's not at or close to 100%, check the Tomcat thread pool size and try increase it. There should be parameters in StyleReport to control it's thread pool sizes too. Normally if the CPUs are fully utilized, the performance sh...
31,293
<p>I keep a JMS connection always open, because I have a MessageListener on it. </p> <p>Is it a common need to worry about minimizing maintenance of applications with long lived JMS connections? </p> <p>I was thinking something along the lines of try to recover from some possible common well known kinds of failure, l...
<p>A good JMS provider will deal with network outages such as a dropped socket or a message broker failing over or being rebooted. e.g. here is how you <a href="http://activemq.apache.org/how-do-i-configure-automatic-reconnection.html" rel="nofollow noreferrer">enable automatic reconnection</a> in <a href="http://activ...
<p>Your will need to handle two cases:</p> <ol> <li>Firewall between you and the JMS server. Most firewalls will cut an "idle" connection after a couple of hours. If this is the case, send a message every hour or so or, if you can, enable TCP_KEEPALIVE. This is a TCP/IP option which will cause the underlying socket to...
44,202
<p>If you want to associate some constant value with a class, here are two ways to accomplish the same goal:</p> <pre><code>class Foo { public: static const size_t Life = 42; }; class Bar { public: enum {Life = 42}; }; </code></pre> <p>Syntactically and semantically they appear to be identical from the clien...
<p>The <code>enum</code> hack used to be necessary because many compilers didn't support in-place initialization of the value. Since this is no longer an issue, go for the other option. Modern compilers are also capable of optimizing this constant so that no storage space is required for it.</p> <p>The only reason for...
<p>Well, if needed, you can take the address of a static const Member Value. You've have to declare a separate member variable of enum type to take the address of it.</p>
25,110
<p>By default, IIS6 does not serve .json (no wildcard <code>MIME</code> type).</p> <p>Therefore a 404 not found is thrown. I then add a new MIME type <code>(.json, text/plain or application/x-javascript or application/json)</code> which works fine.</p> <p>However, when you then add a new mapping <code>(Home Directory...
<p>By default, IIS in W2K3 and above won't serve files that aren't of a MIME type that it knows about (instead returning 404 errors).</p> <p>You need to add a MIME type to IIS to allow it to serve that type of file. You can set it at the site level or at the server level.</p> <p>To set this for the entire server:</p>...
<p>If you don't have IIS installed, obviously, you'll want to install it prior to launching the IIS Manager. I needed (on Windows 7) to go to: 'control panel/program and features' then click 'turn windows features on or off'</p> <p>Reference: <a href="http://www.howtogeek.com/howto/windows-vista/how-to-install-iis-on-...
43,160
<p>Looking to do a very small, quick 'n dirty side project. I like the fact that the Google App Engine is running on Python with Django built right in - gives me an excuse to try that platform... but my question is this:</p> <p>Has anyone made use of the app engine for anything other than a toy problem? I see some goo...
<p>I have tried app engine for my small quake watch application <a href="http://quakewatch.appspot.com/" rel="nofollow noreferrer">http://quakewatch.appspot.com/</a></p> <p>My purpose was to see the capabilities of app engine, so here are the main points:</p> <ol> <li>it doesn't come by default with Django, it has it...
<p>Take a look the the <a href="http://mysqlgame.appspot.com/" rel="nofollow noreferrer">sql game</a>, it is very stable and actually pushed traffic limits at one point so that it was getting throttled by Google. I have seen nothing but good news about App Engine, other than hosting you app on servers someone else con...
13,541
<p>I'm developing a shareware desktop application. I'm to the point where I need to implement the trial-use/activation code. How do you approach something like this? I have my own ideas, but I want to see what the stackoverflow community thinks.</p> <p>I'm developing with C++/Qt. The intended platform is Windows/Mac/L...
<p><strong>What to protect against and what not to protect against:</strong></p> <p>Keep in mind that people will always find a way to get around your trial period. So you want to make it annoying for the person to have to get around your trial period, but it doesn't matter if it's impossible to get around you trial ...
<p>If you are [fairly] likely to have a network connection, you can have the installer register with your website, then check against it every time it starts.</p> <p>If that's not feasible, writing a value into a world-modifiable point on the filesystem (a registry entry, entry in and /etc conf file, etc) may be worka...
24,105
<p>I am looking for pointers to the solution of the following problem: I have a set of rectangles, whose height is known and x-positions also and I want to pack them in the more compact form. With a little drawing (where all rectangles are of the same width, but the width may vary in real life), i would like, instead o...
<p>Your problem is a simpler variant, but you might get some tips reading about heuristics developed for the "binpacking" problem. There has been a lot written about this, but <a href="http://en.wikipedia.org/wiki/Bin_packing_problem" rel="nofollow noreferrer">this page</a> is a good start. </p>
<p>Put a tetris-like game into you website. Generate the blocks that fall and the size of the play area based on your paramters. Award points to players based on the compactness (less free space = more points) of their design. Get your website visitors to perform the work for you.</p>
18,480
<p>I have a logical error. I provided the following as input:</p> <ul> <li>the salary is 30000</li> <li>the child n° is 9</li> </ul> <p>So the the net salary will be:</p> <ul> <li><p>the family bonus + salary - tax</p> <pre><code> (750) + (30000) - (3000) </code></pre></li> <li><p>but my program count them as...
<p>I took the existing code, and hard-wired the inputs (rather than using Console.ReadLine()), I get:</p> <blockquote> <p>You are 28 years old Salary= 30000 Tax= 3000 Family bonus= 750 Net= 25500</p> </blockquote> <p>The main problem seems to be not initializing values - i.e. treating fields as variables:</p> <p...
<p>Another problem seems to lie in the fact that you don't initialize familybonus when you say familybonus += 300. So everytime you call GetFamilybonus it's added to the previous result. You call it twice in the PrintEmployee function, once directly and once indirectly by calling getNet;</p>
36,909
<p>What is the best way to iterate through a strongly-typed generic List in C#.NET and VB.NET?</p>
<p>For C#:</p> <pre><code>foreach(ObjectType objectItem in objectTypeList) { // ...do some stuff } </code></pre> <p>Answer for VB.NET from <strong>Purple Ant</strong>:</p> <pre><code>For Each objectItem as ObjectType in objectTypeList 'Do some stuff ' Next </code></pre>
<p>I may be missing something, but iterating through a generic list should be fairly simple if you use my examples below. The List&lt;> class implements the IList and IEnumerable interfaces so that you can easily iterate through them basically any way you want.</p> <p>The most efficient way would be to use a for loop:...
3,600
<p>What is the Big-O time complexity of the following nested loops:</p> <pre class="lang-cpp prettyprint-override"><code>for (int i = 0; i &lt; N; i++) { for (int j = i + 1; j &lt; N; j++) { System.out.println(&quot;i = &quot; + i + &quot; j = &quot; + j); } } </code></pre> <p>Would it be <em>O(N^2)</em...
<p>Yep, it's still O(n^2), it has a smaller constant factor, but that doesn't affect O notation.</p>
<p>Yes, it would be N squared. The actual number of steps would the sum of 1 to N, which is .5*(N - 1)^2, if I'm not mistaken. Big O only takes into account the highest exponant and no constants, and thus, this is still N squared.</p>
47,255
<p>PLA has a heat capacity of <a href="https://www.sd3d.com/wp-content/uploads/2017/06/MaterialTDS-PLA_01.pdf" rel="nofollow noreferrer">1.8-2.1 J/g-K</a>, while <a href="http://www.matweb.com/search/datasheet_print.aspx?matguid=4de1c85bb946406a86c52b688e3810d0" rel="nofollow noreferrer">PETG 1.1-1.3 J/g-K</a>. This me...
<p>I'm adding this answer to somewhat challenge the findings of my original answer, and the premise of the question: PETG does not need lower print speeds, and can even be printed at higher speeds than PLA under some conditions due to reduced need for cooling. You can see this from some of the &quot;#speedboatrace&quot...
<p>The density of PLA is around 1.25 g/cm³ and the density of PETG is around 1.38 g/cm³. When you're talking about the amount of energy needed to melt a particular <em>volume</em> (which is what your extrusion units are) rather than mass, you need to scale the heat capacities (with units of <span class="math-container"...
1,633
<p>How do I write code where a company icon appears on the left side next to the URL address in the browser's address bar?</p>
<p>You are looking for a <a href="https://stackoverflow.com/questions/6642/preferred-way-to-use-favicons#6645">Favicon</a>.</p>
<p>load a file on the webserver called <a href="https://stackoverflow.com/favicon.ico">favicon.ico</a></p>
3,135
<p>I have had a bug recently that only manifested itself when the library was built as a release build rather than a debug build. The library is a .NET dll with a COM wrapper and I am using CoCreateInstance to create a class from the dll in an unmanaged c++ app. When I finally tracked the bug down it was caused by ac...
<p>Try adding an (empty) static constructor, or initialize the singleton <em>in</em> a static constructor.</p> <p>Jon Skeet has a full discussion of singleton patterns <a href="https://csharpindepth.com/articles/Singleton" rel="nofollow noreferrer">here</a>. I'm not sure why it failed, but at a guess it could relate to...
<p>Just reiterating what Marc Gravell said, but it sounds <em>a lot</em> like a beforefieldinit problem, which means the empty static constructor is your solution. You'd need to post any and all constructors in the class to get a definitive answer.</p> <p>The second method has the advantage of lazy loading (where that...
26,794
<p>With more and more code pushed to the Views in Asp.Net MVC (i.e. AJAX, JQuery, etc...), how do you maintain the 'testability'?</p> <ul> <li>How do you test your Views?</li> <li>How do you test your views with client-side jscript code?</li> <li>How do you test your Views with Async behavior?</li> </ul> <p>It seems ...
<p><a href="http://selenium.openqa.org/" rel="nofollow noreferrer">Selenium</a> is a great tool for testing the front end of any web app. It is written in the browser's native language, JavaScript. Having the browser run the test framework code gives your tests the ability to expose browser incompatibility issues. ...
<p>Also see other free browser automation tools like ArtOfTest and WatiN. The Selenium stack can be a little complicated to set up.</p>
18,896
<p>Ten years ago when I first encountered the <a href="http://en.wikipedia.org/wiki/Capability_Maturity_Model" rel="noreferrer">CMM for software</a> I was, I suppose like many, struck by how accurately it seemed to describe the chaotic "level one" state of software development in many businesses, particularly with its ...
<p>At the heart of the matter lies this problem, neatly described by the CMM guidance itself...</p> <p>“<em>...Sound judgment is necessary to use the CMM correctly and with insight. Intelligence, experience and knowledge must shape an appropriate interpretation of the CMM in a specific environment. That interpretation...
<p>At school, I was taught: CMM is a good Idea, but lacking certification (anyone can say they are level 5 / level 4) it ends up being a marketing tool for offshore shops. So, yeah, the idea is sound, but how do you prove adherence?</p>
9,106
<p><strong>For a particular segment of Java code, I'd like to measure:</strong></p> <ul> <li><strong>Execution time (most likely <em>thread execution time</em>)</strong></li> <li><strong>Memory usage</strong></li> <li><strong>CPU load (specifically attributable to the code segment)</strong></li> </ul> <p>I'm a relati...
<p>Profiling may be an easier option since you don't require in-production stats. Profiling also doesn't require code modification. VisualVM (which ships w/ the JDK 1.6.06+) is a simple tool. If you want something more in-depth I'd go with Eclipse TPTP, Netbeans profiler, or JProfiler(pay).</p> <p>If you want to write...
<p>We can measure the cpu and memory used during a specific invoked method by collecting the cpu and memory metrics during its execution.<br> Of course if other concurrent threads for other methods consumes memory and cpu during its execution, you are stuck. So it is a valid approach while you are able to execute a m...
38,769
<p>I maintain several old MFC applications using Visual Studio 7 and I was considering upgrading to Visual Studio 2008. After reading <a href="https://stackoverflow.com/questions/86562/what-is-missing-in-the-visual-studio-express-editions#86614">this question</a>, I realise that the Express edition will not be able to ...
<p>Packaging GTK and its dependencies on Windows is a full-time project in itself. Qt is much more easily distributed since it has no dependencies that do not come with Windows.</p> <p>Qt has been cross platform from the start. GTK has not always been cross platform. Such fundamental decisions shape the overall design...
<p>I recommend to use Qt because:</p> <ul> <li>It's cross-platform and and covers wide range of operating systems (including mobile)</li> <li>It is opensource and has a fast speed in getting better</li> <li>It has the a nice GUI designer and a very capable IDE (Qt Creator)</li> <li>The API design is excellent and easy...
24,331
<p>What is the difference between Obfuscation, Hashing, and Encryption?</p> <p>Here is my understanding: </p> <ul> <li>Hashing is a one-way algorithm; cannot be reversed </li> <li>Obfuscation is similar to encryption but doesn't require any "secret" to understand (ROT13 is one example) </li> <li>Encryption is reve...
<p>Hashing is a technique of creating semi-unique keys based on larger pieces of data. In a given hash you will eventually have "collisions" (e.g. two different pieces of data calculating to the same hash value) and when you do, you typically create a larger hash key size.</p> <p>obfuscation generally involves trying...
<p>All fine, except obfuscation is not really similar to encryption - sometimes it doesn't even involve ciphers as simple as ROT13.</p>
22,291
<p>When hosting a WCF service on IIS you have an option of manually configuring the endpoint or declaratively by means of WebServiceHostFactory. It doesn't seem to be that difficult to manually create the endpoint so I figured I would ask.</p> <ul> <li>What are the benefits of using WebServiceHostFactory? </li> <li>Ar...
<p>Can you clarify : are you asking specifically about <strong>Web</strong>ServiceHostFactory (emph: "Web")? Or just the difference between IIS hosting it vs starting your own server through code?</p> <p>WebServiceHostFactory is new in .NET 3.5, and supports some of the newer AJAX/JSON stuff.</p> <p>Actually, within...
<p>I am definitely not an expert (yet), but cons that come to mind are:</p> <ul> <li>you can only have one authentication method at a time (ie. not both Windows and anonymous) cf. <a href="https://stackoverflow.com/questions/575021/webservicehostfactory-and-iis-authentication">WebServiceHostFactory and IIS authenticat...
32,559
<p>I want to write an <code>onClick</code> event which submits a form several times, iterating through selected items in a multi-select field, submitting once for each. </p> <p><strong>How do I code the loop?</strong></p> <p>I'm working in Ruby on Rails and using <code>remote_function()</code> to generate the JavaSc...
<p>My quick answer (as I've not coded it yet) would be to create another function that creates a POST using XMLHTTPRequest and the specific parameters for a single call. Then inside your onClick() handler call that function as you loop through your selected items.</p> <p>I would suggest that you do a Proof of Concept ...
<p>Unless you're modifying the browser DOM, I can't think of a reason that you would want to do this. (But without knowing fully what you're trying to do, I could be wrong in this case =)</p> <p>You should be able to send back data from mulitple objects (even nested complex objects in your form) in just one POST.</p> ...
8,656
<p>i got a client side javascript function which is triggered on a button click (basically, its a calculator!!). Sometimes, due to enormous data on the page, the javascript calculator function take to long &amp; makes the page appear inactive to the user. I was planning to display a transparent div over entire page, ma...
<p>Javacript to show a curtain:</p> <pre><code>function CalculateAmountOnClick () { var curtain = document.body.appendChild( document.createElement('div') ); curtain.id = "curtain"; curtain.onkeypress = curtain.onclick = function(){ return false; } try { // your operations } finally { curtain.paren...
<p>In addition to all of the above, don't forget to put an invisible iframe behind the shim, so that it shows up above select boxes in IE.</p> <p>Edit: This site, although it provides a solution to a more complex problem, does cover creating a modal background. <a href="http://www.codeproject.com/KB/aspnet/ModalDialog...
25,192
<p>I'm executing several discrete queries in a single batch against SQL Server. For example:</p> <pre> update tableX set colA = 'freedom'; select lastName from customers; insert into tableY (a,b,c) values (x,y,z); </pre> <p>Now, I want to capture the result in a DataSet (from select statement) which is easy enough ...
<p>look into SQL Connection events. I think that's what you're after: <a href="http://msdn.microsoft.com/en-us/library/a0hee08w.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/a0hee08w.aspx</a></p>
<p>Nick is right to suggest <code>@@ROWCOUNT</code> - in fact, as a matter of routine I always use <code>SET NOCOUNT ON</code>, which has a (small) performance benefit - but more importantly, this detail is an implementation detail - so you code shouldn't care...</p> <p>If you want to return a value (such as number of...
38,423
<p>So I've seen some very good design software, but almost all of it is very expensive. I'm just wondering if there's a good cheap design software out there.</p>
<p>Try Fusion 360. It's free for educators, students, enthusiasts and start-ups. It's not 100% intuitive, but once you learn the basics, it probably has all the facilities that you will ever need for mechanical design.</p>
<p>Try Fusion 360. It's free for educators, students, enthusiasts and start-ups. It's not 100% intuitive, but once you learn the basics, it probably has all the facilities that you will ever need for mechanical design.</p>
707
<p>I have a <code>QDirModel</code> whose current directory is set. Then I have a <code>QListView</code> which is supposed to show the files in that directory. This works fine.</p> <p>Now I want to limit the files shown, so it only shows <em>png</em> files (the filename ends with .png). The problem is that using a <cod...
<p>We ran into something similar where I work, and ended up making our own proxy model to do our filtering. However, looking through the documentation for what you want (which seems like it would be a more common case), I came across two possibilities.</p> <ol> <li>You might be able to set a name filter on the QDirMo...
<p>Just use <a href="http://api.kde.org/frameworks-api/frameworks5-apidocs/kitemmodels/html/classKRecursiveFilterProxyModel.html" rel="nofollow">KRecursiveFilterProxyModel</a> model from the <a href="http://api.kde.org/frameworks-api/frameworks5-apidocs/kitemmodels/html/index.html" rel="nofollow">KItemModels</a> KDE AP...
31,232
<p>I want to display some WPF elements near to the selected item of a ListView. How can I obtain the coordinates (screen or relative) of the selected ListViewItem? </p> <pre><code>&lt;ListView x:Name="TechSchoolListView" ClipToBounds="False" Width="Auto" Height="Auto" HorizontalContentAlignment="Stre...
<p>You should use <a href="http://msdn.microsoft.com/en-us/library/aa346420.aspx" rel="nofollow noreferrer">ContainerFromElement</a> to get the item's container, which is a visual and from there you can get the coordinates. You can't express this in XAML, however. You need to do it in code, on one of the ListView event...
<p>Although Franci Penov's answer is correct I would like to give a code sample to show how what he was saying worked for me.</p> <pre><code>UIElement selectedContainer = (UIElement)(sender as ListView).ItemContainerGenerator.ContainerFromIndex((sender as ListView).SelectedIndex); Point startPoint = selectedContainer...
26,996
<p>This is really annoying, we've switched our client downloads page to a different site and want to send a link out with our installer. When the link is created and overwrites the existing file, the metadata in windows XP still points to the same place even though the contents of the .url shows the correct address. I...
<p>Take a look at here: <a href="http://www.cyanwerks.com/file-format-url.html" rel="nofollow noreferrer">http://www.cyanwerks.com/file-format-url.html</a></p> <p>It explains there's a Modified field you can add to the .url file. It also explains how to interpret it.</p>
<p>.URL files are wierd (are they documented anywhere?)</p> <p>Mine look like this and I don't seem to have that problem (maybe because of the Modified entry?)</p> <pre><code>[DEFAULT] BASEURL=http://www.xxxx.com/Help [InternetShortcut] URL=http://www.xxxx.com/Help Modified=60D0EDADF1CAC5014B </code></pre>
17,062
<p>I'm a bit new to jQuery and hope somebody can help me out.</p> <p>I'm trying to change an element (li) to another element (div) after the (li) has been dropped.</p> <p>Sample code:</p> <pre><code>$("#inputEl&gt;li").draggable({ revert: true, opacity: 0.4, helper: "clone" }); $("#dropEl") .droppa...
<p>So, what you want is to keep your original list intact and drop list items into dropEl? How about this:</p> <pre><code>drop: function(ev,ui) { $(this).append("&lt;div&gt;Some content&lt;/div&gt;"); } </code></pre> <p>Or, if you want to replace the list elements with a div element and also have the div element...
<p>thanx for the reply.</p> <p>Your first code worked, and plus I can also sort the divs in the droppable like this:</p> <pre><code> drop: function(ev, ui) { $(this).append("&lt;div&gt;Some content&lt;/div&gt;"); $("#dropEl").sortable(); } </code></pre> <p><strike>Now the problem is how do I know which li...
36,968
<p>I am a beginner of python and have a question, very confusing for me. If I define a function first but within the function I have to use a variable which is defined in another function below, can I do it like this? Or how can I import the return things of another function into a function? for example:</p> <pre><cod...
<p>The scope of functions <code>hello</code> and <code>hi</code> are entirely different. They do not have any variables in common.</p> <p>Note that the result of calling <code>hi(x,y)</code> is some object. You save that object with the name <code>good</code> in the function <code>hello</code>.</p> <p>The variable ...
<p>The "hello" function doesn't mind you calling the "hi" function which is hasn't been defined yet, provided you don't try to actually use the "hello" function until after the both functions have been defined.</p>
46,658
<p>I realize that since UNIX sockets are platform-specific, there has to be some non-Java code involved. Specifically, we're interested in using JDBC to connect to a MySQL instance which only has UNIX domain sockets enabled. </p> <p>It doesn't look like this is supported, but from what I've read it should be at leas...
<p>Checkout the JUDS library. It is a Java Unix Domain Socket library...</p> <p><a href="https://github.com/mcfunley/juds" rel="noreferrer">https://github.com/mcfunley/juds</a></p>
<p>Some searching on the internet has uncovered the following useful-looking library:</p> <p><a href="http://www.nfrese.net/software/gnu_net_local/overview.html" rel="nofollow noreferrer">http://www.nfrese.net/software/gnu_net_local/overview.html</a></p> <p><a href="http://web.archive.org/web/20080820110115/http://ww...
20,580
<p>Is there a way to dump an entire assemblies source to files using reflector?</p>
<p>Yes, right click on the assembly and choose Export...</p>
<p>Yes, right click on the assembly and choose Export...</p>
33,749
<p>As far as I know, there's no way to use {% include %} within a dynamic JS file to include styles. But I don't want to have to make another call to the server to download styles. </p> <p>Perhaps it would be possible by taking a stylesheet and injecting it into the head element of the document...has anyone does this ...
<p>In your JS file:</p> <pre><code>var style = document.createElement('link'); style.setAttribute('rel', 'stylesheet'); style.setAttribute('type', 'text/css'); style.setAttribute('href', 'style.css'); document.getElementsByTagName('head')[0].appendChild(style); </code></pre> <p>Hope that helps.</p>
<p>I can envision cases where you'd want to dynamically generate JS or CSS, but generally you're better off creating static files for each and making your code general enough to fulfill all your needs.</p> <p>This goes beyond a simple matter of code reuse - if you're dynamically generating any of this, it will need to...
49,766
<p>I am currently working on the authentication of an AJAX based site, and was wondering if anybody had any reccomendations on best practices for this sort of thing.</p> <p>My original approach was a cookie based system. Essentially I set a cookie with an auth code, and every data access changed the cookie. As well,...
<p>Personally, I have not found using SSL for the entire site (or most of it) to be overkill. Maybe a while ago when speeds and feeds were slower. Now I wouldn't hesitate to put any part of a site under SSL. <p> If you've decided that using SSL for the entire site is acceptable, you might consider just using the old ...
<p>What if you put a "generated" timestamp on each of the responses from the server and the AJAX application could always use the cookie with the latest timestamp.</p>
14,470
<p>I wonder what's the best deployment directory for Rails apps? Some developers use directories such as <code>/u/apps/#{appname}</code>. Are there <strong>any</strong> advantages when using <code>/u/apps/#{appname}</code> instead of <code>/var/www/#{appname}</code> or other OS default directories?</p> <p>Obviously I ...
<p>As other people have said, it really doesn't matter where you keep your applications - the thing that does matter is that you're consistent about it, so that whichever server you're on, its just a case of going to the usual location.</p> <p>I think the only reason people use /u/apps/#{appname} is that it's Capistra...
<p>Like the other posters I think you should just put them wherever feels most natural. Read <code>man hier</code> if you'd like to see what directories in the standard UNIX hierarchy are meant for. I like putting things somewhere logical under <code>/var</code></p> <p>Another very important consideration is that you ...
20,096
<p>Here's the scenario: </p> <p>A C# Windows Application project stored in SVN is used to create an executable. Normally, a build server handles the build process and creates builds at regular intervals which are used by testing. In this particular instance I was asked to modify a specific build and create the executa...
<p>The app uses the Regional Settings of the machine it's running on, and it looks like it is your problem. You can force a thread to use a specific culture by setting System.Threading.Thread.CurrentThread.CurrentCulture and System.Threading.Thread.CurrentThread.CurrentUICulture to a specific value.</p>
<p>I had a similar problem once (except in C++) When I compared the sizes of the compiled executables, they were way off. Unfortunately, after days of searching, the best solution I found was to uninstall VS05 and re-install it.</p>
11,247
<p>I usually type my map declarations but was doing some maint and found one without typing. This got me thinking (Oh No!). What is the default typing of a Map declaration. Consider the following:</p> <pre><code>Map map = new HashMap(); map.put("one", "1st"); map.put("two", new Integer(2)); map.put("three", "3rd");...
<p>There is no default type.</p> <p>The types in Java generics are only for compile-time checking. They are erased at runtime and essentially gone.</p> <p>Think of generics as a static helper to a) better document your code, and b) enable some limited compile-time checking for type safety.</p>
<p><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html" rel="nofollow noreferrer">HashMap</a> is a collection of objects, Think C++ containers. Each element of the map is a "bucket" to hold data.<br> You are putting different types of data in the buckets, the hashmap needs to know that these are not...
33,041
<p>If I simply wrap my query with:</p> <pre><code>BEGIN TRANSACTION COMMIT TRANSACTION </code></pre> <p>If anything fails inside of that, will it automatically rollback?</p> <p>From looking at other code, they seem to check for an error, if there is an error then they do a GOTO statement which then calls ROLLBACK...
<p>I typically do something like this inside my stored procedures. It keeps things nice and safe and passes along any errors that I encounter.</p> <pre><code>SET XACT_ABORT ON; BEGIN TRY BEGIN TRANSACTION; -- Code goes here COMMIT TRANSACTION; END TRY BEGIN CATCH IF @@TRANCOUNT &gt; 0 ROLLBA...
<p>For transaction control you use begin, commit and rollback. You begin a transaction by supplying BEGIN TRANSACTION. Then you put the various SQL statements you need. Then you end the transaction by issuing either a commit or rollback. COMMIT TRANSACTION will commit all the changes that you did to the database after ...
37,063
<p>We're using WatiN for testing our UI, but one page (which is unfortunately not under our teams control) takes forever to finish loading. Is there a way to get WatiN to click a link on the page before the page finishes rendering completely?</p>
<p>Here's the code we found to work:</p> <pre><code>IE browser = new IE(....); browser.Button("SlowPageLoadingButton").ClickNoWait(); Link continueLink = browser.Link(Find.ByText("linktext")); continueLink.WaitUntilExists(); continueLink.Click(); </code></pre>
<p>You should be able to leave out the call to WaitUntilExists() since WatiN does this internally when you call a method or property on an element (like the link.Click() in you rexample).</p> <p>HTH, Jeroen van Menen Lead dev WatiN</p>
7,140
<p>We have a project coming up where the PM is insistent that the team should "eat their own dog food"?</p> <p>At what point is it realistic to do this?</p> <p>e.g. assume we have to write an editor. We can't use this editor at the beginning to actually code because it doesn't exist. We have to use another editor.</p...
<p><em>Some</em> of you should be using it as soon as you possibly can. The first version should be stripped-down, with only the most essential features that you <em>need</em> in order to use it as an (in this case) editor. Once you start using it you'll find out in a hurry which features are important.</p>
<p>Depending on how the development in being done you can switch earlier or later. If you are using a TDD methodology or where finding and fixing bugs is higher on the list I would start whenever you have enough features you feel would help your day to day life. This could be really early in the development if you have...
28,253
<p>I have a need to run a relatively large number of virtual machines on a relatively small number of physical hosts. Each virtual machine isn't doing to much - each only needs to run essentially one basic network service - think SMTP or the like. Furthermore, the load on each is going to be extremely light. </p> <p>U...
<p>there are three main fronts to make those fit:</p> <ol> <li><p>lower overhead. OpenVZ, Vserver, chroot, would be ideal if applicable. if you really need each instance be a real VM with it's own kernel, try KVM/Xen instead of VMWare. may be less mature, but you'll have a lot more flexibility.</p></li> <li><p>small...
<p>Cloud Foundry. I know nothing about VMs compared to anyone else who may have submitted an answer, but from what I understand if you have a host, a VM on that host, and then Cloud Foundry on that VM you can easily create a base Secondary VM and easily replicate and configure all of your services within that Secondary...
18,638
<p>Is it even possible to perform address (physical, not e-mail) validation? It seems like the sheer number of address formats, even in the US alone, would make this a fairly difficult task. On the other hand it seems like a task that would be necessary for several business requirements.</p>
<p>Here's a free and sort of "outside the box" way to do it. Not 100% perfect, but it should reject blatantly non-existent addresses.</p> <p>Submit the entire address to <a href="https://developers.google.com/maps/documentation/geocoding/" rel="noreferrer">Google's geocoding web service</a>. This service attempts to ...
<p>For US addresses you can require a valid state, and verify that the zip is valid. You could even check that the zip code is in the right state, but beyond that I don't think there are many tests you could run that wouldn't provide a lot of false negatives.</p> <p>What are you trying to do -- prevent simple mistakes...
16,346
<p>I am using a FORM LABS 3 printer with clear resin. After printing the model, I wash it with Isopropenyl and dry it. Then I cure it using Formlabs Form Cure for 5 minutes under 60 C°. After curing the model, the clear print loses some of its transparency.</p> <p>Is this normal? can it be avoided?</p>
<p>This happens to most resins and the amount of haziness is directly related to the type of resin. Not all clear resins do this mind you, but it has to do with the curing sprlectrum of light(natural sunlight cures do this way worse.)</p>
<p>Clouding is a known issue with colored transparent resins, as is yellowing with clear resin.</p> <p>Uncle Jessy did quite a good video explaining the issue and how to best avoid it.</p> <p>The conclusion was that you should wash and dry them with as little UV exposure as possible (Drying them inside a box in a warm ...
2,097
<p>I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I do to be sure the order of the array is not changed?</p>
<p>I examined the methods of <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable_methods.aspx" rel="noreferrer">System.Linq.Enumerable</a>, discarding any that returned non-IEnumerable results. I checked the remarks of each to determine how the order of the result would differ from order of the sou...
<p>The question here is specifically referring to LINQ-to-Objects.</p> <p>If your using LINQ-to-SQL instead there is no order there unless you impose one with something like: </p> <pre><code>mysqlresult.OrderBy(e=&gt;e.SomeColumn) </code></pre> <p>If you do not do this with LINQ-to-SQL then the order of results can ...
25,033
<p>Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory?</p> <p>To give a bit more of a concrete example, imagine some cron job writing out a file (say, a log file or a tar-ed up backup) to a directory every hour. I'd like a...
<p>The problems with the existing answers:</p> <ul> <li>inability to handle filenames with embedded spaces or newlines. <ul> <li>in the case of solutions that invoke <code>rm</code> directly on an unquoted command substitution (<code>rm `...`</code>), there's an added risk of unintended globbing.</li> </ul> </li> <li>i...
<pre><code>leaveCount=5 fileCount=$(ls -1 *.log | wc -l) tailCount=$((fileCount - leaveCount)) # avoid negative tail argument [[ $tailCount &lt; 0 ]] &amp;&amp; tailCount=0 ls -t *.log | tail -$tailCount | xargs rm -f </code></pre>
4,538
<p>According to this</p> <p><a href="http://perldoc.perl.org/UNIVERSAL.html" rel="noreferrer">http://perldoc.perl.org/UNIVERSAL.html</a></p> <p>I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or CLASS->isa().</p> <p>This means that to find out if something is a reference in the first place and th...
<p>The primary problem is that if you call <code>UNIVERSAL::isa</code> directly, you are bypassing any classes that have overloaded <code>isa</code>. If those classes rely on the overloaded behavior (which they probably do or else they would not have overridden it), then this is a problem. If you invoke <code>isa</co...
<p>Right. It does a wrong thing for classes that overload <code>isa</code>. Just use the following idiom:</p> <pre><code>if (eval { $obj-&gt;isa($class) }) { </code></pre> <p>It is easily understood and commonly accepted.</p>
25,000
<p>With SVN, I had a single big repository I kept on a server, and checked-out on a few machines. This was a pretty good backup system, and allowed me easily work on any of the machines. I could checkout a specific project, commit and it updated the 'master' project, or I could checkout the entire thing.</p> <p>Now, I...
<p>I would <strong>strongly</strong> advise against putting unrelated data in a given Git repository. The overhead of creating new repositories is quite low, and that is a <em>feature</em> that makes it possible to keep different lineages completely separate.</p> <p>Fighting that idea means ending up with unnecessari...
<p>There is another method for having nested git repos, but it doesn't solve the problem you're after. Still, for others who are looking for the solution I was:</p> <p>In the top level git repo just hide the folder in .gitignore containing the nested git repo. This makes it easy to have two separate (but nested!) gi...
5,745
<p>Are there any documented techniques for speeding up mySQL dumps and imports?</p> <p>This would include my.cnf settings, using ramdisks, etc. </p> <p>Looking only for documented techniques, preferably with benchmarks showing potential speed-up.</p>
<ol> <li>Get a copy of <em>High Performance MySQL</em>. Great book. </li> <li>Extended inserts in dumps </li> <li>Dump with --tab format so you can use mysqlimport, which is faster than mysql &lt; dumpfile</li> <li>Import with multiple threads, one for each table.</li> <li>Use a different database engine if possible. i...
<p>Using indexes but not too much, activate query cache, using sphinx for big database, here is some good tips <a href="http://www.keedeo.com/media/1857/26-astuces-pour-accelerer-vos-requetes-mysql" rel="nofollow">http://www.keedeo.com/media/1857/26-astuces-pour-accelerer-vos-requetes-mysql</a> (In French)</p>
9,270
<p>Is there a simple and foolproof way we can test an AJAX installation? We have a problem in calling a webscript using AJAX form a JS file. The error is 'ServiceLib' is not defined. The error gets a few hits on Google.</p> <p>We've added some AJAX functionality to a customer's app. This works fine here in the offi...
<p>Firebug might help - if you can get someone at the far end to install it, it may be able to give you an insight into what is going on with the ajax requests via its console, which logs and gives you the ability to view the return data of all ajax requests.</p>
<p>I'm thinking...</p> <p>There are three parts to the process:<br> 1) The client-side javascript logic in the browser sends the HTTP request to the server.<br> 2) The server-side ASP.NET page processes it and responds.<br> 3) The client-side logic receives the response and updates the web page, or whatever. </p> <p...
41,748
<p>I'm running an xcopy command in a batch script which copies a file to a shared drive on another workstation; however the workstation requires a login before connecting to the share. Is there a way to script the login/connect into the batch file? </p> <p>thanks in advance</p>
<p>You can use the "net use x:\servername\sharename /u:username password" command to login to the share within the batch file. However putting the password into a plaintext batch file is generally a bad idea.</p>
<p>You can use net use to map a temporary drive and login using the credentials. This is what we had to do. Perhaps there is a better way. Then at the end of the script we unmap the drive.</p> <p>Here is a link to the net use command: <a href="http://www.cezeo.com/tips-and-tricks/net-use-command/" rel="nofollow norefe...
41,632
<p>I have a web application project (wap) that is successfully being deployed to a development server by our tfsbuild server.</p> <p>I'd like the build server to run our collection of webtests after deployment.</p> <p>What is a best practice (or ANY practice) for doing this?</p>
<p>You're almost there with your code. I agree with you, the MSDN is not quite explicit on what's inside that byte array, but here's what you can do :</p> <pre><code>IPAddress address = new IPAddress(_ClientIPAddress.Address.Skip(2).Take(4).ToArray()); </code></pre> <p>The first two bytes do not seem to be used, but ...
<p>The real answer can be found here. <a href="http://www.tech-archive.net/Archive/Windows/microsoft.public.windows.terminal_services/2007-03/msg00474.html" rel="nofollow noreferrer">http://www.tech-archive.net/Archive/Windows/microsoft.public.windows.terminal_services/2007-03/msg00474.html</a></p>
36,736
<p>I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. </p> <p>I've found solutions to this problem but they rely on alternative color palettes than RGB. I would rather just use straight RGB than mapping back...
<p>You could average the RGB values of random colors with those of a constant color:</p> <p><em>(example in Java)</em></p> <pre><code>public Color generateRandomColor(Color mix) { Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(25...
<p>you could have them be within a certain brightness. that would control the ammount of "neon" colors a bit. for instance, if the "brightness"</p> <pre><code>brightness = sqrt(R^2+G^2+B^2) </code></pre> <p>was within a certain high bound, it would have a washed out, light color to it. Conversely, if it was within a ...
6,467
<p>Given this:</p> <pre><code>Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() &gt; g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub </code></pre> <p>I want to be able to say this (as I would in Delphi)...
<p>Use the 'AddHandler' and 'AddressOf' keywords to add a handler to the Tick event.</p> <pre> AddHandler timeReminder.Tick, AddressOf timeReminder_Tick </pre>
<p>The <code>addHandler</code> is a very powerful tool.</p> <p>Try using it to add an event to a series of controls within a collection.</p> <p>The handler can add validation or error checking to all types of controls and will work with whatever you add to the form.</p>
18,873
<p>In C# WinForms, what's the proper way to get the backward/forward history stacks for the System.Windows.Forms.WebBrowser?</p>
<p>Check out <a href="http://www.bsalsa.com/downloads.html" rel="nofollow noreferrer">http://www.bsalsa.com/downloads.html</a>. This is a series of Delphi components (free source code, you can see an example of this here: <a href="http://staruml.cvs.sourceforge.net/staruml/staruml/staruml/components/plastic-components/...
<p>It doesn't look like it's possible.</p> <p>My suggestion would be to catch the <strong>Navigated</strong> event and maintain your own list. A possible problem with that is when the user clicks <em>back</em> in the browser, you don't know to unwind the stack.</p>
7,836
<p>What resources have to be manually cleaned up in <em>C#</em> and what are the consequences of not doing so?</p> <p>For example, say I have the following code:</p> <pre><code>myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); // Use Brush </code></pre> <p>If I don't clean up the brush using the d...
<ul> <li>Handles to internal windows data structures.</li> <li>Database connections.</li> <li>File handles.</li> <li>Network connections.</li> <li>COM/OLE references.</li> </ul> <p>The list goes on.</p> <p>It's important to call <code>Dispose</code> or even better yet, use the <code>using</code> pattern.</p> <pre><c...
<p>The garbage collector will handle any managed resources. In your example, the brush will be cleaned up when the garbage collector decides to, which will happen some time after the last reference to the brush is no longer valid.</p> <p>There are certain things that need to be manually cleaned up, but those are point...
14,270