input
stringlengths
51
42.3k
output
stringlengths
18
55k
What are the useful new ASP.NET features in the .NET Framework 3.5? <p>I've kept up to date with new features in the C# language as it's moved from version 1 through version 3. I haven't done such a good job keeping up to date with ASP.NET. I feel like some of the post version 1 features are not so good (e.g. the AJA...
<p>For ASP.NET, you have a lot of improvements:</p> <ul> <li>split view (code and design)</li> <li>faster switching between code and design view</li> <li>embedded master pages (one master page in another)</li> <li>javascript debugging</li> </ul> <p>Anyway most of the useful stuff are really in the meat of the languag...
Validating posted form data in the ASP.NET MVC framework <p>I've been playing around with the ASP.NET MVC Framework and the one thing that's really confusing me is how I'm meant to do server side validation of posted form data. I presume I don't post back to the same URL, but if I don't, how do I redisplay the form wi...
<p>Here's an overview of the flow in MVC:</p> <ol> <li>/new - render your "New" view containing a form for the user to fill out</li> <li>User fills out form and it is posted to /create</li> <li>The post is routed to the Create action on your controller</li> <li>In your action method, update the model with the data tha...
What is the difference between Early and Late Binding? <p>What is the difference between early and late binding?</p>
<p>The short answer is that early (or static) binding refers to compile time binding and late (or dynamic) binding refers to runtime binding (for example when you use reflection).</p>
What's the best database storage device? <p>So, the answer should probably be presented in tiers for the size of the application, but I'm wondering about people's experience with choosing where the disk drives used by the database should reside.</p> <p>Here are some of the options:</p> <ul> <li>JBOD - (just a bunch o...
<p>Although SAS-based DAS is likely to be quickest for a single DB server (ideally with 15krpm 2.5 inch SFF disks in a RAID 10 configuration) for most systems you lose a lot of the advantages that a SAN can bring. For that reason I'd always build databases with dual FC (4 or 8Gbps fibre links) adapters into dual SAN sw...
Pre-built regular expression patterns or Regex Libraries? <p>Does anyone use have a good regex library that they like to use? Most of the regexes that you find online either contain bugs or are so focused on the edge cases that it turns into a competition to validate whatever spec 100%. Of course you can write your own...
<p>Boost, for c++</p>
Asynchronous Remoting calls <p>We have a remoting singleton server running in a separate windows service (let's call her RemotingService). The clients of the RemotingService are ASP.NET instances (many many).</p> <p>Currently, the clients remoting call RemotingService and blocks while the RemotingService call is servi...
<p>The idea behind using the ThreadPool is that through it you can control the amount of synchronous threads, and if those get too many, then the thread pool automatically manages the waiting of newer threads.</p> <p>The Asp.Net worked thread (AFAIK) doesn't come from the Thread Pool and shouldn't get affected by your...
Is there a difference between the on_exit() and atexit() functions? <p>Is there any difference between</p> <pre><code> int on_exit(void (*function)(int , void *), void *arg); </code></pre> <p>and</p> <pre><code> int atexit(void (*function)(void)); </code></pre> <p>other than the fact that the function used by o...
<p>You should use <code>atexit()</code> if possible. <code>on_exit()</code> is nonstandard and less common. For example, it's not available on OS X.</p> <p>Kernel.org - <a href="http://www.kernel.org/doc/man-pages/online/pages/man3/on_exit.3.html"><code>on_exit()</code></a>:</p> <blockquote> <p>This function come...
Why do I get the error "Unable to update the password" when calling AzMan? <p>I'm doing a authorization check from a WinForms application with the help of the AzMan authorization provider from Enterprise Library and am receiving the the following error:</p> <blockquote> <p>Unable to update the password. The value pr...
<p>For AzMan with ASP.NET, turn on impersonation in <code>web.config</code> (<code>&lt;identity impersonate="true" username="xx" pasword="xx" /&gt;</code>), and make sure with an AD administrator that the impersonation account has "reader" permissions on the AzMan store; plus, give write permissions to this account on ...
Data Layer Best Practices <p>I am in the middle of a "discussion" with a colleague about the best way to implement the data layer in a new application.</p> <p>One viewpoint is that the data layer should be aware of business objects (our own classes that represent an entity), and be able to work with that object native...
<p>It really depends on your view of the world - I used to be in the uncoupled camp. The DAL was only there to supply data to the BAL - end of story.</p> <p>With emerging technologies such as Linq to SQL and Entity Framework becoming a bit more popular, then the line between DAL and BAL have been blurred a bit. In L2S...
How can I "unaccept" a drag in Flex? <p>Once I've called <code>DragManager.acceptDrag</code> is there any way to "unaccept" the drag? Say that I have a view which can accept drag and drop, but only in certain areas. Once the user drags over one of these areas I call <code>DragManager.acceptDrag(this)</code> (from a <co...
<p>Are you using only the dragEnter method? If you are trying to reject the drag while still dragging over the same component you need to use both the dragEnter and dragOver methods.</p> <p>Check out this example:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adob...
Any good advice on using emacs for C++ project? <p>I'm looking for a good article on using emacs as C/C++ IDE.</p> <p>Something like Steve Yegge's <a href="http://steve.yegge.googlepages.com/effective-emacs">"Effective emacs"</a>.</p>
<p>No specific article, really, but I've found <a href="http://www.emacswiki.org/cgi-bin/wiki">EmacsWiki</a> to be full of useful information. Consider checking out these entries:</p> <ul> <li><a href="http://www.emacswiki.org/cgi-bin/wiki/CPlusPlus">CPlusPlus</a> as a starting point for many C++-related articles, and...
IKVM and Licensing <p>I have been looking into IKVMing Apache's FOP project to use with our .NET app. It's a commercial product, and looking into licensing, IKVM runs into some sticky areas because of its use of GNU Classpath. From what I've seen, no one can say for sure if this stuff can be used in a commercial prod...
<p>There are multiple issues here as ikvm is currently being transitioned away from the GNU classpath system to Sun's OpenJDK. Both are licensed as GPL+Exceptions to state explicitly that applications which merely use the OpenJDK libraries will not be considered derived works.</p> <p>Generally speaking, applications ...
What are the proper permissions for an upload folder with PHP/Apache? <p>Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.</p> <p>I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user ...
<p>You can create a new group with both the apache user and FTP user as members and then make the permission on the upload folder 775. This should give both the apache and FTP users the ability to write to the files in the folder but keep everyone else from modifying them.</p>
How should I unit test a code-generator? <p>This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.</p> <p>I have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code nee...
<p>I started writing up a summary of my experience with my own code generator, then went back and re-read your question and found you had already touched upon the same issues yourself, focus on the execution results instead of the code layout/look.</p> <p>Problem is, this is hard to test, the generated code might not ...
T-Sql date format for seconds since last epoch / formatting for sqlite input <p>I'm guessing it needs to be something like:</p> <pre><code>CONVERT(CHAR(24), lastModified, 101) </code></pre> <p>However I'm not sure of the right value for the third parameter.</p> <p>Thanks!</p> <hr> <p>Well I'm trying to write a scr...
<p>Last epoch is when 1970 GMT?</p> <pre><code>SELECT DATEDIFF(s,'19700101 05:00:00:000',lastModified) </code></pre> <p>See also <a href="http://wiki.lessthandot.com/index.php/Epoch_Date" rel="nofollow" title="excanvas">Epoch Date</a></p>
Passing more parameters in C function pointers <p>Let's say I'm creating a chess program. I have a function</p> <pre><code>void foreachMove( void (*action)(chess_move*), chess_game* game); </code></pre> <p>which will call the function pointer action on each valid move. This is all well and good, but what if I need to...
<p>Ah, if only C supported closures...</p> <p>Antonio is right; if you need to pass extra parameters, you'll need to redefine your function pointer to accept the additional arguments. If you don't know exactly what parameters you'll need, then you have at least three choices:</p> <ol> <li>Have the last argument in yo...
What version of .Net framework ships with SQL Server 2008? <p>Does SQL Server 2008 ship with the .NET 3.5 CLR, so that stored procedures written in CLR can use 3.5 features?</p>
<p>Actually it ships with .NET 3.5 SP1. So yes, the stored procs can use 3.5 features and libraries.</p>
ASP.NET Proxy Application <p>Let me try to explain what I need. I have a server that is visible from the internet. What I need is to create a ASP.NET application that get the request of a web Site and send to a internal server, then it gets the response and publish the the info. For the client this should be totally tr...
<p>Why won't any old proxy software work for this? Why does it need to be an ASP.NET application? There are TONS of tools out there (both Windows and *nix) that will get the job done quite easily. Check <a href="http://www.squid-cache.org/" rel="nofollow" title="excanvas">Squid</a> or <a href="http://www.grok.co.uk/...
Speeding up an ASP.Net Web Site or Application <p>I have an Ajax.Net enabled ASP.Net 2.0 web site. Hosting for both the site and the database are out of my control as is the database's schema. In testing on hardware I do control the site performs well however on the client's hardware, there are noticeable delays when r...
<ol> <li><a href="http://weblogs.asp.net/scottgu/archive/2008/05/12/visual-studio-2008-and-net-framework-3-5-service-pack-1-beta.aspx">Script Combining in .net 3.5 SP1</a></li> <li><a href="http://developer.yahoo.com/performance/rules.html">Best Practices for fast websites</a></li> <li>HTTP Compression (gzip)</li> <li>...
What are the list of Resharper like plugins for VS I should consider? <p>My license for Whole Tomatoes Visual AssistX is about to expire and I'm not really planning on renewing it. I use it for spell checking but that's about it. The refactoring abilities have been a little disappointing. Before I just jump into Res...
<p>Aside from trying out Visual AssistX, the only other one I've tried is ReSharper (which I highly recommend). If you do decide to go for ReSharper, you'll likely notice that it's missing a spell checker for code though - however the <a href="http://www.agentsmithplugin.com/" rel="nofollow" title="excanvas">Agent Smit...
How do you kill all current connections to a SQL Server 2005 database? <p>I want to rename a database, but keep getting the error that 'couldn't get exclusive lock' on the database, which implies there is some connection(s) still active.</p> <p>How can I kill all the connections to the database so that I can rename it...
<p>See <a href="http://wiki.lessthandot.com/index.php/Kill_All_Active_Connections_To_A_Database">Kill All Active Connections To A Database</a>.</p> <p>The reason that the approach that <a href="http://stackoverflow.com/questions/11620/how-do-you-kill-all-current-connections-to-a-sql-server-2005-database/11627#11627">A...
Design pattern for parsing binary file data and storing in a database <p>Does anybody recommend a design pattern for taking a binary data file, parsing parts of it into objects and storing the resultant data into a database? </p> <p>I think a similar pattern could be used for taking an XML or tab-delimited file and p...
<ol> <li>Just write your file parser, using whatever techniques come to mind</li> <li>Write lots of unit tests for it to make sure all your edge cases are covered</li> </ol> <p>Once you've done this, you will actually have a reasonable idea of the problem/solution.</p> <p>Right now you just have theories floating aro...
How can I get Unicode characters to display properly for the tooltip for the IMG ALT in IE7? <p>I've got some Japanese in the ALT attribute, but the tooltip is showing me the ugly block characters in the tooltip. The rest of the content on the page renders correctly. So far, it seems to be limited to the tooltips.</p...
<p>This is because the font used in the tooltip doesn't include the characters you are trying to display. Try installing a font pack that includes those characters. I'm affraid you can't do much for your site's visitors other than implementating a tooltip yourself using javascript.</p>
How can I create virtual machines as part of a build process using MSBuild and MS Virtual Server and/or Hyper-V Server Virtualization? <p>What I would like to do is create a clean virtual machine image as the output of a build of an application.</p> <p>So a new virtual machine would be created (from a template is fine...
<p>You can actually script a fair number of tasks in MS Virtual Server:</p> <p><a href="http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true" rel="nofollow" title="excanvas"><a href="http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true" rel="nofollow">http://www.micr...
Configurable Table Prefixes with a .Net OR/M? <p>In a web application like wiki or forums or blogging software, it is often useful to store your data in a relational database. Since many hosting companies offer a single database with their hosting plans (with additional databases costing extra) it is very useful for yo...
<p>I've now researched what it takes to do this in both Entity Framework and LINQ to SQL and <a href="http://theruntime.com/blogs/jacob/archive/2008/08/27/changing-table-names-in-an-orm.aspx" rel="nofollow">documented the steps required in each</a>. It's much longer than answers here tend to be so I'll be content with ...
How much extra overhead is generated when sending a file over a web service as a byte array? <p>This <a href="http://stackoverflow.com/questions/11782/file-uploads-via-web-services" rel="nofollow" title="excanvas">question and answer</a> shows how to send a file as a byte array through an XML web service. How much over...
<p>Typically a byte array is sent as a <code>base64</code> encoded string, not as individual bytes in tags. </p> <p><a href="http://en.wikipedia.org/wiki/Base64" rel="nofollow">http://en.wikipedia.org/wiki/Base64</a></p> <p>The <code>base64</code> encoded version is about <strong>137%</strong> of the size of the orig...
How can I determine the IP of my router/gateway in Java? <p>How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway's IP?</p> <p>This is somewhat easy in .NET if you know your way around. But how d...
<p>On Windows, OSX, Linux, etc then Chris Bunch's answer can be much improved by using </p> <pre><code>netstat -rn </code></pre> <p>in place of a <code>traceroute</code> command.</p> <p>Your gateway's IP address will appear in the second field of the line that starts either <code>default</code> or <code>0.0.0.0</cod...
How do you log errors (Exceptions) in your ASP.NET apps? <p>I'm looking for the best way to log errors in an ASP.NET application. I want to be able to receive emails when errors occurs in my application, with detailed information about the Exception and the current Request.</p> <p>In my company we used to have our own...
<p>I use <a href="http://code.google.com/p/elmah/">elmah</a>. It has some really nice features and here is a <a href="http://www.codeproject.com/KB/aspnet/ELMAHDemo.aspx">CodeProject</a> article on it. I think the StackOverflow team uses elmah also!</p>
Access to global application settings <p>A database application that I'm currently working on, stores all sorts of settings in the database. Most of those settings are there to customize certain business rules, but there's also some other stuff in there.</p> <p>The app contains objects that specifically do a certain t...
<p>You could use Martin Fowlers ServiceLocator pattern. In php it could look like this:</p> <pre><code>class ServiceLocator { private static $soleInstance; private $globalSettings; public static function load($locator) { self::$soleInstance = $locator; } public static function globalSettings() { if...
Considering N2 CMS but worried about performance. Is this justified? <p>Hy, does anyone worked with N2 Content Management System(<a href="http://www.codeplex.com/n2" rel="nofollow">http://www.codeplex.com/n2</a>). If yes, how does it perform, performance wise(under heavy load)? It seems pretty simple and easy to use.</...
<p>Maybe try this question at <a href="http://www.codeplex.com/n2/Thread/List.aspx" rel="nofollow"><a href="http://www.codeplex.com/n2/Thread/List.aspx" rel="nofollow">http://www.codeplex.com/n2/Thread/List.aspx</a></a></p> <p>They might be able to tell you about performance limitations or bottlenecks.</p>
Programmatically list WMI classes and their properties <p>Hey everyone, Is there any known way of listing the WMI classes and their properties available for a particular system? Im interested in a vbscript approach, but please suggest anything really :)</p> <p>P.S. Great site.</p>
<p>I believe this is what you want.</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=2cc30a64-ea15-4661-8da4-55bbc145c30e&amp;displaylang=en" rel="nofollow">WMI Code Creator</a></p> <p>A part of this nifty utility allows you to browse namespaces/classes/properties on the local and remote PCs, ...
Add .NET 2.0 SP1 as a prerequisite for deployment project <p>I have a .NET 2.0 application that has recently had contributions that are Service Pack 1 dependent. The deployment project has detected .NET 2.0 as a prerequisite, but NOT SP1. How do I include SP1 as a dependency/prerequisite in my deployment project?</p>...
<p>You'll want to setup launch condition in your deployment project to make sure version 2.0 SP1 is installed. You'll want to set a requirement based off the MsiNetAssemblySupport variable, tied to the version number of .NET 2.0 SP1 (2.0.50727.1433 and above according to <a href="http://blogs.msdn.com/astebner/archive/...
Arrays of Arrays in Java <p>This is a nasty one for me... I'm a PHP guy working in Java on a JSP project. I know how to do what I'm attempting through too much code and a complete lack of finesse. I'd prefer to do it RIGHT. :) Here is the situation:</p> <p>I'm writing a small display to show customers what days th...
<p>Don't try to be as dynamic as PHP is. You could try to first <strong>define</strong> what you need.</p> <pre><code>interface Season { public string getDays(); } interface User { public Season getWinter(); public Season getSpring(); public Season getSummer(); public Season getFall(); } interfac...
Large Data Sets <p>I'm always looking for large data sets to test various types of programs on. Does anyone have any suggestions?</p>
<p>Check out the <a href="http://www.netflixprize.com/">netflix contest</a>. I believe they exposed their database, or a large subset, to facilitate the contest.</p> <p>UPDATE: <a href="http://www.netflixprize.com/faq">Their faq</a> says they have 100 million entries in the subset you can download.</p>
What is a good way to denormalize a mysql database? <p>I have a large database of normalized order data that is becoming very slow to query for reporting. Many of the queries that I use in reports join five or six tables and are having to examine tens or hundreds of thousands of lines.</p> <p>There are lots of querie...
<p>I know more about mssql that mysql, but I don't think the number of joins or number of rows you are talking about should cause you too many problems with the correct indexes in place. Have you analyzed the query plan to see if you are missing any?</p> <p><a href="http://dev.mysql.com/doc/refman/5.0/en/explain.html...
How to setup site-wide variables in php? <p>I want to define something like this in <em>php</em>:</p> <pre><code>$EL = "\n&lt;br /&gt;\n"; </code></pre> <p>and then use that variable as an "endline" marker all over my site, like this:</p> <pre><code>echo "Blah blah blah{$EL}"; </code></pre> <p>How do I define $EL o...
<p>Most PHP sites should have a file (I call it a header) that you include on every single page of the site. If you put that first line of code in the header file, then include it like this on every page:</p> <pre><code> include 'header.php'; </code></pre> <p>you won't have to use the global keyword or anything, the ...
What do ref, val and out mean on method parameters? <p>I'm looking for a clear, concise and accurate answer. </p> <p>Ideally as the actual answer, although links to good explanations welcome.</p> <p>This also applies to VB.Net, but the keywords are different - <code>ByRef</code> and <code>ByVal</code>.</p>
<p>By default (in C#), passing an object to a function actually passes a copy of the reference to that object. Changing the parameter itself only changes the value in the parameter, and not the variable that was specified.</p> <pre><code>void Test1(string param) { param = "new value"; } string s1 = "initial value...
Best practice for webservices <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>T...
<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>
A ThreadStateException occures when trying to restart a thread <p>From time to time I get a System.Threading.ThreadStateException when attempting to restart a thread. The code in question is as follows:</p> <pre><code>// Make sure the thread is done stopping while (this.mThread.ThreadState == ThreadState.Running) { ...
<p>It's possible for a thread to be in more than one state at once therefore the ThreadState property is actually a bitmap of possible states. So testing for equality with just one state will not give you the right result. You would need to do something like:</p> <pre><code>if((mThread.ThreadState &amp; ThreadState.Ru...
How do I integrate my continuous integration system with my bug tracking system? <p>I use cruisecontrol.rb for CI and FogBugz for bug tracking, but the more general the answers, the better.</p> <p>First is the technical problem: is there an API for FogBugz? Are there good tutorials, or better yet, pre-written code?</...
<p>At my company we've recently adopted the (commercial) Atlassian stack - including JIRA for issue tracking and Bamboo for builds. Much like the Microsoft world (I'm guessing - we're a Java shop), if you get all your products from a single vendor you get the bonus of tight integration.</p> <p>For an example of how th...
Does CruiseControl.NET run on IIS 7.0? <p>I'm new to development (an admin by trade) and I'm setting up my development environment and I would like to set up a CruiseControl.Net server on Server 2008. A quick Google did not turn up any instructions for getting it running on IIS 7.0, so I was wondering if anyone had ex...
<p>Here is a helpful article that worked for me:</p> <p><a href="http://huntjason.wordpress.com/2009/08/13/getting-cruisecontrol-net-working-under-iis7/" rel="nofollow">Getting CruiseControl.NET working under IIS7</a></p>
The theory (and terminology) behind Source Control <p>I've tried using source control for a couple projects but still don't really understand it. For these projects, we've used TortoiseSVN and have only had one line of revisions. (No trunk, branch, or any of that.) If there is a recommended way to set up source cont...
<p>Think of source control as a giant "Undo" button for your source code. Every time you check in, you're adding a point to which you can roll back. Even if you don't use branching/merging, this feature alone can be very valuable.</p> <p>Additionally, by having one 'authoritative' version of the source control, it bec...
Purpose of {1} in this regular expression to match url protocols <p>I was reading <a href="http://stackoverflow.com/questions/6173/regular-expression-for-parsing-links-from-a-webpage">this question</a> about how to parse URLs out of web pages and had a question about the <a href="http://stackoverflow.com/questions/6173...
<p>@<a href="http://stackoverflow.com/questions/13470/question-about-specific-regular-expression#13479" rel="nofollow">Rob</a>: I disagree. To enforce what you are asking for I think you would need to use negative-look-behind, which is possible but is certainly not related to use {1}. Neither version of the regexp ad...
Insert Update stored proc on SQL Server <p>I've written a stored proc that will do an update if a record exists, otherwise it will do an insert. It looks something like this:</p> <pre><code>update myTable set Col1=@col1, Col2=@col2 where ID=@ID if @@rowcount = 0 insert into myTable (Col1, Col2) values (@col1, @col2) <...
<p>Your assumption is right, this is the optimal way to do it and it's called <a href="http://en.wikipedia.org/wiki/Upsert">upsert/merge</a>.</p> <p><a href="http://www.sqlservercentral.com/articles/T-SQL/61773/">Importance of UPSERT - from sqlservercentral.com</a>: </p> <blockquote> <p>For every update in the case...
CASE tools <p>I was using a CASE called <a href="http://www.magicsoftware.com/" rel="nofollow">MAGIC</a> for a system I'm developing, I've never used this kind of tool before and at first sight I liked, a month later I had a lot of the application generated, I felt very productive and ... I would say ... satisfied.</p>...
<p>We use a CASE tool at my current company for code generation and we are trying to move away from it.</p> <p>The benefits that it brings - a graphical representation of the code making components 'easier' to pick up for new developers - are outweighed by the disadvantges in my opinion.</p> <p>Those main disadvantag...
Speed difference in using inline strings vs concatenation in php5? <p>(assume php5) consider</p> <pre><code>&lt;?php $foo = 'some words'; //case 1 print "these are $foo"; //case 2 print "these are {$foo}"; //case 3 print 'these are ' . $foo; ?&gt; </code></pre> <p>Is there much of a di...
<p>The performance difference has been <a href="http://nikic.github.com/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth.html" rel="nofollow">irrelevant</a> since at least January 2012, and likely earlier:</p> <pre><code>Single quotes: 0.061846971511841 seconds Double quotes: 0.061599016189575 seconds </code><...
Developer testing vs. QA team testing - What is the right division of work? <p>While trying to advocate more developer testing, I find the argument "Isn't that QA's job?" is used a lot. In my mind, it doesn't make sense to give the QA team all testing responsibilities, but at the same time Spolsky and others say you s...
<p>It's the difference between "black box" testing (where you know what the code is supposed to do, but not how it works), and "white box" testing (where knowing how it works drives how you test it). "Black box" testing is what most people think of when you mention Quality Assurance.</p> <p>I work for a company where ...
How do I make Powershell run a batch file and then stay open? <p>For example; with the old command prompt it would be:</p> <pre><code>cmd.exe /k mybatchfile.bat </code></pre>
<p>Drop into a cmd instance (or indeed PowerShell itself) and type this:</p> <pre><code>powershell -? </code></pre> <p>You'll see that powershell.exe has a "-noexit" parameter which tells it not to exit after executing a "startup command".</p>
Using OpenGL textures larger than window/display size <p>I'm having problems using textures that are larger than the OpenGL window or the display size as non-display render targets.<br> What's the solution for this problem?</p>
<p>There's a simple solution.</p> <p>Assuming your (non-display) textures are <strong>1024x1024</strong> and you are restricted to a <strong>256x256</strong> window/display.</p> <pre><code>unsigned int WIN_WIDTH = 256; unsigned int WIN_HEIGHT = WIN_WIDTH; unsigned int TEX_WIDTH = 1024; unsigned int TEX_HEIGHT = TEX_W...
RGB to monochrome conversion <p>How do I convert the RGB values of a pixel to a single monochrome value?</p>
<p>I found one possible solution in the <a href="http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html">Color FAQ</a>. The <em>luminance component</em> Y (from the <em>CIE XYZ system</em>) captures what is most perceived by humans as color in one channel. So, use those coefficients:</p> <pre><code>mono = (0.2125...
How do I call a Flex SWF from a remote domain using Flash (AS3)? <p>I have a Flex swf hosted at <a href="http://www.a.com/a.swf" rel="nofollow">http://www.a.com/a.swf</a>. I have a flash code on another doamin that tries loading the SWF:</p> <pre><code>_loader = new Loader(); var req:URLRequest = new URLRequest("http:...
<p>This is all described in <a href="http://livedocs.adobe.com/flex/3/progAS_flex3.pdf" rel="nofollow" title="Flex Documentation: System.Security.allowDomain">The Adobe Flex 3 Programming ActionScript 3 PDF</a> on page 550 (Chapter 27: Flash Player Security / Cross-scripting):</p> <blockquote> <p>If two SWF files wr...
GLUT pop-up menus <p>Is it easy to create GLUT pop-up menus for my OpenGL application? If yes, how?</p>
<p>Creating and using pop-up menus with GLUT is very simple. Here is a code sample that creates a pop-up menu with 4 options:</p> <pre class="lang-c prettyprint-override"><code>// Menu items enum MENU_TYPE { MENU_FRONT, MENU_SPOT, MENU_BACK, MENU_BACK_FRONT, }; // Assign a default valu...
Why are there so few modal-editors that aren't vi*? <p>Pretty much every other editor that isn't a vi descendant (vim, cream, vi-emu) seems to use the emacs shortcuts (<kbd>ctrl</kbd>+<kbd>w</kbd> to delete back a word and so on)</p>
<p>Early software was often modal, but usability took a turn at some point, away from this style. </p> <p>VI-based editors are total enigmas -- they're the only real surviving members of that order of software. </p> <p>Modes are a no-no in usability and interaction design because we humans are fickle mammals who cann...
LINQ-to-SQL vs stored procedures? <p>I took a look at the "Beginner's Guide to LINQ" post here on StackOverflow (<a href="http://stackoverflow.com/questions/8050/beginners-guide-to-linq">http://stackoverflow.com/questions/8050/beginners-guide-to-linq</a>), but had a follow-up question:</p> <p>We're about to ramp up a ...
<p>Some advantages of LINQ over sprocs:</p> <ol> <li><strong>Type safety</strong>: I think we all understand this.</li> <li><strong>Abstraction</strong>: This is especially true with <a href="http://msdn.microsoft.com/en-us/library/bb386964.aspx">LINQ-to-Entities</a>. This abstraction also allows the framework to add...
How to organize dataset queries to improve performance <p>I don't know when to add to a dataset a tableadapter or a query from toolbox. Does it make any difference?</p> <p>I also dont know where to create instances of the adapters. </p> <ul> <li>Should I do it in the <code>Page_Load</code>? </li> <li>Should I just do...
<blockquote> <p>Should I just do it when I'm going to use it?</p> </blockquote> <p>I would recommend that you only retrieve the data when you are going to use it. If you are not going to need it, there is no reason to waste resources by retrieving it in Page_Load. If you are going to need it multiple times throughou...
Is it possible to disable command input in the toolbar search box? <p>In the Visual Studio toolbar, you can enter commands into the search box by prefixing them with a > symbol. Is there any way to disable this? I've never used the feature, and it's slightly annoying when trying to actually search for something that yo...
<p>This is a really cool feature. I've poked through the <a href="http://msdn.microsoft.com/en-us/library/1665hyw1(VS.80).aspx" rel="nofollow">feature documentation</a>, and the accompanying <a href="http://msdn.microsoft.com/en-us/library/c338aexd(VS.80).aspx" rel="nofollow">command list</a>, and not a heck of a lot i...
How best to use File Version and Assembly Version? <p>In .NET there are two version numbers available when building a project, File Version and Assembly Version. How are you using these numbers? Keeping them the same? Auto-incrementing one, but manually changing the other?</p> <p>Also what about the <code>AssemblyIn...
<p>In solutions with multiple projects, one thing I've found very helpful is to have all the AssemblyInfo files point to a single project that governs the versioning. So my AssemblyInfos have a line:</p> <pre><code>[assembly: AssemblyVersion(Foo.StaticVersion.Bar)] </code></pre> <p>I have a project with a single file...
How do you set your LAMP testing server? <p>I am using xampp on Windows, but I would like to use something closer to my server setup.</p> <p><a href="http://phpimpact.wordpress.com/2008/05/24/virtual-appliances-lamp-development-made-easy/" rel="nofollow">Federico Cargnelutti tutorial</a> explains how to setup LAMP VMW...
<p>Assuming you have VMware workstation, VMware player or anything that can run vmware appliance, you just need to:</p> <ol> <li>Download, unzip <a href="http://www.vmware.com/appliances/directory/1248" rel="nofollow">Ubuntu 8.04 Server</a> and start the virtual machine.</li> <li>Update ubuntu and set the layout and t...
Changing CURRENT save/default directory in Delphi 2007 without using Save-As <p>I have a project group that contains a project I'm working on as well as some related component and packages. I prefer to keep the database links active during design-time. </p> <p>I know how to write the code which would change the databa...
<p>I am not sure I completely understand your question.</p> <ul> <li>If you are referring to the folder the IDE has as the current folder, then you can just change the shortcut that launches Delphi to set the current directory where ever you want it to be.</li> </ul>
How do you create a debug only function that takes a variable argument list? Like printf() <p>I'd like to make a debug logging function with the same parameters as <code>printf</code>. But one that can be removed by the pre-processor during optimized builds.</p> <p>For example:</p> <pre><code>Debug_Print("Warning: v...
<p>I still do it the old way, by defining a macro (XTRACE, below) which correlates to either a no-op or a function call with a variable argument list. Internally, call vsnprintf so you can keep the printf syntax:</p> <pre><code>#include &lt;stdio.h&gt; void XTrace0(LPCTSTR lpszText) { ::OutputDebugString(lpszText)...
Optimizing the PDF Export of Huge Reports in Sql Reporting Services 2005 <p>First off I understand that it is a horrible idea to run extremely large/long running reports. I am aware that Microsoft has a rule of thumb stating that a SSRS report should take no longer than 30 seconds to execute. However sometimes gargant...
<blockquote> <ol> <li>Does anyone know of anyway to reduce/optimize the PDF export phase and or the size of the PDF without lowering the total page count?</li> </ol> </blockquote> <p>I have a few ideas and questions:<br /> 1. Is this a graphics-heavy report? If not, do you have tables that start out as te...
Best practices for managing and deploying large JavaScript apps <p>What are some standard practices for managing a medium-large JavaScript application? My concerns are both speed for browser download and ease and maintainability of development.</p> <p>Our JavaScript code is roughly "namespaced" as:</p> <pre><code>var...
<p>The approach that I've found works for me is having seperate JS files for each class (just as you would in Java, C# and others). Alternatively you can group your JS into application functional areas if that's easier for you to navigate.</p> <p>If you put all your JS files into one directory, you can have your serve...
How do I get rid of Home in ASP.Net MVC? <p>I know this site is written using ASP.Net MVC and I do not see "/Home" in the url. This proves to me that it can be done. What special route and do I need?</p>
<p>Just change "Home" to an empty string.</p> <pre><code>routes.MapRoute( "Home", "", new { action = Index, controller = Home } ); </code></pre>
How do you begin designing a large system? <p>It's been mentioned to me that I'll be the sole developer behind a large new system. Among other things I'll be designing a UI and database schema.</p> <p>I'm sure I'll receive some guidance, but I'd like to be able to knock their socks off. What can I do in the meantime...
<p>Do you know much about OOP? If so, look into Spring and Hibernate to keep your implementation clean and <a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/01/08/Orthogonal-Code.aspx">orthogonal</a>. If you get that, you should find TDD a good way to keep your design compact and lean, especially since ...
Runtime Configuration in .Net (specifically the EntLib) <p>I'm looking for a way to configure a DB connection at runtime; specifically using the Enterprise Library. I see that there's a *.Data.Configuration (or something close to this ... don't recall off the top of my head) assembly but am finding not much on the int...
<p>If you're using a winforms app you could try using <a href="http://msdn.microsoft.com/en-us/library/aa221771(office.11).aspx" rel="nofollow">UserProperties</a> to store this info. Another possible solution could be <a href="http://msdn.microsoft.com/en-us/library/2tw134k3.aspx" rel="nofollow">custom configuration se...
Read from .msg files <p>I need to read from Outlook .MSG file in .NET <em>without</em> using COM API for Outlook (cos it will not be installed on the machines that my app will run). Are there any free 3rd party libraries to do that? I want to extract From, To, CC and BCC fields. Sent/Receive date fields would be good i...
<p><strong>Update:</strong> I have found a 3rd party COM library called <a href="http://www.dimastr.com/redemption/">Outlook Redemption</a> which is working fine for me at the moment. If you use it via COM-Interop in .NET, don't forget to release every COM object after you are done with it, otherwise your application c...
Entity diagrams in ASP.NET MVC <p>What's the best way/tool to display nice diagrams with entity relationships in ASP MVC views? <br /> i.e. servers and and applications, or servers with other servers.</p> <p>Are there any third party tools out there that can do this? <br /> I've been searching around things like Tel...
<p>Here are some 3rd-party diagramming tools:</p> <ul> <li><a href="http://www.nevron.com/Products.DiagramFor.NET.Overview.aspx" rel="nofollow">http://www.nevron.com/Products.DiagramFor.NET.Overview.aspx</a></li> <li><a href="http://www.nwoods.com/GO/dotnet.htm" rel="nofollow">http://www.nwoods.com/GO/dotnet.htm</a></...
How do I convert a string to an enum in C#? <p>What's the best way to convert a string to an enumeration value in C#?</p> <p>I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to the enumeration ...
<p>It's rather ugly:</p> <pre><code>StatusEnum MyStatus = (StatusEnum) Enum.Parse(typeof(StatusEnum), "Active", true); </code></pre> <p>I tend to simplify this with:</p> <pre><code>public static T ParseEnum&lt;T&gt;(string value) { return (T) Enum.Parse(typeof(T), value, true); } </code></pre> <p>Then I can do:...
C# Auto Clearing Winform Textbox <p>I have a user that want to be able to select a textbox and have the current text selected so that he doesn't have to highlight it all in order to change the contents. </p> <p>The contents need to be handle when enter is pushed. That part I think I have figured out but any suggesti...
<p>Hook into the KeyPress event on the TextBox, and when it encounters the Enter key, run your hardware setting code, and then highlight the full text of the textbox again (see below) - Windows will take care of clearing the text with the next keystroke for you.</p> <pre><code>TextBox1.Select(0, TextBox1.Text.Length);...
What's the best way to get started with OSGI? <p>What makes a module/service/bit of application functionality a particularly good candidate for an OSGi module? </p> <p>I'm interested in using <a href="http://en.wikipedia.org/wiki/OSGi">OSGi</a> in my applications. We're a Java shop and we use Spring pretty extensively...
<p>Well, since you can not have one part OSGi and one part non-OSGi you'll need to make your entire app OSGi. In its simplest form you make a single OSGi bundle out of your entire application. Clearly this is not a best practice but it can be useful to get a feel for deploying a bundle in an OSGi container (Equinox, Fe...
Should DB layer members be static or instance? <p>I've seen projects where the classes in the DB layer have just static functions in them and other projects where those classes need to be instantiated to get access to the member functions. </p> <p>Which is "better" and why?</p>
<p>I like a single object to be correlated to a single record in the database, i.e. an object must be instantiated. This is your basic <a href="http://martinfowler.com/eaaCatalog/activeRecord.html" rel="nofollow">ActiveRecord</a> pattern. In my experience, the one-object-to-one-row approach creates a much more fluid ...
How do I handle page flow in MVC (particularly asp.net) <p>If you had to provide a wizard like form entry experience in mvc how would you abstract the page flow?</p>
<p>Investigate the post-redirect-get pattern.</p> <p><a href="http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx" rel="nofollow">http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx</a><br /> <a href="http://devlicio.us/blogs/tim_barcz/archive/2008/08/22/prg-pattern-in-the-asp-net-mvc-framework.aspx"...
How do I generate a hashcode from a byte array in C#? <p>Say I have an object that stores a byte array and I want to be able to efficiently generate a hashcode for it. I've used the cryptographic hash functions for this in the past because they are easy to implement, but they are doing a lot more work than they should ...
<p>The hash code of an object shouldn't be unique. </p> <p>The checking rule is: </p> <ul> <li>Are the hash codes equal? Then call the full (slow) <code>Equals</code> method.</li> <li>Are the hash codes not equal? Then the two items are definitely not equal.</li> </ul> <p>All you want is a <code>GetHashCode</code> a...
Removing N items from a list conditionally <p>I was writing some <strong>ASP.NET</strong> control when I came to the scenario where I needed to remove items from a list, only when they matched a certain condition.</p> <p>The <code>RemoveAll</code> method of the generic <code>List</code> class does a good job, but remo...
<p>If you want to specify both a limit for number of items to remove and a condition to select the items to remove, you can use this approach:</p> <pre><code>int limit = 30; // Suppose you want to remove 30 items at most list.RemoveAll(item =&gt; ShouldIRemoveThis(item) &amp;&amp; limit-- &gt; 0); </code></pre>
Best .NET build tool <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/476163">NAnt or MSBuild, which one to choose and when?</a> </p> </blockquote> <p>What is the best build tool for <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET</a>?</p> <p>I cur...
<p>We actually use a combination of <a href="http://en.wikipedia.org/wiki/NAnt">NAnt</a> and <a href="http://en.wikipedia.org/wiki/MSBuild">MSBuild</a> with <a href="http://en.wikipedia.org/wiki/CruiseControl">CruiseControl</a>. NAnt is used for script flow control and calls MSBuild to compile projects. After the physi...
How do you deal with transport-level errors in SqlConnection? <p>Every now and then in a high volume .NET application, you might see this exception when you try to execute a query:</p> <blockquote> <p>System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server.<...
<p>I posted <a href="http://stackoverflow.com/questions/154897/what-do-you-do-if-you-cannot-resolve-a-bug#155077">an answer on another question</a> on another topic that might have some use here. That answer involved SMB connections, not SQL. However it was identical in that it involved a low-level transport error.</...
Internationalization in SSRS <p>What's the best way to handle translations for stock text in a <code>SSRS</code>. For instance - if I have a report that shows a grid of contents what's the best way to have the correct translation for the header of that grid show up, assuming the culture of the report is set correctly.<...
<p>AS far as I know, there is no way to localize a report (meaning automating the translation of string litterals)...</p> <p>Like you said,you basically have to use the User!Language global variable to catch the user's settings and then use that to retrieve the appropriate strings from the DB...</p> <p>However, you c...
Haskell's algebraic data types <p>I'm trying to fully understand all of Haskell's concepts.</p> <p>In what ways are algebraic data types similar to generic types, e.g., in C# and Java? And how are they different? What's so algebraic about them anyway? </p> <p>I'm familiar with universal algebra and its rings and fiel...
<p>Haskell's <em>algebraic data types</em> are named such since they correspond to an <em>initial algebra</em> in category theory, giving us some laws, some operations and some symbols to manipulate. We may even use algebraic notation for describing regular data structures, where:</p> <ul> <li><code>+</code> represent...
Getting Started with Unit Testing <blockquote> <p>Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are:</p> <ul> <li>Running the tests becomes automate-able and repeatable</li> <li>You can test at a much more granular level t...
<p>Ok here's some best practices from some one who doesn't unit test as much as he should...cough.</p> <ol> <li>Make sure your tests test <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=35578" rel="nofollow" title="one">one</a> thing and one thing only.</li> <li>Write unit tests as you go. Preferably <a hre...
VS 2008 - Detachable code tabs <p>Admittedly this might not be a problem on larger screens, but my employer is abit tight and refuses to buy monitors larger than 19inch, this means that I dont have much screen real estate to view all the Visual Studio windows and my code at the same time, or two pieces of code at once....
<p>You can right click on the tab strip and insert a new vertical (or horizontal) tab group.</p> <p>This allows you to view multiple tabs at the same time.</p>
Recommended notes/doc service that offers an API? <p>I'm looking for a good online service for notes/documents (think Google Docs) that has a decent web UI and offers an API for clients to read/write the stored data.</p> <p>Google Docs is almost perfect - except there's no way to update the contents of existing docume...
<p>None of the APIs for the more 'Word' like online editors seem to have any 'edit' functionality, just download and upload. This is obviously due to the complexity of the documents being stored.</p> <p>With Google Docs API you can get a document, edit it, and then re-upload it (you may need to delete the previous ver...
What is the best way to partition terabyte drive in a linux development machine? <p>I have a new 1 TB drive coming in tomorrow. What is the best way to divide this space for a development workstation?</p> <p>The biggest problem I think I'm going to have is that some partitions (probably /usr) will become to small afte...
<p>If you partition your drive using <a href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">LVM</a> you won't have to worry about any individual partition running out of space in the future. Just move space around as necessary.</p>
How do you spawn another process in C? <p>How do you run an external program and pass it command line parameters using C? If you have to use operating system API, include a solution for Windows, Mac, and Linux.</p>
<p>If you want to perform more complicated operations, like reading the output of the external program, you may be better served by the <a href="http://man.he.net/man3/popen">popen</a> system call. For example, to programmatically access a directory listing (this is a somewhat silly example, but useful <em>as</em> an e...
When to use IList and when to use List <p>I know that IList is the interface and List is the concrete type but I still don't know when to use each one. What I'm doing now is if I don't need the Sort or FindAll methods I use the interface. Am I right? Is there a better way to decide when to use the interface or the conc...
<p>There are two rules I follow:</p> <ul> <li>Accept the most basic type that will work</li> <li>Return the richest type your user will need</li> </ul> <p>So when writing a function or method that takes a collection, write it not to take a List, but an IList&lt;T&gt;, an ICollection&lt;T&gt;, or IEnumerable&lt;T&gt;....
Create an encrypted ZIP file in Python <p>I'm creating an ZIP file with ZipFile in Python 2.5, it works ok so far:</p> <pre><code>import zipfile, os locfile = "test.txt" loczip = os.path.splitext (locfile)[0] + ".zip" zip = zipfile.ZipFile (loczip, "w") zip.write (locfile) zip.close() </code></pre> <p>but I couldn't...
<p>I created a simple library to create a password encrypted zip file in python. - <a href="https://github.com/smihica/pyminizip"><strong>here</strong></a></p> <pre><code>import pyminizip compression_level = 5 # 1-9 pyminizip.compress("src.txt", "dst.zip", "password", compression_level) </code></pre> <p><strong>The ...
What areas of specialization within programming would you recommend to a beginner <p>I am a student studying software development, and I feel programming, in general, is too broad of a subject to try to know everything. To be proficient, you have to decide which areas to focus your learning and understanding. Certain s...
<p>Ben, Almost all seasoned programmers are still students in programming. You never stops learning anything when you are a developer. But if you are really starting off on your career then you should be least worried about the specialization thing. All APIs, frameworks and skills that you expect that gives you a long ...
Using GLEW to use OpenGL extensions under Windows <p>I've been using OpenGL extensions on Windows the <a href="http://stackoverflow.com/questions/14413/using-opengl-extensions-on-windows" rel="nofollow">painful way</a>. Is GLEW the easier way to go? How do I get started with it?</p>
<p>Yes, the <strong>OpenGL Extension Wrangler Library</strong> (GLEW) is a painless way to use OpenGL extensions on Windows. Here's how to get started on it:</p> <p>Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the <a href="http://www.opengl.org/registry/">OpenGL...
Language Conversion Testing <p>We created a tool which converts a language called P2, a language similar to assembly which I think exists only in Japan, to C#. There are at least a hundred modules written in P2 and we want to verify if the conversion to C# is right? How can we test this?</p>
<p>You don't test the converter, you test the final code. </p> <p>If the code doesn't compile, clearly your converter is failing. If the code compiles and your functionality tests fail, then you can tweak the code so that it passes the test. If you are fairly successful you should see that you only need to fix the mod...
Why are DispatcherObject.CheckAccess() and VerifyAccess() hidden from Intellisense? <p>The <code>System.Windows.Threading.DispatcherObject</code> class (which <code>DependencyObject</code> is based on) contains a useful function, called <code>CheckAccess()</code>, that determines whether or not the code is running on t...
<p>A Microsoft employee <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bd0e6f6c-cadd-48f1-8e1a-163c2f17e4ca/">recently stated</a> CheckAccess is used only for "advanced scenarios", so they hid it from Intellisense.</p> <blockquote> <p>"CheckAccess and VerifyAccess have always been marked to be n...
Suitable alternative to CryptEncrypt <p>We have a situation in our product where for a long time some data has been stored in the application's database as SQL string (choice of MS SQL server or sybase SQL anywhere) which was encrypted via the Windows API function <a href="http://msdn.microsoft.com/en-us/library/aa3799...
<p>Any semi-decent algorithm will end up with a strong chance of generating a NULL value somewhere in the resulting ciphertext.</p> <p>Why not do something like <a href="http://en.wikipedia.org/wiki/Base64" rel="nofollow">base-64 encode</a> your resulting binary blob before persisting to the DB? (<a href="http://synes...
Tracking Useful Information <p>What do the clever programmers here do to keep track of handy programming tricks and useful information they pick up over their many years of experience? Things like useful compiler arguments, IDE short-cuts, clever code snippets, etc.</p> <p>I sometimes find myself frustrated when looki...
<p>Two Things I do:</p> <ul> <li>I blog about it - this allows me to go back and search my own blog.</li> <li>We use the code snippet feature in Visual Studio.</li> </ul> <p>Cheers.</p>
How can I learn about parser combinators? <p>I've found a few resources on the subject, but they all require a deep understanding of <a href="http://en.wikipedia.org/wiki/Smalltalk">SmallTalk</a> or <a href="http://en.wikipedia.org/wiki/Haskell_%28programming_language%29">Haskell</a>, neither of which I know.</p>
<p>I wrote 8 longish blog entries on monadic parser combinators in C# and F#; see <a href="http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!123.entry">here</a> for the first one.</p> <p>See also <a href="http://www.quanttec.com/fparsec/">FParsec</a> (Parsec for F#)</p>
Select ..... where .... OR <p>Is there a way to select data where any one of multiple conditions occur on the same field?</p> <p>Example: I would typically write a statement such as:</p> <pre><code>select * from TABLE where field = 1 or field = 2 or field = 3 </code></pre> <p>Is there a way to instead say something...
<p>Sure thing, the simplest way is this:</p> <pre><code>select foo from bar where baz in (1,2,3) </code></pre>
Mac iWork/Pages Automation <p>There is a rich scripting model for Microsoft Office, but not so with Apple iWork, and specifically the word processor Pages. While there are some AppleScript hooks, it looks like the best approach is to manipulate the underlying XML data.</p> <p>This turns out to be pretty ugly because (...
<p>I'd suggest that modifying the underlying XML file is "considered harmful". Especially if you haven't checked to see if the document is open!</p> <p>I've had a quick look at the Scripting Dictionary for Pages, and it seems pretty comprehensive; here is part of one entry:</p> <blockquote> <p><strong>document</st...
PowerShell App.Config <p>Has anyone worked out how to get PowerShell to use <code>app.config</code> files? I have a couple of .NET DLL's I'd like to use in one of my scripts but they expect their own config sections to be present in <code>app.config</code>/<code>web.config</code>.</p>
<p>Cross-referencing with this thread, which helped me with the same question: <a href="http://stackoverflow.com/questions/2789920/subsonic-access-to-app-config-connection-strings-from-referenced-dll-in-powershel">Subsonic Access To App.Config Connection Strings From Referenced DLL in Powershell Script</a></p> <p>I ad...
What Comes After The %? <p>I've searched for this a little but I have not gotten a particularly straight answer. In C (and I guess C++), how do you determine what comes after the % when using <code>printf</code>?. For example:</p> <pre><code>double radius = 1.0; double area = 0.0; area = calculateArea( radius ); print...
<p><a href="http://en.wikipedia.org/wiki/Printf#printf_format_placeholders"><a href="http://en.wikipedia.org/wiki/Printf#printf_format_placeholders">http://en.wikipedia.org/wiki/Printf#printf_format_placeholders</a></a> is Wikipedia's reference for format placeholders in printf. <a href="http://www.cplusplus.com/refere...
Is AnkhSVN any good? <p>I asked a couple of coworkers about <a href="http://ankhsvn.open.collab.net" rel="nofollow">AnkhSVN</a> and neither one of them was happy with it. One of them went as far as saying that AnkhSVN has messed up his devenv several times.</p> <p>What's your experience with AnkhSVN? I really miss hav...
<p>Older AnkhSVN (pre 2.0) was very crappy and I was only using it for shiny icons in the solution explorer. I relied on Tortoise for everything except reverts.</p> <p>The newer Ankh is a complete rewrite (it is now using the Source Control API of the IDE) and looks &amp; works much better. Still, I haven't forced it ...
Best traffic / performance / usage monitoring module? <p>Are there any open source (or I guess commercial) packages that you can plug into your site for monitoring purposes? I'd like something that we can hook up to our ASP.NET site and use to provide reporting on things like:</p> <ul> <li>performance over time</li> <...
<p>It should be noted that google analytics is not an accurate representation of web site usage. This is because the web beacon (web bug) used on the page does not always load for these reasons:</p> <ol> <li>Google analytics servers are called by millions of pages every second and can not always process the requests i...
Creation Date of Compiled Executable (VC++ 2005) <p>The creation date of an executable linked in VS2005 is not set to the real creation-date of the exe-file. Only a complete re-build will set the current date, a re-link will not do it. Obviously the file is set to some date, which is taken from one of the project-files...
<p>Delete the executable as part of a pre-link event.</p> <p>Edit: Hah, I forgot about Explorer resetting the creation date if you name a file exactly the same as a file that was recently deleted.</p> <p>Why are you keying off the creation date anyway?</p>
How Do You Secure database.yml? <p>Within Ruby on Rails applications database.yml is a plain text file that stores database credentials.</p> <p>When I deploy my Rails applications I have an after deploy callback in my Capistrano recipe that creates a symbolic link within the application's /config directory to the dat...
<p>The way I have tackled this is to put the database password in a file with read permissions only for the user I run my application as. Then, in database.yml I use ERB to read the file:</p> <pre><code>production: adapter: mysql database: my_db username: db_user password: &lt;%= begin IO.read("/home/my_deplo...