instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse I want to be able to do this because I don't like knowfully causing Exceptions: chars = #some list indx = chars.index(chars) if indx == -1: #doSomething else: #doSomethingElse...
stackexchange/codereview
Have any well-documented or open source projects targeted iPhone, Blackberry, and Android ? Are there other platforms which are better-suited to such an endeavor ? Note that I am particularly asking about client-side software, not web apps, though any information about the difficulties of using web apps across multipl...
stackexchange/codereview
Leaving aside the question of whether you should serve single or multiple stylesheets, assuming you're sending just one, what do you think of this as a basic structure? /* Structure */ Any template layout stuff should be put into here, so header, footer, body etc. /* Structure End */ /* Common Components*/ Repeated ele...
stackexchange/codereview
I have have some code which adds new cells to a table and fills them with text boxes. The way I've coded it so far works fine: TableCell tCell1 = new TableCell(); TableCell tCell2 = new TableCell(); TableCell tCell3 = new TableCell(); TableCell tCell4 = new TableCell(); TableCel...
stackexchange/codereview
In applying for jobs via agents I sometimes get blocked by an agent who says do you know software package X. When I reply that I know the similar package Y they might say unless you know X I cannot put you forward. The problem is that some of these agents don't know what they talking about, they are merely being used b...
stackexchange/codereview
How do I apply the MarshalAsAttribute to the return type of the code below? public ISomething Foo() { return new MyFoo(); }
stackexchange/codereview
Definition: A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction How to check if the given string is a palindrome? This was one of the FAIQ [Frequently Asked Interview Question] a while ago but that mostly using C. Looking for solutions in any a...
stackexchange/codereview
In the earliest stages of planning the development of a new system, which development model to follow seems paramount. I've always held onto the belief that a classic waterfall (or hybrid waterfall/iterative prototyping) is the best approach for medium to large projects. It seems that once a project gets to be a cert...
stackexchange/codereview
G'day Stackoverflowers, I'm the author of Perl's autodie pragma, which changes Perl's built-ins to throw exceptions on failure. It's similar to Fatal, but with lexical scope, an extensible exception model, more intelligent return checking, and much, much nicer error messages. It will be replacing the Fatal module in ...
stackexchange/codereview
I need to send large files from silverlight 2 beta 2, so I need to set the sendchuncked property to true, but the property doesn't seem to exist. I've seen other posts on the internet where people have been able to set this in Silverlight. I disassebled the .dll at C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Re...
stackexchange/codereview
Why is it bad to name a variable id in Python?
stackexchange/codereview
I want to write a raw byte/byte stream to a position in a file. This is what I have currently: $fpr = fopen($out, 'r+'); fseek($fpr, 1); //seek to second byte fwrite($fpr, 0x63); fclose($fpr); This currently writes the actually string value of "99" starting at byte offset 1. IE, it writes bytes "9" and "9". I just ...
stackexchange/codereview
I need to design a small project for generating excel reports in .NET, which will be sent to users to use. The excel reports will contain PivotTables. I don't have much experience with them, but I can think of three implementation alternatives: Set a query for it, populate it, send it disconnected. This way the user w...
stackexchange/codereview
Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName As String) Select Case reportName Case "Security" Me.ShowSecurityReport() Case "Configuration" Me.ShowConfigurationReport() Case "RoleUsers" Me.ShowRoleUsersRepo...
stackexchange/codereview
I am creating an HTTP handler that listens for calls to a specific file type, and handles it accordingly. My HTTP Handler listens for .bcn files, then writes a cookie to the user's computer and sends back an image... this will be used in advertising banners so that the user is tagged as seeing the banner, and we can t...
stackexchange/codereview
I'm wondering if updating statistics has helped you before and how did you know to update them?
stackexchange/codereview
A client has a number of disparate systems that they are planning to link together and have asked for a set of system interface specifications that would document the data and protocols used to interface the different parts. The interfaces are between processes not between users. Any recommendations for a template tha...
stackexchange/codereview
If I have a Range object--for example, let's say it refers to cell A1 on a worksheet called Book1. So I know that calling Address() will get me a simple local reference: $A$1. I know it can also be called as Address(External:=True) to get a reference including the workbook name and worksheet name: [Book1]Sheet1!$A$1...
stackexchange/codereview
I am looking for a tool for regression testing a suite of equipment we are building. The current concept is that you create an input file (text/csv) to the tool specifying inputs to the system under test. The tool then captures the outputs from the system and records the inputs and outputs to an output file. The outpu...
stackexchange/codereview
I am trying to display a list of all files found in the selected directory (and optionally any subdirectories). The problem I am having is that when the GetFiles() method comes across a folder that it cannot access, it throws an exception and the process stops. How do I ignore this exception (and ignore the protected f...
stackexchange/codereview
I'd like to use the new CMFCListCtrl features with my CListView class (and, of course, the new CMFCHeaderCtrl inside it). Unfortunately, you can't use Attach() or SubclassWindow() because the SysListView32 window is already associated with a CListView object. Do I have to override CListView's OnCmdMsg() and route all m...
stackexchange/codereview
I want to replace the first occurrence in a given string. How can I accomplish this in .NET?
stackexchange/codereview
I have been looking for documentation related to interacting with MSPaint from the command line. I have only found references to /p, /pt and /wia, but no guidance as to how to use them and their limitations. I am trying to send some graphics files to the printer and when I drop the file on my printer driver I get a dif...
stackexchange/codereview
From the documentation, I would expect adModeShareDenyWrite to be the way, but it's not working right. I'm using an Access database via ADO. My connection string says Mode=8, which is adModeShareDenyWrite. But when I try to delete a row from a table, I get: Unspecified error, Description:Could not delete from speci...
stackexchange/codereview
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer serializer = new XmlSerializer(typeof(MyClass)); //... } Here is the exception: A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll Additional information: Coul...
stackexchange/codereview
What's the best way to access WSE 2.0 web services from .NET 2.0? Using VS2005's web references is not working, because generated classes are using System.Web.Services as their base (instead of Microsoft.Web.Services2).
stackexchange/codereview
I have a rails app that I have serving up XML on an infrequent basis. This is being run with mongrel and mysql. I've found that if I don't exercise the app for longer than a few hours it goes dead and starts throwing Errno::EPIPE errors. It seems that the mysql connection get timed out for inactivity or something like ...
stackexchange/codereview
I'm developing a an eclipse plugin that uses an SWT interface. I need to display text, and within that text there needs to be links. The only two widgets that I've found that will allow me to include clickable links in text are Link and Browser. Browser, however, is overkill for my needs, and I couldn't properly cus...
stackexchange/codereview
I wrote a short bash script to complete a task that involves creating a temporary directory and storing various files in it and performing various operations on it. In my first pass I just created the temp dir at /tmp/$$.$script", but then I tested the script on a computer where I didn't have write access to /tmp/, and...
stackexchange/codereview
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax error in PHP. What's the most efficient way to directly obtain an element from a returned array without assigning the result to a temp variable?
stackexchange/codereview
I want to build a site where the user can enter text and format it in Markdown. The reason I'd like a Javascript solution is because I want to display a live preview, just like on StackOverflow. My site is not targeted at developers, however, so an editor control would be ideal. I gather that on StackOverflow, the WMD ...
stackexchange/codereview
I'm trying to use the this keyword in a static method, but the compiler won't allow me to use it. Why not?
stackexchange/codereview
I'm in a situation where I would to generate a script for a database that I could run on another server and get a database identical to the original one, but without any of the data. In essence, I want to end up with a big create script that captures the database schema. I am working in an environment that has SQL Se...
stackexchange/codereview
Assume the following: models.py class Entry(models.Model): title = models.CharField(max_length=50) slug = models.CharField(max_length=50, unique=True) body = models.CharField(max_length=200) admin.py class EntryAdmin(admin.ModelAdmin): prepopulated_fields = {'slug':('title',)} I want the slug to be pr...
stackexchange/codereview
My questions is simple! Would you start learning Smalltalk if you had the time? Why? Why not? Do you already know Smalltalk? Why would you recommend Smalltalk? Why not? Personally I'm a Ruby on Rails programmer and I really like it. However, I'm thinking about Smalltalk because I read various blogs and some people ar...
stackexchange/codereview
I have an XML datatype and want to convert an element into a sql DateTime variable. How? e.g. Declare @Xml Xml Set @Xml = '<Root><DateFrom>2008-10-31T00:00:00</DateFrom></Root>' Declare @DateFrom DateTime Set @DateFrom = ????? How can I set @DateFrom with the date from the xml above?
stackexchange/codereview
What do you use to validate an email address on a ASP.NET form. I want to make sure that it contains no XSS exploits. This is ASP.NET 1.1
stackexchange/codereview
SQL to find duplicate entries (within a group) I have a small problem and I'm not sure what would be the best way to fix it, as I only have limited access to the database (Oracle) itself. In our Table "EVENT" we have about 160k entries, each EVENT has a GROUPID and a normal entry has exactly 5 rows with the same GROUPI...
stackexchange/codereview
Okay, that may not be the best subject... I am setting up an approval workflow within an application. I pass the username and the dollar amount to the subprocedure and figure out what workflow I need to use for the approval process. I thought I had this working until I try to handle the condition when the user hasn't b...
stackexchange/codereview
We need to make our enterprise ASP.NET/NHibernate browser-based application able to function when connected to or disconnected from the customer's server. Has anyone done this? If so, how did you do it? (Technology, architecture, etc.) Background: We develop and sell an enterprise browser-based application used by cons...
stackexchange/codereview
Is there a way to automatically apply a theme/template/style to all controls of the targettype, so I don't have to specify Template=..., Style=... on all controls?
stackexchange/codereview
I would like to debug an embedded system containing gdb remotely using some kind of gui (ie like ddd). The embedded system does not have the sources or build symbols. However my local x windows box has. However the execution must happen on the embedded system. How can I from my development box drive gdb remotely with s...
stackexchange/codereview
I need a very accurate way to time parts of my program. I could use the regular high-resolution clock for this, but that will return wallclock time, which is not what I need: I needthe time spent running only my process. I distinctly remember seeing a Linux kernel patch that would allow me to time my processes to nanos...
stackexchange/codereview
I need to make a change to an ASP.NET web service written a couple years ago on 2.0. I call this web service from an old 1.1 web site. I need to make some changes to the web service, so am thinking, should I rewrite this into a WCF service and if so, will I still be able to use it from my 1.1 web site?
stackexchange/codereview
I am just curious to know how long, in minutes, does the reporting service take to generate report when it returns 1MB of data. Maybe using views and table is properly index. SSRS reporting and server side generation.
stackexchange/codereview
I have a web application using ASP.NET 2.0 and I want to know if I should be moving it to ASP.NET 3.5, particularly... what am I missing by not moving to ASP.NET 3.5? I understand the disadvantages, but I don't understand the advantages. What are the biggest benefits of migrating/rewriting? Will I get a speed improvem...
stackexchange/codereview
I have a basic C# console application that reads a text file (CSV format) line by line and puts the data into a HashTable. The first CSV item in the line is the key (id num) and the rest of the line is the value. However I've discovered that my import file has a few duplicate keys that it shouldn't have. When I try to ...
stackexchange/codereview
3-Tier design has been my standard design philosophy for years for database driven applications, and it has never failed me. For those who practice it, describe your layers. I've found that many people muddle up the business tier and the data access tier, making it more like a 2.5-Tier design. I prefer to move the data...
stackexchange/codereview
I am creating a service that needs to run on Windows 2000, XP, 2003, 2008 & Vista. The service needs to access a network share as part of its processing. For XP and beyond the service can be running as the Network Service account but what's the equivalent in Windows 2000?
stackexchange/codereview
Sybase db tables do not have a concept of self updating row numbers. However , for one of the modules , I require the presence of rownumber corresponding to each row in the database such that max(Column) would always tell me the number of rows in the table. I thought I'll introduce an int column and keep updating this ...
stackexchange/codereview
We are developing a considerably big application using Ruby on Rails framework (CRM system) and are considering to rewrite it to use ExtJS so that Rails would just do the data handling, while ExtJS would do all the browser heavylifting in a desktop-like manner. Anyone has some experience and hints about what would be ...
stackexchange/codereview
I have a type (System.Type) of an enum and a string containing enumeration value to set. E.g. given: enum MyEnum { A, B, C }; I have typeof(MyEnum) and "B". How do I create MyEnum object set to MyEnum.B?
stackexchange/codereview
When I try to bind port 80 to a socket in c, i always get the error, that I don't have permission to use this port. is there an easy way to get this permission?
stackexchange/codereview
Studying emergence, it's quite useful to have a development framework to build upon to quickly test out new ideas. 3d with physics collision would be nice, and open-source would be a big plus. For this purpose 'breve' looks quite promising, but I was wondering if anyone had used it or knows of any other suitable engine...
stackexchange/codereview
My question is what do most developers prefer for error handling, Exceptions or Error Return Codes. Please be language(or language family) specific and why you prefer one over the other. I'm asking this out of curiosity. Personally I prefer Error Return Codes since they are less explosive and don't force user code to p...
stackexchange/codereview
The most basic task in an object oriented environment is executing a method on an object. To do this, you have to have a reference to the object on which you are invoking the method. Is the proper way to establish this reference to pass the object as a parameter to the constructor (or initializer method) of the calling...
stackexchange/codereview
I've been using JSch for a couple of weeks now. It seems to work okay, but its API is a little bit cumbersome. I'm also a little off put by its total lack of documentation (not even javadoc style comments). Has anyone used a good Java SSH2 library that they'd recommend. I'm particularly interested in SCP file trans...
stackexchange/codereview
I am looking for a pseudo random number generator which would be specialized to work fast when it is given a seed before generating each number. Most generators I have seen so far assume you set seed once and then generate a long sequence of numbers. The only thing which looks somewhat similar to I have seen so far is ...
stackexchange/codereview
I recently began profiling an osgi java application that I am writing using VisualVM. One thing I have noticed is that when the application starts sending data to a client (over JMS), the number of loaded classes starts increasing at a steady rate. The Heap size and the PermGen size remains constant, however. The nu...
stackexchange/codereview
What's a simple way to implement a c++ Win32 program to... - display an 800x600x24 uncompressed bitmap image - in a window without borders (the only thing visible is the image) - that closes after ten seconds - and doesn't use MFC
stackexchange/codereview
I have an asp.net textbox and a MaskedEditExtender control attached to it. The textbox is used for date input. The MaskedEditExtender has MaskType="Date" Mask="99/99/9999". When the form is submitted with an invalid date, the browser shows a Javascript error "... string was not recognized as a valid datetime". I know w...
stackexchange/codereview
the new keyboard from Microsoft, Sidewinder x6 can record in game macro. I was woundering if it could be used in Visual Studio (record key in application too)? (This could be very useful to press 1 key instead of Ctrl+M,M to Toggle Outline.)
stackexchange/codereview
I'm having troubles finding good Ruby libraries that implement WS-Security. I've seen wss4r but have yet to use it (and the documentation is a bit light on it). What libraries do you use for this task, or is there a better alternative?
stackexchange/codereview
We've noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block: public PageSizer(string href, int index) { HRef = href; PageIndex = index; } Copy and pasted from IE7, ends up like this: public PageSizer(string href, int index){ HRef = href; PageI...
stackexchange/codereview
I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers?
stackexchange/codereview
When viewing someone else's webpage containing an applet, how can I force Internet Explorer 6.0 to use a a particular JRE when I have several installed?
stackexchange/codereview
How do I suspend a whole process (like the Process Explorer does when I click Suspend) in C#. I'm starting the Process with Process.Start, and on a certain event, I want to suspend the process to be able to do some investigation on a "snapshot" of it.
stackexchange/codereview
I'm involved in a project that is attempting to use the Eclipse RCP splash screen to gather user credentials, language, etc. If this screen loses focus, it is not available (under Windows at least) through the ALt-Tab functionality, and can only be found by minimizing all other windows and uncovering it. Any way of hav...
stackexchange/codereview
I have a class that looks like this public class SomeClass { public SomeChildClass[] childArray; } which will output XML from the XMLSerializer like this: <SomeClass> <SomeChildClass> ... </SomeChildClass> <SomeChildClass> ... </SomeChildClass> </SomeClass> But I want the XML to look like ...
stackexchange/codereview
I have returned to php development from Moose and I really miss CLOS like object model for php. Is there some kind of syntaxtic sugar which would allow me to write less code in php when dealing with objects? Just to stress this requirement a bit more. I don't want to write one thing in several places. I can live with p...
stackexchange/codereview
Currently Tomcat's login support redirects users back to where they initially were when the application figured out they weren't logged in. For this particular application I need to force them to always go back to index.jsp. I'm pretty sure this is a simple configuration option in the WAR's web.xml, but I haven't found...
stackexchange/codereview
After reading the answers to the question "Calculate Code Metrics" I installed the tool SourceMonitor and calculated some metrics. But I have no idea how to interpret them. What's a "good" value for the metric "Percent Branch Statements" "Methods per Class" "Average Statements per Method" "Maximum Method or Function C...
stackexchange/codereview
In Visual Studio, when I type the line "Implements IDisposable", the IDE automatically adds: a disposedValue member variable a Sub Dispose() Implements IDisposable.Dispose a Sub Dispose(ByVal disposing As Boolean) The Dispose() should be left alone, and the clean up code should be put in Dispose(disposing). However t...
stackexchange/codereview
In my application I have a window which I popup with small messages on it (think similar to tooltip). This window uses the layered attributes to draw alpha backgrounds etc. If I have several of these windows open at once, and I click one with my mouse, when they disappear they cause my application to lose focus (it swi...
stackexchange/codereview
I have a user control in a repeater that I need to pass data to during the databound event, so I've created two public properties in the control. How do I access these properties from the page's codebehind class?
stackexchange/codereview
I've got an issue when accessing a web site, I can access it by using the NetBIOS name, but when accessing with the FQDN i get an error. Any ideas on how to troubleshoot this? (There is no DNS configured yet, we have modified the Hosts file to enter the related names and IP.)
stackexchange/codereview
I love vim and the speed it gives me. But sometimes, my fingers are too speedy and I find myself typing :WQ instead of :wq. (On a German keyboard, you have to press Shift to get the colon :.) Vim will then complain that WQ is Not an editor command. Is there some way to make W and Q editor commands?
stackexchange/codereview
I am working on a Sharepoint Server 2007 State machine Workflow. Until now I have a few states and a custom Association/InitiationForm which I created with InfoPath 2007. In Addition I have a few modification forms. I have a Problem with the removing of the modification link in the state-page of my workflow. I have a ...
stackexchange/codereview
I'm using Zend Studio for Eclipse (Linux), and I'm trying to generate getter and setters methods in a PHP class. I try to do this: http://files.zend.com/help/Zend-Studio-Eclipse-Help/creating_getters_and_setters.htm but I haven't "Generate Getters and Setters" option in Source Menu, it's missed! Could u help me? Thank...
stackexchange/codereview
PowerShell v1.0 is obviously a console based administrative shell. It doesn't really require a GUI interface. If one is required, like the Exchange 2007 management GUI, it is built on top of PowerShell. You can create your own GUI using Windows Forms in a PowerShell script. My question is, "What sort of PowerShell scri...
stackexchange/codereview
What is the difference between g++ and gcc? Which one of them should be used for general c++ development?
stackexchange/codereview
When I insert a DVD or CD, I want to programmatically know what type of media(DVD or CD) is it.
stackexchange/codereview
I just started programming Objective-C and, having a background in Java, wonder how people writing Objective-C programs deal with private methods. I understand there may be several conventions and habits and think about this question as an aggregator of the best techniques people use dealing with private methods in Obj...
stackexchange/codereview
How can I tell Activerecord to not load blob columns unless explicitly asked for? There are some pretty large blobs in my legacy DB that must be excluded for 'normal' Objects.
stackexchange/codereview
From Wikipedia: Generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters and was pioneered by Ada which appeared in 1983. This approach permits writing...
stackexchange/codereview
One of the biggest advantages of object-oriented programming is encapsulation, and one of the "truths" we've (or, at least, I've) been taught is that members should always be made private and made available via accessor and mutator methods, thus ensuring the ability to verify and validate the changes. I'm curious, thou...
stackexchange/codereview
I just want a simple tool that will help me quickly write scripts/packages that I can schedule to run. My transform requirements are pretty simple (changing column names, merging/splitting tables, and date conversions). I'll sacrifice flexibility for speed of development on this one. Any come to mind?
stackexchange/codereview
When I try this with a generic class where this.value is T: if (this.value.GetType() == typeof(int)) { ((int)this.value)++; } else { throw new InvalidOperationException ("T must be an int to perform this operation"); } I get a compile-time error: "Cannot convert type 'T' to 'int'" What should I do ...
stackexchange/codereview
It seems like a standard requirement: next time the user launches the application, open the window in the same position and state as it was before. Here's my wish list: Window position same as it was Unless the screen has resized and the old position is now off screen. Splitters should retain their position Tab con...
stackexchange/codereview
On OS X, does Objective-C compile to native code or byte-code? Can Objective-C programs be compiled on Linux?
stackexchange/codereview
How does one dynamically load a new report from an embedded resource? I have created a reporting project that contains a report as an embedded resource. I added a second report file and use the following code to switch reports: this.reportViewer1.LocalReport.ReportEmbeddedResource = "ReportsApplication2.Report2.rdlc"; ...
stackexchange/codereview
I am looking for a toolkit that will allow me to design widgets containing 2D graphics for an elevator simulation in Java. Once created, those widgets will be integrated with SWT, Swing, or QtJambi framework. Background information: I am developing an Elevator Simulator for fun. My main goal is to increase my knowledg...
stackexchange/codereview
I'd like to rank a collection of landscape images by making a game whereby site visitors can rate them, in order to find out which images people find the most appealing. What would be a good method of doing that? Hot-or-Not style? I.e. show a single image, ask the user to rank it from 1-10. As I see it, this allows m...
stackexchange/codereview
Working with software day-to-day usually means you have to juggle project work, meetings, calls and other interrupts. What single technique, trick, or tool do you find most useful in managing your time? How do you stay focused? What is your single biggest distraction from your work?
stackexchange/codereview
Is it possible to have one application binary build for multiple mobile devices (on BREW platform), rather than making a separate build for each device using build script with conditional compilation. In particular is is possible to use single BREW application build for multiple screen resolutions? Note that the goal i...
stackexchange/codereview
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
stackexchange/codereview
What are some guidelines for factoring of web services? On one extreme you have different procedures for every operation, and expose all types through WSDL. This seems to result in the WS interface changing as often as the business logic. On the other, a generic interface where the types and validation are performed...
stackexchange/codereview
In your own application that is. [edit] Alright, so I agree completely -- more than you know -- without equivocation that graphical emoticons are an abomination. But! That doesn't help me when the project owners tell me that we must support graphical emoticons. [/edit] The problem more complex than it would initially s...
stackexchange/codereview
I'm in a small business of hosting my clients' websites, and a lot of times they ask me to create one from scratch. I'm no designer, but I can code CSS/HTML, AJAX, PHP. However, I'm not willing to create sites from scratch, knowing how much is involved. In the past, I've tried using design templates, but they proved to...
stackexchange/codereview
I need to explain to the client why dupes are showing up between 2 supposedly different exams. It's been 20 years since Prob and Stats. I have a generated Multiple choice exam. There are 192 questions in the database, 100 are chosen at random (no dupes). Obviously, there is a 100% chance of there being at least 8 dupe...
stackexchange/codereview