instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
What's the difference between file and open in Python? When should I use which one? (Say I'm in 2.5)
stackexchange/codereview
I have a dictionary of 200,000 items (the keys are strings and the values are integers). What is the best/most pythonic way to print the items sorted by descending value then ascending key (i.e. a 2 key sort)? a={ 'keyC':1, 'keyB':2, 'keyA':1 } b = a.items() b.sort( key=lambda a:a[0]) b.sort( key=lambda a:a[1], revers...
stackexchange/codereview
I'm having an unusual problem with an IE document with contentEditable set to true. Calling select() on a range that is positioned at the end of a text node that immediately precedes a block element causes the selection to be shifted to the right one character and appear where it shouldn't. I've submitted a bug to Mi...
stackexchange/codereview
My team has been using SVN for a few years. We now have the option of switching to Perforce. What would be the benefits (and pitfalls) of making such a switch?
stackexchange/codereview
I have created a Web Application in asp.net 2.0. which is working fine on my Local machine. However when trying to deploy it on sever that has windows 2003 sever, I get the error: Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this requ...
stackexchange/codereview
I want to index this view but because it has subquery i cant index. Can anyone suggest how to change this view so that i can index it. ALTER VIEW [dbo].[Recon2] WITH SCHEMABINDING AS SELECT dbo.Transactions.CustomerCode, dbo.Customer_Master.CustomerName, dbo.Transactions.TransDate, dbo.Transactions.PubCode, db...
stackexchange/codereview
I was wondering if there is a clean way to represent an is-a relationship as illustrated by this example: This DB stores recording times for three types of programs: movies, game shows, drama. In an object oriented sense each of these is-a program. Each of these subclasses have different properties. Here are the tables...
stackexchange/codereview
In .NET (VB), how can I take all of the items in one collection, and add them to a second collection (without losing pre-existing items in the second collection)? I'm looking for something a little more efficient than this: For Each item As Host In hostCollection1 hostCollection2.Add(item) Next My collections are ...
stackexchange/codereview
I have a self built JSP webapp and at the moment I'm using tomcats built in admin pannel to manage user accounts (that are stored in tomcats config xml files) but this is limited because i can not create new accounts from within the web-app (eg. I can not have a sign up website) and need to manually create the accounts...
stackexchange/codereview
I assist in maintaining an enterprise web-based system (programmed in J2EE, but this is a more general question) and I'd like to know: what good tools are out there to measure the "health" of an enterprise system? For instance, tools to check memory space on servers, check the status of batch runs, the number of recor...
stackexchange/codereview
OpenID is all good... UNTIL the provider goes down. At that point you're potentially locked out of EVERYTHING (since you jumped on the bandwagon and applied OpenID everywhere you could). This question came up because I can't, for the life of me, login with my myopenid.com provider. :-(
stackexchange/codereview
I am putting together a proposal for a large multinational company for our licenced solution. Problem is I've never put together something this big before and so I don't know what is acceptable. Ignoring hosting or support (or even the functionality of the app) for the moment and just concentrating the licence - do yo...
stackexchange/codereview
My application is preparing a cover-sheet for submitting documents by fax. I identify the batch by printing a Code39 on it. The incoming faxes are received as tif files and my small c# service is polling for new faxes and calling a decoding function. Currently I use a Win32 dll to recognize the barcode (QSbar39) and ...
stackexchange/codereview
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access) that needs to work as follows: Upload file Record and save info regarding file to database Import data from file into database Redirect to different page When run sequentially like this, everything works fine. However, since the files being...
stackexchange/codereview
I'm trying to create a Zip file from .Net that can be read from Java code. I've used SharpZipLib to create the Zip file but also if the file generated is valid according to the CheckZip function of the #ZipLib library and can be successfully uncompressed via WinZip or WinRar I always get an error when trying to uncompr...
stackexchange/codereview
My Ubuntu server has Apache and Subversion installed. I use this server as a staging server, purely for testing purposes. I use Apache to host the web application, and Subversion to keep versioned copies of the source code. My current workflow: Make changes to a file Commit the file to the Subversion repository Upload...
stackexchange/codereview
Is there a NAnt task that will echo out all property names and values that are currently set during a build? Something equivalent to the Ant echoproperties task maybe?
stackexchange/codereview
I have a products table... alt text http://img357.imageshack.us/img357/6393/productscx5.gif and a revisions table, which is supposed to track changes to product info alt text http://img124.imageshack.us/img124/1139/revisionslz5.gif I try to query the database for all products, with their most recent revision... select ...
stackexchange/codereview
Is it possible to modify a registry value (whether string or DWORD) via a .bat/.cmd script?
stackexchange/codereview
Assuming I have only the class name of a generic as a string in the form of "MyCustomGenericCollection(of MyCustomObjectClass)" and don't know the assembly it comes from, what is the easiest way to create an instance of that object? If it helps, I know that the class implements IMyCustomInterface and is from an assemb...
stackexchange/codereview
I just wrote my first web service so lets make the assumption that my web service knowlege is non existant. I want to try to call a dbClass function from the web service. However I need some params that are in the session. Is there any way I can get these call these session variables from the webservice??
stackexchange/codereview
The VS Database Project does not seem to have the "Show All Files" option in the Solution Explorer. Does anyone know of a way to turn the option on in VS? The "Show All Files" option on the solution explorer actually does two things. With the option selected, VS shows "hidden/nested" files within the project AND it s...
stackexchange/codereview
I'm running PHP, Apache, and Windows. I do not have a domain setup, so I would like my website's forms-based authentication to use the local user accounts database built in to Windows (I think it's called SAM). I know that if Active Directory is setup, you can use the PHP LDAP module to connect and authenticate in you...
stackexchange/codereview
I know this is a dumb question. For some reason my mind is blank on this. Any ideas? Sorry should have been more clear. Using a HtmlGenericControl to pull in link description as well as image. private void InternalCreateChildControls() { if (this.DataItem != null && this.Relationships.Count > 0) ...
stackexchange/codereview
In an environment with multiple windows servers what is the best way to ensure patch compliance accross all systems? Is there a simple tool (some sort of client/server app?) that allows reports to be generated showing the status of all the systems so any that aren't automatically patching themselves can be fixed with...
stackexchange/codereview
I've never used the Global Temporary Tables however I have some questions how they will work in a php environment. How is data shared: Assuming persistent connections to oracle through php using oci8. Is the data tied to a database id? is it done based on the Apache httpd demons? Or is each individual request unique?...
stackexchange/codereview
I am trying to use Difflib.SequenceMatcher to compute the similarities between two files. These two files are almost identical except that one contains some extra whitespaces, empty lines and other doesn't. I am trying to use s=difflib.SequenceMatcher(isjunk,text1,text2) ratio =s.ratio() for this purpose. So, the ques...
stackexchange/codereview
Suppose you have a large file made up of a bunch of fixed size blocks. Each of these blocks contains some number of variable sized records. Each record must fit completely within a single block and then such records by definition are never larger than a full block. Over time, records are added to and deleted from these...
stackexchange/codereview
I'm trying to do a SQL Server 2008 setup and I've been given a Cross Language Installation failure. More specifically: Rule "cross language installation: failed. the Setup language is different than the language of existing SQL Server features. To continue, use SQL Server Setup installation media of the same language...
stackexchange/codereview
I've used the MIT Continuous testing plugin in the past, but it has long since passed out of date and is no longer compatible with anything approaching a modern release of Eclipse. Does anyone have a good replacement? Free, naturally, is preferred.
stackexchange/codereview
I'm trying to redirect requests for a wildcard domain to a sub-directory. ie. something.blah.example.com --> blah.example.com/something I don't know how to get the subdomain name to use in the rewrite rule. Final Solution: RewriteCond %{HTTP_HOST} !^blah\.example\.com RewriteCond %{HTTP_HOST} ^([^.]+) RewriteRule ^(.*)...
stackexchange/codereview
I'm trying to build a Windows installer using Nullsoft Install System that requires installation by an Administrator. The installer makes a "logs" directory. Since regular users can run this application, that directory needs to be writable by regular users. How do I specify that all users should have permission to ha...
stackexchange/codereview
I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error: SQLite3::SQLException: cannot rollback - no transaction is active This error is crippling my ability to test m...
stackexchange/codereview
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it in a Windows Service to do some processing, and I'm looping through a large amount of data that I'm pulling back from the context. Yes - I know I could do this with a stored procedure but there are reasons why that would be a less than ...
stackexchange/codereview
I started using subversion for one of my projects and it would be absolutely amazing if I could just export the latest version from the repository on my production server by for example running a php or perl script. The production site is hosted with a shared hosting provider who doesn't allow shell access or for examp...
stackexchange/codereview
I have an Open Source app and I currently only post the binary for the Windows build. At this point Linux users have to get the source and compile it. Is there a standard way for posting a Linux binary? My app is in c / c++ and compiled with gcc, the only external Linux code I use is X Windows and CUPS.
stackexchange/codereview
I have a bunch a values I would like to add together which are entered into a form. Right now, the form has 11 lines but it could get larger in the future. I can easily add all the values together with something like: $total = $value1 + $value2 + ... + $value11; All the values I want to add together are coming from an...
stackexchange/codereview
My team is starting to document our C code using doxygen, paying particular attention to our public API headers. There appears to be a lot of flexibility and different special commands in doxygen, which is great, but it's not clear what's a good thing and what's a bad thing without trial and error. What are your favou...
stackexchange/codereview
Is it possible, in Java, to make a JPanel skip drawing its background thus being transparent except for the components on it?
stackexchange/codereview
How to do paging in Pervasive SQL (version 9.1)? I need to do something similar like: //MySQL SELECT foo FROM table LIMIT 10, 10 But I can't find a way to define offset.
stackexchange/codereview
On destruction of a restful resource, I want to guarantee a few things before I allow a destroy operation to continue? Basically, I want the ability to stop the destroy operation if I note that doing so would place the database in a invalid state? There are no validation callbacks on a destroy operation, so how does on...
stackexchange/codereview
My custom homebrew photography processing software, running on 64 bit Linux/GNU, writes out PNG and TIFF files. These are to be sent to a quality printing shop to be made into fine art. Working with interior designers - it's important to get the colors just right! The print shops usually have no trouble with TIF...
stackexchange/codereview
I know that this is somewhat subjective, but I wonder if there is a generally accepted standard for naming assemblies which contain some "core" functions. Let's say you got a larger Projects, with Assemblies like Company.Product.WebControls.dll Company.Product.Net.dll Company.Product.UserPages.dll and you have a Bunc...
stackexchange/codereview
The Image Web Part doesn't seem to have an href attribute that I can set. Is there something I am missing?
stackexchange/codereview
Looking for an open source library, for C++, Java, C# or Python, for reading the data from Quicken .qdf files. @Swati: Quicken .qif format is for transfer only and is not kept up to date by the application like the .qdf file is.
stackexchange/codereview
How come this doesn't work (operating on an empty select list <select id="requestTypes"></select> $(function() { $.getJSON("/RequestX/GetRequestTypes/", showRequestTypes); } ); function showRequestTypes(data, textStatus) { $.each(data, function() { var optio...
stackexchange/codereview
For some reason, when I try to install SQL Server 2008 Express, I get an error saying that I need to have .Net Framework 3.5 installed first, but the thing is: I already have! So could anybody tell me if I can bypass this verification by updating a registry key or something? I have np with visual studio or any other th...
stackexchange/codereview
C#6 Update In C#6 ?. is now a language feature: // C#1-5 propertyValue1 = myObject != null ? myObject.StringProperty : null; // C#6 propertyValue1 = myObject?.StringProperty; The question below still applies to older versions, but if developing a new application using the new ?. operator is far better practice. Orig...
stackexchange/codereview
We attempt to do agile development at my current job and we succeed for the most part. The main problem seems to be that the developers on the project are always waiting for requirements at the beginning of the sprint and rushing to get get things down by the end. The business analysts who are delivering the requiremen...
stackexchange/codereview
I would like to code a little program which visually illustrates the behavior of the volatile keyword. Ideally, it should be a program which performs concurrent access to a non volatile static field and which gets incorrect behavior because of that. Adding the volatile keyword in the same program should fix the proble...
stackexchange/codereview
I'm trying to learn RegEx in Ruby, based on what I'm reading in "The Rails Way". But, even this simple example has me stumped. I can't tell if it is a typo or not: text.gsub(/\s/, "-").gsub([^\W-], '').downcase It seems to me that this would replace all spaces with -, then anywhere a string starts with a non letter or...
stackexchange/codereview
I have a JComboBox and would like to have a separator in the list of elements. How do I do this in Java? A sample scenario where this would come in handy is when making a combobox for font-family-selection; similar to the font-family-selection-control in Word and Excel. In this case I would like to show the most-used-f...
stackexchange/codereview
In an HTML form post what are valid characters for creating a multipart boundary?
stackexchange/codereview
It is much more convenient and cleaner to use a single statement like import java.awt.*; than to import a bunch of individual classes import java.awt.Panel; import java.awt.Graphics; import java.awt.Canvas; ... What is wrong with using a wildcard in the import statement?
stackexchange/codereview
I have an ASP.NET 3.5 WebForm that leverages the frameworks Page.ClientScript.GetCallbackEventReference() method and I'd like some of the calls to be synchronous. Now, the documentation says that the 5th parameter (see below) controls this. Specifically, when you pass 'false' it's supposed to be a non-asynchronous c...
stackexchange/codereview
Underneath one "Project" in TFS we have multiple products. This is because for us, a project is a business unit and they each can have many applications that we develop for them. Each one has its own folder in source control(under the TFS project) and each one has its own TeamBuild set up. The issue I have is that w...
stackexchange/codereview
I've developed a Visual C#.NET 2008 Express Edition solution containing three projects. I am cleaning it up to commit it into a CVS repository. There are several files that are created during the build process that are not necessary to be placed in the repository since they will be regenerated automatically. The questi...
stackexchange/codereview
I'm using grep to generate a list of files I need to move: grep -L -r 'Subject: \[SPAM\]' . How can I pass this list to the mv command and move the files somewhere else?
stackexchange/codereview
I want to add a mailto link on our web page. I want to add a urgent priority to this mail.
stackexchange/codereview
In new C++ code, I tend to use the C++ iostream library instead of the C stdio library. I've noticed some programmers seem to stick to stdio, insisting that it's more portable. Is this really the case? What is better to use?
stackexchange/codereview
I am moving from classic ASP to ASP.NET and have encountered what many of you already know as "viewstate". I might be jumping the gun with my assumption, but it looks highly cumbersome. I have developed many ASP forms in the past and never had issues with keeping state. Is there another way OR am I going to have to ...
stackexchange/codereview
Has anyone tried the ActiveRecord Intro Sample with C# 3.5? I somehow have the feeling that the sample is completely wrong or just out of date. The XML configuration is just plain wrong: <add key="connection.connection_string" value="xxx" /> should be : <add key="hibernate.connection.connection_string" value="xxx" /> ...
stackexchange/codereview
How to add a click event listener to my custom control made with wxWidgets? The custom control uses wxWindow as the base. On the event list I see wxEVT_LEFT_DOWN wxEVT_LEFT_UP wxEVT_LEFT_DCLICK wxEVT_MIDDLE_DOWN wxEVT_MIDDLE_UP wxEVT_MIDDLE_DCLICK wxEVT_RIGHT_DOWN wxEVT_RIGHT_UP wxEVT_RIGHT_DCLICK wxEVT_MOTION wxE...
stackexchange/codereview
How do I write a cpp macro which expands to include newlines?
stackexchange/codereview
I would like to host a Maven repository for a framework we're working on and its dependencies. Can I just deploy my artifacts to my FTP host using mvn deploy, or should I manually deploy and/or setup some things before being able to deploy artifacts? I only have FTP access to server I want to host the Maven repo on. Th...
stackexchange/codereview
The Python list comprehension syntax makes it easy to filter values within a comprehension. For example: result = [x**2 for x in mylist if type(x) is int] Will return a list of the squares of integers in mylist. However, what if the test involves some (costly) computation and you want to filter on the result? One o...
stackexchange/codereview
I'm using Amazon's tools to build a web app. I'm very happy with them, but I have a security concern. Right now, I'm using multiple EC2 instances, S3, SimpleDB and SQS. In order to authenticate requests to the different services, you include your Access Identifiers (login required). For example, to upload a file to S3...
stackexchange/codereview
Background Normal rails eager-loading of collections works like this: Person.find(:all, :include=>:companies) This generates some sql which does LEFT OUTER JOIN companies ON people.company_id = companies.id Question However, I need a custom join (this could also arise if I was using find_by_sql) so I can't use the va...
stackexchange/codereview
I am interested to know what strategies people have to keep their code AND work versioned across multiple machines. For example I have a desktop PC running XP, a macbook running OSX and VMWare running XP as well as a sales laptop for running product demos. I want to know how I can always have these in sync. Subversi...
stackexchange/codereview
Some of the controls I've created seem to default to the old Windows 95 theme, how do I prevent this? Here's an example of a button that does not retain the Operating System's native appearance (I'm using Vista as my development environment): HWND button = CreateWindowEx(NULL, L"BUTTON", L"OK", WS_VISIBLE | WS_CHILD | ...
stackexchange/codereview
I need to know when the memory will be allocated for a particular program. How can i view where the memory is allocated.
stackexchange/codereview
PMD would report a violation for: ArrayList<Object> list = new ArrayList<Object>(); The violation was "Avoid using implementation types like 'ArrayList'; use the interface instead". The following line would correct the violation: List<Object> list = new ArrayList<Object>(); Why should the latter with List be used ins...
stackexchange/codereview
Given this data: CREATE TABLE tmpTable( fldField varchar(10) null); INSERT INTO tmpTable SELECT 'XXX' UNION ALL SELECT 'XXX' UNION ALL SELECT 'ZZZ' UNION ALL SELECT 'ZZZ' UNION ALL SELECT 'YYY' SELECT CASE WHEN fldField like 'YYY' THEN 'OTH' ELSE 'XXX' END AS newField FROM tmpTable The expected resultset is: XXX...
stackexchange/codereview
Vxworks supports standard IP v4 and IP v6 sockets, but sockets are also used for other purposes. What other types of sockets are available?
stackexchange/codereview
How can this line in Java be translated to Ruby: String className = "java.util.Vector"; ... Object o = Class.forName(className).newInstance(); Thanks!
stackexchange/codereview
I'm trying to automate a program I made with a test suite via a .cmd file. I can get the program that I ran's return code via %errorlevel%. My program has certain return codes for each type of error. For example: 1 - means failed for such and such a reason 2 - means failed for some other reason ... echo FAILED: Test ...
stackexchange/codereview
I have a server that sends data via a socket, the data is a wav 'file'. I can easily write the data to disk and then play it in WMP, but I have no idea how I can play it as I read it from the socket. Is it possible? Bonus question: how would I do it if the stream was in mp3 or other format? This is for windows in nativ...
stackexchange/codereview
Update: Looks like the query does not throw any timeout. The connection is timing out. This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception. I cannot use any of these techniques: 1) Increase timeout. 2) Run it asynchronously with a callback. This ...
stackexchange/codereview
I have to work on an old 1.3 JVM and I'm asked to create a secure connection to another server. Unfortunately the HttpsURLConnection only appears sinc JVM 1.4. Is there another way to create a secure connection? Is there a library that I could you to add this fonctionnality?
stackexchange/codereview
How would I go about creating multiple documents when a single file is opening in a MFC application? We have an aggregate file format which can contain information for multiple documents. When this file is opened, I would like multiple CDocuments created for each record in the file. We already have a extended CDocMan...
stackexchange/codereview
I have object A which in turn has a property of type Object B Class A property x as Object B End Class On my ASP.NET page when I select a gridview item which maps to an object of type A I serialize the object onto the QueryString and pass it to the next page. However I run into problems if property x actually has s...
stackexchange/codereview
Given the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span> </div> <div> <span>Test: Text5</span> </div> </body> </html> What is the best XPath query to locate any span with text that starts with Test?
stackexchange/codereview
I have a Dictionary<string, someobject>. EDIT: It was pointed out to me, that my example was bad. My whole intention was not to update the references in a loop but to update different values based on differnt threads need to update/get the data. I changed the loop to a method. I need to update items in my dictionary - ...
stackexchange/codereview
We want test the JTAPI feature of our application. Are there any emulator for JTAPI available? The testing with real hardware is a little diffcult.
stackexchange/codereview
I have a simple function that sends out emails, how would I go about using threads to speed email delivery? Sample code would be ideal.
stackexchange/codereview
What is the proper way to inject a data access dependency when I do lazy loading? For example I have the following class structure class CustomerDao : ICustomerDao public Customer GetById(int id) {...} class Transaction { int customer_id; //Transaction always knows this value Customer _customer = null; ICustom...
stackexchange/codereview
Using Maven 1.x with just the bundled/standard plugins, what configuration is necessary to build an executable Jar? Answers should cover: including dependencies in target Jar proper classpath configuration to make dependency Jars accessible
stackexchange/codereview
As in a title, does anyone know how to freeze GridView header in ASP.NET ?
stackexchange/codereview
I'm discovering a simple solution for singular-plural keywords searches. I heard about stemming but I don't want to use all its features, only plural/singular transformation. The language is Dutch. Have looked at http://www.snowball.tartarus.org before. Does anyone know the simple solution for singular|plural relevant ...
stackexchange/codereview
The MSDN states that the method returns true if the method is successfully queued; NotSupportedException is thrown if the work item is not queued. For testing purposes how to get the method to return false? Or it is just a "suboptimal" class design?
stackexchange/codereview
I'm trying to create a new Excel file using jxl, but am having a hard time finding examples in their API documentation and online.
stackexchange/codereview
This is along similar lines as these recent questions: Best Java Obfuscation Application For Size Reduction Creating non-reverse-engineerable Java programs However, one ends up recommending yGuard and the other ProGuard but neither mention both. I wonder if we could get a comparison of each one and hear peoples experie...
stackexchange/codereview
I have read that while plug-ins are not supported for SQL Server Management Studio, it can be done. Does anyone have any resources or advice on how to go about it using C#? A company that is currently offering plug-ins to Management Studio is Red Gate: http://www.red-gate.com/products/SQL_Refactor/index.htm
stackexchange/codereview
I've got a XmlNodeList which I need to have it in a format that I can then re-use within a XSLT stylesheet by calling it from a C# extension method. Can anyone help? I have read that it might have something to do with using a XPathNavigator but I'm still a bit stuck.
stackexchange/codereview
In VB.Net, I can declare a variable in a function as Static, like this: Function EncodeForXml(ByVal data As String) As String Static badAmpersand As Regex = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)") data = badAmpersand.Replace(data, "&amp;") ''// more processing return data End Function Note tha...
stackexchange/codereview
Is it possible to include one CSS file in another?
stackexchange/codereview
I am trying to get a Flex application to communicate with a custom python webserver I have developed. I am noticing that I cannot read the postdata received because Flex does not seem to include the Content-Length in the HTTP headers. (My webserver work when posted to from plain HTML) Is this a known problem? any idea...
stackexchange/codereview
Given a string with a module name, how do you import everything in the module as if you had called: from module import * i.e. given string S="module", how does one get the equivalent of the following: __import__(S, fromlist="*") This doesn't seem to perform as expected (as it doesn't import anything).
stackexchange/codereview
I understand access modifiers at the class level and below, but why would an entire assembly be private? I assume by default, assemblies are public?
stackexchange/codereview
Background I have a massive db for a SharePoint site collection. It is 130GB and growing at 10gb per month. 100GB of the 130GB is in one site collection. 30GB is the version table. There is only one site collection - this is by design. Question Am I able to partition a database (SharePoint) using SQL 2005s data part...
stackexchange/codereview