input
stringlengths
51
42.3k
output
stringlengths
18
55k
How are you generating tests from specifications? <p>I came across a printed <a href="http://www.eiffel.com/general/column/2008/02.html" rel="nofollow">article by Bertrand Meyer</a> where he states that tests can be generated from specifications. My development team does nothing like this, but it sounds like a good tec...
<p>This might be a reference to <a href="http://rspec.info/" rel="nofollow">RSpec</a>, which is a really clever way of developing tests as a series of requirements. I'm still getting used to it, but it's been very handy in both defining what I need to do and then ensuring I do it.</p>
SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies <p>I am trying to get the DB2 data provider from a 32-bit .Net application to connect to DB2 running as a 32-bit application on Vista 64 (is that confusing enough yet)? Unfortunately, I am gett...
<p>Are you required to have it run as x86? I had similar issues with web apps under Visual Studio's dev web server (which is x86), but switching over to IIS (x64) worked for me. Since I was deploying to IIS x64, I called it a day at that point.</p> <p>I tried tracing with Filemon and Regmon, but didn't get any denied ...
Stop the taskbar flashing <p>I know I can programatically make the taskbar item for a particular window start flashing when something changes, but is there any way I can stop it from flashing either programatically after a certain period of time or at least is there a keyboard shortcur I can give to my users to somehow...
<p>The <a href="http://msdn.microsoft.com/en-us/library/ms679347%28VS.85%29.aspx" rel="nofollow">FlashWindowEx</a> function which controls the flashing takes a <a href="http://msdn.microsoft.com/en-us/library/ms679348%28VS.85%29.aspx" rel="nofollow">FLASHWINFO</a> struct which has a uCount field to control how many tim...
Why is pagination so resource-expensive? <p>It's one of those things that seems to have an odd curve where the more I think about it, the more it makes sense. To a certain extent, of course. And then it doesn't make sense to me at all.</p> <p>Care to enlighten me?</p>
<p>Because in most cases you've got to sort your results first. For example, when you search on Google, <a href="http://www.google.com.au/search?hl=en&amp;safe=off&amp;q=google&amp;start=1000&amp;sa=N" rel="nofollow">you can view only up to 100 pages of results</a>. They don't bother sorting by page-rank beyond 1000 we...
What is the best way to package and distribute an Excel application <p>I've writen an Excel-based, database reporting tool. Currentely, all the VBA code is associated with a single XLS file. The user generates the report by clicking a button on the toolbar. Unfortunately, unless the user has saved the file under anothe...
<p>Simply move your code into an Excel Addin (XLA) - this gets loaded at startup (assuming it's in the %AppData%\Microsoft\Excel\XLSTART folder) but if it's a addin, not a workbook, then only your macros and defined startup functions will be loaded.</p> <p>If the functions depend on a spreadsheet itself, then you migh...
Suppress NTLM dialog box after unauthorized request <p>In a recent sharepoint project, I implemented an authentication webpart which should replace the NTLM authentication dialog box. It works fine as long as the user provides valid credentials. Whenever the user provides invalid credentials, the NTLM dialog box pops u...
<p><a href="http://stackoverflow.com/users/2199/mark-brackett">Mark</a>'s comment is correct; The NTLM auth prompt is triggered by a 401 response code and the presence of NTLM as the first mechanism offered in the WWW-Authenticate header (Ref: <a href="http://curl.haxx.se/rfc/ntlm.html" rel="nofollow">The NTLM Authenti...
Can someone point me to some guides for WPF <p>I am having trouble finding good guides for WPF.<br /> I have experience in C# and .NET but I don't know anything about WPF except for the regular marketing-ish description of the technology as a whole.<br /> Can anyone point me to a good beginner's tutorial/guide on WPF....
<p>Scott Hanselmann has blogged extensively about his experience in learning WPF by creating his 'BabySmash' windows application. All the source code is on codeplex and he has many blog articles describing his progress.</p> <p><a href="http://www.hanselman.com/blog/IntroducingBabySmashAWPFExperiment.aspx" rel="nofollo...
Stopping MSI from launching an EXE in the SYSTEM context <p>I've got a problem here with an MSI deployment that I'm working on (using <a href="http://en.wikipedia.org/wiki/InstallShield" rel="nofollow">InstallShield</a>). We have a program running in the background that needs to run per-user, and it needs to start auto...
<p>You can use the LogonUser property of Windows Installer as a condition to the action launching the EXE.</p>
Is version control (ie. Subversion) applicable in document tracking? <p>I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder. </p...
<p>I've worked with Word documents in SVN. With <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a>, you can easily diff Word documents (between working copy and repository, or between two repository revisions). It's really slick and definitely recommended.</p> <p>The other thing to do if you're using Word docume...
Java return copy to hide future changes <p>In Java, say you have a class that wraps an <code>ArrayList</code> (or any collection) of objects. </p> <p>How would you return one of those objects such that the caller will not see any future changes to the object made in the ArrayList? </p> <p>i.e. you want to return a de...
<p>Turn that into a spec:<br /> -that objects need to implement an interface in order to be allowed into the collection Something like <code>ArrayList&lt;ICloneable&gt;()</code></p> <p>Then you can be assured that you always do a deep copy - the interface should have a method that is guaranteed to return a deep copy. ...
How to bring in a web app <p>I run a game and the running is done by hand, I have a few scripts that help me but essentially it's me doing the work. I am at the moment working on web app that will allow the users to input directly some of their game actions and thus save me a lot of work.</p> <p>The problem is that I'...
<p>This is my general approach to testing/launching. How you test/launch depends mostly on:</p> <ol> <li>What your application <strong>is</strong>.</li> <li>Who your users <strong>are</strong>.</li> </ol> <p>If you application is a technical application and is geared to the technically-minded, the word "beta" won't r...
How to get your own (local) IP-Address from an udp-socket (C/C++) <ol> <li>You have multiple network adapters.</li> <li>Bind a UDP socket to an local port, without specifying an address.</li> <li>Receive packets on one of the adapters.</li> </ol> <p>How do you get the local ip address of the adapter which received the...
<p>You could enumerate all the network adapters, get their IP addresses and compare the part covered by the subnet mask with the sender's address.</p> <p>Like:</p> <pre><code>IPAddress FindLocalIPAddressOfIncomingPacket( senderAddr ) { foreach( adapter in EnumAllNetworkAdapters() ) { adapterSubnet = a...
How should I test a method that populates a list from a DataReader? <p>So I'm working on some legacy code that's heavy on the manual database operations. I'm trying to maintain some semblance of quality here, so I'm going TDD as much as possible.</p> <p>The code I'm working on needs to populate, let's say a <code>List...
<p>To make this less tedious, you will need to encapsulate/refactor the mapping between the DataReader and the Object you hold in the list. There is quite of few steps to encapsulate that logic out. If that is the road you want to take, I can post code for you. I am just not sure how practical it would be to post th...
How to know if a line intersects a plane in C#? - Basic 2D geometry <p>my school maths are very rusty and I think this is a good opportunity to take advance of this community :D</p> <p>I have two points (a line) and a rectangle, I would like to know how to calculate if the line intersects the rectangle, my first appro...
<p>From my "Geometry" class:</p> <pre><code>public struct Line { public static Line Empty; private PointF p1; private PointF p2; public Line(PointF p1, PointF p2) { this.p1 = p1; this.p2 = p2; } public PointF P1 { get { return p1; } set { p1 = value; }...
Is there a Java Console/Editor similar to the GroovyConsole? <p>I'm giving a presentation to a Java User's Group on Groovy and I'm going to be doing some coding during the presentation to show some side-by-side Java/Groovy. I really like the GroovyConsole as it's simple and I can resize the text easily. </p> <p>I'm ...
<p><a href="http://www.drjava.org/" rel="nofollow">DrJava</a> is your best bet. It also has an <a href="http://www.drjava.org/eclipse.shtml" rel="nofollow">Eclipse plugin</a> to use the interactions pane like GroovyConsole.</p>
Avoiding repeated constants in CSS <p>Are there any useful techniques for reducing the repetition of constants in a CSS file?</p> <p>(For example, a bunch of different selectors which should all apply the same colour, or the same font size)?</p>
<p>Elements can belong to more than one class, so you can do something like this: </p> <pre><code>.DefaultBackColor { background-color: #123456; } .SomeOtherStyle { //other stuff here } .DefaultForeColor { color:#654321; } </code></pre> <p>And then in the content portion somewhere: </p> <pre><code>&lt;...
enter key to insert newline in asp.net multiline textbox control <p>I have some C# / asp.net code I inherited which has a textbox which I want to make multiline. I did so by adding textmode="multiline" but when I try to insert a newline, the enter key instead submits the form :P</p> <p>I googled around and it seems li...
<p>It turns out this is a bug with Firefox + ASP.NET where the generated javascript for the defaultButton stuff doesn't work in Firefox. I had to put a replacement for the WebForm_FireDefatultButton function as described <a href="http://forums.asp.net/t/1294544.aspx" rel="nofollow">here</a>:</p> <pre><code>function We...
Asp.Net MVC: How do I enable dashes in my urls? <p>I'd like to have dashes separate words in my URLs. So instead of:</p> <pre><code>/MyController/MyAction </code></pre> <p>I'd like:</p> <pre><code>/My-Controller/My-Action </code></pre> <p>Is this possible?</p>
<p>You can use the ActionName attribute like so:</p> <pre><code>[ActionName("My-Action")] public ActionResult MyAction() { return View(); } </code></pre> <p>Note that you will then need to call your View file "My-Action.cshtml" (or appropriate extension). You will also need to reference "my-action" in any Html.Ac...
Moving from Visual Studio 2005 to 2008 and .NET 2.0 <p>I'm currently using VS2005 Profesional and .NET 2.0, and since our project is rather large (25 projects in the solution), I'd like to try VS 2008, since its theoretically faster with larger projects. </p> <p>Before doing such thing, i'd like to know if what I've r...
<p>Yes it's possible. In the project properties you can target different versions of the .Net Framework going back to .NET 2.0.</p> <p>Upgrading to VS 2008 will upgrade your Solution file and you won't be able to go back to VS 2005 unless you have backed up your solution</p>
What does this javascript error mean? Permission denied to call method to Location.toString <p>This error just started popping up all over our site.</p> <p><strong><em>Permission denied to call method to Location.toString</em></strong></p> <p>I'm seeing google posts that suggest that this is related to flash and our ...
<p>Are you using javascript to communicate between frames/iframes which point to different domains? This is not permitted by the JS "same origin/domain" security policy. Ie, if you have</p> <pre><code>&lt;iframe name="foo" src="foo.com/script.js"&gt; &lt;iframe name="bar" src="bar.com/script.js"&gt; </code></pre> <p>...
MySQL Binary Log Replication: Can it be set to ignore errors? <p>I'm running a master-slave MySQL binary log replication system (phew!) that, for some data, is not in sync (meaning, the master holds more data than the slave). But the slave stops very frequently on the slightest MySQL error, can this be disabled? (perha...
<p>stop slave; set global sql_slave_skip_counter=1; start slave;</p> <p>You can ignore only the current error and continue the replication process.</p>
How to unit test an object with database queries <p>I've heard that unit testing is "totally awesome", "really cool" and "all manner of good things" but 70% or more of my files involve database access (some read and some write) and I'm not sure how to write a unit test for these files.</p> <p>I'm using PHP and Python ...
<p>I would suggest mocking out your calls to the database. Mocks are basically objects that look like the object you are trying to call a method on, in the sense that they have the same properties, methods, etc. available to caller. But instead of performing whatever action they are programmed to do when a particular...
Update Panel inside of a UserControl inside of a Repeater inside of another UpdatePanel <p>Yes, it sounds crazy....It might be.</p> <p>The final updatepanel does not appear to trigger anything, it just refreshes the update panels and does not call back to the usercontrol hosting it.</p> <p>Any ideas?</p> <p>EDIT: I ...
<p>I would suggest you start by removing the UpdatePanels at first, and make sure your control orgy is working correctly with postbacks. Once you have that working, try adding the UpdatePanels back in from the bottom up.</p>
Is there a Way to use Linq to Oracle <p>I can connect with the DataContext to the Oracle database however I get errors in running the query against the oracle database. I looked at the SQL generated and it is for MSSQL and not Oracle PSQL. </p> <p>Does anybody know of a decent easy to use wrapper to use LINQ against...
<p>No, LINQ to SQL is very much MS SQL only - think of it as a client driver.</p> <p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1623471&amp;SiteID=1">Microsoft is/was helping Oracle and DataDirect develop providers for Oracle and other non-MS database servers.</a></p>
How can I authenticate using client credentials in WCF just once? <p>What is the best approach to make sure you only need to authenticate once when using an API built on WCF?</p> <p>My current bindings and behaviors are listed below</p> <pre><code> &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="wsHttp"...
<p>If you're on an intranet, Windows authentication can be handled for "free" by configuration alone. </p> <p>If this isn't appropriate, token services work just fine, but for some situations they may be just too much.</p> <p>The application I'm working on needed bare-bones authentication. Our server and client run i...
How to handle error logging <p>Until recently I've been using <code>syslog</code> in my <code>System_Exception</code> exception handler to log important errors - a pretty useful concept I thought. However my host just cut me off, and it appears that loveable <code>syslog</code> has actually been sending my error report...
<p>Try <strong>log4php</strong>. I'm using <strong>log4net</strong> for my .NET project and it's just terrific. :)</p>
What control is this? ("Open" Button with Drop Down) <p>The "Open" button on the open file dialog used in certain windows applications includes a dropdown arrow with a list of additional options -- namely "Open with..". </p> <p>I haven't seen this in every windows application, so you may have to try a few to get it, ...
<p>I used the draggable search in Spy++ (installed with VS) to look at the split open button on the file-open dialog of VS.</p> <p>This revealed that it's an ordinary windows button with a style which includes BS_DEFSPLITBUTTON. That's a magic keyword which gets you to some interesting places, including</p> <p><a h...
Accessing a Component on an inherited form from the base form <p>A number of forms in my project inherit from a base form. It is easy to get at the Controls collection of the derived forms, but I have not found a simple way to access the Components collection, since VS marks this as private. </p> <p>I assume this coul...
<p>If you set the Modifiers property of your components to strict protected makes them accessible without the use of a components collection. </p> <p>Edit: Discoverability could be done using reflection to walk over each field. Although that might be suboptimal in your case.</p>
Outlook synchronization on multiple machines <p><i>This isn't much of a programming question, but I'm sure I'm not the only person here who has this issue.</i></p> <p>Currently I have two machines with Outlook 2007. They both sync e-mail from Google Apps. One of the machines publishes my calendar to a secure server, w...
<p>Question 2: Yes. Use your Exchange server as you normally would then add your IMAP email account to Outlook. I have a client that has done this for his office staff and it's been working fine for years.</p>
Content Type for MHT files <p>What is the content type for MHT files?</p>
<p>Microsoft, who co-authored the spec for MHT, seem to think that it should be '<code>message/rfc822</code>' on <a href="http://support.microsoft.com/kb/937912">this support page</a>.</p> <p>No specific MIME type seems to be given in the spec though: <a href="http://tools.ietf.org/html/rfc2557">RFC2557: MIME Encapsul...
Profile a rails controller action <p>What is the best way to profile a controller action in Ruby on Rails. Currently I am using the brute-force method of throwing in <code>puts Time.now</code> calls between what I think will be a bottleneck. But that feels really, really dirty. There has got to be a better way.</p>
<p>I picked up this technique a while back and have found it quite handy.</p> <p>When it's in place, you can add <code>?profile=true</code> to any URL that hits a controller. Your action will run as usual, but instead of delivering the rendered page to the browser, it'll send a detailed, nicely formatted ruby-prof pag...
How do threads work in Python, and what are common Python-threading specific pitfalls? <p>I've been trying to wrap my head around how threads work in Python, and it's hard to find good information on how they operate. I may just be missing a link or something, but it seems like the official documentation isn't very tho...
<p>Yes, because of the Global Interpreter Lock (GIL) there can only run one thread at a time. Here are some links with some insights about this:</p> <ul> <li><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=214235">http://www.artima.com/weblogs/viewpost.jsp?thread=214235</a></li> <li><a href="http://smoothsp...
Is there a reason to use BufferedReader over InputStreamReader when reading all characters? <p>I currently use the following function to do a simple HTTP GET.</p> <pre><code>public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; ...
<p>In this case, I would do as you are doing (use a byte array for buffering and not one of the stream buffers).</p> <p>There are exceptions, though. One place you see buffers (output this time) is in the servlet API. Data isn't written to the underlying stream until <em>flush()</em> is called, allowing you to buffer ...
Visual Studio 2008 debugging issue <p>I'm working in VS 2008 and have three projects in one solution. I'm debugging by attaching to a .net process invoked by a third party app (SalesLogix, a CRM app). </p> <p>Once it has attached to the process and I attempt to set a breakpoint in one of the projects, it doesn't set...
<p>I saw this functionality in older versions of VS.Net (2003 I think). It may still exist in current versions, but I haven't encountered it. Seems that files with the same name, even in different directories confuse VS.Net, and it ends up setting a break point in a file with the same name. May only happen if the cl...
How stable is WPF? <p>How stable is WPF not in terms of stability of a WPF program, but in terms of the 'stability' of the API itself. </p> <p>Let me explain: </p> <p>Microsoft is notorious for changing its whole methodology around with new technology. Like with the move from silverlight 1 to silverlight 2. With WP...
<p>MS do have a history of "fire and movement" with regards to introducing new technology into their development stack, but they also have a strong history of maintaining support for the older stuff, and backwards-compatibility. WPF seems to be getting stuff added to it with each new release of the framework but the th...
Do indexes work with "IN" clause <p>If I have a query like:</p> <pre><code>Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3) </code></pre> <p>and I have an index on the <code>EmployeeTypeId</code> field, does SQL server still use that index?</p>
<p>Yeah, that's right. If your employee table has 10,000 records, and only 5 records have employeetypeID in (1,2,3), then it will most likely use the index to fetch the records. However, if it finds that 9,000 records have the employeeIDType in (1,2,3), then it would most likely just do a table scan to get the corres...
How many ServiceContracts can a WCF service have? <p>How many ServiceContracts can a WCF service have?</p> <p>Specifically, since a ServiceContract is an attribute to an interface, how many interfaces can I code into one WCF web service? Is it a one-to-one?</p> <p>Does it make sense to separate the contracts across m...
<p>WCF services can have multiple endpoints, each of which can implement a different service contract.</p> <p>For example, you could have a service declared as follows:</p> <pre><code>[ServiceBehavior(Namespace = "DemoService")] public class DemoService : IDemoService, IDoNothingService </code></pre> <p>Which would ...
How to respond to an alternate URI in a RESTful web service <p>I'm building a RESTful web service which has multiple URIs for one of its resources, because there is more than one unique identifier. Should the server respond to a GET request for an alternate URI by returning the resource, or should I send an HTTP 3xx re...
<p>I'd personally plump for returning the resource rather than faffing with a redirect, although I suspect that's only because my subcoscious is telling me redirects are slower.</p> <p>However, if you were to decide to use a redirect I'd think a 302 or 307 might be more appropiate than a 303, although the <a href="htt...
Java Logging vs Log4J <p>Is it still worth to add the log4j library to a Java 5 project just to log let's say some exceptions to a file with some nice rollover settings. Or will the standard util.logging facility do the job as well?</p> <p>What do you think?</p>
<p>I'd say you're probably fine with util.logging for the needs you describe.</p> <p>For a good decision tree, have a look at <a href="http://java.sys-con.com/node/48541">Log4j vs java.util.logging</a></p> <blockquote> <p>Question One : Do you anticipate a need for any of the clever handlers that Log4j has that J...
using a html entity in xslt (e.g. &nbsp;) <p>What is the best way to include an html entity in XSLT?</p> <pre><code>&lt;xsl:template match="/a/node"&gt; &lt;xsl:value-of select="."/&gt; &lt;xsl:text&gt;&amp;nbsp;&lt;/xsl:text&gt; &lt;/xsl:template&gt; </code></pre> <p>this one returns a <strong>XsltParseError...
<p>You can use CDATA section</p> <pre><code>&lt;xsl:text disable-output-escaping="yes"&gt;&lt;![CDATA[&amp;nbsp;]]&gt;&lt;/xsl:text&gt; </code></pre> <p>or you can describe &amp;nbsp in local DTD:</p> <pre><code>&lt;!DOCTYPE xsl:stylesheet [ &lt;!ENTITY nbsp "&amp;#160;"&gt; ]&gt; </code></pre> <p>or just use <code...
Sending e-mail from a Custom SQL Server Reporting Services Delivery Extension <p>I've developed my own delivery extension for Reporting Services 2005, to integrate this with our SaaS marketing solution.</p> <p>It takes the subscription, and takes a snapshot of the report with a custom set of parameters. It then render...
<p>What's at:</p> <pre><code>at MyDeliveryExtension.MailDelivery.SendMail(SubscriptionData data, Stream reportStream, String reportName, String smptServerHostname, Int32 smtpServerPort) in C:\inetpub\wwwroot\CustomReporting\MyDeliveryExtension\MailDelivery.cs:line 48 at MyDeliveryExtension.MyDelivery.Deliver(Noti...
C# - SQLClient - Simplest INSERT <p>I'm basically trying to figure out the simplest way to perform your basic insert operation in C#.NET using the SqlClient namespace. </p> <p>I'm using <code>SqlConnection</code> for my db link, I've already had success executing some reads, and I want to know the simplest way to inse...
<pre><code>using (var conn = new SqlConnection(yourConnectionString)) { var cmd = new SqlCommand("insert into Foo values (@bar)", conn); cmd.Parameters.AddWithValue("@bar", 17); conn.Open(); cmd.ExecuteNonQuery(); } </code></pre>
Is regex case insensitivity slower? <p><a href="http://twitter.com/codinghorror/statuses/901272685">Source</a></p> <blockquote> <p>RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely measurable)</p> </blockquote> <p>Assuming that this applies to PHP, Python, Perl, Ruby etc as w...
<p>Yes, [A-Za-z] will be much faster than setting the <code>RegexOptions.IgnoreCase</code>, largely because of Unicode strings. But it's also much more limiting -- [A-Za-z] does <em>not</em> match accented international characters, it's literally the A-Za-z ASCII set and nothing more.</p> <p>I don't know if you saw Ti...
Is soapUI the best web services testing tool/client/framework? <p>I have been working on a web services related project for about the last year. Our team found <a href="http://www.soapui.org">soapUI</a> near the start of our project and we have been <em>mostly</em>(*) satisfied with it (the free version, that is).</p>...
<p>I use soapUI, and it's generally pretty good. Be aware that it seems to leak memory, and eventually it will no longer save your project, so save regularly!</p> <p>This is about the only hassle I have with it (other than the general ugliness that almost every Java application has!), and I can't live without it.</p>...
What is the simplest SQL Query to find the second largest value? <p>What is the simplest SQL query to find the second largest integer value in a specific column? </p> <p>There are maybe duplicate values in the column.</p>
<pre><code>SELECT MAX( col ) FROM table WHERE col &lt; ( SELECT MAX( col ) FROM table ) </code></pre>
Sending email in .NET through Gmail <p>Instead of relying on my host to send email, I was thinking of sending the messages though my Gmail account. The emails are personalized emails to the bands I play on my show. Is it possible to do?</p>
<p>Be sure to use <code>System.Net.Mail</code>, not the deprecated <code>System.Web.Mail</code>. Doing SSL with <code>System.Web.Mail</code> is a gross mess of hacky extensions.</p> <pre><code>using System.Net; using System.Net.Mail; var fromAddress = new MailAddress("from@gmail.com", "From Name"); var toAddress = ne...
Passing null to a method <p>I am in the middle of reading the excellent <a href="http://rads.stackoverflow.com/amzn/click/0132350882">Clean Code</a></p> <p>One discussion is regarding passing nulls into a method.</p> <pre><code>public class MetricsCalculator { public double xProjection(Point p1, Point p2) { ...
<p>General rule is if your method doesn't expect null arguments then you should throw <a href="http://msdn.microsoft.com/en-us/library/system.argumentnullexception.aspx">System.ArgumentNullException</a>. Throwing proper exception not only protects you from resource corruption and other bad things but serves as a guide ...
1:1 Foreign Key Constraints <p>How do you specify that a foreign key constraint should be a 1:1 relationship in transact sql? Is declaring the column UNIQUE enough? Below is my existing code.!</p> <pre><code>CREATE TABLE [dbo].MyTable( [MyTablekey] INT IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, [OtherTableKey...
<p>A foreign key column with the UNIQUE and NOT NULL constraints that references a UNIQUE, NOT NULL column in another table creates a 1:(0|1) relationship, which is probably what you want.</p> <p>If there was a true 1:1 relationship, every record in the first table would have a corresponding record in the second table...
Get the DefaultView DataRowView from a DataRow <p>Here's the situation: I need to bind a WPF <code>FixedPage</code> against a <code>DataRow</code>. Bindings don't work against <code>DataRows</code>; they work against <code>DataRowViews</code>. I need to do this in the most generic way possible, as I know nothing abo...
<p>Not Exactly a sexy piece of code but their doesn't seem to be an automated way to find the row without just looping the table.</p> <pre><code> DataRowView newRowView = null; foreach (DataRowView tempRowView in myDataTable.DefaultView) { if (tempRowView.Row == rowToMatch) ...
Alternative "architectural" approaches to javaScript client code? <p>How is your javaScript code organized? Does it follow patterns like MVC, or something else? </p> <p>I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right n...
<p>..but Javascript has many facets that <strong>are</strong> OO.</p> <p>Consider this:</p> <pre><code>var Vehicle = jQuery.Class.create({ init: function(name) { this.name = name; } }); var Car = Vehicle.extend({ fillGas: function(){ this.gas = 100; } }); </code></pre> <p>I've used this techniq...
Does ReadUncommitted imply NoLock <p>When writing a SQL statement in SQL Server 2005, does the READUNCOMMITTED query hint imply NOLOCK or do I have to specify it manually too?</p> <p>So is:</p> <pre><code>With (NoLock, ReadUnCommitted) </code></pre> <p>the same as:</p> <pre><code>With (ReadUnCommitted) </code></pre...
<p>According to Kalen Delaney...</p> <p>The NOLOCK hint has nothing to do with the index options. The hint tells SQL Server not to request locks when doing SELECT operations, so there will be no conflict with data that is already locked. The index options just tell SQL Server that this level of locking is allowed, whe...
How to make 'pretty urls' work in php hosted in IIS? <p>Is there some way I can use urls like: </p> <p><em><a href="http://www.blog.com/team-spirit/" rel="nofollow">http://www.blog.com/team-spirit/</a></em></p> <p>instead of</p> <p><em><a href="http://www.blog.com/?p=122" rel="nofollow">http://www.blog.com/?p=122</a...
<p><a href="http://www.codeplex.com/IIRF" rel="nofollow">Isapi Rewrite Filter on CodePlex</a> - actively developed, free ("DonationWare"), open source.</p>
Mocking Asp.net-mvc Controller Context <p>So the controller context depends on some asp.net internals. What are some ways to cleanly mock these up for unit tests? Seems like its very easy to clog up tests with tons of setup when I only need, for example, Request.HttpMethod to return "GET".</p> <p>I've seen some exampl...
<p>Using MoQ it looks something like this:</p> <pre><code>var request = new Mock&lt;HttpRequestBase&gt;(); request.Expect(r =&gt; r.HttpMethod).Returns("GET"); var mockHttpContext = new Mock&lt;HttpContextBase&gt;(); mockHttpContext.Expect(c =&gt; c.Request).Returns(request.Object); var controllerContext = new Control...
How can I take a byte array of a TIFF image and turn it into a System.Drawing.Image object? <p>I have a <code>byte[]</code> array, the contents of which represent a TIFF file (as in, if I write out these bytes directly to a file using the <code>BinaryWriter</code> object, it forms a perfectly valid TIFF file) and I'm t...
<p><strong>Edit:</strong> The assumption below is not correct, I had a chance to fire up my IDE later and tested with and without Write and both populated the MemoryStream correctly.</p> <p>I think you need to write to your MemeoryStream first.</p> <p>As if my memory (no pun intended) serves me correctly this:</p> <...
SQL Server 2003 internet connection <p>Recently we got a new server at the office purely for testing purposes. It is set up so that we can access it from any computer. </p> <p>However today our ip got blocked from one of our other sites saying that our ip has been suspected of having a virus that sends spam emails. we...
<p>I assume that this server is behind a router? You should be able to block <code>WAN</code> connections to the server on the router and still leave it open to accepting <code>LAN</code> connection. Or you could restrict the <code>IPs</code> that can connect to the server to the development machines on the network.</p...
Alternatives to System.exit(1) <p>For various reasons calling <code>System.exit</code> is frowned upon when writing <strong>Java Applications</strong>, so how can I notify the calling process that not everything is going according to plan?</p> <p><strong>Edit:</strong> The 1 is a <code>standin</code> for any non-zero ...
<p>The use of System.exit is frowned upon when the 'application' is really a sub-application (e.g. servlet, applet) of a larger Java application (server): in this case the System.exit could stop the JVM and hence also all other sub-applications. In this situation, throwing an appropriate exception, which could be caugh...
What is a good dvd burning component for Windows or .Net? <p>I'd like to add dvd burning functionality to my .Net app (running on Windows Server 2003), are there any good components available? I've used the NeroCOM sdk that used to come with Nero but they no longer support the sdk in the latest versions of Nero. I le...
<p>I've used the code from the codeproject <a href="http://www.codeproject.com/KB/miscctrl/imapi2.aspx" rel="nofollow">article</a> and it works pretty well. It's a nice wrapper around the IMAPI2, so as longs as IMAPI2 supports what you need to do, the .NET wrapper will do it.</p>
Setting the height of a DIV dynamically <p>In a web application, I have a page that contains a DIV that has an auto-width depending on the width of the browser window.</p> <p>I need an auto-height for the object. The DIV starts about 300px from the top screen, and it's height should make it stretch to the bottom of t...
<p>Try this simple, specific function:</p> <pre><code>function resizeElementHeight(element) { var height = 0; var body = window.document.body; if (window.innerHeight) { height = window.innerHeight; } else if (body.parentElement.clientHeight) { height = body.parentElement.clientHeight; } else if (...
How to pass method name to custom server control in asp.net? <p>I am working on a Customer Server Control that extends another control. There is no problem with attaching to other controls on the form.</p> <p>in vb.net: Parent.FindControl(TargetControlName)</p> <p>I would like to pass a method to the control in the...
<p>If you want to be able to pass a method in the ASPX markup, you need to use the <code>Browsable</code> attribute in your code on the event.</p> <p>VB.NET</p> <pre><code>&lt;Browsable(True)&gt; Public Event InitializeStuffCallback </code></pre> <p>C#</p> <pre><code>[Browsable(true)] public event EventHandler Init...
Caching Active Directory Data <p>In one of my applications, I am querying active directory to get a list of all users below a given user (using the "Direct Reports" thing). So basically, given the name of the person, it is looked up in AD, then the Direct Reports are read. But then for every direct report, the tool nee...
<p>In order to take control over the properties that you want to be cached you can call 'RefreshCache()' passing the properties that you want to hang around:</p> <pre class="lang-c# prettyprint-override"><code>System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(); ...
Best use pattern for a DataContext <p>What's the best lifetime model for a DataContext? Should I just create a new one whenever I need it (aka, function level), should I keep one available in each class that would use it (class level), or should I create a static class with a static DataContext (app-domain level)? Are ...
<p>You pretty much need to keep the same data context available throughout the lifetime of the operations you want to perform if you're ever going to be storing changes which are to be .SubmitChanges()'d later, as otherwise you will lose those changes.</p> <p>If you're just querying stuff then it's fine to create them...
What is the best approach to both modularity and platform independence? <p>I hope this question does not come off as broad as it may seem at first. I am designing a software application in my <code>&lt;sarcasm&gt;</code><em>voluminous</em><code>&lt;/sarcasm&gt;</code> spare time. I would like it to be both cross-plat...
<p>Are you planning a desktop or web application? </p> <p>Everyone around here seems to think that Mono is great, but I still do not think it is ready for industry use, I would equate mono to where wine is, great idea; when it works it works well, and when it doesn't...well your out of luck. mod_mono for Apache is ext...
Best open-source Mathematica equivalent <p>What is the best open-source equivalent for Mathematica? My requirements are:</p> <ol> <li>(most important) Must be a real computer algebra system (CAS). Notably, I don't want Matlab clones -- I want something that can, at least, symbolically differentiate and integrate.</l...
<p>SAGE is definitely one you should consider since it actually includes the full version of Maxima within it (along with interfaces to various other mathematical packages). To answer your questions:</p> <p>1) SAGE can symbolically <a href="http://www.sagemath.org/doc/tutorial/tour_algebra.html#differentiation-integr...
Drawing a custom label on a pie chart in Yahoo's Flash Library ASTRA <p>Has anyone looked at <a href="http://developer.yahoo.com/flash/" rel="nofollow">Yahoo's ASTRA</a>? It's fairly nifty, but I had some issues creating a custom label for a pie chart. They have an example for a line chart, which overrides an axis's se...
<p>Okay... so no-one's tried Astra, or people just avoid Flash questions.</p> <p>After a lot of guess work it turns out I needed to cast the series to a PieSeries and then work with those member functions, as the ISeries was useless on it's own.</p> <pre><code>myPieChart.dataTipFunction = function (item:Object, in...
What's the maximum amount of RAM I can use in a Windows box? <p>Obviously, that's 64-bit windows.</p> <p>Also, what's the maximum amount of memory a single 64-bit process can use? I was kind of counting on using it all... (Yes, I know what I'm doing, please don't tell me that if I need that much RAM i must be doing s...
<p>What version of windows? it differs from XP to vista and from home to business versions of vista, and I would guess again for server.</p> <p>see <a href="http://msdn.microsoft.com/en-us/library/aa366778.aspx" rel="nofollow">here for more info on maximum ram for diffrent windows versions</a></p> <p>for Windows Serv...
Change templates in Xcode <p>How would I change the initial templates created by Xcode when creating a new Cocoa Class.</p> <p>I am referring to the comments and class name created when using Xcode's new class wizard.</p>
<p>You wouldn't change the existing templates. In other words, don't <em>modify</em> anything under the <code>/Developer</code> hierarchy (or wherever you installed your developer tools).</p> <p>Instead, clone the templates you want to have customized variants of. Then change their names and the information in them....
How can I use `scp` to deploy a website's `.htaccess` file? <p>I am currently using the following command to upload my site content:</p> <pre><code>scp -r web/* user@site.com:site.com/ </code></pre> <p>This works great except that the .htaccess file is not sent. Presumably, this is because it's hidden.</p> <p>I have...
<p>Just combine the two commands:</p> <pre><code>scp -r web/* web/.htaccess user@site.com:site.com/ </code></pre> <p>If you want 0 entries of your password you can set up <a href="http://sial.org/howto/openssh/publickey-auth/" rel="nofollow">public key authentication</a> for ssh/scp.</p>
Is it possible to call Javascript's onsubmit event programatically on a form? <p>In Ruby on Rails, I'm attempting to update the <code>innerHTML</code> of a div tag using the <code>form_remote_tag</code> helper. This update happens whenever an associated select tag receives an onchange event. The problem is, <code>&lt...
<p>I realize this question is kind of old, but what the heck are you doing eval for?</p> <pre><code>document.getElementById('formId').onsubmit(); document.getElementById('formId').submit(); </code></pre> <p>or</p> <pre><code>document.formName.onsubmit(); document.formName.submit(); </code></pre> <p>When the DOM of ...
How do you get the ethernet address using Java? <p>I would like to retrieve the ethernet address of the network interface that is used to access a particular website.</p> <p>How can this be done in Java?</p> <p><strong>Solution</strong> Note that the accepted solution of <code>getHardwareAddress</code> is only availa...
<p><a href="http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress%28%29"> java.net.NetworkInterface.getHardwareAddress</a> (method added in Java 6)</p> <p>It has to be called on the machine you are interested in - the MAC is not transferred across network boundaries (i.e. LAN and WAN)...
Can't create a subversion repository with Eclipse 3.4.0, svn 1.5.1 <p>I'm working on mac OS x 10.4. I have a subversion repository stored on an external drive connected via USB. I created a new python project in Eclipse (using the PyDev plugin). When I use right click Team->Share Project to set up a new prject with sub...
<p>Try adding the repository first using the "SVN Repository Exploring" perspective (Window > Open Perspective > Other... > SVN Repository Exploring).</p> <p>Make sure that the URL you are using points to the correct directory, which typically contains these default repository files:</p> <pre><code>conf/ dav/ db/ ...
Are Python threads buggy? <p>A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy - enough to avoid using altogether. What can said about this rumor?</p>
<p>Python threads are good for <strong>concurrent I/O programming</strong>. Threads are swapped out of the CPU as soon as they block waiting for input from file, network, etc. This allows other Python threads to use the CPU while others wait. This would allow you to write a multi-threaded web server or web crawler, for...
HTML Scraping in Php <p>I've been doing some html scraping in PHP using regular expressions. This works, but the result is finicky and fragile. Has anyone used any packages that provide a more robust solution? A config driven solution would be ideal, but I'm not picky.</p>
<p>I would recomend <a href="https://sourceforge.net/projects/simplehtmldom/">PHP Simple HTML DOM Parser</a> after you have scraped the HTML from the page. It supports invalid HTML, and provides a very easy way to handle HTML elements. </p>
COMException "Library not registered." while using System.DirectoryServices <p>I have only just started received the following error in my windows forms application under dot net 2 framework on windows 2000 when using System.DirectoryServices.</p> <pre><code> {System.Runtime.InteropServices.COMException} System.Run...
<p>Having used <a href="http://www.red-gate.com/products/reflector/" rel="nofollow">Reflector</a> to have a quick peak at the Directory Services code, it looks like your Active Directory Service Interfaces installation might be kaput.</p> <p>You can download version 2.5 from <a href="http://technet.microsoft.com/en-us...
Has .NET made raw COM and DCOM programming redundant? <p>Has the introduction of the .net framework made raw programming in COM and DCOM redundant ? </p> <p>(Except for using some COM+ services, e.g. for transaction management through the System.EnterpriseServices namespace)</p>
<p>Not yet, because the OS is still unmanaged.</p> <p>If MS finally do what their labs have been talking about for years and produce a fully managed OS then it will.</p> <p>That OS won't be backwards compatible though. They would have to produce managed versions of Office, IE, etc first. They will have to produce a v...
How to make user controls know about css classes in ASP.NET <p>Since there are no header sections for user controls in asp.net, user controls have no way of knowing about stylesheet files. So css classes in the user controls are not recognized by visual studio and produces warnings. How can I make a user control know t...
<p>Here's what I did:</p> <pre><code>&lt;link rel="Stylesheet" type="text/css" href="Stylesheet.css" id="style" runat="server" visible="false" /&gt; </code></pre> <p>It fools Visual Studio into thinking you've added a stylesheet to the page but it doesn't get rendered.</p> <p><hr /></p> <p>Here's an even more conci...
How do I create a SHA1 hash in ruby? <p><a href="http://en.wikipedia.org/wiki/SHA-1">SHA Hash functions</a></p>
<pre><code>require 'digest/sha1' Digest::SHA1.hexdigest 'foo' </code></pre>
What is a race condition? <p>When writing multi-threaded applications, one of the most common problems experienced are race conditions. </p> <p>My questions to the community are:</p> <p>What is a race condition? How do you detect them? How do you handle them? Finally, how do you prevent them from occurring?</p>
<p>A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don't know the order in which the threads will attempt to access the shared data. Therefore, the result of the change i...
What is the best quick-read Python book out there? <p>I am taking a class that requires Python. We will review the language in class next week, and I am a quick study on new languages, but I was wondering if there are any really great Python books I can grab while I am struggling through the basics of setting up my IDE...
<p>I loved <a href="http://www.diveintopython.net/toc/index.html" rel="nofollow">Dive Into Python</a>, especially if you're a quick study. The beginning basics are all covered (and may move slowly for you), but the latter few chapters are great learning tools.</p> <p>Plus, Pilgrim is a pretty good writer.</p>
Can you pair program remotely? <p>We have a team of about 7 engineers, whom I supervise. We do not have a formal office where we all work. Instead, a handful are located outside of our city, while the rest of us are scattered around the Bay Area.</p> <p>Quite frequently, I find myself attempting to teach concepts like...
<p>I've done quite a lot of pair-programming not only cross-site but cross-timezone. I live in Israel and I work with people on the West Coast all the time. The best way I've found is to use shared VNC session and skype. You need some "good behavior" to ensure that only one of us types at a given time. The VNC serv...
duplicating jQuery datepicker <p>The <code>datepicker</code> function only works on the first input box that is created.</p> <p>I'm trying to duplicate a datepicker by cloning the <code>div</code> that is containing it.</p> <pre><code>&lt;a href="#" id="dupMe"&gt;click&lt;/a&gt; &lt;div id="template"&gt; input-text &...
<p>I use a CSS class instead:</p> <pre><code>&lt;input type="text" id="BeginDate" class="calendar" /&gt; &lt;input type="text" id="EndDate" class="calendar" /&gt; </code></pre> <p>Then, in your <code>document.ready</code> function:</p> <pre><code>$('.calendar').datepicker(); </code></pre> <p>Using it that way for m...
How do I lock a file in Perl? <p>What is the best way to create a lock on a file in Perl?</p> <p>Is it best to flock on the file or to create a lock file to place a lock on and check for a lock on the lock file?</p>
<p>If you end up using flock, here's some code to do it:</p> <pre><code>use Fcntl ':flock'; # Import LOCK_* constants # We will use this file path in error messages and function calls. # Don't type it out more than once in your code. Use a variable. my $file = '/path/to/some/file'; # Open the file for appending. N...
Comparison of Javascript libraries <p>After the suggestion to use a library for <a href="http://stackoverflow.com/questions/34486/what-more-is-needed-for-ajax-than-this-function">my ajax needs</a> I am going to use one, the problem is that there are so many and I've no idea how to even begin telling them apart.</p> <p...
<p>To answer B:</p> <p><a href="http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks"><strong>Comparison of JavaScript frameworks</strong></a></p> <p><hr /></p> <p><strong>EDIT:</strong> Although everyone and their mom is apparently riding the <a href="http://jquery.com/"><strong>jQuery</strong></a> band...
programmatically merge .reg file into win32 registry <p>What's the best way to programmatically merge a .reg file into the registry? This is for unit testing; the .reg file is a test artifact which will be added then removed at the start and end of testing.</p> <p>Or, if there's a better way to unit test against the r...
<p>It is possible to remove registry keys using a .reg file, although I'm not sure how well it's documented. Here's how:</p> <pre><code>REGEDIT4 [-HKEY_CURRENT_USER\Software\&lt;otherpath&gt;] </code></pre> <p>The <code>-</code> in front of the key name tells <code>Regedit</code> that you want to remove the key.</p...
Image processing in Silverlight 2 <p>Is it possible to do image processing in silverlight 2.0?</p> <p>What I want to do is take an image, crop it, and then send the new cropped image up to the server. I know I can fake it by clipping the image, but that only effects the rendering of the image. I want to create a new...
<p>Well, you can actually do local image processing in Silverlight 2... But there are no built in classes to help you. But you can load any image into a byte array, and start manipulating it, or implement your own image encoder.</p> <p>Joe Stegman got lots of great information about "editable images" in Silverlight ov...
Verilog automatic task <p>What does it mean if a task is declared with the automatic keyword in Verilog?</p> <pre><code>task automatic do_things; input [31:0] number_of_things; reg [31:0] tmp_thing; begin // ... end endtask; </code></pre> <p>Note: This question is mostly because I'm curious if there are a...
<p>"automatic" does in fact mean "re-entrant". The term itself is stolen from software languages -- for example, C has the "auto" keyword for declaring variables as being allocated on the stack when the scope it's in is executed, and deallocated afterwards, so that multiple invocations of the same scope do not see per...
Retrieving HTTP status code from loaded iframe with Javascript <p>I used the jQuery Form plugin for asynchronous form submission. For forms that contain files, it copies the form to a hidden iframe, submits it, and copies back the iframe's contents. The problem is that I can't figure out how to find what HTTP status co...
<p>You can't get page headers by JS, but you can distinguish error from success: Try something like this:</p> <pre><code>&lt;script type="text/javascript"&gt; var uploadStarted = false; function OnUploadStart(){ uploadStarted = true; } function OnUploadComplete(state,message){ ...
How do you get the last record generated in a recursive CTE? <p>In the code below I am using a recursive CTE(Common Table Expression) in SQL Server 2005 to try and find the top level parent of a basic hierarchical structure. The rule of this hierarchy is that every CustID has a ParentID and if the CustID has no parent ...
<p>If you just want want the highest recursion depth couldn't you do something like this?Then, when you actually query the CTE just look for the row with max(Depth)? Like so:</p> <pre><code>DECLARE @LookupID int --Our test value SET @LookupID = 1; WITH cteLevelOne (ParentID, CustID, Depth) AS ( SELECT a.P...
Print Odd-Even numbers using signals <p>I need to to print natural nos. 1,2,...n such that the parent process prints all odd numbers and the child process prints all even numbers, and all of this needs to be done using POSIX signals. How would I go about accomplishing this?</p> <p>The output should be:</p> <p>Parent ...
<p>It would probably be more beneficial for you provide what you have so far and explain what doesn't work as expected but here is what I came up with:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;sys/types.h&gt; #include &lt;unistd.h&gt; #include &lt;signal.h&gt; #include &lt;stdlib.h&gt; #define READY_SIGNA...
mysql software: any suggestions to oversee my mysql replication server? <p>I've had a tough time setting up my replication server. Is there any program (OS X, Win, Linux or php no problem) that lets me monitor and resolve replication issues? (btw, for those -uhm- following, ive been on this issue <a href="http://stacko...
<p>To monitor the servers we use the free <a href="http://www.maatkit.org/tools.html" rel="nofollow">tools from Maatkit</a> ... simple, yet efficient.</p> <p>The binary replication is available in 5.1, so I guess you've got some balls. We still use 5.0 and it works OK, but of course we had our share of issues with it....
Are there static analysis tools for Python? <p>I am starting to use Python (specifically because of Django) and I would like to remove the burden for exhaustive testing by performing some static analysis. What tools/parameters/etc. exist to detect issues at compile time that would otherwise show up during runtime? (ty...
<p><a href="http://www.logilab.org/857">pylint</a> is the best such tool I've found. Due to Python's nature it's difficult to statically analyze it, but it will catch undefined variables, basic type errors, unused code, etc. You'll want to tweak the configuration file, as by default it outputs many warnings I consider ...
How can I clear Class::DBI's internal cache? <p>I'm currently working on a large implementation of Class::DBI for an existing database structure, and am running into a problem with clearing the cache from Class::DBI. This is a mod_perl implementation, so an instance of a class can be quite old between times that it is...
<p>The "<a href="http://wiki.class-dbi.com/wiki/Common_problems" rel="nofollow">common problems</a>" page on the <a href="http://wiki.class-dbi.com/wiki" rel="nofollow">Class::DBI wiki</a> has a <a href="http://wiki.class-dbi.com/wiki/Common_problems#Old_data_due_to_object_index" rel="nofollow">section</a> on this subj...
Spread vs MPI vs zeromq? <p>In one of the answers to <a href="http://stackoverflow.com/questions/31572/broadcast-like-udp-with-the-reliability-of-tcp#31629">Broadcast like UDP with the Reliability of TCP</a>, a user mentions the <a href="http://spread.org">Spread</a> messaging API. I've also run across one called <a h...
<p>MPI was deisgned tightly-coupled compute clusters with fast, reliable networks. Spread and ØMQ are designed for large distributed systems. If you're designing a parallel scientific application, go with MPI, but if you are designing a persistent distributed system that needs to be resilient to faults and network i...
What Are High-Pass and Low-Pass Filters? <p>Graphics and audio editing and processing software often contain functions called "High-Pass Filter" and "Low-Pass Filter". Exactly what do these do, and what are the algorithms for implementing them?</p>
<p>Here is how you implement a low-pass filter using convolution:</p> <pre class="lang-c prettyprint-override"><code>double[] signal = (some 1d signal); double[] filter = [0.25 0.25 0.25 0.25]; // box-car filter double[] result = new double[signal.Length + filter.Length + 1]; // Set result to zero: for (int i=0; i ...
Lazy Loading with a WCF Service Domain Model? <p>I'm looking to push my domain model into a WCF Service API and wanted to get some thoughts on lazy loading techniques with this type of setup.</p> <p>Any suggestions when taking this approach?</p> <hr> <p>when I implemented this technique and step into my app, just be...
<p>Don't do lazy loading over a service interface. Define explicit DTO's and consume those as your data contracts in WCF.</p> <p>You can use NHibernate (or other ORMs) to properly fetch the objects you need to construct the DTOs.</p>
How do I begin using SVN? <p>I am ready to start using SVN, but I have NO (as in the money required for free beer) experience with source control. I have installed subversion on my server (that was easy, 'apt-get install subversion') but now I don't know what to do, how to configure it, or how to use it.<br /><br />Wh...
<p>Eric Sink has an <a href="http://www.ericsink.com/scm/source_control.html">excellent series</a> on source code control aimed at beginners. For Subversion specifics, including setting up and administering a server, the <a href="http://svnbook.red-bean.com/">Subversion book</a> is a great resource, and includes a sect...
Writing cross-platform apps in C <p>What things should be kept most in mind when writing cross-platform applications in C? Targeted platforms: 32-bit Intel based PC, Mac, and Linux. I'm especially looking for the type of versatility that Jungle Disk has in their USB desktop edition ( <a href="http://www.jungledisk.com/...
<p>I maintained for a number of years an ANSI C networking library that was ported to close to 30 different OS's and compilers. The library didn't have any GUI components, which made it easier. We ended up abstracting out into dedicated source files any routine that was not consistent across platforms, and used #defi...
Getting started with SideShow Devices <p>Is there a recommendation for a hardware platform for developing/testing SideShow devices, or is the Emulator adequate?</p>
<p>I'm not really sure about sideshow in particular. But since sideshow uses the microframework I could give you my view on that. For just getting started the emulator is very good. You're going to use the emulator during development most of the time anyway so if you're just figuring things out it is fine to use just t...
Comparison of Lat, Long Coordinates <p>I have a list of more than 15 thousand latitude and longitude coordinates. Given any X,Y coordinates, what is the fastest way to find the closest coordinates on the list?</p>
<p>I did this once for a web site. I.e. find the dealer within 50 miles of your zip code. I used the <a href="http://en.wikipedia.org/wiki/Great-circle_distance">great circle calculation</a> to find the coordinates that were 50 miles north, 50 miles east, 50 miles south, and 50 miles west. That gave me a min and max...
Elegant Snippets of F# <p>I'm currently learning F# quite intensively. I really love it as a language, it just sort of 'feels' right and seems to allow you to produce some succint elegant code.</p> <p>I'm interested in finding some really nice 'wow factor' snippets of F# code which demonstate the elegence of the langu...
<p>My favorite is recursively listing all files under a folder in a four-line sequence expression:</p> <pre><code>open System.IO let rec filesUnderFolder basePath = seq { for file in Directory.GetFiles(basePath) do yield file for subDir in Directory.GetDirectories(basePath) do ...
I don't understand std::tr1::unordered_map <p>I need an associative container that makes me index a certain object through a string, but that also keeps the order of insertion, so I can look for a specific object by its name or just iterate on it and retrieve objects in the same order I inserted them.</p> <p>I think t...
<p>You've asked for the canonical reason why Boost::MultiIndex was made: list insertion order with fast lookup by key. <a href="http://www.boost.org/doc/libs/1_36_0/libs/multi_index/doc/tutorial/basics.html#list_fast_lookup" rel="nofollow">Boost MultiIndex tutorial: list fast lookup</a></p>