instruction
stringlengths
0
30k
It depends on the complexity of your query. If you're retrieving the data once, then doing a table scan is faster. However, if you're going back to the table more than once for related information in the same query, then the index is faster. Another related strategy is to do the table scan, and put all the data ...
|python|
What is the best way to go about calling a function given a string with the function's name in a python program. For example, let's say that I have a module foo, and I have a string whose contents are "bar". What is the best way to go about calling foo.bar()? I need to get the return value of the function, which i...
Maybe I'm crazy but worrying about speed in cases like this using an interpretive language is like trying to figure out what color to paint the shed. Let's not even get into the idea that this kind of optimization is entirely pre-mature. You hit the nail on the head when you said 'maintainability'. I'd choose the ap...
Bottom line: no, because the overhead of interpretation is greater than the overhead of method dispatching. As I heard someone observe a while back: "I used to worry about the overhead of a virtual function. Then I started programming in Tcl."
Bottom line: no, because the overhead of interpretation overwhelms the overhead of method dispatching.
If you are using an interpreted language, the difference is irrelevant. You should not be using an interpreted language if performance is an issue. Both will perform about the same.
Assuming module 'foo' with method 'bar': import foo methodToCall = getattr(foo, 'bar') result = methodToCall() As far as that goes lines 2 and three can be compressed to: result = getattr(foo, 'bar')() if that makes more sense for your use case. You can use getattr in this fashion on clas...
I always use method 2 as well. The only benefit of using each is if you're just reading (rather than re-assigning) the value of the hash entry, you're not constantly de-referencing the hash.
The official size is 57x57. I would recommend using the exact size simply due to the fact that it takes less memory when loaded (unless Apple caches the scaled representation). With that said, [Rex is right](http://stackoverflow.com/questions/1598/what-are-the-correct-pixel-dimensions-for-an-apple-touch-icon#1599) that...
If you're mostly concerned with data layer testing, you might want to check out this book: **xUnit Test Patterns: Refactoring Test Code**. I was always unsure about it myself, but this book does a great job to help enumerate the concerns like performance, reproducibility, etc.
Can ASP.NET AJAX partial rendering work inside a SharePoint 2007 application page?
|ajax|sharepoint|
I have a simple page with my ScriptManager and my UpdatePanel, and my ContentTemplate has one ListBox and one Label. I am just trying to catch its OnSelectionChanged so I can update the text in the Label. No matter what settings I try to tweak, I always get a full-page postback. Is this really not going to work, o...
|unix|filesystems|
Have you looked at Wikipedia's [Category:Computational problems][1] and [Category:NP Complete Problems][2] pages? It's probably not complete, but they look like good starting points. Wikipedia seems to do pretty well in CS topics. [1]: http://en.wikipedia.org/wiki/Category:Computational_problems [2]: http://e...
I did subclass and it was easy and did work. I still don't like it so much. I was already subclassing column styles for other reasons. I'd rather handle all databinding myself, where I can more easily change it and test it. This whole mixing of the UI with the data is old school, and not it a good way. Thanks fo...
A lot of times I'll use client alias to point an application at a different sql server than the ones it's connection string is for, esp. handy when working on DTS or an application with a hard coded connection string. Have everybody use a commonly named alias, use the alias in the connection string and point the alias’...
We are a C++ shop, that is moving to C# for UI work (our image processing and 3D graphics code will stay in native C++). I found [C# for C++ Developers][1] a very quick and handy introduction to the language. Our team has been using Visual Studio for while, whereas I came from an SVN/Slickedit/CMake/Ant kind of environ...
Microsoft has a page which gives several examples of writing scripts to "drive" MS Word. [One such example][1] shows how to convert from a Word document to HTML. By changing the last parameter to any values listed [here][2], you can get the output in different formats. [1]: http://www.microsoft.com/technet/scr...
**There's no easy way to find out the memory size of a python object**. One of the problems you may find is that Python objects - like lists and dicts - may have references to other python objects (in this case, what would your size be? The size containing the size of each object or not?). There are some pointers overh...
A better design is to make this class release the expensive resource on its own, before its disposed. For example, If its a database connection, only connect when needed and release immediately, long before the actual class gets disposed.
You would use what is known as an iterative recursive function, which is O(N) in time as it takes N iterations to complete and O(1) in space as each function it holds its own state in the function arguments. (define (reverse sentence-to-reverse) (reverse-iter (sentence-to-reverse "")) (define...
You would use what is known as an iterative recursive function, which is O(N) in time as it takes N iterations to complete and O(1) in space as each function it holds its own state in the function arguments. (define (reverse sentence-to-reverse) (reverse-iter (sentence-to-reverse "")) (define...
You would use what is known as an iterative recursive function, which is O(N) in time as it takes N (N being the number of words) iterations to complete and O(1) in space as each iteration holds its own state within the function arguments. (define (reverse sentence-to-reverse) (reverse-iter (sentence-to...
|c|memory-management|
|c|memory|
How to dispose a class in .net?
|.net|class|dispose|
The .net garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class <b>myclass</b> to call myclass.dispose and free up all the used space by variables and objects in <b>myclass</b>?
|.net|memorymanagement|
The .net garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class <b>myclass</b> to call myclass.dispose and free up all the used space by variables and objects in <b>myclass</b>? <hr/> **NOTE**: Several users have ind...
|.net|memory-management|
The .net garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class <b>myclass</b> to call myclass.dispose and free up all the used space by variables and objects in <b>myclass</b>?
|.net|memory-management|dispose|
|.net|memory|dispose|
PreviousPage property "The System.Web.UI.Page representing the page that transferred control to the current page." very useful
try clearing your local VS cache. find your project and delete the folder. the folder is created by VS for what reason I honestly don't understand. but I've had several occasions where clearing it and doing a re-build fixes things... hope this is all that you need as well. here C:\Documents and Settings\Administrato...
it would make deployment easier for clients that use godaddy where the database isn't in the app_data folder. also backing up those websites would be as simple as FTP the entire thing. i have concerns about possible collisions on saving. especially if I add something as simple as a click counter to say a list of mp...
On Unix systems you can use [mlock(2)](http://linux.die.net/man/2/mlock) to lock memory pages into RAM, preventing them being paged. > mlock() and mlockall() respectively lock part or all of the calling > process’s virtual address space into RAM, preventing that memory from > being paged to the swap area. There...
Yeah, the built-in [`isNaN(object)`][1] will be much faster than any regex parsing. Although the results are somewhat different to what you're looking for ([try it][2]): document.write(!isNaN('-1') + "<br />"); document.write(!isNaN('-1.5') + "<br />"); document.write(!isNaN('0') + "<br />"); d...
Yeah, the built-in [`isNaN(object)`][1] will be much faster than any regex parsing, because it's built-in and compiled, instead of interpreted on the fly. Although the results are somewhat different to what you're looking for ([try it][2]): document.write(!isNaN('-1') + "<br />"); document.write(!isNaN('...
What Jason Pratt posted is correct. >>> class Test(object): ... def a(self): ... pass ... >>> def b(self): ... pass ... >>> Test.b = b >>> type(b) <type 'function'> >>> type(Test.a) <type 'instancemethod'> >>> type(Test.b) <type 'instance...
> malloc can return NULL if no memory is > available. You're not checking for > that. Right you are... I didn't think about that as I was monitoring the memory and it there was enough free. Is there any way for there to be available memory on the system but for malloc to fail? Either way...I will add that chec...
> malloc can return NULL if no memory is > available. You're not checking for > that. Right you are... I didn't think about that as I was monitoring the memory and it there was enough free. Is there any way for there to be available memory on the system but for malloc to fail? > Yes, if memory is fragmented. A...
What is the output of `which godi_confdir`? P.S. I remember having this exact same problem, but I don't remember precisely how I fixed it.
How do I do full-text searching in Ruby on Rails?
|ruby-on-rails|full-text-search|
I would like to do full-text searching of data in my Ruby on Rails application. What options exist?
Standards Document
|coding-style|
I am with writing a coding standards document for a team of about 15 with a load of between 10 and 15 projects a year. Amongst other sections (which I may post here as I get to them) I am writing a section on code formatting. So to start with, I think it wise that, for whatever reason, we establish some basic, consiste...
My 2cents, I am using eclipse for some months now with m2eclipse integration. It's easy to use and straight forward. Once you associate your project to maven and update the dependencies using m2eclipse, any change to pom.xml are reflected to entire project, even Java version definition causes it to be compiled in ri...
You can use Ferret (which is Lucene written in Ruby). It integrates seamless with Rails using the acts_as_ferret mixin. Take a look at "[How to Integrate Ferret With Rails][1]". A alternative is [Sphinx][2]. Kind Regards [1]: http://wiki.rubyonrails.org/rails/pages/HowToIntegrateFerretWithRails [2]: http:/...
Do you continue development in a branch or in the trunk?
|svn|version-control|releasing|
Suppose you're developing a software product that has periodic releases. What are the best practices with regard to branching and merging? Slicing off periodic release branches to the public (or whomever your customer is) and then continuing development on the trunk, or considering the trunk the stable version, tagging...
The easiest way would be to use Automation thru the Microsoft.Office.Interop.<Application> libraries. You can create an instance of a Word application, for example. There are methods attached to the Application object that will allow you to open and close documents, plus pretty much anything else you can accomplish i...
The trunk is generally the main development line. Releases are branched off and often times experimental or major work is done on branches then merged back to the trunk when it's ready to be integrated with the main development line.
The already mentioned [A List Apart][1] is really good. Another site I've used since I started web development is SitePoint.com. Here is their [CSS Reference][2]. If you want a good CSS book their's is one of my favorites. [1]: http://www.alistapart.com/ [2]: http://reference.sitepoint.com/css
I tend to take the "release branch" approach. The trunk is volatile. Once release time approaches, I'd make a release branch, which I would treat more cautiously. When that's finally done, I'd label/tag the state of the repository so I'd know the "official" released version. I understand there are other ways to d...
I'll add this [Url][1] to my post I found it today, it has some information regarding the subject but no real "performance" information. [1]: http://www.ibm.com/developerworks/web/library/wa-aj-jaxer/index.html?ca=dgr-jw64wa-aj-jaxer&S_TACT=105AGY46&S_CMP=GRsitejw64
Checklist for Database Schema Upgrades
|database|installation|version-control|
Having to upgrade a database schema makes installing a new release of software a lot trickier. What are the best practices for doing this? I'm looking for a checklist or timeline of action items, such as - shut down apps - modify schema - install new apps - restart db etc, showing how to minimize risk and ...
Having to upgrade a database schema makes installing a new release of software a lot trickier. What are the best practices for doing this? I'm looking for a checklist or timeline of action items, such as - 8:30 shut down apps - 8:45 modify schema - 9:15 install new apps - 9:30 restart db etc, showing how t...
You can use multiple inheritance in your html elements (e.g. `<div class="one two">`) but I'm not aware of a way of having constants in the CSS files themselves. This link (the first found when googling your question) seems to have a fairly indepth look at the issue: <http://icant.co.uk/articles/cssconstants/>
You should comma seperate each id or class for example: h1,h2 { color: #fff; }
It may not include files that you normally wouldn't see. Or, the files may be there, but you may be unable to see them when reopening the .zip file in explorer, because they are hidden. You may go into Tools->Folder Options, go to the View tab, and select the radio button to view hidden files and folders.
A write lock doesn't help if the file upload failed part way through and the sender hasn't tried resending (and relocking) the file yet.
Stack objects are handled automatically by the compiler. When the scope is left, it is deleted. { obj a; } // a is destroyed here When you do the same with a 'newed' object you get a memory leak : { obj* b = new obj; } b is not destroyed, so we lost the ability to recla...
I was recently wanting to put Drag and Drop functionality in my project and I hadn't come across this issue, but I was intrigued and really wanted to see if I could come up with a better method than the one described in the page you linked to. I hope I clearly understood everything you wanted to do and overall I think...
Elements can belong to more than one class, so you can do something like this: .DefaultBackColor { background-color: #123456; } .SomeOtherStyle { //other stuff here } .DefaultForeColor { color:#654321; } And then in the content portion somew...
In my opinion, trying to parse HTML with anything other than an HTML parser is just asking for a world of pain. HTML is a *really* complex language (which is one of the major reasons that XHTML was created, which is much simpler than HTML). For example, this: <HTML / <HEAD / <TITLE / > / ...
I don't have much PHP experience, although I'm using it at my current job. In general, I find that larger systems benefit from the readability and understandability that OO provides. But things like consistency (don't mix OO and non-OO) and your personal preferences (although only really on personal projects) are also ...
Can you be a bit more specific? For the example you give you need to use include in both ways. In case 1 you only include a file, in case 2 you need to include the class file (for instance user.class.php) to allow instantiation of the User class. It depends how the rest of the application is built, is it OO? Use OO...
There may be some confusion here about what "K&R C" is. The term refers to the language as documented in the first edition of "The C Programming Language." Roughly speaking: the input language of the Bell Labs C compiler from around 1969 to around 1988. Kernighan and Ritchie were involved in the ANSI standardization...
First of all the [itertools module](http://docs.python.org/lib/module-itertools.html) is incredibly useful for all sorts of cases in which an iterator would be useful, but here is all you need to create an iterator in python: > yield Isn't that cool? Yield can be used to replace a normal **return** in a function...
First of all the [itertools module](http://docs.python.org/lib/module-itertools.html) is incredibly useful for all sorts of cases in which an iterator would be useful, but here is all you need to create an iterator in python: > yield Isn't that cool? Yield can be used to replace a normal **return** in a function...
You can force the keyboard focus to stay on the TextBox by handling the PreviewLostKeyBoardFocus event like this: <TextBox PreviewLostKeyboardFocus="TextBox_PreviewLostKeyboardFocus" /> private void TextBox_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { ...
It obviously varies depending on languages and technologies. By the look of your example name space I am going to guess java, in which case <http://java.sun.com/docs/codeconv/> is a really good place to start. You might also want to look at something like maven's standard directory structure which will make all your ...
I can recommend Sphinx. Ryan Bates has a great [screencast][1] on using the Thinking Sphinx plugin to create a full-text search solution. [1]: http://railscasts.com/episodes/120-thinking-sphinx
Here's what I'd do : Put the data in a standard form (with no runat="server" attribute) and set the action of the form to post to the target off-site page. Before submitting I would submit the data to my server **using an XmlHttpRequest** and analyze the response. If the response means you should go ahead with the ...
[Side by side comparison table of three maven plugins.][1] [1]: http://docs.codehaus.org/display/MAVENUSER/Eclipse+Integration
Where I work we use the following guidelines: - Each IDisposable class **must** have a finalizer - Whenever using an IDisposable object, it must be used inside a "using" block. The only exception is if the object is a member of another class, in which case the containing class must be IDisposable and must call ...
Where I work we use the following guidelines: - Each IDisposable class **must** have a finalizer - Whenever using an IDisposable object, it must be used inside a "using" block. The only exception is if the object is a member of another class, in which case the containing class must be IDisposable and must call ...
I wound up just implementing the translation manually. The code's not too bad, but it did leave me wishing that they provided support for it directly. I could see such a method being useful in a lot of different circumstances. I guess that's why they added extension methods :)
I once was called upon to look at a mysql that had "stopped working". I discovered that the DB files were residing on a Network Appliance filer mounted with NFS2 and with a maximum file size of 2GB. And sure enough, the table that had stopped accepting transactions was exactly 2GB on disk. But with regards to the pe...
1. [Wikipedia Article](http://en.wikipedia.org/wiki/Inversion_of_control). To me, inversion of control is turning your sequentially written code and turning it into an delegation structure. Instead of your program explicitly controlling everything, your program sets up a class or library with certain functions to be ca...
You need to have Sharepoint 2007 service pack 1 -- or else there's no chance. (Sharepoint 2007 predates ajax 1.0 -- they built some support into service pack 1)
You need to have Sharepoint 2007 service pack 1 -- or else there's no chance. (Sharepoint 2007 predates ajax 1.0 -- they built some support into service pack 1) Next, from a trouble shooting point of view, test that the **exact** same code functions as expected when hosted in a regular asp.net page. (Literally copy...
At work we use teraterm and realterm for checking serial data is correctly formatted. Also we have a hardware splitter with a switch so we can monitor traffic to our application via a cable back to another port. Windows allows you access to the serial port via CreateFile. That gives you a handle and from there you c...
Some of the neat features are available in Visual Assist X, though not all of them. I've asked on their forums, but they haven't appeared as yet. VAX gets updated regularly on a rough 4 week period for bug fixes and a new feature every couple of months.
I think your second approach (e.g., tagging releases and doing experimental stuff in branches, considering the trunk stable) is the best approach. It should be clear that branches inherit all the bugs of a system at the point in time where it is branched: if fixes are applied to a trunk, you will have to go one by ...
How do you manage schema upgrades to a production database?
|database|administration|installation|
This seems to be an overlooked area that could really use some insight. What are your best practices for: - making an upgrade procedure - backing out in case of errors - syncing code and database changes - testing prior to deployment - mechanics of modifying the table etc...
|database|installation|administration|
The trunk should generally be your main development source. Otherwise you will spend a lot of time merging in new features. I've seen it done the other way and it usually leads to a lot of last minute integration headaches. We label our releases so we can quickly respond to production emergencies without distribin...
How to select an SQL database?