instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm writing a simple IDictionary abstraction in C# that wraps a
Dictionary<K, ICollection<V>>. Basically, it maps multiple values to one key. I can't decide whether to remove a key and its empty list when the last item in a values list is removed, or leave it (to avoid instantiating a new collection if... | <p>I would remove the collections so that your MultiMap has consistent behavior. If I used your MultiMap I would be very surprised (and unhappy) to find that a missing key behaves differently depending on whether a key was previously in the MultiMap or not.</p>
<p>Does Clear() remove the the Collections?</p>
<p>You m... | <p>Why not treat the key as present even if all the values are removed, and provide explicit API for removing the key?</p>
| 40,214 |
<p>My employer uses subversion for version-control, and this is unlikely to change. I'm interested in learning more about git, and using git-svn to interface with my employer's subversion repositories. My question is: if I were to begin using git-svn, would I need to do some or all of my version control work from the c... | <p><a href="http://www.syntevo.com/git-svn/index.html" rel="nofollow noreferrer">This page</a> seems to indicate that <a href="http://www.syntevo.com/smartgit/index.html" rel="nofollow noreferrer">SmartGit</a> can do what you want. As far as I can tell, you have to do the initial init/clone from cmd/bash though.</p>
| <p>I wonder if it would be possible to somehow intercept the Push command in git-gui and make it run git-svn dcommit instead? I have already added an git alias to run !git-svn dcommit.</p>
| 48,580 |
<p>I used <code>git pull</code> and had a merge conflict:</p>
<pre><code>unmerged: some_file.txt
You are in the middle of a conflicted merge.
</code></pre>
<p>How do I abandon my changes to the file and keep only the pulled changes?</p>
| <p>Since your <code>pull</code> was unsuccessful then <code>HEAD</code> (not <code>HEAD^</code>) is the last "valid" commit on your branch:</p>
<pre><code>git reset --hard HEAD
</code></pre>
<p>The other piece you want is to let their changes over-ride your changes. </p>
<p>Older versions of git allowed you to use ... | <p>I found the following worked for me (revert a single file to pre-merge state):</p>
<pre><code>git reset *currentBranchIntoWhichYouMerged* -- *fileToBeReset*
</code></pre>
| 12,722 |
<p>Does SQL Server's (2000) <strong>Soundex function work on Asian character sets</strong>? I used it in a query and it appears to have not worked properly but I realize that it could be because I don't know how to read Chinese...</p>
<p>Furthermore, are there any other languages where the function might have trouble ... | <p>Soundex is fairly specific to English - it may or may not work well on other languages. One example that happened in New Zealand was an attempt at patient name matching using Soundex. Unfortunately pacific island names did not work well with Soundex, in many cases hashing to the same small set of values. A differ... | <p>You may use an algorithm like Levenshtein distance. There are various implementations of the algorithm as user-defined functions which you may use within a <code>SELECT</code> statement.</p>
| 38,443 |
<p>Essentially the only thing I can deploy to my deployment machine is a JAR file. I can't install JRuby, nor can I install Glassfish or Tomcat.</p>
<p>Is it possible to package up a Rails application (including Rails, vendored, of course) to a JAR file such that I can do</p>
<pre><code>c:\my_server> java rails_a... | <p>I'd recommend that you checkout Jetty. The process for <a href="http://docs.codehaus.org/display/JETTY/Embedding+Jetty" rel="noreferrer">Embedding Jetty</a> is surprisingly easy, and it should be possible to give it your servlets from your current jar file. I haven't used Ruby/Rails, though, so I'm not sure if the... | <p>I just ran across this blog today, and I intend on giving it a try, if anyone else has let me know</p>
<p><a href="http://matthewkwilliams.com/index.php/2010/03/02/rails-jruby-in-a-jar/" rel="nofollow">http://matthewkwilliams.com/index.php/2010/03/02/rails-jruby-in-a-jar/</a></p>
| 15,695 |
<p>SQL:</p>
<pre><code>SELECT
u.id,
u.name,
isnull(MAX(h.dateCol), '1900-01-01') dateColWithDefault
FROM universe u
LEFT JOIN history h
ON u.id=h.id
AND h.dateCol<GETDATE()-1
GROUP BY u.Id, u.name
</code></pre>
| <p>A solution, albeit one that defers handling of the null value to the code, could be:</p>
<blockquote>
<p>DateTime yesterday = DateTime.Now.Date.AddDays(-1);</p>
</blockquote>
<pre><code>var collection=
from u in db.Universe
select new
{
u.id,
u.name,
MaxDate =(DateTime?)
... | <p>This isn't a full answer for you, but on the left join piece you can use the DefaultIfEmpty operator like so:</p>
<pre><code>var collection =
from u in db.Universe
join history in db.History on u.id = history.id into temp
from h in temp.DefaultIfEmpty()
where h.dateCol < DateTime.Now.Date.AddDays(-1)
select u.i... | 2,325 |
<p>I know the file needs to be where the getClass().getResource(filename) can find it, but I don't know where that is.</p>
<p>I'm interested both in where to put the files on the filesystem itself, and how to go about using Eclipse's functionality to set up the resources.</p>
| <p>For Eclipse, typically all you need to do is set up a folder somewhere within your source code directory. For instance, if the directory containing your source is <code>/src</code> then you can create a <code>/src/resources</code> folder to place your images/files in. Then, within your class you do a <code>getReso... | <p>You can either put them in the src folder alongside your classes, or you can create a new source folder for the purpose (usually called <em>resources</em>), although you'll locate them identically from code.</p>
<p>Then you get at them using <code>getResource("/com/x/y/foo.png")</code>.</p>
| 33,954 |
<p>I'm going to try out turbogears however I'm on windows vista.
however due to firewall proxy problems, it seems i can't download .egg files which is required for setup turbogears to get installed in my windows environment.
I do have a bootable, or I can make a bootable Linux USB, I can try cygwin but I am not sure wh... | <p>You can run TG <a href="http://docs.turbogears.org/1.0/InstallWindows" rel="nofollow noreferrer">locally from windows</a>. The <code>tgsetup.py</code> method of installation uses <a href="http://pypi.python.org/pypi/setuptools/0.6c9" rel="nofollow noreferrer">setuptools</a> which depends on being able to bring in <c... | <p>This might not be what you are looking for, but you can <a href="http://www.mtu.net/~engstrom/ssh-proxy.php" rel="nofollow noreferrer">bypass the proxy tunneling SSH</a>. Another possibility is using <a href="http://tor.eff.org" rel="nofollow noreferrer">Tor</a>.</p>
| 35,845 |
<p>I have an internal enterprise application I've developed for my company built on .Net 3.5 / SQL 2008. </p>
<p>I have two types of databases. The main system database which contains all of our global data, such as user names, and customers, etc. And project databases, which contain the actual data pertaining to ou... | <p>Generally if there is only ever one (or a handful) of databases, and you have direct control over them (typicall corporate environment), I'd recommend not auto upgrading the databases as it is more hassle than it's worth. Just pass the script on to the people doing the install.</p>
<p>For more widespread releases i... | <p>Since you are using .NET 3.5 you may want to consider using LINQ. LINQ has the ability to dynamically create a database (<a href="http://msdn.microsoft.com/en-us/library/bb399420.aspx" rel="nofollow noreferrer">link to howto</a>) using a mapping file or the strongly typed DBML file you've created. I believe that i... | 38,092 |
<p>I'm trying to have a new layer appear above existing content on my site when a link/button is clicked. I am using jquery - but the code I have doesn't seem to work as expected.</p>
<p>Here is what I have:</p>
<pre><code> $(document).ready(function(){
$("#button").click(function () {
$("#showme").insertAfter("... | <p>It would appear to me that to get the desired effect, the div you are inserting #showme into needs to be position: relative, and #showme should be position: absolute. Absolute positioning will take the element out of the document flow, allowing it to sit above the content.</p>
<p>Also, two tips - $() is a shortcut... | <p>Make sure <code>#showme</code> has a <code>position</code> other than <code>static</code>.</p>
| 27,570 |
<p>I was looking into using some .NET code from within a Delphi program, I will need to make my program extensible using .net assemblies and predefined functions (I already support regular DLLs).</p>
<p>After a lot of searching online, I found <a href="http://www.managed-vcl.com/" rel="noreferrer">Managed-VCL</a>, bu... | <p>In the Jedi Code Library (JCL) - free - there is a JclDotNet.pas, containing a class TJclClrHost, probably doing what you want:</p>
<pre><code> TJclClrHost = class(TJclClrBase, ICorRuntimeHost)
private
FDefaultInterface: ICorRuntimeHost;
FAppDomains: TObjectList;
procedure EnumAppDomains;
functio... | <p>You can use .Net classes as COM objects in Delphi:</p>
<ul>
<li>create assembly in C# </li>
<li>create type library for assembly</li>
<li>import type library in Delphi</li>
</ul>
<p>Now you can access classes from .Net assembly that are exported in type library.</p>
| 32,324 |
<p>I have an NFS-mounted directory on a Linux machine that has hung. I've tried to force an unmount, but it doesn't seem to work:</p>
<pre><code>$ umount -f /mnt/data
$ umount2: Device or resource busy
$ umount: /mnt/data: device is busy
</code></pre>
<p>If I type "<code>mount</code>", it appears that the directory i... | <p>You might try a lazy unmount:</p>
<pre><code>umount -l
</code></pre>
| <p>Your NFS server disappeared.</p>
<p>Ideally your best bet is if the NFS server comes back.</p>
<p>If not, the "umount -f" should have done the trick.
It doesn't ALWAYS work, but it often will.</p>
<p>If you happen to know what processes are USING the NFS filesystem,
you could try killing those processes and then ... | 6,153 |
<p>I'm working on a C++ library that (among other stuff) has functions to read config files; and I want to add tests for this. So far, this has lead me to create lots of valid and invalid config files, each with only a few lines that test one specific functionality. But it has now got very unwieldy, as there are so man... | <p>Perhaps the library could accept some kind of stream input, so you could pass in a string-like object and avoid all the input files? Or depending on the type of configuration, you could provide "get/setAttribute()" functions to directly, publicy, fiddle the parameters. If that is not really a design goal, then never... | <p>In some tests I have done, I have actually used the test code to write the configuration files and then delete them after the test had made use of the file. It pads out the code somewhat and I have no idea if it is good practice, but it worked. If you happen to be using boost, then its filesystem module is useful fo... | 22,592 |
<p>If I create classes, that are used at the moment only in a single thread, should I make them thread-safe, even if I don't need that at the moment? It could be happen, that I later use this class in multiple threads, and at that time I could get race conditions and may have a hard time to find them if I didn't made t... | <p>Start from the data. Decide which data is explicitly shared and protect it. If at all possible, encapsulate the locking with the data. Use pre-existing thread-safe concurrent collections.</p>
<p>Whenever possible, use immutable objects. Make attributes final, set their values in the constructors. If you need t... | <p>If you want to follow what Sun did in the Java API, you can take a look at the collection classes. Many common collection classes are not thread-safe, but have thread-safe counterparts. According to Jon Skeet (see comments), many of the Java classes were originally thread-safe, but they were not benefiting developer... | 29,010 |
<p>With Windows 7 probably going to RTM next October (and DirectX 11 with it), would it be worth waiting for DirectX 11's explicit GPGPU features, meaning it will be cross-platform (ATI/Nvidia, not Windows/Linux/Mac/Whatever); or should I create a CUDA application now?</p>
| <p>From a learning point-of-view I think you would benefit from starting with CUDA now, since it will help you a lot with thinking in data-parallelism which is what the GPUs are good at. Then when/if you turn to DirectX 11, you have a good foundation for working with it, but it depends on the kind of time you have avai... | <p>If you want the learning experience, go for it!</p>
<p>Another alternative is AMD/ATI's stream SDK which you can download here: <a href="http://ati.amd.com/technology/streamcomputing/sdkdwnld.html" rel="nofollow noreferrer">http://ati.amd.com/technology/streamcomputing/sdkdwnld.html</a></p>
<p>nVidia's Cuda and AT... | 27,810 |
<p>Suppose there´s a template function in C++ that does some useful work but also outputs a sequence of values via an output iterator. Now suppose that that sequence of values sometimes is interesting, but at others is not useful. Is there a ready-to-use iterator class in the STL that can be instantiated and passed to ... | <p>The STL does not provide such an iterator. But you could code it yourself (tested that code):</p>
<pre><code>struct null_output_iterator :
std::iterator< std::output_iterator_tag,
null_output_iterator > {
/* no-op assignment */
template<typename T>
void operator=(T co... | <p>I based mine on <a href="http://www.open-std.org/jtc1/sc22/open/n2356/lib-iterators.html#lib.back.insert.iterator" rel="nofollow noreferrer">std::back_insert_iterator</a>, but without the container:</p>
<pre><code>#include <iterator>
template<typename T>
class NullOutputIter
: public std::iterator&... | 43,582 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/73713/how-do-i-check-for-nulls-in-an-operator-overload-without-infinite-recursion">How do I check for nulls in an '==' operator overload without infinite recursion?</a> </p>
</blockquote>
<p>When I over... | <p>As Microsoft says,</p>
<blockquote>
<p>A common error in overloads of
operator == is to use (a == b), (a ==
null), or (b == null) to check for
reference equality. This instead
results in a call to the overloaded
operator ==, causing an infinite loop.
Use ReferenceEquals or cast the type
to Object, t... | <p>Follow the DB treatment:</p>
<pre><code>null == <anything> is always false
</code></pre>
| 11,245 |
<p>I am currently writing a small calendar in ASP.Net C#. Currently to produce the rows of the weeks I do the following for loop:</p>
<pre><code>var iWeeks = 6;
for (int w = 0; w < iWeeks; w++) {
</code></pre>
<p>This works fine, however, some month will only have 5 weeks and in some rare cases, 4.</p>
<p>How can... | <p>Here is the method that does it:</p>
<pre><code>public int GetWeekRows(int year, int month)
{
DateTime firstDayOfMonth = new DateTime(year, month, 1);
DateTime lastDayOfMonth = new DateTime(year, month, 1).AddMonths(1).AddDays(-1);
System.Globalization.Calendar calendar = System.Threading.Thread.Current... | <p>How about checking which week the first and last days will be in?</p>
| 3,116 |
<p>Following is some obviously-defective code for which I think the compiler should emit a diagnostic. But neither <code>gcc</code> nor <code>g++</code> does, even with all the warnings options I could think of: <code>-pedantic -Wall -Wextra</code></p>
<pre><code>#include <stdio.h>
short f(short x)
{
retur... | <p>Use -Wconversion -- the problem is an implicit cast (conversion) from long x to short when the function f(short x) is called [not printf], and -Wconversion will say something like "cast from long to short may alter value".</p>
<p>..</p>
<p>Edit: just saw your note. -Wconversion results in a warning for me, using ... | <p>I would strongly suggest investing in PC-lint/FlexeLint from <a href="http://gimpel.com/" rel="nofollow noreferrer">Gimpel</a>. The software is made for catching things like this that the compiler just isn't. It is relatively inexpensive and well worth the price. There is an online demo on the site that you can u... | 39,956 |
<p>So I'm using hibernate and working with an application that manages time.
What is the best way to deal with times in a 24 hour clock?</p>
<p>I do not need to worry about TimeZone issues at the beginning of this application but it would be best to ensure that this functionality is built in at the beginning.</p>
<p>... | <p>Store them as long ts = System.currentTimeMillis().
That format is actually TimeZone-safe as it return time in UTC.</p>
<p>If you only need time part, well, I'm not aware of built-in type in Hib, but writing your own type Time24 is trivial -- just implement either org.hibernate.UserType or org.hibernate.CompositeU... | <p><code>java.util.Date</code> should be used; not a long (and definitely not a <code>Calendar</code>).</p>
<p>If you are using annotations be sure to use <code>@Temporal</code></p>
| 15,122 |
<p>I have a very large codebase (read: thousands of modules) that has code shared across numerous projects that all run on different operating systems with different C++ compilers. Needless to say, maintaining the build process can be quite a chore. </p>
<p>There are several places in the codebase where it would clean... | <h1>Little Update</h1>
<p>Some compilers might support <code>__has_include ( header-name )</code>.</p>
<p>The extension was added to the <a href="https://isocpp.org/files/papers/p0636r0.html" rel="noreferrer">C++17 standard</a> (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0061r1.html" rel="noref... | <p><strong>I had to do something similar for the Symbian OS. This is how i did it:
lets say you want to check if the file "file_strange.h" exists and you want to include some headers or link to some libraries depending on the existance of that file.</strong></p>
<p><strong>first creat a small batch file for checking t... | 17,266 |
<p>I am writing a program that does a lot of writes to a Postgres database. In a typical scenario I would be writing say 100,000 rows to a table that's well normalized (three foreign integer keys, the combination of which is the primary key and the index of the table). I am using PreparedStatements and executeBatch()... | <p>This is an issue that I have had to deal with often on my current project. For our application, insert speed is a critical bottleneck. However, we have discovered for the vast majority of database users, the select speed as their chief bottleneck so you will find that there are more resources dealing with that issue... | <p>You can obviously try to change the size of your batch to find the best size for your configuration, but I doubt that you will gain a factor 3.</p>
<p>You could also try to tune your database structure. You might have better performances when using a single field as a primary key than using a composed PK. Depending... | 48,141 |
<p>I'm taking a course in computational complexity and have so far had an impression that it won't be of much help to a developer. </p>
<p>I might be wrong but if you have gone down this path before, could you please provide an example of how the complexity theory helped you in your work? Tons of thanks.</p>
| <p>O(1): Plain code without loops. Just flows through. Lookups in a lookup table are O(1), too.</p>
<p>O(log(n)): efficiently optimized algorithms. Example: binary tree algorithms and binary search. Usually doesn't hurt. You're lucky if you have such an algorithm at hand.</p>
<p>O(n): a single loop over data. Hurts f... | <p>A good example could be when your boss tells you to do some program and you can demonstrate by using the computational complexity theory that what your boss is asking you to do is not possible.</p>
| 13,663 |
<p>I'm wondering where I find the source to show how the operator ** is implemented in Python. Can someone point me in the right direction? </p>
| <p>The python grammar definition (from which the parser is generated using <a href="http://www.python.org/dev/peps/pep-0269/" rel="noreferrer">pgen</a>), look for 'power': <a href="http://svn.python.org/view/python/trunk/Grammar/Grammar?rev=65872&view=markup" rel="noreferrer">Gramar/Gramar</a></p>
<p>The python as... | <p>It's the power to operator</p>
<p><a href="http://www.python.org/doc/2.5.2/ref/power.html" rel="nofollow noreferrer">python.org doc - Power operator</a></p>
<p>Edit: Oh, dang, the code, right. Hope the link still helps. Sloppy read from my part</p>
| 46,173 |
<p>I have a SQL Server 2005 sp2 box where tempdb has either 8 data files or 5 data files dependingo n where you look. DBCC showfilestates and sys.database_files (both queried in tempdb) show 8 data files (tempdev - tempdev8), however when I query sys.master_files (in master db, which is also what the GUI uses), I only... | <p>It's possible that one view is showing outdated information. One scenario is that those files were dropped from tempdb but SQL Server has not been restarted to delete those files our their entries from some of the system catalog. And you can't add new ones until the old ones are really gone. Anything destructive you... | <p>The first question I have to ask is, why are you messing with tempdb? Are you experiencing bottlenecks because of tempdb?</p>
| 27,932 |
<p>I have an HTML wrapper that contains a Flex application, is there an Event that I can listen on, that is triggered when a user leaves the HTML wrapper either by navigation arrows or closing the browser?</p>
<p>Thanks. </p>
| <p>You can also listen for Event.ACTIVATE and Event.DEACTIVATE in Flash. All EventDispatchers receive these events when Flash/AIR gains or loses focus from the OS.</p>
<p><a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/EventDispatcher.html#event:deactivate" rel="nofollow noreferrer">ht... | <p>There is Body.onUnload, but i'm not sure how reliable it actually is.</p>
| 21,730 |
<p>I have a Trac project installed on top of a Subversion implementation (easy to do thanks to Webfaction's control panel), but now I have configuration work to do. With that in mind, are there <em>easy</em> ways to do the following in Trac:</p>
<p>1) Ensure that customers can only see a high level progress indicator... | <p>I would not recommend using the same Trac project for tracking development tasks and showing the customer progress. You want to be able to be candid with your development tickets, comments, etc. Customers can focus on the wrong things and misinterpret data you put in the tickets. I would recommend providing the cust... | <p>@Dave Dunkin is right. Use Trac for your internal use, and use a system like <a href="http://www.basecamphq.com/" rel="nofollow noreferrer">Basecamp</a> to give your clients a high-level overview of what's going on in the project.</p>
| 23,504 |
<p>Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)?</p>
| <p><a href="http://www.w3schools.com/css/css_image_transparency.asp" rel="nofollow noreferrer">Here's some good information about image opacity and transparency with CSS</a>.</p>
<p>So to make an image with opacity 50%, you'd do this:</p>
<pre><code><img src="image.png" style="opacity: 0.5; filter: alpha(opacity=5... | <p>The way I usually see things done with smaller images such as buttons it that only a certain portion of the image is shown. Then many states of the picture will make up a larger picture which gets shifted around behind the visible port. I'll delete this when someone has code.</p>
| 8,516 |
<p><strong>I was wondering if there was a .NET-compatible CLR that was implemented using the CLI</strong> (common language infrastructure), e.g., using .NET itself, or at least if there were any resources that would help with building one.</p>
<p>Basically, something like a .NET program that loads assemblies as Memory... | <p>I don't think there are currently any standalone .net VMs that are self hosting but both <a href="http://www.gocosmos.org" rel="noreferrer">Cosmos</a> and <a href="http://sharpos.org" rel="noreferrer">SharpOS</a> are .net runtimes written in C#.</p>
<p>It may be possible to reuse some of their runtime code to extra... | <p>Look at the System.Reflection.Emit namespace, specifically the ILGenerator class.</p>
<p>You can emit IL on the fly.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.ilgenerator_members.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.reflection.emit.ilge... | 18,236 |
<p>How would you append an integer to a <code>char*</code> in c++?</p>
| <p>First convert the int to a <code>char*</code> using <code>sprintf()</code>:</p>
<pre><code>char integer_string[32];
int integer = 1234;
sprintf(integer_string, "%d", integer);
</code></pre>
<p>Then to append it to your other char*, use <code>strcat()</code>:</p>
<pre><code>char other_string[64] = "Integer: "; //... | <p>Something like:</p>
<pre><code>width = floor(log10(num))+1;
result = malloc(strlen(str)+len));
sprintf(result, "%s%*d", str, width, num);
</code></pre>
<p>You could simplify len by using the maximum length for an integer on your system.</p>
<p><em>edit</em> oops - didn't see the "++". Still, it's an alternative.<... | 45,167 |
<p>Does anybody know how I can get the number of the elements (rows*cols) returned after I do an SQL query? If that can't be done, then is there something that's going to be relatively representative of the size of data I get back?</p>
<p>I'm trying to make a status bar that indicates how much of the returned data I ... | <p>That is frequently a problem when you wan to reserve dynamic memory to hold the entire result set. </p>
<p>One technique is to return the count as part of the result set.</p>
<pre><code>WITH
data AS
(
SELECT interesting-data
FROM interesting-table
WHERE some-condition
)
SELECT COUNT(*), data.*
from... | <p>SQLRowCount can return the number of rows for SELECT queries if the driver supports it. Many drivers dont however, because it can be expensive for the server to compute this. If you want to guarantee you always have a count, you must use COUNT(*), thus forcing the server into doing the potentially time consuming cal... | 45,706 |
<p>I have a setup executable that I need to install. When I run it, it launches a msi to do the actual install and then dies immediately. The side effect of this is it will return control back to any console you call it from before the install finishes. Depending on what machine I run it on, it can take from three to t... | <p>Would doing a WMI lookup of processes that have the initial setup as the parent process do the trick? For example, if I launch an MSI from a command prompt with process id 4000, I can execute the following command line to find information about msiexec process:</p>
<pre><code>c:\>wmic PROCESS WHERE ParentProces... | <p>If you're using a .NET language (you can do it in Win32, but waaaay easier in .NET) you can enumerate all the Processes in the system (after your initial call to Setup.exe completes) and find all the processes which parent's PID equal to the PID of the Setup.exe - and then monitor all those processes. When they will... | 13,203 |
<p>Is it possible to create a stored procedure as</p>
<pre><code>CREATE PROCEDURE Dummy
@ID INT NOT NULL
AS
BEGIN
END
</code></pre>
<p>Why is it not possible to do something like this?</p>
| <p>You could check for its NULL-ness in the sproc and <code>RAISERROR</code> to report the state back to the calling location. </p>
<pre><code>CREATE proc dbo.CheckForNull @i int
as
begin
if @i is null
raiserror('The value for @i should not be null', 15, 1) -- with log
end
GO
</code></pre>
<p>Then call: <... | <p>Parameter validation is not currently a feature of procedural logic in SQL Server, and NOT NULL is only one possible type of data validation. The CHAR datatype in a table has a length specification. Should that be implemented as well? And how do you handle exceptions? There is an extensive, highly developed and som... | 42,787 |
<p>This seems to be an overlooked area that could really use some insight. What are your best practices for:</p>
<ul>
<li>making an upgrade procedure</li>
<li>backing out in case of errors</li>
<li>syncing code and database changes</li>
<li>testing prior to deployment</li>
<li>mechanics of modifying the table</li>
</... | <p>That's a great question. ( There is a high chance this is going to end up a normalised versus denormalised database debate..which I am not going to start... okay now for some input.)</p>
<p>some off the top of my head things I have done (will add more when I have some more time or need a break)</p>
<p>client desig... | <p>As Pat said, use liquibase. Especially when you have several developers with their own dev databases
making changes that will become part of the production database.</p>
<p>If there's only one dev, as on one project I'm on now(ha), I just commit the schema changes as SQL text files into a CVS repo, which I check ou... | 4,950 |
<p>I'm trying to convert an XML file into the markup used by dokuwiki, using XSLT. This actually works to some degree, but the indentation in the XSL file is getting inserted into the results. At the moment, I have two choices: abandon this XSLT thing entirely, and find another way to convert from XML to dokuwiki mar... | <p>There are three reasons for getting unwanted whitespace in the result of an XSLT transformation:</p>
<ol>
<li>whitespace that comes from between nodes in the source document</li>
<li>whitespace that comes from within nodes in the source document</li>
<li>whitespace that comes from the stylesheet</li>
</ol>
<p>I'm ... | <p>Regarding your edit about new lines, you can use this template to recursively replace one string within another string, and you can use it for line breaks:</p>
<pre><code><xsl:template name="replace.string.section">
<xsl:param name="in.string"/>
<xsl:param name="in.characters"/>
<xsl:para... | 22,298 |
<p>Is it good practice to have a unit test that specifies how long a certain function takes to return a value. I'm unit testing a curl function and want to specify that it needs to time out after 5 seconds. Is this in line with the way unit tests work?</p>
| <p>Testing your function plus curl plus the server is more integration test than unit test. That being said, you don't have to be that dogmatic, if you only have one test like that this certainly is viable. I've written, and still have tests that are not pure unit tests, but they do their job. I'll keep them as far as ... | <p>I think you should be mocking the method the function uses to detect that it has spent long enough waiting, then you can test the timeout instantly and not wait in real time.</p>
| 39,196 |
<p>If you're building an <code>AJA~Xy</code> app, are there any downsides to using <code>JSONP</code> requests/responses even if you're not planning on any <code>cross-domain</code> requests? </p>
<p>The only thing I can think of is that there are a couple extra bytes for the callback wrapper... </p>
<p><strong>Edit:... | <p>Downside? It's fairly limited - you trigger a "GET" request and get back some script that's executed. You don't get error handling if your server throws an error, so you need to wrap all errors in JSON as well. You can't really cancel or retry the request. You're at the mercy of the various browser author opinions o... | <p>Here is another bit you may want to consider with JSONP.. possible memory leaks.. </p>
<p><a href="http://neil.fraser.name/news/2009/07/27/" rel="nofollow noreferrer">http://neil.fraser.name/news/2009/07/27/</a></p>
| 3,965 |
<p>I'm looking for a GWT common purpose paging widget.
So far I have found <a href="http://gwt-widget.sourceforge.net/" rel="nofollow noreferrer">GWT widget library</a> and the
<a href="http://code.google.com/p/google-web-toolkit-incubator/w/list" rel="nofollow noreferrer">Google Incubator widgets</a>.
Is there any o... | <p>You found the two major ones. The Google Incubator widgets might be a good bet, because the intention is for these to eventually make it into the main library. In general the GWT widget library widgets tend to be fancier, but the GWT incubator library widgets tend to be more modular and also more robust across mor... | <p>This GXT library have a commercial lisence!</p>
| 28,649 |
<p>Is there a way to make stack trace to display the whole generated SQL statement when there is an error instead just the first few characters of it?</p>
<p>This is what it currently displays</p>
<blockquote>
<p>...\Zend\Db\Adapter\Pdo\Abstract.php(220): Zend_Db_Adapter_Abstract->query('UPDATE "diction...', Array)... | <p>If you want to view the complete sql statement you can use Zend_Debug. For example if your sql statement is in the variable $select and you want to view the complete sql statement you can use the following line of code:</p>
<pre><code>Zend_Debug::Dump($select);
exit;
</code></pre>
<p>Or if your code is created wit... | <p>whilst the profiler is V cool - it doesn't help debug when the system throws an exception..</p>
<p>check out this post on giving a more detailed stack trace inc full SQL</p>
<p>ONLY TO BE USED IN DEV ENVIRONMENTS for obvious reasons</p>
<p><a href="http://www.edmondscommerce.co.uk/blog/zend-framework/zend-framewo... | 42,829 |
<p>I have a loop (for item in @dataset) and I want, in each iteration, to get different data from another table and make some operations that will be printed in the view. I cant't get this data from the dataset used in the loop.</p>
<p>How can I do this according to MVC? I can put the code into the loop, in the view, ... | <p>If you have one table, and want to get data from another table, usually this is in the situation of a <code>has_many</code> relation. For example, we have <code>@people</code> (<code>Person</code> model), and each person <code>has_many</code> addresses (<code>Address</code> model). In those cases the best thing to d... | <ul>
<li>Keep all the logic on your @dataset item inside the controller action</li>
<li>Utilize methods in your models for the interaction with other model objects you need</li>
<li>You should be left with only @dataset for your view that you can render in a partial.</li>
</ul>
<p>You would need to further explain you... | 35,565 |
<p>I'm working on a design for a hierarchical database structure which models a catalogue containing products (this is similar to <a href="https://stackoverflow.com/questions/112866/database-schema-for-a-hierarchial-groups">this question</a>). The database platform is SQL Server 2005 and the catalogue is quite large (7... | <p>Use a closure table. If your basic structure is a parent-child with the fields ID and ParentID, then the structure for a closure table is ID and DescendantID. In other words, a closure table is an ancestor-descendant table, where each possible ancestor is associated with all descendants. You may include a LevelsB... | <p>you might be able to solve the customer groups problem with roles and treeId's but you'll have to provide us with the query.</p>
| 46,353 |
<p>I'm using the JSP <a href="http://displaytag.sourceforge.net/11/" rel="nofollow noreferrer">displaytag</a> tag lib to create HTML tables. I'd like the user to able to click on a column header in order to sort the data. My JSP code is shown below:</p>
<pre><code><display:table name="tableData" id="stat" sort="pag... | <p>As far as I know, this is not possible. JQuery's tablesorter may work for the small tables that it uses for its examples, but most tables have to come from an actual database. This hit is far too great to simply retrieve all the data before returning to the client with this information, and then allowing it to be ... | <p>Take a look at using <a href="http://jquery.com" rel="nofollow noreferrer">jquery</a> and its excellent <a href="http://tablesorter.com" rel="nofollow noreferrer">tablesorter</a> API. This will let you sort the table on the client side using Javascript.</p>
| 33,490 |
<p>How do you automatically start a service after running an install from a Visual Studio Setup Project?</p>
<p>I just figured this one out and thought I would share the answer for the general good. Answer to follow. I am open to other and better ways of doing this.</p>
| <p>Add the following class to your project.</p>
<pre><code>using System.ServiceProcess;
class ServInstaller : ServiceInstaller
{
protected override void OnCommitted(System.Collections.IDictionary savedState)
{
ServiceController sc = new ServiceController("YourServiceNameGoesHere");
sc.Start(... | <p>There is also another way which does not involve code. You can use the Service Control Table. Edit the generated msi file with orca.exe, and add an entry to the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa371634(v=vs.85).aspx" rel="nofollow noreferrer">ServiceControl Table</a>.</p>
<p>Only t... | 26,146 |
<p>How do you create non scrolling div that looks like the MS Office 2007 ribbon on a web page without two sets of scroll bars. One for the window and one for the div.</p>
| <p>Try this:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Fixed Header/Full Page Content</title>
<meta http-equiv="C... | <p>You could alternatively use </p>
<pre><code>
<div style='position:absolute;top:0px:left:0px;'>Text</div>;
</code></pre>
<p>It will jamm the div on the top of the page, but if your page scrolls down it will stay there. </p>
| 32,043 |
<p>I've got a unfinished project that a developer just didn't finish and didn't leave any documentation about the installation process. I've downloaded the production directory to my windows machine (running InstantRails 2), I created the databases as required in the <code>database.yml</code> and I tried to run the <co... | <p>Sometimes Rails will throw this error if there's a syntax error where Admin is defined.</p>
<p>Try looking for admin.rb and make sure that it parses.</p>
<p>Also, you may want to try running the migrations one at a time (<code>rake db:migrate VERSION=1</code>, etc.) to see if that helps you track down which migrat... | <p>It don't points me where i have a Admin constant. There is a way to check at least where should I look? my models, my controllers, etc?</p>
<p>rake db:migrate VERSION=1, gives me a error already. As I told you, am I just trying to finish a project unfinished by another guy.</p>
<p>How can i do a migration file per... | 26,993 |
<p>C# What is the easiest way to disable a control after 10 seconds? Using a Timer or a stopwatch? I'm new to both so thanks for the help.</p>
| <p>I'm not sure how you'd expect stopwatch to help. A timer certainly sounds like the right answer to me. You should be aware that there are <a href="http://pobox.com/~skeet/csharp/threads/timers.shtml" rel="nofollow noreferrer">several different timers available</a> - in this case <a href="http://msdn.microsoft.com/en... | <p>Use a timer. It suits your needs better.</p>
<p>EDIT: As other have said, go with the <code>System.Windows.Forms.Timer</code></p>
| 35,152 |
<p>For various reasons a web application would be best suite a project that I am working on but I am worried about the user interface. There will be a lot of pick and choose options that could be handled by check lists, combo boxes, etc… and to a lesser extent their will be some free text fields. However, I am concer... | <p>We are currently in the process of rolling out an application that is exactly as you describe. There are a number of issues that you will run into.</p>
<p>You will probably need a "Soft keyboard" at some point. We have not found a decent third party one, but they are not too difiicult to write yourself.</p>
<p>If... | <p>You might want to take a look at Baobab Health's <a href="http://github.com/baobab/touchscreentoolkit" rel="nofollow noreferrer">open source touchscreen tookit</a>. It does a nice job converting an html form into a touchscreen interaction using only javascript. Documentation is a little light, but it might at leas... | 16,230 |
<p>I want to prevent XSS attacks in my web application. I found that HTML Encoding the output can really prevent XSS attacks. Now the problem is that how do I HTML encode every single output in my application? I there a way to automate this?</p>
<p>I appreciate answers for JSP, ASP.net and PHP.</p>
| <p>You don't want to encode all HTML, you only want to HTML-encode any user input that you're outputting. </p>
<p>For PHP: <a href="http://us.php.net/htmlentities" rel="nofollow noreferrer">htmlentities</a> and <a href="http://us.php.net/manual/en/function.htmlspecialchars.php" rel="nofollow noreferrer">htmlspecialcha... | <p>If you do actually HTML encode every single output, the user will see plain text of &lt;html&gt; instead of a functioning web app.</p>
<p>EDIT: If you HTML encode every single input, you'll have problem accepting external password containing < etc..</p>
| 8,311 |
<p>I have a query:</p>
<p>UPDATE choices SET votes = votes + 1 WHERE choice_id = '$user_choice'</p>
<p>But when I execute it in my script, the votes field is updated twice, so the votes will go from 4 to 6 instead to 5. It doesn't seem that it is getting called twice because I echo out stuff to test this and only get... | <p>There are several SQL interfaces for many different brands of database in PHP. You haven't shown the PHP code you use to execute the query, nor have you identified which brand of database you use.</p>
<p>In some SQL interfaces in PHP, creating the statement implicitly executes the SQL. Then you have the opportuni... | <p>I just created the a database table to test this query, I must say it is running fine on my side.</p>
<blockquote>
<p>UPDATE <code>choices</code> SET <code>votes</code> = ( votes +1 ) WHERE <code>choice_id</code> = '1' </p>
</blockquote>
<p>I think the code my be executed twice in your application, can you try ... | 29,542 |
<p>As an example, Google App Engine uses Google Datastore, not a standard database, to store data. Does anybody have any tips for using Google Datastore instead of databases? It seems I've trained my mind to think 100% in object relationships that map directly to table structures, and now it's hard to see anything di... | <p>There's two main things to get used to about the App Engine datastore when compared to 'traditional' relational databases:</p>
<ul>
<li>The datastore makes no distinction between inserts and updates. When you call put() on an entity, that entity gets stored to the datastore with its unique key, and anything that has... | <p>Being rooted in the database world, a data store to me would be a giant table (hence the name "bigtable"). BigTable is a bad example though because it does a lot of other things that a typical database might not do, and yet it is still a database. Chances are unless you know you need to build something like Google... | 12,940 |
<p>I want to set the backgroun color for a GridViewColumn that is databound inside of a listview in WPF. I'm not sure how to ask this question being fairly new to WPF, otherwise I wouldn't have bothered all of you.</p>
<p>I want to change the background color of the whole row, based on a bool flag in my databound obje... | <p>I ran into a few troubles trying to do this, ended up like so</p>
<pre><code><ListBox ...>
<ListBox.ItemTemplate>
<DataTemplate>
<Border x:Name="BGBorder">
<!-- -->
</Border>
<DataTemplate.Triggers>
<DataTrigger
Bindin... | <p>I haven't tested this yet so it might need some tweaks but you're going to want to trigger off the value to set your background color.</p>
<pre><code><DataTemplate.Triggers>
<Trigger Property="IsInternalNote" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger&g... | 44,914 |
<p>I would like to know how to write PHPUnit tests with Zend_Test and in general with PHP.</p>
| <p>I'm using Zend_Test to completely test all controllers. It's quite simple to set up, as you only have to set up your bootstrap file (the bootstrap file itself should NOT dispatch the front controller!). My base test-case class looks like this:</p>
<pre><code>abstract class Controller_TestCase extends Zend_Test_PHPU... | <p>I haven't used Zend_Test but I have written tests against apps using Zend_MVC and the like. The biggest part is getting enough of your bootstrap code in your test setup.</p>
| 9,138 |
<p>I need an encoder that can convert mp3 files to he-aac (aka aac+).
So far the best one I have found is <a href="http://www.nero.com/eng/down-ndaudio.php" rel="nofollow noreferrer">nero aac encoder</a> .
I have two problemes with it :
- Only one input format : wav . It is a little bit slow to transform mp3 files t... | <p>Nero AAC is the only one as far as I know. Even if FAAC supported HE-AAC it would be useless, since as an encoder its pretty awfully designed and its quality is not even competitive with LAME, let alone a good AAC encoder.</p>
<p>Kostya on the FFMPEG team is currently working on an AAC encoder but it has a long wa... | <p>I don't have an idea about the quality, but I just found
<a href="http://dgaapenc.berlios.de/en/" rel="nofollow noreferrer">enhAacPlusEnc</a></p>
| 10,718 |
<p>I am currently working with a developer who is experienced at Ms-SQL, but not much at MySQL. He has been cursing MySQL for having Bugs, and also being far harder to use.</p>
<p>Is is because his experience has been so good with Management studio. It seems to me that his problems are with using phpMyAdmin.</p>
<p>F... | <p>You should really check <a href="http://www.webyog.com" rel="noreferrer">SQLYog</a>. It's great, and has a community version.</p>
<p><img src="https://i.stack.imgur.com/gGnji.png" alt="enter image description here"></p>
| <p><a href="http://www.sqlpp.com/products/mysql-management/" rel="nofollow">VSQL++ for MySQL</a> is a powerful GUI database management tool for MySQL</p>
| 36,460 |
<p>There is a little circuit board, or breadboard or something <a href="http://reprap.org/wiki/Prusa_i3_Rework_Electronics_and_wiring#Wiring" rel="nofollow noreferrer">in the diagram of the wiring for the i3</a>.</p>
<p>And it's mentioned that the z-axis motors need to be <a href="http://reprap.org/wiki/Prusa_i3_Rewor... | <p>In the diagram, they do show the wires connecting together, which is right. You can accomplish that just about any way you like, so long as you pair up the wires correctly from one motor to the other.</p>
<p>I'm assuming both "Z" motors are the same type and have the same color-coding for their wires. If not, you'l... | <p>For some unknown reason, everywhere everybody is saying that Z stepper motors need to be connected in parallel... And this was always the only obvious way, until recently some people started to connect these motors in series.</p>
<p>And I personally started to believe the right way is to connect them in series.</p>... | 171 |
<p>This is very interesting to me... This image displays perfectly well in Safari, but not at all in Firefox! Here's the relevant code:</p>
<pre><code><div id="ad">
<p>Advertisment</p>
<img src="/ADS/fakead1.gif" />
</div>
</code></pre>
<p>With CSS:</p>
<pre><code>#ad{color: #6... | <p>Wow, I'm not so smart...</p>
<p>AdBlock Plus is smarter that I would have thought! I'll need to change the div name to something less obvious than "ad" (!)</p>
<p>I should have known.</p>
<p>A word to the wise: if you want your ad to get through, name the div in klingon.</p>
| <p>it works for me here. its just your adblock i would say</p>
| 46,244 |
<p>I have a class library with some extension methods written in C# and an old website written in VB.</p>
<p>I want to call my extension methods from the VB code but they don't appear in intelisense and I get compile errors when I visit the site.</p>
<p>I have got all the required <em>Import</em>s because other class... | <p>It works for me, although there are a couple of quirks. First, I created a C# class library targeting .NET 3.5. Here's the only code in the project:</p>
<pre><code>using System;
namespace ExtensionLibrary
{
public static class Extensions
{
public static string CustomExtension(this string text)
{
... | <p>This was quite a while ago and I can't really how I solved it, but needless to say, it was user error. I probably restarted my computer and away it went.</p>
| 26,183 |
<p>In SQL, How we make a check to filter all row which contain a column data is null or empty ?<br>
For examile </p>
<pre><code>Select Name,Age from MEMBERS
</code></pre>
<p>We need a check Name should not equal to null or empty.</p>
| <p>This will work in all sane databases (<em>wink, wink</em>) and will return the rows for which name is not null nor empty</p>
<pre><code>select name,age from members where name is not null and name <> ''
</code></pre>
| <p>nvl(Name, 'some dumb string') this will return Name if Name is not null and different of '' (oracle, don't know for others). It will be equal to 'some dumb string' if null or equal to ''.</p>
| 42,130 |
<p>In low latency trading applications we are very conscious of latency issues. There is some concern that our application may experience increased latency if the server on which it is running changes PowerNow state.</p>
<p>Any kernel developers familiar with calling PowerNow changes and how much processor time is us... | <p>The Linux kernel appears to assume an upper bound of a fifth of a millisecond for a PowerNow state change operation to complete.</p>
<p>I would have thought a bigger worry than the cost of the state change itself, though, would be that downclocking the CPU will make your application run slower, increasing latency a... | <p>I doubt it has any latency. PowerNow just lowers core frequency and core voltage. I don't know that it will halt the CPU for a short time to do so and then resume processing after the change. AFAIK the change happens on the fly, the processing is not interrupted for that.</p>
<p>Thus the bigger problem might be tha... | 19,101 |
<p>As you work in a legacy codebase what will have the greatest impact over time that will improve the quality of the codebase?</p>
<ul>
<li>Remove unused code</li>
<li>Remove duplicated code </li>
<li>Add unit tests to improve test coverage where coverage is low</li>
<li>Create consistent formatting across files</li>... | <ul>
<li>Read Michael Feather's book <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="noreferrer" rel="nofollow noreferrer">"Working effectively with Legacy Code"</a></li>
</ul>
<p>This is a GREAT book.</p>
<p>If you don't like that answer, then the best advice I can give would be:</p>
<ul>
<l... | <p>The single biggest thing that I've done to the legacy code that I have to work with is to build a real API around it. It's a 1970's style COBOL API that I've built a .NET object model around, so that all the unsafe code is in one place, all of the translation between the API's native data types and .NET data types ... | 17,691 |
<p>I'm a doing some blackbox testing of a ASP.Net website and I need to test different session timeout scenarios. </p>
<p>I'm not sure they fully encapsulated session timeouts. Other then leaving a page open for 20 minutes is there an easier way to force a session timeout?</p>
| <p><strong>Decrease the timeout</strong></p>
<p>The easiest and most non-intrusive way to test this is probably to just decrease the timeout to a fairly small number, such as 3 or 5 minutes. This way you can pause for a few minutes to simulate a longer pause without worrying about application restarts or special reset... | <p>You have two options:-</p>
<p>1- Decrease the session timeout in web.config.
2- Restart IIS or Application pool.</p>
| 22,348 |
<p>A client has installed Sql server 2005 reporting services. When we go to the web bit at <code>http://servername/reports/</code> we just see a blank screen like:
<img src="https://i.stack.imgur.com/nGQXH.jpg" alt="http://img91.imageshack.us/img91/3787/rsblankqx4.jpg"></p>
<p>We are using windows authentication and ... | <p>I don't recognize that magic number, and neither does <a href="http://en.wikipedia.org/wiki/Magic_number_(programming)" rel="nofollow noreferrer">Wikipedia</a>. I would guess that some code in your program (or in a library you're using) is using <code>memset()</code> and hitting your pointer. Have you grepped your... | <p>0x7c7c = 01111100 01111100 in binary. That could be one of those "most difficult to read" bit patterns that format utilities fill unused space on hard drives with.</p>
| 46,905 |
<p>I have a table with doctor offices and doctors in those offices that I'm populating to a repeater control. The data coming back is not aggregated. So, if there are 2 doctors in 1 office, there are 2 rows, same office, different doctor. </p>
<p>Is there a way to aggregate the data so the repeater shows 1 office with... | <p>In your aspx markup:</p>
<pre><code><table><tr><th>Office</th><th>Doctors</th></tr>
<asp:repeater id="Repeater" runat="server" OnItemDataBound="NextItem" ... >
<ItemTemplate><asp:Literal id="RepeaterRow" runat="server" />
</ItemTemplate>
<... | <p>I think you'd be best doing the aggregation in the database.</p>
| 48,193 |
<p>This seems very noisy to me. Five lines of overhead is just too much.</p>
<pre><code>m_Lock.EnterReadLock()
Try
Return m_List.Count
Finally
m_Lock.ExitReadLock()
End Try
</code></pre>
<p>So how would you simply this?</p>
| <p>I was thinking the same, but in C# ;-p</p>
<pre><code>using System;
using System.Threading;
class Program
{
static void Main()
{
ReaderWriterLockSlim sync = new ReaderWriterLockSlim();
using (sync.Read())
{
// etc
}
}
}
public static class ReaderWriterE... | <p>I ended up doing this, but I'm still open to better ways or flaws in my design.</p>
<pre><code>Using m_Lock.ReadSection
Return m_List.Count
End Using
</code></pre>
<p>This uses this extension method/class:</p>
<pre><code><Extension()> Public Function ReadSection(ByVal lock As ReaderWriterLockSlim) As Re... | 20,523 |
<p>What is the best way to extract the MAC address from <code>ifconfig</code>'s output?</p>
<p>Sample output:</p>
<pre><code>bash-3.00# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 1F:2E:19:10:3B:52
inet addr:127.0.0.66 Bcast:127.255.255.255 Mask:255.0.0.0
UP BROADCAST RUN... | <p>You can do a cat under <code>/sys/class/</code> </p>
<pre><code>cat /sys/class/net/*/address
</code></pre>
<p>Specifically for <code>eth0</code></p>
<pre><code>cat /sys/class/net/eth0/address
</code></pre>
| <p>Output of ifconfig:</p>
<pre><code>$ifconfig
eth0 Link encap:Ethernet HWaddr 00:1b:fc:72:84:12
inet addr:172.16.1.13 Bcast:172.16.1.255 Mask:255.255.255.0
inet6 addr: fe80::21b:fcff:fe72:8412/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:638661 errors:0... | 30,510 |
<p>I am developing a .NET application which uses a few projects that I've pieced together from other internal projects. I was thinking about merging the .exe and the DLLS into a single executable file with a tool called <a href="http://research.microsoft.com/~mbarnett/ilmerge.aspx" rel="nofollow noreferrer">ILMerge</a... | <p>As long as they're your libraries, I don't think there's any big problem with it. Unless it makes the image absolutely and monstrously huge, I think it's better if the executable relies on itself as much as it can (exceptions being, of course, when you're replicating system functionality... no point in that).</p>
<... | <p>Many of the advantages of shared libraries stem from the fact that they are in fact shared. Do you have other applications which use the same DLLs which are also distributed publicly or might be in the future? If so, then sticking with the shared libraries can give several advantages. Typically, only one copy of the... | 38,520 |
<p>What tools do you use to develop Oracle stored procedures, in a team :</p>
<ul>
<li>To automatically "lock" the current procedure you are working with, so nobody else in the team can make changes to it until you are finished.</li>
<li>To automatically send the changes you make in the stored procedure, in an Oracle ... | <p>I'm not sure if the original poster is still monitoring this, but I'll ask the question anyways.</p>
<p>The original post requested to be able to:</p>
<blockquote>
<p>To automatically "lock" the current
procedure you are working with, so
nobody else in the team can make
changes to it until you are finished... | <p>Toad also does this without requiring CVS / SVN.</p>
| 13,705 |
<p>I have a page which work like a navigation and a iframe in this page which show the content. </p>
<p>Now there are some situation when the inner page is directly shown in the browser.
eg: if somebody types the inner page's url in the browser address bar, the page is displayed in the window. </p>
<p>I want to prev... | <p><b>window.parent</b>: The window object that contains the frame. If the the window is the top level window then window.parent refers the window itself. (It is never null.)</p>
<p><b>window.top</b>: The top level window object, even if the current window is the top level window object.</p>
<p><b>window.self</b>: ... | <pre><code><script language="Javascript"><!--
if (top.location == self.location) {
top.location = "index.html" // must be viewed in main index
}
//--></script>
</code></pre>
<p>modified it from a situation where an an iframe decides to become the main frame.</p>
| 43,170 |
<p>I'm implementing charts using <a href="http://www.ziya.liquidrail.com/" rel="nofollow noreferrer">The Ziya Charts Gem</a>. Unfortunately, the documentation isn't really helpful or I haven't had enough coffee to figure out theming. I know I can set a theme using</p>
<pre><code>chart.add(:theme, 'whatever')
</code></... | <p>As I understand it, the themes are used by initializing the theme directory in your ziya.rb file like so: </p>
<p><code>Ziya.initialize(:themes_dir => File.join( File.dirname(__FILE__), %w[.. .. public charts themes]) )
</code></p>
<p>And you'll need to set up the proper directory, in this case public/charts/t... | <p>To partly answer my own question, there are some themes in the website sources which can be checked out at </p>
<pre><code>svn co svn://rubyforge.org/var/svn/liquidrail/samples/charting
</code></pre>
<p>(then go to /public/charts/themes/)</p>
| 14,894 |
<p>Ok here's what I'm trying to do I want to write a class that inherits everything from the class ListItem</p>
<pre><code>class RealListItem : ListItem
{
public string anExtraStringINeed;
}
</code></pre>
<p>For some reason or another .net is treating all the members like they are private when I try to do this so... | <p>The System.Web.UI.Controls.ListItem class is "sealed"... That means you cannot inherit from it... </p>
| <p>As Charles states, ListItem is sealed which means you can't inherit from it. In the framework, some classes are marked as sealed and others are not. (The ones that aren't sealed you can inherit.)</p>
<p>You could create your own ListItem that contains a System.Web.UI.WebControls.ListItem, but I don't think this wi... | 39,018 |
<p>Sorry, I'm new to SVN and I looked around a little for this. How do you mark a major version in SVN, kind of like set up a restore point. Right now I just setup my server and added all my files- I've been intermittently committing different changes. When I have something in a stable state is there a way to mark this... | <p>Sounds like you're looking for tags.</p>
<p><a href="http://svnbook.red-bean.com/en/1.1/ch04s06.html" rel="nofollow noreferrer">Tags in the Subversion book</a></p>
<p>"A tag is just a “snapshot” of a project in time"</p>
| <p>try reading this page <a href="http://svnbook.red-bean.com/en/1.1/re07.html" rel="nofollow noreferrer">svn copy</a> . Basically you just need to do a svn copy</p>
| 12,770 |
<p>I need to test a site with a dynamic menu in Mac Firefox, but I'm running in Windows. A simple browsershot.com test won't help; I need to actually use the site.</p>
<p>How can I acquire a method of doing Mac emulation without physically having a Mac? Is there some kind of remote VM product out there?</p>
| <p>We use <a href="http://www.browsercam.com/" rel="noreferrer">BrowserCam</a> for exactly that.</p>
| <p>Check out the <a href="http://wiki.osx86project.org/wiki/index.php/Vmware_how_to" rel="nofollow noreferrer">OSx86 Project</a>. I've used this before, it works quite well and is pretty easy to understand.</p>
| 21,486 |
<p>I spend some time editing configurations in .htaccess files across several projects in Eclipse. How would I go about telling Eclipse to auto color this file in a similar fashion as shell scripts or HTML?</p>
| <p>I found using the "Properties File Editor" seems to give a decent color output. It's actually for Java files, so it comes with a stock Eclipse.</p>
<p>In Preferences, "General" -> "Content Types" -> "Text" -> "Java Properties File"
click "Add..." button, enter ".htaccess", click "OK".</p>
| <p>You could use the <a href="http://www.gstaff.org/colorEditor/" rel="nofollow noreferrer"><strong>ColorEditor</strong></a> from Gstaff, in order to define your <a href="http://www.codecommit.com/blog/eclipse/general-purpose-editor-within-eclipse" rel="nofollow noreferrer"><strong>own syntax coloring</strong></a>.</p>... | 47,539 |
<p>I have a table with multiple rows. Each row is a form. I want to use JQuery to submit all the forms that have the check box checked. The form is posting to an IFrame so there is not much need for AJAX.</p>
<p>So far I have:</p>
<pre><code> $("form").submit();
</code></pre>
<p>which submits the form. but all... | <p>Off the top of my head, you probably want something like this</p>
<pre><code>$("input:checked").parent("form").submit();
</code></pre>
<p>This will find the checked form fields, traverse up to find the parent form object and submit that.</p>
| <p>This is kinda a guess since I'm not sure of your layout, but here goes....</p>
<pre><code>$("td > input:checked > form").submit();
</code></pre>
| 28,536 |
<p>I want to continuously sample from my PC's audio line in using C# (then process that data). What is the best way to do the sampling?</p>
| <p>You can do some (basic) audio capture using the open source <a href="http://www.codeplex.com/naudio" rel="nofollow noreferrer">NAudio</a> .NET Audio Library. Have a look at the NAudioDemo project to see a simple example of recording to a WAV file using the WaveIn functions. NAudio also now includes the ability to ca... | <p>Managed DirectX supports direct capture of audio and is very easy to use, but is no longer supported and was removed from the DirectX SDK last year. It's still possible to <a href="http://www.microsoft.com/downloads/details.aspx?familyid=86cf7fa2-e953-475c-abde-f016e4f7b61a&displaylang=en" rel="nofollow noreferr... | 28,297 |
<p>I have html code that looks roughly like this:</p>
<pre><code><div id="id1">
<div id="id2">
<p>some html</p>
<span>maybe some more</span>
</div>
<div id="id3">
<p>different text here</p>
<input type="text">
<span>maybe... | <p>In this case, <code>document.getElementById('id1').appendChild(document.getElementById('id2'));</code> should do the trick.</p>
<p>More generally you can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore" rel="noreferrer"><code>insertBefore()</code></a>.</p>
| <p>You can use
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentElement" rel="nofollow noreferrer">insertAdjacentElement</a> instead of <code>appendChild</code> to have more control about the position of element with respect to a target element.</p>
<p>Syntax: <code>targetElement.insertAd... | 41,998 |
<p>Where can I find algorithms for image distortions? There are so much info of Blur and other classic algorithms but so little of more complex ones. In particular, I am interested in swirl effect image distortion algorithm.</p>
| <p>I can't find any references, but I can give a basic idea of how distortion effects work.</p>
<p>The key to the distortion is a function which takes two coordinates (x,y) in the distorted image, and transforms them to coordinates (u,v) in the original image. This specifies the inverse function of the distortion, sin... | <p>Take a look at <a href="http://www.imagemagick.org/script/index.php" rel="nofollow noreferrer">ImageMagick</a>. It's a image conversion and editing toolkit and has interfaces for all popular languages.</p>
<p>The -displace operator can create swirls with the correct displacement map.</p>
<p>If you are for some rea... | 27,878 |
<p>I've written this to try and log onto a forum (phpBB3).</p>
<pre><code>import urllib2, re
import urllib, re
logindata = urllib.urlencode({'username': 'x', 'password': 'y'})
page = urllib.urlopen("http://www.woarl.com/board/ucp.php?mode=login"[logindata])
output = page.read()
</code></pre>
<p>However when I run it ... | <p>Your line</p>
<pre><code>page = urllib.urlopen("http://www.woarl.com/board/ucp.php?mode=login"[logindata])
</code></pre>
<p>is semantically invalid Python. Presumably you meant</p>
<pre><code>page = urllib.urlopen("http://www.woarl.com/board/ucp.php?mode=login", [logindata])
</code></pre>
<p>which has a comma s... | <p>This would be easier with the high-level "mechanize" module.</p>
| 41,584 |
<p>I want to work with versioned ActiveRecord associations. <i>E.g.</i>, I want to find the object that another object belongs_to as of a certain past date, or the one that it belonged to before that. Does there already exist a library subclassing Rails' ActiveRecord to provide versioned relations? Or some other Ruby l... | <p>Try the <a href="http://ar-versioned.rubyforge.org/" rel="noreferrer">ActsAsVersioned</a> plugin</p>
| <p>Supporting historical state in a transactional application is a good way to massively expand complexity, slow DB performance and make life difficult for yourself. If you only need to display or report on historical state and do not need it up to the minute consider building a star schema with <a href="http://en.wik... | 33,856 |
<h2>Problem</h2>
<p>I have timestamped data, which I need to search based on the timestamp in order to get the one existing timestamp which matches my input timestamp the closest.<br>
Preferably this should be solved with the STL. boost::* or stl::tr1::* (from VS9 with Featurepack) are also possible.<br>
Example of ti... | <p>I would use set::lower_bound to find the matching or greater value, then decrement the iterator to check the next lower value. You should use std::set rather than std::map since your key is embedded in the object - you'll need to provide a functor that compares the timestamp members.</p>
<pre><code>struct Timestam... | <p>Depending on what your usage is, you could do a simple linear search instead of a sort. Come up with a "distance" function, loop through keeping track of the best match so far, and its distance. When you find a better match, forget the previous one, and keep the new one and its distance. When you've looped throug... | 26,879 |
<p>I'm trying to create a table with two columns comprising the primary key in MySQL, but I can't figure out the syntax. I understand single-column PKs, but the syntax isn't the same to create a primary key with two columns.</p>
| <pre><code>CREATE TABLE table_name
(
c1 INT NOT NULL,
c2 INT NOT NULL,
PRIMARY KEY (c1, c2)
)
</code></pre>
| <p>Example:</p>
<pre><code> CREATE TABLE `synthesis`.`INV_MasterItemList` (
`MasterItemList_ID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`Customer_ID` INTEGER UNSIGNED NOT NULL,
`Model_ID` INTEGER UNSIGNED NOT NULL,
`Serial` VARCHAR(45) NOT NULL,
PRIMARY KEY (`MasterItemList_ID`),
UNIQUE INDEX `INDE... | 20,236 |
<p>Joel Spolsky <a href="http://www.joelonsoftware.com/articles/PleaseLinker.html" rel="noreferrer">praised</a> native-code versions of programs that have no dependencies on runtimes. </p>
<p>What native-code compilers are available for functional languages?</p>
| <p>This post is really quite unclear. The question appears to be "Are there compilers for functional languages which can produce native executables without the need to install additional software?"</p>
<p>The answer, generally, is yes. For example, <a href="http://www.haskell.org/" rel="noreferrer">Haskell</a> has <... | <p><a href="http://plt-scheme.org/" rel="nofollow noreferrer">PLT Scheme</a> has got a JIT compiler.</p>
<p><a href="http://community.schemewiki.org/?Stalin" rel="nofollow noreferrer">Stalin</a> is a Scheme compiler which does ridiculously aggressive optimisation.</p>
<p>All Common Lisp implementations that I know of... | 13,031 |
<p>Is it realistic to try and learn and code a Flex 3 application without purchasing FlexBuilder? Since the SDK and BlazeDS are open source, it seems technically possible to develop without Flex Builder, but how realistic is it.</p>
<p>I would like to test out Flex but don't want to get into a situation where I am dep... | <p>I've been using Flex since version 2 and Flex3/BlazeDS since it came out of beta. I also have some experience with Lazzlo and the difference is day and night (Flex rocks!). I have not regretted once using Flex. Regarding FlexBuilder, it is worth every penny. While it is completely possible and reasonable to writ... | <p>Absolutely. I've been a Flex developer since Flex 2 and until recently I've used my regular editor, TextMate, for coding and Ant for building. TextMate has some good extensions for ActionScript and Flex coding, but I think you could get that for any decent editor.</p>
<p>What's been missing from my setup is a usabl... | 6,185 |
<p>I have several long running report type transactions that take 5-10 minutes. Would I see any performance increase by using stored procs? Would it be significant?</p>
<p>each query runs once a night.</p>
| <p>Probably not. Stored procs give you the advantage of pre-compiled SQL. If your SQL is invoked infrequently, they this advantage will be pretty worthless. So if you have SQL that is expensive because the queries themselves are expensive, then stored procs will gain you no meaningful performance advantage. If you ha... | <p>yes, the query plan for stored procs can be optimized
and even if it can't procs are preferred over embedded sql</p>
<p>"would you see any performance improvement" - the only way to know for certain is to try it</p>
<p>in theory, stored procedures pre-parse the sql and store the query plan instead of figuring out ... | 15,743 |
<p>Are there any 'standard' plugins for detecting the CPU architecture in <strong>scons</strong>? </p>
<p>BTW, this question was asked already <a href="https://stackoverflow.com/questions/152016/detecting-cpu-architecture-compile-time">here</a> in a more general form... just wondering if anyone has already taken the t... | <p>Using <strong>i386</strong> is rather compiler dependant, and won't detect non x86 32 bits archs. Assuming the python interpreter used by scons runs on the CPU you are interested in (not always the case - think cross compilation), you can just use python itself.</p>
<pre><code>import platform
print platform.machine... | <p>Something like this?</p>
<pre><code>env = Environment()
conf = Configure(env)
if conf.CheckDeclaration("__i386__"):
conf.Define("MY_ARCH", "blahblablah")
env = conf.Finish()
</code></pre>
| 30,470 |
<p>What I want to achieve is this. I want to give the user the ability to upload an image file, store the image in BLOB in SQL Server, and then use this image as a logo in other pages of the site. </p>
<p>I have done this by using </p>
<pre><code> Response.Clear();
Response.ContentType = "image/pjpeg";
Respo... | <p>Add a 'Generic Handler' to your web project, name it something like Image.ashx. Implement it like this:</p>
<pre><code>public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
using(Image image = GetImage(context.Request.QueryString["ID"]))
{
... | <p>We actually just released some classes that help with exactly this kind of thing:</p>
<p><a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449" rel="nofollow noreferrer">http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449</a></p>
<p>Specifically, check out the... | 4,191 |
<p>I am working with some input that is in the possible forms</p>
<pre><code>$1,200
20 cents/ inch
$10
</code></pre>
<p>Is there a way to parse these to numbers in VB? Also printing these numbers?</p>
<p><strong>EDIT:</strong> Regular expressions would be great.</p>
<p><strong>EDIT:</strong> VB 6 in particular</p>... | <p>Ehh...Assuming all that you want is the digits, I would use a Regular Expression to simply replace any non-digit with "".</p>
<p>You would need to reference Microsoft VBScript Regular Expressions in your project. Then let's say that your text was in a variable called strTest. Here is some off the cuff untested code... | <p>Sometimes it just takes brute force!</p>
<p>Here is a routine that takes in a string with numbers and returns a number properly handled with fractions, M or B suffixes, and more. You can modify i to handle any special condition or text algebra (miles / hour, cents / inch, etc)</p>
<p>This is taken from one of our... | 28,587 |
<p>The performance of a Direct3D application seems to be significantly better in full screen mode compared to windowed mode. What are the technical reasons behind this?</p>
<p>I guess it has something to do with the fact that a full screen application can gain exclusive control for the display. But why the application... | <p>Here are the cliff notes on how things work underneath. </p>
<p>Monitor screen always needs to be associated with so-called primary surface to be able to display anything, i.e. videocard can only scan out of one surface in video memory.</p>
<p>When application is fullscreen (and everything was set up correctly to ... | <p>Basically, the video hardware is completely dedicated to the exclusive mode application.</p>
<p>There is no contention for video resources (pipeline, texture memory, etc...)</p>
<p>In particular, texture upload can be a big bottleneck. The less you have to do it (because you have it all), the better.</p>
| 39,160 |
<p>I have an editable DataGridView with SelectionMode set to FullRowSelect (so the whole row is highlighted when the user clicks on any cell). However I would like the cell that currently has focus to be highlighted with a different back color (so the user can clearly see what cell they are about to edit). How can I do... | <p>I figured out a better way of doing this, using the CellFormatting event:</p>
<pre><code>Private Sub uxContacts_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles uxContacts.CellFormatting
If uxContacts.CurrentCell IsNot Nothing Then
If e.... | <p>You want to use the DataGridView RowPostPaint method. Let the framework draw the row, and afterwards go back and color in the cell you're interested in.</p>
<p>An example is here at <a href="http://msdn.microsoft.com/en-us/library/85kxk29c.aspx" rel="nofollow noreferrer">MSDN</a></p>
| 9,913 |
<p>We prototype a design, GUI, just to analyze a particular problem, proof of concept, etc. Sometimes we throw away the prototype, and sometimes it ends up in the production code. We use different languages, technologies, strategies, and styles to prototype.</p>
<p>What are the different situations you prototype usual... | <p>One hot title is <em><a href="https://rads.stackoverflow.com/amzn/click/com/0120885689" rel="noreferrer" rel="nofollow noreferrer">Effective Prototyping for Software Makers</a></em>. The issue is that there are several schools of thought.</p>
<ul>
<li><p>Rapid Prototyping. Use fancy tools; get
something done soon... | <p>I start off making a prototype that makes the most interesting part work, then I throw it away and move on to a new, more interesting project...</p>
<p>*kills self*</p>
| 13,295 |
<p>Ok, so I'm looking for a bit of architecture guidance, my team is getting a chance to re-cast certain decisions with a new feature that we're building, and I wanted to see what SO thought :-) There are of course certain things that we're not changing, so the solution would have to fit in this model. Namely, that we... | <pre><code>Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);
</code></pre>
| <p>Use the <a href="http://www.pinvoke.net/default.aspx/shell32/ExtractIconEx.html" rel="nofollow noreferrer">ExtractIconEx</a> (and <a href="http://msdn.microsoft.com/en-us/library/ms648069.aspx" rel="nofollow noreferrer">here</a>) p/invoke. You can extract small and large icons from any dll or exe. Shell32.dll itself... | 24,894 |
<p>Normally I program in C# but have been forced to do some work in C++. It seems that the integration with Visual Studio (2008) is really poor compared to C# but I was wondering if there are any good tools, plugins or configurations that can improve the situation.</p>
<p>Another post pointed out the program Visual As... | <p>I think there are two possibilities: 1) either you're trying out C++ stuff that is waaay over your knowledge (and consequently, you don't know what you did wrong and how to interpret error messages), 2) you have too high expectations.</p>
<p>A hint: many subsequent errors are caused by the first error. When I get ... | <p>My suggestions:</p>
<ul>
<li>If you want more features like you get in C#, get <a href="http://www.wholetomato.com/" rel="nofollow noreferrer">VisualAssist X</a>, and learn how to use it. It isn't free but it can save you a lot of time.</li>
<li>Set your <a href="http://msdn.microsoft.com/en-us/library/thxezb7y.as... | 19,745 |
<p>I'm looking for a good reader/writer lock in C++. We have a use case of a single infrequent writer and many frequent readers and would like to optimize for this. Preferable I would like a cross-platform solution, however a Windows only one would be acceptable. </p>
| <p>Newer versions of <a href="http://www.boost.org/doc/libs/1_50_0/doc/html/thread.html" rel="noreferrer">boost::thread</a> have read/write locks (1.35.0 and later, apparently the previous versions did not work correctly).</p>
<p>They have the names <a href="http://www.boost.org/doc/libs/1_50_0/doc/html/thread/synchro... | <p>You could copy Sun's excellent <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html" rel="nofollow noreferrer">ReentrantReadWriteLock</a>. It includes features such as optional fairness, lock downgrading, and of course reentrancy.</p>
<p>Yes it's in Java, but you ... | 30,293 |
<p>Excuting the line of SQL:</p>
<pre><code>SELECT *
INTO assignment_20081120
FROM assignment ;
</code></pre>
<p>against a database in oracle to back up a table called assignment gives me the following ORACLE error:
ORA-00905: Missing keyword</p>
| <p>Unless there is a single row in the <code>ASSIGNMENT</code> table and <code>ASSIGNMENT_20081120</code> is a local PL/SQL variable of type <code>ASSIGNMENT%ROWTYPE</code>, this is not what you want.</p>
<p>Assuming you are trying to create a new table and copy the existing data to that new table</p>
<pre><code>CREA... | <p>Late answer, but I just came on this list today!</p>
<pre class="lang-sql prettyprint-override"><code>CREATE TABLE assignment_20101120 AS SELECT * FROM assignment;
</code></pre>
<p>Does the same.</p>
| 39,309 |
<p>i'm interested in project management software similar to MS Project. the project is a serious rebuild of my software. we have a bug management system already but i need to track project progress.</p>
<p>i don't like web-based apps so much because the data is either hosted off-site or i need to set up my own serve... | <p>Please give <a href="https://sourceforge.net/projects/openworkbench/" rel="nofollow noreferrer">open workbench</a> a try.</p>
| <p>I used primavera some time back, and I think it can do the said comparison.</p>
| 14,212 |
<p>I have a lot of constants that are somehow related, at some point I need to pair them, something like this:</p>
<pre><code>const
key1 = '1';
key2 = '2';
key3 = '3';
value1 = 'a';
value2 = 'b';
value3 = 'c';
</code></pre>
<p>I want to avoid doing:</p>
<pre><code>if MyValue = key1 then Result := value1... | <p>Yes, assignment can be done this way instead, avoiding manual string concatenation:</p>
<pre><code>MyStringList.Values[Key1] := Value1;
</code></pre>
| <p>You can use a multi-dimensional constant array with an enumeration for at least one of the dimensions:</p>
<p>Define it like this:</p>
<pre><code>type
TKVEnum = (tKey, tValue); // You could give this a better name
const
Count = 3;
KeyValues: array [1..Count, TKVEnum] of string =
// This is each of your n... | 30,798 |
<p>I find I can do more with NHibernate, and even Castle than with the Linq to Entities, or linq to SQL.</p>
<p>Am I crazy?</p>
| <p>No you're not crazy. nHibernate is a full OR Mapper, Linq to SQL and Linq to Entities don't implement everything you'd expect from an OR mapper and targeted at a slightly different group of developers.</p>
<p>But don't let that put you off linq though. Linq is still a pretty good idea.. Try Linq to nHibernate :-)</... | <p>I have not tried the Entity Framework, but I definitely would recommend NHibernate over Linq to SQL; The biggest reason I can give is just the control. Linq to SQL likes to have a lot more control over everything, loading the object and maintaining all kinds of tracking information about the object. If you seriali... | 9,750 |
<p>What is the best way to version control my database objects? I'm using Visual studio 2005/2008 and SQL server 2005. I would prefer a solution which can be used with SVN.</p>
| <p>Same as your other code, add a "Database project" to your application solution and keep the sql files used to build the database objects in there. Use the same version control for those code files as you do for the application.</p>
| <p>We do dumps to plaintext and keep them in our VCS.</p>
<p>You'd be able to script a backup-and-commit to do something similar.</p>
| 17,646 |
<p>Multiple approaches exist to write your unit tests when using Rhino Mocks:</p>
<ul>
<li>The Standard Syntax</li>
<li>Record/Replay Syntax</li>
<li>The Fluent Syntax</li>
</ul>
<p>What is the ideal and most frictionless way?</p>
| <p>For .NET 2.0, I recommend the record/playback model. We like this because it separates clearly your expectations from your verifications.</p>
<pre><code>using(mocks.Record())
{
Expect.Call(foo.Bar());
}
using(mocks.Playback())
{
MakeItAllHappen();
}
</code></pre>
<p>If you're using .NET 3.5 and C# 3, then ... | <p>Interesting question! My own preference is the for the reflection-based syntax (what I guess you mean by the Standard Syntax). I would argue that this is the most frictionless, as it does not add much extra code: you reference the stubs directly on your interfaces as though they were properly implemented. </p>
<... | 7,831 |
<p>I have a mature MFC C++ application that displays on screen and prints using CDC wrappings on the Win32 GDI. While it has been optimized over the years, I would like to replace it with something a bit faster. The graphics included rendered triangular surface models, complex polylines and polygons, and lots of text... | <p>I think DirectX or <a href="http://libsdl.org/" rel="nofollow noreferrer">SDL</a> will suit your needs. They are designed for 3D but work for 2D as well. Both support Windows CE / Mobile and SDL is also available for a bunch of non-Microsoft OS.</p>
<p>Unfortunately direct compatibility with GDI is not supported in... | <p>I think DirectX or <a href="http://libsdl.org/" rel="nofollow noreferrer">SDL</a> will suit your needs. They are designed for 3D but work for 2D as well. Both support Windows CE / Mobile and SDL is also available for a bunch of non-Microsoft OS.</p>
<p>Unfortunately direct compatibility with GDI is not supported in... | 24,938 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.