input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Yaws uses old config file <p>I'm developing a web app on Yaws 1.65 (installed through apt) running on Debian etch on a VPS with UML. Whenever I do /etc/init.d/yaws restart or a stop/start, it initializes according to an old version of the config file (/etc/yaws/yaws.conf).</p>
<p>I know this because I changed the doc... | <p>I'm completely inexperienced with yaws, but I have a troubleshooting suggestion: What happens if you remove the config file completely? If it still starts yaws without a config file, that could be a clear sign that something is being cached.</p>
<p>For what it's worth, with a quick 5 minutes of googling, I found no... |
Dealing with circular dependencies in OCaml <p>I'm writing an interpreter for an experimental language. Three of the main constructs of the language are definitions, statements, and expressions. Definitions can contain statements and expressions, statements can contain definitions and expressions, and one kind of expre... | <p>Recursive definitions need to appear in the same file. If you want to separate definitions, statements, and expressions into separate modules, you can do so using <a href="http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#htoc100">recursive modules</a>, but they will still need to appear in the same file. DA... |
How to pass a single object[] to a params object[] <p>I have a method which takes params object[] such as:</p>
<pre><code>void Foo(params object[] items)
{
Console.WriteLine(items[0]);
}
</code></pre>
<p>When I pass two object arrays to this method, it works fine:</p>
<pre><code>Foo(new object[]{ (object)"1", (o... | <p>A simple typecast will ensure the compiler knows what you mean in this case.</p>
<pre><code>Foo((object)new object[]{ (object)"1", (object)"2" }));
</code></pre>
<p>As an array is a subtype of object, this all works out. Bit of an odd solution though, I'll agree.</p>
<p>Edit: Woops, typoed my example code.</p>
|
What are the important Ruby commands? <p>I'm not sure of all of them, but what are the commands to do things like update Ruby, download a new gem, or update an existing gem? What other important things are there?</p>
<p>Since it might matter, I'm running Windows.</p>
| <p>By Ruby commands you probably mean the command line programs for Ruby. These are also called Ruby Helper programs. Here are a few:</p>
<ul>
<li><p><a href="http://linux.die.net/man/1/ruby">ruby</a> - The interpreter itself. Run Ruby scripts or statements.</p></li>
<li><p><a href="http://www.rubygems.org/read/boo... |
Viewing DirectX application remotely <p>We're working on an application that displays information through a Direct3D visualisation. A late client request is the ability to view this application via some Remote Desktop solution.</p>
<p>Has anyone done anything similar? What options are available / unavailable? I'm thin... | <p>I think you can still use all of the normal D3D tools, but you won't be able to render to a surface associated with the screen. You'll have to render to a DIB (or some such) and Blt it with GDI to a normal window HDC. RDC/VNC/Citrix should all work with this technique.</p>
<p>Performance will definitely suffer - bu... |
SQL Query, Count with 0 count <p>I have three tables: page, attachment, page-attachment</p>
<p>I have data like this:</p>
<pre><code>page
ID NAME
1 first page
2 second page
3 third page
4 fourth page
attachment
ID NAME
1 foo.word
2 test.xsl
3 mm.ppt
page-attachment
ID PAGE-ID ... | <p>Change your "inner join" to a "left outer join", which means "get me all the rows on the left of the join, even if there isn't a matching row on the right."</p>
<pre><code>select page.name, count(page-attachment.id) as attachmentsnumber
from page
left outer join page-attachment on page.id=page-id
group by pa... |
Version Control for word documents <p>How would people recommend doing version control for word documents? Is the in build control up to the job or is it better to rely on dedicated version control systems, and if so, which ones?</p>
| <p>@<a href="#36834">lomaxx</a>:</p>
<blockquote>
<p>Subversion has built in support for word documents </p>
</blockquote>
<p>More specifically, <a href="http://tortoisesvn.tigris.org">TortoiseSVN</a> does. If you use the TortoiseSVN context menu in explorer to, e.g., bring up a diff, Tortoise will call a script th... |
Changing a CORBA interface without recompiling <p>I'd like to add a method to my existing server's CORBA interface. Will that require recompiling all clients?</p>
<p>I'm using TAO.</p>
| <p>Recompilation of clients is not required (and should not be, regardless of the ORB that you use). As Adam indicated, lookups are done by operation name (a straight text comparison).</p>
<p>I've done what you're describing with our ACE/TAO-based system, and encountered no issues (servers were in ACE/TAO C++, clients... |
How to best implement software updates on windows? <p>I want to implement an "automatic update" system for a windows application.
Right now I'm semi-manually creating an <a href="http://connectedflow.com/appcasting/">"appcast"</a> which my program checks, and notifies the user that a new version is available. (I'm us... | <p>There's now a Windows port of Sparkle, see <a href="http://winsparkle.org">http://winsparkle.org</a>.</p>
|
What is the meaning of "non temporal" memory accesses in x86 <p>This is a somewhat low-level question. In x86 assembly there are two SSE instructions: </p>
<blockquote>
<p><code>MOVDQA <i><em>xmmi, m128</em></i></code></p>
</blockquote>
<p>and </p>
<blockquote>
<p><code>MOVNTDQA <i><em>xmmi, m128</em></i></cod... | <p>Non-Temporal SSE instructions (MOVNTI, MOVNTQ, etc.), don't follow the normal cache-coherency rules. Therefore non-temporal stores must be followed by an SFENCE instruction in order for their results to be seen by other processors in a timely fashion.</p>
<p>When data is produced and not (immediately) consumed agai... |
Checking the results of a Factory in a unit test <p>I have developed some classes with similar behavior, they all implement the same interface. I implemented a factory that creates the appropriate object and returns the interface. I am writing a unit test for the factory. All you get back is an interface to the obje... | <p>Since I don't know how your factory method looks like, all I can advise right now is to </p>
<ol>
<li><p>Check to see the object is the correct concrete implementation you were looking for:</p>
<pre><code>IMyInterface fromFactory = factory.create(...);
Assert.assertTrue(fromFactory instanceof MyInterfaceImpl1);
... |
How to convert .ICO to .PNG? <p>What tool can I use to convert a .ICO file to a .PNG file?</p>
| <p>Google has an ico to png converter, I saw it on <a href="http://www.reddit.com/r/programming/comments/6ytnt/googles_free_favicon_png_online_converter/">reddit</a> the other day.</p>
<p><a href="http://www.google.com/s2/favicons?domain=stackoverflow.com">http://www.google.com/s2/favicons?domain=stackoverflow.com</a>... |
Best GUI tool for documenting a SQL Server DB <p>What tool(s) do you use to generate documentation for a database (preferably into a .chm help file)?</p>
| <p><H1> SQL Doc </H1></p>
<p><strong>Document SQL Server 2000, 2005 and 2008 databases</strong></p>
<p><a href="http://www.red-gate.com/products/SQL_Doc/index.htm" rel="nofollow"><img src="http://www.red-gate.com/images/boxshots/large/sqldoc.gif" alt="alt text" /></a></p>
<p><a href="http://www.red-gate.com/products... |
How to implement a file download in asp.net <p>What is the best way to implement, from a web page a download action using asp.net 2.0?</p>
<p>Log files for a action are created in a directory called [Application Root]/Logs. I have the full path and want to provide a button, that when clicked will download the log fil... | <p>Does this help:</p>
<p><a href="http://www.west-wind.com/weblog/posts/76293.aspx">http://www.west-wind.com/weblog/posts/76293.aspx</a></p>
<pre><code>Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment; filename=logfile.txt");
Response.TransmitFile( Server.Map... |
How do I implement a chromeless window with WPF? <p>I want to show a chromeless modal window with a close button in the upper right corner.
Is this possible?</p>
| <p>You'll pretty much have to roll your own Close button, but you can hide the window chrome completely using the WindowStyle attribute, like this:</p>
<pre><code><Window WindowStyle="None">
</code></pre>
<p>That will still have a resize border. If you want to make the window non-resizable then add ResizeMode="... |
How do you display a dialog from a hidden window application? <p>I have developed a COM component (dll) that implements an Edit() method displaying a WTL modal dialog.</p>
<p>The complete interface to this COM component corresponds to a software standard used in the chemical process industry (CAPE-OPEN) and as a resul... | <p>Are you using a parent for the Dialog? e.g.</p>
<pre><code>MyDialog dialog(pParent);
dialog.DoModal();
</code></pre>
<p>If you are, try removing the parent. Especially if the parent is the desktop window.</p>
|
C# string concatenation and string interning <p>When performing string concatentation of an existing string in the intern pool, is a new string entered into the intern pool or is a reference returned to the existing string in the intern pool? According to this article, String.Concat and StringBuilder will insert new st... | <p>If you create new strings, they will not automatically be put into the intern pool, unless you concatenate constants compile-time, in which case the compiler will create one string result and intern that as part of the JIT process.</p>
|
Best .NET Wrapper for Google Maps or Yahoo Maps? <p>I need to do a quick demo app using Google Maps (or Yahoo Maps, or any similar service). So far I haven't had much luck finding .NET wrappers for any of these services.</p>
<p>Any suggestions or pointers?</p>
<p>I'm not opposed to using the native javascript api to... | <p>I always check <a href="http://www.CodePlex.com" rel="nofollow">CodePlex.com</a></p>
<p><a href="http://www.codeplex.com/googlemap" rel="nofollow">http://www.codeplex.com/googlemap</a></p>
<p><a href="http://www.codeplex.com/YahooMap" rel="nofollow">http://www.codeplex.com/YahooMap</a></p>
<p>The GoogleMaps proje... |
How to prevent Write Ahead Logging on just one table in PostgreSQL? <p>I am considering log-shipping of <a href="http://www.postgresql.org/docs/8.2/static/runtime-config-wal.html">Write Ahead Logs (WAL)</a> in PostgreSQL to create a warm-standby database. However I have one table in the database that receives a huge am... | <p>Ran across this old question, which now has a better answer. Postgres 9.1 introduced "Unlogged Tables", which are tables that don't log their DML changes to WAL. See the docs for more info, but at least now there is a solution for this problem. </p>
<p>See <a href="http://www.depesz.com/2011/01/03/waiting-for-9-1-u... |
Parallelize Bash Script with maximum number of processes <p>Lets say I have a loop in bash:</p>
<pre><code>for foo in `some-command`
do
do-something $foo
done
</code></pre>
<p><code>do-something</code> is cpu bound and I have a nice shiny 4 core processor. I'd like to be able to run up to 4 <code>do-something</cod... | <p>Depending on what you want to do xargs also can help (here: converting documents with pdf2ps):</p>
<pre><code>cpus=$( ls -d /sys/devices/system/cpu/cpu[[:digit:]]* | wc -w )
find . -name \*.pdf | xargs --max-args=1 --max-procs=$cpus pdf2ps
</code></pre>
<p>From the docs:</p>
<pre><code>--max-procs=max-procs
-P ... |
How do I read a disk directly with .Net? <p>Is is possible to read a disk directly with .Net? By directly I mean via the device bypassing the file system. I think I would go about this by opening the device some way "\Device\Ide\IdeDeviceP2T0L0-1" for example. </p>
<p>If I can't open the device with a .NET api knowi... | <p>Cool, thank you Mark, I had forgotten that CreateFile opens things too. I was looking at the volume management API and not seeing how to open things. </p>
<p>Here is a little class that wraps things up. It might also be possible/correct to just pass the SafeFileHandle into a FileStream.</p>
<pre><code>using Sys... |
What non-programming books should programmers read? <p>This is a <a href="http://stackoverflow.com/questions/tagged/polls">poll</a> asking the Stackoverflow community what <strong>non-programming</strong> books they would recommend to fellow programmers.</p>
<h3>Please read the following before posting:</h3>
<ul>
<li... | <h2><a href="http://rads.stackoverflow.com/amzn/click/0345453743" rel="nofollow">The Hitchhiker's Guide to the Galaxy</a></h2>
<p>by Douglas Adams</p>
<p><img src="http://upload.wikimedia.org/wikipedia/en/1/1c/Hitchhiker%27s_Guide_%28book_cover%29.jpg" alt="alt text"></p>
<p>Life, the universe, and everything</p>
<... |
Best browser for web application <p>I am in a position where I can choose the client browser for my web app. The app is being used internally, and we are installing each client "manually".I would like to find a better solution for the browser,so :</p>
<p>What is a good browser that I can use as a client to a web appli... | <p><a href="http://developer.mozilla.org/en/Prism" rel="nofollow">Mozilla Prism</a> seems ideal for your purposes.</p>
<p>It shares code with Firefox but is designed to run web applications without the usual Browser interface to make them appear more like desktop applications. So no back button or address bar to worr... |
PHP : session variable aren't usable when site is redirected <p>I've to admin a small website for my alumni group which is hosted by my ISV. The url is something like www.myIsv.com/myWebSite/ which is quite ugly and very forgetable. The main admin of the webserver has registered a domain name www.mysmallwebsite.com and... | <p>Sessions are tied to the server <strong>AND</strong> the domain. Using frameset across domain will cause all kind of breakage because that's just not how it was designed to do. </p>
<p>Try using apache mod rewrite to create a "passthrough redirection", the "<strong>proxy</strong>" flag ([P]) in the rule is the magi... |
C# WinForms - DataGridView/SQL Compact - Negative integer in primary key column <p>I'm just getting dirty in WinForms, and I've discovered, through a lovely tutorial, the magic of dragging a database table onto the design view of my main form. So, all is lovely, I've got my DataGridView with all of the columns represen... | <p>@Brian -1 is a good choice for the default value since no "real" rows are likely to have identities less than zero. If it defaulted to 0 or 1 then there'd be a chance that it'd clash with an existing row, causing a primary key violation.</p>
<p>For applications that stay offline and create multiple rows before savi... |
ASP.NET controls cannot be referenced in code-behind in Visual Studio 2008 <p>Ok, so, my visual studio is broken. I say this NOT prematurely, as it was my first response to see where I had messed up in my code. When I add controls to the page I can't reference all of them in the code behind. Some of them I can, it seem... | <p>The above fix (deleting the temp files) did not work for me. I had to delete the <code>PageName.aspx.designer.cs</code> file, then right-click my page, and choose "Convert to Web Application" from the context menu. </p>
<p>When Visual Studio attempted to rebuild the designer file, it encountered (and revealed to ... |
How to provide next page of updated content? <p>Feel free to edit the title if you know how to formulate the question better. (Tagging is a problem as well.) The problem may be too difficult in this general form, so let us consider a concrete example.</p>
<p>You get a screenful of stackoverflow questions by requesting... | <p>This can't be done an easy way. For instance, the "Unanswered" list here at stackoverflow is sorted by number of votes. So if you'd save the last ID of the page you're viewing (in a cookie, request, session, whereever) and someone upvotes a post while you're browsing page 2, page 3 isn't complete since the recently ... |
Which class design is better? <p>Which class design is better and why?</p>
<pre><code>public class User
{
public String UserName;
public String Password;
public String FirstName;
public String LastName;
}
public class Employee : User
{
public String EmployeeId;
public String EmployeeCode;
... | <p>The question is simply answered by recognising that inheritance models an "IS-A" relationship, while membership models a "HAS-A" relationship.</p>
<ul>
<li>An employee IS A user</li>
<li>An employee HAS A userinfo</li>
</ul>
<p>Which one is correct? This is your answer.</p>
|
One or Two Primary Keys in Many-to-Many Table? <p>I have the following tables in my database that have a many-to-many relationship, which is expressed by a connecting table that has foreign keys to the primary keys of each of the main tables:</p>
<ul>
<li>Widget: WidgetID (PK), Title, Price </li>
<li>User: UserID (PK... | <p>You only have one primary key in either case. The second one is what's called a compound key. There's no good reason for introducing a new column. In practise, you will have to keep a unique index on all candidate keys. Adding a new column buys you nothing but maintenance overhead.</p>
<p>Go with option 2.</p>
|
Enforce constraint checking only when inserting rows in MSSQL? <p>Is there a way to enforce constraint checking in MSSQL only when inserting new rows? I.e. allow the constraints to be violated when removing/updating rows?</p>
<p>Update: I mean FK constraint.</p>
| <p>You could create an INSERT TRIGGER that checks that the conditions are met. That way all updates will go straight through.</p>
<pre><code>CREATE TRIGGER employee_insupd
ON employee
FOR INSERT
AS
/* Get the range of level for this job type from the jobs table. */
DECLARE @min_lvl tinyint,
@max_lvl tinyint,
@em... |
php mail() not working windows 2003, IIS SMTP <p>I'm getting this problem:</p>
<pre><code>PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for chris.mahan@gmail.com in c:\inetpub\wwwroot\mailtest.php on line 12
</code></pre>
<p>from this script:</p>
<pre><code><?php
$to = "chr... | <p>Try removing the IP restrictions for Relaying in the SMTP server, and opening it up to all relays. If it works when this is set, then you know that the problem has to do with the original restrictions. In this case, it may be a DNS issue, or perhaps you had the wrong IP address listed.</p>
|
Generate field in MySQL SELECT <p>If I've got a table containing Field1 and Field2 can I generate a new field in the select statement? For example, a normal query would be:</p>
<pre><code>SELECT Field1, Field2 FROM Table
</code></pre>
<p>And I want to also create Field3 and have that returned in the resultset... some... | <pre><code>SELECT Field1, Field2, 'Value' Field3 FROM Table
</code></pre>
<p>or for clarity</p>
<pre><code>SELECT Field1, Field2, 'Value' AS Field3 FROM Table
</code></pre>
|
How to find out if a file exists in C# / .NET? <p>I would like to test a string containing a path to a file for existence of that file (something like the <code>-e</code> test in Perl or the <code>os.path.exists()</code> in Python) in C#.</p>
| <p>Use:</p>
<pre><code>File.Exists(path)
</code></pre>
<p>MSDN: <a href="http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx">http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx</a></p>
<p>Edit: In System.IO</p>
|
Programmable, secure FTP replacement <p>We need to move off traditional FTP for security purposes (it transmits it's passwords unencrypted). I am hearing SSH touted as the obvious alternative. However I have been driving FTP from an ASP.NET program interface to automate my web-site development, which is now quite a hig... | <p><a href="http://www.codeproject.com/KB/IP/sharpssh.aspx" rel="nofollow">sharpssh</a> implements sending files via scp.</p>
|
"Similar Posts" like functionality using MS SQL Server? <p>I have lots of article store in MS SQL server 2005 database in a table called Articles-</p>
<pre><code>"Articles (ArticleID, ArticleTitle, ArticleContent)"
</code></pre>
<p>Now I want some SP or SQL query which could return me similar Article against any user... | <p>Something like this might work, a kind of ranking system. You would probably have to split the string in your application to build a SQL string, but I have used similar to build an effective site search.</p>
<pre><code>Select
Top 10
ArticleID,
ArticleTitle,
ArticleContent
From
Articles
Order By
(Case When ArticleTi... |
What do you call the tags in Subversion and CVS that add automatic content? <p>Things like <code>$log$</code> and <code>$version$</code> which add data upon check-in to the file. I'm interested in seeing the other ones and what information they can provide, but I can't get much info unless I know what they are called.<... | <p>Both Subversion and CVS call them <code>Keywords</code>.</p>
<p><a href="http://svnbook.red-bean.com/en/1.0/ch07s02.html#svn-ch-7-sect-2.3" rel="nofollow">Have a look in the SVN manual here</a> (scroll down to <strong>svn:keywords</strong>) or <a href="http://badgertronics.com/writings/cvs/keywords.html" rel="nofol... |
How do I check job status from SSIS control flow? <p>Here's my scenario - I have an SSIS job that depends on another prior SSIS job to run. I need to be able to check the first job's status before I kick off the second one. It's not feasible to add the 2nd job into the workflow of the first one, as it is already way to... | <p>You may want to create a third package the runs packageA and then packageB. The third package would only contain two execute package tasks.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms137609.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms137609.aspx</a></p>
<p>@Craig
A status table i... |
How to use the SharePoint MultipleLookupField control? <p>I want to use the MultipleLookupField control in a web page that will run in the context of SharePoint. I was wondering if anyone would help me with an example, which shows step by step how to use the control two display two SPField Collections.</p>
| <p>I'm not entirely sure I understand your question, especially the bit about displaying two SPField collections. Sorry if this turns out to be the answer to a completely different question!</p>
<p>Anyway here's a quick demo walkthrough of using the MultipleLookupField in a web part.</p>
<p>Create a team site. Add a ... |
javascript locals()? <p>In python one can get a dictionary of all local and global variables in the current scope with the built-in functions locals() and globals(). Is there some equivalent way of doing this in javascript? For instance, I would like to do something like the following:</p>
<pre><code>var foo = funct... | <ul>
<li><p>locals() - No. </p></li>
<li><p>globals() - Yes.</p></li>
</ul>
<p><code>window</code> is a reference to the global scope, like <code>globals()</code> in python.</p>
<pre><code>globals()["foo"]
</code></pre>
<p>is the same as:</p>
<pre><code>window["foo"]
</code></pre>
|
Is overloading the only way to have default function arguments in C#? <p>Is it true that the only way to handle default function arguments is through function overloading?</p>
<p>For example, in PHP I can do this:</p>
<pre><code>function foo($x, $y=0)
{
}
</code></pre>
<p>Would the best way to handle it in C# be thi... | <p>Just to satisfy some curiosity:</p>
<p>From <a href="http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx">Why doesn't C# support default parameters?</a>:</p>
<blockquote>
<p>In languages such as C++, a default value can be included as part of the method declaration:</p>
<p>void Process(Employee em... |
GUIDs as Primary Keys - Offline OLTP <p>We are working on designing an application that is typically OLTP (think: purchasing system). However, this one in particular has the need that some users will be offline, so they need to be able to download the DB to their machine, work on it, and then sync back once they're on ... | <p>Using Guids as primary keys is acceptable and is considered a fairly standard practice for the same reasons that you are considering them. They can be overused which can make things a bit tedious to debug and manage, so try to keep them out of code tables and other reference data if at all possible.</p>
<p>The thi... |
Is Java "pass-by-reference" or "pass-by-value"? <p>I always thought Java was <strong>pass-by-reference</strong>; however I've seen a couple of blog posts (for example, <a href="http://javadude.com/articles/passbyvalue.htm">this blog</a>) that claim it's not. I don't think I understand the distinction they're making. </... | <p>Java is always <strong>pass-by-value</strong>. Unfortunately, they decided to call pointers references, thus confusing newbies. Because those <em>references</em> are passed by value.</p>
<p>It goes like this:</p>
<pre><code>public static void main( String[] args ){
Dog aDog = new Dog("Max");
foo(aDog);
... |
jQuery and Prototype Selector Madness <p>Both the jQuery and Prototpye JavaScript libraries refuse to allow me to use a variable to select an list item element by index number although they accept a hard coded number. </p>
<p>For example, in Prototype this works:</p>
<pre><code>$$('li')[5].addClassName('active');
</c... | <p>Are you certain that <code>currentPage</code> is an integer? Try something like:</p>
<pre><code>var currentPage = 5;
jQuery('li').eq(currentPage);
</code></pre>
<p>as a simple sanity check. If that works, you should try casting to <code>Integer</code>.</p>
|
How do I get the full url of the page I am on in C# <p>I need to be able to get at the full URL of the page I am on from a user control. Is it just a matter of concatenating a bunch of Request variables together? If so which ones? Or is there a more simpiler way?</p>
| <p>Here is a list I normally refer to for this type of information:</p>
<pre><code>Request.ApplicationPath : /virtual_dir
Request.CurrentExecutionFilePath : /virtual_dir/webapp/page.aspx
Request.FilePath : /virtual_dir/webapp/page.aspx
Request.Path : /virtual_dir/webapp/page.aspx
Request.PhysicalApplicationPath :... |
How do you give a C# Auto-Property a default value? <p>How do you give a C# Auto-Property a default value? I either use the constructor, or revert to the old syntax. </p>
<p><strong> Using the Constructor:</strong></p>
<pre><code>class Person
{
public Person()
{
Name = "Default Name";
}
publ... | <p>In C# 5 and earlier, to give auto implemented properties a default value, you have to do it in a constructor.</p>
<p>The ability to have auto property initializers is included since C# 6.0. The syntax is:</p>
<pre><code>public int X { get; set; } = x; // C# 6 or higher
</code></pre>
|
Cannot create an environment variable in the registry <p>I have a custom installer action that updates the PATH environment, and creates an additional environment variable. Appending a directory to the existing path variable is working fine, but for some reason my attempts to create a new environment variable have been... | <p>What OS is this? Is it on a 64-bit system? What is the nature of the failure: silent or is an exception thrown?</p>
<p>You could try running <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow">ProcessMonitor</a> and seeing if it sees the attempt to set the value.</p>
|
Smarty integration into the Code Igniter framework <p><strong>A Little Background Information</strong>:<br>
I've been looking at a few PHP framework recently, and it came down to two. The Zend Framework or CodeIgniter. </p>
<p>I prefer CodeIgniter, because of its simple design. It's very bare bone, and it is just kept... | <p>Sorry to resurrect an old question - but none of the answers have been flagged as "accepted" yet.</p>
<p>There's a library called "template" that does a great job of allowing you to use just about any template parser you want:</p>
<p><a href="http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.... |
Where do you store your database connectionstring? <p>I usually store my connectionstring in web.config or in the application settings of my Visual Studio project. The application I'm currently working on makes a lot of trips to the database which means it will look up the connectionstring every time. Should I be putti... | <p>I wouldn't cache the connection object, that will defeat the built-in connection pooling -- ADO.NET will handle connections (assuming you instantiate and close them) efficiently by itself.</p>
<p>As far as the connection string itself, you shouldn't need to cache it if you load it from connection -- the connection ... |
Is there a best .NET algorithm for credit card encryption? <p>The .NET <code>System.Security.Cryptography</code> namespace has a rather bewildering collection of algorithms that I could use for encryption of credit card details. Which is the best?</p>
<p>It clearly needs to be secure for a relatively short string. </p... | <p>No offense, but the question is a little "misguided". There is no "silver bullet" solution. I would recommend to read up on cryptography in general and then do some threat modeling. Some questions (by no means a comprehensive list) you should ask yourself:</p>
<ul>
<li>Is the module doing the encryption the one whi... |
File Access Strategy in a Multi-Threaded Environment (Web App) <p>I have a file which is an XML representation of some data that is taken from a Web service and cached locally within a Web Application. The idea being is that this data is <em>very</em> static, but just <em>might</em> change. So I have set it up to cache... | <p>Here is the code that I use to make sure a file is not locked by another process. It's not 100% foolproof, but it gets the job done most of the time:</p>
<pre><code> /// <summary>
/// Blocks until the file is not locked any more.
/// </summary>
/// <param name="fullPath"></param... |
Emacs in Windows <p>How do you run Emacs in Windows?</p>
<p>What is the best flavor of Emacs to use in Windows, and where can I download it? And where is the .emacs file located?</p>
| <p>I use <a href="http://www.emacswiki.org/emacs/EmacsW32">EmacsW32</a>, it works great. <em>EDIT: I now use regular GNU Emacs 24, see below.</em></p>
<p>See its <a href="http://www.emacswiki.org/cgi-bin/wiki/EmacsW32">EmacsWiki page</a> for details.</p>
<p>To me, the biggest advantage is that:</p>
<ul>
<li>it has a... |
Working on a Visual Studio Project with multiple users? <p>I just wonder what the best approach is to have multiple users work on a Project in Visual Studio 2005 Professional.</p>
<p>We got a Solution with multiple Class Libraries, but when everyone opens the solution, we keep getting the "X was modified, Reload/Disca... | <p>What you need is source control.</p>
<p>You should definitely not open the same files over the network on multiple machines. For one thing, Visual Studio has safeguards in place to prevent you from modifying certain files during a build, but it has none of that that will prevent others from modifying the same files... |
How to detect the presence of a default recording device in the system? <p>How do I detect if the system has a default recording device installed?
I bet this can be done through some calls to the Win32 API, anyone has any experience with this?</p>
<p>I'm talking about doing this through code, not by opening the contro... | <p>Using the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ea4894b5-e98d-44f6-842d-e32147237638&DisplayLang=en" rel="nofollow">DirectX SDK</a>, you can call DirectSoundCaptureEnumerate, which will call your DSEnumCallback function for each DirectSoundCapture device on the system. The first para... |
How to wrap a function with variable length arguments? <p>I am looking to do this in C/C++.</p>
<p>I came across <a href="http://www.swig.org/Doc1.3/Varargs.html"><strong>Variable Length Arguments</strong></a> but this suggests a solution with Python & C using <a href="http://sourceware.org/libffi/">libffi</a>.</p... | <p>the problem is that you cannot use 'printf' with va_args. You must use <strong>vprintf</strong> if you are using variable argument lists. vprint, vsprintf, vfprintf, etc. (there are also 'safe' versions in Microsoft's C runtime that will prevent buffer overruns, etc.)</p>
<p>You sample works as follows:</p>
<pr... |
What are the differences between GPL v2 and GPL v3 licenses? <p>In simple terms, what are the reasons for, and what are the differences between the GPL v2 and GPL v3 open source licenses? Explanations and references to legal terms and further descriptions would be appreciated.</p>
| <p>The page linked to in another answer is a good source, but a lot to read. Here is a short list of some the major differences:</p>
<ul>
<li><p>internationalization: they used new terminology, rather than using language tied to US legal concepts</p></li>
<li><p>patents: they specifically address patents (including t... |
Should I Keep Registering A Failure? <p>I'm working on an automated regression test suite for an app which I maintain. While developing the automated regression test, I ran across some behavior that's almost certainly a bug. So, for now, I've modified the automated regression test to not register a failure--it's deli... | <p>If you stop testing it, how are you going to know when it's fixed, and more importantly, how are you going to know if it gets broken again? I'm against taking out the test, because you're likely to forget to add it back in again.</p>
|
How do you properly use namespaces in C++? <p>I come from a Java background, where packages are used, not namespaces. I'm used to putting classes that work together to form a complete object into packages, and then reusing them later from that package. But now I'm working in C++.</p>
<p>How do you use namespaces in C+... | <p>Namespaces are packages essentially. They can be used like this:</p>
<pre><code>namespace MyNamespace
{
class MyClass
{
};
}
</code></pre>
<p>Then in code:</p>
<pre><code>MyNamespace::MyClass* pClass = new MyNamespace::MyClass();
</code></pre>
<p>Hope that helps.</p>
<p>Or, if you want to always use a spe... |
is it possible to concat arguments to a command line using backquotes ? <p>I would like to execute an OS command from my ruby script but I want to add an argument from a ruby variable.</p>
<p>I know that's possible by using keyword <em>system</em> like that :</p>
<pre><code>#!/usr/bin/env ruby
directory = '/home/paul... | <p>No, that will just concatenate the output from <code>ls</code> and the contents of <code>directory</code>.</p>
<p>But you can do this:</p>
<pre><code>#!/usr/bin/env ruby
directory = '/home/paulgreg/'
`ls #{directory}`
</code></pre>
|
Mute Specific Application in Vista <p>I am in need of a way to mute a specific application in Vista.</p>
<p>Example: Mute just Firefox, but not all of the other application. Much similar to muting a specific program from within the volume mixer in vista. </p>
<p>If there is a program that will do this, i would appre... | <p>I suggest using the built in Mixer in Vista...</p>
<p>Why do you want to use an 3rd party program?</p>
|
Lightweight fuzzy search library <p>Can you suggest some light weight fuzzy text search library?</p>
<p>What I want to do is to allow users to find correct data for search terms with typos.</p>
<p>I could use full-text search engines like Lucene, but I think it's an overkill.</p>
<p><strong>Edit:</strong><br>
To mak... | <p>Lucene is very scalable—which means its good for little applications too. You can create an index in memory very quickly if that's all you need.</p>
<p>For fuzzy searching, you really need to decide what algorithm you'd like to use. With information retrieval, I use an <a href="http://en.wikipedia.org/wiki/N-... |
Why does the Bourne shell printf iterate over a %s argument? <p>What's going on here?</p>
<p>printf.sh:</p>
<pre><code>#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" $NAME
</code></pre>
<p>Command line session:</p>
<pre><code>$ ./printf.sh
Hello, George
Hello, W.
Hello, Bush
</code></pre>
<p>UPDATE: <code>p... | <p>Your NAME variable is being substituted like this:</p>
<pre><code>printf "Hello, %s\n" George W. Bush
</code></pre>
<p>Use this:</p>
<pre><code>#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" "$NAME"
</code></pre>
|
How can I unit test a Windows Service? <p>.NET Framework: 2.0
Preferred Language: C#</p>
<p>I am new to TDD (Test Driven Development).</p>
<p>First of all, is it even possible to unit test Windows Service?</p>
<p>Windows service class is derived from ServiceBase, which has overridable methods, </p>
<ol>
<li>OnStart... | <p>I'd probably recommend designing your app so the "OnStart" and "OnStop" overrides in the Windows Service just call methods on a class library assembly. That way you can automate unit tests against the class library methods, and the design also abstracts your business logic from the implementation of a Windows Servi... |
Managing LINQ to SQL .dbml model complexity <p>This question is addressed to a degree in this question on <a href="http://stackoverflow.com/questions/33664/best-practices-for-managing-linq-to-sql-dbml-files" rel="nofollow">LINQ to SQL .dbml best practices</a>, but I am not sure how to add to a question.</p>
<p>One of ... | <p>Take advantage of the namespace settings. You can get to it in properties from clicking in the white space of the ORM.</p>
<p>This allows me to have a Users table and a User class for one set of business rules and a second (but the same data store) Users table and a User class for another set of business rules.</p>... |
Custom titlebars/chrome in a WinForms app <p>I'm almost certain I know the answer to this question, but I'm hoping there's something I've overlooked.</p>
<p>Certain applications seem to have the Vista Aero look and feel to their caption bars and buttons even when running on Windows XP. (Google Chrome and Windows Live... | <p>Here's an article with full code sample on how to use your own custom "chrome" for an application:</p>
<p><a href="http://geekswithblogs.net/kobush/articles/CustomBorderForms3.aspx">http://geekswithblogs.net/kobush/articles/CustomBorderForms3.aspx</a></p>
<p>This looks like some really good stuff. There are a tota... |
TFS - Branching for experimental development: Solution fails to load <p><em>Disclaimer: I'm stuck on TFS and I hate it.</em></p>
<p>My source control structure looks like this:</p>
<ul>
<li>/dev</li>
<li>/releases</li>
<li>/branches</li>
<li>/experimental-upgrade</li>
</ul>
<p>I branched from dev to experimental-upg... | <p>@Ben</p>
<p>You can actually do a full delete in TFS, but it is highly not recommended unless you know what you are doing. You have to do it from the command line with the command tf destroy</p>
<pre><code>tf destroy [/keephistory] itemspec1 [;versionspec]
[itemspec2...itemspecN] [/stopat:versionspec] ... |
Extract Address Information from a Web Page <p>I need to take a web page and extract the address information from the page. Some are easier than others. I'm looking for a firefox plugin, windows app, or VB.NET code that will help me get this done.</p>
<p>Ideally I would like to have a web page on our admin (ASP.NET/VB... | <p>What type of address information are you referring to?</p>
<p>There are a couple FireFox plugins <a href="https://addons.mozilla.org/en-US/firefox/addon/4106" rel="nofollow">Operator</a> & <a href="http://blog.codeeg.com/tails-firefox-extension-03/" rel="nofollow">Tails</a> that allow you to extract and view mi... |
Metalanaguage to describe the Model from MVC to generate identical client and server side code <p>I am looking for a powerful meta-language to describa behaviour for an application i intend to use in offline mode (google-gears + javascript) and server side sqlite + (php/ruby/java etc) and looking for a good format to d... | <p>Have you looked at <a href="http://code.google.com/webtoolkit/" rel="nofollow">Google Web Toolkit</a>? GWT allows you to write server side Java objects which get translated into Javascript for you. This allows you to not deal with the browser quirks at all.
I'm not sure how well integrated the Gears and GWT projec... |
SQL Server Views, blessing or curse? <p>I once worked with an architect who banned the use of SQL views. His main reason was that views made it too easy for a thoughtless coder to needlessly involve joined tables which, if that coder tried harder, could be avoided altogether. Implicitly he was encouraging code reuse v... | <p>There are some very good uses for views; I have used them a lot for tuning and for exposing less normalized sets of information, or for UNION-ing results from multiple selects into a single result set.</p>
<p>Obviously any programming tool can be used incorrectly, but I can't think of any times in my experience whe... |
Which Dynamic .NET language makes more sense to learn, Iron Ruby or Iron Python? <p>I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn.</p>
<p>Having limited time, I really only have time to look learn one of them.</p>
<p>A... | <p>Without getting into the relative merits of the languages (which would be an entire pissing contest in itself), IronPython (stable 1.1.1, beta 2.0) is further along in development than IronRuby (alpha)</p>
|
Efficient synthesis of a 4-to-1 function in Verilog <p>I need to implement a 4-to-1 function in Veriog. The input is 4 bits, a number from 0-15. The output is a single bit, 0 or 1. Each input gives a different output and the mapping from inputs to outputs is known, but the inputs and outputs themselves are not. I w... | <p>What you have is fine. A case statement would also work equally well. It's just a matter of how expressive you wish to be. </p>
<p>Your solution, indexing, works fine if the select encodings don't have any special meaning (a memory address selector for example). If the select encodings do have some special sema... |
What is WCF in simple terms? <p>What is WCF in simple terms?</p>
<p>It's hard to distill the meaning from <a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation">the Wikipedia page</a>.</p>
| <p>WCF - <a href="http://msdn.microsoft.com/en-us/library/ms731082.aspx">Windows Communication Framework</a> - is Microsoft's framework to make inter-process communication easier. It let's you do this communication through various means, plain old asmx web services, Remoting, MS Message Queuing, and a couple more.</p>
... |
Writing/Using C++ Libraries <p>I am looking for basic examples/tutorials on:</p>
<ol>
<li><p>How to write/compile libraries in C++ (<code>.so</code> files for Linux, <code>.dll</code> files for Windows).</p></li>
<li><p>How to import and use those libraries in other code.</p></li>
</ol>
| <h2>The code</h2>
<p><em>r.cc</em> :</p>
<pre><code>#include "t.h"
int main()
{
f();
return 0;
}
</code></pre>
<p><em>t.h</em> :</p>
<pre><code>void f();
</code></pre>
<p><em>t.cc</em> :</p>
<pre><code>#include<iostream>
#include "t.h"
void f()
{
std::cout << "OH HAI. I'M F." <&l... |
Setting Focus with ASP.NET AJAX Control Toolkit <p>I'm using the <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx" rel="nofollow">AutoComplete</a> control from the ASP.NET AJAX Control Toolkit and I'm experiencing an issue where the AutoComplete does not populate when I set the... | <p>We had exactly the same problem. What we had to do is write a script at the bottom of the page that quickly blurs then refocuses to the textbox. You can have a look at the (terribly hacky) solution here: <a href="http://www.drive.com.au" rel="nofollow">http://www.drive.com.au</a> </p>
<p>The textbox id is <code> ... |
Get Last Day of the Month in Python <p>Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month?</p>
<p>If the standard library doesn't support that, does the dateutil package support this?</p>
| <p>I didn't notice this earlier when I was looking at the <a href="https://docs.python.org/2/library/calendar.html">documentation for the calendar module</a>, but a method called <a href="http://docs.python.org/library/calendar.html#calendar.monthrange">monthrange</a> provides this information:</p>
<blockquote>
<p><... |
How to use p4merge as the merge/diff tool for Mercurial? <p>Does anyone know how to setup <a href="http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial">Mercurial</a> to use <a href="http://www.perforce.com/perforce/products/merge.html">p4merge</a> as the merge/diff tool on OS X 10.5?</p>
| <p>Place this into your <code>~/.hgrc</code> (or, optionally, your <code>Mercurial.ini</code> on Windows):</p>
<pre><code>[merge-tools]
p4.priority = 100
p4.premerge = True # change this to False if you're don't trust hg's internal merge
p4.executable = /Applications/p4merge.app/Contents/MacOS/p4merge
p4.gui = True
p... |
Regex to match against something that is not a specific substring <p>I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring.</p>
<p>Example:</p>
<pre><code>// Updated to be correct, thanks @Apocalisp
^foo.*(?<!bar)$
</code></pre>
<p>Should match ... | <p>I think in this case you want <strong>negative lookbehind</strong>, like so:</p>
<pre><code>foo.*(?<!bar)
</code></pre>
|
What are some resources for getting started in operating system development? <p>One thing I've always wanted to do is develop my very own operating system (not necessarily fancy like Linux or Windows, but better than a simple boot loader which I've already done).</p>
<p>I'm having a hard time finding resources/guides ... | <p>There are a lot of links after this <a href="http://www.osix.net/modules/article/?id=359" rel="nofollow">brief overview</a> of what is involved in writing an OS for the X86 platform.</p>
<p>The link that appears to be most promising (www.nondot.org/sabre/os/articles) is no longer available, so you'll need to poke t... |
How to generate urls in django <p>In Django's template language, you can use <code>{% url [viewname] [args] %}</code> to generate a URL to a specific view with parameters. How can you programatically do the same in Python code?</p>
<p>What I need is to create a list of menu items where each item has name, URL, and an ... | <p>If you need to use something similar to the <code>{% url %}</code> template tag in your code, Django provides the <code>django.core.urlresolvers.reverse()</code>. The <code>reverse</code> function has the following signature:</p>
<pre><code>reverse(viewname, urlconf=None, args=None, kwargs=None)
</code></pre>
<p><... |
NHibernate ISession Flush: Where and when to use it, and why? <p>One of the things that get me thoroughly confused is the use of <code>session.Flush</code>,in conjunction with <code>session.Commit</code>, and <code>session.Close</code>.</p>
<p>Sometimes <code>session.Close</code> works, e.g., it commits all the change... | <p>Briefly:</p>
<ol>
<li>Always use transactions</li>
<li>Don't use <code>Close()</code>, instead wrap your calls on an <code>ISession</code> inside a <code>using</code> statement or <strong>manage the lifecycle of your ISession somewhere else</strong>.</li>
</ol>
<p>From <a href="http://nhibernate.info/doc/nh/en/ind... |
Is there a standard HTML layout with multiple CSS styles available? <p>When it comes to web-design, I am horrible at producing anything remotely good looking. Thankfully there are a lot of free <a href="http://www.mantisatemplates.com/web-templates.php">sources</a> for <a href="http://www.freecsstemplates.org/">design<... | <p>Check out the <a href="http://developer.yahoo.com/yui/grids/" rel="nofollow">Grids framework</a> from YUI. Particularly awesome is the <a href="http://developer.yahoo.com/yui/grids/builder/" rel="nofollow">Grid Builder</a>. Also, they have a set of reset, base, and font CSS files that will give you a good baseline t... |
When is Control.DestroyHandle called? <p>When is this called? More specifically, I have a control I'm creating - how can I release handles when the window is closed. In normal win32 I'd do it during <code>wm_close</code> - is <code>DestroyHandle</code> the .net equivalent?</p>
<hr>
<p>I don't want to destroy the wind... | <p>Normally <code>DestroyHandle</code> is being called in <code>Dispose</code> method. So you need to make sure that all controls are disposed to avoid resource leaks.</p>
|
Is there a built-in method to compare collections in C#? <p>I would like to compare the contents of a couple of collections in my Equals method. I have a Dictionary and an IList. Is there a built-in method to do this?</p>
<p>Edited:
I want to compare two Dictionaries and two ILists, so I think what equality means is... | <p><a href="http://msdn.microsoft.com/en-us/library/bb342073.aspx"><code>Enumerable.SequenceEqual</code></a></p>
<blockquote>
<p>Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer(T).</p>
</blockquote>
<p>You can't directly compare the list & the dictio... |
How to find the mime type of a file in python? <p>Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer.</p>
<p>Assumption: The browser figures out which application/v... | <p>The python-magic method suggested by toivotuo is outdated. <a href="http://github.com/ahupp/python-magic">Python-magic's</a> current trunk is at Github and based on the readme there, finding the MIME-type, is done like this.</p>
<pre><code># For MIME types
>>> import magic
>>> mime = magic.Magic(m... |
How to concatenate strings of a string field in a PostgreSQL 'group by' query? <p>I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table:</p>
<pre><code>ID COMPANY_ID EMPLOYEE
1 1 Anna
2 1 Bill
3 2 Carol
4 2 ... | <h3>Update as of PostgreSQL 9.0:</h3>
<p>Recent versions of Postgres (since late 2010) have the <a href="http://www.postgresql.org/docs/current/static/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE"><code>string_agg(expression, delimiter)</code></a> function that will do exactly what the question asked for, even l... |
Crop MP3 to first 30 seconds <p><strong>Original Question</strong></p>
<p>I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first <em>n</em> seconds of the track.</p>
<p>Now, I know I could jus... | <p>I also recommend ffmpeg, but the command line suggested by John Boker has an unintended side effect: it re-encodes the file to the default bitrate (which is 64 kb/s in the version I have here at least). This might give your customers a false impression of the quality of your sound files, and it also takes longer to ... |
What software to use for a multistage development environment? <p>For me a multistage environment contains environments for development, testing, quality assurance, maybe a client review stage and finally production. It should allow easy collaboration between developers, project status tracking and easy deployment of t... | <p>We use CruiseControl.NET to automatically push source control checkins out to a dev server. This allows people to regression test their changes in real time.</p>
<p>We then use a series of scripts to robocopy the build to other environments. </p>
<p>For Example:</p>
<ul>
<li>Developer completes a change and check... |
Custom Aggregate Functions in MS SQL Server? <p>How can I create a custom aggregate function in MS SQL Server? An example would help a lot.</p>
| <p>SQL Server 2000 doesn't officially support custom aggregate functions. However, I recently needed that functionality as well, and I found this article enlightening:<br />
<a href="http://weblogs.sqlteam.com/jeffs/articles/1490.aspx" rel="nofollow">http://weblogs.sqlteam.com/jeffs/articles/1490.aspx</a></p>
<p>It's... |
COTS Workshop Registration System <p>Does anyone have any experience with any COTS systems for managing workshops and the associated registrations, courses, communications, etc.?</p>
<p>We have a home-built Perl system that is about 8 years old and is currently embedded as an iframe in a SharePoint portal site (extern... | <p>You might also look into Moodle - it's a platform developed to supplement classroom teaching (or implement online learning courses) but should have all the major features you listed, and would support your needs reasonably well, as well as enhancing your event with an online component such as slide/presentation dist... |
Configuring sendmail behind a firewall <p>I'm setting up a server which is on a network behind a firewall and I want programs on this computer to be able to use sendmail to send emails to any email address. We have an SMTP server running on this network (let's call it mailrelay.example.com) which is how we're supposed... | <p>@<a href="#44014">eli</a>: modifying sendmail.cf directly is not usually recommended, since it is generated by the macro compiler. </p>
<p>Edit /etc/mail/sendmail.mc to include the line:</p>
<pre><code> define(`SMART_HOST',`mailrelay.example.com')dnl
</code></pre>
<p>After changing the sendmail.mc macro configur... |
Does Microsoft ASP.NET Ajax Cause DOM Object Leaks? <p>We've been using "Drip" to try and identify why pages with UpdatePanels in them tend to use a lot of client-side memory. With a page with a regular postback, we are seeing 0 leaks detected by Drip. However, when we add an update panel to the mix, every single DOM... | <p>According to <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FASP-NET-AJAX-Action-Alessandro-Gallo%2Fdp%2F1933988142&tag=diaryofamadma-20&linkCode=ur2&camp=1789&creative=9325" rel="nofollow">ASP.NET AJAX in Action</a>, p. 257</p>
<blockquote>
<p>Ju... |
Best way to use a property to reference a Key-Value pair in a dictionary <p>This is a fairly trivial matter, but I'm curious to hear people's opinions on it.</p>
<p>If I have a Dictionary which I'm access through properties, which of these formats would you prefer for the property?</p>
<pre><code>/// <summary>
... | <p>I like the second one purely because any avoidance of magic strings/numbers in code is a good thing. IMO if you need to reference a number or string literal in code more than once, it should be a constant. In most cases even if it's only used once it should be in a constant </p>
|
Looking for a simple JavaScript example that updates DOM <p>I am looking for a simple JavaScript example that updates DOM.<br>
Any suggestions?</p>
| <p>Here is a short pure-javascript example. Assume you have a div with the id "maincontent".</p>
<pre><code>var newnode = document.createTextNode('Here is some text.');
document.getElementById('maincontent').appendChild(newnode);
</code></pre>
<p>Of course, things are a lot easier (especially when you want to do more... |
Difference between foreach and for loops over an IEnumerable class in C# <p>I have been told that there is a performance difference between the following code blocks.</p>
<pre><code>foreach (Entity e in entityList)
{
....
}
</code></pre>
<p>and </p>
<pre><code>for (int i=0; i<entityList.Count; i++)
{
Entity e... | <p>foreach creates an instance of an enumerator (returned from GetEnumerator) and that enumerator also keeps state throughout the course of the foreach loop. It then repeatedly calls for the Next() object on the enumerator and runs your code for each object it returns.</p>
<p>They don't boil down to the same code in a... |
Can .NET check other running programs command line parameters? <p>We've got an interesting case where we are trying to determine how different instances of our app were launched. Is there any way for .NET to be able to query another running instance and get the command line parameters passed to that instance? I've not ... | <p>You can retrieve this information through WMI.</p>
<p>See the <a href="http://msdn.microsoft.com/en-us/library/aa394372.aspx" rel="nofollow">Win32_Process</a> class, in particular its command line property. This <a href="http://www.codeproject.com/KB/cs/EverythingInWmi02.aspx" rel="nofollow">Code Project article</... |
Order an Array like another Array in C# <p>I'm looking for the best algorithm to take array A {0,1,2,3} and make order it like array B {3,1,0,2}. Any ideas?</p>
| <p>So if you have two arrays and they hold the same data just in different order then just do this:</p>
<p>A = B</p>
<p>I suspect that is not your situation so I think we need more info.</p>
|
What are the best keyboard macros for programming in windows? <p>I like putting shortcuts of the form "g - google.lnk" in my start menu so google is two keystrokes away. Win, g.</p>
<p>My eight or so most frequent applications go there.</p>
<p>I also make links to my solution files I am always opening "x - Popular Pr... | <p><a href="http://www.autohotkey.com/" rel="nofollow">AutoHotkey</a> is a reasonably good program for implementing windows key shortcuts. You might instead define WIN + G to be "open browser to google" which gives you a better response time (don't have to wait for start menu to popup, etc)</p>
<p>There are macro pro... |
How do I get the ClickOnce Publish version to match the AssemblyInfo.cs File version? <p>Every time I publish the application in <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="nofollow">ClickOnce</a> I get get it to update the revision number by one. Is there a way to get this change automatically to change the ... | <p>We use Team Foundation Server Team Build and have added a block to the TFSBuild.proj's <code>AfterCompile</code> target to trigger the ClickOnce publish with our preferred version number:</p>
<pre class="lang-xml prettyprint-override"><code><MSBuild Projects="$(SolutionRoot)\MyProject\Myproject.csproj"
... |
version control practice <p>In my current job the supervisor's practice is to only check in production ready code. Most recently the project I was on involved work by 3 different developers with some file overlap. This meant manually integrating changes despite the fact that some changes took a day and then it was do... | <p>You can use various ways to handle this situation, depending on your source control system. </p>
<p>Private branches: Allow you to check in and work on code while you go, merging back and forth at appropriate times.</p>
<p>Shelvesets/pacakaged changesets: Allow you to store changesets and send them around for revi... |
Regex in VB6? <p>I need to write a program that can sift through specially-formatted text files (essentially CSV files with a fixed set of column types that have different delimiters for some columns ... comma in most places, colons in others) to search for formatting errors. I figure regular expressions will be the w... | <p>Use the Regex COM component built into Windows. You can find a step by step on referencing and using it in your project at: <a href="http://www.regular-expressions.info/vb.html" rel="nofollow">http://www.regular-expressions.info/vb.html</a></p>
|
Eclipse "Share Project" by hand? <p>What actually happens to the file system when you do a Subclipse Share Project on an Eclipse project that was externally checked out from Subversion? All the .svn folders are already in place. I get an error when I try to Share Project the right way, and I'd rather not delete and r... | <p>Dunno exactly what happens within eclipse, I presume it does some funky stuff in the .metadata directory of the workspace. That said, I would recommend the following to get eclipse to learn about the svn settings of the project:</p>
<ul>
<li>Delete the project from the workspace (keep "Delete project contents on d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.