instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm hoping there's something in the same conceptual space as the old VB6 <code>IsNumeric()</code> function?</p>
| <p><strong>2nd October 2020:</strong> note that many bare-bones approaches are fraught with subtle bugs (eg. whitespace, implicit partial parsing, radix, coercion of arrays etc.) that many of the answers here fail to take into account. The following implementation might work for you, but note that it does not cater for... | <p>I do it like this:</p>
<pre><code>function isString(value)
{
return value.length !== undefined;
}
function isNumber(value)
{
return value.NaN !== undefined;
}
</code></pre>
<p>Of course isString() will be tripped up here if you pass some other object that has 'length' defined.</p>
| 21,176 |
<p>While implementing an applicative server and its client-side libraries in C++, I am having trouble finding a clean and reliable way to stop client processes on server shutdown on Windows.</p>
<p>Assuming the server and its clients run under the same user, the requirements are:</p>
<ul>
<li>the solution should work... | <p>If you use thread, a simple solution is to use a named system event, the thread sleeps on the event waiting for it to be signaled, the control application can signal the event when it wants the client applications to quit.</p>
<p>For the UI application it (the thread) can post a message to the main window, WM_ CLOS... | <p>That's a very general question, and there are some inconsistencies.</p>
<p>While it is a not 100% rule, most console applications run to completion, whereas GUI applications run until the user terminates them (And services run until stopped via the SCM). Hence, it's easier to request a GUI to close. You send them t... | 10,747 |
<p>When I print <code>"\[\e[34m\]sometext"</code> I get some text in blue, but can I specify the shade of blue somewhere?</p>
| <p>You're using an ANSI escape sequence, which has very limited color options. I use an .Xdefaults file (explained in <a href="http://freemode.net/archives/000121.html" rel="nofollow noreferrer">this tutorial</a>). These options won't make your shell prompt all colorful, but is used by editors such as vim.</p>
<p>Be... | <p>You're using an ANSI escape sequence, which has very limited color options. I use an .Xdefaults file (explained in <a href="http://freemode.net/archives/000121.html" rel="nofollow noreferrer">this tutorial</a>). These options won't make your shell prompt all colorful, but is used by editors such as vim.</p>
<p>Be... | 12,457 |
<p>I've looked at the ReaderWriterLock in .NET 2.0 and the ReaderWriterLockSlim in .NET 3.5, and the slim version doesn't use kernel objects for the locking. For my context, which can potentially generate a large (but not huge) amount of objects, this sounds better.</p>
<p>But the code I write needs to be used in both... | <p>As far as I know there isn't one from Microsoft (otherwise <code>ReaderWriterLockSlim</code> would be somewhat pointless) and if you find one from a third party other than one you trust to have <em>excellent</em> minds who have spent a long time thinking about, implementing and testing it, I wouldn't trust it. I cer... | <p>What about <code>ReaderWriterGate</code> from the <a href="http://www.wintellect.com/PowerThreading.aspx" rel="nofollow noreferrer">PowerThreading</a> library?</p>
| 36,410 |
<p>Is it a good idea to store my SQL queries in a global resource file instead of having it in my codebehind? I know stored procedures would be a better solution but I don't have that luxury on this project. </p>
<p>I don't want queries all over my pages and thought a central repository would be a better idea.</p>
| <p>Resource files are usually used for localization. But a string is just a string is just a string, and do you really want to be sending any old string in a resource file to your database?</p>
<p>I completely agree with others that you should be using linq or typed datasets, etc. Personally I've only had to resort to... | <p>I would look up strongly typed datasets with tableadapters and let the tableadapters handle all queries. When you are used with it you'll never go back.</p>
<p>Just add a dataset to your solution, add a connection, and a tableadapter for a table, then start build all querys (update, select, delete, search and so on... | 34,016 |
<p>So why exactly is it that it's always recommended to use const as often as possible? It seems to me that using const can be more of a pain than a help in C++. But then again, I'm coming at this from the python perspective: if you don't want something to be changed, don't change it. So with that said, here are a ... | <p>This is the definitive article on "const correctness": <a href="https://isocpp.org/wiki/faq/const-correctness" rel="noreferrer">https://isocpp.org/wiki/faq/const-correctness</a>.</p>
<p>In a nutshell, using const is good practice because...</p>
<ol>
<li>It protects you from accidentally changing variables that are... | <p>You can give the compiler hints with const as well....as per the following code</p>
<pre><code>#include <string>
void f(const std::string& s)
{
}
void x( std::string& x)
{
}
void main()
{
f("blah");
x("blah"); // won't compile...
}
</code></pre>
| 16,563 |
<p>Our base Masterpage has something like the following</p>
<pre><code> <head runat="server">
<title></title>
<script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/actions.js")%>"></script>
<script type="text/javascript" src="<%= Page.ResolveCl... | <p>Use the ScriptManager server control:</p>
<pre><code> <asp:ScriptManager ID="myScriptManager" runat="server">
<Scripts>
<asp:ScriptReference Path = "~/javascript/actions.js" />
<asp:ScriptReference Path = "~/javascript/jquery/jquery-1.2.6.min.js" />
</Scripts>
&... | <p>As per <a href="http://weblogs.asp.net/scottgu/archive/2006/12/19/tip-trick-how-to-run-a-root-site-with-the-local-web-server-using-vs-2005-sp1.aspx" rel="nofollow noreferrer">ScottGu</a>,</p>
<p>One tip to take advantage of is the relative path fix-up support provided by the head runat="server" control. You can us... | 22,230 |
<p>We have a RedHat box with Apache2, PHP5 and MySQL 5 for much of our development. Now, we have a Rails client, and we need to set up a Rails app on the same server. Can we install Ruby and the Rails framework with the same Apache, or should we avoid this? Why or Why not? Is it possible to direct subdomains to either ... | <p>Yes, you can configure your virtual hosts to Rails, PHP, or anything else with the proper configuration. The details depend largely on how you are connecting to Rails, but generally however you would configure a single purpose Apache server should work for the virtual hosts.</p>
| <p>Yeah - Install <a href="http://www.modrails.com/" rel="nofollow noreferrer">passenger</a>, then you can configure your sites through your apache conf files. The passenger docs contain everything you'll need to know!</p>
| 22,852 |
<p>I'm reading "<a href="http://jspro.org/" rel="nofollow noreferrer">Pro JavaScript Techniques</a>" by <a href="https://en.wikipedia.org/wiki/John_Resig" rel="nofollow noreferrer">John Resig</a>, and I'm confused with an example. This is the code:</p>
<pre><code>// Create a new user object that accepts an ob... | <p>I started this post with the sole purpose of learning why that things happened, and I finally did. So in case there's someone else interested in the "whys", here they are:</p>
<p><strong>Why does 'this' changes inside the anonymous function?</strong></p>
<p>A new function, even if it is an anonymous, decla... | <p>I found something that seems to be the answer; it’s all about context. Using the anonymous function inside the <em>for</em> loop, changes the context, making 'this' refer to the <em><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window" rel="nofollow noreferrer">window</a></em> object. Strange isn't it?</... | 49,466 |
<p>In a vxWorks Real-Time process, you can pass environment variables as one of the parameter of the <strong>main</strong> routine.</p>
<p>How do you use the environment variables in the kernel context?</p>
| <p>Call this directly from the VxWorks shell:</p>
<pre><code>putenv "<VARIABLE NAME>=<VALUE>"
</code></pre>
<p>replace with your environment variable name and with the value you want to set it to.</p>
| <p>Vxworks environment variable support is provided by the envLib.</p>
<p>use <strong>putenv("VAR=value")</strong> to set the value of the environment variable.</p>
<p>use <strong>char* var = getenv("VAR")</strong> to retrieve the value.</p>
| 22,519 |
<p>I could write myself a helper class that does this when given a functor, but I was wondering if there's a better approach, or if there's something already in the standard library (seems like there should be).</p>
<p>Answers I've found on StackOverflow are all for C# which doesn't help me.</p>
<p>Thanks</p>
| <p>No - there isn't. Apache <code>commons-collections</code> has predicates for this sort of thing but the resultant code (using anonymous inner classes) is usually ugly and a pain to debug.</p>
<p>Just use a basic <strong>for-loop</strong> until they bring <a href="http://javac.info" rel="noreferrer">closures</a> int... | <p>You can try <a href="http://quaere.codehaus.org/" rel="nofollow noreferrer">Quaere</a>. I didn't use it but it looks interesting.</p>
| 27,976 |
<p>I have an application that's a mix of Java and C++ on Solaris. The Java aspects of the code run the web UI and establish state on the devices that we're talking to, and the C++ code does the real-time crunching of data coming back from the devices. Shared memory is used to pass device state and context information f... | <p>The first thing I would do is construct a model of the system to map the data flow and try to understand precisely where the bottleneck lies. If you can model your system as a <a href="http://en.wikipedia.org/wiki/Pipeline_(software)" rel="nofollow noreferrer">pipeline</a>, then you should be able to use the theory... | <p>You need to scale sideways and out. Maybe something like a <a href="http://en.wikipedia.org/wiki/Java_Message_Service" rel="nofollow noreferrer">message queue</a> could be the backend between the frontend and the crunching.</p>
| 7,428 |
<p>I am creating a small web page using PHP that will be accessed as an IFRAME from a couple of sites. I'm wanting to restrict access to this site to work ONLY within the "approved" sites, and not other sites or accessed directly. Does anyone have any suggestions? Is this even possible? The PHP site will be Apache,... | <p>Unfortunately this isn't going to be possible.</p>
<p>Using Javascript you can check to see if your page is embedded in another frame, but this won't be foolproof as Javascript can be turned off in some people's browsers.</p>
<p>For example, you can run the following javascript to reparent your page if that's the ... | <p>Thanks for all the great ideas! I think the solution I'm going to go with is a session cookie set by the approved "iframing" site. Someone really determined will still be able to get the content, but I think I can prevent most of the abuse by coming up with a decent "secret" algorithm based on some sort of shared ... | 30,389 |
<p>I'm trying to make a Card class that duplicates the behavior of Dashboard widgets in that you can put controls or images or whatever on two sides of the card and flip between them. </p>
<p>Layer backed views have a transform property, but altering that doesn't do what I would expect it to do (rotating the layer ar... | <p><strike>Mike Lee has <a href="http://atomicwang.org/motherfucker/Index/B4E5D81C-A9A0-403C-B7A3-62FEB81DE777.html" rel="nofollow noreferrer">an implementation of the flip effect</a> for which he has released some <a href="http://boondoggle.atomicwang.org/lemurflip/" rel="nofollow noreferrer">sample code</a>.</strike>... | <p>Probably not the case in 2008 when this question was asked, but this is pretty easy these days:</p>
<pre><code>[UIView animateWithDuration:0.5 animations:^{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.iconView cache:YES];
/* changes to the view made here will be reflec... | 48,624 |
<p>Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes I need to scroll around in order to get the syntax highlighting adjusted, as sometimes it mysteriously drops all highlighting.</p>
<p>Are there any work-arounds or ways to fix this? I'm using vim 7.1.</p>
| <p>You might like to try this <a href="http://www.vim.org/scripts/script.php?script_id=1491" rel="noreferrer">improved Javascript syntax highlighter</a> rather than the one that ships with VIMRUNTIME.</p>
| <p>For a quick and dirty fix, sometimes I just scroll up and down and the highlighting readjusts. <kbd>Ctrl</kbd>+<kbd>L</kbd> for a screen redraw can also fix it.</p>
| 8,326 |
<p>Firstly I'm extending an existing class structure and cannot alter the original, with that caveat:</p>
<p>I would like to do this:</p>
<pre><code>class a
{
int val;
... // usual constructor, etc...
public int displayAlteredValue(int inp)
{
return (val*inp);
}
}
class b extends a
{
... // ... | <p>You can overload a function in a derived class. So what you have specified above should work. Just wrote a quick test and it worked.</p>
<pre><code>public class DerivedOverload {
/**
* @param args
*/
public static void main(String[] args) {
A classA = new A();
B classB = new B(... | <p>You could write the code in class B as follows:</p>
<pre><code>public int displayAlteredValue(int inp)
{
return -1;
}
</code></pre>
<p>and indicate on the function that -1 is an error return. For int this doesn't really work, but if you returned a class, you could return null if they call the single parameter... | 36,207 |
<p>People keep giving me examples with carp instead of warn. Why? What makes carp better than warn?</p>
| <p>carp gives you more info as to where the message comes from (context)</p>
<pre><code>#!/usr/bin/perl
use Carp;
foo();
bar();
baz();
sub foo {
warn "foo";
}
sub bar {
carp "bar";
}
sub baz {
foo();
bar();
}
</code></pre>
<p>produces</p>
<pre><code>foo at ./foo.pl line 9.
bar at ./foo.pl line 13
... | <p><code>Carp</code> reports errors from the caller's perspective. This is useful for modules where you typically want to warn about incorrect usage (e.g. a missing argument) and identify the place where the error <em>occurred</em> as opposed to where it was <em>detected.</em> This is especially important for utility f... | 22,888 |
<p>I'm testing the VB function below that I got from a Google search. I plan to use it to generate hash codes for quick string comparison. However, there are occasions in which two different strings have the same hash code. For example, these strings</p>
<p>"122Gen 1 heap size (.NET CLR Memory w3wp):mccsmtpteweb025.2... | <p>I'm betting there are more than just "occasions" when two strings generate the same hash using your function. In fact, it probably happens more often than you think.</p>
<p>A few things to realize:</p>
<p>First, there will be hash collisions. It happens. Even with really, really big spaces like MD5 (128 bits) the... | <p>I don't quite see the environment you work in. Is this .Net code? If you really want good hash codes, I would recommend looking into cryptographic hashes (proven algorithms) instead of trying to write your own.</p>
<p>Btw, could you edit your post and paste the code in as a Code Sample (see toolbar)? This would mak... | 8,935 |
<p>in Microsoft Access, is there a way which I can programatically set the Confirm Action Queries flag on the options screen to False? Ideally when the database is started up I would like to check if it's true, and if so, mark it as false for the currently logged in user.</p>
<p>The application is locked down reasonab... | <p>Place the following in a method when the database starts:</p>
<pre><code>If Application.GetOption("Confirm Action Queries") Then
Application.SetOption "Confirm Action Queries", False
End If
</code></pre>
| <p>It is usually better to either use Execute or Set Warnings to get rid of the warning on action queries because options apply to all databases. If you change the options in code, I recommend that you set them back before exiting (and hope that exits are not unexpected) or someone might get an unpleasant surprise when... | 42,690 |
<p>I am thinking of developing a web search engine using Erlang, Mnesia & Yaws. Is it possible to make a powerful and the fastest web search engine using these software? What will it need to accomplish this and how what do I start with? </p>
| <p>Erlang can make the most powerful web crawler today. Let me take you through my simple crawler.</p>
<p>Step 1. I create a simple parallelism module, which i call <i> mapreduce</i></p>
<pre>
-module(mapreduce).
-export([compute/2]).
%%=====================================================================
%% usage ex... | <p>In the <a href="http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/rdbms/src/" rel="nofollow noreferrer">'rdbms' contrib</a>, there is an implementation of the Porter Stemming Algorithm. It was never integrated into 'rdbms', so it's basically just sitting out there. We have used it internally, and it work... | 23,794 |
<p>I have inherited a project that uses LLBLGen Pro for the DB layer. The DB model requires that when a entry is deleted a flag (DeletedDate is set to the current time). The last programmer ignored this requirement and has used regular deletes throughout the entire application.</p>
<p>Is there a way to set the code ge... | <p>I implemented this in SQL Server 2005 using INSTEAD OF triggers on delete for any soft delete table. The triggers set the delete flag and perform clean-up. The beauty of this solution is that it correctly handles deletes issued by any system that accesses the database. INSTEAD OF is relatively new in SQL Server, I k... | <p>It depends if you are using self-servicing or adapter. If SS you will need to modify the template so that it sets the flag for you rather than deleting the entity.</p>
<p>If adapter, you can inherit from DataAccessAdapter and override the delete methods to set the flag for you rather than deleting the entities.</p>... | 16,119 |
<p>if I call php's <code>parse_ini_file("foo.ini")</code>, in what paths does it look for foo.ini ?
the include path? the function's documentation doesn't mention it.</p>
| <p>The filename argument for parse_ini_file is a standard php filename, so the same rules will apply as opening a file using <a href="http://us3.php.net/manual/en/function.fopen.php" rel="noreferrer">fopen</a>.</p>
<p>You must either specify an absolute file path ("/path/to/my.ini") or a path relative to your current ... | <p>I would imagine it only looks in the current working directory - See <a href="http://uk3.php.net/manual/en/function.getcwd.php" rel="nofollow noreferrer">http://uk3.php.net/manual/en/function.getcwd.php</a> if you want to know what that is.</p>
<p>You can always find a path relative to your application by basing it... | 16,900 |
<p>I'm currently trying to debug a customer's issue with an FTP upload feature in one of our products. The feature allows customers to upload files (< 1MB) to a central FTP server for further processing. The FTP client code was written in-house in VB.NET.</p>
<p>The customer reports that they receive "Connection fo... | <p>Do a search for Comcast and BitTorrent. Here's <a href="http://www.alternet.org/columnists/story/69779/" rel="nofollow noreferrer">one article</a>.</p>
| <p>I dont think the ISP would try to kill a 500KB file transfer. Im no expert in either socket thingy or on ISPs... just giving my thoughts on the matter.</p>
| 18,191 |
<p>We have several common libs. Ideally we want them all to use the latest version of a dll even if they have been compiled against an older different version (assume the latest version is backward compatible)</p>
<p>e.g we have:<BR>
<BR>
Project dll<BR>
Common controls dll<BR>
Logging dll<BR>
Database access dll</p>
... | <p>By default, for versioned DLLs I believe VS will force an exact match. If you look in the properties of the reference, however, you'll find a property called "Specific Version". Set that to "false" and it will match later versions.</p>
<p>I don't have the full version of VS with me to find an appropriate MSDN link,... | <p>If you have the source, you could use project references instead of dll references. That way you would always get the latest.</p>
| 22,591 |
<p>The scenario is this</p>
<p>We have two applications A and B, both which are running in separate database (Oracle 9i ) transactions</p>
<p>Application A - inserts some data into the database, then calls Application B
Application B - inserts some data into the database, related (via foreign keys) to A's data. Returns... | <p>You have three options:</p>
<ol>
<li><p>Redesign the application so that you don't have two different processes (both with database connections) writing to the database and roll it into a single app.</p></li>
<li><p>Create application C that handles all the database transactions for A and B.</p></li>
<li><p>Roll yo... | <pre><code>App_A =={0}=> database # App_A stores information for App_B
App_A ------> App_B # App_A starts App_B
App_B <={0}== database # App_B retrieves the information
App_B =={1}=> database # App_B stores more informaion
App_A <={2}== App_B ... | 11,488 |
<p>What is the best way to sort class members?</p>
<p>I'm in conflict with a team member about this. He suggests that we should sort the members alphabetically. I think it's better to organize in a semantic manner: important attributes first, related methods together, etc.</p>
<p>What do you think?</p>
| <p>I like semantic. Alphabetical doesn't seem to make a lot of sense to me, cause when you're looking for a member, you rarely know exactly what it's called. Also, if you're using any sort of naming convention (eg: Hungarian), alphabetical is going to lead to grouping by type, which may not be what you want.</p>
| <p>Are you writing a phone book? </p>
<p>With a semantic approach you can easily show what are the most important methods.
I generally go with Constructor, Destructor first, then important methods followed by getters and setters and eventually misc. methods. Finally, I take a similar approach for internal parts (priv... | 23,642 |
<p>I was looking at how some site implemented rounded corners, and the CSS had these odd tags that I've never really seen before.</p>
<pre><code>-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
</code></pre>
<p>I goo... | <p>The <code>-moz-*</code> properties are Gecko-only (Firefox, Mozilla, Camino), the <code>-webkit-*</code> properties are WebKit-only (Chrome, Safari, Epiphany). Vendor-specific prefixes are common for implementing CSS capabilities that have not yet been standardized by the W3C.</p>
<hr>
<p>Twitter's not "alienating... | <p>I suggest browsing the site from IE or some other browser. I bet you get different markup.</p>
| 15,211 |
<p>I have a html string held in memory after transforming to my desired template with XSLT. What is the best mechanism to the send this to the client printer? </p>
<p>In previous projects I have shamelessly cheated and created a print preview screen, which was essentially an ASPX page with white background that I then... | <p>I don't think a 'print preview' is cheating at all. Since your string is most likely on the server (ie created in ASP.NET code-behind), you must output it to the client somehow and call window.print() to print. There's no way for a webserver to access a client's printers. However you may be able to streamline thin... | <p>Look at CSS media selectors. You can use them to create a single page the looks how you want on the screen and also prints nicely when the user chooses print in the browser.</p>
| 32,797 |
<p>This is pretty simple, I come from a swing/awt background.</p>
<p>I'm just wondering what the proper way to set the background color for a SWT widget is?</p>
<p>I've been trying:</p>
<pre><code>widget.setBackground( );
</code></pre>
<p>Except I have no idea how to create the color Object in SWT?</p>
| <p>To create a color, try this:</p>
<pre><code>Device device = Display.getCurrent ();
Color red = new Color (device, 255, 0, 0);
</code></pre>
| <p>Remember that in SWT you must explicitly dispose any resources that you create when you are done with them. This includes widgets, fonts, colors, images, displays, printers, and GCs. If you do not dispose these resources, eventually your application will reach the resource limit of your operating system and the ap... | 7,267 |
<p>In the Flex framework a custom preloader can be used while the site is loading.</p>
<p>In the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=app_container_4.html" rel="nofollow noreferrer">Adobe docs</a> it specifies that '<strong>the progress bar [preloader] is displayed if less than half of the ... | <p>You should just extend the DownloadProgressBar, try the following code. i've used this before and I've found jesse warden site <a href="http://jessewarden.com/2007/07/making-a-cooler-preloader-in-flex-part-1-of-3.html" rel="nofollow noreferrer">click here </a>usful for info on this (where I found out about it and t... | <p>its not possible to make preloader show instantly , since some classes needs to be downloaded before progress can be displayed . other alternative can be that you display a progress in html and when flash movie is loaded it shows up but here .</p>
| 16,726 |
<p>I'm writing a Greasemonkey script to connect two company-internal webpages. One is SSL, and the other is insecure and can only be accessed via a POST request. If I create a hidden form on the secure page and submit it via an <code>onclick()</code> in an <code><a></code>, it works fine, but FF gives a warning... | <p>This may be possible by doing a GM_xmlhttpRequest. e.g.,</p>
<pre><code>GM_xmlhttpRequest({
method: 'POST',
url: 'http://your.insecure.site.here',
onload: function(details) {
// look in the JavaScript console
GM_log(details.responseText);
/* This function will be called when the page (url... | <p>That's a browser configuration setting, which can't (or shouldn't) be changable by Javascript.</p>
<p>Unless the script needs to be used by more than one user, Tools -> Options -> Security. You can click on settings to display which warning messages are displayed. Note that this currently affects all sites rather... | 46,461 |
<p>When using an aggregate control in some reports you would prefer to see a blank field instead of 0. There does not appear to be a way to do this automatically. Does anyone have a way that this can be done. Note, you want to maintain the '0' value for the field in cases when you export, but you want to show a blan... | <p>There are a number of ways to solve this. The two primary are to use either visibility rules or highlights to create conditional formatting. The visibility is particularly attractive since it is easy to only apply the format rules to particular types of output (e.g. HTML).</p>
<p>For this particular case, there a... | <p>Just an FYI, after working with this for a while longer, I have found that it is just easier to use Visibility rules. The one big advantage is that you can easily configure different visibility for different output formats. So for PDF it may be best to use blanks, but for Excel you may want the 0 values.</p>
| 8,079 |
<p>What are the advantages/disadvantages of the major Ruby VMs (things like features, compatibility, performance, and quirks?) I know there are also some bonus features like being able to use Java interfaces through JRuby, too. Those would also be helpful to note. Does any VM have a clear advantage at this point, and i... | <p>It's simply a bug in your code: finalizers should not be accessing managed objects.</p>
<p>The only reason to implement a finalizer is to release unmanaged resources. And in this case, you should carefully implement <a href="http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx" rel="noreferrer">the standard IDisp... | <h2>The Full Code</h2>
<p>You'll find below the full code, copy/pasted from a Visual C++ 2008 .cs file. As I'm now on Linux, and without any Mono compiler or knowledge about its use, there's no way I can do tests now. Still, a couple of hours ago, I saw this code work and its bug:</p>
<pre><code>using System;
using Sys... | 16,302 |
<p>It's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, you'll probably use <code>m_foo</code>. I've also seen <code>myFoo</code> occasionally.</p>
<p>C# (or possibly just... | <p>The rules (which did not change in C++11):</p>
<ul>
<li>Reserved in any scope, including for use as <a href="https://stackoverflow.com/questions/4297933/c-implementation#4297974">implementation</a> macros:
<ul>
<li>identifiers beginning with an underscore followed immediately by an uppercase letter</li>
<li>identi... | <p>Yes, underscores may be used anywhere in an identifier. I believe the rules are: any of a-z, A-Z, _ in the first character and those +0-9 for the following characters.</p>
<p>Underscore prefixes are common in C code -- a single underscore means "private", and double underscores are usually reserved for use by the c... | 28,315 |
<p>I'm working on an older classic ASP site, and there's a form that allows the user to enter some text (into a multiline textbox), and if they add an html character like ® (register trademark) it inserts it correctly. But when they go to edit the data, using the same form, the update will add a random 'Â' (circumf... | <p>The fundemental problem is the impact of Response.Codepage on Form Posts.</p>
<p>When you send a form to a client specifying that the content is encoded as UTF-8, the browser will assume that the content of form posts should be sent encoded as UTF-8.</p>
<p>Now the action page that receives the post will (somewhat... | <p>® is what ® looks like if it's stored as UTF-8, but displayed as ASCII/ISO-8859-1/Windows-1252. Using the <code>meta</code> tag is not enough to make sure your page is being served as UTF-8. You will also need to set the encoding in the Content-Type HTTP header. This header is typically set either with some server-... | 45,614 |
<p>I am working on converting a CVS repository that has the following symbols (among others):</p>
<p><code>tcm-6.1.0-branch</code> -- a branch<br>
<code>tcm-6.1.0</code> -- a tag</p>
<p>Using the standard transformations cvs2svn identifies them properly. However, I'd like to do some clean up during the conversion... | <p>Using the filesystem here is probably a good bet. Have a request that immediately returns a url to the report pdf location. Your server can then either kick off an external process or send a request to itself to perform the reporting. The client can poll the server (using http HEAD) for the PDF at the supplied url. ... | <p>What about emailing the report to the user. All the asp page should do is send the request to generate the report and return a message that the report will be emailed after is has finished running.</p>
| 19,060 |
<h2>Background</h2>
<p>I'm trying out Scons by setting up a basic C++ sample project that has two sub-projects: </p>
<ul>
<li>Prj1 is an EXE that depends on Prj2</li>
<li>Prj2 is a DLL that exports some functions</li>
</ul>
<p>The problem I'm running into is that the library builds its .obj, .pdb, .lib, .dll, etc. f... | <p>Ok Third try is a charm. I am just placing this in a new answer to keep it cleaner. I talked with my local scons guru, and he stated that the install method should work, but there is a much easier way.</p>
<p>Simply define the full path where you want the executable (or dll) to go. So:</p>
<pre><code>prj2_env.Prog... | <p>VariantDir is the way to do this. How does your Sconstruct call your Sconscript files? Also have you read this section of the documentation: <a href="http://www.scons.org/doc/1.1.0/HTML/scons-user/c3271.html" rel="nofollow noreferrer">http://www.scons.org/doc/1.1.0/HTML/scons-user/c3271.html</a> (I assume you have).... | 35,376 |
<p>Iv been encountering problems with disk space when deploying my app to a pocket pc emulator.</p>
<p>So what Iv done is set up a shared directory on my pc to simulate a SD card, Iv copied the program there manually and then run it from the emulator, with this approach I still need to do the visual studio deployment ... | <p>The "Output File Folder" under Properties->Devices is greyed out, but the [...] button just to the right of it isn't. Adjust it there.</p>
<p>NOTE: To clarify, You click on the [...] button and you get a dialog that allows you to select a folder from the device ("Location of output on device") and enter an additio... | <p>You should think from the perspective emulator not your hard drive. Your shared folder emulates SD card, emulator and Visual Studio do not know anything about that. Previous answer was correct, use "Output File Folder" and put the path "\Storage Card\". And run your app in Visual Studio - application will be deploye... | 32,351 |
<p>Can anyone suggest a tutorial or sample code that implements a nested set (or similar ordered tree structure) with associated Javascript that facilitates drag and drop? I'm looking for both the display code (view) as well as the AJAX backend controller which writes the tree to the database on change.</p>
<p>I want ... | <p>After much searching I found <a href="http://www.artweb-design.de/2008/5/30/scriptaculous-sortabletree" rel="nofollow noreferrer">this online example</a>, written by Sven Fuchs, which does 90% of what I needed.</p>
| <p>Something like this you really don't wanna be slapping a jquery plugin for. If you can't find anything out there it's time to make yourself an espresso and dive right into the code yourself :)</p>
<p>Use other -- more mature -- code out there as a sample point, but write it yourself and it will really suit your pro... | 24,115 |
<p>I don't find the oft-used "*" to be very nice looking - can anyone suggest a nicer-looking method or point me to an example?</p>
<p>I tried making the field highlighted in red as one person suggested but I did not like the look.</p>
<p>Bold labels might do the trick.</p>
<p>But I really like the idea of "Required... | <p>Generally speaking, the best web forms are the simplest ones that require me to think the least. The "standard" that has evolved is that required fields have an asterisk (*) next to them. Sometimes the asterisk is red to help it stand out a bit.</p>
<p>Why fight the standard? Don't make your users think too much... | <p>Might want to check out <a href="http://www.PeterBlum.com" rel="nofollow noreferrer">www.PeterBlum.com</a> - His Professional Validation Package rocks for validating and formatting of controls. He has tutorials for using and numerous examples as well as a detailed manual.</p>
| 32,911 |
<p>Anyone has ever programmed a PHP (or Perl) function to get the ceiling value Excel style?</p>
| <p><em>"Microsoft Excel's ceiling function does not follow the mathematical definition, but rather as with (int) operator in C, it is a mixture of the floor and ceiling function: for x ≥ 0 it returns ceiling(x), and for x < 0 it returns floor(x). This has followed through to the Office Open XML file format. For exam... | <p>Sorry, not quite clear what 'Excel style' is, but PHP has a <a href="http://us3.php.net/ceil" rel="nofollow noreferrer">ceil</a> function.</p>
| 11,448 |
<p>Can someone please point me to articles or books that discusses different programming paradigm (function/logical/OOP)... I am not looking for the syntax details but the ideas that make them good.. </p>
<p>for ex: using functional programming we avoid any side-effects.. If I know the idea I could write side effect f... | <p><a href="http://www.cs.rochester.edu/~scott/pragmatics/" rel="nofollow noreferrer">Programming Language Pragmatics</a> gives a pretty thorough overview of different paradigms. The book is about language design, so it talks a lot about syntax, semantics, type systems, target architectures, etc. The newest edition h... | <p>There is a reading list about <a href="http://www.cis.upenn.edu/%7Ebcpierce/courses/670Fall04/GreatWorksInPL.shtml" rel="nofollow noreferrer">programming language concepts here</a></p>
| 31,851 |
<p>I'm using TkCVS as the GUI front-end for a CYGWIN CVS client, on a Windows XP machine.
It's a good compromise, since on my Linux machine I'm also running TkCVS (the same machine running the CVS server, BTW...).</p>
<p>I'm interested in replacing the diff utility (which has a tkdiff.tcl GUI front-end, for TkCVS) wit... | <p>From a <a href="http://www.twobarleycorns.net/tkcvs/FAQ" rel="nofollow noreferrer">tkcvs faq</a>:</p>
<blockquote>
<p>Q4. Can I use a diff tool other than
tkdiff with tkcvs?</p>
<p>A. Yes, by changing cvscfg(tkdiff).
You usually have to write a wrapper
for your diff tool to get it to
check out th... | <p>what about just using the cvs diff command?</p>
<p>Or download the cvscommand plugin module for vim.</p>
| 25,037 |
<p>I have a collection of an object called Bookmarks which is made up of a collection of Bookmarks. This collection of bookmarks are bound to a treeview control. </p>
<p>I can get the bookmarks back out that I need, but I need a copy of the bookmarks so I can work with it and not change the original. </p>
<p>Any ... | <p>Create a new constructor for your bookmark class that takes an existing bookmark as the parameter.</p>
<p>Within this new constructor, copy all the property values from the existing bookmark onto the new one.</p>
<p>This technique is known as a "Copy Constructor".</p>
<p>There's an article on MSDN that goes into ... | <p>Most collection classes in .Net provide a constructor overload that allow you to pass in another collection like </p>
<pre><code>dim copyOfBookMars as New List(of BookMark)(myOriginalBookMarkList)
</code></pre>
| 49,707 |
<p>When I use traceroute, I often see abbreviations in the hostnames along the route, such as "ge", "so", "ic", "gw", "bb" etc. I can guess "bb" means backbone.</p>
<p>Does anyone know what any these strings abbreviate, or know any other common abbreviations?</p>
| <p>These are ISO-3166-1 Alpha2 geographical domain id's converted to lower case.</p>
<ul>
<li>ge - Georgia</li>
<li>gw - Guinea-Bisseau</li>
<li>so - Somalia</li>
<li>bb - Barbados</li>
<li>ic - old code for Iceland?</li>
</ul>
<p>Just look for ISO-3166 for the complete list of country codes. And RFC 1700 for the geo... | <p>Short version; Country codes</p>
<p>Likely not totally correct, but...</p>
| 15,091 |
<p>One of my favorite vim features is the ability to do</p>
<pre><code>set path=/my/project/root/**
</code></pre>
<p>and then use</p>
<pre><code>:find SomeClassFile.java
</code></pre>
<p>Only problem is, I've got some generated directories at that level that I cannot move and wish to exclude from such searches. I ... | <p>I'm pretty sure you can't exclude things from a <code>"**"</code> search. Instead, you could specify all the subdirectories below that one that <em>don't</em> include generated code, like</p>
<pre><code>set path=/my/project/root/src/**,/my/project/root/com/**,/my/project/root/foo/**
</code></pre>
| <p>If you're on a unix-like system, you can use backticks to run a command-line script like this:</p>
<pre><code>:e `find . -name foo.java -print`
</code></pre>
<p>So you could write your own script to exclude whatever directories you want. I've done a similar thing to exclude .svn directories from <code>:grep</code... | 49,165 |
<p>If one were to use TiddlyWiki as a personal database for notes and code snippets, how would you go about keeping it in sync between multiple machines. Would a svn/cvs etc work. How would you handle merges?</p>
| <p>One option is the up-and-comer <a href="http://getdropbox.com" rel="noreferrer">DropBox</a>. A free filesharing service that gives you 2GB free, and no limit to the number of computers you share on.</p>
<p>Define a shared folder, put your tiddlywiki files in there, and then point the local editing to the shared dri... | <p>Why not just setup something like DokuWiki on a webserver? You do have your own web server, right? You can get a virtual hosted solution for $19/mo these days.</p>
| 11,147 |
<p>What did I do wrong?</p>
<p>Here is an excerpt from my code:</p>
<pre><code>public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
ScrolledComposite scrollBox = new ScrolledComposite(parent, SWT.V_SCROLL);
scrollBox.setExpandHorizontal(true);
mParent = new Composite(scrollBox... | <p>This is a common hurdle when using <code>ScrolledComposite</code>. When it gets so small that the scroll bar must be shown, the client control has to shrink horizontally to make room for the scroll bar. This has the side effect of making some labels wrap lines, which moved the following controls farther down, whic... | <p>Don't you need to recompute the size of the scrollBox after the layout?</p>
| 5,557 |
<p>I'm using JavaScript to hide an image and show some text thats hidden under it. But, when the text is shown if you scroll over it, it fires the mouseout event on the container, that then hides the text and shows the image again, and it just goes into a weird loop.</p>
<p>The html looks like this:</p>
<pre><code>&l... | <p>I'd give the container div:</p>
<pre><code>position: relative;
</code></pre>
<p>and add a third div in the container (should be the last child of the container) with:</p>
<pre><code>position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
</code></pre>
<p>and catch the mouseover and mouseout events on this div ... | <p>This may not be the best solution but you could set a global boolean variable that would be accessible to both methods that would just specify if the last action was HoverIn or HoverOut. You could use this boolean variable to determine if the code should run or not. </p>
<pre><code>if (bWasHoverIn){
...
}
</code... | 7,226 |
<p>I am currently trying to build on TeamCity, which uses Microsoft.Office.Interop dll. This will build and work fine locally as I have Office installed, however when trying to build it on TeamCity it fails as it has no reference. </p>
<p>I can't install the PIA distributable as I get an error message saying the Offic... | <p>If all the teamcity server is doing is a build, then add the Microsoft.Office.Interop DLL to a References folder for your project, and then configure your project to look in that references folder.</p>
<p>However, if the TeamCity server is also running tests that use Office Interop, then you will run into problems ... | <p>Not really - the Interop dll is only a thunk layer between your .NET code and the actual (COM) Office code. If you have the Interop dll without the underlying Office dll, then any calls into the Interop will fail because the Interop will want to call the COM objects it's making interoperable.</p>
<p>Those COM obje... | 49,897 |
<p>I came across this suggestion on the klipper github, <a href="https://www.facebook.com/groups/Hypercube.Evo/permalink/192106034761003/" rel="nofollow noreferrer">https://www.facebook.com/groups/Hypercube.Evo/permalink/192106034761003/</a>. In order to reduce the stretching in the bowden tube you can add fiberglass p... | <p>The question seems to be built on a false premise, namely that the major extrude/retract errors in a Bowden design come from tube stretch. The PTFE tube is <em>not</em> significantly elastic, actually it is reasonably stiff so there is minimal scope for improvement here.</p>
<p>A longer tube <em>will</em> contribut... | <p>The <a href="http://La%20solution%20propos%C3%A9e%20dans%20la%20revendication%201%20de%20la%20pr%C3%A9sente%20demande%20ne%20peut%20%C3%AAtre%20consid%C3%A9r%C3%A9e%20comme%20impliquant%20une%20activit%C3%A9%20inventive%20pour%20les%20motifs%20suivants:%2050%20Ohm%20repr%C3%A9sente%20la%20valeur%20ordinaire%20de%20l... | 997 |
<p>I have a web application (ASP.net 2.0) that has a database (SQL Server) at the background. I'm considering ways how to handle database concurrency if two users insert the same data to the same table at the same time. Are there any way to handle this case? Thanks in advance.</p>
<p>Jimmy</p>
| <p>To prevent the same data being INSERTed at the same time, use a unique index on the columns that you want to be unique. The first <code>INSERT</code> will succeed, handle the error for the losing <code>INSERT</code> appropriately.</p>
<p>To prevent 2+ users from modifying the same (existing) record at the same tim... | <p>Without knowing how your C# code talks to the database (O/R, ADO.NET...), it's difficult to give you a useful answer...</p>
<p>EDIT: all the examples are great, but they won't help if he's using SubSonic for example.</p>
| 44,651 |
<p>Our dev shop currently uses Visual SourceSafe. We all know how that could end up (badly), so we're investigating other systems. First up is Perforce. Does anyone have experience with using it and its integration into Visual Studio (2003/2005/2008)? Is it as good as any other, or is it pretty solid with good features... | <p>I used Perforce at my last 3 jobs (my current job I'm using Subversion, which I don't like nearly as much.) I'm a big fan of Perforce, and moving from SourceSafe it will seem like Nirvana. Just getting atomic checkin will be a big boost for your company. Otherwise, Perforce is fast, it has good tools, and the workfl... | <p>I haven't used Perforce, but I have found moving to Team Foundation Server as one of the best options while working with Visual Studio.</p>
| 4,634 |
<p>I'm new with my 3D printer, I just print two different pawn pieces from thingverse. I just used Cura to convert the files to be readable for the printer. Is my problem with the pieces has to do with the configuration from the Cura software? or with my printer itself? </p>
<p><a href="https://i.stack.imgur.com/xh3Bi... | <p>That looks like horrible underextrusion. Either the extruder steps/mm are way off, but more likely is that your nozzle is clogged (because I wouldn't expect the steps/mm to be this far off). It's also possible that the temperature you're printing at is inappropriate for the filament you're using. Also, make sure tha... | <p>That looks like horrible underextrusion. Either the extruder steps/mm are way off, but more likely is that your nozzle is clogged (because I wouldn't expect the steps/mm to be this far off). It's also possible that the temperature you're printing at is inappropriate for the filament you're using. Also, make sure tha... | 468 |
<p>You might have a set of properties that is used on the developer machine, which varies from developer to developer, another set for a staging environment, and yet another for the production environment. </p>
<p>In a Spring application you may also have beans that you want to load in a local environment but not in a... | <p>I just put the various properties in JNDI. This way each of the servers can be configured and I can have ONE war file.
If the list of properties is large, then I'll host the properties (or XML) files on another server. I'll use JNDI to specify the URL of the file to use.</p>
<p>If you are creating different app fil... | <p>I use Ant's copy with a filter file.
In the directory with the config file with variables I have a directory with a file for each environment. The build script know the env and uses the correct variable file.</p>
| 11,957 |
<p>i have sql statement like this </p>
<pre><code>SELECT DISTINCT results_sp_08.material_number FROM results_sp_08
INNER JOIN courses ON results_sp_08.material_number = courses.material_number
INNER JOIN users ON results_sp_08.id = users.id
AND results_sp_08.doctor = 'xx260'
</code></pre>
<p>i... | <p>Like Joel, your best bet is to add the GROUP BY clause. In your case</p>
<pre><code>GROUP BY results_sp_08.material_number
</code></pre>
| <p>I usually use a double-join strategy on these:</p>
<pre><code>JOIN tablex AS x1 ON whatever
LEFT JOIN tablex AS x2 ON whatever
AND x2.pkid < x1.pkid AND x2.somefield IS NULL
</code></pre>
<p>which guarantees I get at most 1 record on all my joins.</p>
| 49,625 |
<p>I am using a <code>ListView</code> to display the main screen of my application.<br>
The main screen is essentially a <code>menu</code> to get into the different sections of application. Currently, I have the <code>ListView</code> whose contents are added programmatically in the <code>onCreate</code> method. </p>
... | <p>What I typically do for a ListView is to implement my own Adapter by extending the handy BaseAdapter class. One of the abstract methods you'll implement will be getView() as the previous poster mentioned. From there you can inflate a layout containing an ImageView, get a reference to it using findViewById, and set... | <p>From the google docs for ArrayAdapter.</p>
<blockquote>
<p>To use something other than TextViews
for the array display, for instance,
ImageViews, or to have some of data
besides toString() results fill the
views, override getView(int, View,
ViewGroup) to return the type of view
you want.</p>
</blockqu... | 36,653 |
<p>I am fairly new to Emacs and I have been trying to figure out how to change the default folder for <kbd>C-x C-f</kbd> on start-up. For instance when I first load Emacs and hit <kbd>C-x C-f</kbd> its default folder is <code>C:\emacs\emacs-21.3\bin</code>, but I would rather it be the desktop. I believe there is some ... | <p>You didn't say so, but it sounds like you're starting Emacs from a Windows shortcut.</p>
<p>The directory that you see with c-x c-f is the cwd, in Emacs terms, the <code>default-directory</code> (a variable).</p>
<p>When you start Emacs using an MS Windows shortcut, the <code>default-directory</code> is initially ... | <p>In Windows 8, it works to create a shortcut in the Desktop and change the property 'Start In:' for the shortcut. </p>
<p>Now, I ran the program emacs-23.3\bin\addpm.exe as recommended, and the Windows-8 screen (that horrendous invention from Microsoft) it appeared an icon-link to Emacs. But there you have to change... | 8,535 |
<p>Alright. So I have a very large amount of binary data (let's say, 10GB) distributed over a bunch of files (let's say, 5000) of varying lengths.</p>
<p>I am writing a Java application to process this data, and I wish to institute a good design for the data access. Typically what will happen is such:</p>
<ul>
<li>... | <p>Use Java NIO and MappedByteBuffers, and treat your files as a list of byte arrays. Then, let the OS worry about the details of caching, read, flushing etc.</p>
| <p>@Eric</p>
<p>But my queries are going to be much, much simpler than anything I can do with SQL. And wouldn't a database access be much more expensive than a binary data read?</p>
| 16,948 |
<p>What is the best way to go about monitoring a folder to see when an image file has been added to it? Files are added approximately once a minute and the naming goes like this... image0001.jpg, image0002.jpg, image0003.jpg etc. I need to know when a file has been written to the folder so that my app can access and us... | <p>Look into <a href="http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx" rel="noreferrer">directory change notifications</a>.</p>
| <p><a href="http://en.wikipedia.org/wiki/Inotify" rel="nofollow noreferrer">inotify</a> might be your thing</p>
| 30,388 |
<p>Is there a Php function to determine if a string consist of only ASCII alphanumerical characters?</p>
<p>Note: I'm sorry if the question sounds dumb to some, but I couldn't easily find such a function in the Php manual.</p>
| <p>Try <a href="http://us3.php.net/manual/en/function.ctype-alnum.php" rel="noreferrer">ctype_alnum</a></p>
| <p>This is my solution</p>
<pre><code><?php
public function alphanum($string){
if(function_exists('ctype_alnum')){
$return = ctype_alnum($string);
}else{
$return = preg_match('/^[a-z0-9]+$/i', $string) > 0;
}
return $return;
}
?>
</code></pre>
| 42,780 |
<p>For a upcoming project, there are plans to port the existing C++ code that compiles on Windows and Linux to the MacOS(leopard). The software is command line application, but a GUI front end might be planned. The MacOS uses the g++ compiler. By having the same compiler as Linux, it does not seem like there would be... | <p>Does your app have a GUI, and which one (native / Qt / Gtk+)?</p>
<p>If not, the issues to watch out for (compared to Linux) are mainly in the dynamic linkage area. OS X uses '-dylib' and '-bundle' and in fact has two kinds of dynamic libraries (runtime loadable and the normal ones). Linux has only one kind (-share... | <p>We haven't been porting to MacOS, but have been porting to various Unixes from Linux, the main work area has been the installation, and startup systems, so expect to put most of the work there (given your existing is already portable between Linux and Windows).</p>
| 17,556 |
<p><strong>Is there a way to enforce/limit the types that are passed to primitives?</strong> <em>(bool, int, string, etc.)</em></p>
<p>Now, I know you can limit the generic type parameter to a type or interface implementation via the <em>where</em> clause. However, this doesn't fit the bill for primitives (AFAIK) becau... | <pre><code>public class Class1<GenericType> where GenericType : struct
{
}
</code></pre>
<p>This one seemed to do the job..</p>
| <p>In dotnet 6, I encountered this error when using <code>struct</code>:</p>
<blockquote>
<p>The type 'string' must be a non-nullable value type in order to use it as parameter 'T'</p>
</blockquote>
<p>So I use IConvertible instead</p>
<pre><code>var intClass = new PrimitivesOnly<int>();
var doubleClass = new Pri... | 3,039 |
<p>We have some files on our website that users of our software can download. Some of the files are in virtual folders on the website while others are on our ftp. The files on the ftp are generally accessed by clicking on an ftp:// link in a browser - most of our customers do not have an ftp client. The other files are... | <p>HTTP has many advantages over FTP:</p>
<ul>
<li>it is available in more places (think workplaces which block anything other than HTTP/S)</li>
<li>it works nicely with proxies (FTP requires extra settings for the proxy - like making sure that it allows the CONNECT method)</li>
<li>it provides built-in compression (w... | <p>Both FTP and HTTP seem sufficient for your needs, so I would definitely recommend choosing the <em>simplest</em> approach, which is either to leave things as they currently are or consolidate on HTTP.</p>
<p>Personally, I would put everything on HTTP. If nothing else, it eliminates an extra server. There is no co... | 3,502 |
<p>I've been tasked with maintaining an application originally written in VB6. It has since been imported into VB .Net and to say the least the code is anything but Object Oriented. The code is riddled with classes which contain nothing more than Public Shared attributes(variables) and methods(functions), the result of... | <p>Build a class which reads the XML file in, and provides properties/methods/etc based upon the data in that file. When the class writes the XML file back out, have it format in the manner needed for the new version.</p>
<p>So, basically, the class will be able to read in the current version, plus all the older versi... | <p>You might have answered your own question when you used the word strategy (i.e. the Strategy Design Pattern). </p>
<p>Possibly you could:</p>
<ul>
<li>Create a project class that knows nothing about conversions but accepts a strategy object.</li>
<li>Create a hierarchy of classes to model each possible conversion ... | 11,054 |
<p>I've used a WordPress blog and a Screwturn Wiki (at two separate jobs) to store private, company-specific KB info, but I'm looking for something that was created to be a knowledge base. Specifically, I'd like to see:</p>
<ul>
<li>Free/low cost</li>
<li>Simple method for users to subscribe to KB (or just sections) ... | <p>I second Luke's answer.</p>
<p>I can Recommend <a href="http://www.atlassian.com/software/confluence/" rel="noreferrer">Confluence</a> and here is why:
I tested extensively many commercial and free Wiki based solutions. Not a single one is a winner on all accounts, including confluence. Let me try to make your ques... | <p>We've been using a combination of </p>
<ul>
<li>TWiki</li>
<li>OpenGrok for the codebase</li>
<li>usenet</li>
<li>LotusNotes based system</li>
</ul>
<p>As long as there is a google search appliance pointed at these things I think it's ok to have any or many versions as long as people use them</p>
| 2,474 |
<p>I'm having trouble with SQL Server 2008 (Express with Advanced Services) Reporting Services permissions. I'm running this on Vista Ultimate at home - standalone machine with no servers, no domain or active directory.</p>
<p>When I go to the ReportServices site, I get this:</p>
<blockquote>
<p>The permissions gr... | <p>Try running IE as admin and then going to the page. Then under settings add your user and give it permissions. You should be able to run IE not as admin after that. This worked for me using SSRS 2005 under vista.</p>
<p>If not that, then check which user account the service is running as.</p>
<p>See the MSDN page ... | <p>Try with administrator permissions, you run Internet Explorer with administrator, I attached three images with that issue and the solution. I had the same issue in w8.
Good Look.</p>
| 32,610 |
<p>I'm using <a href="http://sourceforge.net/projects/nusoap/" rel="nofollow noreferrer">nusoap</a> to connect to a soap webservice. The xml that the class sends to the service is constructed from an array, ie:</p>
<pre><code>$params = array("param1" => "value1", "param2" => "value1");
$client->call('HelloWor... | <p>The problem is with the inner array()</p>
<pre><code>$test_array = array("item" => "value 1", "item" => "value 2");
</code></pre>
<p>creates an array with a single key ("item").</p>
<p>Try this and see if it works:</p>
<pre><code>$params = array("items" => array("item" => array("value 1", "value 2"))... | <p>Your core problem is you're writing invalid PHP code</p>
<pre><code>$x = array("items" => array("item" => "value 1", "item" => "value 2"));
var_dump($x);
array(1) {
["items"]=>
array(1) {
["item"]=>
string(7) "value 2"
}
}
</code></pre>
<p>Which of course wont work, as its synonymous... | 36,081 |
<p>I was wondering if anybody knew of a method to configure apache to fall back to returning a static HTML page, should it (Apache) be able to determine that PHP has died? This would provide the developer with a elegant solution to displaying an error page and not (worst case scenario) the source code of the PHP page ... | <p>The PHP source code is only displayed when apache is not configured correctly to handle php files. That is, when a proper handler has not been defined. </p>
<p>On errors, what is shown can be configured on php.ini, mainly the display_errors variable. That should be set to off and log_errors to on on a production en... | <p>There are 2 ways to use PHP and Apache.</p>
<pre><code>1. Install PHP as an Apache module: this way the PHP execution is a thread inside the apache process. So if PHP execution fails, then Apache process fails too. there is no fallback strategy.
2. Install PHP as a CGI script handler: this way Apache will start a ... | 8,734 |
<p>Is there a possibility to deactivate / activate all try catch blocks in the whole project as easy as clicking a button?</p>
<p>I need this for debugging when I don't want the catch block to handle the exception, but instead prefer that VS breaks into the code as if the try catch block was not there. </p>
<p>At the... | <p>To catch exceptions the moment they're thrown ("first-chance exceptions" in Win32 parlance):</p>
<ul>
<li><p>in VS2008: go to <strong>Debug</strong>, <strong>Exceptions...</strong></p></li>
<li><p>by VS2015: this has been moved to <strong>Debug > Windows > Exception Settings</strong></p></li>
</ul>
<p>Then check t... | <p>You can change the way Visual Studio breaks when an exception occurs. By default, it breaks on unhandled exceptions. If you go to menu Debug > Exceptions, you can uncheck Common Language Runtime Exceptions and make other changes in the IDE's behavior when exceptions occur. For example, you can have it break on only ... | 45,299 |
<p>What is BODMAS and why is it useful in programming?</p>
| <p><a href="http://www.easymaths.com/What_on_earth_is_Bodmas.htm" rel="noreferrer">http://www.easymaths.com/What_on_earth_is_Bodmas.htm</a>:</p>
<blockquote>
<p>What do you think the answer to 2 + 3 x 5 is?</p>
<p>Is it (2 + 3) x 5 = 5 x 5 = 25 ?</p>
<p>or 2 + (3 x 5) = 2 + 15 = 17 ?</p>
<p>BODMAS can... | <p>I read somewhere that especially in C/C++ splitting your expressions into small statements was better for optimisation; so instead of writing hugely complex expressions in one line, you cache the parts into variables and do each one in steps, then build them up as you go along.</p>
<p>The optimisation routines will... | 2,561 |
<p>I need to use different database connection string and SMTP server address in my ASP.NET application depending on it is run in development or production environment. </p>
<p>The application reads settings from Web.config file via <a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.webconfigura... | <p>In Visual Studio 2010 and above, you now have the ability to apply a transformation to your web.config depending on the build configuration.</p>
<p>When creating a web.config, you can expand the file in the solution explorer, and you will see two files:</p>
<ul>
<li>Web.Debug.Config</li>
<li>Web.Release.Config</li... | <p>You can also use the extension "Configuration Transform" works the same as "SlowCheetah", </p>
| 39,283 |
<p>I have use IlMerge to merge all the dlls of my projects in one exe. I use a targets file which is referenced in the "import" of the main csproj.</p>
<p>The ExecCommand in the targets is:</p>
<pre><code> <Exec Command="&quot;$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe&quot; /out:@(MainAssembly) &q... | <p>I'd recommend that you check out the ILMerge Task in the <a href="http://msbuildtasks.tigris.org/" rel="nofollow noreferrer">MSBuild Community Tasks</a>. Documentation for the ILMerge Task is included in the <a href="http://msbuildtasks.tigris.org/servlets/ProjectDocumentList" rel="nofollow noreferrer">download</a>.... | <p>I'd recommend that you check out the ILMerge Task in the <a href="http://msbuildtasks.tigris.org/" rel="nofollow noreferrer">MSBuild Community Tasks</a>. Documentation for the ILMerge Task is included in the <a href="http://msbuildtasks.tigris.org/servlets/ProjectDocumentList" rel="nofollow noreferrer">download</a>.... | 32,747 |
<p>Is there a way to restart the Rails app (e.g. when you've changed a plugin/config file) while Mongrel is running. Or alternatively quickly restart Mongrel. Mongrel gives these hints that you can but how do you do it?</p>
<p>** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).</p>
<p>** Rai... | <p>You can add the -c option if the config for your app's cluster is elsewhere:</p>
<pre><code>mongrel_rails cluster::restart -c /path/to/config
</code></pre>
| <p>For example,</p>
<pre><code>killall -USR2 mongrel_rails
</code></pre>
| 9,990 |
<p>It is a real pain to deploy my InfoPath 2007 Forms from the designer into our development environment's SharePoint server. All of our forms require "full trust" since they include business logic written in C#. Here are the manual steps:</p>
<p>1) Run the "Publish Form" wizard in InfoPath, specifying the target si... | <p>You can package InfoPath forms in SharePoint solutions (WSP files). These can be deployed by making use of STSADM. For more information:</p>
<ul>
<li><a href="http://blogs.importchaos.com/alonsorobles/2008/06/04/creating-a-sharepoint-solution-for-an-infopath-form-template-deployment/#comments" rel="nofollow norefer... | <p>We can build our own service to deploy the InfoPath form in Share point Server. I have developed the service to solve my problem.
I have used “STSADM” command to deploy the InfoPath form. You have to understand the STSADM syntax so that you can build the script to deploy the InfoPath form.</p>
<p>Here I have summa... | 12,065 |
<p>I have a set of conditions in my where clause like</p>
<pre><code>WHERE
d.attribute3 = 'abcd*'
AND x.STATUS != 'P'
AND x.STATUS != 'J'
AND x.STATUS != 'X'
AND x.STATUS != 'S'
AND x.STATUS != 'D'
AND CURRENT_TIMESTAMP - 1 < x.CREATION_TIMESTAMP
</code></pre>
<p>Which of these conditions will be executed ... | <p>Are you <strong>sure</strong> you "don't have the authority" to see an execution plan? What about using AUTOTRACE?</p>
<pre><code>SQL> set autotrace on
SQL> select * from emp
2 join dept on dept.deptno = emp.deptno
3 where emp.ename like 'K%'
4 and dept.loc like 'l%'
5 /
no rows selected
Execu... | <p>Tricky question. Just faced the same dilemma. I need to mention a function within a query. The function itself makes another query, so you understand how it affects performance in general. But in most cases we have, the function wouldn't be called so often if the rest of conditions executed first.</p>
<p>Well, thou... | 44,181 |
<p>Using ASP.NET 2.0, I have a web app where I am trying to use JavaScript to make one tab in a tab-container the active tab.</p>
<p>The recommendations have been based on:</p>
<pre><code>var mX=document.getElementById('<%= tc1.ClientID%>')
$find('<%= tc1.ClientID%>').set_activeTabIndex(1);
</code></pre... | <p>I've actually run into that before. <strong>Here's an explanation: <a href="http://west-wind.com/WebLog/posts/6148.aspx" rel="nofollow noreferrer">http://west-wind.com/WebLog/posts/6148.aspx</a></strong></p>
<p>For example, if your markup looks like:</p>
<pre><code><asp:Panel id="whatever" runat="server">
... | <p>It looks and sounds like the code snippets are not themselves offensive, but some <em>other</em> code that was modifying the controls collection is now upset about them. Can you tell where in your program the error is actually occuring?</p>
<p>By the way, the <%# %> is not appropriate here — it's only for... | 13,159 |
<p>Is there a function in Common Lisp that takes a string as an argument and returns a keyword?</p>
<p>Example: <code>(keyword "foo")</code> -> <code>:foo</code></p>
| <p>Here's a <code>make-keyword</code> function which packages up keyword creation process (<code>intern</code>ing of a name into the <code>KEYWORD</code> package). :-)</p>
<pre><code>(defun make-keyword (name) (values (intern name "KEYWORD")))
</code></pre>
| <pre><code>(intern "foo" "KEYWORD") -> :foo
</code></pre>
<p>See the <a href="https://lispcookbook.github.io/cl-cookbook/strings.html#converting-between-symbols-and-strings" rel="nofollow noreferrer">Strings section</a> of the <a href="https://lispcookbook.github.io/cl-cookbook/" rel="nofollow noreferrer">Common Li... | 26,024 |
<p>I have a database that I need to provide redundancy for. </p>
<p>It is Codebase, but using a typical SQL database uses too much CPU, and having the DB offsite causes too much latency in my process. </p>
<p>I need a viable solution for providing data redundancy with an offsite location for my time criticla proces... | <p>You could actually use C# with <a href="http://www.mono-project.com/" rel="nofollow noreferrer">Mono</a>.</p>
| <p>You could always use <a href="http://boo.codehaus.org/" rel="nofollow noreferrer">Boo DSL</a> on Mono to construct a C# clone. But then again it would probably be easier to use C# directly on Mono itself I guess ;)</p>
| 41,009 |
<p>Would the following SQL statement automatically create an index on Table1.Table1Column, or must one be explicitly created?</p>
<p>Database engine is SQL Server 2000</p>
<pre><code> CREATE TABLE [Table1] (
. . .
CONSTRAINT [FK_Table1_Table2] FOREIGN KEY
(
[Table1Column... | <p>SQL Server will not automatically create an index on a foreign key. Also from MSDN:</p>
<blockquote>
<p>A FOREIGN KEY constraint does not have
to be linked only to a PRIMARY KEY
constraint in another table; it can
also be defined to reference the
columns of a UNIQUE constraint in
another table. A FOREI... | <p>According to: <a href="https://learn.microsoft.com/en-us/sql/relational-databases/tables/primary-and-foreign-key-constraints?view=sql-server-ver16#indexes-on-foreign-key-constraints" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/sql/relational-databases/tables/primary-and-foreign-key-constraints?view=s... | 35,232 |
<p>How can I efficiently create a unique index on two fields in a table like this:
create table t (a integer, b integer);</p>
<p>where any unique combination of two different numbers cannot appear more than once on the same row in the table.</p>
<p>In order words if a row exists such that a=1 and b=2, another row can... | <p>How about controlling what goes into the table so that you always store the smallest number into the first column and the largest one in the second? As long as it 'means' the same thing of course. It's probably less expensive to do it before it even gets to the database.</p>
<p>If this is impossible, you could sa... | <p>See <a href="https://stackoverflow.com/questions/208666/two-foreign-keys-instead-of-primary">Two foreign keys instead of primary</a></p>
| 28,405 |
<p>I have a 2 threads application. One GUI thread and one worker thread (CWinThread) in which I make time consuming operations - calculations and HTTP comunication. </p>
<p>I have to switch from HTTP to SSL socket connection. I also need to make a verification of server certificate (is it trusted, is it expired, <stro... | <p>For the SSL support - take a look at openssl.org</p>
<p>Cancel support is nice; to do it you have to check on regular basis from the worker thread if cancel was requested. Pay attention to use volatile variable or protected the access to it with a Critical section.
Do not do the network operation from the GUI threa... | <p>There is another free library, SOcketPro, available here:</p>
<p><a href="http://www.udaparts.com/document/articles/demome.htm" rel="nofollow noreferrer">http://www.udaparts.com/document/articles/demome.htm</a></p>
<p>Rgds,
moster67</p>
| 48,447 |
<p>i need a Regular Expression to convert a a string to a link.i wrote something but it doesnt work in asp.net.i couldnt solve and i am new in Regular Expression.This function converts (bkz: string) to (bkz: show.aspx?td=string)</p>
<pre><code>Dim pattern As String = "&lt;bkz[a-z0-9$-$&-&.-.ö-öı-ış-şç-çğ-ğ... | <p>Your regexp is in trouble because of a ')' without '('</p>
<p>Would:</p>
<pre><code>&lt;bkz:\s+((?:.(?!&gt;))+?.)&gt;
</code></pre>
<p>work better ?</p>
<p>The first group would capture what you are after.</p>
| <p>Thanks Vonc,Now it doesnt raise error but also When i assign str to a Label.Text,i cant see the link too.Forexample after i bind str to my label,it should be viewed in view-source ;</p>
<pre><code><span id="Label1">(bkz: <a href="http://www.mysite.com?t=here">here</a>)</span>
</code></pre>
... | 37,488 |
<p>Is there any way to clean up this type of loop using LINQ?</p>
<pre><code> List<Car> result;
List<string> makes;
List<string> models;
for (int i = 0; i < makes.Count() && i < models.Count(); i++)
{
result.Add(new Car() { Make = makes[i], Model = models[i] });
}
</code... | <p>You could use <code>Enumerable.Range</code>, like so:</p>
<pre><code>List<Car> result = Enumerable.Range(0, Math.Min(makes.Count, models.Count))
.Select(i => new Car { Make = makes[i], Model = models[i] }).ToList();
</code></pre>
<p>If <code>makes</code> and <code>models</code> always contain the same... | <p>Depending on how frequently you are going to need to write LINQ queries against these arrays, it may be worth building a class that wraps the arrays and implements <code>IEnumerable<Car></code>. Then your code looks like this:</p>
<pre><code>IEnumerable<Car> cars = new MyClass(makes, models);
var resul... | 22,229 |
<p>The table doesn't have a last updated field and I need to know when existing data was updated. So adding a last updated field won't help (as far as I know).</p>
| <p>SQL Server 2000 does not keep track of this information for you. </p>
<p>There may be creative / fuzzy ways to guess what this date was depending on your database model. But, if you are talking about 1 table with no relation to other data, then you are out of luck.</p>
| <p>You can add a timestamp field to that table and update that timestamp value with an update trigger.</p>
| 2,495 |
<p>I would like to create a simple file format/DSL which would allow my users to input data. My system is in python and using python's parser is appealing.
Syntax like this for defining a data element seems quite convenient.</p>
<pre><code>Allocation(Param1 = Val1, Param2 = Val2 )
</code></pre>
<p>However, it does ... | <p>I'd imagine that there would be some way to do it. But I feel compelled to ask, is there really a big enough difference in readability from this</p>
<pre><code>Allocation(Param1 = Val1, Param2 = Val2 )
</code></pre>
<p>To this:</p>
<pre><code>Allocation(Param 1 = Val1, Param 2 = Val2 )
</code></pre>
<p>to make ... | <p>You can do this:</p>
<pre><code>def Allocation(**kwargs):
print kwargs
myargs = {"Param 1":Val1, "Param 2":Val1}
Allocation(**myargs)
</code></pre>
<p><strong>Edit:</strong>
Your edit now includes my answer so no, there is no easier way to have spaces in keyword arguments.</p>
| 45,804 |
<p>I have a web part that I've developed, and if I manually install the web part it is fine.</p>
<p>However when I have packaged the web part following the instructions on this web site as a guide:
<a href="http://www.theartofsharepoint.com/2007/05/how-to-build-solution-pack-wsp.html" rel="noreferrer">http://www.thear... | <p>Figured it out.</p>
<p>The error message is the one from the .webpart file:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<!--
The following Guid is used as a reference to the web pa... | <p>Have you recycled your worker process or reset IIS?</p>
| 14,708 |
<p>I love the Ruby RSpec BDD development style. Are there any good tools for doing this with C/C++?</p>
| <p><a href="http://github.com/arnaudbrejeon/cspec/wikis/home" rel="noreferrer">cspec</a> is for C. Presumably it will work with C++. There is a list of tools for various languages on the <a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development" rel="noreferrer">Behavior Driven Development Wikipedia page</a>.... | <p>The original link (<a href="http://www.laughingpanda.org/projects/cppspec" rel="nofollow noreferrer">CppSpec</a>) is dead, but it is still accessible at the <a href="https://archive.org/web/" rel="nofollow noreferrer">Internet Archive</a> at <a href="https://web.archive.org/web/20080208105001/http://www.laughingpand... | 23,572 |
<p>I have a basic ActiveRecord model in which i have two fields that i would like to validate. The requirement is that at least one of the fields must have a value. Both can have values, but at least one needs a value.</p>
<p>How do i express this with </p>
<pre><code>validates_presence_of
</code></pre>
<p>statemen... | <pre><code>validates_presence_of :main_file, :if => Proc.new { |p| p.alt_file.blank? }
validates_presence_of :alt_file, :if => Proc.new { |p| p.main_file.blank? }
</code></pre>
| <p>changing .nil? to .blank? does the trick!</p>
| 19,628 |
<p>I am reading file from ResultSet and it's required to save file into Oracle Database.</p>
<pre><code>...
ResultSet rs = ...
java.sql.Blob myfile = rs.getBlob("field")
java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream();
</code></pre>
<p>I get get this error message</p>
<pre><code>java.lan... | <p>I have found the solution. I'd like to share with those who has this problem.</p>
<p>The code to get outputstream from oracle blob is:</p>
<pre><code>java.io.OutputStream os = ((oracle.sql.BLOB) myBlob).setBinaryStream(1L);
</code></pre>
<p>setBinaryStream() is actually returning java.io.OutputStream object</p>
| <p><code>java.sql.Blob</code> <a href="http://java.sun.com/javase/6/docs/api/java/sql/Blob.html" rel="nofollow noreferrer">is an interface</a>. Presumably the implementation returned in your <code>ResultSet</code> is a different implementation to <code>oracle.sql.BLOB</code>?</p>
<p>What does <code>myfile.getClass()</c... | 49,736 |
<p>I have a Monoprice MP10 with magnetic flexible paper coated build plate and I have just tried printing bed level test which is, of necessity, very thin on the build plate.</p>
<p>Watching the item print, I saw that the bed level was obviously way way off at the back left corner and down the left side. I was printing... | <p>In my experience with the Creality magnetic textured build surface, it's easier to remove a thin print while the surface is still pretty warm -- probably between 35 °C and 40 °C -- as opposed to fully cooled to room temperature.</p>
<p>If the print is <em>very</em> thin, however (as when the nozzle is much too close... | <p>You could try freezing your bed with cooling spray around the print and then wait some seconds and try peel it off.</p>
<p>I had the problem once on my PEI sheet and it did help. I used this spray: <a href="https://www.distrelec.ch/de/kuehlmittel-spray-prefix-prefix-200-suffix-suffix-ml-kontakt-chemie-freeze-75-200-... | 1,742 |
<p><a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="nofollow noreferrer">Ajax</a>, <a href="http://en.wikipedia.org/wiki/Adobe_Flex" rel="nofollow noreferrer">Flex</a> and <a href="http://en.wikipedia.org/wiki/Microsoft_Silverlight" rel="nofollow noreferrer">Silverlight</a> are a few ways to make more... | <p>Here's a quick rundown of each area (with lots of helpful links):</p>
<h2>Cross-platform compatibility</h2>
<p><a href="http://arstechnica.com/news.ars/post/20050808-5183.html" rel="nofollow noreferrer">Ajax</a> works in <a href="http://www.musingsfrommars.org/2006/03/ajax-dhtml-library-scorecard.html" rel="nofoll... | <p>Other than what's already been mentioned here, another huge thing to consider is what your UI is going to be.</p>
<p>If you're going to be using a lot of advanced UI controls like trees, lists, tab controls, etc then consider the following:</p>
<ul>
<li><p>JavaScript/HTML - No native support for anything beyond th... | 7,129 |
<p>I have an excel spreadsheet in a format similar to the following...</p>
<pre><code>| NAME | CLUB | STATUS | SCORE |
| Fred | a | Gent | 145 |
| Bert | a | Gent | 150 |
| Harry | a | Gent | 195 |
| Jim | a | Gent | 150 |
| Clare | a | Lady | 99 |
| Simon | a | Junior | 130... | <pre><code>Public Function TopTen(Club As String, Scores As Range)
Dim i As Long
Dim vaScores As Variant
Dim bLady As Boolean
Dim lCnt As Long
Dim lTotal As Long
vaScores = FilterOnClub(Scores.Value, Club)
vaScores = SortOnScore(vaScores)
For i = LBound(vaScores, 2) To UBound(vaScores... | <p>Use a pivot table which will act as a database query on the data you have. Pivot so that the teams go down the columns and team members along with their status type go across the pivot table. I'm not sure for 2003, but Excel 2007 lets you then sort so the highest scores appear to the left. Then your first sum can... | 8,239 |
<p>We have an intranet asp.net web application which uses the OOTB ASP.net membership and role providers. </p>
<p>Now we are planning to expose the application to internet, by moving the web server to the DMZ as represented in the following (crappy) text diagram</p>
<pre>
External Int... | <p>Changing your DMZ policy and opening ports is usually REALLY hard. You might have better success doing what I did: expose a WCF service inside the network and communicate with it over HTTP on port 80.</p>
<p>Zero friction with the LAN folks, and I just mimic the same exact (though crappy) API that .NET gives us :... | <p>We have a couple of Internet-facing web servers in a DMZ and had to open tunnels in our firewall back to the SQL server in our private network that they need to interact with. I think we used something other than port 1433 for the SQL connections. So far it's worked pretty well, i.e. no security breaches.</p>
| 27,992 |
<p>What's the best way to convert a string to an enumeration value in C#?</p>
<p>I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to the corresponding enumeration value.</p>
<p>In an ideal world... | <p>In .NET Core and .NET Framework ≥4.0 <a href="https://msdn.microsoft.com/en-us/library/dd783499%28v=vs.110%29.aspx" rel="noreferrer">there is a generic parse method</a>:</p>
<pre><code>Enum.TryParse("Active", out StatusEnum myStatus);
</code></pre>
<p>This also includes C#7's new inline <code>out</code> va... | <p>First of all, you need to decorate your enum, like this:</p>
<pre><code> public enum Store : short
{
[Description("Rio Big Store")]
Rio = 1
}
</code></pre>
<p>in .net 5, i create this extension method:</p>
<pre><code>//The class also needs to be static, ok?
public static string GetDescription(th... | 3,682 |
<p>I a working in VisualStudio 2005. I have a dataset with sevaral datatables in it already. I had to modify the database to add a new foreign key that I forgot about. How do I get visual studio to recognize the new relationship?</p>
| <p>.Net does not load FK relationships into your DataSet automatically - however, you can add them yourself with a <a href="http://msdn.microsoft.com/en-us/library/system.data.datarelation.aspx" rel="nofollow noreferrer">DataRelation</a>*. </p>
<p>*this may not be true if you are using LINQ - if you are, I am unsure.... | <p>Right-click on the DataSet page, and select Add->Relation?</p>
<p>If you've defined it in your database, you can always re-drag the affected table back into the Dataset then re-enter your Queries.</p>
| 17,909 |
<p>The Compact Framework doesn't support Assembly.GetEntryAssembly to determine the launching .exe. So is there another way to get the name of the executing .exe?</p>
<p>EDIT: I found the answer on Peter Foot's blog: <a href="http://peterfoot.net/default.aspx" rel="nofollow noreferrer">http://peterfoot.net/default.asp... | <p>I am not sure whether it works from managed code (or even the compact framework), but in Win32 you can call GetModuleFileName to find the running exe file.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms683197(VS.85).aspx" rel="nofollow noreferrer">MSDN: GetModuleFileName</a></p>
| <p>In managed code, i think you can use this:
<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.executablepath.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.application.executablepath.aspx</a></p>
<p>Application.ExecutablePath</p>
| 4,554 |
<p>I have a complex .NET Remoting server app that provides a couple of services. Clients can currently use tcp and http channels to connect to the server.</p>
<p>Now I need to implement some new administration services, but I want to restrict their availability to the local machine, i.e. I want to create an administra... | <p>There are no overloads for RegisterWellKnownServiceType that allow you to specify which channel to register on, nor are there any methods on the IPCServerChannel to register a service, so none of that will work.</p>
<p>The best I can think of is writing a ChannelSink that filters your messages or provides security.... | <p>Get the IPAddress of the service calling it. If it is anything other than 127.0.0.1 reject the call.</p>
| 28,973 |
<p>What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows?</p>
| <p>You have a couple of choices. For one, you can use the <a href="https://docs.python.org/library/os.path.html#os.path.getmtime" rel="noreferrer"><code>os.path.getmtime</code></a> and <a href="https://docs.python.org/library/os.path.html#os.path.getctime" rel="noreferrer"><code>os.path.getctime</code></a> functions:</... | <p><code>os.stat</code> does include the creation time. There's just no definition of st_anything for the element of <code>os.stat()</code> that contains the time.</p>
<p>So try this:</p>
<p><code>os.stat('feedparser.py')[8]</code></p>
<p>Compare that with your create date on the file in ls -lah</p>
<p>They should... | 29,333 |
<p>I'm using VisualSVN client and server and one of the requirements for web projects to work as expected is to have the .sln in the same directory (root) as the other files.</p>
<p>I thought it was as simple as removing all the extra parent paths ../ and other relative paths and saving it. However when I try to open ... | <p>THe other option is when you create the project simply uncheck the default box for "create directory for solution"</p>
| <p>I couldn't find a solution file for my project. I was able to run the project on one machine without a .sln in the project. The reason it worked on the machine I created it on was that that I keep my VS projects under C:\Dev\Projects but Visual Studio kept its .sln file c:\users\xyz\documents\VisualStudio2015\pro... | 26,273 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.