instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have two tables: articles and articletags</p>
<pre><code>articles: id, author, date_time, article_text
articletags: id, tag
(article.id == articletags.id in a many-to-many relationship)
</code></pre>
<p>I am after the last time that something was published under each tag. To put it another way, for every tag, l... | <pre><code>select t.tag, max(a.date_time) as latest
from articles a
inner join articletags t
on t.id = a.id
group by t.tag
</code></pre>
| <pre><code>SELECT date_time, tag
FROM articles, articletags
WHERE articles.id = articletags.id
ORDER BY date_time DESC
GROUP BY tag
</code></pre>
| 37,622 |
<p>Recently I tried CodeSmith templates for NHibernate. As many of you might watched, there is a video explaining how to create a Petshop.Data using these templates. My question is what is the correct architecture in this approach? Should we have a BLL (or Services) layer to interact with this Petshop.Data or directly ... | <p>I would say that a presentation layer can be aware of your Business Objects, but should not be aware of how they get populated from the database (but NHibernate takes care of that for you anyways). If you do use a Service Layer it gives you one more point of flexibility/control. I always use one.</p>
| <p>I have had a similar experience with CodeSmith. Here's a blog entry I made:
<a href="http://hypertrends.com/Blog/post/2008/12/15/CodeSmith-to-create-NHibernate-Mappings-Honest-Thoughts.aspx" rel="nofollow noreferrer">http://hypertrends.com/Blog/post/2008/12/15/CodeSmith-to-create-NHibernate-Mappings-Honest-Thoughts.... | 37,576 |
<p>If I call <code>finalize()</code> on an object from my program code, will the <strong>JVM</strong> still run the method again when the garbage collector processes this object?</p>
<p>This would be an approximate example:</p>
<pre><code>MyObject m = new MyObject();
m.finalize();
m = null;
System.gc()
</code></pr... | <p>According to this simple test program, the JVM will still make its call to finalize() even if you explicitly called it:</p>
<pre><code>private static class Blah
{
public void finalize() { System.out.println("finalizing!"); }
}
private static void f() throws Throwable
{
Blah blah = new Blah();
blah.finalize... | <p>The finalize method is never invoked more than once by a JVM for any given object. You shouldn't be relying on finalize anyway because there's no guarantee that it will be invoked. If you're calling finalize because you need to execute clean up code then better to put it into a separate method and make it explicit, ... | 4,847 |
<p><strong>Given:</strong> Constructing an ADO Connection object from one thread and giving it to another thread is <strong><em>forbidden</em></strong>. The two threads are different apartments, and even though the first thread will <strong>never</strong> touch it again (not even maintain a reference to it!), it doesn... | <p>SHOOTING for the bounty!</p>
<p>Okay, some classes/frameworks of classes in .NET have methods that are apartment bound, but BY DESIGN ONLY. That means you have to SPECIFICALLY CODE to do this. Its not set by default. Coding for this is kinda kludgy. You have to get the thread ID you want to stick with and check... | <p>Why would you want to create a connection on one thread and use it from another? </p>
<p>The time between connection creation/open and close/dispose should be minimal as is possible, so handing it off to another thread does not sound like a good idea regardless of whether or not its possible. </p>
| 39,463 |
<p>Simple question, hopefully an easy way and just want to verify I'm doing it the correct / efficient way.</p>
<p>I have a class T object, which is typically put into a vector that is created in my main() function. It can be any kind of data, string, int, float.. etc. I'm reading from a file... which is inputted fr... | <p>It looks like it will work fine, and I would say this is probably the best way to do it. But why are you asking here instead of just testing it yourself?</p>
| <p>Don't use <code>.eof()</code> on a stream in a <code>while</code>-condition. The condition will evaluate to true only <em>after</em> an attempt to read past the end of the file has been made. a better way is to do </p>
<pre><code>while(myFile >> object)
insert(v, object, U);
</code></pre>
<p>Your use of ... | 35,785 |
<p>I'm building few command-line utilities in Xcode (plain C, no Cocoa). I want all of them to use my customized version of libpng, and I want to save space by sharing one copy of the library among all executables (I don't mind re-distributing <code>.dylib</code> with them).</p>
<p>Do I need to do some magic to get li... | <p>Dynamic linking on Mac OS X, a tiny example</p>
<p>Steps:</p>
<ol>
<li>create a library libmylib.dylib containing mymod.o</li>
<li>compile and link a "callmymod" which calls it</li>
<li>call mymod from callmymod, using DYLD_LIBRARY_PATH and DYLD_PRINT_LIBRARIES</li>
</ol>
<p>Problem: you "just" w... | <p>Are you aware of the Apple reference page <a href="http://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/index.html" rel="nofollow noreferrer">Dynamic Library Programming Topics</a>? It should cover most of what you need. Be aware that there a shared libraries that get loa... | 23,633 |
<p>I installed Tomcat 6.0.18 on a windows server 2003 box and it will not start as a service.
I'm running it with jdk 1.6.0_07.</p>
<p>It runs when I start it with tomcat6.exe.</p>
<p>I got a vague error in the System Event Log on Windows.</p>
<p>The Apache Tomcat 6 service terminated with service-specific error 0 (... | <p>I'll bite it :-)</p>
<p>Tomcat Service on windows is dependent on the MS C Runtime library msvcr71.dll. As long as it is in the path, the service will start just fine.</p>
<p>Just to prevent your other windows to be forced to use this version of the runtime library, you might want to copy the DLL to just the tomca... | <p>I copied the msvcr71.dll from the java home directory to the bin directory of the apache-tomcat install, and the service started after that.</p>
| 17,085 |
<p>I'm attempting to write a Python C extension that reads packed binary data (it is stored as structs of structs) and then parses it out into Python objects. Everything works as expected on a 32 bit machine (the binary files are always written on 32bit architecture), but not on a 64 bit box. Is there a "preferred" ... | <p>Explicitly specify that your data types (e.g. integers) are 32-bit. Otherwise if you have two integers next to each other when you read them they will be read as one 64-bit integer.</p>
<p>When you are dealing with cross-platform issues, the two main things to watch out for are:</p>
<ol>
<li>Bitness. If your packe... | <p>Why aren't you using the <a href="http://docs.python.org/lib/module-struct.html" rel="nofollow noreferrer">struct</a> package?</p>
| 16,380 |
<p>I've done several flash projects working as the ActionScripter with a designer doing all the pretty things and animation. When starting out I found quite a lot of information about ActionScript coding and flash design. Most of the information available seems to focus on one or the other.</p>
<p>I didn't find any in... | <p>I've been doing Flash for 9 years and I still find this a difficult thing to get right. </p>
<p>There is a balance of power between designers and developers, which will inevitably tip one way or the other. </p>
<p>If you work for a developer led studio, then you are lucky, as the designers will be instructed to ma... | <p>On our team everyone uses TortoiseSVN and a Trac instance per project. Designers are using the standard Flash designer to edit .FLAs and developers are using <a href="http://www.flashdevelop.org/community/" rel="nofollow noreferrer">FlashDevelop</a> to manage ActionScript files and debug the project.</p>
<p>The too... | 4,500 |
<p>I have ASP.Net code similar to the following (this is inside a FIELDSET):</p>
<pre><code><ol>
<li>
<label>Some label</label>
<one or more form controls, ASP.Net controls, labels, etc.>
</li>
<li>
<label>Another label</label>
... | <p><strong>edit</strong>: corrected code (see old code in revision history and comments for more info)</p>
<p>ok this should work:</p>
<pre><code>$('li label:first-child').each(function() {
$(this).siblings().wrapAll('<div class="li-non-label-child-wrapper">');
});
</code></pre>
<p>from:</p>
<pre><code>&l... | <p>One approach would be to just wrap everything inside the <li> and then move the label out, e.g.</p>
<pre><code>var $div = $('li').wrapInner('<div></div>').children('div');
$div.children('label').prependTo($div.parent());
</code></pre>
| 25,932 |
<p>I am developing an application with VS208 for different Oracle versions. I am wondering if I need to install different version of ODAC to do this, or does the latest release has backward compatibility? Thanks in advance,</p>
| <p>According to the <a href="http://www.oracle.com/technology/software/tech/windows/odpnet/install11106.html" rel="noreferrer">system requirements</a>, it should work with 9i and up. I've accessed a 10g database using 11g before without problem. Although I should note that I didn't really do a whole lot with it.</p>
| <p>ODAC 11g will work (is backward compatible) with databases back to version 9.2. In general, unless you have a very compelling reason, it is a good idea to use the latest version if ODAC that you can to take advantages of bug fixes and new features.</p>
<p>Christian Shay</p>
<p>Oracle</p>
| 37,363 |
<p>In a C++ function I need the compiler to choose a different block if it is compiling for a 64 bit architecture.</p>
<p>I know a way to do it for MSVC++ and g++, so I'll post it as an answer. However I would like to know if there is a better way (more elegant that would work for all compilers/all 64 bits architectur... | <p>This works for MSVC++ and <code>g++</code>: </p>
<pre><code>#if defined(_M_X64) || defined(__amd64__)
// code...
#endif
</code></pre>
| <p>If your using Windows, your probably better to get the "PROCESSOR_ARCHITECTURE" environment variable from the registry because sizeof(PVOID) will equal 4 if its a 32bit process running on a 64bit operating system (aka WOW64):</p>
<pre><code> if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SYSTEM\CurrentControlSet\\Cont... | 19,718 |
<p>I'm trying to get a sampling of what people think are the best sign-up forms. Good design, usability. Smart engineering. Helpful feedback.</p>
| <p>One of my all-time fave sign-up forms was the original <a href="http://www.vox.com/" rel="nofollow noreferrer">Vox</a> one, which has since been changed; there was <a href="http://www.askthecssguy.com/2007/03/form_field_hints_with_css_and.html" rel="nofollow noreferrer">a great break-down</a> of it published online,... | <p>A couple of examples I find interesting are <a href="http://www.tripit.com" rel="nofollow noreferrer">Tripit</a>, a site for organizing your travel plans. Although there is a link to Sign-up for the service the easiest and quickest way is to forward a confirmation email from a travel service (orbitz, travelocity, u... | 13,123 |
<p>In other words may one use <code>/<tag[^>]*>.*?<\/tag>/</code> regex to match the <code>tag</code> html element which does not contain nested <code>tag</code> elements?</p>
<p>For example (lt.html):</p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stric... | <p>Yes, it is allowed (W3C Validator accepts it, only issues a warning).</p>
<p>Unescaped <code><</code> and <code>></code> are also allowed inside comments, so such simple regexp can be fooled.</p>
<p>If BeautifulSoup doesn't handle this, it could be a bug or perhaps a conscious design decision to make it more... | <pre><code>yeah except /<tag[^>]*>.*?<\/tag>/
</code></pre>
<p>Will not match a single tag, but match the first start-tag and the last end-tag for a given tag. Just like your first non-greedy tag-match, your in-between should be written non-greedy as well.</p>
| 12,012 |
<p>Normally when you update an object in linq2sql you get the object from a datacontext and use the same datacontext to save the object, right?</p>
<p>What's the best way to update a object that hasn't been retreived by that datacontext that you use to perform the save operation, i.e. I'm using flourinefx to pass data... | <p>To update an existing but disconnected object, you need to "attach" it do the data context. This will re-use the existing primary key etc. You can control how to handle changes- i.e. treat as dirty, or treat as clean and track future changes, etc.</p>
<p>The Attach method is on the table - i.e.</p>
<pre><code>ctx.... | <p>I am hoping you can help. I am developing a tiered website using Linq to Sql. I created a new class(or object) in DBML designer called memberState. This object is not an actual table in the database. I have this method in my middle layer:<br/><br/></p>
<pre><code>public override IEnumerable(memberState) GetMemb... | 48,541 |
<p>Sure, we can use a simple bulleted list or a mindmap. But, there must be a better, more interactive way. What do you use when starting your website architecture?</p>
| <p>From a physical and logical architecture standpoint, nothing beats the whiteboard, drawing up the layers/tiers of the application in boxes. Then create an electronic copy using Visio.</p>
<p>After that, iteratively dive into each layer and design it using appropriate tools and techniques. Here are what I commonly... | <p>By "architecture", do you mean the initial site map? If not, please post a clarification and I'll edit my response.</p>
<p>Our tech team starts development after our creative department has done their stuff. Part of what we get is output from the information architect. He passes off a graphical sitemap, a detailed ... | 7,791 |
<p>What is a view in Oracle?</p>
| <p>A <strong>View in Oracle</strong> and in other database systems is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used. For example, if we frequently issue the following query</p>
<pre><code>SELECT customerid, customername FROM customers WHERE countryid='US';
</cod... | <p>A view is a virtual table, which provides access to a subset of column from one or more table. A view can derive its data from one or more table. An output of query can be stored as a view. View act like small a table but it does not physically take any space. View is good way to present data in particular users fro... | 32,027 |
<p>How do you retrieve selected text using Regex in C#?</p>
<p>I am looking for C# code that is equivalent to this Perl code:</p>
<pre><code>$indexVal = 0;
if($string =~ /Index: (\d*)/){$indexVal = $1;}
</code></pre>
| <pre><code>int indexVal = 0;
Regex re = new Regex(@"Index: (\d*)")
Match m = re.Match(s)
if(m.Success)
indexVal = int.TryParse(m.Groups[1].toString());
</code></pre>
<p>I might have the group number wrong, but you should be able to figure it out from here.</p>
| <pre><code>int indexVal = 0;
Regex re = new Regex.Match(s, @"(<?=Index: )(\d*)");
if(re.Success)
{
indexVal = Convert.ToInt32(re.Value);
}
</code></pre>
| 3,072 |
<p>I am writing my own control that will contain a panel with text, images and other media. What is the best way to render the text and images. The control may contain long texts and many images.<br>
Should I add the text as labels and images as PictureBox or should I use the DrawString and DrawImage methods to render ... | <p>If you use labels, then you get all the labelly goodness for free.</p>
<p>If you use DrawString, then it'll probably be (a little bit) faster, but it's a lot more complicated if you need to deal with things like the text changing.</p>
<p>The OnPaint handler is a always a tricky one to write, and invalidating the c... | <p>I would use DrawString and DrawImage - you have less resources to worry about, but with added complexity.</p>
<p>I don't think it's that bad drawing your own strings and images once you get into it.</p>
<p>This is a nice introduction to it:</p>
<p><a href="https://web.archive.org/web/20150116060854/http://bobpowell.... | 41,047 |
<p>I'm studying an introductory course in databases and one of the exercises is to work with MS-Access. However I'm using Linux at home and although I can use the computer classes at the university it is far from convenient (limited open time - my studying time is mostly nights).</p>
<p>So how can I use an Access file... | <p>Although a bit dated, I've had good success with <code>mdbtools</code> which is a set of command line tools for accessing and converting Access databases to other formats. I've used it for importing databases into PostgreSQL.</p>
<p>If you're running an Ubuntu variant you can install it with:</p>
<pre><code>sudo a... | <p>If you've got an assignment to work with Access, then frigging find a Windows computer and do your exercise on the native platform for Access. It's completely senseless to do anything else, as you won't be learning anything useful about Access.</p>
<p>If the assignment is to use a Jet data store, then that's someth... | 49,398 |
<p>My page has two components that depend on JavaScript. On the left-hand side, there is attribute-based navigation (abn). And the right-hand side is the Result of the abn.</p>
<p>There is an event handler for abn and an event handler for the result (both are on clicks)
Whenever the user clicks on the abn, I do an Ajax... | <p>Did you insert an element with the same id (duplicate id)?</p>
| <p>They are class, not div. And they have the same class.
The event handler is not part of the result. The javascript is at the bottom of the page while the Result is at the top. So the javascript is sitll there. They are not being replaced.</p>
| 37,290 |
<p>I'm trying to take advantage of the constant memory, but I'm having a hard time figuring out how to nest arrays. What I have is an array of data that has counts for internal data but those are different for each entry. So based around the following simplified code I have two problems. First I don't know how to al... | <p>I think constant memory is 64K and you cannot allocate it dynamically using <code>cudaMalloc</code>. It has to be declared constant, say,</p>
<pre><code>__constant__ data mydata[100];
</code></pre>
<p>Similarly you also don't need to free it. Also, you shouldn't pass the reference to it via pointer, just access it... | <p>Why don't you just use the so-called "packed" data representation? This approach allows you to place all the data you need into one-dimension byte array. E.g., if you need to store</p>
<pre><code>struct data
{
int nFiles;
int nNames;
int* files;
int* names;
}
</code></pre>
<p>You can just store thi... | 34,110 |
<p>I am using a global named mutex for file access synchronization between an ASP.NET application and a console application.</p>
<p>While running the ASP.NET application, the console application fails to acquire mutex - as expected. While running the console application, the ASP.NET application throws <code>Unauthoriz... | <p>do you have the right user set up to access to the resources? using </p>
<pre><code>MutexSecurity and MutexAccessRule ?
</code></pre>
<p>try looking at this on MSDN <a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.mutexsecurity.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/li... | <p>Here the sample from <a href="https://stackoverflow.com/questions/778817/how-to-determine-if-a-previous-instance-of-my-application-is-running-c">How to determine if a previous instance of my application is running?</a> (see the <a href="https://stackoverflow.com/users/33080/romkyns">romkyns</a>' answer)</p>
<pre><c... | 46,382 |
<p>My Invoice model has an address_id attribute, and I don't want this address_id to change FOREVER. So I don't want this to happen outside the class:</p>
<pre><code>invoice.address_id = 1
invoice.address = some_address
</code></pre>
<p>Rails automatically adds this address_id attribute to the model from the invoice ... | <p>You want <a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001317" rel="noreferrer"><code>attr_readonly</code></a>.</p>
| <p>Not as pretty as a one liner, but code below should work (and you could always do some metaprogramming to write an 'immutable' method)</p>
<pre><code>def address_id=(id)
if new_record?
write_attribute(:address_id, id)
else
raise 'address is immutable!'
end
end
</code></pre>
| 16,632 |
<p>So I've got an application whose window behavior I would like to behave more like Photoshop CS. In Photoshop CS, the document windows always stay behind the tool windows, but are still top level windows. For MDI child windows, since the document window is actually a child, you can't move it outside of the main windo... | <p>I havn't seen anything remarkable about Photoshop CS that requries anything close to this level of hacking that can't instead be done simply by specifying the correct owner window relationships when creating windows. i.e. any window that must be shown above some other window specifies that window as its owner when b... | <p>I would imagine they've, since they're not using .NET, rolled their own windowing code over the many years of its existence and it is now, like Amazon's original <a href="http://en.wikipedia.org/wiki/Obidos_(software)" rel="nofollow noreferrer">OBIDOS</a>, so custom to their product that off-the-shelf (aka .NET's MD... | 18,556 |
<p>I have a case where I have a bunch of text boxes and radio buttons on a screen all built dynamically with various DIVs. There are onblur routines for all of the text boxes to validate entry, but depending on the radio button selection, the text box entry could be invalid when it was valid originally. I can't use o... | <p>This question is a bit too involved for me at this time of the night, but I will give you this bit of advice:</p>
<pre><code>eval("tagCreditOrDebit = document.forms[0]." + tagFactor.name.substr(0,3) + "CreditOrDebitC");
</code></pre>
<p>This can be written in a MUCH better way:</p>
<pre><code>tagCreditOrDebit = d... | <p>First, for the love of god and all that is holy, stop writing native javascript and help yourself to some of that <a href="http://jquery.com" rel="nofollow noreferrer">jQuery</a> :)</p>
<p>Second, start using a validation framework. For jQuery, <a href="http://docs.jquery.com/Plugins/Validation" rel="nofollow noref... | 27,928 |
<p>I've created a webservice and when I want to use its methods I instantiate it in the a procedure, call the method, and I finally I dispose it, however I think also it could be okay to instantiate the webservice in the "private void Main_Load(object sender, EventArgs e)" event.</p>
<p>The thing is that if I do it th... | <p>It depends on how often you are going to be calling the web service. If you're going to be calling it almost constantly, it would probably be better to use method #2. However, if it's not going to be getting called quite so often, you are better off using method #1, and only instantiating it when you need it.</p>
| <p>Right now I made a solution for a mobile device and it turns to be used on irregular times, it could be used in 10 minutes, 1 hour, 4 hours its very variable, it seems that the better aproach is the first strategy.</p>
<p>Last year we went on a project where we used webservices, the fact is that we instantiated our... | 3,416 |
<p>Is it possible to programmatically push files to a wireless SD card - like a www.eye.fi card?</p>
<p>I use a Mac and thought I could do this using some AppleScript - but have not found a way...</p>
<p>Derek</p>
| <p>The eye-fi card relies on image files being written to a specific directory in the card before they'll transfer them. Beyond that it works exactly like a memory card.</p>
<p>Write a file to it as if you're writing a regular memory card, and as long as it's a jpg image file of reasonable size, and in an appropriate... | <p>It looks like you can treat it just like an external hard drive (plug the memory card in and figure out where the mount point is).</p>
| 8,113 |
<p>For my apps, I store some configuration file in xml along with the assembly(exe), and something other temporary files for proccessing purpose. </p>
<p>I found some quirk with <code>".\\"</code> and <code>Application.StartupPath</code>.</p>
<p>I've been using </p>
<pre><code>String configPath = ".\\config.xml";
<... | <pre><code>System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))
</code></pre>
| <p>How about </p>
<pre><code>string currentAssemblyFile = System.Reflection.Assembly.GetExecutingAssembly().Location;
</code></pre>
<p>and then figure it out from there...</p>
| 31,596 |
<p>Using the method <code>Application.Restart()</code> in C# should restart the current application: but it seems that this is not always working.</p>
<p>Is there a reason for this Issue, can somebody tell me, why it doesn't work all the time?</p>
| <p>There could be a lot of reasons for this. It's not that the method doesn't work; rather, many times programmers forget that they've put something in their code that would stop the application from automatically shutting down, or starting up. Two examples:</p>
<ul>
<li>The Closing event on a form can stop an app's s... | <p>I know this is an old thread, but I found a workaround. Hopefully this will help someone else in need. </p>
<p>I needed a solution that would trigger the update sequence during a ClickOnce Application startup from code. <code>Applicatoin.Restart</code> did not do this. I wanted a way of being able to check for ... | 12,072 |
<p>I got my Xampp server running and can run my html in subdirectories now, as well (can't have spaces in the subdirectory names).</p>
<p><strong>SSI Includes or PHP Includes:</strong></p>
<p>Xampp says SSI is deactivated. Tried uncommenting the lines for includes, but it doesn't change the deactivation.</p>
<p>How ... | <p>I don't know if Xampp has a special way of activating SSI or not, but the <a href="http://httpd.apache.org/docs/2.2/howto/ssi.html#configuring" rel="nofollow noreferrer">normal Apache way</a> should work.</p>
<p>The normal way to include files in SSI is</p>
<pre><code><!--#include virtual="/something/file.html"... | <p>PHP includes are pretty straightforward. Just name your file something.php and do this:</p>
<pre><code><?php include('path/to/file.php'); ?>
</code></pre>
<p>The file will be parsed by php so it can contain the standard mix of PHP/HTML tags or whatever other text you'd like.</p>
| 40,419 |
<p>I have a form using multiple <code><cfinput type="datefield" ...></code>. They are positioned in such a way that the pop-up CSS calendar should appear over the field for others. However, the text fields for the other dates end up in front of the calendar.</p>
<p>This is only an IE issue as Firefox and Safari ... | <p>Well, you have to encapsulate your datefield wirhin a div with both position:relative and Z-index value, as in :</p>
<pre><code><div style="position:relative; z-index:3">
<cfinput type="dateField" name="info_dateDebutPub" value="#dateformat(info_dateDebutPub,'dd/mm/yy')#" mask="dd/mm/yy">
</div>
<... | <p>My first inclination is to attempt to add a style for the text fields with a negative z-index. Alternately, you could attempt to apply a positive z-index to the popup.</p>
<p>The first would probably be easier, given the way that the popups are written dynamically -- CF passes any unrecognized or unused attributes... | 25,709 |
<p>What is the differences between those 2 assuming I'm using SQL Server as my database? Are they the same?</p>
| <p>This <a href="http://blogs.microsoft.co.il/blogs/sasha/archive/2008/07/01/linq-to-sql-more-useful-than-you-d-think.aspx" rel="nofollow noreferrer">post</a> points to some info. in particular 3 main differences:</p>
<ul>
<li><p>The ability to query relational stores other than Microsoft SQL Server</p></li>
<li><p>A ... | <p>Long answer: google.
Short answer: using entity framework, you will be able to create something based on classes (partial, that you can "extend") resembling domain objects (not true DDD though, that's why NHibernate still exists and linq to nhibernate is being developed), using sql you will be just thinking database... | 38,489 |
<p><strong>Original Question</strong></p>
<p>I am writting a logging class where the goal is to be able to do this:</p>
<pre><code>// thread one
Logger() << "Some string" << std::ios::hex << 45;
// thread two
Logger() << L"Some wide string" << std::endl;
</code></pre>
<p>Currently my Lo... | <p>You can use friend definition, which will define the operator in the surrounding namespace of the class, and make it only visible to operator overloading resolution (not callable manually using the ::operator<<... syntax):</p>
<pre><code>class Logger
{
public:
Logger();
~Logger();
std::ostream* o... | <p>why not do it the printf way and use the multi parameter method (with the three dots ...). This still gives you alot of formating power and doesnt make it that messy as when you are using the <<.</p>
<p>For example:</p>
<pre><code>Logger("This is my log msg %0X", 45);
</code></pre>
<p>Hang on two secs and i... | 37,055 |
<p>Every time I try to create a new project or solution in visual studio (2005 and 2008), I get an error saying, "Project Creation failed." I even tried running vs in administrative mode, but I still get the same answer. Anyone have any suggestions, in short of uninstalling all of VS and reinstalling it?</p>
| <p>It sounds like an Add-in behaving badly. Can you launch it in safe mode?</p>
<pre><code>devenv.exe /SafeMode
</code></pre>
| <p>Out of the blue i would guess a security/rights issue, eg. trying to create the solution on a drive/folder you don't have write access to, or has otherwise restricted rights.</p>
| 19,923 |
<p>How would you implement a GUI similar to the "My Computer" view in Windows Explorer?</p>
<p>In particular the "Icons" view mode. Including the grouping of different item types (as Files Stored on This Computer/Hard Disk Drives/Devices with Removable Storage groups in Windows Explorer)</p>
<p>In WinForms I would us... | <p>Have a TreeView with <a href="http://www.dev102.com/2007/12/27/how-to-use-hierarchical-datatemplate-in-wpf/" rel="nofollow noreferrer">HeirarchichalDataTemplate</a> defined for your FileSystem class</p>
| <p>See FolderView, FileView, etc controls from <a href="http://www.ssware.com/megapack.htm" rel="nofollow noreferrer">Shell MegaPack.WPF</a></p>
<p>It supports grouping and icons mode (among lots of other things).</p>
| 22,309 |
<p>I am trying to create a serial port in VB.net using code only. Because I am creating a class library I cannot use the built-in component. I have tried instantiating a new SeialPort() object, but that does not seem to be enough. I'm sure there is something simple I am missing and any help would be greatly appreciated... | <p>If you want to use the events make sure you declare your serialPort object using the 'withevents'. The below example will allow you to connect to a serial port, and will raise an event with the received string. </p>
<pre><code>Imports System.Threading
Imports System.IO
Imports System.Text
Imports System.IO.Port... | <p>I have used the SerialPort .Net class in a past project and I worked fine. You really don't need anything else. Check the hardware setting in the control panel and make sure you instantiate the class with the same parameters.</p>
| 42,731 |
<p>I hate Physics, but I love software development. When I go back to school after Thanksgiving, I'll be taking two more quarters of Physics before I'm done with the horrid thing. I am currently reading postings on the F# units of measurement feature, but I've never used a language like F#. Would it be suitable to writ... | <p>In my biased opinion, F# is ideal for physics. It has a feature called Units of Measure which does dimensional analysis for you, providing errors if you get it wrong. For example if you write:</p>
<pre><code>let distance : float<meters> = gravity * 3.0<seconds>
</code></pre>
<p>That would <strong>yield... | <p>Learning any computer language won't teach you physics, and you can learn physics by writing programs in any language.</p>
<p>Dimensional analysis is a rather handy tool for physics problems, it can steer you away from being "not even wrong".</p>
<p>I've always gained a certain perverse pleasure in getting an answ... | 20,280 |
<p>I've read conflicting things on this.</p>
<p>From Wikipedia:</p>
<blockquote>
<p>Controller
Processes and responds to events, typically user actions, and may invoke
changes on the model.</p>
</blockquote>
<p>It's the word TYPICALLY that is confusing. If not just user input, then what else?</p>
| <p>I view the controller as a <em>Coordinator</em>, most of my code is usually in the controller. This is where the most of branches happen. In a View or Model, most of your code is going to deal with itself (a data object doesn't know anything about a view object). However a controller matches a data object (model)... | <p>I call validating and sanitising user input part of the view.</p>
<p>I call the controller the logic behind, the part that takes the validated, sanitised data, and does work with it. That way you can write a test harness that acts as the view, that supplies data to the controller and test the outcomes.</p>
| 46,544 |
<p>I have a <code>CMFCRibbonStatusBar</code> in my mainframe to which I add a <code>CMFCRibbonButtonsGroup</code> which again has a <code>CMFCRibbonButton</code>. This button has the same ID as a menu entry.</p>
<p>Creating the button is done as follows:</p>
<pre><code>CMFCRibbonButtonsGroup* pBGroup = new CMFCRibbon... | <p>I don't think it's possible to show the tooltip without the mouse cursor being over the control. That's all done automatically.</p>
<p>However if you want to have a nice looking tooltip like in your screenshot, you need to call <code>SetToolTipText</code> and <code>SetDescription</code>, like this:</p>
<pre><code>... | <p>I am using <code>CMFCRibbonButton</code> controls within a <code>CMFCRibbonButtonGroup</code>, which is added to the <code>CMFCRibbonStatusBar</code>. Take note of the 4th parameter in the <code>CMFCRibbonButton()</code> constructor, <code>bAlwaysShowDescription</code>, as this seems to affect the behavior dependin... | 31,597 |
<p>I've notice an issue - it feels like a bug but I suspect a 'feature' - in SSMS in SQL Server 2008.</p>
<p>I have various tabs open, for example an alter table script in one table and a SProc that queries that table in another tab, and when I execute my Alter Table script the changes are not reflected in Intellisens... | <p><code>CTRL</code> + <code>SHIFT</code> + <code>R</code> to update the intellisense, for short.</p>
| <p>Well done raising the issue - I have it frequently in VS 2008 SP1 but there coding the right name still produces an error squigly until the refresh happens - and I can't get it to do so at the moment. I suspect I need another shutdown/reload.</p>
| 45,458 |
<p>Which Eclipse package should I choose for Python development with <a href="http://www.pydev.org/" rel="nofollow noreferrer">PyDev</a>?</p>
<p>Nothing on the Eclipse homepage tells me what to choose, and the PyDev documentation assumes I already have Eclipse installed. Does it matter which Eclipse package I choose?<... | <p>If you just plan on doing Python dev, I'd just go with <a href="http://download.eclipse.org/eclipse/downloads/" rel="noreferrer">Platform Runtime Binary</a>.</p>
<p>After that, I'd follow the instructions <a href="http://pydev.org/download.html" rel="noreferrer">http://pydev.org/download.html</a> and <a href="http:... | <p>I use J2EE Eclipse for Python and Java development. It works well.
But Classic Eclipse should be enought.</p>
| 30,237 |
<p>Which SQL statement is faster?</p>
<pre><code>SELECT TOP 2 c1.Price, c2.Price, ..... c49.Price, c50.Price
FROM Table1 AS c1, Table2 AS c2, ..... Table49 AS c49, Table50 AS c50
WHERE c1.Date = c2.Date AND c2.Date = c3.Date ..... c49.Date = c50.Date
ORDER BY c1.ID DESC
OR
SELECT TOP 2 c1.Price, c2.Price, ..... | <p>What is faster is not having 50 tables to start with. Joining 50 tables might be ok, but it's a highly counter-intuitive design and probably not the most maintainable solution.</p>
<p>Can you not store your data in rows (or columns) of a single (or fewer) tables rather than 50 tables??!</p>
| <p>Ignore JOINs whenever possible. Performance wise, Join statements are not efficient at all.</p>
| 30,054 |
<p>For as long as I can remember I have avoided using switch statement fall-through. Actually, I can't remember it ever entering my consciousness as a possible way to do things as it was drilled into my head early on that it was nothing more than a bug in the switch statement. However, today I ran across some code that... | <p>It may depend on what you consider fallthrough. I'm ok with this sort of thing:</p>
<pre class="lang-js prettyprint-override"><code>switch (value)
{
case 0:
result = ZERO_DIGIT;
break;
case 1:
case 3:
case 5:
case 7:
case 9:
result = ODD_DIGIT;
break;
case 2:
case 4:
case 6:
... | <p>In some instances, using fall-throughs is an act of laziness on the part of the programmer - they could use a series of || statements, for example, but instead use a series of 'catch-all' switch cases.</p>
<p>That being said, I've found them to be especially helpful when I know that <em>eventually</em> I'm going to... | 22,850 |
<p>I am fairly new to WPF and I am having a problem with inheriting from a user control.</p>
<p>I created a User Control and now I need to inherit from that control and add some more functionality.</p>
<p>Has anyone does this sort of thing before? Any help would be greatly appreciated.</p>
<p>Thank you</p>
| <p>Well .. you create your base control </p>
<pre><code>public abstract class BaseUserControl : UserControl{...}
</code></pre>
<p>then in the XAML file :</p>
<pre><code><Controls:BaseUserControl x:Class="Termo.Win.Controls.ChildControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="ht... | <p>You can accomplish this by using a <code>delegate</code>.</p>
<p>Essentially, you need to create an interface (<code>YourInterface</code>) which wraps up the functionality you want, then make both the user control and your class implement that interface.</p>
<p>Next, make sure the user control has a reference to a... | 33,794 |
<p>The following code is just a simplified example to demonstrate my problem:</p>
<pre><code>using System;
using System.IO;
using System.Diagnostics;
using System.Threading;
namespace ConsoleApplication5
{
class Program
{
static string LogFile = @"C:\test.log";
static void Main(string[] args)... | <p>There is nothing strange going on here. Imagine that you have a file "a.txt" and you open it in notepad 10 times. After that, you change the contents of the file and save it in every instance of notepad. Naturally, the last save you make is the one that is persisted to the file because it rewrites the previous 9 sav... | <p>Use <code>SyncLock</code> which makes sure only one thread opens the file at a time.
In the mean time the other processes do not crash but wait in a <code>queue</code>.</p>
| 37,892 |
<p>Is it possible in .NET to list files on a remote location like an URL? Much in the same way the System.IO classes work. All I need is the URLs to images that are on a remote server.</p>
| <p><strong>Short answer:</strong> No, unless you have more control over that web-server</p>
<p><strong>Long answer:</strong> Here are possible solutions...</p>
<ol>
<li><p>You will need server-side script that will do it locally and output this list in your preferred format.</p></li>
<li><p>Most of the web-servers im... | <blockquote>
<p>Is it possible in .NET to list files on a remote location like an URL?</p>
</blockquote>
<p>You should specify which protocol we're talking about.</p>
<p>For HTTP, lubos hasko provided the answer: no. HTTP has no concept of files; only of resources. If you have control over the web server, you can a... | 3,460 |
<p>I am calling a csh script that the first thing it does is starts a new group.</p>
<p>I need to be able to see the standard output from the child process that is executed after the fork. I also want the parent process to 'hang' unitl the child process is finished.</p>
<p>Here is the script (<code>razor_from_cgwin... | <p>From your module you could call HttpContext.Current.Handler and see if it is a Page. You'd probably have to do this in the PostMapRequestHandler event or a later event in the life cycle.</p>
<p>Alternatively, maybe you can check which HttpHandlerFactory is being used for the request. If it is the PageHandlerFactory... | <p>IIS won't invoke the ASP.NET handler on images and scripts*, so a HTTPModule should only run on ASPX requests anyways.</p>
<ul>
<li>Unless you mean scripts served by as an embedded resource, ie webresource.axd.</li>
</ul>
| 35,331 |
<p>How can I get list all the files within a folder recursively in Java? </p>
| <p>Not sure how you want to represent the tree? Anyway here's an example which scans the entire subtree using recursion. Files and directories are treated alike. Note that <a href="http://docs.oracle.com/javase/6/docs/api/java/io/File.html#listFiles%28%29" rel="noreferrer">File.listFiles()</a> returns null for non-dire... | <p>In JDK7, "more NIO features" should have methods to apply the visitor pattern over a file tree or just the immediate contents of a directory - no need to find all the files in a potentially huge directory before iterating over them. </p>
| 22,932 |
<p>We have two Tables:</p>
<ul>
<li>Document: id, title, document_type_id, showon_id</li>
<li>DocumentType: id, name</li>
<li>Relationship: DocumentType hasMany Documents. (Document.document_type_id = DocumentType.id)</li>
</ul>
<p>We wish to retrieve a list of all document types for one given ShowOn_Id. </p>
<p>We ... | <p>You can use a join:</p>
<pre><code>SELECT DISTINCT DocumentType.*
FROM DocumentType
INNER JOIN Document
ON DocumentType.id=Document.document_type_id
WHERE Document.showon_id = 42
</code></pre>
<p>I think it's the best way to do it.</p>
| <p>Follow up on <a href="https://stackoverflow.com/questions/181930/ms-sql-2k5-performance-distinct-or-full-table-in-where-in-statement#183155">Matt's answer</a>:</p>
<p>I've enabled the query plan and tested the following four different queries that have come up so far:</p>
<ul>
<li><p><code>SELECT DocumentType.* FR... | 21,975 |
<p>When writing j2me applications for cellphones, using <code>System.out.println()</code> prints on the console if using an emulator. However, when the code is deployed on a cellphone, where does the console output go?</p>
<p>If it is impossible to see this in the untethered cellphone, is there a way to see it if the ... | <p>I found <a href="https://stackoverflow.com/questions/120618/logging-in-j2me">this question</a> with answers on j2me logging. Maybe one can try this if nothing else works. A simple way to access <code>System.out.println()</code> would be nice though.</p>
| <p>The only input I can offer is that this will differ greatly on each platform. I work mainly with BlackBerrys and System.err goes to the devices event log but I have no idea where System.out goes.</p>
| 15,453 |
<p>I have the whole MVC-Model set up and use HTML views as templates. But I have german strings in there that I would like to translate to other languages at some point.</p>
<p>What is the best way to do this? I know I have to use Zend_Translate, but do I have to implement a single call to a translate function for eve... | <p>First of all, I'd suggest to use complete phrases as the basis for your translation. With words you always have the problem that languages are not consistent when it comes to sentence structure. </p>
<p>Then you have to choose one of the available Zend_Transalate adapters: Array, Csv, Gettext, Ini, Tbx, Tmx, Qt, X... | <p>No, you don't have to translate every single word. The idea of translation in this sense is more a of a message translation idea.</p>
<p>In my current project we do two types of translations. When it's just going to be a short text, we type that directly into the source code for purposes of readability.</p>
<p>I.E... | 39,537 |
<p>I have a table similar to this:</p>
<pre><code>CREATE TABLE example (
id integer primary key,
name char(200),
parentid integer,
value integer);
</code></pre>
<p>I can use the parentid field to arrange data into a tree structure.</p>
<p>Now here's the bit I can't work out. Given a parentid, is it possible ... | <p>There are a few ways to do what you need in PostgreSQL.</p>
<ul>
<li><p>If you can install modules, look at the tablefunc contrib. It has a connectby() function that handles traversing trees. <a href="http://www.postgresql.org/docs/8.3/interactive/tablefunc.html" rel="noreferrer">http://www.postgresql.org/docs/8.3/... | <p>If you need to store arbitrary graphs, not just hierarchies, you could push Postgres to the side and try a graph database such as <a href="http://agraph.franz.com/support/learning/" rel="nofollow noreferrer">AllegroGraph</a>:</p>
<p>Everything in the graph database is stored as a triple (source node, edge, target n... | 7,653 |
<p>I've been making my way through <em>The Little Schemer</em> and I was wondering what environment, IDE or interpreter would be best to use in order to test any of the Scheme code I jot down for myself.</p>
| <p><a href="http://racket-lang.org/" rel="noreferrer">Racket</a> (<a href="http://racket-lang.org/new-name.html" rel="noreferrer">formerly Dr Scheme</a>) has a nice editor, several different Scheme dialects, an attempt at visual debugging, lots of libraries, and can run on most platforms. It even has some modes specifi... | <p>LispMe works on a Palm Pilot, take it anywhere, and scheme on the go. GREAT way to learn scheme.</p>
| 8,402 |
<p>I've got many assemblies/projects in the same c#/.net solution. A setting needs to be saved by people using the web application gui, and then a console app and some test projects need to access the same file. Where should I put the file and how to access it?</p>
<p>I've tried using "AppDomain.CurrentDomain.BaseDire... | <p>Put the file in </p>
<pre><code> Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
"[Company Name]\[Application Suite]");
</code></pre>
| <p>Thought about storing it in the registry or in Isolated Storage? Not sure if multiple applications can share Isolated Storage or not, though.</p>
| 12,665 |
<p>This is a 3 part question regarding embedded RegEx into SQL statements. </p>
<ol>
<li><p>How do you embed a RegEx expression into an Oracle PL/SQL
select statement that will parse out
the “DELINQUENT” string in the text
string shown below?</p></li>
<li><p>What is the performance impact if used within a
mission crit... | <p>Why would you need regular expressions here?
INSTR and SUBSTR will do the job perfectly.</p>
<p>But if you convinced you need Regex'es you can use:</p>
<p><a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions129.htm#i1239887" rel="nofollow noreferrer">REGEXP_INSTR</a><br>
<a href="http:... | <p>Why not just use INSTR (for Oracle) or CHARINDEX (for SQL Server) combined with SUBSTRING? Seems a bit more straightforward (and portable, since it's supported in older versions).</p>
<p><a href="http://www.techonthenet.com/oracle/functions/instr.php" rel="nofollow noreferrer">http://www.techonthenet.com/oracle/fun... | 9,868 |
<p>I'm considering one of two IRepository interfaces, one that is a descendant of IQueryable and one that contains IQueryable. </p>
<p>Like this:</p>
<pre><code>public interface IRepository<T> : IQueryable<T>
{
T Save(T entity);
void Delete(T entity);
}
</code></pre>
<p>Or this:</p>
<pre><code>p... | <p>Depends on if you want a Has-A or an Is-A relationship.</p>
<p>The first one is an Is-A relationship. The IRepository interface is a IQueryable interface. The second is a has-a. The IRepository has an IQueryable interface. In the process of writing this, I actually like the second better then the first, simply ... | <p>You could always quick write stuff against List, it's not mocking using a mock framework, but it sure works great.</p>
| 19,864 |
<p>I have seen two ways of implementing DAO-DVO design.</p>
<p>1) DVO are objects and DAOs are instantiated using factories i.e DAOs are also objects
2) DVOs are again objects but in this case, DAOs are classes which contain only static methods which accept DVOs to perform tasks.</p>
<p>I was wondering which way is b... | <p>Try the Spring Framework. DAOs are initialized via Dependency Injection and are just plain 'ole Java objects.</p>
<p>Then, the methods on the DAO should just use Domain Objects that are used at all layers of the Application.</p>
| <p>I would strongly recommend not using that many layers unless they are really layered physically. eg if you have something like a rich client where you need to send detached objects to update the GUI, otherwise, its a world of pain.</p>
| 4,428 |
<p>We have an <a href="http://www.r-project.org" rel="nofollow noreferrer">R Server</a>
(R is a programming language used in statistical analysis) that basically takes a script and a csv file, processes some data and returns results as text.</p>
<p>I need to write a service on the R server so that .net clients (could... | <p>Personally, I'd recommend the simplest binding that gives what you need. I've done quite a lot of WCF (some quite complex), and I've never had to use anything other than BasicHttpBinding; this also allows that greatest possible compatibility with non-.NET clients, and lets you use things like MTOM for efficient bina... | <p>Extract from the book WCF4 of wros " All these built-in bindings are built on standars that work for specific scenarios, but will also work i you choose the wrong or less-efficient one. So how do you choose hich one is right for you?</p>
<p>The most obvious decisión s if you need to interact with non-WCF applicatio... | 29,418 |
<p>I know that to find all the <code>.h</code> files I need to use:</p>
<pre><code>find . -name "*.h"
</code></pre>
<p>but how to find all the <code>.h</code> AND <code>.cpp</code> files?</p>
| <pre><code>find . -name \*.h -print -o -name \*.cpp -print
</code></pre>
<p>or</p>
<pre><code>find . \( -name \*.h -o -name \*.cpp \) -print
</code></pre>
| <pre><code>find . -regex ".*\.[cChH]\(pp\)?" -print
</code></pre>
<p>This tested fine for me in cygwin.</p>
| 35,093 |
<p>Address records are probably used in most database, but I've seen a number of slightly different sets of fields used to store them. The number of fields seems to vary from 3-7, and sometimes all fields are simple labelled address1..addressN, other times given specific meaning (town, city, etc).</p>
<p>This is UK sp... | <p>The Post Office suggests (<a href="http://www.postoffice.co.uk/portal/po/content1?catId=19100182&mediaId=19100267" rel="noreferrer">http://www.postoffice.co.uk/portal/po/content1?catId=19100182&mediaId=19100267</a>) 7 lines: </p>
<ul>
<li>Addressees Name </li>
<li>Company/Organisation</li>
<li>Building Name... | <p>It's very likely that a "UK" will be opened to Eire as well, and in some lines of business there will be legal differences, generally between Scotland / NI / the channel islands and England and Wales.</p>
<p>In short, I would add country to the list. Otherwise it's fine (no fewer certainly), though of course any ad... | 48,784 |
<p>I code C++ using MS Dev Studio and I work from home two days per week. I use CVS to keep my sources synchronized between the two computers but there are difference between the environments the machines are in.</p>
<p>Can anyone suggest a way I can conditionally modify constants in my code depending on whether I am ... | <p>On your home and work machines, set an environment variable <code>LOCATION</code> that is either "1" for home or "2" for work.</p>
<p>Then in the preprocessor options, add a preprocessor define /DLOCATION=$(LOCATION). This will evaluate to either the "home" or "work" string that you set in the environment variable.... | <p>I generally use config files, then just create a symlink to the appropriate configuration.</p>
| 14,489 |
<p>I have the following intentionally trivial function:</p>
<pre><code>void ReplaceSome(ref string text)
{
StringBuilder sb = new StringBuilder(text);
sb[5] = 'a';
text = sb.ToString();
}
</code></pre>
<p>It appears to be inefficient to convert this to a StringBuilder to index into and replace some of the... | <p>C# strings are "immutable," which means that they can't be modified. If you have a string, and you want a similar but different string, you must create a new string. Using a StringBuilder as you do above is probably as easy a method as any.</p>
| <p>I don't know if this is more efficient, but it works. Either way you'll have to recreate the string after each change since they're immutable.</p>
<pre><code> string test = "hello world";
Console.WriteLine(test);
test = test.Remove(5, 1);
test = test.Insert(5, "z");
Console.WriteLine(test);
</c... | 30,437 |
<p>How to copy file(s) from one solaris 9 machine to another solaris 9 machine using only java?</p>
<p>We have ssh access to both machines. The java program will run on one of those two machines.</p>
<p>Update: rsync is not really an option. can't install it easily (UNIX team is, hum, hard to deal with)</p>
| <p>.NET doesn't provide all Cultures/Regions out-of-the-box. Note the 'predefined' RegionInfos here: <a href="http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo(VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo(VS.80).aspx</a>. </p>
<p>Unfortunat... | <p><strike>Some</strike>All of the regions you missed are now supported (in newer versions of the .NET Framework and of the operating system).</p>
<p>The following code finds all <code>RegionInfo</code> that are "reachable" from a specific culture:</p>
<pre><code>foreach (var ri in CultureInfo.GetCultures(CultureType... | 27,611 |
<p>When creating a string using the following notation:</p>
<pre><code>NSString *foo = @"Bar";
</code></pre>
<p>Does one need to release <code>foo</code>? Or is <code>foo</code> autoreleased in this case?</p>
| <p>Compiler allocated strings (of the format @"STRING") are constant, and so -retain, -release, and -autorelease messages to them are ignored. You don't have to release or autorelease foo in this case (but it won't hurt).</p>
| <p>I agree with @Ben\ Gottlieb at "Compiler allocated strings (of the format @"STRING") are constants" but as you have not initialized them via passing an <code>alloc</code> or <code>retain</code> message, you must not pass <code>release</code> or <code>autorelease</code> message to them otherwise your app will crash w... | 42,748 |
<p>I have a user control where the XAML of the control can bind to the appropriate properties from the parent's data context like normal (the data context propagates in xaml). </p>
<p>For example, I have a window whose DataContext I am setting to ObjectA for example. My user control within the window is then try to ac... | <p>failing that if you need to check whether the DataContext is being set you can use the DataContextChanged</p>
<pre><code>public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
DataContextChanged += new DependencyPropertyChangedEventHandler(UserContr... | <p>I think you are checking the 'DataContext' in the constructor of the UserControl. It will be null at the Constructor since the user control hasnt yet created while execution is in the constructor code. But check the property at Loaded event you will see the object properly.</p>
<pre><code>public partial class UserC... | 37,910 |
<p>I have a weird issue. I had a web service that was compiled under the 2.0 framework that was being consumed by a windows app that was compiled with the 1.1 framework. This worked just fine. Now, after upgrading the web service to the 3.5 framework, the windows app is no longer able to call it.</p>
<p>Creating a litt... | <p>Try 'rediscover' the web service in .NET 1.1 (possibly just a test app) and see if the problem persists.</p>
| <p>Can you go the the web service directly on the IIS installation? If not, check the application configuration in IIS. You must switch the version of ASP.NET.</p>
| 34,262 |
<p>I have two characters displayed in a game I am writing, the player and the enemy. defined as such:</p>
<pre><code>public void player(Graphics g) {
g.drawImage(plimg, x, y, this);
}
public void enemy(Graphics g) {
g.drawImage(enemy, 200, 200, this);
}
</code></pre>
<p>Then called with:</p>
<pre><code>play... | <p>I think your problem is that you are not using good OO design for your player and enemies. Create two classes:</p>
<pre><code>public class Player
{
int X;
int Y;
int Width;
int Height;
// Getters and Setters
}
public class Enemy
{
int X;
int Y;
int Width;
int Height;
// Ge... | <p>Use a rectangle to surround each player and enemy, the height and width of the rectangles should correspond to the object you're surrounding, imagine it being in a box only big enough to fit it.</p>
<p>Now, you move these rectangles the same as you do the objects, so they have a 'bounding box'</p>
<p>I'm not sure ... | 43,534 |
<p>I have a collection of ClickOnce packages in a publish folder on a network drive and need to move them all to another server (our DR machine). </p>
<p>After copy/pasting the whole directory and running the setups on the new machine I get an error message stating that it cannot find the old path:</p>
<blockquote>
... | <p>I found a solution:</p>
<p>Firstly, using MageUI, I changed the "Start Location" under "Deployment Options". On saving, it prompted me to sign with a key, which I created there and then. I then ran the <code>setup.exe</code> file, and it worked without fail.</p>
<p>After checking which files had ... | <p>I believe that you do have a certificate. You need one to create a ClickOnce deployment. Visual Studio may have autocreated a self-signed one for you. I'm not too familiar with the process, hopefully someone with a more definitive answer will chip in. Also, have you tried the MageUI tool, maybe it will be more obv... | 21,067 |
<p>I realize there is a somewhat related thread on this here:
<a href="https://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies">Loading assemblies and its dependencies</a></p>
<p>But I am modifying something and this doesn't exactly apply. </p>
<pre><code>string path = Path.GetDirectoryName... | <p>Looks like the "Department of Redundancy Department."</p>
<p>A lot more code than is necessary. Less is more!</p>
<p><strong>Edit:</strong> On second thought, it could be that the assembly you are loading has dependencies that live in its own folder that may be required to use the first assembly. </p>
| <p>This can be necessary when you are developping a windows service. The working dir of a service defaults to %WinDir%, so if you want to load an assembly from the dir that your service exe resides in, this is the way to go.</p>
| 16,466 |
<p>I'm relatively new to Nant, what i'd like to do is have a task that creates a new Website and AppPool in IIS6</p>
<p>is there a way to do this in Nant?</p>
<p>Essentially the task would need to set all the appropriate properties including the correct version of the .net Framework</p>
<p>Ideally i'd also like to c... | <p>Have you looked at <a href="http://nantcontrib.sourceforge.net/" rel="nofollow noreferrer">NantContrib</a>? It might provide some better IIS support without having to write your own task (or shelling out).</p>
<p>It has some IIS specific tasks like <a href="http://nantcontrib.sourceforge.net/release/latest/help/tas... | <p>You can do this from the command line using ADSUTIL, you can find more information here:</p>
<p><a href="http://blogs.msdn.com/david.wang/archive/2007/12/12/howto-create-custom-application-pool-by-commandline.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/david.wang/archive/2007/12/12/howto-create-custom-app... | 29,095 |
<p>After reading <a href="https://stackoverflow.com/questions/4689/recommended-fonts-for-programming">this</a> question I installed Consolas. The trouble is, now the text seems too small. I have to adjust it to size 12 to use it comfortably. Anyone else experience this when switching to Consolas (or any other font)?... | <p>I use Consolas, 11pt on my 1440x900 laptop (Windows XP). I've been using 10pt for some time but I found myself having eye strain so I've set 11pt for all the development tools, editors and shells I'm using. </p>
<p>I would, however, be much hapier if 11pt Consolas would be a little smaller. I don't like that big di... | <p>I use consolas 9 pt @ 1280x800, 15.4 inch monitor (laptop)</p>
| 21,591 |
<p>I am creating a large table dynamically using Javascript.
I have realised the time taken to add a new row grows exponentially as the number of rows increase.</p>
<p>I suspect the Page is getting refreshed in each loop per row (I am also adding input elements of type text on each cell)</p>
<p>Is there a way to stop... | <p>You can create the table object without adding it to the document tree, add all the rows and then append the table object to the document tree. </p>
<pre><code>var theTable = document.createElement("table");
// ...
// add all the rows to theTable
// ...
document.body.appendChild(theTable);
</code></pre>
| <p>Did you try the <tbody> tag when you create the table?
It is possible browsers optimize that and don't "refresh" the table while populating it.</p>
| 40,544 |
<p>I have two directories in the same parent directory. Call the parent directory <strong>base</strong> and the children directories <strong>alpha</strong> and <strong>bravo</strong>. I want to replace <strong>alpha</strong> with <strong>bravo</strong>. The simplest method is:</p>
<pre><code>rm -rf alpha
mv bravo a... | <p>The final solution is combining the symlink- and the rename-approach:</p>
<pre><code>mkdir alpha_real
ln -s alpha_real alpha
# now use "alpha"
mkdir beta_real
ln -s beta_real tmp
# atomically rename "tmp" to "alpha"
# use -T to actually replace "alpha" instead of moving *into* "alpha"
mv -T tmp alpha
</code></p... | <p>Why don't you just do something like:</p>
<pre><code>rm -rf alpha/*
mv bravo/* alpha/
rm -rf bravo/
</code></pre>
<p>That would mean that everything <em>in</em> alpha is destroyed, alpha <em>never</em> gets deleted, and all the contents get moved.</p>
| 39,567 |
<p><strong>Motivation</strong></p>
<p>I'd like to find a way to take an arbitrary color and lighten it a few shades, so that I can programatically create a nice gradient from the one color to a lighter version. The gradient will be used as a background in a UI.</p>
<p><strong>Possibility 1</strong></p>
<p>Obviously ... | <p>I would go for the second option. Generally speaking the RGB space is not really good for doing color manipulation (creating transition from one color to an other, lightening / darkening a color, etc). Below are two sites I've found with a quick search to convert from/to RGB to/from HSL:</p>
<ul>
<li><a href="http:... | <p>I would have tried number #1 first, but #2 sounds pretty good. Try doing it yourself and see if you're satisfied with the results, it sounds like it'll take you maybe 10 minutes to whip up a test.</p>
| 17,145 |
<p>I have a DataGridViewComboBoxColumn in a DataGridView that's based on a lookup table.</p>
<p>The ValueMember and DisplayMember fields are bound to string columns in the DataTable. All rows have a value for both fields - except for a special record where the value field is deliberately set to NULL.</p>
<p>However, ... | <p>Well, I did come up with <em>a</em> solution. Because the DataGridView is data bound, I implemented the ColumnChanging event for the DataTable. Sample code:</p>
<pre><code>void Schedule_ColumnChanging(object sender, DataColumnChangeEventArgs e)
{
if
(
e.Column.ColumnName == "Site" &&
... | <p>I use a typed dataset to provide the values for the dropdown. After filling values from the database I add <em>another</em> row to provide the null support. The final lines of the method that populates the datatable look like this...</p>
<pre><code>// Fill dt from datatable...
var nullRow = rv.NewRunDropDownEntry... | 43,599 |
<p>Which ftp client or which syntax allows easy chmod for sub-directories?</p>
| <p>LFTP allows for recursive CHMOD if the client allows it. You can accomplish this by logging in with LFTP from a Unix/Linux CLI and then run the following:</p>
<pre><code>chmod -R 0755 /www/directory/*
</code></pre>
<p>You could also setup a real nifty Bash script for this:</p>
<pre><code>#!/bin/bash
lftp <<... | <p>To chmod all subdirs from where you are (recursive):</p>
<pre><code>chmod -R *
</code></pre>
| 40,982 |
<p>I have already posted something similar <a href="https://stackoverflow.com/questions/118051/c-grid-binding-not-update">here</a> but I would like to ask the question more general over here.</p>
<p>Have you try to serialize an object that implement INotifyPropertyChanged and to get it back from serialization and to b... | <p>Use the <code>DataContractSerializer</code> and create a method for OnDeserialized</p>
<pre><code>[OnDeserialized]
private void OnDeserialized(StreamingContext c) {}
</code></pre>
<p>This will let you raise the PropertyChanged event when deserialization is complete</p>
| <p>The trick of having it's own <a href="https://stackoverflow.com/questions/118051/c-grid-binding-not-update#118438">Event and binding it after serialization</a> works but is not elegant because require an other event that I would not like to have...</p>
| 14,901 |
<p>I have a table with columns</p>
<blockquote>
<p>Index, Date</p>
</blockquote>
<p>where an Index may have multiple Dates, and my goal is the following: select a list that looks like</p>
<blockquote>
<p>Index, MinDate, MaxDate</p>
</blockquote>
<p>where each Index is listed only once, and MinDate (MaxDate) rep... | <p>I would recommend a derived table approach. Like this:</p>
<pre><code>SELECT
myTable.Index,
MIN(myTable.[Date]),
MAX(myTable.[Date])
FROM myTable
Inner Join (
SELECT Index
From myTable
WHERE [Date] BETWEEN '1/1/2000' AND '12/31/2000') As AliasName
On myTable.Index... | <p>You don't need the sub-select in the where clause. Also, you could add indexes to the date column. How many rows in the table?</p>
<pre><code>SELECT
[INDEX],
MIN ( [Date] ),
MAX ( [Date] )
FROM
myTable
WHERE
[Date] Between '1/1/2000' And '12/31/2000'
GROUP BY
[Index]
ORDER BY
[INDEX] ... | 31,707 |
<p>I thought 2048 security violation error were mean to happen when trying to access other domains. </p>
<p>I got:</p>
<p><strong>"Security sandbox violation: <a href="http://127.0.0.1/site_media/main.swf" rel="nofollow noreferrer">http://127.0.0.1/site_media/main.swf</a> cannot load data from 127.0.0.1:80"</strong>,... | <p>Despite being called "crossdomain" policy files, the policy actually applies to the combination of both the domain and port: localhost:80 and localhost:443 are not the same thing as far as FP's security policy is concerned. I also don't think that the Flash Player itself assumes a default port of 80 so "localhost" ... | <p>Try using, localhost. If that doesn't work just create a crossdomain file.</p>
| 47,728 |
<p>Inspired by the MVC storefront the latest project I'm working on is using extension methods on IQueryable to filter results.</p>
<p>I have this interface;</p>
<pre><code>IPrimaryKey
{
int ID { get; }
}
</code></pre>
<p>and I have this extension method</p>
<pre><code>public static IPrimaryKey GetByID(this IQuer... | <p>It works, when done right. cfeduke's solution works. However, you don't have to make the <code>IPrimaryKey</code> interface generic, in fact, you don't have to change your original definition at all:</p>
<pre><code>public static IPrimaryKey GetByID<T>(this IQueryable<T> source, int id) where T : IPrimar... | <p>This cannot work due to the fact that generics don't have the ability to follow inheritance patterns. ie. IQueryable<SimpleObj> is not in the inheritance tree of IQueryable<IPrimaryKey></p>
| 10,820 |
<p>I want my Python script to copy files on Vista. When I run it from a normal <code>cmd.exe</code> window, no errors are generated, yet the files are NOT copied. If I run <code>cmd.exe</code> "as administator" and then run my script, it works fine.</p>
<p>This makes sense since User Account Control (UAC) normally pre... | <p>As of 2017, an easy method to achieve this is the following:</p>
<pre><code>import ctypes, sys
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if is_admin():
# Code of your program here
else:
# Re-run the program with admin rights
ctypes.w... | <p>If your script always requires an Administrator's privileges then: </p>
<pre><code>runas /user:Administrator "python your_script.py"
</code></pre>
| 15,882 |
<p>Quick question. What do you think, I have a few sites that use a 3 level drop-down menu that will be broken if IE8 released with its current CSS standards in IE8 beta2. So do I take the time to redo those drop downs now? I realize that the way they rendered CSS changed completely between beta 1 and 2, but 2 was/is ... | <p>You can add the meta tag to force IE7 compatible rendering. Your site continues to work, no changes are made to the web site and life is happy for everyone.</p>
<p>That said, i'm curious about the "forced to properly handle CSS" bit; IE8 has been pretty big win for CSS standards, but I could be missing the bandwago... | <p>Personally I find that it really depends on the audience, and the level of effort needed to fix the issue.</p>
<p>If I can make a quick, couple hour fix to make it compliant, even if it is for a small subset of users, great! However, if it is much more involved, then I start to balance the potential adoption rate,... | 22,791 |
<p>Is there a way to check if a file has been opened by ReWrite in Delphi? </p>
<p>Code would go something like this:</p>
<pre><code>AssignFile(textfile, 'somefile.txt');
if not textFile.IsOpen then
Rewrite(textFile);
</code></pre>
| <p>You can get the filemode. (One moment, I'll create an example).</p>
<p>TTextRec(txt).Mode gives you the mode:</p>
<pre><code>55216 = closed
55217 = open read
55218 = open write
fmClosed = $D7B0;
fmInput = $D7B1;
fmOutput = $D7B2;
fmInOut = $D7B3;
</code></pre>
<p>Search TTextRec in the system unit for more inf... | <p>Joseph's answer works perfectly - I called the function <code>filenotopen</code> and changed the line if </p>
<pre><code>Result := (HFileRes = INVALID_HANDLE_VALUE);
</code></pre>
<p>to</p>
<pre><code>Result := NOT (HFileRes = INVALID_HANDLE_VALUE);
</code></pre>
<p>I also removed the line 'if not(Result) then b... | 17,069 |
<p>To summarize, as we all know,</p>
<p>a) Silverlight is expected to be hosted by a browser, and runs in an isolated sandbox so that there won’t be any security issues</p>
<ol>
<li>Silverlight don’t have direct access
to the file system, other than the
isolated storage area </li>
<li>There is no
direct way to op... | <p>Two ways I can think about is,</p>
<p><strong>Create a "Shell"</strong></p>
<p>Host the HTML Page with Silverlight, in a Winforms desktop application, using a web browser control, and communicate to and fro using HTML DOM. Then I can request the hosted shell to do things like printing. <a href="http://amazedsaint.... | <p>I am attempting to also reuse a codebase for both desktop and silverlight. There are two options that I know of in addition to the ones mentioned</p>
<p>If you directly reference (instead of a project reference) a silverlight dll from a normal project, it should work. This would let you reference a silverlight dll... | 47,991 |
<p>What would be a very fast way to determine if your connectionstring lets you connect to a database?</p>
<p>Normally a connection attempt keeps the user waiting a long time before notifying the attempt was futile anyway.</p>
| <p>You haven't mentioned what database you are connecting to, however. In <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005" rel="nofollow noreferrer">SQL Server 2005</a>, from .NET, you can specify a connection timeout in your connection string like so:</p>
<pre><code>server=<server>;da... | <p>Shorten the timeout on the connection string and execute something trivial.</p>
<p>The wait should be about the same as the timeout.</p>
<p>You would still need a second or two though.</p>
| 3,199 |
<p>How would I reset the primary key counter on a sql table and update each row with a new primary key?</p>
| <p>I would add another column to the table first, populate that with the new PK.</p>
<p>Then I'd use update statements to update the new fk fields in all related tables.</p>
<p>Then you can drop the old PK and old fk fields.</p>
<p><strong>EDIT:</strong> Yes, as Ian says you will have to drop and then recreate all f... | <p>If this is Microsoft's SQL Server, one thing you could do is use the <strong>[dbcc checkident](<a href="http://msdn.microsoft.com/en-us/library/ms176057(SQL.90).aspx)" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms176057(SQL.90).aspx)</a></strong></p>
<p>Assume you have a single table that you... | 28,470 |
<p>I have an XML file loaded into a DOM document,
I wish to iterate through all 'foo' tags, getting values from every tag below it. I know I can get values via </p>
<pre><code>$element = $dom->getElementsByTagName('foo')->item(0);
foreach($element->childNodes as $node){
$data[$node->nodeName] = $node-... | <p>Not tested, but what about:</p>
<pre><code>$elements = $dom->getElementsByTagName('foo');
$data = array();
foreach($elements as $node){
foreach($node->childNodes as $child) {
$data[] = array($child->nodeName => $child->nodeValue);
}
}
</code></pre>
| <p>With <a href="https://github.com/servo-php/fluidxml" rel="nofollow"><strong>FluidXML</strong></a> you can query and iterate XML very easly.</p>
<pre><code>$data = [];
$store_child = function($i, $fooChild) use (&$data) {
$data[] = [ $fooChild->nodeName => $fooChild->nodeValue ];
};
fluidxml($dom)... | 23,314 |
<p>Application frameworks such as DotNetNuke, Eclipse, Websphere and so forth are available today which offer customizable frameworks that can be used as dashboard applications. Do you use these or do you and your peers keep writing amazing, modular, maintainable dashboard frameworks which you support yourselves?</p>
... | <p>The one I use is Oracle Application Development Framework. It's a complete, fully supported framework, and Oracle use it themselves to build their own enterprise applications. It comes with a lot of JSF components that are very easy to bind to the underlying data objects.
I'd recommend this for all Java application... | <p>At work, we try to create from scratch as little as possible. We use Frameworks a lot (maybe not always end to end frameworks). We have used Dot Net Nuke a lot. Another framework we use a lot is CSLA.</p>
| 10,565 |
<p>I have a project with several sources directories : </p>
<pre><code>src/A
/B
/C
</code></pre>
<p>In each, the Makefile.am contains </p>
<pre><code>AM_CXXFLAGS = -fPIC -Wall -Wextra
</code></pre>
<p>How can avoid repeating this in each source folder ? </p>
<p>I tried to modifiy src/Makefile.am and the conf... | <p>You can do several things:</p>
<p>(1) One solution is to include a common makefile fragment on all your <code>Makefile.am</code>s:</p>
<pre><code>include $(top_srcdir)/common.mk
...
bin_PROGRAMS = foo
foo_SOURCES = ...
</code></pre>
<p>in that case you would write</p>
<pre><code>AM_CXXFLAGS = -fpic -Wall -Wextra... | <p>Use EXTRA_CFLAGS in configure.ac</p>
<p>For example for your case it would be this:</p>
<p><code>EXTRA_CFLAGS=-fPIC -Wall -Wextra</code></p>
| 41,922 |
<p>Is there any alternative image manipulation library for .net? I would prefer something that is managed and open source. </p>
<p>I ask this because of two reasons:</p>
<ol>
<li>I have encountered hard to debug GDI+ errors with System.Drawing in the past</li>
<li>I have read that using System.Drawing in asp.net web... | <p>I don't know of any fully-managed 2D drawing libraries that are either free or open-source (there appears to be a few commercially available, but OSS is the way to go). However, you might look into <a href="http://www.go-mono.com/docs/index.aspx?tlink=0@N:Cairo" rel="nofollow noreferrer">the Mono bindings to Cairo<... | <p>With respect to (1), most of the hard to debug errors are due to not closing open handles (Dispose() in managed-land). I'm curious where you heard (2).</p>
| 3,426 |
<p>I need a tool that handle both on-screen and printed reports, via my C# application. </p>
<p>I'm looking for simple, standard and powerful. </p>
<p>I need to be able to give the user the ability to select which columns to display, formatting, etc... with my own GUI and dynamically build the report based upon their... | <p>We use SQL reporting services. HTML reports have their place but you dont get very much controlling over formatting.
<BR></p>
<p>SQL reporting services summary:</p>
<p>Advantages:<BR>
Basic version is free<BR>
Included with SQL express<BR>
Many exporting options pdf, html, csv etc<BR>
Can use many different datas... | <p>I'm currently considering DevXpress XtraReports as a replacement for CR. So far I like what I see.</p>
| 19,887 |
<p>What's the point in the standard pattern for event delegates in .net? I.e. the EventHandler predefined delegate? Why not just choose the most appropriate signature for the requirement?</p>
<p>Edit: And furthermore, is it necessary to slavishly follow Microsoft's example in all cases?</p>
| <p>It's mainly for consistency and versioning—with the <code>sender</code> paramater as always System.Object and the <code>args</code> parameter as always a System.EventArgs, or a dervied class thereof, you can change the sender argument passed to it as well as change the EventArgs type afterwards without breaking any ... | <p>It decouples the caller from the callee.</p>
| 30,708 |
<p>I have some Ruby code which takes dates on the command line in the format:</p>
<pre><code>-d 20080101,20080201..20080229,20080301
</code></pre>
<p>I want to run for all dates between <code>20080201</code> and <code>20080229</code> inclusive and the other dates present in the list.</p>
<p>I can get the string <cod... | <p>But then just do </p>
<pre><code>ends = '20080201..20080229'.split('..').map{|d| Integer(d)}
ends[0]..ends[1]
</code></pre>
<p>anyway I don't recommend eval, for security reasons</p>
| <p>Combining @Purfideas answer with another answer somewhere on StackOverflow, I solved this by also surrounding the code with an input check, so the only thing used is a valid enumerable </p>
<pre><code>if !value[/^[0-9]+\.\.[0-9]+$/].nil?
ends = value.split('..').map{|d| Integer(d)}
value = ends[0]..ends[1]
... | 7,692 |
<p>I have a ARM11 based hardware board which runs a Linux kernel ver. 2.6.21.5-cfs-v19. I have my application running on this ARM-LINUX board. To do source level debugging, of my application I used to use gdb from command prompt of the linux board, that was with some earlier version of the board linux version. </p>
<p... | <p>Sometime ago I published an <a href="http://www.linux.com/feature/121735" rel="nofollow noreferrer">article</a> about cross-target debugging with GDB and GDBServer. The target processor there is PPC7450, but it's rather detailed, so maybe you'll find it useful.</p>
| <p>You might have some luck using <a href="http://wiki.openembedded.net/index.php/Main_Page" rel="nofollow noreferrer">OpenEmbedded</a>. If there's no precompiled version you can use right away, setting up an OE-cross compile environment is not that hard. </p>
<p>Another option could be to install gdb-server on the bo... | 7,457 |
<p>This question is directed to the non-english speaking people here.</p>
<p><em>It is somewhat biased because SO is an "english-speaking" web forum, so... In the other hand, most developers would know english anyway...</em></p>
<p>In your locale culture, are technical words translated into locale words ? For... | <p>Coming from Switzerland and speaking German I vote for keeping them in English. I have been at an IBM congress some time back (OS/2 0.9 developpers conference, I0m giving away my age here). At that time most people were not as familiar with the names of interface components (combobox, listbox, button) as they are to... | <p>What I normally do is to danish-sify (I'm from denmark), or use the danish words for IT terms when talking to business people, or normal non-it people. If it is IT people i just use the english terms.</p>
| 13,617 |
<p>I was going to Ask a Question earlier today when I was presented to a surprising functionality in Stackoverflow. When I wrote my question title stackoverflow suggested me several related questions and I found out that there was already two similar questions. That was stunning! </p>
<p>Then I started thinking how I ... | <p>One such way to implement such an algorithm would involve ranking the questions as per a heuristic function which assigns a 'relevance' weight factor using the following steps:</p>
<ol>
<li>Apply a noise filter to the 'New' question to remove words that are common across a large number of objects such as: 'the', 'a... | <p>Isn't StackOverflow going to be open sourced at some point? If so, you can always find out how they did it there.</p>
<p>Update: It appears that they say they <em>might</em> open source it. I hope they do.</p>
| 6,399 |
<p>I have a problem to connect to my WCF service if customer is using proxy with credentials. I'm unable to find the way to set credential to generated client proxy. </p>
<p>If I use the web service, then it is possible to set proxy. </p>
| <p>I'm not entirely sure if this is what you are looking for but here you go.</p>
<pre><code> MyClient client = new MyClient();
client.ClientCredentials.UserName.UserName = "u";
client.ClientCredentials.UserName.Password = "p";
</code></pre>
| <p>Not sure if this is what you are looking for but the below is a working code sample to authenticate using the client credentials.</p>
<pre><code> Dim client As ProductServiceClient = New ProductServiceClient("wsHttpProductService")
client.ClientCredentials.UserName.UserName = "username"
client.ClientCred... | 13,094 |
<p>How can I call a C++ function from C# .NET?</p>
| <ol>
<li><p>compile the C++ function into a dll and <a href="http://msdn.microsoft.com/en-us/magazine/cc164123.aspx" rel="nofollow noreferrer">use P/Invoke</a></p>
<p>or</p>
</li>
<li><p>compile the C++ function into a C++/CLI assembly, wrap in a managed C++ class, and then treat like any other assembly (add a referenc... | <p>Or</p>
<p>Create a COM wrapper and then reference it from .NET</p>
| 35,998 |
<p>Can you use the bash "getopts" function twice in the same script?</p>
<p>I have a set of options that would mean different things depending on the value of a specific option. Since I can't guarantee that getopts will evaluate that specific option first, I would like to run getopts one time, using only that specifi... | <p>Yes, just reset OPTIND afterwards.</p>
<pre><code>#!/bin/bash
set -- -1
while getopts 1 opt; do
case "${opt}" in
1) echo "Worked!";;
*) exit 1;
esac
done
OPTIND=1
set -- -2
while getopts 2 opt; do
case "${opt}" in
2) echo "Worked!";;
*) exit 1;
esac
done
</code></pr... | <p>getopts does not modify the original arguments, as opposed to the older getopt standalone executable. You can use the bash built-in getopts over and over without modifying your original input.</p>
<p>See the bash man page for more info.</p>
<p>HTH.</p>
<p>cheers,</p>
<p>Rob</p>
| 17,467 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.