instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm using GDOME.pm and in my script I have this line:</p>
<pre><code>my $doc = XML::GDOME->createDocument("","","");
</code></pre>
<p>I can't for the life of me figure out why it's coming out with this error:</p>
<pre><code>NAMESPACE_ERR at /usr/lib/perl5/site_perl/5.6.1/i586-linux/XML/GDOME.pm line 103.
</cod... | <p>The documentation says: </p>
<pre><code>$doc = XML::GDOME->createDocument( $nsURI, $name, $dtd );
</code></pre>
<blockquote>
<p>Creates a new xml document. It will be
in the $nsURI namespace, if $nsURI is
defined, and its document element will
have the name $name.</p>
</blockquote>
<p>Now, your example... | <p>The XML::GDOME::DOMImplementation::createDocument that is called there is a C routine, so errors encountered in it are reported as if from the line of Perl code that called it.
That error will be caused by gdome_di_createDocument setting error code 14.</p>
<p>I don't get the error you report with:</p>
<pre><code> ... | 45,872 |
<p>I work in a shop that is certified at CMMI level 5. This certification is important because it gives us access to certain customers and contracts. I'm looking at how to blend Scrum with CMMI. I've found some info on mixing Scrum with CMMI-3, but quite a bit of it is "hand wavy" and wouldn't hold up to intense scr... | <p>This seems an interesting paper by the SEI folks at Carnegie Mellon (not just about Scrum though):</p>
<blockquote>
<p>CMMI and Agile are compatible. At the project level, CMMI focuses at a high level of abstraction
on what projects do, not on what development methodology is used, while Agile methods
focus on... | <p>On EuroStar 2009 conference Gittie Ottosen spoke about how they do agile at their company. What's impressive is that this company <a href="http://www.systematic.com" rel="nofollow noreferrer">Systematic</a> is creating software for air-crafts, military etc. They do it in compliance with CMMI 5, ISO 9001 and AQAP 150... | 32,188 |
<p>One thing that annoys me when debugging programs in Visual Studio (2005 in my case) is that when I use "step over" (by pressing <kbd>F10</kbd>) to execute to the next line of code, I often end up reaching that particular line of code in a totally different thread than the one I was looking at. This means that all th... | <p>I think there is only one answer to your question, which you have discounted as being 'way too much work.' However, I believe that is because you are going about it the wrong way. Let me present steps for adding a conditional breakpoint on Thread ID, which are extremely easy, but not obvious until you know them.</p... | <p>I recently had the same problem of debugging only a certain thread. While I won't discount the above answer as very comprehensive and valuable (and wish I had found it 2 days ago) - I implemented the following to help "everyday" troubleshooting.</p>
<p>This idea is only a simple workaround when running multiple ins... | 43,662 |
<p>I was talking to somebody a recently who mentioned it was possible to store reports created using Crystal Reports as XML files.</p>
<p>Upon Googling this, I can't find anything suggesting that this is the case (using <I>data</i> stored in XML in a report, yes, but actually storing the report, the part stored by def... | <p>It is not possible to store the report template in XMLformat. XML is supported as export format of the "rendered" report only.<br>
For what purpose do you need the report template in XML format. There is a Java reporting solution called <a href="http://www.inetsoftware.de/products/crystalclear/" rel="nofollow noref... | <p>At least in version 8.5 XML-file is one of the supported export destinations just like PDF, Excel or Word. Seems unlikely they'd have removed the support in later versions.</p>
| 21,335 |
<p>I have an archiving process that basically deletes archived records after a set number of days. Is it better to write a scheduled SQL job or a windows service to accomplish the deletion? The database is mssql2005. </p>
<h2>Update:</h2>
<p>To speak to some of the answers below, this question is regarding an in h... | <p>It depends on what you want to accomplish.
Do you want to store the deleted archives somewhere? Log the changes? An SQL Job should perform better since it is run directly in the database, but it is easier to give a service acces to resources outside the database. So it depends on what you want to do,,,</p>
| <p>To follow on Corey's point, if this is externally distributed, will you need to support SQL Express? If not, I'd go with the SQL job directly. Otherwise, you'll have to get more creative as SQL Express does not have the SQL Agent that comes with the full versions of SQL 2005 (as well as MSDE). Without the SQL Age... | 31,175 |
<p>Been using the code below to return a single record from the database. I have read that ExecuteScalar is the right way to return a single record. I have never been able to get ExecuteScalar to work though. How would I change this to return a single value in VB.Net using ExecuteScalar?</p>
<pre><code> Dim oracl... | <p>From Microsoft</p>
<p>"The ExecuteOracleScalar() method of the OracleCommand class is used to execute a SQL statement or stored procedure that returns a single value as an OracleType data type. If the command returns a result set, the method returns the value of the first column of the first row. The method returns... | <p>not sure why the other answer is marked as accepted, as it doesn't appear to answer your question</p>
<blockquote>
<p>How would I change this to return a single value in VB.Net using ExecuteScaler</p>
</blockquote>
<p>ExecuteScalar will only return a Single Value - so keep that in mind when writing the query por... | 47,132 |
<p>We have several .NET applications that monitor a directory for new files, using FileSystemWatcher. The files are copied from another location, uploaded via FTP, etc. When they come in, the files are processed in one way or another. However, one problem that I have never seen a satisfactory answer for is: for large f... | <p>If you are in control on the program that is writing the files into the directory, you can have the program write the files to a temporary directory and then move them into the watched directory. The move should be an atomic operation, so the watcher shouldn't see the file until it is fully in the directory.</p>
<... | <p>A write lock doesn't help if the file upload failed part way through and the sender hasn't tried resending (and relocking) the file yet.</p>
| 4,994 |
<p>ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks. </p>
<p>Does anyone have any ideas how I could get around this problem?</p>
| <p>I'm curious as to why you need to mock the DataRow. Sometimes you can get caught up doing mocking and forget that it can be just as prudent to use the real thing. If you are passing around data rows then you can simply instantiate one with a helper method and use that as a return value on your mock.</p>
<pre><code>... | <p>Any time I can't mock something (I prefer MoQ over Rhino, but that's beside the point) I have to code around it.</p>
<p>The way I see it you only have two choices. Pay for a superior framework such as TypeMock that can mock ANY class, or code a wrapper around classes that weren't written to be mocked. </p>
<p>It... | 18,846 |
<p>Since String implements <code>IEnumerable<char></code>, I was expecting to see the Enumerable extension methods in Intellisense, for example, when typing the period in</p>
<pre><code>String s = "asdf";
s.
</code></pre>
<p>I was expecting to see <code>.Select<char>(...)</code>, <code>.ToList<char>... | <p>It's by explicit design. The problem is that while String most definitely implements <code>IEnumerable<T></code>, most people don't think of it, or more importantly use it, in that way. </p>
<p>String has a fairly small number of methods. Initially we did not filter extension methods off of String and the ... | <p>It should.</p>
<pre><code>For example you can write it public static string myExtensionMethod(this String yuppi){
}
</code></pre>
<p>Then it is supposed to be there.</p>
| 45,003 |
<p>I have an interface that I have defined in C++ which now needs to be implemented in C#. What is the best way to go about this? I don't want to use COM at all in my interface definition. The way I have solved this right now is to to have two interface definitions, one in C++ and one in C#. I then expose the C# interf... | <p>If you are willing to use C++/CLI for your managed code instead of C#, then you can just consume the native C++ interface definition directly via the header file. How easy this will be will depend on exactly what is in your interface - simplest case is something that you could use from C.</p>
<p>Take a look at Marc... | <p>You don't mention which version of .NET you're using, but something that's worked for me in using Visual Studio .NET 2003 is to provide a thin C# wrapper around the pimpled implementation of the real C++ class:</p>
<pre><code>public __gc class MyClass_Net {
public:
MyClass_Net()
:native_ptr_(new MyClass())... | 9,024 |
<p>Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using the MFC90.dll and msvc[pr]90.dlls along with the manifest files in a private side-by-side configuration so as to not worry about versions or installing them to the system.</p>
<p>Pre-SP1, this was working fine (and still works fine on our... | <p>I have battled this problem myself last week and consider myself somewhat of an expert now ;)</p>
<p>I'm 99% sure that not all dlls and static libraries were recompiled with the SP1 version. You need to put</p>
<pre><code>#define _BIND_TO_CURRENT_MFC_VERSION 1
#define _BIND_TO_CURRENT_CRT_VERSION 1
</code></pre>
... | <p>I just remembered another trick that I used to find out which static libraries were ill-behaving: 'grep' through the static libraries for the string '21022'. HOWEVER, don't use the 'normal' grep tools like wingrep because they won't show you these strings (they think it's a binary file and look for the raw, non-unic... | 8,426 |
<p>I would like to add a DataGridViewTextBoxCell cell to a DataGridViewCell control, but as well as being able to type in the text cell as normal it must also contain a '...' button that once clicks brings up the OpenFileDialog window to allow the user to select a file. Once selected, the text cell will be populated wi... | <p><a href="http://msdn.microsoft.com/en-au/library/7tas5c80.aspx" rel="nofollow noreferrer">This</a> MSDN article explains how to add a custom control to a <code>DataGridView</code>.</p>
<p>You should be able to make a <code>UserControl</code> that has a textbox and button on it and embed that in the <code>DataGridVi... | <p>You will need to create your own column and cell classes in order to do this. I would suggest using <strong>.NET</strong> Reflector to look at the implementation details of the DataGridViewTextBox as a starting point and then customizing to add display of a button at the end of it. Check out these tutorials to get s... | 8,868 |
<p>I have a class Customer in app_code folder in asp.net web site, how can I create an instance using reflection, for example using Activator.CreateInstance(assemblyName, typeName)? Because the app_code is dynamically compiled, I don't know the assembly in design time?</p>
<p>Thanks
Fred</p>
<p>The question is should... | <p>I think you can use <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getexecutingassembly.aspx" rel="nofollow noreferrer">Assembly.GetExecutingAssembly()</a> to get a reference to the current assembly.</p>
| <p>You can also use GetType().Assembly if you know that it will be the same assembly as your currently executing code.</p>
| 42,959 |
<p>I want to know how the glBlendFunc works. For example, i have 2 gl textures, where the alpha is on tex1, i want to have alpha in my final image. Where the color is on tex1, i want the color from tex2 to be.</p>
| <p>glBlendFunc applies only to how the final color fragment gets blended with the frame buffer. I think what you want is multitexturing, to combine the two textures by blending the texture stages using glTexEnv, or using a fragment shader to combine the the two textures.</p>
| <p>glBlendFunc applies only to how the final color fragment gets blended with the frame buffer. I think what you want is multitexturing, to combine the two textures by blending the texture stages using glTexEnv, or using a fragment shader to combine the the two textures.</p>
| 22,647 |
<p>i have a 3 column datafile and i wanted to use splot to plot the same.
But what i want is that gnuplot plots first row (in some colour, say red) and then pauses for say 0.3 secs and then moves on to plotting next row (in other colour, not in red, say in green), pauses for 0.3 secs and then proceeds to next row....so... | <p>If you want to produce an animation, you better use specialized tools for it (like mplayer).</p>
<p>Use gnuplot to prepare all source images (first one with single row plotted, second - with two lines, etc), then use mplayer or convert (from imagemagic) to produce avi or animated GIF out of source files.</p>
<p>Yo... | <p>make a plotfile eg. 'myplotfile.plt'. and put in it all the commands you would normally type in gnuplot to plot your graphs.</p>
<p>then just add the line</p>
<pre><code>!sleep $Number_of_Seconds_to_Pause</code></pre>
<p>to your plot file where you want it to pause, and run it from the terminal with</p>
<pre><co... | 27,755 |
<p>I'm trying to wrap my head around reflection, so I decided to add plugin capability to a program that I'm writing. The only way to understand a concept is to get your fingers dirty and write the code, so I went the route of creating a simple interface library consisting of the IPlugin and IHost interfaces, a plugin ... | <p>I'm just guessing here because from your code it's not obvious where do you have definition of IPlugin interface but if you can't cast in your host application then you are probably having IPlugin interface in your host assembly and then at the same time in your plugin assembly. This won't work.</p>
<p>The easiest ... | <p>Is your type not public, if so, call the overload that takes in a boolean:</p>
<pre><code>Activator.CreateInstance(type, true);
</code></pre>
<p>Also, in your first example, see if o is null and if not, print out o.GetType().Name to see what it really is.</p>
| 5,152 |
<p>I've got two branches of code. 1 has a dialog box that the other doesn't, but because of politics the dialog box wasn't moved into the newest branch. Now they want it in... </p>
<p>So is it possible to copy a dialog box from one project to another.
There apears to be an export and import feature however it's greye... | <p>.RC files are simple text files. You can simply copy/paste the DIALOG text from one .RC file to the other. Make sure that you copy the corresponding RESOURCE.H entries as well.</p>
<p>Alternatively, you might be able to open both .RC files and then simply drag-and-drop the dialog from one to the other.</p>
| <p>Drag and drop doesn't work in Visual Studio 2010. Editing the .RC file does work but be careful. For me the ID for the dialog showed up with *ID_etc*. I copied it and removed the *'s and it seemed to fix the problem.</p>
| 35,108 |
<p>Is it possible to embed a DOS console in a Windows Form or User Control in C# 2.0?</p>
<p>We have a legacy DOS product that my Windows app has to interact with, and it's been requested that an instance of the legacy product should run within the Windows application.</p>
<p>At the moment, I'm using the user32.dll t... | <p>It's possible to redirect the standard input/output of console/dos applications using the Process class. It might look something like this:</p>
<pre><code>var processStartInfo = new ProcessStartInfo("someoldapp.exe", "-p someparameters");
processStartInfo.UseShellExecute = false;
processStartInfo.ErrorDialog = fal... | <p>You can use the CreateProcess function and the hStdInput, Output, and Error members of the STARTUPINFO argument, this will allow you to intercept standard input and output of the application.</p>
| 46,366 |
<p>I track alot of things with RRD, eg, uptime, network throughput, etc. This works well when you can fit all the graphs on a single page, however, once you scale beyond a page it becomes difficult to use graphs to catch issues, you need to look at them to see that there is an issue, and if there is hundreds or thousan... | <p>You can read the RRD file directly, not just use the graphs generated. You might need to write your own app to do this, but the file format is an open standard so shouldn't be that difficult to get what you need.</p>
<p><a href="http://oss.oetiker.ch/rrdtool-trac/browser/branches/1.3/program/src/rrd_format.h" rel="... | <p>Looks like RRD actually supports this,</p>
<p><a href="http://cricket.sourceforge.net/aberrant/rrd_hw.htm" rel="nofollow noreferrer">http://cricket.sourceforge.net/aberrant/rrd_hw.htm</a></p>
<p>Would be interested in hearing if anyone has used this.</p>
| 29,582 |
<p>I have an application I'm writing where I'm allowing the administrators to add aliases for pages, categories, etc, and I would like to use a different controller/action depending on the alias (without redirecting, and I've found that render doesn't actually call the method. I just renders the template). I have tried... | <h2>Quick Solution</h2>
<p>Have a catch-all route at the bottom of routes.rb. Implement any alias lookup logic you want in the action that route routes you to. </p>
<p>In my implementation, I have a table which maps defined URLs to a controller, action, and parameter hash. I just pluck them out of the database, th... | <p>I'm not sure I fully understand the question, but you could use <code>method_missing</code> in your controllers and then lookup the alias, maybe like this:</p>
<pre><code>class MyController
def method_missing(sym, *args)
aliased = Alias.find_by_action_name(sym)
# sanity check here in case no alias
se... | 15,747 |
<p>I would like to gain some insight into the life cycle that is used in industry when developing and deploying OSGi based systems.<br>
My main focus is on the deployment phases, after the development phase has created versioned and packaged a bundle. Specifically testing procedures that may be carried out, and method ... | <p>OSGi bundles can be assembled together in a running OSGi engine (whether Equinox, Felix, dmServer etc.). As with other code, there may be dependencies on platform-specific behaviour (such as code only working on Windows that uses c:\ style file references), code that works together with JNI and is only valid for x86... | <p>You could study Eclipse, as it is one of the largest OSGi based systems I am aware of. And they have many documents that talk about versioning and how they use testing in the eclipse platform.</p>
| 49,235 |
<p>I came across an interesting article which shows how we can transparently encrypt jdbc connections using java thin client. </p>
<p><a href="http://javasight.wordpress.com/2008/08/29/network-data-encryption-and-integrity-for-thin-jdbc-clients/" rel="nofollow noreferrer">http://javasight.wordpress.com/2008/08/29/netw... | <p>It can be similarly done. I believe on the Oracle AS there is an option at the bottom of the page when you create datasource which says add properties. I believe you can add the following over there and give it a try.</p>
<pre><code>// Set the Client encryption level
"oracle.net.encryption_client" = Service.getLe... | <p>Late reply somehow, but for any one who come across this question again</p>
<p><strong><em>For Enryption/Integrity:</em></strong></p>
<p>you will need to insert this properties manually in $J2EE_HOME/config/data-sources.xml as follows : -not tested thoroughly but should work, at least with little twicking , but sh... | 28,823 |
<p>I see a lot of example code for C# classes that does this:</p>
<pre><code>public class Point {
public int x { get; set; }
public int y { get; set; }
}
</code></pre>
<p>Or, in older code, the same with an explicit private backing value and without the new auto-implemented properties:</p>
<pre><code>public ... | <p>I tend to agree (that it seems needlessly verbose), although this has been an issue our team hasn't yet resolved and so our coding standards still insist on verbose properties for all classes.</p>
<p><a href="https://blog.codinghorror.com/properties-vs-public-variables/" rel="noreferrer">Jeff Atwood</a> dealt with ... | <p>You never know if you might not need some translation of the data later. You are prepared for that if you hide away your members. Users of your class wont notice if you add the translation since the interface remains the same.</p>
| 13,668 |
<p>PHP5 has a "magic method" <code>__call()</code>that can be defined on any class that is invoked when an undefined method is called -- it is roughly equivalent to Ruby's <code>method_missing</code> or Perl's <code>AUTOLOAD</code>. Is it possible to do something like this in older versions of PHP?</p>
| <p>The most important bit that I was missing was that <code>__call</code> exists in PHP4, but you must enable it on a per-class basis by calling <code>overload()</code>, as seen in <a href="http://us2.php.net/manual/en/function.overload.php" rel="nofollow noreferrer">php docs here</a> .
Unfortunately, the __call() func... | <p>I recall using it, and a little bit of googling suggests that</p>
<pre><code>function __call($method_name, $parameters, &$return)
{
$return_value = "You called ${method_name}!";
}
</code></pre>
<p>as a member function will do the job.</p>
| 10,195 |
<p>I have a project at work the requires me to be able to enter information into a web page, read the next page I get redirected to and then take further action. A simplified real-world example would be something like going to google.com, entering "Coding tricks" as search criteria, and reading the resulting page.</p>... | <p>You can programmatically create an Http request and retrieve the response:</p>
<pre><code> string uri = "http://www.google.com/search";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
... | <p>Depending on how the website works you can either manipulate the url to perform what you want. e.g to search for the word "beatles" you could just open a request to google.com?q=beetles and then just read the results. </p>
<p>Alternatively if the website does not use querystring values (url) to process page action... | 16,375 |
<p>One of my projects use the MyISAM engine in MySQL, but I'm considering changing it to InnoDB as I need transaction support here and there.</p>
<ul>
<li>What should I look at or consider before doing this? </li>
<li>Can I just change the engine, or should the data be prepared for it?</li>
</ul>
| <p>Yes absolutely, there are many things, you should test your application extremely thoroughly:</p>
<ul>
<li>Transactions can deadlock and need to be repeated. This is the case (in some circumstances) even with an autocommitted transaction which only inserts one row.</li>
<li>Disc usage will almost certainly increase... | <p>The performance characteristics can be different, so you may need to keep an eye on the load.</p>
<p>The data will be fine.</p>
| 27,831 |
<p>Assuming I'm trying to automate the installation of something on windows and I want to try to test whether another installation is in progress before attempting install. I don't have control over the installer and have to do this in the automation framework. Is there a better way to do this, some win32 api?, than ju... | <p>See the description of the <a href="http://msdn.microsoft.com/en-us/library/aa372909(VS.85).aspx" rel="noreferrer">_MSIExecute Mutex</a> on MSDN.</p>
| <p>I was getting an unhandled exception using the code above. I cross referenced this article witt this <a href="https://stackoverflow.com/questions/17070583/releasing-a-mutex">one</a></p>
<p>Here's my updated code:</p>
<pre><code> /// <summary>
/// Wait (up to a timeout) for the MSI installer service to beco... | 17,016 |
<p>LINQ is one of the greatest improvements to .NET since generics and it saves me tons of time, and lines of code. However, the fluent syntax seems to come much more natural to me than the query expression syntax.</p>
<pre><code>var title = entries.Where(e => e.Approved)
.OrderBy(e => e.Rating).Select(e =&... | <p>Neither is better: they serve different needs. Query syntax comes into its own when you want to leverage <strong>multiple range variables</strong>. This happens in three situations:</p>
<ul>
<li>When using the let keyword</li>
<li>When you have multiple generators (<em>from</em> clauses)</li>
<li>When doing joins</... | <p>I really like the Fluent syntax and I try to use it where I can, but in certain cases, for example where I use joins, I usually prefer the Query syntax, in those cases I find it easier to read, and I think some people are more familiar to Query (SQL-like) syntax, than lambdas.</p>
| 26,364 |
<p>I'm working on a project for school, and I'm implementing a tool which can be used to download files from the web ( with a throttling option ). The thing is, I'm gonna have a GUI for it, and I will be using a <code>JProgressBar</code> widget, which I would like to show the current progress of the download. For that ... | <p>Any HTTP response is <em>supposed</em> to contain a Content-Length header, so you could query the URLConnection object for this value.</p>
<pre><code>//once the connection has been opened
List values = urlConnection.getHeaderFields().get("content-Length")
if (values != null && !values.isEmpty()) {
// g... | <p>As @erickson said, sometimes there is header "Transfer-Encoding: chunked", instead of "Content-Length: " and of course you have null value for length.</p>
<p>About the available() method - nobody can guarantee to you that it will return proper value, so I recommend you to not use it.</p>
| 32,924 |
<p>I didn't see any similar questions asked on this topic, and I had to research this for something I'm working on right now. Thought I would post the answer for it in case anyone else had the same question.</p>
| <p>I found the answer here: <a href="http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/" rel="noreferrer">http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/</a></p>
<p>You just concatenat... | <p>In some special cases you may find this useful (e.g. rendering cell-content in MS Report )
<br>example:</p>
<pre><code>select * from
(
values
('use STAGING'),
('go'),
('EXEC sp_MSforeachtable
@command1=''select ''''?'''' as tablename,count(1) as anzahl from ? having count(1) = 0''')
) as t([Copy_and_... | 5,092 |
<p>I get the following error in Visual Studio 2005 when doing a build:</p>
<blockquote>
<p>Error 9 Cannot register assembly
"E:\CSharp\project\Some.Assembly.dll"
- access denied. Access is denied. (Exception from HRESULT: 0x80070005
(E_ACCESSDENIED)) project</p>
</blockquote>
<p>It happens only intermittant... | <p>It sounds like you have a DLL that gets locked every now and then, preventing VS from overwriting/locking it. Have you tried using tools like Process Explorer (<a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb896653.as... | <p>This may be caused by Visual Studio requiring administrator rights on Windows 7 or higher. To check, see whether the registry key mentioned below is set. If not, copy into a <code>.reg</code> and merge. Be sure to check that your Visual Studio 2005 installation path in the <code>.reg</code> file is correct!</p>
<pr... | 10,664 |
<p>I have to check some code and run it. I have the URL:</p>
<pre><code>svn+ssh://myuser@www.myclient.com/home/svn/project/trunk
</code></pre>
<p>I have a file with their private key. What do I do to get this code?</p>
| <p>If you need to use a custom key just for svn, the following will work:</p>
<p><code>SVN_SSH="ssh -i /path/to/key_name"</code></p>
<p><code>export SVN_SSH</code></p>
<p><code>svn commands</code></p>
<p><a href="http://labs.kortina.net/2010/01/30/svn-checkout-with-private-key-over-ssh/">http://labs.kortina.net/201... | <pre><code>SVN_SSH="ssh -i /xxx/xxx/id_rsa" svn checkout svn+ssh://username@svn.xxx.com/data
</code></pre>
| 23,353 |
<p>Am looking for a regression test framework where I can add tests to.. Tests could be any sort of binaries that poke an application..</p>
| <p>This really depends on what you're trying to do, but one of the features of the new <a href="http://search.cpan.org/dist/Test-Harness/" rel="nofollow noreferrer">Test::Harness</a> (disclaimer: I'm the original author and still a core developer) is that if your tests output TAP (the Test Anything Protocol), you can u... | <p>You did not indicate what language you are working in, but the xUnit family is available for a lot of different languages.</p>
<p>/Allan</p>
| 9,505 |
<p>I know about <a href="http://jakarta.apache.org/bcel/" rel="noreferrer">BCEL</a>, but this project seems to be dead, as it had no releases for two years. And the Java-world moves on. For example JDK 1.6 has a new class-file-format.</p>
<p>So what library can be used to create bytecode for the JVM. If no library, a ... | <p>ASM</p>
<p><a href="http://asm.objectweb.org/" rel="noreferrer">http://asm.objectweb.org/</a></p>
<p>It is much faster than BCEL and supports generics and annotations.
One point about its architecture: in order to ensure high performance ASM is built around a parser that throws events (in contrast to BCEL where t... | <p>I think my favorite java bytecode creator is called javac and you can find it at www.sun.com</p>
| 37,176 |
<p>If I am in a function in the code behind, and I want to implement displaying a "Loading..." in the status bar the following makes sense, but as we know from WinForms is a NoNo:</p>
<pre><code>StatusBarMessageText.Text = "Loading Configuration Settings...";
LoadSettingsGridData();
StatusBarMessageText.Te... | <p>Best and simplest:</p>
<pre><code>using(var d = Dispatcher.DisableProcessing())
{
/* your work... Use dispacher.begininvoke... */
}
</code></pre>
<p>Or</p>
<pre><code>IDisposable d;
try
{
d = Dispatcher.DisableProcessing();
/* your work... Use dispacher.begininvoke... */
} finally {
d.Dispose();
... | <p>The easiest way to get this to work is to add the LoadSettingsGridData to the dispatcher queue. If you set the operation's DispatcherPriority sufficiently low enough, the layout operations will occur, and you will be good to go.</p>
<pre><code>StatusBarMessageText.Text = "Loading Configuration Settings...";
this.D... | 10,847 |
<p>I experience that on several different machines, with plugins, without plugins, with VB.net or c# solutions of many different sizes, <strong>closing</strong> the solution in <strong>VS 2005</strong> generally takes significantly more time than actually <strong>building</strong> the solution.</p>
<p>This has always ... | <blockquote>
<p>What on earth is visual studio doing
when you have actually told it to shut
down?</p>
</blockquote>
<p>You can use <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">Process Monitor</a> from sysinternals. It maybe because of some plugins. Try resetti... | <p>I've found that closing all the open documents before you close the solution helps speed it up. Or maybe it's just a perception thing, but it <em>seems</em> faster :)</p>
| 6,716 |
<p>Ok guys and gals, here is my problem:</p>
<p>I've built a custom control that uses a textbox to present data to the user. </p>
<p>When the user interacts with the control the <strong>value of that textbox is altered with client side javascript</strong>.</p>
<p>I also have a button on my page. When the user clicks... | <p>Ah ha! I've solved my own problem!</p>
<p>Because I had set Readonly="True" on the textbox control ASP.NET was not picking up it's value from the postback.</p>
<p>Instead I should have manually added the readonly attribute to the textbox during my user control construction.</p>
<p>eg.</p>
<pre><code>this.textBox... | <p>Strange that you answered yourself!
In fact, I've faced this nuisance before, and cost me some time until I found a note in the visual studio documentation describing the cause, you can read it here <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.readonly.aspx" rel="nofollow norefe... | 33,651 |
<p>I'm doing some small changes to C++ MFC project. I'm .NET developer so Windows programming is new to me.</p>
<p>I need to launch some method right after CDialog is completely shown (painted) for the first time, but only once.</p>
<p>How can I do this? In .NET I would handle <strong>Form.Shown</strong> event.</p>
... | <p>Found the answer here: <a href="https://web.archive.org/web/20190119124649/https://blogs.msdn.microsoft.com/oldnewthing/20060925-02/?p=29603" rel="nofollow noreferrer">Waiting until the dialog box is displayed before doing something</a></p>
<pre><code>Short story:
INT_PTR CALLBACK
DlgProc(HWND hwnd, UINT uiMsg, WPAR... | <p>Another approach I've used a number of times with great success is to use a timer. Set it for 10m0s. It'll only fire after the dialog is shown. </p>
| 33,848 |
<p>Say I have an interface like this:</p>
<pre><code>public interface ISomeInterface
{
...
}
</code></pre>
<p>I also have a couple of classes implementing this interface;</p>
<pre><code>public class SomeClass : ISomeInterface
{
...
}
</code></pre>
<p>Now I have a WPF ListBox listing items of ISomeInterface, using a... | <p>In order to bind to explicit implemented interface members, all you need to do is to use the parentheses. For example:</p>
<p>implicit:</p>
<pre><code>{Binding Path=MyValue}
</code></pre>
<p>explicit:</p>
<pre><code>{Binding Path=(mynamespacealias:IMyInterface.MyValue)}
</code></pre>
| <p>You have another option. Set a Key on your DataTemplate and reference that key in the ItemTemplate. Like this:</p>
<pre><code><DataTemplate DataType="{x:Type documents:ISpecificOutcome}"
x:Key="SpecificOutcomesTemplate">
<Label Content="{Binding Name}"
ToolTip="{Binding Descrip... | 42,518 |
<p>I have been given a .Hive file from a registry which i have to parse and use the contents as part of a html report(from this i assume i have to convert to text somehow). The whole thing must be done within the program so i cant just convert the hive file and then run it through my program. I currently have no idea h... | <p>Without seeing the input, it is hard to tell what the best approach is. You are probably going to need to use the RegExp class to parse out your keys and values. If you can get clean enough paths to the values, you might be able to get away with string.Split() to split the path into arrays of keys and walk the reg... | <p>Thanks for your answer, ive managed to figure it out now. It wasnt the parsing it was importing the data i was having problems with. I created a hive.out file and then imported it in the normal text way.</p>
| 40,494 |
<p>I've worked with a few of these in the past, but I'm looking for a good, reliable and extensible data class for ASP.NET 3.5, that I can adopt and extend for future projects.</p>
<p>I'm not looking for LinQ, and I don't want anything which won't be a source-code level solution.</p>
<p>Ideally, it also won't be heav... | <p>You might want to look at Mircrosoft's Enterprise library's <a href="http://msdn.microsoft.com/en-us/library/cc309504.aspx" rel="nofollow noreferrer">Data Access Block</a> I have found it useful and it is a building block of <a href="http://nettiers.com/" rel="nofollow noreferrer">.netTiers</a>.
<a href="http://www... | <p>I wish there were something similar to the DataSet/DataTable/DataRow/etc ADO data classes, but open for extension. While working with them is sometimes very hard, they make many expensive and complex tasks easy. Its a tradeoff, definitely. </p>
| 47,711 |
<p>I have a C++ header that contains #define statements, Enums and Structures. I have tried using the h2py.py script that is included with Python to no avail (except giving me the #defines converted). Any help would be greatly appreciated.</p>
| <p>I don't know h2py, but you may want to look at 'ctypes' and 'ctypeslib'. ctypes is included with python 2.5+, and is targeted at creating binary compatibility with c-structs.</p>
<p>If you add ctypeslib, you get a sub-tool called codegen, which has a 'h2xml.py' script, and a 'xml2py.py', the combination of which w... | <p>Where did you get the idea that h2py had anything to do with structs or enums?</p>
<p>From the source</p>
<pre><code># Read #define's and translate to Python code.
# Handle #include statements.
# Handle #define macros with one argument.
</code></pre>
<p>The words 'enum' and 'struct' never appear in the module.</p... | 48,938 |
<p>The monthRegex regular expression always returns true, even if dateInput is something like "December 1, 2008" by my thoughts it should match a regular expression by whichever key I pass into it. But that isn't what happens, it just returns true, and detects "JAN" as the month.</p>
<pre><code> function dateForma... | <p>Remove the "monthRegex.compile();" line and it works.</p>
<p>This is because monthRegex.compile(); complies "" as a regex and therefore everything matches it.</p>
| <p>You don't need to use regular expressions for plain old string matching. You especially don't need to compile and throw away 12 regular expressions every time the function is called.</p>
<p>A saner version:</p>
<pre><code>// Get integer number of named month. 1-indexed for January;
// return 0 if unreadable name.
... | 38,859 |
<p>I have some directories that are bundled with my installer and I need to access them from within a custom action. I have done some research and seen that the SourceDir can be used to obtain the currently executing dir location. However I cannot find any examples of how to obtain this property? Or another way to o... | <p>I'm assuming you're using vbscript for the custom action. If so, properties can be accessed via the Session object. See below:</p>
<pre><code>strSourceDir = Session.Property("SourceDir")
</code></pre>
<p>Be aware that the SourceDir property is only available at <a href="http://msdn.microsoft.com/en-us/library/aa37... | <p>Are you using InstallShield? Here's an example for an InstallScript CA:</p>
<pre><code>MsiGetProperty(hMSI, "CustomActionData", strDirectory, numBuffer);
</code></pre>
<p>... where you also used a Set Property "Type 51" custom action to setup CustomActionData for your function to the value SOURCEDIR.</p>
| 35,508 |
<p>I am creating a new table inside mysql and I am trying to add a foreign key constraint to one of the fields.</p>
<pre>
CREATE TABLE `onlineorder` (
`receiptid` varchar(10) NOT NULL default '',
`delivereddate` date default NULL,
`cid` int(10) NOT NULL,
`card#` int(10) default NULL,
`expire` date default NU... | <p>You need to use the InnoDB engine to have foreign keys.</p>
<p>Ref: <a href="http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html</a></p>
| <p>There are two type of constraints when you managing your tables with phpmyadmin:</p>
<ul>
<li>internal: when you set constraints with phpmyadmin designer for example the constraints stored as internal,that will not be included in export.</li>
<li>innoDB: these constraints included in export check out linked video a... | 37,944 |
<p>In either a Windows or Mac OS X terminal if you type...</p>
<pre><code>nslookup -type=SRV _xmpp-server._tcp.gmail.com
</code></pre>
<p>... (for example) you will receive a bunch of SRV records relating to different google chat servers..</p>
<p>Does anyone have any experience in this area and possibly know how to ... | <p>I believe you need to use the DNSServiceDiscovery framework. I don't have the iPhone SDK, but a Google search suggests that it is available on the iPhone.</p>
<p>See the Apple Developer Site for <a href="https://developer.apple.com/library/mac/documentation/networking/conceptual/dns_discovery_api/Introduction.html... | <p>Hmm, looks like I can't run <code>system()</code> on the Simulator or the device. I can run <code>NSTask</code> on the Simulator, but not the iPhone, and <code>NSTask</code> is not part of the <code>Foundation</code> framework.</p>
<p>The <a href="http://www.isc.org/index.pl?/sw/bind/index.php" rel="nofollow norefe... | 32,239 |
<p>I am testing an application that checks if a file exists across a network. In my testing, I am purposefully pulling the network plug so the file will not be found. The problem is this causes my app to go unresponsive for at least 15 seconds. I have used both the FileExists() and GetAttr() functions in VB6. Does anyo... | <p>Unfortunately, VB doesn't make this easy, but luckily the Win32 API does, and it's quite simple to call Win32 functions from within VB.</p>
<p>For the LAN/WAN, you can use a combination of the following Win32 API calls to tell you whether the remote connection exists without having to deal with a network time-out:<... | <p>I agree with Will. Something like this is simple to handle with Script.FileSystemObject:</p>
<pre><code>Dim objFSO As New FileSystemObject
If objFSO.FileExists("C:\path\to\your_file.txt") Then
' Do some stuff with the file
Else
' File isn't here...be nice to the user.
EndIf
</code></pre>
| 24,786 |
<p>Host: GoDaddy Shared Hosting</p>
<p>Trust Level: Medium</p>
<p>The following happens after I submit a valid user/pass. The database has read/write permissions and when I remove the login requirement on an admin page that updates the database work as expected.</p>
<p>Has anyone else had this issue or know what the... | <p><a href="http://www.codeproject.com/Questions/586223/SecurityplusExceptionpluscomingplusinplusaplusrunn">http://www.codeproject.com/Questions/586223/SecurityplusExceptionpluscomingplusinplusaplusrunn</a></p>
<p>Solution 4
System.Security.SecurityException: Request for the permission of type 'System.Net.SocketPermis... | <p>Have you tried playing around with the permissions of the files and folders in your site? I've had an error on godaddy where a new file couldn't be written because the directory had no write permission. You could try setting your whole root to read/write to see if that fixes your problem. To get to your permissio... | 39,152 |
<p>At the moment, I am thinking about print fans that cool the plastic when printing. I am not asking about the design of the fanducts, which might be a whole book on its own. I would like to know how to find out the best application of print cooling for a given PLA filament, - that is fan speeds and setup in a slicer ... | <p>Everybody's combination of fan hardware and print settings is different. Unless someone else has the exact same printer and slicer profiles as you, there's no way to really say anything like "use X% for PLA" or whatever. For practical purposes, you just empirically figure it out with test prints based on a few simpl... | <p>I use PLA and both my fans stopped working. I am not techy and couldn't figure out how to fix them so I set up a house fan that blew directly at the motor keeping it cool and it works as good if not better than the fans that came with the 3d printer. You cannot let your motors over heat because your filament will ge... | 341 |
<p>So C# now allows you to use <code>default(Foo)</code> to get a recognized "not filled in yet"/empty instance of a class -- I'm not sure if it is exactly the same as <code>new Foo()</code> or not. Many library classes also implement a <code>Foo.Empty</code> property, which returns a similar instance. And of course ... | <p><code>default(Foo)</code> will return null when <code>Foo</code> is a class type, zero where <code>Foo</code> is a value type (such as int), and an instance of <code>Foo</code> with all fields initialized to <em>their</em> respective <code>default()</code> values where <code>Foo</code> is a struct. It was added to t... | <p><code>default(Foo)</code> works for both value types and reference types. <code>New Foo(), null</code> and <code>Foo.Empty()</code> do not. This makes it a good choice for use with generic types, for example, when you may not know which you're dealing with. But in most reference-type cases, <code>null</code> is p... | 22,906 |
<p>Is there any way to get the custom attributes of a specific object I am receiving in a method?</p>
<p>I do not want nor can to iterate over Type.GetMembers() and search for my member. I have the object, which is also a member, that has the attribute.</p>
<p>How do I get the attribute?</p>
<pre><code>class Custom
... | <p>No. Objects don't have attributes - members do. By the time you're in the "Do" method, there's no record of the fact that you called Do(MyObject) vs Do(MyOtherFieldWhichHasTheSameValue).</p>
<p>If you need to look up the attributes on a member, you'll basically have to pass in the relevant MemberInfo, not what it h... | <p>You cannot do this without at least 1 Reflection call. After that, save the value somehow.</p>
<p>Example:</p>
<pre><code>abstract MyBase
{
public string Name;
protected MyBase()
{
//look up value of Name attribute and assign to Name
}
}
[Name("Foo")]
class MyClass : MyBase
{
}
</code></pre>
| 25,044 |
<p>Has anyone written a version of .Net's generic Queue that implements INotifyCollectionChanged, or is there one hidden deep in the .Net framework somewhere already?</p>
| <p>A quick search didn't show any results. But the interface is simple and it would be almost trivial to extend the Queue class and add support for the interface. Just override all methods thusly:</p>
<pre><code>// this isn't the best code ever; refactor as desired
protected void OnCollectionChanged( NotifyCollectio... | <p>I used the same approach as Chris Wenham. Under load, performance suffers because new NotifyCollectionChangedEventArgs need to be allocated for each Enqueue/Dequeue.</p>
<p>Regardless, in the Enqueue, send args with NotifyCollectionChangedAction.Add, the item added, and Count-1 as the index. In the Dequeue, send ... | 35,563 |
<p>Caveat: I'm relatively new to coding as well as <a href="http://macromates.com/" rel="nofollow noreferrer">TextMate</a>, so apologies if there is an obvious answer I'm missing here.</p>
<p>I do a lot of HTML/CSS markup, there are certain patterns that I use a lot, for example, forms, navigation menus etc. What I wo... | <p>You can do this very easily in TextMate using <a href="http://manual.macromates.com/en/snippets" rel="nofollow noreferrer">Snippets</a>. Just add a new snippet in the bundle editor, and set up how you want to trigger it. You can set a key shortcut, or have it pop up when you hit <code>Tab</code> after a certain word... | <p>As mentioned prior snippets are what you are looking for.</p>
<p>For reference look here:
<a href="http://manual.macromates.com/en/snippets" rel="nofollow noreferrer">http://manual.macromates.com/en/snippets</a><br>
<a href="http://screenflicker.com/mike/code/div-snippets/" rel="nofollow noreferrer">http://screenf... | 6,557 |
<p>I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something. </p>
<p>For what do you use regular expressions?</p>
<p>P.S. sorry for my bad engli... | <p>Consider an example in Ruby:</p>
<pre><code>puts "Matched!" unless /\d{3}-\d{4}/.match("555-1234").nil?
puts "Didn't match!" if /\d{3}-\d{4}/.match("Not phone number").nil?
</code></pre>
<p>The "/\d{3}-\d{4}/" is the regular expression, and as you can see it is a VERY concise way of finding a match in a string.</p... | <blockquote>
<p>A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as <code>*.txt</code> to find all text files in a file manager. The regex equ... | 2,695 |
<p>I know most people think that as a <em>bad practice</em> but when you are trying to make your class public interface only work with references, keeping pointers inside and only when necessary, I think there is no way to return something telling that the value you are looking doesn't exist in the container.</p>
<pre... | <p>The STL deals with this situation by using iterators. For example, the std::map class has a similar function:</p>
<pre><code>iterator find( const key_type& key );
</code></pre>
<p>If the key isn't found, it returns 'end()'. You may want to use this iterator approach, or to use some sort of wrapper for your r... | <p>Interesting question. It's a problem in C++ to exclusively use references I guess - in Java the references are more flexible and can be null. I can't remember if it's legal C++ to force a null reference:</p>
<pre><code>MyType *pObj = nullptr;
return *pObj
</code></pre>
<p>But I consider this dangerous. Again in Ja... | 17,343 |
<p>I have a file which is an XML representation of some data that is taken from a Web service and cached locally within a Web Application. The idea being is that this data is <em>very</em> static, but just <em>might</em> change. So I have set it up to cache to a file, and stuck a monitor against it to check if it has b... | <p>Here is the code that I use to make sure a file is not locked by another process. It's not 100% foolproof, but it gets the job done most of the time:</p>
<pre><code> /// <summary>
/// Blocks until the file is not locked any more.
/// </summary>
/// <param name="fullPath"></param... | <p>How about using <code>AutoResetEvent</code> to communicate between threads? I created a console app which creates roughly 8 GB file in <code>createfile</code> method and then copy that file in <code>main</code> method</p>
<pre><code> static AutoResetEvent waitHandle = new AutoResetEvent(false);
static string fi... | 6,258 |
<p>i need to compress my css as part of my ant build. i noticed that csstidy does this, but it would not be easy to include this in my ant build because i would need to use a different binary on different platforms.</p>
<p>so, is there a java css compressor that people use?</p>
| <p>Check out the <a href="http://developer.yahoo.com/yui/compressor/" rel="noreferrer">Yahoo YUI compressor</a>.</p>
<p>It compresses CSS as well as Javascript, and it's written in Java.</p>
<p>Edit: You should be using some sort of HTTP compression <i>as well</i>, like mod_deflate or mod_gzip.</p>
| <p>I recently released <a href="http://www.andy-roberts.net/coding/csscompressor" rel="nofollow noreferrer">CSS Compressor</a>. It's a code fork of YUI Compressor, but adds more compression enhancements that make it more similar to csstidy, particularly with regards to grouping selectors that share the same rules. Obvi... | 22,175 |
<p>I need to sort tuples according to the second element of each tuple but apparently usort/1 only works with the first element. So I have to swap the elements, usort them and swap back.Is there an easier way?Also is there a way to sort in descending order (I know sorting and reversing can be done, but just want to kno... | <p>Have you tried <a href="http://www.erlang.org/doc/man/lists.html#keysort-2" rel="nofollow noreferrer">keysort/2</a> function (or its counterpart <a href="http://www.erlang.org/doc/man/lists.html#ukeysort-2" rel="nofollow noreferrer">ukeysort/2</a>)?</p>
<pre><code>> lists:reverse(lists:keysort(2, [{a,2}, {b,1}, ... | <p>It shouldn't be too hard to write your own sort function (adapted from a common example):</p>
<pre><code>qsort([]) -> [];
qsort([Pivot|Tail]) ->
{PivotFirst, PivotSecond} = Pivot,
qsort([{FirstElement, SecondElement} || {FirstElement,SecondElement} <- Tail, SecondElement < PivotSecond])
... | 21,906 |
<p>Is there a way I can control columns from code. </p>
<p>I had a drop drop box with select : Daily and weekend and the gridview column with Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,sunday.
If the user selects Daily i want to show columns only from Monday to Friday.</p>
<p>It is possible to control fr... | <p>Use <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.columns.aspx" rel="noreferrer">Columns</a> property:</p>
<pre><code>GridView1.Columns[5].Visible = false
GridView1.Columns[6].Visible = false
</code></pre>
| <p>It might be a hassle for you to use the index of the column -- conveniently, the Columns property also accepts the name of the column, which you can set on creation using the Name property of the column. This helps make the code self-documenting.</p>
| 24,368 |
<p>I am using mysql++ in order to connect to a MySQL database to perform a bunch of data queries. Due to the fact that the tables I am reading from are constantly being written to, and that I need a consistent view of the data, I lock the tables first. However, MySQL has no concept of 'NOWAIT' in its lock query, thus i... | <p>You can implement a "cancel-like" behavior this way:</p>
<p>You execute the query on a separate thread, that keeps running whether or not the timeout occurs. The timeout occurs on the main thread, and sets a variable to "1" marking that it occurred. Then you do whatever you want to do on your main thread. </p>
<p>... | <p>You could execute the blocking query in a different thread and never being bothered with the timeout. When some data arrives you notify the thread that needs to know about the status of the transaction.</p>
| 10,738 |
<p>The overall goal is to create a print of the liberty bell. No clapper is needed. The support beam is not needed. I am just looking to mimic the outside shape of the bell. After an application of Google-fu I found this image. It has been cleaned up and cropped a bit.</p>
<p><a href="https://i.stack.imgur.com/HT... | <p>As you are already familiar with OpenSCAD, consider to use the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/3D_to_2D_Projection" rel="nofollow noreferrer">projection() function</a> to accomplish your goal.</p>
<p>If you allow for an interpretation that one can cast a shadow of the part on a surface b... | <p>You could have done that with OpenSCAD, there are instructions for extruding. </p>
<p>Personally, I'd just do a 1 altitude copy with
<a href="http://www.thingiverse.com/thing:1981938" rel="nofollow noreferrer">Image 2 STL 2 Heightmap Mesh Converter Generator</a>, then rotate in OpenSCAD. It's called <code>rotate_e... | 566 |
<p>I would like to modify an MSI installer (created through <a href="http://en.wikipedia.org/wiki/WiX" rel="noreferrer">WiX</a>) to delete an entire directory on uninstall.</p>
<p>I understand the <code>RemoveFile</code> and <code>RemoveFolder</code> options in WiX, but these are not robust enough to recursively delet... | <p><strong>EDIT</strong>: Perhaps look at the answer <a href="https://stackoverflow.com/a/17608049/286021">currently immediately below</a>.</p>
<hr>
<p>This topic has been a headache for long time. I finally figured it out.
There are some solutions online, but none of them really works. And of course there is no docu... | <p>I used Custom Action separately coded in C++ DLL and used the DLL to call appropriate function on Uninstalling using this syntax :</p>
<pre class="lang-xml prettyprint-override"><code><CustomAction Id="Uninstall" BinaryKey="Dll_Name"
DllEntry="Function_Name" Execute="deferred" />
</code></pre>
... | 41,517 |
<p>After having implemented the strategy pattern, I wanted to make an array of the interface-type, to which I can then add any concrete type. </p>
<p>For those who don't know the strategy pattern:
<a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Strategy_pa... | <p>Make the array store pointers to the interface type:</p>
<pre><code>typedef std::vector<Interface *> Array;
Array myArray;
myArray.push_back(new A());
</code></pre>
<p>Additionally, you can use ptr_vector which manages memory for you:</p>
<pre><code>typedef boost::ptr_vector<Interface> Array;
// the r... | <p>errr, for example...
std::vector< boost::shared_ptr< AbstractStrategy > > </p>
<p></p>
| 20,687 |
<p>I need to take a web page and extract the address information from the page. Some are easier than others. I'm looking for a firefox plugin, windows app, or VB.NET code that will help me get this done.</p>
<p>Ideally I would like to have a web page on our admin (ASP.NET/VB.NET) where you enter a URL and it scraps th... | <p>I've never done this, but here are a couple things you could try. First, you could implement a custom <a href="http://java.sun.com/javase/6/docs/api/java/awt/Stroke.html" rel="nofollow noreferrer">Stroke</a> that creates skinny trapezoids. The width of the end caps would be a function of the pressure at the end poin... | <p>PostScript RIPs often convert circles to curves and curves to a series of straight line segments. The number of segments depends on the flatness setting which defaults to one suitable for the raster display resolution.</p>
<p>A thick line or thick line segments can be converted to a skinny filled polygon.</p>
| 6,408 |
<p>I'm trying to make a PHP script, I have the script finished but it takes like 10 minutes to finish the process it is designed to do. This is not a problem, however I presume I have to keep the page loaded all this time which is annoying. Can I have it so that I start the process and then come back 10mins later and j... | <p>Well, you can use "<a href="http://de2.php.net/manual/en/function.ignore-user-abort.php" rel="noreferrer">ignore_user_abort</a>(true)"</p>
<p>So the script will continue to work (keep an eye on script duration, perhaps add "<a href="http://de2.php.net/manual/en/function.set-time-limit.php" rel="noreferrer">set_time... | <p>Just call StartBuffer() before any output, and EndBuffer() when you want client to close connection. The code after calling EndBuffer() will be executed on server without client connection.</p>
<pre>
private function StartBuffer(){
@ini_set('zlib.output_compression',0);
@ini_set('implicit_flush... | 33,211 |
<p>How do I go about programmatically updating the FILEVERSION string in an MFC app? I have a build process that I use to generate a header file which contains the SVN rev for a given release. I'm using SvnRev from <a href="http://www.compuphase.com/svnrev.htm" rel="nofollow noreferrer">http://www.compuphase.com/svnrev... | <p>An <code>.rc</code> file can <code>#include</code> header files just like <code>.c</code> files can. I have an auto-generated <code>version.h</code> file, which defines things like:</p>
<pre><code>#define MY_PRODUCT_VERSION "0.47"
#define MY_PRODUCT_VERSION_NUM 0,47,0,0
</code></pre>
<p>Then I just have my <co... | <p>Changing <code>VS_VERSION_INFO</code> will reflect when you right click on the file in Explorer and see properties only.</p>
<p>If you want to show the current SVN revision number in the Caption bar, i would suggest:</p>
<ul>
<li>Have a script get the version number and generate version.h file just with </li>
</ul... | 13,421 |
<p>I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal." </p>
<p>I checked the line and the lines around it and everything seems fine-parentheses, ... | <p>Most browsers seem to have problems with code like this:</p>
<pre><code>var foo = "</script>";
</code></pre>
<p>In Firefox, Opera and IE8 this results in an unterminated string literal error. Can be pretty nasty when serializing html code which includes scripts.</p>
| <pre><code>str = str_replace(array("\r\n","\n\r","\r", "\n"), '<br />', stripslashes($str));
</code></pre>
<p>This should work.</p>
| 28,162 |
<p>Our CruiseControl system checks out from starteam. I've noticed that it is sometimes not checking out new versions of files, only added files.</p>
<p>Does anyone know why this is?</p>
| <p>I cannot say <em>why</em> this happens, but for what it's worth, we avoid the problem entirely by having StarTeam delete all of the local files before checking-out. We get <em>all</em> of the files that way. We use the following StarTeam arguments in our NAnt script:</p>
<pre><code>delete-local -q -p &quot;${st... | <p>This is a CI build, so I want to see the diffs on each build, cleaning out the build gives me a fresh build each time, and I don't know what is new.</p>
<p>So its a known issue?</p>
| 12,081 |
<p>I created a simple class with a DependencyProperty. When setting the value, I observe that ValidateValueCallback is called before CoerceValueCallback.</p>
<p>On <a href="http://wpftutorial.net/How+does+a+DependencyProperty+resolve+its+value.htm" rel="nofollow noreferrer">wpftutorial</a> and in other books, it is st... | <p>One difference that I know of, is that named pipes under Linux are actual entries in the filesystem (you'll see it in a directory listing, they have a special type), whereas on Windows they are stored in some magical repository somewhere (they are all accessed via the path "\\.\pipe\".</p>
<p>Secondly, in Linux you... | <p>See also the previous thread:</p>
<p><a href="https://stackoverflow.com/questions/175579/what-are-named-pipes#176140">What are named pipes?</a></p>
<p>Which contains my take and several other peoples'</p>
| 23,336 |
<p>We are currently thinking of building a cache-system to hold data pulled out of an SQL database and make it available to a couple of other applications (website, webservice, etc). We imagine the cache to be running as a windows service and basically consist of a smart dictionary which holds the cache entries. My que... | <p>32bit or 64bit? 32bit is 2gb (for a process), 64 bit is <a href="http://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx#physical_memory_limits_windows_server_2003" rel="noreferrer">1TB (enterprise edition 2003 server)</a>.</p>
<p><a href="http://blogs.msdn.com/joshwil/archive/2005/08/10/450202.aspx" rel="nore... | <p>As with any other Windows program, you're limited by address space. That is: on 32-bit, you can have 2GB of address space. On x64, you can have 8TB.</p>
<p>If you don't have 8TB of physical memory, it will start to page.</p>
| 24,435 |
<p>What causes Firefox to follow a POST request with a GET request when submitting a form via the POST method? The GET method is sent to the same url as the POST method but without the request parameters.</p>
<p>If you change the form method to GET, it will result in two identical GET requests.</p>
| <p>This is a bug in Firefox 3. This happens when the response to the POST contains an image tag with an empty source attribute. eg <code><img src=""/></code></p>
| <p>Probably there is some javascript involved. The form is submitted as a result of an onclick event in an anchor with: href="..." onclick="..form.submit()"</p>
| 12,124 |
<p>I have a table with playerhandles, like this:</p>
<pre><code>1 - [N] Laka
2 - [N] James
3 - nor | Brian
4 - nor | John
5 - Player 2
6 - Spectator
7 - [N] Joe
</code></pre>
<p>From there I wanna select all players where the first n-chars match, but I don't know the pattern, only that it's the first n-chars. In the... | <p>You could add an exists clause.</p>
<pre><code>select name from players p1 where exists (
select 1 from players p2 where
p2.name like CONCAT( SUBSTRING(p1.name, 1, 3), '%')
and p1.name <> p2.name )
</code></pre>
<p>This will give you:<BR>
1 - [N] Laka<BR>
2 - [N] James<BR>
3 - nor | Brian<BR>
4 -... | <p>You could add an exists clause.</p>
<pre><code>select name from players p1 where exists (
select 1 from players p2 where
p2.name like CONCAT( SUBSTRING(p1.name, 1, 3), '%')
and p1.name <> p2.name )
</code></pre>
<p>This will give you:<BR>
1 - [N] Laka<BR>
2 - [N] James<BR>
3 - nor | Brian<BR>
4 -... | 44,725 |
<p>How do you do the following operations in C++?</p>
<ol>
<li>Opening Files</li>
<li>Closing Files</li>
<li>Reading Files</li>
<li>Writing Files</li>
</ol>
| <h2>Reading</h2>
<pre><code>#include <fstream>
int main()
{
std::ifstream inputFile("MyFileName") // Opens a File.
int x;
inputFile >> x; // Reads an integer from a file.
std::string word;
inputFile >> word; // Reads a space separated word from a file.
double y;
in... | <p>With C++ you've got lots of choices for how to interact with files, especially if you are using one of the many frameworks around, like Qt, wxWidgets, or GLib. To summarize, the standard C++ library uses a streams based model of file access, via std::ifstream and std::ofstream. This is similar to what you see when u... | 34,684 |
<p>How can I display something over all other application. I want to to display something over all form of my program and all other programs open on my desktop (not mine).</p>
<p><strong>*Top Most doesn't work I have tested and my browser can go OVER my application :S</strong></p>
<p>Here is an image of when I use To... | <p>You can use the form instance and set the property <strong>TopMost</strong> to True. </p>
<p><hr/>
If you want to be over all Windows, there are another way with <strong>Win32 Api</strong> calls.</p>
<p>Here is what you could do:</p>
<p>In your form class add :</p>
<pre><code>[System.Runtime.InteropServices.DllI... | <p>In my team we had a internal tool that keeps on running after Windows startup. It is a WinForm with TopMost set to ture. On Vista, sometimes we had the same problem. At very random times, the form will lost TopMost property and other non-topmost window can appear above it.
I had a log of researches but found no answ... | 42,015 |
<p>I have some pages on my site that are plain HTML pages, but I want to add some ASP .NET type functionality to these pages. My concern is that if I simple rename the .html page to .aspx that I will break links, and lose SEO, and so on.</p>
<p>I would think there is a "best practice" for how to handle this situation.... | <p>Create your new pages on aspx, and just serve 301 permanent redirects from the HTML pages.</p>
<p>Search spiders are smart enough to realize the content has moved and will not penalize you.</p>
<p>Both Google and Yahoo also say that they parse a meta-refresh with no delay as a 301 redirect, so just do something li... | <p>If the new ASP.NET functionalities is minor, I would recommend to include IFrames inside your HTML which links to the new created ASP.NET pages containing your minor dynamic changes.</p>
| 34,436 |
<p>I'm trying to add the lucene sandbox contribution called <a href="http://lucene.apache.org/java/docs/lucene-sandbox/index.html#Term%20Highlighter" rel="nofollow noreferrer">term-highlighter</a> to my pom.xml.
I'm not really that familiar with Maven, but the code has a <a href="http://svn.apache.org/repos/asf/lucene/... | <p>You have to add the version number, but you only have to do it once in a project structure. That is, if the version number is defined in a parent pom, you don't have to give the version number again. (But you don't even have to provide the dependency in this case since the dependency will be inherited anyways.)</p>
| <p>You have it right, but you probably want to add the version as well:</p>
<p><a href="http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html" rel="nofollow noreferrer">From The Maven 5 minute tutorial</a></p>
<pre><code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w... | 20,394 |
<p>How is it possible that .NET is finding the wrong 'MyType' in this scenario?</p>
<p>I have a type A.B.C.D.MyType in a project that I'm working on, and I'm referencing a DLL that has a type A.B.MyType? I do not have any 'using A.B;' statements anywhere in my code, and I do have 'using A.B.C.D;'. When I compile, the ... | <p>Are you working in a namespace that is under A.B namespace? (for example A.B.X) if so the C# namespace resolutions (<a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf" rel="noreferrer">ECMA-334 C# Language Specification : 10.8 10.8 Namespace and type names</a>) says:</p>
<blockquote>... | <p>Just a guess: in your project properties, is the "default namespace" set to A.B ?</p>
| 32,856 |
<p>I have a table that contains tasks and I want to give these an explicit ordering based on the priority of the task. The only way I can think to do this is via an <strong>unique</strong> int column that indexes where the task is in term of the priority (i.e. 1 is top 1000 is low).</p>
<p>The problem is that say I wa... | <p>Use a real number value as the priority. You can always slide in a value between two existing values with something like <code>newPri = task1Pri + (task2Pri - task1Pri)/2</code> where Task1 has the lower priority numeric value (which is probably the higher piority).</p>
<p>Corin points out that min and max priorit... | <p>I would assign only a small number of values (1..10) and then ORDER BY Priority DESC, DateCreated ASC.
If you need to have different priorities for each task you need to UPDATE WHERE Priority > xxx like you said.</p>
| 13,761 |
<p>I'm writing a scheduler or sorts. It's basically a table with a list of exes (like "C:\a.exe") and a console app that looks at the records in the table every minute or so and runs the tasks that haven't been run yet.</p>
<p>I run the tasks like this:</p>
<pre><code>System.Diagnostics.Process p = new System.Diagno... | <p>You can catch the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.win32exception.aspx" rel="noreferrer">Win32Exception</a> to check if <a href="http://msdn.microsoft.com/en-us/library/e8zac0ca.aspx" rel="noreferrer">Process.Start()</a> failed due to the file not existing or execute access is d... | <p>To expand on what @jop said. You will also need to wait for the process to close. Thus:</p>
<pre><code> p.Start();
p.WaitForExit();
int returnCode = p.ExitCode;
</code></pre>
<p>Non-zero codes are typically errors. Some application use negative ones are errors, and positive ones as status co... | 18,813 |
<p>How do you decide between passing arguments to a method versus simply declaring them as object instance variables that are visible to all of the object's methods?</p>
<p>I prefer keeping instance variables in a list at the end of the Class, but this list gets longer as my program grows. I figure if a variable is pas... | <p>Since you're referring to instance variables, I'm assuming that you're working in an object-oriented language. To some degree, when to use instance variables, how to define their scope, and when to use local variables is subjective, but there are a couple of rules of thumb you can follow whenever creating your class... | <p>Of course it is easy to keep one big list of public variables in the class. But even intuitively, you can tell that this is not the way to go.</p>
<p>Define each variable right before you are going to use it. If a variable supports the function of a specific method, use it only in the scope of the method.</p>
<p>A... | 45,046 |
<p>Is it possible to get the x,y coordinates of a Flex app within an HTML page? I know you can use ExternalInterface.ObjecID to get the "id attribute of the object tag in Internet Explorer, or the name attribute of the embed tag in Netscape" but I can't seem to get past that step. It seems like it should be possible ... | <p>I think the easiest thing to do is to include some kind of JavaScript library on the HTML page, say jQuery, and use it's functions for determining the position and size of DOM nodes. I would do it more or less like this:</p>
<pre><code>var jsCode : String = "function( id ) { return $('#' + id).offset(); }";
var of... | <p>If you are trying just to measure where it's at within a page as the external user the only thing that pops into my mind is a Firefox extension called MeasureIt I've used it occasionally for various measuring on web pages.</p>
<p>Are you trying to do this programmatically from within the embedded page itself and if... | 11,476 |
<p>When we compile a dll using __stdcall inside visual studio 2008 the compiled function names inside the dll are.</p>
<p>FunctionName</p>
<p>Though when we compile the same dll using GCC using wx-dev-cpp GCC appends the number of paramers the function has, so the name of the function using Dependency walker looks li... | <p>__stdcall decorates the function name by adding an underscore to the start, and the number of bytes of parameters to the end (separated by @).</p>
<p>So, a function:</p>
<pre><code>void __stdcall Foo(int a, int b);
</code></pre>
<p>...would become _Foo@8.</p>
<p>If you list the function name (undecorated) in the... | <p>You can also use <code>-Wl,--add-stdcall-alias</code> to your linker options in GCC. This will ensure that both function names (decorated and undecorated) are present and can be used as alias.</p>
| 13,297 |
<p>I'm having an issue with a USB project using <code>LIB-USB</code>. The USB device is based on a PIC18F4550 and has a single control endpoint. The PC front-end is written in MSVC and uses Lib-Usb 1.12.</p>
<p>On the PC end, the program begins by setting the configuration, claiming the interface, then sending (and re... | <p><strong>It Now Works!!</strong></p>
<p>Of course, I now feel "smart like a bag of hammers" Had I read section 18 thoroughly I would have noticed the line about adding a 220nF capacitor between Vusb and ground. Added a 470nF cap between pin18 and ground and that was all it took .... reliable transfers now. </p>
<... | <p>I do not have an analyzer ("yet", at least) but I did install DebugView to see what the driver is doing, with the following output trace. The first transfer shown (a vendor-specific one) is successful while the second one dies. A return code of "-5" which means "I/O error" (not particularly useful) is returned fro... | 30,120 |
<p>Generally the database server is the biggest, most expensive box we have to buy as scaling vertically is the only option. Are there any databases that scale well horizontally (i.e. across multiple commodity machines) and what are the limitations in this approach?</p>
| <p><strong>Oracle RAC -- Real Application Cluster</strong></p>
<p>This works nicely, you just add boxes to your cluster. You can fail over from one box to the other. It's not replication, all the boxes are part of the same logical unit.</p>
<p>It's pretty spendy, of course.</p>
| <p>Oracle Real Application Clusters. If you want the best then take a look at it.</p>
| 6,421 |
<p>This issue is driving me mad.</p>
<p>I have several tables defined, and CRUD stored procs for those tables. I have wired up the stored procs to the tables in Visual Studio using the dbml mapper. </p>
<p>All work fine, except for one table. The insert stored proc is not being hit for my history table.</p>
<p>The i... | <p>Ok, this is unbelievable but... the app already had a page called history.aspx. VB defaulted to the history class for that page, rather than the db.History class used by LinQ.</p>
<p>Once I renamed history.aspx, everything worked! :)</p>
| <p>Did you manually wired up your sproc to your table in the .dbml file? If you select a table a in the property grid you may see an Insert behavior. If it says, Use Runtime, then you SPROC will not be called and you have change that setting from Use Runtime, to manually configure it to call you SPROC on Insert.</p>
| 47,951 |
<p>In a stored procedure, when is #Temptable created in SQL Server 2005? When creating the query execution plan or when executing the stored procedure?</p>
<pre><code>if (@x = 1)
begin
select 1 as Text into #Temptable
end
else
begin
select 2 as Text into #Temptable
end
</code></pre>
| <p>It's created when it's executed and dropped when the session ends.</p>
| <p>Whilst it may be automatically dropped at the end of a session, it is good practice to drop the table yourself when you're done with it.</p>
| 6,553 |
<p>Should I use textbox.text.Trim() function every time when I insert any data from web page to database.</p>
<p>I just have a habit of using the trim function? Does it effect the performance any way? Should I use everytime or just when needed?</p>
| <p>I've seen many problems with spaces which had been added at the end to a text field by accident (for instance logins which mysteriously didn't work). So it's not a bad idea at all to trim() most textfield input as a standard practice. </p>
<p>I think the performance hit of a trim() is absolutely neglible, except ma... | <p>Use trim and make sure you create a function to strip out any potential sql poisoning attacks.</p>
<p>php provides you</p>
<pre><code>mysql_real_escape_string();
</code></pre>
| 38,662 |
<p>As an example take the following code:</p>
<pre><code>public enum ExampleEnum { FooBar, BarFoo }
public class ExampleClass : INotifyPropertyChanged
{
private ExampleEnum example;
public ExampleEnum ExampleProperty
{ get { return example; } { /* set and notify */; } }
}
</code></pre>
<p>I want a to d... | <p>You can create a custom markup extension.</p>
<p>Example of usage:</p>
<pre><code>enum Status
{
[Description("Available.")]
Available,
[Description("Not here right now.")]
Away,
[Description("I don't have time right now.")]
Busy
}
</code></pre>
<p>At the top of y... | <p>Try using </p>
<pre><code><ComboBox ItemsSource="{Binding Source={StaticResource ExampleEnumValues}}"
SelectedValue="{Binding Path=ExampleProperty}" />
</code></pre>
| 8,317 |
<p>Given a large set of data, I was able to create a 3D graph in Microsoft Excel. How can I create a STL file similar to this graph to create a physical model of this graph?
<a href="https://i.stack.imgur.com/xvJhX.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/xvJhX.jpg" alt="enter image description here">... | <p>Before worrying too much about the hydrophilic properties of PLA, it might be worthwhile to test a fitting.</p>
<p>First, print a fitting and see that the freshly made print is strong enough to carry the pressure of the water, and the compression force of hose clamp you may need to connect the stiff irrigation hose... | <p>PLA will biodegrade over time. ABS would last longer, and stand up to higher temps.</p>
| 888 |
<p>I'm trying to set an invalid value to -1.. But I don't like magic numbers.. Anyone know where to find a set of common constants. I'm working in VS6 (ish). </p>
<p>I'm trying to read a file from across a network, and I need a bad value for the total file size,so I know if I got valid info on it.. 0 is a valid size s... | <pre><code>#define BAD_VALUE -1
</code></pre>
<p>EDIT: the original question had no context. The revised question indicates you want an invalid file size and are thus looking for the win32 constants. Look at <a href="http://en.wikipedia.org/wiki/Windows.h" rel="nofollow noreferrer">windows.h</a> i think the constant y... | <p>It's generally accepted the 0 and 1 (positive & negative) are OK to use directly.</p>
<p>In fact, it'll probably make you code even more confusing to use a variable instead.</p>
<p>Update: OK, you updated your question after I wrote my answer. If you are using "-1" in an arithmetic way, then just "-1" is fine.... | 46,158 |
<p>I have a UITableView cell that is going to have a variable size depending on it's content (potentially several lines of text). </p>
<p>SInce it appears that heightForRowAtIndexPath is called <em>before</em> I layout the cell, I just guess the correct height by calling [NSString sizeWithFont] on my text string. Is t... | <p>It's going to sound dumb, but ...uh... "layout your cell before you exit heightForRowAtIndexPath" ;)</p>
<p>Seriously, though -- the OS only ever calls this if it's going to be needed (as in: it's about to create the cell & display it on screen), so laying it out & getting ready to display is not wasted ef... | <p>If you look at SMS.app as example, Apple saves the row height of the cell in the SMS.app sqlite database.</p>
| 34,315 |
<p>I'm wondering to using extension method to avoid checking for null in hierarchy.
The example:</p>
<pre><code>// GetItems(), GetFirstOrDefault(), GetProduct(), GetIDProduct() are extension methods like:
public static SomeType GetSomeProperty( this XYZ obj ) {
if ( object.ReferenceEquals( obj, null ) ) { return d... | <p>I'd just do it sanely:</p>
<pre><code>Guid? idProduct = null;
Invoice invoice = this.Invoce;
if (invoice != null &&
invoice.Items != null &&
invoice.Items.Count > 0 &&
invoice.Items[0] != null)
{
idProduct = invoice.Items[0].IDProduct();
}
</code></pre>
| <p>The first thing that struck me when reading this code was</p>
<pre><code>GetFirstOrDefault().GetProduct()
</code></pre>
<p>It breaks two idioms: 1) using <code>Get</code> style methods as noted by Jon, and 2) "unhiding" the abstraction provided by Null Object. The <code>OrDefault</code> engages me as a reader of y... | 37,328 |
<p>I'm looking for a single line regex which does the following:</p>
<p>Given a HTML tag with the "name" attribute, I want to replace it with my own attribute. If that tag lacks the name attribute, I want to implant my own attribute. The result should look like this:</p>
<pre><code><IMG name="img1" ...> => &... | <p>The trick is to match every complete "attribute=value" pair, but <em>capture</em> only the ones whose attribute name isn't "name". Then plug in your own "name" attribute along with all the captured ones.</p>
<pre><code>s/<IMG
((?:\s+(?!name\b)\w+="[^"]+")*)
(?:\s+name="[^"]+")?
((?:\s+(?!name\b)\w+="[^"]+... | <p>If, like in your example, the name attribute is always the first one inside the IMG tag, then it's very easy. Search for </p>
<p><code><(?!/)(/w+)\s+(name="[^"]+")?</code> </p>
<p>and replace with </p>
<p><code><\1 name="myImg1"</code> </p>
<p>but I doubt that this is what you really want.</p>
<p>If the n... | 46,909 |
<p>Is there any way to set the same icon to all my forms without having to change one by one?
Something like when you setup <code>GlobalAssemblyInfo</code> for all your projects inside your solution.</p>
| <p>One option would be to inherit from a common base-Form that sets the Icon in the constructor (presumably from a resx). Another option might be <a href="http://www.postsharp.org/" rel="noreferrer">PostSharp</a> - it seems like it should be possible to do this (set .Icon) via AOP; not trivial, though. Finally, you cou... | <p>I'm not sure if the MS VS designer can deal with Forms that don't derive directly from Form. If not then you may try to copy the main form's icon to all other forms:
for each form in Forms collection</p>
<pre><code>form.icon = MainFrom.Icon
</code></pre>
<p>Or perhaps in each Form's _Loaded event:</p>
<pre><code>... | 22,924 |
<p>Is global memory initialized in C++? And if so, how?</p>
<p>(Second) clarification:</p>
<p>When a program starts up, what is in the memory space which will become global memory, prior to primitives being initialized? I'm trying to understand if it is zeroed out, or garbage for example.</p>
<p>The situation is: ca... | <p>Yes global primitives are initialized to NULL.</p>
<p>Example:</p>
<pre><code>int x;
int main(int argc, char**argv)
{
assert(x == 0);
int y;
//assert(y == 0); <-- wrong can't assume this.
}
</code></pre>
<p>You cannot make any assumptions about classes, structs, arrays, blocks of memory on the heap...</... | <p>Variables declared with static/global scope are always initialized under VC++ at least.</p>
<p>Under some circumstances there can actually be a difference in behaviour between:</p>
<pre><code>int x = 0;
int main() { ... }
</code></pre>
<p>and</p>
<pre><code>int x;
int main() { ... }
</code></pre>
<p>If you ar... | 8,561 |
<p>We are currently storing plain text passwords for a web app that we have. </p>
<p>I keep advocating moving to a password hash but another developer said that this would be less secure -- more passwords could match the hash and a dictionary/hash attack would be faster.</p>
<p>Is there any truth to this argument? ... | <p>Absolutely none. But it doesn't matter. I've posted a similar response before:</p>
<p>It's unfortunate, but people, even programmers, are just too emotional to be easily be swayed by argument. Once he's invested in his position (and, if you're posting here, he is) you're not likely to convince him with facts alo... | <blockquote>
<p>more passwords could match the hash and a dictionary/hash attack would be faster.</p>
</blockquote>
<p>Yes and no. Use a modern hashing algorithm, like an SHA variant, and that argument gets very, very week. Do you really need to be worried if that brute force attack is going to take only 352 years... | 8,349 |
<p>I'm supporting a site that still uses mixed ASP.NET and <a href="http://en.wikipedia.org/wiki/Active_Server_Pages" rel="nofollow noreferrer">ASP Classic</a>. The user receives a 'You are not authorized' error page while accessing certain ASP Classic page. I've checked her active directory account and she could acces... | <p>ASP is entirely dependent on the underlying IIS and the OS for security. It has none of its own. In ASP you access <code>Request.ServerVariables("AUTH_USER")</code>, etc. when the connection is authenticated, but this is done by IIS.</p>
| <p>You can force ASP to use the ASP.NET authentication by making a few changes in IIS so ASP files are using the aspnet_isapi.dll just like the asp.net pages. </p>
<p>Scott Guthrie published an article about this <a href="http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-cla... | 20,046 |
<p>I have a DTS package that drops a table then creates it and populates it but sometimes something happens and the package fails after the drop table. If it's rerun it fails cuz the table hasn't been created yet. </p>
<p>Is there something like "if exists" for SQLServer 2000 like in MySQL?</p>
<p>thanks.</p>
| <p>Or quicker:</p>
<pre><code>IF OBJECT_ID('temp_ARCHIVE_RECORD_COUNTS') IS NOT NULL
DROP TABLE temp_ARCHIVE_RECORD_COUNTS
</code></pre>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa276843%28v=sql.80%29.aspx" rel="noreferrer">OBJECT_ID - MSDN Reference - SQL Server 2000</a></li>
<li><a href="http... | <p>You need to check the <a href="http://msdn.microsoft.com/en-us/library/aa260447(SQL.80).aspx" rel="nofollow noreferrer">sysobjects</a> table </p>
| 31,269 |
<p>I have read that while plug-ins are not supported for SQL Server Management Studio, it can be done.</p>
<p>Does anyone have any resources or advice on how to go about it using C#?</p>
<p>A company that is currently offering plug-ins to Management Studio is Red Gate:
<a href="http://www.red-gate.com/products/SQL_Re... | <p>Here is a very good guide to creating a plugin for SQL Server Management Studio:
<a href="http://blogs.microsoft.co.il/blogs/shair/archive/2008/07/28/how-to-create-sql-server-management-studio-addin.aspx">http://blogs.microsoft.co.il/blogs/shair/archive/2008/07/28/how-to-create-sql-server-management-studio-addin.asp... | <p><a href="http://weblogs.sqlteam.com/mladenp/archive/2007/11/20/Free-SQL-Server-tools-that-might-make-your-life-a.aspx" rel="nofollow noreferrer">Here's a list</a> of a lot of free tools for sql server. at the top you have the section that holds stuff about add-ins from SSMS.</p>
<p>You might also want to check out ... | 19,054 |
<p>I have a quad core machine and would like to write some code to parse a text file that takes advantage of all four cores. The text file basically contains one record per line.</p>
<p>Multithreading isn't my forte so I'm wondering if anyone could give me some patterns that I might be able to use to parse the file in... | <p>I'd go with your original idea. If you are concerned that the queue might get too large implement a buffer-zone for it (i.e. If is gets above 100 lines the stop reading the file and if it gets below 20 then start reading again. You'd need to do some testing to find the optimal barriers). Make it so that any of the t... | <p>@lomaxx</p>
<blockquote>
<p>@Derek & Mark: I wish there was a way to accept 2 answers. I'm going to have to end up going with Wolfbyte's solution because if I split the file into n sections there is the potential for a thread to come across a batch of "slow" transactions, however if I was processing a file wh... | 2,866 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.