instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
When using Groovy MarkupBuilder, I have places where I need to output text into the document, or call a function which outputs text into the document. Currently, I'm using the undefined tag "text" to do the output. Is there a better way to write this code? li { text("${type.getAlias()} blah blah ") function1(type....
stackexchange/codereview
This question is slightly related to this question about exception handling. The workaround I found there consists of rolling my own message loop. So my Main method now looks basically like this: [STAThread] static void Main() { // this is needed so there'll actually an exception be thrown by // Application.Run/App...
stackexchange/codereview
I want to write an onClick event which submits a form several times, iterating through selected items in a multi-select field, submitting once for each. How do I code the loop? I'm working in Ruby on Rails and using remote_function() to generate the JavaScript for the ajax call.
stackexchange/codereview
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python) background, they both have excellent admin generators. Seems like this is missing in Rails. For those who aren't familiar with Symfony or Django, they both allow you to specify some metadata around your models to automatically (dynamicall...
stackexchange/codereview
One may not always know the Type of an object at compile-time, but may need to create an instance of the Type. How do you get a new object instance from a Type?
stackexchange/codereview
This is mostly geared toward desktop application developers. How do I design a caching block which plays nicely with the GC? How do I tell the GC that I have just done a cache sweep and it is time to do a GC? How do I get an accurate measure of when it is time to do a cache sweep? Are there any prebuilt caching sche...
stackexchange/codereview
I am a C/C++ programmer professionally, but I've created a couple of personal web sites using PHP and MySQL. They're pretty basic, and I'd like to jazz them up using Ajax, but I've never done any Ajax. I've done all the development so far manually, i.e. no IDE or anything like that. Does anyone have suggestions on Aja...
stackexchange/codereview
Is there a .NET variable that returns the "All Users" directory?
stackexchange/codereview
Is it completely against the Java way to create struct like objects? class SomeData1 { public int x; public int y; } I can see a class with accessors and mutators being more Java like. class SomeData2 { int getX(); void setX(int x); int getY(); void setY(int y); private int x; private...
stackexchange/codereview
Does anyone know tools which look at a MySQL database, show you all the tables graphically and allow you to create complicated JOIN statements via drag-and-drop?
stackexchange/codereview
If I am in a function in the code behind, and I want to implement displaying a "Loading..." in the status bar the following makes sense, but as we know from WinForms is a NoNo: StatusBarMessageText.Text = "Loading Configuration Settings..."; LoadSettingsGridData(); StatusBarMessageText.Text = "Done"; What ...
stackexchange/codereview
What files can we modify so that our solution is still supported by Microsoft? Is it allowed to customize error pages? Can we modify the web.config files to use custom HTTPHandlers?
stackexchange/codereview
Do you expect your WPF developers to know expression blend? Any good resources for learning more about Blend? [UPDATE] Does knowing blend make you more productive?
stackexchange/codereview
Has anyone built a website with IronPython and ASP.NET. What were your experiences and is the combination ready for prime-time?
stackexchange/codereview
I was listening to a recent episode of Hanselminutes where Scott Hanselman was discussing accessibility in web applications and it got me thinking about accessibility in my own applications. We all understand the importance of semantic markup in our web applications as it relates to accessibility but what about other s...
stackexchange/codereview
I'm sure most of you are writing lots of automated tests and that you also have run into some common pitfalls when unit testing. My question is do you follow any rules of conduct for writing tests in order to avoid problems in the future? To be more specific: What are the properties of good unit tests or how do you wr...
stackexchange/codereview
My website will be using only OpenID for authentication. I'd like to pull user details down via attribute exchange, but attribute exchange seems to have caused a lot of grief for StackOverflow. What is the current state of play in the industry? Does any OpenID provider do a decent job of attribute exchange? Should I ...
stackexchange/codereview
I have a binary file that I have to parse and I'm using Python. Is there a way to take 4 bytes and convert it to a single precision floating point number?
stackexchange/codereview
I am curious about how many of you folks incorporate mocking of objects (frameworks like JMock, NMock, RhinoMocks hand in hand with unit testing frameworks) into your daily development process. What are your experiences? You see, I develop on top of a GIS (geographic information systems) platform, in which most of work...
stackexchange/codereview
I know this sounds like a point-whoring question but let me explain where I'm coming from. Out of college I got a job at a PHP shop. I worked there for a year and a half and thought that I had learned all there was to learn about programming. Then I got a job as a one-man internal development shop at a sizable corpora...
stackexchange/codereview
Knowing an exception code, is there a way to find out more about what the actual exception that was thrown means? My exception in question: 0x64487347 Exception address: 0x1 The call stack shows no information. I'm reviewing a .dmp of a crash and not actually debugging in Visual Studio.
stackexchange/codereview
I'm about to start on a large Qt application, which is made up of smaller components (groups of classes that work together). For example, there might be a dialog that is used in the project, but should be developed on its own before being integrated into the project. Instead of working on it in another folder somewhere...
stackexchange/codereview
Is it possible in Word 2007 to create a revision history table automatically using track changes or some other method? e.g. Revision History DateVersionDescriptionAuthor 16/09/20081.0CreatedJohn Smith 17/09/20081.1Fixed dumb spelling errorsColin Jones
stackexchange/codereview
I want to create a number of masked edit extenders from codebehind. Something like: private MaskedEditExtender m_maskedEditExtender; protected override void OnLoad(EventArgs e) { base.OnLoad(e); m_maskedEditExtender = new MaskedEditExtender() { BehaviorID = "clientName" }; m_maskedEditExtend...
stackexchange/codereview
I have a old website that generate its own RSS everytime a new post is created. Everything worked when I was on a server with PHP 4 but now that the host change to PHP 5, I always have a "bad formed XML". I was using xml_parser_create() and xml_parse(...) and fwrite(..) to save everything. Here is the example when savi...
stackexchange/codereview
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035 Return value of function 'function' might be undefined The function, however, is clean, small, and does have a known, expected, return value. The first statement in the function is: Result := ''; and there is no local vari...
stackexchange/codereview
What SQL can be used to list the tables, and the rows within those tables in an SQLite database file – once I have attached it with the ATTACH command on the sqlite3 command line tool?
stackexchange/codereview
Visual studio is pretty good but doesn't create stored procedures automatically. Iron Speed designer does supposedly. But is it any good?
stackexchange/codereview
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>(); Now I want to iterate through the dictionary in reverse order. I can't use a simple for loop because I don't know the keys of the dictionary. A foreach is easy: foreach (SomeObject object in myDictiona...
stackexchange/codereview
Which is better? Or use and OR mapper with SP's? If you have a system with SP's already, is an OR mapper worth it?
stackexchange/codereview
I'm making an example for someone who hasn't yet realized that controls like ListBox don't have to contain strings; he had been storing formatted strings and jumping through complicated parsing hoops to get the data back out of the ListBox and I'd like to show him there's a better way. I noticed that if I have an objec...
stackexchange/codereview
I always thought Java uses pass-by-reference. However, I read a blog post which claims that Java uses pass-by-value. I don't think I understand the distinction the author is making. What is the explanation?
stackexchange/codereview
To experiment, I've (long ago) implemented Conway's Game of Life (and I'm aware of this related question!). My implementation worked by keeping 2 arrays of booleans, representing the 'last state', and the 'state being updated' (the 2 arrays being swapped at each iteration). While this is reasonably fast, I've often won...
stackexchange/codereview
I know I can do most of this by hacking Trac and using Git hooks, but I was wondering if someone has / knows of something ready. Commenting on (and closing) tickets from commit messages would be nice, specially if the diff appears inline with the comment/closing remark. sha1 hashes should be auto-linked to gitweb/cigt/...
stackexchange/codereview
The following code should find the appropriate project tag and remove it from the XmlDocument, however when I test it, it says: The node to be removed is not a child of this node. Does anyone know the proper way to do this? public void DeleteProject (string projectName) { string ccConfigPath = ConfigurationManager....
stackexchange/codereview
Occasionally while attempting to save a Crystal Report that I'm working on in VS2008, a dialog titled "File Save Failed" pops up saying "The document could not be saved in C:\Users\Phillip\AppData\Local\Temp{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}.rpt. It has been saved in C:\Users\Phillip\AppData\Local\Temp\~zzz{YYYYYY...
stackexchange/codereview
I like to use static functions in C++ as a way to categorize them, like C# does. Console::WriteLine("hello") Is this good or bad? If the functions are used often I guess it doesn't matter, but if not do they put pressure on memory? What about static const?
stackexchange/codereview
So I have some files I want to ignore in a subversion repository, but I don't want my ignore patterns for this to be propagated to the repository. In other words, I added some private files in my checkout that I want to keep, but they only exist for me and wouldn't make sense to be ignored for everyone, so if I use the...
stackexchange/codereview
I'm sure this has already been asked and answered so I apologize in advance for that but I'm not figuring out the correct keywords to search for. Searching for "Pattern" hits way too many Q & A's to be useful. I'm working on a regression testing app. I'm displaying a form on the screen and according to which user is ...
stackexchange/codereview
How would you reccommend handling RSS Feeds in ASP.NET MVC? Using a third party library? Using the RSS stuff in the BCL? Just making an RSS view that renders the XML? Or something completely different?
stackexchange/codereview
Okay, I've looked all over the internet for a good solution to get PHP and MySQL working on IIS7.0. It's nearly impossible, I've tried it so many times and given up in vain. Please please help by linking some great step-by-step tutorial to adding PHP and MySQL on IIS7.0 from scratch. PHP and MySQL are essential for ins...
stackexchange/codereview
I have created a database model in Visio Professional (2003). I know that the Enterprise version has the ability to create a DB in SQL Server based on the data in Visio. I do not have the option to install Enterprise. Aside from going through the entire thing one table and relationship at a time and creating the whole ...
stackexchange/codereview
How can I improve the look and feel of my Linux desktop to suit my programming needs? I found Compiz and it makes switching between my workspaces (which is something I do all the time to make the most of my 13.3" screen laptop) easy and look great - so what else don't I know about that make my programming environment m...
stackexchange/codereview
Are there good reasons why it's a better practice to have only one return statement in a function? Or is it okay to return from a function as soon as it is logically correct to do so, meaning there may be many return statements in the function?
stackexchange/codereview
Is there a good yacc/bison type LALR parser generator for .NET ?
stackexchange/codereview
When using host headers to host multiple websites on the same IP address in IIS, is there any way of accessing that website from a browser running on the local machine? This is normally required when a given web component only allows configuration from the local machine. It's also useful when things like ASP.Net's buil...
stackexchange/codereview
What is the best way to localise a date format descriptor? As anyone from a culture which does not use the mm/dd/yyyy format knows, it is annoying to have to enter dates in this format. The .NET framework provides some very good localisation support, so it's trivial to parse dates according to the users culture, but yo...
stackexchange/codereview
I can get Python to work with Postgresql but I cannot get it to work with MySQL. The main problem is that on the shared hosting account I have I do not have the ability to install things such as Django or PySQL, I generally fail when installing them on my computer so maybe it's good I can't install on the host. I found...
stackexchange/codereview
I have one table "orders" with a foreing key "ProductID". I want to show the orders in a grid with the product name, without LazyLoad for better performance, but I if use DataLoadOptions it retrieves all Product fields, which seams like a overkill. Is there a way to retrieve only the Product name in the first query? Ca...
stackexchange/codereview
Consider the need to develop a lightweight desktop DB application on the Microsoft platforms. It could be done fairly easily with MS Access but I'd like to be able to distribute it to others and I don't want to pay for a runtime license. Requirements: easy distribution to others no runtime licensing issues Consider...
stackexchange/codereview
When I try to print a string in a Windows console, sometimes I get an error that says UnicodeEncodeError: 'charmap' codec can't encode character ..... I assume this is because the Windows console cannot handle all Unicode characters. How can I work around this? For example, how can I make the program display a replacem...
stackexchange/codereview
I have a page that is generated which inserts an HTML comment near the top of the page. Inside the comment is a *nix-style command. <!-- command --option value --option2 value2 --option3 --> This comment breaks the page completely. What is wrong with the comment to cause this to happen, and why is this the case?
stackexchange/codereview
Is it worth learning the convention or is it a bane to readability and maintainability?
stackexchange/codereview
I'm new to MVC (and ASP.Net routing). I'm trying to map *.aspx to a controller called PageController. routes.MapRoute( "Page", "{name}.aspx", new { controller = "Page", action = "Index", id = "" } ); Wouldn't the code above map *.aspx to PageController? When I run this and type in any .aspx page I get the...
stackexchange/codereview
How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway's IP? This is somewhat easy in .NET if you know your way around. But how do you do it in Java?
stackexchange/codereview
I've got a project using Maven 2 as the build tool. Now I am using Netbeans 6 as my IDE and really want to be able to use the profiler. Is there any way I can get this to work?
stackexchange/codereview
I've seen this all over the place: Download here! SHA1 = 8e1ed2ce9e7e473d38a9dc7824a384a9ac34d7d0 What does it mean? How does a hash come into play as far as downloads and... What use can I make of it? Is this a legacy item where you used to have to verify some checksum after you downloaded the whole file?
stackexchange/codereview
As the title already states, I'm trying to declare a nested function and return a pointer to that function. I want this function 'not' to return a new function pointer which will return the negation of whatever the original function was. Here is what I have: someType not( someType original ) { int isNot( ListEntry*...
stackexchange/codereview
I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++. Here's an example of the equations: -44.3940 = a * 50.0 + b * 37.0 + tx -45.3049 = a * 43.0 + b * 39.0 + tx -44.9594 = a * 52.0 + b * 41.0 + tx From this, I'd like to get the best approximation for a, b, and tx.
stackexchange/codereview
I haven't been able to find an understandable explanation of how to actually use Python's itertools.groupby() function. What I'm trying to do is this: Take a list - in this case, the children of an objectified lxml element Divide it into groups based on some criteria Then later iterate over each of these groups separ...
stackexchange/codereview
I'm looking for the best way to log errors in an ASP.NET application. I want to be able to receive emails when errors occurs in my application, with detailed information about the Exception and the current Request. In my company we used to have our own ErrorMailer, catching everything in the Global.asax Application_Err...
stackexchange/codereview
I am working on a function to establish the entropy of a distribution. It uses a copula, if any are familiar with that. I need to sum up the values in the array based on which dimensions are "cared about." Example: Consider the following example... Dimension 0 (across) _ _ _ _ _ _ _ _ _ _ _ _ _ |_ 0 _|_ 0 _|_ 0 _|_...
stackexchange/codereview
This is ASP classic, not .Net. We have to get a way to SFTP into a server to upload and download a couple of files, kicked off by a user. What have other people used to do SFTP in ASP classic? Not necessarily opposed to purchasing a control.
stackexchange/codereview
I'm trying to maintain a Setup Project in Visual Studio 2003 (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to HKCU for every user on the computer. They need to be in the HKCU rather than HKLM because they are the default user settings, and they do change p...
stackexchange/codereview
What should I use to virtualize my desktop, vmx, xen, or vmware? Needs to work on a linux or windows host, sorry virtual pc. @Derek Park: Free as in speech, not beer. I want to be able to make a new virtual machine from my own licensed copies of windows, for that vmware is kind of expensive.
stackexchange/codereview
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on the client side when I press the Cancel button, which has the CausesValidation attribute set to "False". How can I get this to stop? I do not believe that Validation Groups are supported in 1.1. Here's a code sample: <asp:Te...
stackexchange/codereview
I have a library that reads/writes to a USB-device using CreateFile() API. The device happens to implement the HID-device profile, such that it's compatible with Microsoft's HID class driver. Some other application installed on the system is opening the device in read/write mode with no share mode. Which prevents my li...
stackexchange/codereview
I don't think this is possible just using the color setting in SpriteBatch, so I'm trying to work out a simple shader that would take every pixel and make it white, while respecting the alpha value of the pixel. The answer Joel Martinez gave looks right, but how do I incorporate that when I draw the sprite with SpriteB...
stackexchange/codereview
Besides "no connection", what other failure modes should I test for? How do I simulate a high-latency link, an unreliable link, or all the other sorts of crazy stuff that will undoubtedly happen "in the wild"? How about wireless applications? How do I test the performance in a less-than-ideal WL environment?
stackexchange/codereview
I'm building an application against some legacy, third party libraries, and having problems with the linking stage. I'm trying to compile with Visual Studio 9. My compile command is: cl -DNT40 -DPOMDLL -DCRTAPI1=_cdecl -DCRTAPI2=cdecl -D_WIN32 -DWIN32 -DWIN32_LEAN_AND_MEAN -DWNT -DBYPASS_FLEX -D_INTEL=1 -DIPLIB=none ...
stackexchange/codereview
I can never remember the differences in regular expression syntax used by tools like grep and AWK, or languages like Python and PHP. Generally, Perl has the most expansive syntax, but I'm often hamstrung by the limitations of even egrep ("extended" grep). Is there a site that lists the differences in a concise and easy...
stackexchange/codereview
I've been making a concerted effort to improve my javascript skills lately by reading as much javascript code as I can. In doing this I've sometimes seen the javascript: prefix appended to the front of event handler attributes in HTML element tags. What's the purpose of this prefix? Basically, is there any appreciable ...
stackexchange/codereview
Compare String.Format("Hello {0}", "World"); with "Hello {0}".Format("World"); Why did the .Net designers choose a static method over an instance method? What do you think?
stackexchange/codereview
In evaluating different systems integration strategies, I've come across some words of encouragement, but also some words of frustration over BizTalk Server. What are some pros and cons to using BizTalk Server (both from a developer standpoint and a business user), and should companies also consider open source altern...
stackexchange/codereview
I have a PHP application that displays a list of options to a user. The list is generated from a simple query against SQL 2000. What I would like to do is have a specific option at the top of the list, and then have the remaining options sorted alphabetically. For example, here's the options if sorted alphabetically:...
stackexchange/codereview
Does anyone have any practical suggestions about how to manage feature creep in GUIs? I'm getting strong pressure from both internal and external sources to add, modify, tweak, etc. I always cringe when someone approaches me with the words "wouldn't it be nice if...?". I can't just turn around and yell "NO" at them, b...
stackexchange/codereview
I have a counter in hardware that I can observe for timing considerations. It counts miliseconds and is stored in a 16 bit unsigned value. How do I safely check if a timer value has passed a certain time and safely handle the inevitable rollover: //this is a bit contrived, but it illustrates what I'm trying to do const...
stackexchange/codereview
You have an ascending list of numbers, what is the most efficient algorithm you can think of to get the ascending list of sums of every two numbers in that list. Duplicates in the resulting list are irrelevant, you can remove them or avoid them if you like. To be clear, I'm interested in the algorithm. Feel free to p...
stackexchange/codereview
I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match. How I can replace all the URL? I guess I should be using the exec command, but I did not really figure how to do it. function repla...
stackexchange/codereview
I build up an array of strings with string[] parts = string.spilt(" "); And get an array with X parts in it, I would like to get a copy of the array of strings starting at element parts[x-2] Other than the obvious brute force approach (make a new array and insert strings), is there a more elegant way to do this in C...
stackexchange/codereview
What's the best way to allow a user to browse for a file in C#?
stackexchange/codereview
SQL: 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
stackexchange/codereview
I have designed database tables (normalised, on an MS SQL server) and created a standalone windows front end for an application that will be used by a handful of users to add and edit information. We will add a web interface to allow searching accross our production area at a later date. I am concerned that if two user...
stackexchange/codereview
I'm trying to setup CruiseControl.net at the moment. So far it works nice, but I have a Problem with the MSBuild Task. According to the Documentation, it passes CCNetArtifactDirectory to MSBuild. But how do I use it? I tried this: <buildArgs> /noconsolelogger /p:OutputPath=$(CCNetArtifactDirectory)\test </buildArgs>...
stackexchange/codereview
I was curious about how other people use the this keyword. I tend to use it in constructors, but I may also use it throughout the class in other methods. Some examples: In a constructor: public Light(Vector v) { this.dir = new Vector(v); } Elsewhere public void SomeMethod() { Vector vec = new Vector(); dou...
stackexchange/codereview
Suppose I have the following CSS rule in my page: body { font-family: Calibri, Trebuchet MS, Helvetica, sans-serif; } How could I detect which one of the defined fonts were used in the user's browser? For people wondering why I want to do this is because the font I'm detecting contains glyphs that are not availabl...
stackexchange/codereview
Is there an easy way to produce MSDN-style documentation from the Visual Studio XML output? I'm not patient enough to set up a good xslt for it because I know I'm not the first person to cross this bridge. Also, I tried setting up sandcastle recently, but it really made my eyes cross. Either I was missing something ...
stackexchange/codereview
I've been using Subversion for a few years and after using SourceSafe, I just love Subversion. Combined with TortoiseSVN, I can't really imagine how it could be any better. Yet there's a growing number of developers claiming that Subversion has problems and that we should be moving to the new breed of distributed ve...
stackexchange/codereview
I was wondering if there is an open source library or algorithm that can expand a non-numeric range. For example, if you have 1A to 9A you should get 1A, 2A, 3A, 4A, 5A, 6A, 7A, 8A, 9A. I've tried Googling for this and the best I could come up with were Regex that would expand numerics with dashes (1-3 becoming 1,2,...
stackexchange/codereview
Particularly, what is the best snippets package out there? Features: easy to define new snippets (plain text, custom input with defaults) simple navigation between predefined positions in the snippet multiple insertion of the same custom input accepts currently selected text as a custom input cross-platform (Windows, ...
stackexchange/codereview
I've just created a new Windows XP VM on my Mac using VMware Fusion. The VM is using NAT to share the host's internet connection. How do I access a Rails application, which is accessible on the Mac itself using http://localhost:3000?
stackexchange/codereview
Are PHP variables passed by value or by reference?
stackexchange/codereview
Does anyone know how IE7 determines what Security Zone to use for a site? I see the basics for IE6 here, but I can't find the equivalent for IE7.
stackexchange/codereview
I've read the Wikipedia articles for both procedural programming and functional programming, but I'm still slightly confused. Could someone boil it down to the core?
stackexchange/codereview
Does Django have any template tags to generate common HTML markup? For example, I know that I can get a url using {% url mapper.views.foo %} But that only gives me the URL and not the HTML code to create the link. Does Django have anything similar to Rails' link_to helper? I found django-helpers but since this is a co...
stackexchange/codereview
Does anybody know how to get local path of file cached by Firefox based on its URL from an XPCOM component?
stackexchange/codereview
After trying to avoid JavaScript for years, Iv started using Query for validation in MVC asp.net, as there does not seem to be an official way of doing validation, Iv been surprised how good jQuery is. Firstly is there a way to get intellisense working for jQuery and its validation plugin, so that i don have to learn ...
stackexchange/codereview
How do you debug PHP scripts? I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in PHPEclipse is also quite useful. What is the best (in terms of fast and easy) way to debug in phpStorm or any other IDE?
stackexchange/codereview
What is the best approach to calculating the largest prime factor of a number? I'm thinking the most efficient would be the following: Find lowest prime number that divides cleanly Check if result of division is prime If not, find next lowest Go to 2. I'm basing this assumption on it being easier to calculate the sma...
stackexchange/codereview
Where can I get some decent looking free ASP.Net or CSS themes?
stackexchange/codereview