instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Are there good reasons why it's a better practice to have only one return statement in a function? </p>
<p>Or is it okay to return from a function as soon as it is logically correct to do so, meaning there may be many return statements in the function?</p>
| <p>I often have several statements at the start of a method to return for "easy" situations. For example, this:</p>
<pre class="lang-java prettyprint-override"><code>public void DoStuff(Foo foo)
{
if (foo != null)
{
...
}
}
</code></pre>
<p>... can be made more readable (IMHO) like this:</p>
<pre... | <p>I'm usually in favor of multiple return statements. They are easiest to read.</p>
<p>There are situations where it isn't good. Sometimes returning from a function can be very complicated. I recall one case where all functions had to link into multiple different libraries. One library expected return values to b... | 5,731 |
<p>In DB2, you can name a column ORDER and write SQL like</p>
<pre><code>SELECT ORDER FROM tblWHATEVER ORDER BY ORDER
</code></pre>
<p>without even needing to put any special characters around the column name. This is causing me pain that I won't get into, but my question is: why do databases allow the use of SQL k... | <p>I largely agree with the sentiment that keywords shouldn't be allowed as identifiers. Most modern computing languages have 20 or maybe 30 keywords, in which case imposing a moratorium on their use as identifiers is entirely reasonable. Unfortunately, SQL comes from the old COBOL school of languages ("computing langu... | <p>Because object names are ... <em>names</em>. All database systems let you use quoted names to stop you from running into trouble.</p>
<p>If you are running into issues, the fault lies not with the practice of permitting object names to be <em>names</em>, but with faulty implementations, or with faulty code librarie... | 30,465 |
<p>I'm someone who writes code just for fun and haven't really delved into it in either an academic or professional setting, so stuff like these bitwise operators really escapes me.</p>
<p>I was reading an article about JavaScript, which apparently supports bitwise operations. I keep seeing this operation mentioned in... | <p>Since nobody has broached the subject of why these are useful:</p>
<p>I use bitwise operations a lot when working with flags. For example, if you want to pass a series of flags to an operation (say, <code>File.Open()</code>, with Read mode and Write mode both enabled), you could pass them as a single value. This ... | <p>I kept hearing about how slow JavaScript bitwise operators were. I did some tests for <a href="http://dreaminginjavascript.wordpress.com/2009/02/09/bitwise-byte-foolish/" rel="nofollow noreferrer">my latest blog post</a> and found out they were 40% to 80% faster than the arithmetic alternative in several tests. Perh... | 34,897 |
<p>I'm really baffled by this - I know how to do this in VB, unmanaged C++ and C# but for some reason I can't accept a ref variable of a managed type in C++. I'm sure there's a simple answer, really - but here's the C# equivalent:</p>
<pre><code>myClass.myFunction(ref variableChangedByfunction);
</code></pre>
<p>I've... | <p>Turns out in the function declaration you need to use a % after the parameter name:</p>
<p>bool Importer::GetBodyChunk(String^% BodyText, String^% ChunkText)</p>
<p>And then you pass in the variable per usual.</p>
| <p>Just to make it a little clearer:</p>
<p>Parameters of reference types (e.g. System::String) have to be denoted with <code>^</code> in the newer C++/CLI syntax. This tells the compiler that the parameter is a handle to a GC object. </p>
<p>If you need a tracking reference (like with <code>ref</code> or <code>out</... | 16,369 |
<p>Can anyone please tell me if Certifying Authorities (CAs) are allowed to make modifications to the Certificate Signing Request (CSR) before actually signing the certificate with their own private key? </p>
<p>Specifically, I'd like to know if it's valid for the CA to insert additional fields (such as EKUs) into the... | <p>Yes</p>
<p>The Certificate Authority is responsible for enforcing the organisations PKI security policy via its policy files and templates. This may include EKU (extended key usage) attributes. </p>
<p>In reality you are requesting a certificate of a certain type from the CA on behalf of your subject. It is up to ... | <p>I can't speak about CAs in general, but I once ran a Windows Server 2003 network with its own CA, and it's definitely possible to make <code>certreq</code> (through the <code>-attrib</code> option) add additional fields to the CSR before it gets to the CA. Thus, it looks to me like it's possible for the CA itself to... | 33,600 |
<p>Calling through to my Silverlight Enabled WCF-Service in my silverlight application, occasionally users get timeouts. Whats the easiest way to boost the time allowed by the service client for a response?</p>
<p>The exact exception thrown is: System.TimeoutException: [HttpRequestTimedOutWithoutDetail]</p>
<p>Thanks... | <ul>
<li>Ammount of time connection can be open: <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.binding.opentimeout.aspx" rel="noreferrer">BasicHttpBinding.OpenTimeout</a> property</li>
<li>Time that a connection can remain inactive, during which no application messages are received, befo... | <p>Rather than changing the timeout, I think you should implement a timer-based callback to the server from the Silverlight application so that the session doesn't expire. This would eliminate the overhead of longer timeouts for all of your application.</p>
| 42,920 |
<p>I have a Yahoo map with lots of markers (~500). The map performs well enough until I close the page, at which point it pauses (in Firefox) and brings up a "Stop running this script?" dialog (in IE7). If given long enough the script does complete its work.</p>
<p>Is there anything I can do to reduce this delay?</p>
... | <p>Use Javascript profiler and see which function is slow. Then you'll have better idea how to make a workaround or at least how to remove expensive cleanup (and let it leak in IE6).</p>
| <p>You could try removing all the markers, or even removing the map from the DOM using the "onbeforeunload" event.</p>
| 10,750 |
<p>Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the <strong>viewport</strong>)?</p>
<p>(The question refers to Firefox.)</p>
| <p>Now <a href="http://www.quirksmode.org/dom/w3c_cssom.html" rel="noreferrer">most browsers</a> support <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect" rel="noreferrer">getBoundingClientRect</a> method, which has become the best practice. Using an old answer is very slow, <a hr... | <p>For a similar challenge, I really enjoyed <a href="https://gist.github.com/hsablonniere/2581101" rel="nofollow noreferrer">this gist</a> which exposes a polyfill for <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded" rel="nofollow noreferrer">scrollIntoViewIfNeeded()</a>.</p>
... | 15,082 |
<p>All the examples I see are for Java SE applications by passing your JAR file at the command line. Can JConsole attach to a WAR or EAR and monitor application performance?</p>
| <p>JConsole is for monitoring JVMs. I'm assuming that you would like to monitor the performance of your application server. To do so, you'll have to set the com.sun.management.jmxremote property, when initializing your application server.</p>
<p>For example, in Tomcat (I know this is not a complete Java EE container),... | <p>If you are using Tomcat you should try <a href="http://www.lambdaprobe.org" rel="nofollow noreferrer">lambda probe</a>. It's a war file that once installed on tomcat enables a web-app with similar monitoring capabilities as jconsole.</p>
<p>On the lambda probe web there is also a JBoss download, but I only tested o... | 40,369 |
<p>I need to give users the ability to optionally add metadata to documents. Another way to state this is the fact that users need to add at least 5 categories to a document.</p>
<p>Basically what I want to do is dynamically add metadata (or categories) to a document on an ad hoc basis. Here are the options that I hav... | <p>Each document has a unique DocumentID.</p>
<p>Just add another table that has three columns:</p>
<pre>DocumentID
MetaName
MetaData</pre>
<p>Then they can add as many pieces of metadata to a given document. If all their documents use the same metanames then it's trivial to search the metadata.</p>
<p>-Adam</p>
| <p>All of these options are feasible, and there is not one correct answer. You should weigh your various options and choose the best solution for your situation.</p>
<p>Option 1: Feasible but could really get out of hand as your user count increases. May also have an impact on storage costs.</p>
<p>Option 2: Prob... | 26,933 |
<p>I <a href="https://stackoverflow.com/questions/381164">this post</a>, I've seen this:</p>
<pre><code>class MonitorObjectString: public MonitorObject {
// some other declarations
friend inline bool operator==(/*const*/ MonitorObjectString& lhs,
/*const*/ MonitorObjectStr... | <p>Perhaps the classes use a form of lazy initialization. When the data is accessed, proper initialization must occur, and the data must be fetched. This may change class members.</p>
<p>However, lazy initialization can be formed so that modification to the class isn't necessary. This can be accomplished by using t... | <p>There's clearly no requirement for non-const args in this case and, like you, I wouldn't think there's any general case for it either.</p>
<p>However, it's certainly the case that const-correctness problems can push their way up from lower levels of the code, and if you can't correct them low-down, then you might h... | 49,984 |
<p>After following the advice in <a href="https://stackoverflow.com/questions/302560/wix-custom-actions-with-wixuiminimal">this question</a> successfully, I added a couple additional lines of code for another custom action. This one is intended to call regsvr32 on the copy of capicom which I've tried to put in the use... | <p>The Right way:</p>
<ul>
<li><p>c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\Deployment\regcap.exe" /O capicom.reg capicom.dll</p></li>
<li><p>Run program from Adam Tengen's <a href="https://stackoverflow.com/questions/269423/how-to-generate-wix-xml-from-a-reg-file">post here</a>.</p></li>
</ul>
... | <p>You could use heat on the File to create a output WXS file, that will put the capicom.dll information in the registry without the use of regsvr32, when the msi is executed</p>
<p>Something like so:</p>
<pre><code>heat file [Path\Capicom.dll] -template:product -out capicom.wxs
</code></pre>
<p>Then add the capicom... | 39,374 |
<p>I run Flex Builder 3 on a mac and as my project grows - the compile time gets longer and longer and longer. I am using some SWC's and there is a fair amount of code but it shouldn't take minutes to build and crash daily should it?</p>
| <p>In addition to the suggestions already mentioned, close any projects that you have open that you are not using.</p>
<p>Rich click on the Project in the Navigator view and select "Close Unrelated Projects".</p>
<p>Depending on how many projects you have open, this can lead to a significant improvements in compile t... | <p>Usually the first build takes the longest, and then it's pretty quick after that. That's using Vista x64 w/ core 2 duo. </p>
<p>Otherwise, I am nearly certain a Intel Core i7 Extreme Edition 965 3.2GHz upgrade processor would speed your Flex building up nicely .. :) :) :)</p>
| 5,386 |
<p>How would you begin improving on a really bad system?</p>
<p>Let me explain what I mean before you recommend creating unit tests and refactoring. I could use those techniques but that would be pointless in this case.</p>
<p>Actually the system is so broken it doesn't do what it needs to do.</p>
<p>For example the... | <ol>
<li><strong>Put out the fires</strong>. If there are any issues of critical priority, whatever they are, you've got to handle them first. Hack it in if you must, with a smelly codebase it's ok. You know you'll improve it going forward. This is your sales technique targeted at whomever you're reporting to.</li>... | <p>Well you need to start somewhere, and it sounds like there are bugs that need fixing. I would work through those bugs, making quick win refactorings, and writing any unit tests possible along the way. I would also use a tool like <a href="http://www.campwoodsw.com/sourcemonitor.html" rel="nofollow noreferrer">Source... | 23,388 |
<p>For some reason I never see this done. Is there a reason why not? For instance I like _blah for private variables, and at least in Windows Forms controls are by default private member variables, but I can't remember ever seeing them named that way. In the case that I am creating/storing control objects in local v... | <p>This might be counter-intuitive for some, but we use the dreaded Hungarian notation for UI elements.</p>
<p>The logic is simple: for any given data object you may have two or more controls associated with it. For example, you have a control that indicates a birth date on a text box, you will have:</p>
<ul>
<li>the... | <p>I use m_ for member variables, but I'm increasingly becoming tempted to just using lowerCamelCase like I do for method parameters and local variables. Public stuff is in UpperCamelCase.</p>
<p>This seems to be more or less accepted convention across the .NET community.</p>
| 3,084 |
<p>Just for the sake of experimentation, I've been trying to determine different ways to non-destructively chain <code>window.onload</code> functions in a web browser. This is the idea of what I have so far:</p>
<pre><code>var load = window.onload;
var newFunction = function(){
alert("ha!");
}
window.onload = func... | <p>May be it will be better to use addEventListener/attachEvent?</p>
<p><a href="http://www.quirksmode.org/js/events_advanced.html" rel="nofollow noreferrer">Advanced event registration models</a></p>
| <p>You could have a look at <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a> how they handle that.</p>
<p>From the <a href="http://docs.jquery.com/Events/ready#fn" rel="nofollow noreferrer">jQuery docs</a>:</p>
<blockquote>
<p>You can have as many $(document).ready events on your page as you like. ... | 47,816 |
<p>This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:</p>
<ul>
<li><p><strong>Firstly</strong>: Given an established Perl project, what are some decent ways to speed it up beyond just plain in-code optimization?</p></li>
<li><p><strong>Secondly</strong>... | <p>Please remember the rules of Optimization Club:</p>
<ol>
<li>The first rule of Optimization Club
is, you do not Optimize.</li>
<li>The second rule of Optimization Club is, you do not Optimize without measuring.</li>
<li>If your app is running faster than the underlying transport protocol, the optimization is over.<... | <p>If your code needs speeding up then chances are that your test suite does too. This talk touches on the key points:</p>
<p><a href="http://www.slideshare.net/Ovid/turbo-charged-test-suites-presentation" rel="nofollow noreferrer">Turbo Charged Test Suites</a></p>
| 21,333 |
<p>I was recently in a discussion with a non-coder person on the possibilities of chess computers. I'm not well versed in theory, but think I know enough.</p>
<p>I argued that there could not exist a deterministic Turing machine that always won or stalemated at chess. I think that, even if you search the entire spac... | <p>"I argued that there could not exist a deterministic Turing machine that always won or stalemated at chess." </p>
<p>You're not quite right. There can be such a machine. The issue is the hugeness of the state space that it would have to search. It's finite, it's just <strong>REALLY</strong> big.</p>
<p>That's ... | <p>Of course
There's only 10 to the power of fifty possible combinations of pieces on the board. Having that in mind, to play to every compibation, you would need make under 10 to the power of fifty moves (including repetitions multiply that number by 3). So, there's less than ten to the power of one hundred moves in c... | 38,083 |
<p>My <sub>crappy</sub> web host did some upgrades the other day and some settings have gone awry, because looking at our company's wiki (MediaWiki), every quote is being escaped with a backslashes. It's not even just data which is being posted (i.e.: the articles) which are affected, but also the standard MediaWiki te... | <p>You may want to confirm that the data in your DB hasn't been corrupted. If you were addslash()ing your data when, unbeknownst to you, magic_quotes had been turned on, then you'd be double-slashifying data going into your DB.</p>
| <p>I use stripslases() to remove slashes when displaying.</p>
<p><a href="http://www.php.net/manual/en/function.stripslashes.php" rel="nofollow noreferrer">http://www.php.net/manual/en/function.stripslashes.php</a></p>
| 28,730 |
<p>As far as i know the EAP editions of JBoss Application Server (AS) are just a bunch of community edition JBoss projects with some sugar.</p>
<p>So, what is the <strong>community edition</strong> of the JBoss Application Server that <strong>JBoss EAP 4.3.0</strong> corresponds to?</p>
| <p>According to <a href="https://access.redhat.com/articles/112673" rel="nofollow noreferrer">JBoss Enterprise Application Platform Component Details</a>, <strong>JBoss EAP 4.3</strong> is based on:</p>
<blockquote>
<p><strong>JBoss Application Server 4.2.1</strong> with various updates, component upgrades, and bug ... | <p>I've been digging into JBoss version information to try and find an answer to a more specific question i'm dealing with, and i thought i'd share my observations. You can get a picture of the names and dates of releases from JBoss's JIRA bug tracker: you can check out the info for the <a href="https://jira.jboss.org/... | 34,178 |
<p>I want to create an alias for a class name. The following syntax would be perfect:</p>
<pre><code>public class LongClassNameOrOneThatContainsVersionsOrDomainSpecificName
{
...
}
public class MyName = LongClassNameOrOneThatContainsVersionOrDomainSpecificName;
</code></pre>
<p>but it won't compile.</p>
<hr />
<h2>... | <p><strong>You can’t</strong>. The next best thing you <em>can</em> do is have <code>using</code> declarations in the files that use the class.</p>
<p>For example, you could rewrite the dependent code using an import alias (as a quasi-<code>typedef</code> substitute):</p>
<pre><code>using ColorScheme = The.Fully.Qualif... | <p>It's a very late partial answer - but if you define the same class 'ColorScheme', in the same namespace 'Outlook', but in separate assemblies, one called Outlook2003 and the other Outlook2007, then all you need to do is reference the appropriate assembly.</p>
| 30,282 |
<p>Is there an equivalent operator to Haskell's list difference operator <code>\\</code> in F#?</p>
| <p>Was bounced, yet I believe it is worth to write here the implementation of <code>( /-/ )</code> (the F# version of Haskell's <code>\\</code>):</p>
<pre><code>let flip f x y = f y x
let rec delete x = function
| [] -> []
| h :: t when x = h -> t
| h :: t -> h :: delete x t
let inline ( /-/ ) xs ys =... | <p>Assuming you really want conventional set difference rather than the weird ordered-but-unsorted multiset subtraction that Haskell apparently provides, just convert the lists to sets using the built-in <code>set</code> function and then use the built-in <code>-</code> operator to compute the set difference:</p>
<pre... | 8,438 |
<p>I have a DataGridView whose DataSource is a DataTable.
This DataTable has a boolean column, which is interpreted as a checkbox in the DataGridView.</p>
<pre><code>employeeSelectionTable.Columns.Add("IsSelected", typeof(bool));
...
employeeSelectionTable.RowChanged += selectionTableRowChanged;
dataGridViewSelectedEm... | <p>The reason that making an empty DoubleClick event method would not help would be that is executed in addition to the other operations that happen when a double click occurs.</p>
<p>If you look at the windows generated code or examples of programatically adding event handlers, you use += to assign the event handler.... | <p>Is there some reason it needs to be done that low level? Can the DoubleClick Method just be an empty method that eats it?</p>
| 18,135 |
<p>I have currently more than 100 connections in Sleep state.</p>
<p>Some connection must stay in Sleep state (and don't close) because it's permanent connection but some others (with a different user name) are from some php script and I want them to timeout very fast.</p>
<p>Is it possible to setup a wait_timeout pe... | <p>There's no per-user timeout configuration, but you can set the <code>wait_timeout</code> value dynamically. That is, after you make a connection as a given user, you can issue a statement to change the timeout value to what you want it to be for that user's session.</p>
<p>Try the following experiment in the mysql... | <p>I checked the <code>mysql.user</code> table and it doesn't look like there is a setting there for it:</p>
<pre><code>+-----------------------+-----------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------... | 30,181 |
<p>When I run my asp.net app I get the error</p>
<blockquote>
<p>The type ‘System.Web.UI.ScriptManager’ is ambiguous:</p>
</blockquote>
<p>I am having the same problem this person is having <a href="http://forums.asp.net/t/1313257.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1313257.aspx</a> , when I cha... | <p>It looks like you are (perhaps indirectly) referencing the old System.Web.Extensions DLL. Check your config file and search your application for "System.Web.Extensions". Also make sure the old version is not in your bin folder (and does not get copied there). </p>
<p>Make sure you are not using any other libraries ... | <p>Update your project reference and clean out your bin directory. Asp.net is loading the previous version of AJAX from bin</p>
<p>Make sure you remove:
- System.Web.Extensions.dll
- System.Web.Extensions.Design.dll<br>
- old versions of AjaxToolkit.dll</p>
| 37,591 |
<p>I'm looking for an alternative, since I find emacs difficult to use. I'd rather use an editor that supports all the usual shortcuts I'm used to, such as arrow keys to move the cursor around, CTRL+SHIFT+RightArrow to select the next word, etc.</p>
<p>Basically, I don't want to have to relearn all my familiar shortcu... | <p>Firstly, the arrow keys should work just fine on Emacs. (Emacs die-hards will tell you Ctrl-f/b/p/n are preferable, but you don't have to listen to them.) If they don't work by default, something is wrong.</p>
<p>Recent versions of Emacs come with cua-mode, which will make all the other common shortcuts like Ctrl-x... | <p>There are those that say there are no good editors for <strong>anything</strong>, other than emacs. I'm sure you'll find a few of them here (although I'm a vim fan).</p>
<p>The vim macro language is a powerful one which can let you run external programs (including the one in the current edit buffer).</p>
<p>But, ... | 35,844 |
<p>I'm looking at a new computer which will probably have vista on it. But there are so many editions of vista; are there any weird restrictions on what you can run on the various editions? For instance you couldn't run IIS on Windows ME. Can you still run IIS on the home editions of vista? </p>
| <p>There's a very nice and efficient algorithm for this using a method called <strong>reservoir sampling</strong>.</p>
<p>Let me start by giving you its <strong>history</strong>:</p>
<p><strong>Knuth</strong> calls this Algorithm R on p. 144 of his 1997 edition of Seminumerical Algorithms (volume 2 of The Art of Comp... | <p>Well, you do need to know what N is at runtime at least, even if this involves doing an extra pass over the list to count them. The simplest algorithm to do this is to just pick a random number in N and remove that item, repeated k times. Or, if it is permissible to return repeat numbers, don't remove the item.</p>
... | 7,768 |
<p>My web application allows users to upload images of items they are planning on selling. I'm trying to find a good compromise between having the images large enough and detailed enough for buyers to get an idea of the condition of the item and having the images small enough so that they don't slow down the site subs... | <p>Small images could still be usable - If you're trying to prevent that, I would go for small+watermark. At least that's what most stock photo sites are doing.</p>
<p>I would also recommend checking out Amazon s3 for storage of a large number of images. Should really help you with the server load.</p>
| <p>Don't impose any limit's to the user. The user might not have the tools or knowledge on how to reduce the size anyway. You can always resize on the server if needed.</p>
<p>I've created several sites that have image galleries and we normally store three files. </p>
<ol>
<li><p>Original (This is not necessary if
fo... | 32,702 |
<p>I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range).</p>
<p>DateTime has two methods "-" and "<<" to subtract day and month, but not hour. (<a href="https://ruby-doc.org/st... | <p>You could do this.</p>
<pre><code>adjusted_datetime = (datetime_from_form.to_time - n.hours).to_datetime
</code></pre>
| <p>You can use this :</p>
<pre><code>Time.now.ago(n*60*60)
</code></pre>
<p>For example <code>Time.now.ago(7200)</code> will give the date and time that was before 2 hours from now.</p>
| 29,524 |
<p>Here's an open ended question. I work on a lot of mssql files, and I like to have a date stamp on each. This is so I can know just by looking at the source of a stored procedure whether it's up to date or not.</p>
<p>I'd like to have a shortcut autocomplete key, that, if i type say, d-tab-tab, I get the current dat... | <p>Are these files in source control? If so, see whether your source control provider allows templates within the source file which get filled in with the time and date when you check in.</p>
| <p>If you use Notepad (and this is possibly the only argument for using it) then F5 does the trick.</p>
| 35,586 |
<p>I have SQL data that looks like this:</p>
<pre><code>events
id name capacity
1 Cooking 10
2 Swimming 20
3 Archery 15
registrants
id name
1 Jimmy
2 Billy
3 Sally
registrant_event
registrant_id event_id
1 3
2 3
3 2
</code></pre... | <pre><code>SELECT e.*, ISNULL(ec.TotalRegistrants, 0) FROM events e LEFT OUTER JOIN
(
SELECT event_id, Count(registrant_id) AS TotalRegistrants
FROM registrant_event
GROUP BY event_id
) ec ON e.id = ec.event_id
</code></pre>
| <pre><code>SELECT
events.*
, COUNT(registrant_event.registrant_id) AS registrantsCount
FROM events
LEFT JOIN registrant_event ON events.id = registrant_event.event_id
GROUP BY events.id
</code></pre>
| 25,238 |
<p>I have some library code which is used from my application and is also used by a .NET custom action in a Visual Studio installer project. The library code in turn uses the Enterprise Library logging block to do its logging. How can I get configuration information to the Enterprise Library in the context of my cust... | <p>There is no way to use the standard app.config way because that app.config is the msiexec.config you would need to edit prior to executing your MSI. My recommendation would be to have your own configuration loading method which reads from a custom XML or values in the MSI.</p>
| <p>Not sure if this helps, but you can write to the msi log from within a custom action. (Sample VBScript below:)</p>
<pre><code>Const msiMessageTypeInfo = &H04000000
Const msiMessageTypeFatalExit = &H00000000
Const msiMessageTypeError = &H01000000
Const msiMessageTypeWarning = &H02000000
Const msiMess... | 44,853 |
<p>I am using the Html.TextBox helper to create textboxes. I want to set attributes on the textbox, which I understand is done using the following overload: </p>
<p><code>Html.TextBox (string name, object value, object htmlAttributes)</code></p>
<p>However, I want to maintain the functionality where the HTML helper ... | <p>[EDIT] After looking at the <a href="http://www.codeplex.com/aspnet/" rel="noreferrer">source code</a>, it appears that all you need to do is specify the value as null in the signature that takes a name, value, and htmlAttributes. If the value is null, it will attempt to use the value from the ViewData.</p>
<pre>... | <pre><code> @Html.TextBox("Name", "Value", new {@class = "class1 class2", @customAttributeName = "attributeValue"})
</code></pre>
| 37,144 |
<p>When you lock an object is that object locked throughout the whole application?</p>
<p>For Example, this snippet from C# 3.0 in a Nutshell Section 19.6.1 "Thread Safety and .NET Framework Types":</p>
<pre><code>static void AddItems( )
{
for (int i = 0; i < 100; i++)
lock (list)
list.Add ("I... | <pre><code>class UsefulStuff {
object _TheLock = new object { };
public void UsefulThingNumberOne() {
lock(_TheLock) {
//CodeBlockA
}
}
public void UsefulThingNumberTwo() {
lock(_TheLock) {
//CodeBlockB
}
}
}
</code></pre>
<p><code>CodeBlockA<... | <p>The CLR doesn't automatically make static methods thread-safe; you must do it yourself.</p>
<p>lock(list) uses that object as a lock, so if a different thread reaches another point with lock(list) (with the same 'list' object), the other thread will block until the first thread releases the lock.</p>
<p>To be clea... | 34,559 |
<p>I have several C# projects along with some internal library components that I'm trying to document together. Sandcastle seems to be the place to go to generate documentation from C#. I would like to know which of the two, DocProject or Sandcastle Help File Builder GUI is better and supports the features I need.</p... | <p>I can vouch for Sandcastle Help File Builder. It works really well and you can document any number of assemblies within a Sandcastle Help File Builder project. In theory, you could have a Builder project and generate a doc for each C# project and then have a master Builder project which documents everything.</p>
| <p>Doc Project produces more polished docs - when it works - which isn't all the time. It's a much more flakey product.</p>
<p>Sandcastle Help File Builder is solid and gets the job done.</p>
| 41,331 |
<p>Apparently there's a lot of variety in opinions out there, ranging from, "<strong>Never! Always encapsulate (even if it's with a mere macro!)</strong>" to "<strong>It's no big deal – use them when it's more convenient than not.</strong>"</p>
<p>So.</p>
<p>Specific, concrete reasons (preferably w... | <p>Variables should always have a smaller scope possible. The argument behind that is that every time you increase the scope, you have more code that potentially modifies the variable, thus more complexity is induced in the solution.</p>
<p>It is thus clear that avoiding using global variables is preferred if the desig... | <p>I'm in the "never" camp here; if you need a global variable, at least use a <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow noreferrer">singleton pattern</a>. That way, you reap the benefits of lazy instantiation, and you don't clutter up the global namespace.</p>
| 21,217 |
<pre><code>
class C {
T a;
public:
C(T a): a(a) {;}
};
</code></pre>
<p>Is it legal?</p>
| <p>Yes it is legal and works on all platforms.
It will correctly initialize your member variable a, to the passed in value a. </p>
<p>It is considered by some more clean to name them differently though, but not all. I personally actually use it a lot :)</p>
<p>Initialization lists with the same variable name works ... | <p>Legal: yes, as explained by Brian, compiler knows the name to expect in the initializer list must be a member (or a base class), not anything else.</p>
<p>Good style: most likely not - for a lot of programmers (including you, it seems) the result is not obvious. Using a different name for the parameter will keep th... | 33,711 |
<p>I've implemented an object factory to lookup LDAP objects, but the supplied context does not return the DN (via nameCtx.getNameInNamespace()) from the LDAP. Am i doing it wrong in some way?</p>
<pre><code>public class LdapPersonFactory implements DirObjectFactory {
@Override
public Object getObjectI... | <pre><code>String dn = (String) attrs.get("dn").get();
</code></pre>
<p>this throws a <code>NamingException</code> only.<br>
I don't think that the distinguished name (DN) is an attribute of the LDAP object, it's more like an identity key in the LDAP-world.</p>
| <p>Maybe?</p>
<pre><code>String dn = (String) attrs.get("dn").get();
</code></pre>
<p>It should be an attribute like any other?</p>
| 41,823 |
<p>In .NET, the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.object.gethashcode" rel="noreferrer"><code>GetHashCode</code> method</a> is used in a lot of places throughout the .NET base class libraries. Implementing it properly is especially important to find items quickly in a collection or when determ... | <p>I usually go with something like the implementation given in Josh Bloch's <em>fabulous</em> <a href="https://rads.stackoverflow.com/amzn/click/com/0321356683" rel="noreferrer" rel="nofollow noreferrer">Effective Java</a>. It's fast and creates a pretty good hash which is unlikely to cause collisions. Pick two differ... | <p>I want to add my newest findings to this thread I came back to so often.</p>
<p>My current visual studio / project setup provides the functionallity to automatically refactors tuples to structs. This will generate a GetHashCode function like so:</p>
<pre><code> public override int GetHashCode()
{
... | 32,977 |
<p>I want to attach a 'click' event handler to the first child of an element with ID 'foo' using <a href="http://en.wikipedia.org/wiki/JQuery" rel="nofollow noreferrer">jQuery</a>. I understand that the syntax for doing this is:</p>
<pre><code>$('#foo:first-child').bind('click', function(event) {
// I want to acce... | <pre><code>$(this).doStuff()
</code></pre>
| <p>Just use "this":</p>
<pre><code>$('#foo:first-child').bind('click', function(event) {
alert(this === $('#foo:first-child')); // True
this.style.color = "red"; // First child now has red text.
})
</code></pre>
| 31,192 |
<p>Visual Studio 2008 doesn't appear to be loading symbols for MFC dlls when I debug my application. This used to work fine in 2005 - ie. when it loaded the dll it said "Symbols loaded" and can then debug it. In 2008 (having upgraded to MFC 9, so they are different libraries) it doesn't say that it's loaded symbols for... | <p>Use the Microsoft Symbol Server. Scott Hanselman shows how to <a href="http://www.hanselman.com/blog/SetUpYourSystemToUseMicrosoftsPublicSymbolServer.aspx" rel="nofollow noreferrer">do this globally</a>. This works for all of the Windows debuggers (i.e. WinDBG, NTSD, etc.).</p>
<p>Alternatively, you can use the Too... | <p>The .pdb files have to exactly match the .dll build - have you checked it's not using a cached copy of the symbols.</p>
| 28,245 |
<p>I am looking for an algorithm to calculate the next set of operations in a sequence. Here is the simple definition of the sequence.</p>
<ol>
<li>Task 1A will be done every 500 hours</li>
<li>Task 2A will be done every 1000 hours</li>
<li>Task 3A will be done every 1500 hours</li>
</ol>
<p>So at t=500, do 1A. At t=... | <p>If you have enough history to get the last two times each task was done you could reconstruct the original task sequence definitions. When they coincide is incidental.</p>
| <p>Prerequisites:</p>
<ol>
<li>Calculate the LCM of the tasks' time; this is the period of a full cycle.</li>
<li>Compute the event timeline for the full cycle.</li>
</ol>
<p>As each task / group of tasks is started, move an index through the timeline.</p>
| 19,680 |
<p>I have been trying out <a href="http://www.codeplex.com/servicefactory" rel="nofollow noreferrer">Service Factory</a> and have run into some problems in regards to long filenames - surpassing the limit in Vista/XP. The problem is that when generating code from the models service factory prefixes everything with the ... | <p>I have always been in the fortunate position to have Red Gate <a href="http://www.red-gate.com/products/SQL_Compare/index.htm" rel="nofollow noreferrer">Schema compare</a> which i think would do what you ask. Cheap at twice the price!</p>
| <p>I have always been in the fortunate position to have Red Gate <a href="http://www.red-gate.com/products/SQL_Compare/index.htm" rel="nofollow noreferrer">Schema compare</a> which i think would do what you ask. Cheap at twice the price!</p>
| 10,971 |
<p>I have a user interface that requires placing some round buttons in a C# project with some data behind them. The buttons are System.Windows.Forms.buttons and I have used a GIF image with transparency to create them. However, the transparent areas aren't transparent. I've looked for references online but haven't fo... | <p>I'm pretty sure you need to use PNGs with WinForms to get image transparency. I know I've used them successfully.</p>
<p>EDIT: When I used the PNGs, I was overlaying them with the Image control onto the Form1.BackgroundImage; I wasn't using them in buttons.</p>
<p>I think your best bet is to switch from using a bu... | <p>You need to set BackColor property of a button to "Transparent". </p>
<p>Button1.BackColor = System.Drawing.Color.Transparent;</p>
| 24,647 |
<p>I've tried downloading the Rails package and installing it on Windows, but have no idea to make it work.</p>
<p>I have had some experience with this commbination:</p>
<ul>
<li>PHP 4.x + 5.x (Windows)</li>
<li>LIGHTTPD (Windows)</li>
<li>Connecting to a Firebird Database (Windows)</li>
</ul>
<p>Can anybody enlight... | <p>I've gotten Rails up and running on Windows just following the instructions on the RoR <a href="http://www.rubyonrails.org/down" rel="nofollow noreferrer">website</a>. To paraphrase:</p>
<ol>
<li>Download Ruby Windows installer from <a href="http://rubyforge.org/frs/?group_id=167" rel="nofollow noreferrer">here</a... | <p>I used <a href="http://www.michaelwales.com/ruby-on-rails/installing-ruby-on-rails-on-windows-vista" rel="nofollow noreferrer">this tutorial</a> just yesterday and it worked well. BUT you need to install <a href="http://rubyforge.org/frs/?group_id=126" rel="nofollow noreferrer">RubyGems</a> yourself, after installin... | 29,411 |
<p>When trying to call Close or Dispose on an SqlDataReader i get a timeout expired exception. If you have a DbConnection to SQL Server, you can reproduce it yourself with:</p>
<pre><code>String CRLF = "\r\n";
String sql =
"SELECT * " + CRLF +
"FROM (" + CRLF +
" SELECT (a.Number * 256) + b.Number AS Nu... | <p>it's because you have just opened the data reader and have not completely iterated through it yet. you will need to .Cancel() your DbCommand object before you attempt to close a data reader that hasn't completed yet (and the DbConnection as well). of course, by .Cancel()-ing your DbCommand, I'm not sure of this but ... | <p>Where do you actually read the data? You're just creating a reader, but not reading Data. It's just a guess but maybe the reader has problems to close if you're not reading ;)</p>
<pre><code>DbDataReader rdr = cmd.ExecuteReader();
while(rdr.Read())
{
int index = rdr.GetInt32(0);
}
</code></pre>
| 16,146 |
<p>I need to create a screenshot of the page by providing a page URL to the command line tool. I found the following application: <a href="http://www.converthtmltoimage.com/" rel="nofollow noreferrer">Convert HTML To Image</a>. This tool is OK but want a more flexible application. I need to have ability to perform the ... | <p>Watin can capture screenshots:</p>
<p>ie.CaptureWebPageToFile("c:\tmp\watin main page.jpg");</p>
<p>More info:</p>
<p><a href="http://watin.sourceforge.net/releasenotes-1-2-0-4000.html" rel="noreferrer">http://watin.sourceforge.net/releasenotes-1-2-0-4000.html</a>
<a href="http://fwdnug.com/blogs/ddodgen/archive/... | <p>According to the WatiN features page:</p>
<ul>
<li>Supports creating screenshots of webpages</li>
</ul>
<p>I would direct you to more specifical documentation, but the documentation web doesn't work well with Firefox, so I can't search it.</p>
| 44,240 |
<p>I want to build a site where the user can enter text and format it in Markdown. The reason I'd like a Javascript solution is because I want to display a live preview, just like on StackOverflow.</p>
<p>My site is not targeted at developers, however, so an editor control would be ideal.</p>
<p>I gather that on Stac... | <p>We've been pretty happy with WMD. There are a few niggling bugs in it, however. Nothing major, but I would <em>love</em> if John Fraser (the author) made the code open source so we can fix some of them. He's promised to do so but other real life projects are getting in the way.</p>
<p><s>I do follow up with John ev... | <p>I've not tested this, but here is another option:</p>
<p><a href="http://sourceforge.net/projects/md-wysiwyg/" rel="nofollow noreferrer">Markdown wysiwyg</a></p>
| 16,249 |
<p>I'll have couple of python functions I must interface with from the assembly code. The solution doesn't need to be a complete solution because I'm not going to interface with python code for too long. Anyway, I chewed it a bit:</p>
<ul>
<li>What does a python object look like in memory?</li>
<li>How can I call a py... | <p>You will want to read and understand <a href="http://python.org/doc/2.5/ext/ext.html" rel="nofollow noreferrer">Extending and Embedding the Python Interpreter</a> and the <a href="http://python.org/doc/2.5/api/api.html" rel="nofollow noreferrer">Python/C API Reference Manual</a>. This describes how to interface with... | <p>It's certainly doable, but you'd have a much easier time reading the C API docs and writing a go-between function in C.</p>
<p>Come to think of it, C is highly recommended, since it may be hard to tell which of the routines you're calling might be implemented as preprocessor macros.</p>
| 41,270 |
<p>I wrote myself a little downloading application so that I could easily grab a set of files from my server and put them all onto a new pc with a clean install of Windows, without actually going on the net. Unfortunately I'm having problems creating the folder I want to put them in and am unsure how to go about it.<... | <pre><code>If Not System.IO.Directory.Exists(YourPath) Then
System.IO.Directory.CreateDirectory(YourPath)
End If
</code></pre>
| <p>I see how this would work, what would be the process to create a dialog box that allows the user name the folder and place it where you want to.</p>
<p>Cheers</p>
| 11,148 |
<p>Is it possible to free memory allocated by C's alloca() explicitly, before the current function exits? If so,how?</p>
| <p>From <a href="http://www.gnu.org/software/libc/manual/html_mono/libc.html#Variable-Size-Automatic" rel="noreferrer">http://www.gnu.org/software/libc/manual/html_mono/libc.html#Variable-Size-Automatic</a>:</p>
<blockquote>
<p>Allocating a block with <code>alloca</code> is an explicit action; you can allocate as ma... | <p>You don't need to write any custom <code>freea(...)</code> kind of function, nor use VLA.
Memory allocated on the stack can be easily freed in both C and C++ (C++ doesn't support VLAs).
The <code>alloca(...)</code> allocates on the stack, right? This means the memory is going to be deallocated when it goes out of sc... | 35,859 |
<p>I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for .NET 3.5. </p>
<p>Does anyone have a suggestion about good testing frameworks to use?</p>
| <p>We use <a href="http://www.mbunit.com/" rel="noreferrer">MbUnit</a> and <a href="http://www.ayende.com/Blog/archive/2007/03/28/Rhino-Mocks-3.0-Released.aspx" rel="noreferrer">Rihno Mocks</a> and they prove to work very well together. When doing TDD you will almost certainly need to do some form of dependency injecti... | <p>NUnit is always a favorite of mine. However if you are using TFS as your source control I suggest you stick with the Microsoft Stack.</p>
| 2,439 |
<p>For example, I'm writing a multi-threaded time-critical application that processes and streams audio in real-time. Interruptions in the audio are totally unacceptable. Does this mean I cannot use the STL because of the potential slow down when an exception is thrown? </p>
| <p>Generally, the only exceptions that STL containers will throw by themselves is an std::bad_alloc if new fails. The only other times are when user code (for example constructors, assignments, copy constructors) throws. If your user code never throws then you only have to guard against new throwing, which you would ha... | <p>You talk as if exceptions are inevitable. Simply don't do anything that could cause an exception -- fix your bugs, verify your inputs.</p>
| 19,869 |
<p>By default IntelliJ IDEA 7.0.4 seems to use 4 spaces for indentation in XML files. The project I'm working on uses 2 spaces as indentation in all it's XML. Is there a way to configure the indentation in IntelliJ's editor?</p>
| <p>Sure there is. This is all you need to do:</p>
<ul>
<li>Go to</li>
</ul>
<pre>File -> Settings -> Global Code Style -> General</pre>
<ul>
<li>Disable the checkbox next to 'Use same settings for all file types' </li>
<li>The 'XML' tab should become enabled. Click it and set the 'tab' (and probably 'indent') size ... | <p>Note: make sure to not use the <em>same</em> file in two project, or your settings might revert to the default (4 spaces), instead of the custom XML tab indent size.</p>
<p>See <a href="https://youtrack.jetbrains.com/issue/IDEA-130878" rel="nofollow">bug IDEA-130878</a>, for the latest IntelliJ IDEA 14 (Oct 2014)</... | 5,882 |
<p>Please bear with me here, I'm a student and new to Java Server Pages.
If I'm being a complete idiot, can someone give me a good link to a tutorial on JSP, since I've been unable to find info on this anywhere. </p>
<p>Okay, here goes... </p>
<p>I'm using Netbeans and trying to pass an object that connects to a dat... | <p>You can put it in a session <a href="http://www.jsptut.com/Sessions.jsp" rel="nofollow noreferrer">JSP tutorial, Sessions</a>.</p>
<p>But frankly, you don't put database connections in a session. They're a scarce resource. You'd be better off using some pooling mechanism like in <a href="http://www.informit.com/art... | <p><a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html" rel="nofollow noreferrer">http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html</a> is a J2EE tutorial with parts of it talking about JSP as well</p>
<p>one more JSP tutorial from sun : <a href="http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSP... | 26,399 |
<p>I'm using the following code to query a database from my jsp, but I'd like to know more about what's happening behind the scenes.</p>
<p>These are my two primary questions.</p>
<p>Does the tag access the ResultSet directly, or is the query result being stored in a datastructure in memory?</p>
<p>When is the conne... | <p>Observations based on the source for org.apache.taglibs.standard.tag.common.sql.QueryTagSupport</p>
<p>The taglib traverses through the ResultSet and puts all of the data in arrays, Maps, and Lists. So, everything is loaded into memory before you even start looping.</p>
<p>The connection is opened when the query s... | <p>The key thing here is this: javax.servlet.jsp.jstl.sql.Result</p>
<p>That's what JSTL uses as the result of a SQL Query. If you look at the interface, it has this method: </p>
<p>public java.util.SortedMap[] getRows()</p>
<p>c:forEach "knows" about javax.servlet.jsp.jstl.sql.Result, since Result isn't anything el... | 12,077 |
<p>After applying a CSS reset, I want to get back to 'normal' behavior for html elements like: p, h1..h6, strong, ul and li.</p>
<p>Now when I say normal I mean e.g. the p element adds spacing or a carriage return like result when used, or the size of the font and boldness for a h1 tag, along with the spacing.</p>
<p... | <p>YUI provides a base CSS file that will give consistent styles across all <a href="http://web.archive.org/web/20170209084319/https://developer.yahoo.com/yui/articles/gbs/" rel="nofollow noreferrer">'A-grade'</a> browsers. They also provide a CSS reset file, so you could use that as well, but you say you've already re... | <p>I'm not resetting all the elements by default because the default styles are somehow browser depended, so they varies from browser to browser. Instead of using something like <code>ul, ol { list-style: none; }</code>, I'm adding a CSS class like <code>r</code> or <code>reset</code> and then I specify that if that is... | 12,486 |
<p>Is there a measurable performance difference between using INT vs. VARCHAR as a primary key in MySQL? I'd like to use VARCHAR as the primary key for reference lists (think US States, Country Codes) and a coworker won't budge on the INT AUTO_INCREMENT as a primary key for all tables. </p>
<p>My argument, as detailed... | <p>You make a good point that you can avoid some number of joined queries by using what's called a <a href="https://en.wikipedia.org/wiki/Natural_key" rel="noreferrer"><em>natural key</em></a> instead of a <a href="https://en.wikipedia.org/wiki/Surrogate_key" rel="noreferrer"><em>surrogate key</em></a>. Only you can a... | <p>Not sure about the performance implications, but it seems a possible compromise, at least during development, would be to include both the auto-incremented, integer "surrogate" key, as well as your intended, unique, "natural" key. This would give you the opportunity to evaluate performance, as well as other possibl... | 43,049 |
<p>What is the proper way to load a <code>ListBox</code> in C# .NET 2.0 Winforms?</p>
<p>I thought I could just bind it to a <code>DataTable</code>. No such luck.<br>
I thought I could bind it with a <code>Dictionary</code>. No luck. </p>
<p>Do I have to write an class called <code>KeyValuePair</code>, and then use ... | <p>Simple code example. Say you have a <code>Person</code> class with 3 properties. <code>FirstName</code>, <code>LastName</code> and <code>Age</code>. Say you want to bind your listbox to a collection of <code>Person</code> objects. You want the display to show the first name, but the value to be the age. Here's how y... | <p>Using the DataSource paramater used to suck performance wise - on ComboBoxes at least,</p>
<p>I am now heavily conditioned to override ToString() on the object and just adding the objects using the Items.AddRange() method, as another commenter above describes.</p>
| 38,961 |
<p>Some people have suggested that when doing an estimate one should make a lower and upper range on the expected time to delivery. The few project tools I have seen, seem to demand one fixed date. Are there any tools that support this concept of a estimation range?</p>
| <p>Joel touts <a href="http://www.joelonsoftware.com/items/2007/10/26.html" rel="nofollow noreferrer">Evidence-Based Scheduling</a> in their FogBugz 6.0 software.</p>
| <p>I've used <a href="http://www.projectwizards.net/en/products/merlin" rel="nofollow noreferrer">Merlin2</a> which is a project management product for the Mac. When you are starting a new project it asks you the start date and end date - which look fixed, but when you look at the project plan inspector you see that th... | 44,799 |
<p>I have finally started messing around with creating some apps that work with RESTful web interfaces, however, I am concerned that I am hammering their servers every time I hit F5 to run a series of tests..</p>
<p>Basically, I need to get a series of web responses so I can test I am parsing the varying responses corr... | <p>I found this question while looking to do exactly the same thing. Couldn't find an answer anywhere, but after a bit more digging found that the .Net Framework has built in support for this.</p>
<p>You can register a factory object with <code>WebRequest.RegisterPrefix</code> which <code>WebRequest.Create</code> will... | <p>This is not a perfect solution yet it worked for me before and deserves extra care for the simplicity :</p>
<p><a href="http://haacked.com/archive/2007/06/19/unit-tests-web-code-without-a-web-server-using-httpsimulator.aspx" rel="nofollow noreferrer">HTTPSimulator</a></p>
<p>Also a typemock example documented in <... | 11,270 |
<p>I've created a custom list & also added a column in the Announcement List. Question is, how can I include those newly created items when I create a fresh Web Application (like a script, feature or something)?</p>
<p><em>Additional Info</em>: It's like when you're to deploy from your development machine to a st... | <p>Regarding the new custom list, this can be done using features. See <a href="http://msdn.microsoft.com/en-us/library/ms466023.aspx" rel="nofollow noreferrer">How to: Create a Custom List Definition</a> for more information. The Visual Studio Extensions for SharePoint (<a href="http://www.microsoft.com/downloads/deta... | <p>Your question is not very clear but I think you may want to look at Application Templates. </p>
<p>Microsoft provide 40 pre-built templates in the link below and the same technology is available to you. Links from this page should lead you to information showing you how you can crate your own.</p>
<p>Application T... | 16,410 |
<p>I have a project here that connects to an in-production database and grabs tables and views. The code I've inherited connects to a SQL Server database via a SqlConnection, with the user's provided credentials and the database location they provide. When data is required, it uses the connection and a SQL string to cr... | <p>It should work fine as long as you have specified the table name (else IIRC the first table is used). Of course, you can simplify things by giving the appropriate DataTable (rather than the DataSet) to the DGV.
You might also want to check that auto column-generation is enabled on the DGV. But binding to an ad-hoc D... | <p>open your dataset in the designer, click on the adapter, and change the connection to public (it defaults to internal), then you can access it</p>
<p>as for the rest of your issues, show us the codez - databinding on a datagridview works fine AFAIK...</p>
| 20,033 |
<p>I want to create a Java application bundle for Mac without using Mac.</p>
<p>According to <a href="http://developer.apple.com/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html#//apple_ref/doc/uid/TP40001885-208447-TPXREF120" rel="noreferrer">Java Deployment Options for Mac OS X</... | <p>A Java application bundle on OS X is nothing more than a directory containing your .jars and a number of configuration files. The SetFile tool sets a custom HFS filesystem property on the directory to tell finder that it is an app, but giving it a ".app" extension serves the same purpose. I don't think there's any... | <p>One way is to generate a zip file with the App using for example Ant. In ant you can specify that the file in Contents/MacOS should have execute-permissions using something like filemode="755".</p>
| 6,026 |
<p>I'm creating a custom Java Struts tag that is for building and formatting an html select box in a standardised way (part of our usability guidelines).</p>
<p>Each select box has an additional/initial value which describes the requirement of the value returned by the select element, i.e.:</p>
<ul>
<li><i>Mandatory<... | <p><strong>NOTE: See EDIT below for a different approach than the one given here</strong></p>
<p>How about <code>requirementConstraint</code>?</p>
<pre><code><my:customSelect requirementConstraint="Mandatory">
<option value="1">A</option>
<option value="2">B</option>
<option ... | <p><strong>optionality</strong></p>
<p>Mandatory/Optional seems like a boolean whether this is an optional field.</p>
<p>Select All nearly seems unrelated and could be its own property.</p>
| 24,316 |
<p>I know there is a standard behind all C compiler implementations, so there should be no hidden features. Despite that, I am sure all C developers have hidden/secret tricks they use all the time.</p>
| <p>Function pointers. You can use a table of function pointers to implement, e.g., fast indirect-threaded code interpreters (FORTH) or byte-code dispatchers, or to simulate OO-like virtual methods.</p>
<p>Then there are hidden gems in the standard library, such as qsort(),bsearch(), strpbrk(), strcspn() [the latter t... | <p>In Visual Studio, it is possible for you to highlight your own defined types. </p>
<p>To do that, create a file called "usertype.dat" in the folder "Commom7/IDE". The contents of that file shall be the types you want to highlight. For example:</p>
<p>//content of usertype.dat</p>
<pre><code>int8_t
int16_t
int32_t... | 16,032 |
<p>I want to override the JSON MIME type ("application/json") in Rails to ("text/x-json"). I tried to register the MIME type again in mime_types.rb but that didn't work. Any suggestions?</p>
<p>Thanks.</p>
| <p>This should work (in an initializer, plugin, or some similar place):</p>
<pre><code>Mime.send(:remove_const, :JSON)
Mime::Type.register "text/x-json", :json
</code></pre>
| <p>Try:</p>
<pre><code>render :json => var_containing_my_json, :content_type => 'text/x-json'
</code></pre>
| 12,111 |
<p>What are some good jQuery Resources along with some gotchas when using it with ASP.Net?</p>
| <p>ASP.Net's autogenerated id's make using jQuery's selector syntax somewhat difficult.</p>
<p>Two easy ways around this problem:</p>
<ul>
<li>Search for objects using css class instead of id</li>
<li>You can weed out the uniqueid garbage with: <code>$('[id$=myid]')</code></li>
</ul>
| <p><a href="http://www.west-wind.com/Weblog/" rel="nofollow noreferrer">Rick Strahl's Blog</a> is a good place to start. He has quite a few jQuery posts.</p>
| 29,901 |
<p>I have an asp.net image button and I want to cancel the click event incase he fails the client side validation... how do I do that?</p>
| <p>There is an OnClientClick event you can set this to your javascript function. If you return true it will continue to the post back. If you return false the post back will not happen.</p>
<pre><code><asp:Button ID="NavigateAway" runat="server" OnClientClick="javascript:return PromptToNavigateOff();" OnClick="Nav... | <p>I would simply reverse logic and not allow the user to click the button until he has filled the information. Put mandatory markers and if it is filled it then the button is enabled. </p>
| 35,205 |
<p>I've always done web apps and now I need to do a console app. I need to use both an odbc connection and a regular connection. </p>
<p>In the past I would have used:</p>
<pre><code><add name="LinkConnectionString" connectionString="Data Source=SERENITY\SQLEXPRESS;Initial Catalog=Link;Integrated Security=True" pr... | <p>A cool trick to building connection strings is to right click on your desktop, choose "new text document" - this will make a temporary notepad .txt file. Rename it to .udl and then double click it - you can now create any connection string. Click ok when done and open the file in notepad to see the connectionstring.... | <p>Have you tried something like this for SQLServer?</p>
<pre><code> SqlConnection conn = new SqlConnection(@"Data Source=SERENITY\SQLEXPRESS;Initial Catalog=Link;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT * FROM tableName", conn);
conn.Open();
//<snip> Run Command
conn.Close();... | 33,913 |
<p>Is there a function in Python to split a string without ignoring the spaces in the resulting list? </p>
<p>E.g:</p>
<pre><code>s="This is the string I want to split".split()
</code></pre>
<p>gives me</p>
<pre><code>>>> s
['This', 'is', 'the', 'string', 'I', 'want', 'to', 'split']
</code></pre>
<p>I wan... | <pre><code>>>> import re
>>> re.split(r"(\s+)", "This is the string I want to split")
['This', ' ', 'is', ' ', 'the', ' ', 'string', ' ', 'I', ' ', 'want', ' ', 'to', ' ', 'split']
</code></pre>
<p>Using the capturing parentheses in re.split() causes the function to return the separators as well.</p>... | <p>The hard part with what you're trying to do is that you aren't giving it a character to split on. split() explodes a string on the character you provide to it, and removes that character.</p>
<p>Perhaps this may help:</p>
<pre><code>s = "String to split"
mylist = []
for item in s.split():
mylist.append(item)
... | 13,864 |
<p>How can I convert an <code>std::string</code> to a <code>char*</code> or a <code>const char*</code>?</p>
| <p>If you just want to pass a <a href="http://en.cppreference.com/w/cpp/string/basic_string" rel="nofollow noreferrer"><code>std::string</code></a> to a function that needs <code>const char *</code>, you can use <a href="https://en.cppreference.com/w/cpp/string/basic_string/c_str" rel="nofollow noreferrer"><code>.c_str... | <p>Try this </p>
<pre><code>std::string s(reinterpret_cast<const char *>(Data), Size);
</code></pre>
| 45,279 |
<p>I've found <a href="http://blogs.msdn.com/priozersk/archive/2007/08/06/implementing-mvc-pattern-in-net-cf-applications-part-1.aspx" rel="noreferrer">an article</a> on this subject by a Microsoft employee, but has anyone implemented a more robust framework for this? Is there a lightweight framework for WinForms that ... | <p>I personally think that the Mobile Software Factory doesn't hold much joy for CF.
We still use one part of it (EventBroker) at work and I'd like to even remove that part if possible (as it doesn't support generic events and you have to cast the arguments into their strong types from EventArgs). A sister project at w... | <p><strong>Edit: The above posters are correct. I saw MVC and immediately thought of web forms. My apologies. Feel free to disregard this. I'll leave my original message in place just in case anyone who <em>is</em> interested in web forms MVC needs the links. :-)</strong></p>
<p>There are a couple MVC frameworks o... | 4,591 |
<p>As a temporary quick fix to mitigate the major risk while working on the permanent fix for XSS Vulnerability in a very large code base, I'm looking for a pre-existing XSS prevention blacklist that does a reasonable job of protecting against XSS.</p>
<p>Preferably a set of Regular Expressions. I'm aware of plenty of... | <p>I realise this may not be a direct answer to your question, but ASP.NET developers in a similar situation may find this useful:</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EFB9C819-53FF-4F82-BFAF-E11625130C25&displaylang=en" rel="nofollow noreferrer">Microsoft Anti-Cross Site Script... | <p>If you run Apache you could use <a href="http://www.modsecurity.org/" rel="nofollow noreferrer">mod_security</a> to close some holes. At least it would provide you with a tool (the <a href="http://www.modsecurity.org/projects/console/index.html" rel="nofollow noreferrer">console</a> or a plain logfile) to monitor th... | 14,618 |
<p>My log file is:</p>
<pre><code> Wed Nov 12 blah blah blah blah cat1
Wed Nov 12 blah blah blah blah
Wed Nov 12 blah blah blah blah
Wed Nov 12 blah blah blah blah cat2
more blah blah
even more blah blah
Wed Nov 12 blah blah blah blah cat3
Wed Nov 12 blah blah blah blah cat4
</code></pre>
<p>I want to... | <p>if you say every line that starts with space is a continuation of the folling its easy with (g)awk (this is from my memory, so maybe it contains some minor typos, and for better readability with some additional linebreaks):</p>
<pre><code>awk " BEGIN { multiline = 0;}
! /^ / { if (whatever)
... | <p>Something like this?</p>
<pre><code>awk 'function print_part() { if(cat) print part } /^ / { part = part "\n" $0; next } /cat[0-9]$/ { print_part(); part = $0; cat = 1; next; } { print_part(); cat=0} END { print_part() }' inputfile
</code></pre>
<p>The <code>/^ /</code> regexp identifies continuation lines.</p... | 39,967 |
<p>As may be known by many, the Express versions of Visual Studio 2008 don't include support for MFC and a few other packages required to compile a lot of windows programs. </p>
<p>So, here's my problem:</p>
<p>I have the full version of Visual Studio 2005. I've been using this to compile a project that a friend of m... | <p>You can use the VC++ compiler directly from the command line, or just create a new project w/ the source in Visual Studio 2005. Unless he is using some functionality provided in the new versions of MFC/ATL in 2008/2008sp1, you should be able to compile the project just fine.</p>
<p>See ("Create Project from Existin... | <p>Just for the record, I've done that(by modifying the include directories and library directories from inside the IDE) and it's working pretty well, I have MFC, ATL, everything.</p>
| 17,252 |
<p>I have a requirement to send some 100 bytes data over internet .My machine is connected to internet.
I can do this with HTTP by sending requests and receiving responses.
But my requirement is just to send data not receive response.
I am thinking of doing this using UDP Client server program. But to do that I need to... | <p>Cheap answer to send 100 bytes of data on the internet.</p>
<pre><code>C:\Windows\system32>ping -n 1 -l 100 -4 google.com
Pinging google.com [209.85.171.99] with 100 bytes of data:
Reply from 209.85.171.99: bytes=56 (sent 100) time=174ms TTL=233
Ping statistics for 209.85.171.99:
Packets: Sent = 1, Receive... | <p>If you want a UDP listener on the internet, it will have to be hosted somewhere. </p>
<p>You can get HTTP hosting much easier, it's everywhere, UDP you may need your own machine or at least a VM.</p>
| 41,712 |
<p>I hope this isn't a waste of time, however I have really been trying to figure this on out. Is it my syntax. I simply want to remove the parent div ".number-row" once the link with a class of ".remove-link" is clicked.</p>
<p>Thanks in advance</p>
<pre><code><script>
$(document).ready(function(){
$(".rem... | <p>Try <a href="http://docs.jquery.com/Traversing/parents" rel="nofollow noreferrer">parents()</a> instead of <a href="http://docs.jquery.com/Traversing/parent" rel="nofollow noreferrer">parent()</a>:</p>
<pre><code>$(document).ready(function(){
$(".remove-link").click(function() {
$(this).parents(".number... | <p>This should do it...</p>
<pre><code>$(document).ready(function(){
$(".remove-link").click(function() {
$(this).parent().parent().parent().hide();
})
})
</code></pre>
<p>Note that this doesn't <strong>remove</strong>, which you requested; it simply <strong>hides</strong> it. You can use <code>re... | 49,632 |
<p>I have a list with two <code><div></code>s in every <code><li></code> and I want to float them one next to the other and I want the <code><li></code> to take the whole availabe space. How do I do it?</p>
<pre><code><html>
<head>
<title></title>
<style... | <pre class="lang-css prettyprint-override"><code> *{ margin: 0; padding: 0;}
li{ width: 100%: display: block; }
li:after{ clear: both; }
div.a{ width: 49%; float: left; }
div.b{ width: 49%; float: left; }
</code></pre>
<p>Should do the trick. </p>
| <pre><code>li{width:100%;}
.a{}
.b{float: left;}
</code></pre>
<p>That should do as required from my knowledge of CSS</p>
| 11,916 |
<p>How can I change the master volume level? Using this code</p>
<pre><code>[DllImport ("winmm.dll")]
public static extern int waveOutSetVolume (IntPtr hwo, uint dwVolume);
waveOutSetVolume (IntPtr.Zero, (((uint)uint.MaxValue & 0x0000ffff) | ((uint)uint.MaxValue << 16)));
</code></pre>
<p>I can set the wav... | <p>Okay, here goes:</p>
<pre><code>const int MAXPNAMELEN = 32;
const int MIXER_SHORT_NAME_CHARS = 16;
const int MIXER_LONG_NAME_CHARS = 64;
[Flags] enum MIXERLINE_LINEF : uint{
ACTIVE = 0x00000001,
DISCONNECTED = 0x00008000,
SOURCE = 0x80000000
}
[Flags] enum MIXER : uint... | <p>Use this free library, it's simple and does the job.
<a href="https://inputsimulator.codeplex.com/" rel="nofollow noreferrer">InputSimulator</a></p>
<p>It simulates a key press.
You only have to add this reference and call wherever you want static methods like these:</p>
<pre><code> InputSimulator.SimulateKeyPres... | 37,567 |
<p>I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed <a href="http://www.termsys.demon.co.uk/vtansi.htm#colors" rel="noreferrer">here</a>).</p>
<p>One method I have is one to find all the codes ... | <p>The reason why #1 is slower is that [\d;]+ is a greedy quantifier. Using +? or *? is going to do lazy quantifing. See <a href="http://msdn.microsoft.com/en-us/library/3206d374(VS.80).aspx" rel="nofollow noreferrer">MSDN - Quantifiers</a> for more info.</p>
<p>You may want to try:</p>
<pre><code>"(\e\[(\d{1,2};)*?[... | <p>Without doing detailed analysis, I'd guess that it's faster because of the question marks. These allow the regular expression to be "lazy," and stop as soon as they have enough to match, rather than checking if the rest of the input matches.</p>
<p>I'm not entirely happy with this answer though, because this mostly... | 2,685 |
<p>Many databases I've encountered (Like SQL Server) use a single file to store the entire database. This seems to be a pretty common approach. What are the advantages to storing the entire database in a single file, as opposed to breaking up the data into more logical units, such as a single table per file. </p>
<p... | <p>A single non-fragmented large file can be treated by the server application much like a raw disk is treated by the operating system: a random-seekable block of bytes. The database server could, if it chose to, implement an entire file system on top of that block of bytes, if there was a benefit to implementing table... | <p>A related note.
I believe it is a MSFT recommendation that you create a filegroup for your system tables and one for your other objects. Another may also be created to store indexes. We don't do this, as none of our applications demand such high performance. It would also increase complexity of maintenance.</p>
| 43,135 |
<p>While looking at the <code>syntax-case</code> section in R6RS, I saw the keyword <code>make-variable-transformer</code>, described as an <em>identifier macro</em>. The example given is very minimal, and I am not groking why it is necessary, or what use-cases require it. Finding additional examples of its use is also... | <p>After reading <a href="http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-13.html#node_sec_12.3" rel="nofollow noreferrer">http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-13.html#node_sec_12.3</a> my take is as follows:</p>
<p>If <code>mac</code> is a syntax transformer</p>
<p><code>(mac foo (bar baz))</cod... | <p>I came across this searching for documentation on make-variable-transformer. Here's a problem I had that make-variable-transformer was suggested for...</p>
<p><a href="http://groups.google.com/group/comp.lang.scheme/browse_frm/thread/96b07d431f1a66de/777f8e07ae1855f3#777f8e07ae1855f3" rel="nofollow noreferrer">htt... | 42,103 |
<p>Within my InfoPath form (which has to be loaded within a SharePoint Portal by the browser)I have a repeating table containing multiple fields. Now I would like to make the first textfield autoincrement starting by 1. How exactly can I do this?</p>
<p>I have already heard of a way by using the "count" function but t... | <p>Let's say your repeating group is called "item" and your autoincrement field is called "index". The default value of the index field should be</p>
<pre><code>count(/my:myFields/my:item)
</code></pre>
<p>This should count correctly for you.</p>
| <p>I suspect you really want position(). Count is just going to return the total count of nodes that match the xpath expression you give it.</p>
| 35,544 |
<p>I would like to implement a payment solution with my Rails site using Paypal Website Payments Standard. (See <a href="https://www.paypal.com/IntegrationCenter/ic_standard_home.html" rel="noreferrer">https://www.paypal.com/IntegrationCenter/ic_standard_home.html</a>). I don't want fancy gateways, and I don't want to ... | <p>I would also check out <a href="http://www.activemerchant.org/" rel="nofollow noreferrer" title="ActiveMerchant">ActiveMerchant</a>. Here's a bit more info <a href="http://www.codyfauser.com/2008/1/17/paypal-express-payments-with-activemerchant" rel="nofollow noreferrer">here</a>.</p>
| <p><a href="http://spreehq.org" rel="nofollow noreferrer">Spree</a> contains an <a href="http://github.com/Gregg/spree-pp-website-standard/tree/master" rel="nofollow noreferrer">extension</a> for Payapl Website Payments Standard. In fact, the popular <a href="http://envycasts.com" rel="nofollow noreferrer">envycasts</... | 33,325 |
<p>I am trying to retrieve a user on Sharepoint's user photo through the WSS 3.0 object model. I have been browsing the web for solutions, but so far I've been unable to find a way to do it. Is it possible, and if so how?</p>
| <p>Here is a code snippet that should help get the job done for you. You may need to do some additional validation to avoid any exceptions (ensuring the profile actually exists, ensuring the image URL actually exists, etc...):</p>
<pre><code> //get current profile manager
UserProfileManager objUserProfileManag... | <p>Ah, You have to use the UserProfileManager class.
More information here: <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofilemanager.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofilemanager.aspx</a></p... | 8,649 |
<p>I'm having a lot of issues with NSDate objects being prematurely deallocated. I suspect that the issues may be related to the way that I deal with the objects returned from NSDate convenience methods. I <em>think</em> that my showDate property declaration in the JKShow class should be "retain", but changing it to as... | <p>The date returned from dateFromComponents should be in the autorelease pool, so you are correct that your showDate property should be "retain". In fact it should be anyway (unless you specifically want "copy").</p>
<p>From the code you have shown it looks like you are giving ownership of your show object entirely t... | <p>The code you showed has no premature-release problems. In fact, it will leak the array and everything in it, because it doesn't release the array.</p>
<p>Are you running with the garbage collector turned on?</p>
<p>Is <code>list</code> an instance variable or static variable, or is it a local variable?</p>
| 31,923 |
<p>In an iPhone app I'm working on, the user needs to enter some configuration via the settings application before my app will be able to connect to a server and run. Right now when the user first launches my app, I display an alert explaining that the user should go to settings, enter the config details and then relau... | <p>As far as I know there's no sanctioned way to open Settings from another app.</p>
<p>In my opinion you should just ask for the values if you need them at launch, storing them in your NSUserDefaults and possibly directing your users to look in Settings.app if they need to change those settings in the future.</p>
<p... | <p>One of possible solutions suggested above is to write own settings dialog. I have found this project <a href="http://www.inappsettingskit.com/" rel="nofollow">http://www.inappsettingskit.com/</a> which you can include to your app and it shows the same settings as iOS does. I did not test it yet, but going to do now... | 49,373 |
<p>I have a class with the following member functions:</p>
<pre><code>
/// caller pid
virtual pid_t Pid() const = 0;
/// physical memory size in KB
virtual uint64_t Size() const = 0;
/// resident memory for this process
virtual uint64_t Rss() const = 0;
/// cpu used by this process
virtual double PercentCpu() c... | <p>Process info comes from <code>pidinfo</code>:</p>
<pre><code>cristi:~ diciu$ grep proc_pidinfo /usr/include/libproc.h
int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize);
</code></pre>
<p>cpu load comes from <code>host_statistics</code>:</p>
<pre><code>cristi:~ diciu$ grep -r host_... | <p>Most of this info can be gotten from <a href="http://developer.apple.com/documentation/Carbon/Reference/Process_Manager/Reference/reference.html#//apple_ref/doc/uid/TP30000208-CH1g-TPXREF103" rel="nofollow noreferrer">GetProcessInformation()</a>.</p>
<p>By the way, why virtual methods for functions that return proc... | 27,129 |
<p>I need a dropdown list on my page that will allow a user to select their state. Since this is probably a control that will be used elsewhere, I thought it would be a good idea to create an MVC View User Control that could be reused.</p>
<p>I was thinking the control would look something like this:</p>
<pre><code>... | <p>Corey is on to the right solution. I think declaring specific Model objects for your view makes the views VERY simple and as a side bonus makes them dirt easy to test.</p>
<p>So instead of just passing the ID as the object, you'd probably want to create your own Model object to pass in.</p>
<p>It could look somet... | <p>Take a look at the Html.DropDownList helper method. It has a number of overloads that allow you to pass the list data and set the selected item. the simplest version just sets the name of the select. </p>
<pre><code><%= Html.DropDownList("SelectStates"); %>
</code></pre>
<p>If there is a value in the ViewD... | 33,279 |
<p>Does a <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.aspx" rel="noreferrer"><code>System.Windows.Threading.Dispatcher</code></a> work on the UI-thread of a <code>WinForms</code> application?</p>
<p>If yes, why? It is coming from WindowsBase.dll which seems to be a <code>WPF</c... | <p>You can use <code>Dispatcher</code> even in a WinForms app.</p>
<p>If you are sure to be on a UI thread (e.g. in an button.Click handler), <code>Dispatcher.CurrentDispatcher</code> gives you the UI thread dispatcher that you can later use to dispatch from background threads to the UI thread as usual.</p>
| <p>Take a look at <a href="http://code.google.com/p/backgrounder/" rel="nofollow noreferrer">backgrounder</a> and see if it fits your needs.</p>
| 38,941 |
<p>I am trying to merge a directory in subversion, but I get the following error when I do so:</p>
<pre><code>svn: Working copy '[directory name]' not locked'
</code></pre>
<p>I tried deleting the working directory and doing a fresh update, but that did not solve the issue. I also did a cleanup on the directory. </p>... | <p>Check out this blog posting (<a href="http://news.e-scribe.com/145" rel="nofollow noreferrer">Obscure "svn mv" problem solved</a>)... I typically just remove the directory and grab fresh sources.</p>
| <p>Try doing a clean-up and then an update. If that not work, please explain better your issue.</p>
| 12,109 |
<p>So, I have willfully kept myself a Java n00b until recently, and my first real exposure brought about a minor shock: Java does not have C# style properties!</p>
<p>Ok, I can live with that. However, I can also swear that I have seen property getter/setter code in Java in one codebase, but I cannot remember where. H... | <p>There is a "standard" pattern for getters and setters in Java, called <a href="http://docs.oracle.com/javase/tutorial/javabeans/writing/properties.html" rel="nofollow noreferrer">Bean properties</a>. Basically any method starting with <code>get</code>, taking no arguments and returning a value, is a proper... | <p>As previously mentioned for eclipse, integrated development environment (IDE) often can create accessor methods automatically.</p>
<p>You can also do it using NetBeans. </p>
<p>To create accessor methods for your class, open a class file, then Right-click anywhere in the source code editor and choose the menu comm... | 9,587 |
<p>Up till now we've been rewriting URL's using a custon 404 page: the url would not map to any file in the site, and we configured the IIS to send 404 error to a aspx page which redirected those url's to the correct URL.<br>
Now we want to stop using redirects, so after reading Scott Guthrie's article on Url Rewriting... | <p>Every request goes through Application_BeginRequest anyway. </p>
<p>You'll need to add some logic so only those pages that need to be rewritten are changed. </p>
<p>That small bit of logic won't be very expensive.</p>
<p>I've used it, and didn't notice performance suffering at all.</p>
| <p>Scott Guthrie's <a href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx" rel="nofollow noreferrer">article</a> is a good one, but I am curious as to why you are choosing to do this via the Global.asax instead of using an HttpModule as he suggests. Also, the Asp.Net page l... | 42,827 |
<p>Here is my understanding of Coasting: Coasting stops extruding early in a move so that the string itself will finish the layer.</p>
<p>Here is my understanding of Combing: Combing reduces the need to retract during travel moves by making sure that the nozzle oozes where you want it to on the way to the next point.<... | <p>If anything, combing and coasting allow to <strong>mitigate problems that are printer and filament specific</strong>, rather than dependent on particular STL models.</p>
<p><strong>Combing helps</strong> - as you imply in your question - <strong>with materials prone to oozing</strong> (e.g. PETG)</p>
<p><strong>Co... | <p>Coasting is good for filaments that ooze. The stop/up/start time at the end of a layer can be long enough that a visible seam appears if the layer starts in the same place. Transparent filaments also suffer from the velocity effect at layer shifts (more transparent when extruded slower).
The disadvantage is that it ... | 792 |
<p>I'm using c#, and have an open tcpip connection receiving data. Is it possible to save the stream to an ms sql server database as I'm receiving it, instead of receiving all the data then saving it all? If the stream could be sent to the database as it's being received, you wouldn't have to keep the entire chunk of... | <p>Are you writing to the DB as a BLOB, or translating the data in some form, then executing inserts for each row?</p>
<p>Your answer in the comments has me confused. Writing a stream to a BLOB column is vastly different then getting the data then translating it into inserts for separate rows.</p>
<p>Regardless, str... | <p>See <a href="http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/msg/314e7e3782e59a93" rel="nofollow noreferrer">here</a> and <a href="http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/msg/fcd173f1db2951f1" rel="nofollow noreferrer">here</a> for exmaples of working with ... | 31,459 |
<p>I need to write a function that receives a string and a regex. I need to check if there is a match and return the start and end location of a match. (The regex was already compiled by <code>qr//</code>.)</p>
<p>The function might also receive a "global" flag and then I need to return the (start,end) pairs of all th... | <p>The built-in variables <code>@-</code> and <code>@+</code> hold the start and end positions, respectively, of the last successful match. <code>$-[0]</code> and <code>$+[0]</code> correspond to entire pattern, while <code>$-[N]</code> and <code>$+[N]</code> correspond to the <code>$N</code> (<code>$1</code>, <code>$2... | <p>You can also use the deprecated $` variable, if you're willing to have all the REs in your program execute slower. From perlvar:</p>
<pre><code> $‘ The string preceding whatever was matched by the last successful pattern match (not
counting any matches hidden within a BLOCK or eval enclosed by th... | 11,294 |
<p>Suddenly, my printer has started producing prints that have a very pronounced layering. Normally, the alignment between layers is very good, and the prints look very smooth. Suddenly, the prints have become much worse and the layers are misaligned with respect to each other.</p>
<p><a href="https://i.stack.imgur.co... | <p>It appears the heatbreak of my E3D nozzle had worked itself loose from the heatsink, allowing the nozzle to wobble around a bit. Because the nozzle was still tight against the heatbreak I didn't experience any issues with my hotend, but because the heatbreak was slightly loose the nozzle wasn't properly constrained ... | <p>Have you recently leveled your print bed? By placing the nozzle too close to the bed on the first layer the first layer will seem over extruded. If there are no infill layers after the first layer, these layers will seem over extruded as well since the extra filament will have nowhere to go. </p>
<p>A typical sign ... | 115 |
<p>I have a PHP/AJAX/MYSQL chat application. I want to add video chatting to my application. How can I create live video streaming to be used for live video conferences/chatting in a PHP application. What are the key-terms I need to know if I wanted to build such a system? Is it a good idea in the first place to use PH... | <p>I am not saying that you have to abandon PHP, but you need different technologies here.</p>
<p>Let's start off simple (without Akamai :-)) and think about the implications here. Video, chat, etc. - it's all client-side in the beginning. The user has a webcam, you want to grab the signal somehow and send it to the s... | <p>Same problem/answer <a href="https://stackoverflow.com/questions/12782644/add-making-video-call-and-voice-call-to-my-site-php/12782932#12782932">here</a>, quoted below</p>
<blockquote>
<p>I'm assuming you mean that you want to run your own private video
calls, not simply link to Skype calls or similar. You real... | 27,666 |
<p>I have a class hierarchy, this one:</p>
<pre><code>type
TMatrix = class
protected
//...
public
constructor Create(Rows, Cols: Byte);
//...
type
TMinMatrix = class(TMatrix)
private
procedure Allocate;
procedure DeAllocate;
public
constructor Create(Rows, Cols: Byte... | <p>As far as I know, there are two separate issues here:</p>
<h3>Making sure the child class' constructor calls the base class' constructor</h3>
<p>You'll have to <em>explicitly</em> call the base class' constructor:</p>
<pre><code>constructor TMinMatrix.Create(Rows, Cols: Byte);
begin
inherited;
//...
end;
</... | <p>You need overload for both constructors if they have the same name. </p>
<pre><code>type
TMatrix = class
protected
//...
public
constructor Create(Rows, Cols: Byte);
//...
type
TMinMatrix = class(TMatrix)
public
constructor Create(Rows, Cols: Byte); overload;
constructor Create(var tha... | 47,059 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.