instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
When creating a class that has internal private methods, usually to reduce code duplication, that don't require the use of any instance fields, are there performance or memory advantages to declaring the method as static? Example: foreach (XmlElement element in xmlDoc.DocumentElement.SelectNodes("sample")) { string...
stackexchange/codereview
Is it possible to create Eclipse plugins that auto-discover eachother? I am developing a set of plugins that need to operate in two primary situations: individually in concert with each other. When run individually, the plugins should "just work" but when in concert, they will be sharing some of the same model conten...
stackexchange/codereview
Simplified, I have an application where data is intended to flow over the internet between two servers. Ideally, I'd like to test at what point the software ceases to function. At what lowerbound limit (bandwidth, latency, dropped packets) do things stop working to test the reliability of the software. What I thought I...
stackexchange/codereview
I cureently have a set up like below Public ClassA property _classB as ClassB End Class Public ClassB property _someProperty as someProperty End Class what I want to do is to databind object A to a gridview with one of the columns being databound to ClassB._someProperty. When I try to databind it as Classb._...
stackexchange/codereview
I'm working on a project for my school on rails (don't worry this is not graded on code) and I'm looking for a clean way to traverse relationships in ActiveRecord. I have ActiveRecord classes called Users, Groups and Assignments. Users and Groups have a HABTM relationship as well as Groups and Assignments. Now what I n...
stackexchange/codereview
I have a Dictionary where I hold data for movieclips, and I want the data to be garbage collected if I stop using the movieclips. I'm using the weak keys parameters, and it works perfectly with other data, however I've run into a problem. This code works great: var mc = new MovieClip(); var dic = new Dictionary(true);...
stackexchange/codereview
I am trying to send my dynamically created silverlight 2 page/image to a an ASP.net web service to render it as an bitmap image. I can see many examples how to get the XAML using javascript (see here) in version 1 of silverlight but I have a few differences. a) I am using silverlight 2 RC1 b) I have dynamically add co...
stackexchange/codereview
I'm experimenting with Latent Dirichlet Allocation for topic disambiguation and assignment, and I'm looking for advice. Which program is the "best", where best is some combination of easiest to use, best prior estimation, fast How do I incorporate my intuitions about topicality. Let's say I think I know that some ite...
stackexchange/codereview
I have these two pieces of code, wich one is more readable? foreach decimal technicalPremium = 0; foreach (Risk risk in risks) { technicalPremium = technicalPremium + risk.TechnicalPremium; } return technicalPremium; linq return risks.Sum(risk => risk.TechnicalPremium);
stackexchange/codereview
I have a stored procedure that returns 80 columns, and 300 rows. I want to write a select that gets 2 of those columns. Something like SELECT col1, col2 FROM EXEC MyStoredProc 'param1', 'param2' When I used the above syntax I get the error: "Invalid Column Name". I know the easiest solution would be to change th...
stackexchange/codereview
I have stfw but I cannot find a simple / standalone way to create a webservice client in java. Does anyone have a link/sample into this?
stackexchange/codereview
I want to write a script, to be packaged into a gem, which will modify its parameters and then exec a new ruby process with the modified params. In other words, something similar to a shell script which modifies its params and then does an exec $SHELL $*. In order to do this, I need a robust way of discovering the pa...
stackexchange/codereview
I am adding series and panes to a Developer's Express Chart Control in code on a windows form application. I would like to only show the x-axis labels for the first pane. The showInPanes property is telling me it is read only. How do I set this propert in code?
stackexchange/codereview
I've heard that the automotive industry has something called MISRA C. What are the relevant standards for other high reliability/availability/security industries, such as Space Aircraft Banking/financial Automotive Medical Defense/Military ??? -Adam
stackexchange/codereview
I have to write a component that re-creates SQL Server tables (structure and data) in an Oracle database. This component also has to take new data entered into the Oracle database and copy it back into SQL Server. Translating the data types from SQL Server to Oracle is not a problem. However, a critical difference be...
stackexchange/codereview
I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields. Here's my models.py: class Tech(models.Model): name = models.CharField(max_length = 30) class Project(models.Model): title = models.CharField(max_length = 50) techs = m...
stackexchange/codereview
If I have a string (010) and i want to add 1 to it (011) what value type should i use to convert this string into a number for adding and at the same time preserve the whole number and not 10 + 1 = 11.
stackexchange/codereview
Ok, I love Resharper and its addins, but even the best of fanbois have to admit that its API documentation is suboptimal. I'd like to build an addin myself (based on the Agent Johnson plugin). Thankfully that plugin works in 4.0, so I can use it as a starting point for my own work. My question: how do I run and debug t...
stackexchange/codereview
I am trying to create a new instance of Excel using VBA using: Set XlApp = New Excel.Application The problem is that this new instance of Excel doesn't load all the addins that load when I open Excel normally...Is there anything in the Excel Application object for loading in all the user-specified addins? I'm not tryi...
stackexchange/codereview
I develop a number of desktop Java applications using Swing, and while Swing is quite powerful (once you get the hang of it), there are still a lot of cases where I wish some advanced component was available right out of the box. For example, I'd really like to see easy-to-use components (without writing them myself, w...
stackexchange/codereview
At work we have two competing theories for salts. The products I work on use something like a user name or phone number to salt the hash. Essentially something that is different for each user but is readily available to us. The other product randomly generates a salt for each user and changes each time the user chan...
stackexchange/codereview
So, I have an autocomplete dropdown with a list of townships. Initially I just had the 20 or so that we had in the database... but recently, we have noticed that some of our data lies in other counties... even other states. So, the answer to that was buy one of those databases with all towns in the US (yes, I know, geo...
stackexchange/codereview
I have a legacy application that I needed to implement a configuration page for to change text colors, fonts, etc. This applications output is also replicated with a PHP web application, where the fonts, colors, etc. are configured in a style sheet. I've not worked with CSS previously. Is there a programatic way to mod...
stackexchange/codereview
given a matrix of distances between points is there an algorithm for determining a set of n-dimensional points that has these distances? (or at least minimises the error) sort of like a n-dimensional version of the turnpike problem. The best I can come up with is using multidimensional scaling.
stackexchange/codereview
I am writing a Time Sheeting web application that involves users entering their tasks for the week. I would like not to have the page refresh so I am exploring ways to add/delete/edit tasks using JavaScript on the client browser. Currently I am using ASP.NET-MVC, Ajax, JQuery and LiveValidation and I am make steady (i...
stackexchange/codereview
Would it be wwwroot, C, the root virtual directory where the assets are hosted, or the same folder that the assets are in? Meaning if I have a virtual directory 'virdir' with a sub directory 'swf', which is really like C:\somedir\assets\swf\, where would the crossdomain.xml need to go so that my swf app on a different ...
stackexchange/codereview
What are the Win32 APIs to use to programically delete files and folders? Edit DeleteFile and RemoveDirectory are what I was looking for. However, for this project I ended up using SHFileOperation. I found the sample code at CodeGuru helpful.
stackexchange/codereview
i know this doesnt work but i dont know why, also how can i make it work? <% int result = referer.indexOf("smlMoverDetail.do"); %> <% if (result == -1){%> <%out.print("checking");%> <bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate" type="java.lang.String" toScope="session"/> <%...
stackexchange/codereview
I have tree tables, Customer, Invoice and InvoiceRow with the standard relations. These I have to export in one fixed field length file with the first two characters of each row identifying the row type. The row types have different specifications. I could probably do it with a nested loop in a script block, but this ...
stackexchange/codereview
Can anyone recommend a good Source Code control (SCC) that works for the mostly disconnected consultant? I'd prefer something that allows one to save into a local repository and then once connected 'syncs' to the server however I've never seen such a feature. Suggestions? [Windows solution is preferred that integrates ...
stackexchange/codereview
I have a polygon soup of triangles that I would like to construct a BSP tree for. My current program simply constructs a BSP tree by inserting a random triangle from the model one at a time until all the triangles are consumed, then it checks the depth and breadth of the tree and remembers the best score it achieved (...
stackexchange/codereview
I have a VB.net control that has an event: Public Event PassNames(ByVal names() as String) When the event triggered in VB6, I get the following error: "Function or interface marked as restriced, or the function uses an Automation type not supported in Visual Basic" Here is the event in VB6: Private Sub IteropControl1...
stackexchange/codereview
Dependency injection seems to be a good thing. In general, should dependencies be injected at the methods that require them, or should they be injected in the contructor of the class? See the samples below to demonstrate the two ways to inject the same dependency. //Inject the dependency into the methods that require ...
stackexchange/codereview
I have an array NSMutableArray with happy objects. These objects viciously turn on (leak) me whenever I try to clear the array of all the objects and repopulate it. It's allocated in the init function like so self.list = [NSMutableArray array]; The different methods I have used to clear it out include: self.list = nil...
stackexchange/codereview
What Abstract Datatypes should be added to OpenJDK7 ?
stackexchange/codereview
I am using a Q3Table object and wanted to change the width of the vertical header column. Does anyone know how to do this? It seems I can only adjust the height of the header cell but not the width.
stackexchange/codereview
Is it currently possible to translate C# code into an Abstract Syntax Tree? Edit: some clarification; I don't necessarily expect the compiler to generate the AST for me - a parser would be fine, although I'd like to use something "official." Lambda expressions are unfortunately not going to be sufficient given they don...
stackexchange/codereview
I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently. Our production code contains no asserts whatsoever and my question is this... Should I begin using ...
stackexchange/codereview
I am developing a specialty application where the end-user needs to operate multiple controls simultaneously. The application is used to "tune" the control parameters of an electronic device to calibrate the unit to its best performance. Currently, there is a UI with multiple graphical sliders which the operator click...
stackexchange/codereview
I'm having trouble dynamically adding controls inside an update panel with partial postbacks. I've read many articles on dynamic controls and I understand how to add and maintain them with postbacks but most of that information doesn't apply and won't work for partial postbacks. I can't find any useful information abou...
stackexchange/codereview
So, I've started to create some Ruby unit tests that use Selenium RC to test my web app directly in the browser. I'm using the Selenum-Client for ruby. I've created a base class for all my other selenium tests to inherit from. This creates numerous SeleniumDriver instances and all the methods that are missing are cal...
stackexchange/codereview
Some text before the code so that the question summary isn't mangled. class Tree { public event EventHandler MadeSound; public void Fall() { MadeSound(this, new EventArgs()); } static void Main(string[] args) { Tree oaky = new Tree(); oaky.Fall(); } } I haven't used events much in...
stackexchange/codereview
I have a WPF ListView which currently scrolls everytime I click on an item which is only partially visible. How can I keep the control from scrolling that item into view (instead simply selecting the partially visible one)? This behavior is very annoying when doing a drag from this control. Thanks. Added: I am lo...
stackexchange/codereview
My main JavaScript framework is jQuery, so I would like my unit test and mocking frameworks to be compatible with that. I'd rather not have to introduce another JavaScript framework. I am currently using QUnit for unit testing and Jack for mocking, but I am pretty new to the whole unit testing of JavaScript. Is there a...
stackexchange/codereview
I'm working on a Java library and would like to remove some functions from it. My reasons for this is public API and design cleanup. Some objects have setters, but should be immutable, some functionality has been implemented better/cleaner in different methods, etc. I have marked these methods 'deprecated', and would l...
stackexchange/codereview
I'm experimenting with the iPhone SDK and doing some TDD ala Dr. Nic's rbiPhoneTest project. I'm wondering how many, if any, have been successful using this or any other testing framework for iPhone/Cocoa? More important, I'd like to know how to best assert a proprietary binary request/response protocol. The idea is to...
stackexchange/codereview
Flex Builder often fails to connect to the app that it's supposed to debug. After a minute or so it times-out and says that it couldn't connect. The only way I can get it to stop doing this is by restarting Eclipse. Very annoying. Anyone know why this is? I'm using FB 3.1 and Firefox on Win XP. Many thanks!
stackexchange/codereview
Is there a macro that does it? Which DTE objects to use?
stackexchange/codereview
Okay, I am sure this is simple but it is driving me nuts. I recently went to work on a program where I have had to step back in time a bit and use Redhat 9. When I'm typing on the command line from a standard xterm running KornShell (ksh), and I reach the end of the line the screen slides to the right (cutting off the ...
stackexchange/codereview
My ideal situation for logging in our web service would be to log all the method calls (authentication as well as data access) with the parameters passed to them as well as errors that may have occured, and have them linked with a single ID that associates them with the same call. In addition, I'd ideally like to be a...
stackexchange/codereview
How do I set gc.reflogExpire so that items will never expire? What other time interval formats does it accept? The man page says that you can set it to "90 days or 3 months," but doesn't specify what format it expects.
stackexchange/codereview
How do you track outbound links for your web site, since the request is logged on the destination server, not yours?
stackexchange/codereview
Basically I am looking to accomplish something similar to the affect that yelp uses to have the map follow you down the page on their search results page but I'd rather have it be instantaneous rather than have it catch up a few seconds after you scroll. I also don't want to just set the position to "fixed" because I ...
stackexchange/codereview
How do you post data to an iframe?
stackexchange/codereview
It's hard to search for D using Google, so I wasn't able to find a good answer: I have an old iBook G3 and I'd like to install Linux on it and use it to compile (and test) D programs written using Tango on it. Is this possible? Or hasn't anybody tried it, yet? After all the Mac port of GDC + Tango is broken in parts, t...
stackexchange/codereview
I would like to know how to make use of an Axiom database resource inside a Safe function. Right now I'm just handling the connection manually but I know it would be better to use the already defined resources.
stackexchange/codereview
Boost range library (http://www.boost.org/doc/libs/1_35_0/libs/range/index.html) allows us to abstract a pair of iterators into a range. Now I want to combine two ranges into one, viz: given two ranges r1 and r2, define r which traverses [r1.begin(), r1.end()[ and then [r2.begin(), r2.end()[. Is there some way to defin...
stackexchange/codereview
I need to find occurrences of ~ 25 000 words within a text. What is the most suitable algorithm/library for this purpose? target language is C++
stackexchange/codereview
I need to store the summer time (daylight saving time) change-over rules for different world regions in a database. I already have a way of storing regions and sub-regions (so the whole "half of Australia"/Arizona/Navaho problem is taken care of), but I'm wondering what the most efficient schema would be to accomplish...
stackexchange/codereview
Scenario: Currently we have a single solution supporting a single deployable entity, a WinForm/WPF client, this solution has a layer architecture with projects representing various layers (Data, Business, UI). We will be introducing other deployable entities such as a LiteClient, a Server and an RIA. We are considering...
stackexchange/codereview
I am currently working with 2 sql 2000 servers one I can query but not add any databases to which lead to the second one having lots of queries that use the first as a linked server. I would like to improve performance while still querying live data. Is it possible to mirror the live data to the second server, that way...
stackexchange/codereview
How do I get a list of all the tables defined for the database when using active record?
stackexchange/codereview
I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line. Something like: FooBar := Foo(Bar); SimulateBreakPoint; // Cause break point ...
stackexchange/codereview
Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do this: jeremy@jeremy-desktop:~$ ps aux | grep firefox jeremy 7451 25.0 27.4 170536 65680 ? Sl 22:39 1:18 /usr/lib/firefox-3.0.1/firefox jeremy 7578 0.0 0.3 3004 768 pts/0 S+ 22:44 0:00 grep...
stackexchange/codereview
I am looking for an easily digestible book to present to my boss/team. Background info: More and more of our meetings at work involve my boss/team pondering how to implement more "best practices" around here. ("Here" = a very small application development shop. 4 developers) The following things are items that my wh...
stackexchange/codereview
I am looking hard at the basic principles of storing the state of an executing program to disk, and bringing it back in again. In the current design that we have, each object (which is a C-level thingy with function pointer lists, kind of low-level home-made object-orientation -- and there are very good reasons for do...
stackexchange/codereview
I tried doing this: root.addEventListener("click", function () { navigateToURL(ClickURLRequest,"_self"); }); And it does add the event listener. I like using closures because they work well in this situation, however, removing the event listener requires a reference to the original function, and sin...
stackexchange/codereview
What is the best way to get a file (in this case, a .PDF, but any file will do) from a WebResponse and put it into a MemoryStream? Using .GetResponseStream() from WebResponse gets a Stream object, but if you want to convert that Stream to a specific type of stream, what do you do?
stackexchange/codereview
Is there a standard idiom for comparing version numbers? I can't just use a straight String compareTo because I don't know yet what the maximum number of point releases there will be. I need to compare the versions and have the following hold true: 1.0 < 1.1 1.0.1 < 1.1 1.9 < 1.10
stackexchange/codereview
Is there an efficient way of detecting if a jpeg file is corrupted? Background info:   solutions needs to work from within a php script   the jpeg files are on disk   manual checking is no option (user uploaded data) I know that imagecreatefromjpeg(string $filename); can do it. But it is quite slow at doing so. Doe...
stackexchange/codereview
How have you used the Exception.Data property in C# projects that you've worked on? I'd like answers that suggest a pattern, rather than those that are very specific to your app.
stackexchange/codereview
How can I copy and paste in irb (Interactive Ruby Shell) on Windows?
stackexchange/codereview
Can this be done? How? I want to write my own extension. Can Get the current page sorcecode in my own extension?
stackexchange/codereview
Wondering if I need to do something in my swf to be able to access the assets on a different server, meaning more than just specify the url to the asset. Will flash handle the 'go get crossdomain.xml and authenticate everything' behind the scenes or do I need to include some special code beyond simply requesting the sw...
stackexchange/codereview
For a single-server LAMP site (which is usually under quite high load), what is best way to use memcache? Does it make sense to run the memcache daemon on the same server as the application, or is that just going to take valuable memory away from MySQL, giving a net performance loss. Does it even make sense to use me...
stackexchange/codereview
I know how to write trace statements that I can view in a webforms environment, but how do I do this in a windows forms app? I am inside of a static method, and I want to display the sql query that it is generating. I don't have access to messagebox.show, what are my options?
stackexchange/codereview
http://developer.yahoo.com/javascript/howto-proxy.html Are there disadvantages to this technique? The advantage is obvious, that you can use a proxy to get XML or JavaScript on another domain with XMLHttpRequest without running into same-origin restrictions. However, I do not hear about disadvantages over other methods...
stackexchange/codereview
What do you do to pass information between forms? Forward is straight forward (sorry) using Properties or maybe parameters in a New() or DoStuff() method, but what about sending something back when the user is done with the second form? (IE. ID of the item selected) We have used all these: Passed the calling form in...
stackexchange/codereview
I have the following code fragment that starts a Google Earth process using a hardcoded path: var process = new Process { StartInfo = { //TODO: Get location of google earth executable from registry FileName = @"C:\Program Files\Google\Googl...
stackexchange/codereview
I have a question about how to deploy WPF application into a PC without Framework 3.5. If a PC just installs Windows XP and sp3, Is it possible to design a setup package that can install WPF Application directly on this PC? The situation is like this: I designed a simple WPF Application. And I want to get its setup pa...
stackexchange/codereview
I have implemented a python webserver. Each http request spawns a new thread. I have a requirement of caching objects in memory and since its a webserver, I want the cache to be thread safe. Is there a standard implementatin of a thread safe object cache in python? I found the following http://freshmeat.net/projects/l...
stackexchange/codereview
How do I view the SQL that is generated by nHibernate? version 1.2
stackexchange/codereview
I want to record user states and then be able to report historically based on the record of changes we've kept. I'm trying to do this in SQL (using PostgreSQL) and I have a proposed structure for recording user changes like the following. CREATE TABLE users ( userid SERIAL NOT NULL PRIMARY KEY, name VARCHAR(40), ...
stackexchange/codereview
I've never been so good at design because there are so many different possibilities and they all have pros and cons and I'm never sure which to go with. Anyway, here's my problem, I have a need for many different loosly related classes to have validation. However, some of these classes will need extra information to do...
stackexchange/codereview
HTML (or maybe just XHTML?) is relatively strict when it comes to non-standard attributes on tags. If they aren't part of the spec, then your code is considered non-compliant. Non-standard attributes can be fairly useful for passing along meta-data to Javascript however. For instance, if a link is suppose to show a pop...
stackexchange/codereview
I have installed CherryPy 3.1.0,. Here is what happens when I try to run tutorial 9: $ cd /Library/Python/2.5/site-packages/cherrypy/tutorial/ $ python tut09_files.py Traceback (most recent call last): File "tut09_files.py", line 48, in <module> from cherrypy.lib import static ImportError: cannot import name stat...
stackexchange/codereview
I have been adding dependency injection to my code because it makes by code much easier to Unit test through mocking. However I am requiring objects higher up my call chain to have knowledge of objects further down the call chain. Does this break the Law of Demeter? If so does it matter? for example: a class A has a de...
stackexchange/codereview
I have a client who is still using Visual Studio 6 for building production systems. They write multi-threaded systems that use STL and run on mutli-processor machines. Occasionally when they change the spec of or increase the load on one of their server machines they get 'weird' difficult to reproduce errors... I kno...
stackexchange/codereview
Can you recommend peer reviewed libraries that I can use in C environment (something like Boost for C++) ? Something that provides hash, thread, interprocess communications, lists, smart memory management... The environment is embedded system, not a very minimal system, but also not a PC!
stackexchange/codereview
Is there a maximum length when using window.returnValue (variant) in a modal? I am calling a modal window using showModalDialog() and returning a comma delimited string. After selecting a group of users, I am putting them into a stringbuilder to display in a literal. Dim strReturn As New StringBuilder strReturn.Appe...
stackexchange/codereview
Before you answer, this question is complicated: We are developing in asp.net / asp.net mvc / jQuery but I'm open to solutions on any platform using any framework I think logic like sorting / hiding columns / re-arranging columns / validation (where it makes sense) should be on the client-side I think logic like searc...
stackexchange/codereview
I need to do a comparaison between an object and NULL. When the object is not NULL I fill it with some data. Here is the code : if (region != null) { .... } This is working but when looping and looping sometime the region object is NOT null (I can see data inside it in debug mode). In step-by-step when debugging,...
stackexchange/codereview
I'm using LINQ to SQL and C#. I have two LINQ classes: User and Network. User has UserID (primary key) and NetworkID Network has NetworkID (primary key) and an AdminID (a UserID) The following code works fine: user.Network.AdminID = 0; db.SubmitChanges(); However, if I access the AdminID before making the change, t...
stackexchange/codereview
In Ruby: for i in A do # some code end is the same as: A.each do |i| # some code end for is not a kernel method: What exactly is "for" in ruby Is there a way to use other keywords to do similar things? Something like: total = sum i in I {x[i]} mapping to: total = I.sum {|i] x[i]}
stackexchange/codereview
I want to display a list of images (instead of text) for the user to choose from. The control is databound (the URLs come from the database) Instead of the typical vertical scroll bar in a listbox, I want this box to be horizontal. I'm looking for an ASP.NET server control similar to this: http://www.infragistics.com/d...
stackexchange/codereview
When are custom Exception classes most-valuable? Are there cases when they should or should not be used? What are the benefits? Related questions: Performace Considerations for throwing Exceptions Do you write exceptions for specific issues or general exceptions?
stackexchange/codereview
I would like to ask you which automated build environment you consider better, based on practical experience. I'm planning to do some .Net and some Java development, so I would like to have a tool that supports both these platforms. I've been reading around and found out about CruiseControl.NET, used on stackoverflow d...
stackexchange/codereview
I am interested to read and understand the 2D mesh algorithms. A search on Google reveals a lot of papers and sources, however most are too academic and not much on beginner's side. So, would anyone here recommend any reading sources ( suitable for the beginners), or open source implementation that I can learn from th...
stackexchange/codereview
I'm working on trying to generate a report from a couple of database tables. The simplified version looks like this Campaign ---------- CampaignID Source ----------------------- Source_ID | Campaign_ID Content --------------------------------------------------------- Content_ID | Campaign_ID | Content_Row_ID | Conten...
stackexchange/codereview
I am using DevPartner (for Java) with pretty good results. However, there's a "metric publishing" utility which I can't use. The problem is that said utility (pubmetrics.exe) asks for a site/port/user/password combination which I don't know. It pre-fills the site/port data with the localhost and thus I assume it's try...
stackexchange/codereview