instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
My SQL is a bit rusty -- is there a SQL way to project an input table that looks something like this: Name SlotValue Slots ---- --------- ----- ABC 3 1 ABC 4 2 ABC 6 ...
stackexchange/codereview
I'd like to have an HTML page which displays a single PNG or JPEG image. I want the image to take up the whole screen but when I do this: <img src="whatever.jpeg" width="100%" height="100%" /> It just stretches the image and messes up the aspect ratio. How do I solve this so the image has the correct aspect ratio whil...
stackexchange/codereview
When creating a new object that is mapped to one of my SQL Server tables, LINQ inserts a new record into the table when I call SubmitChanges. I want to prevent this, but still need my new object. I know about the custom methods, but is there anyway to disable this behaviour so that it just updates existing records and...
stackexchange/codereview
I have a problem with a memory leak in a .NET CF application. Using RPM I identified that dynamically creating controls are not garbage collected as expected. Running the same piece of code in .NET Window Forms behave differently and disposes the control as I expected. See the output from RPM via PerfMon for the Pro...
stackexchange/codereview
Is it possible to get the route/virtual url associated with a controller action or on a view? I saw that Preview 4 added LinkBuilder.BuildUrlFromExpression helper, but it's not very useful if you want to use it on the master, since the controller type can be different. Any thoughts are appreciated.
stackexchange/codereview
I want to use remote debugging. The program that I want to debug runs on machine b. Visual Studio runs on machine a. On machine b I have a folder with the following files: msvcr72.dll msvsmon.exe NatDbgDE.dll NatDbgDEUI.dll NatDbgEE.dll NatDbgEEUI.dll If you think some files are missing, could you also describe wher...
stackexchange/codereview
In PHP 5, what is the difference between using self and $this? When is each appropriate?
stackexchange/codereview
How can we produce the effect of the red line under a bad spelling word like the image below : alt text http://img505.imageshack.us/img505/7253/options285x395rg9.th.png Update I do not want to use Google or whatever spell program. I would like to know how to create the effect of the red line.
stackexchange/codereview
I'm using HttpWebRequest to pull down XML, and POST data back to a 'WebService' and getting a 401 on the POST. When creating the requests I've added Credentials and now tried a credentials cache and setting PreAutenticate to True, still getting the 401! :( Watching the HTTP traffic on the router I set the get make an ...
stackexchange/codereview
Seems like the subtraction is triggering some kind of issue and the resulting value is wrong. double tempCommission = targetPremium.doubleValue()*rate.doubleValue()/100d; 78.75 = 787.5 * 10.0/100d double netToCompany = targetPremium.doubleValue() - tempCommission; 708.75 = 787.5 - 78.75 double dCommission = request.g...
stackexchange/codereview
I'm venturing into web programming for the first time and would like a nice way to display a frequency indicator of some data, in the form of a tag cloud. For example, pretend I have some simple data of three types of pets: Dog, Cat, Monkey. There are 5 Dogs, 27 Cats and 101 Monkeys. Given this data, what's the best w...
stackexchange/codereview
I'd like to be able to switch the sound output source in Mac OS X without any GUI interaction. There are tools to do control the sound output, such as SoundSource and an applescript to open the preferences dialog. What I am looking for is something that switches the preference instantly, like SoundSource but it has to ...
stackexchange/codereview
Converting my current code project to TDD, I've noticed something. class Foo { public event EventHandler Test; public void SomeFunction() { //snip... Test(this, new EventArgs()); } } There are two dangers I can see when testing this code and relying on a code coverage tool to determine if ...
stackexchange/codereview
I'm trying to install the .Net framework version 2.0 on embedded Windows XP SP2 (aka XPE). I'm using the XPE specific version of the installer from Microsoft: http://www.microsoft.com/downloads/details.aspx?familyid=c4837dad-5719-4b63-8752-cb0a65802329&displaylang=en When the installation starts it fails with the follo...
stackexchange/codereview
I am building a menu and have it set up so that I use a standard <!--#include virtual = "myDoc.xml" --> SSI tag to include my xml document. The xml document includes the xsl document with <?xml-stylesheet type="text/xsl" href="myOtherDoc.xsl"?>. For some reason the xsl document is not working. The xml is being displ...
stackexchange/codereview
I'm looking for a way to match only fully composed characters in a Unicode string. Is [:print:] dependent upon locale in any regular expression implementation that incorporates this character class? For example, will it match Japanese character 'あ', since it is not a control character, or is [:print:] always going to b...
stackexchange/codereview
When you're using Tiles with Struts and do... request.getRequestURL() ...you get the URL to e.g. /WEB-INF/jsp/layout/newLayout.jsp instead of the real URL that was entered/clicked by the user, something like /context/action.do. In newer Struts versions, 1.3.x and after, you can use the solution mentioned on javaranch ...
stackexchange/codereview
i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to "really exists" in /proc (which defeats my debugging strategies) I would like...
stackexchange/codereview
I'm writing some JNI code in C++ to be called from an applet on Windows XP. I've been able to successfully run the applet and have the JNI library loaded and called, even going so far as having it call functions in other DLLs. I got this working by setting up the PATH system environment variable to include the direct...
stackexchange/codereview
Large datasets, millions of records, need special programming to maintain speed in DBGrids. I want to know if there are any ready-made components for Delphi (DBGrids) that do this automatically? EDIT For Example: Some databases have features such as fetch 1st X records (eg 100 records). When I reach the bottom with sc...
stackexchange/codereview
When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently working on a project that requires a lot of refactoring an ex-employees code. I want to write a custom attribute that I can use to mark methods o...
stackexchange/codereview
Without running this code, identify which Foo method will be called: class A { public void Foo( int n ) { Console.WriteLine( "A::Foo" ); } } class B : A { /* note that A::Foo and B::Foo are not related at all */ public void Foo( double n ) { Console.WriteLine( "B::Foo" ); } } static v...
stackexchange/codereview
I have some local changes to an open source project which uses Subversion as its source control. (I do not have commit access on the original project repository.) My change adds a file, but this file is not included in the output of "svn diff". (It may be worth noting that the new file is a binary, not plain text.) H...
stackexchange/codereview
I am running NUnit with the project named AssemblyTest.nunit. The test calls another assembly which uses the log4net assembly. This is using nunit version 2.4.3 with the .net 2.0 framework. In TestFixtureSetup I am calling log4net.Config.XmlConfigurator.Configure( ) and am getting the following error: System.Configura...
stackexchange/codereview
I have a c++ header file containing a class. I want to use this class in several projects, bu I don't want to create a separate library for it, so I'm putting both methods declarations and definitions in the header file: // example.h #ifndef EXAMPLE_H_ #define EXAMPLE_H_ namespace test_ns{ class TestClass{ public: ...
stackexchange/codereview
Recently I converted a Swing application to Webstart. The process was pretty straightforward, but I found that after I close all windows, my application's JVM did not terminate. The thread dump showed that there are a couple of non-daemon threads, notably Swing's EDT, AWT and a couple of websart related threads. The a...
stackexchange/codereview
I want to store a a c# DateTimeOffset value in a SQL Server 2005 database. Sql 2008 has this as a built-in-type, but SQL Server 2005 does not. The DateTimeOffset structure has a DateTime value which I store as DateTime, an an Offset property (of type TimeSpan). Since this is the time zone relative to UTC, presumably it...
stackexchange/codereview
Is there a mode, some switch or a programmatic way that I can ask MSBuild to display or output it's calculated dependencies for a given build file? Some background - I have a large project that requires splitting up to speed up the build time and want to remove the slow changing infrastructure code into it's own relea...
stackexchange/codereview
I would like to execute a stored procedure within a stored procedure, e.g. EXEC SP1 BEGIN EXEC SP2 END But I only want SP1 to finish after SP2 has finished running so I need to find a way for SP1 to wait for SP2 to finish before SP1 ends. SP2 is being executed as part of SP1 so I have something like: CREATE PROCEDU...
stackexchange/codereview
I'm trying to handle this possible exploit and wondering what is the best way to do it? should i use apache's common-validator and create a list of known allowed symbols and use that?
stackexchange/codereview
I've inherited a flash project (my first) that has many existing symbols in the library. They are organized in a large complex hierarchy of folders. Often, I find a reference to a symbol in actionscript code, but can't find the symbol in the library. The "Find" feature only searches for instances of a symbol. If none e...
stackexchange/codereview
Is there a keyboard shortcut in Access 2003 that will run a query while in design or sql mode?
stackexchange/codereview
I am starting a new job on Monday. The company has a home grown enterprise case management application written in ASP.NET/VB.NET. They are attempting to implement an Agile development process. They have gone so far as to get two people Scrum Master certified and hire an Agile coach. They are currently focused on 6-9 mo...
stackexchange/codereview
Is there a difference (performance, overhead) between these two ways of merging data sets? MyTypedDataSet aDataSet = new MyTypedDataSet(); aDataSet .Merge(anotherDataSet); aDataSet .Merge(yetAnotherDataSet); and MyTypedDataSet aDataSet = anotherDataSet; aDataSet .Merge(yetAnotherDataSet); Which do you recommend?
stackexchange/codereview
I checked out a project from SVN and did not specify the project type, so it checked out as a "default" project. What is the easiest way to quickly convert this into a "Java" project? I'm using Eclipse version 3.3.2.
stackexchange/codereview
I'm modifying a mature CGI application written in Perl and the question of content encoding has come up. The browser reports that the content is iso-8859-1 encoded and the application is declaring iso-8859-1 as the charset in the HTTP headers but doesn't ever seem to actually do the encoding. None of the various enco...
stackexchange/codereview
I am seeking a backup tool to back-up virtual OS instances run through Microsoft Virtual Server 2005 R2. According to the MS docs, it should be possible to do it live through volume shadow copy service, but I am having trouble finding any tool for any. What are the best solution to back-up MS Virtual Server instances?
stackexchange/codereview
I want to use implicit linking in my project , and nmake really wants a .def file . The problem is , that this is a class , and I don't know what to write in the exports section . Could anyone point me in the right direction ? The error message is the following : NMAKE : U1073: don't know how to make 'DLLCLASS.def' P....
stackexchange/codereview
Are there any "all-in-one" installers for php + mysql on iis? Preferably with a gui configuration interface.
stackexchange/codereview
I've got a "Schroedinger's Cat" type of problem here -- my program (actually the test suite for my program, but a program nonetheless) is crashing, but only when built in release mode, and only when launched from the command line. Through caveman debugging (ie, nasty printf() messages all over the place), I have deter...
stackexchange/codereview
I am a bit confused about the uses of these words. I have a table with he following columns: SITE, LAT, LONG, NAME, ...... I want results with unique (or is it distinct) LAT, LONG. How do I achieve this?
stackexchange/codereview
Is there a recommended way to upgrade Quartz in JBoss 4.2.x? JBoss bundles quartz 1.5.2, but I have encountered issues (QUARTZ-399, QUARTZ-520) that I want to avoid. I would not want to patch quartz.jar in JBoss just to resolve the errors, but instead provide a new quartz.jar (plus associated configuration artifacts). ...
stackexchange/codereview
I am working on a project that is built on an extended version of the default PDO and PDOStatement classes and as such it uses PDO style named parameters instead of the "?" placeholder for variables. However, the client is now requesting that we look into using a different driver because their version OS X Web Server ...
stackexchange/codereview
I'm specifying my doctype as xhtml strict, but it's being sent over the wire as a content type of text/html. I'd like to specify that the content type is application/xhtml+xm, but I can't figure out where, or if, I can configure this from within my application
stackexchange/codereview
Does anyone have C# code handy for doing a ping and traceroute to a target computer? I am looking for a pure code solution, not what I'm doing now, which is invoking the ping.exe and tracert.exe program and parsing the output. I would like something more robust.
stackexchange/codereview
Now that everyone is talking about MVC, I notice that the business rules are not being addressed. In the old days of the 3-tier architecture, The business rules were in the middle layer. Where do they fall in the new MVC?
stackexchange/codereview
I have a C# method which accepts a Predicate<Foo> and returns a list of matching items... public static List<Foo> FindAll( Predicate<Foo> filter ) { ... } The filter will often be one of a common set... public static class FooPredicates { public static readonly Predicate<Foo> IsEligible = ( foo => ...) ......
stackexchange/codereview
I would like to break a long line of text assigned to the standard Label widget in GWT. I was experimenting with inline <br /> elements but with no success. Something like this: label = "My very very very long<br />long long text"
stackexchange/codereview
If you were a programming teacher and you had to choose one sorting algorithm to teach your students which one would it be? I am asking for only one because I just want to introduce the concept of sorting. Should it be the bubble sort or the selection sort? I have noticed that these two are taught most often. Is there ...
stackexchange/codereview
I'm using the ListView control (ASP.NET 2008) to show a bunch of lines of data, and at the bottom I want some totals. I was initially going to define the header and footer in the LayoutTemplate and get the totals with some local function, i.e. <%#GetTheSum()%>, but it appears that the LayoutTemplate does not process th...
stackexchange/codereview
In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribute?
stackexchange/codereview
I'm doing a little app that I want to distribute in different platforms, at least the 3 major ones. Is it possible to use only Windows has the host OS to compile the binaries for Linux, Mac OS X and other supported platforms without resorting to virtual machines? Or should I ask around in some community to help me comp...
stackexchange/codereview
I'm having trouble wrapping my head around this. Right now I have some models that looks kind of like this: def Review(models.Model) ...fields... overall_score = models.FloatField(blank=True) def Score(models.Model) review = models.ForeignKey(Review) question = models.TextField() grade = models.I...
stackexchange/codereview
Has someone ever measured performance of Sequential Guid vs. Standard Guid when used as Primary Keys inside a database? I do not see the need for unique keys to be guessable or not, passing them from a web UI or in some other part seems a bad practice by itself and I do not see, if you have security concerns, how usin...
stackexchange/codereview
my java application has a loading task which requires two server calls which can be parallelized. So I launch a Thread t1 (doing task1) and a Thread t2 (for task2). I want then to do a specific task, task3 when both other tasks (1 & 2) are over. Naturally I can't tell which of task1 and task2 will finish first... Which...
stackexchange/codereview
Apparently ;-) the standard containers provide some form of guarantees. What type of guarantees and what exactly are the differences between the different types of container? Working from the SGI page (about STL) I have come up with this: Container Types: ================ Container: Forward Container Revers...
stackexchange/codereview
Short of cutting and pasting, is there a way to sort the methods in my classes in Visual Studio 2008? I like orderly code.
stackexchange/codereview
I'm working on a control to tie together the view from one ListView to another so that when the master ListView is scrolled, the child ListView view is updated to match. So far I've been able to get the child ListViews to update their view when the master scrollbar buttons are clicked. The problem is that when click...
stackexchange/codereview
I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: School, Course, and Student, which are defined as follows: class School { List<Course> Courses; List<Student...
stackexchange/codereview
What I would like is be able to generate a simple report that is the output of svn log for a certain date range. Specifically, all the changes since 'yesterday'. Is there an easy way to accomplish this in Subversion besides grep-ing the svn log output for the timestamp? Example: svn -v log -d 2008-9-23:2008-9:24 > r...
stackexchange/codereview
The following SQL SELECT * FROM customers converted to this in LINQ var customers = from c in customers select c; Is their any good reasones why the from and select is swaped? The only logical reason I can think of is for intellisens? For the intellesens to get resolved, it needs to know what it is ...
stackexchange/codereview
I'm sure there's some trivial one-liner with perl, ruby, bash whatever that would let me run a command in a loop until I observe some string in stdout, then stop. Ideally, I'd like to capture stdout as well, but if it's going to console, that might be enough. The particular environment in question at the moment is R...
stackexchange/codereview
I have a user reporting that when they use the back button to return to a web page that they come back as a different person. It seems like they may be accessing a different users profile. Here are the important parts of the code: //here's the code on the web page public static WebProfile p = null; protected void Pag...
stackexchange/codereview
I need to stream a file to the Response for saving on the end user's machine. The file is plain text, so what content type can I use to prevent the text being displayed in the browser?
stackexchange/codereview
The following works in Firefox, but breaks in IE7 & 8: $("#my-first-div, #my-second-div").hide(); so I have to do this: $("#my-first-div").hide(); $("#my-second-div").hide(); Is this normal? EDIT: ok, my actual real-life code is this: $("#charges-gsm,#charges-gsm-faq,#charges-gsm-prices").html(html); and my error i...
stackexchange/codereview
Are there any performance benefits of using SQL Server 2008 over SQL Server 2005?
stackexchange/codereview
How can I make my window not have a title bar but appear in the task bar with some descriptive text? If you set the Form's .Text property then .net gives it a title bar, which I don't want. this.ControlBox = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Max...
stackexchange/codereview
I have a bunch of regression test data. Each test is just a list of messages (associative arrays), mapping message field names to values. There's a lot of repetition within this data. For example test1 = [ { sender => 'client', msg => '123', arg => '900', foo => 'bar', ... }, { sender => 'server', m...
stackexchange/codereview
Basically my problem stems from a desire to have the textbox portion be white, and the drop down to be black. When I set the text to white, the drop down appears as I want it, but the text in the textbox itself is hardly readable. Setting the Foreground to black makes the drop down unreadable. Is there a good way to ha...
stackexchange/codereview
How do you know if the HTTP compression setup is working? Is there any tool I can use to see the compressed page before it is uncompressed by the browser? Are there any tools to measure the amount compressed and response speed?
stackexchange/codereview
What Javascript libraries can you recommend for syntax highlighting <code> blocks in HTML? (One suggestion per answer please).
stackexchange/codereview
I personally like the exclusive or, ^, operator when it makes sense in the context of boolean checks because of its conciseness. I much prefer to write if (boolean1 ^ boolean2) { //do it } than if((boolean1 && !boolean2) || (boolean2 && !boolean1)) { //do it } but I often get confused looks from other experience...
stackexchange/codereview
Lets say I have a class that stores user information complete with getters and setters, and it is populated with data from an XML file. How would I iterate over all of the instances of that class like you would do with java beans and tag libraries?
stackexchange/codereview
I'm looking to compute the Moore-Penrose pseudo-inverse of a matrix in C++, can someone point me to a library implementation or a numerical recipe? Thanks!
stackexchange/codereview
I use Safari Books Online as a reference library and to evaluate book before I decide to buy a paper copy, but it doesn't include any Apress books. Is there a better alternative you would recommend? Edit: Safari Books Online now includes Apress titles which makes it the most complete reference library on the web in my ...
stackexchange/codereview
on KDE, there's a possibility to execute a command when some event happen. for example one can execute a script when kmail receives a mail or when a akregator fetches a new feed. I want to execute the script on a way I can retrieve the mail/feed subject in my script. is there a possibility to specify the program to exe...
stackexchange/codereview
Can VBA code instantiate and use .NET objects? The specific class I'm interested in is System.IO.Compression.GZipStream. For Info GAC is the .NET Global Assembly Cache
stackexchange/codereview
I'm asking all of you who aren't using a library for this, but are constructing your own objects for managing data flowing to and from your database tables. Do I have a recordset object? one object per row of data? Both? Neither? Any suggestions or experiences welcome. Please don't tell me to use an ORM or other suc...
stackexchange/codereview
In short, how do you unit test an error condition such as EINTR on a system call. One particular example I'm working on, which could be a case all by itself, is whether it's necessary to call fclose again when it returns EOF with (errno==EINTR). The behavior depends on the implementation of fclose: // Given an open FIL...
stackexchange/codereview
What is meant by nvarchar? What is the difference between char, nchar, varchar, and nvarchar in SQL Server?
stackexchange/codereview
I'm using libcurl in a Win32 C++ application. I have the curllib.vcproj project added to my solution and set my other projects to depend on it. How do I build it with SSL support enabled?
stackexchange/codereview
Basically, what I need is something like Dependecy Walker, but it should work with .NET applications. Is there anywhere such tool?
stackexchange/codereview
I haven't written any code yet, but I've encountered a similar problem before. Hopefully things have changed since the last time I visited it. I'm trying to do my own image conversion for games into a special OpenGL image format. In order to perform the conversion correctly, I need all pixel data and more importantly, ...
stackexchange/codereview
What are all the C++ blogs that you follow? Please add one url for one posting.
stackexchange/codereview
I have an index.php file which has to process many different file types. How do I guess the filetype based on the REQUEST_URI? If I request http://site/image.jpg, and all requests redirect through index.php, which looks like this <?php include('/www/site'.$_SERVER['REQUEST_URI']); ?> How would I make that work corr...
stackexchange/codereview
This is really the first thing that I have written in python. I come from Java background. I don't want to just learn how to program java code with Python syntax. I want to learn how to program in a pythonic paradigm. Could you guys please comment on how I can make the following code more pythonic? from math import ...
stackexchange/codereview
From within FlexBuilder3, I can go to "Data/Manage Web Services..." select a web service, and click "Update" to ensure that my code and the server are in sync. How do I automate this so that each time I build, the automatically generated web service code is regenerated? If the server interface changes during developmen...
stackexchange/codereview
I have a cluster of three mongrels running under nginx, and I deploy the app using Capistrano 2.4.3. When I "cap deploy" when there is a running system, the behavior is: The app is deployed. The code is successfully updated. In the cap deploy output, there is this: executing "sudo -p 'sudo password: ' mongrel_rail...
stackexchange/codereview
Have a look at this very simple example WPF program: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <GroupBox> <GroupBox.Header> ...
stackexchange/codereview
Our team would like to move from the Visual SourceSafe (VSS) to the Team Foundation Server (TFS). I know that the TFS is much more than just a version control system, but for the first time I would like to use it this way. Currently our projects are organized within the single solution that consists of the shared part ...
stackexchange/codereview
I have done a custom implementation of MembershipProvider but for some reason the initialize method is not being invoked and thus my provider is not setting up properly from the config parameters, who invokes it in the first place and how do i get it to work.
stackexchange/codereview
We have an application where people can type in multiple langugaes. Though we only have one database to store all the data. We have text columns as nvarchar ( assuming we only want text data to be in multiple languages and not all dates etc.) Do you think this is a feasbile solution and are there any other points to co...
stackexchange/codereview
Has anyone used Mono, the open source .NET implementation on a large or medium sized project? I'm wondering if it's ready for real world, production environments. Is it stable, fast, compatible, ... enough to use? Does it take a lot of effort to port projects to the Mono runtime, or is it really, really compatible enou...
stackexchange/codereview
This is the way I read file: public static string readFile(string path) { StringBuilder stringFromFile = new StringBuilder(); StreamReader SR; string S; SR = File.OpenText(path); S = SR.ReadLine(); while (S != null) { stringFromFile.Append(SR.R...
stackexchange/codereview
I find that most of microsoft's new programs are very hard to use. Microsoft Office 2007 (word especially) I find to be hard to use. Microsoft IIS 7.0 is a PAIN, I never remember which icon to click on, things are just to cluttered and hard to find. As a programmer, we have to design according to what people are used t...
stackexchange/codereview
As a test engineer, I often engage in exploratory testing. When I encounter a bug, it is not always immediately clear which steps led to the problem. So, obviously, I have to find the required steps to reproduce the problem. Depending on the situation, this can take a large amount of time. What would be really helpful ...
stackexchange/codereview
Is it possible to convert an existing WPF Application to SilverLight automatically/with minimal effort?
stackexchange/codereview
From Apache, you can use the "mod_jk" module to send HTTP requests to Tomcat using the "AJP" protocol, which is far more efficient that HTTP itself. I want to do the same, but from a Java program. I want to use "AJP" because of its good performances (and Tomcat is not bad after all). Does someone know about a Java impl...
stackexchange/codereview
I need to scan uploaded files for viruses on a Linux server, but I'm not sure how to go about it. What are my options, if any? I'm also interested in how the scanners perform when multiple users send multiple files at the same time.
stackexchange/codereview
What is currying? How can currying be done in C++? Please Explain binders in STL container?
stackexchange/codereview