instruction
stringlengths
0
30k
It's always better to specify the columns you need, if you think about it one time, SQL doesn't have to think "wtf is *" every time you query. On top of that, someone later may add columns to the table that you actually do not need in your query and you'll be better off in that case by specifying all of your columns.
In Tomcat how can my servlet determine what connectors are configured?
|tomcat|
If a function throws and you want to catch the exception, you'll have to wrap the function in a try block, it's the safest way. So in your example: try { // ... } finally { try { SomeCleanupFunctionThatThrows(); } catch(Throwable t) { //or catch whatever you want here...
It depends what kind of initial investment you want to make. jBPM is the best in terms of features and flexibility, but OSWorkflow is a more lightweight, easier to get up and running and has with a smaller learning curve.
You'll need an interface to the Oracle SQL database. As Bob pointed out, Allegro CL has such an interface. [GNU CLISP apparently comes with an interface to the database as well.][1] [1]: http://clisp.cons.org/impnotes/oracle.html
> Should Float or Decimal data type be used for dollar amounts? The answer is easy. Never floats. *NEVER* ! Floats were according to IEEE 754 always binary, only the new standard IEEE 754R defined decimal formats. Many of the fractional binary parts can never equal the exact decimal representation. Any binary nu...
Your problem is that an enumeration does not allow the IList to change. This means you have to avoid this while going through the list. A few possibilities come to mind: - Clone the list. Now each enumerator has its own copy to work on. - Serialize the access to the list. Use a lock to make sure no other thr...
Leave them alone and add the usings. You're asking for trouble manually changing things like that (harder to debug, inconsistent with other projects, et cetera).
atoi and atof will convert or return a 0 if it can't.
I took a conference session on Function Point Analysis a few years back. There is a lot too it. You can check out the [Free Function Point Training Manual][1] online, the [Fundamentals of Function Points][2], or I suspect you can get a book on it at a computer store. You might also check out the [International Fun...
design patterns or best practices for shell scripts
|design-patterns|bash|shell|
Does anyone know of any resources that talk about best practices or design patterns for shell scripts (sh, bash etc...)?
It's easy enough to use the "tf.exe history" command recursively across a directory of files in TFS. This will tell you who changed what files. However what you're after is a little bit more than this - you want to know if the latest versions of any files have lines written by a particular user. The Team Foundati...
I would not refactor tests like standard code. Tests start to become more obscure as you refactor things into common base classes, helper methods, etc. Tests should be sufficiently clear on their own. DRY is not a test concern. That said, there are many plumbing things that are commonly done, and those should be...
I agree with japollock way up there--throw an acception when you are uncertain about the outcome of an operation. Calls to APIs, accessing filesystems, database calls, etc. Anytime you are moving past the "boundaries" of your programming languages. I'd like to add, feel free to throw a standard exception. Unless you...
$$ is the id of the current process.
$$ is the pid of the current shell process. It isn't a good way to generate unique filenames.
In bash $$ is the process ID, which is fine if you need a single file, otherwise take a look at the **mktemp** command.
OBTW, If you have queries that already run against the old table you will need to create a view which replicates the old tables using the new tables. You will need to do a group by to denormalize the tables. Tell your users that the old table/view will not be supported in the future and all new queries or update...
Is a software token a valid second factor in multi-factor security?
|authentication|
We are changing our remote log-in security process at my workplace, and we are concerned that the new system does not use <a href="http://en.wikipedia.org/wiki/Two-factor_authentication">multi-factor authentication</a> as the old one did. (We had been using RSA key-fobs, but they are being replaced due to cost.) The ne...
|authentication|language-agnostic|
|language-agnostic|authentication|
We are changing our remote log-in security process at my workplace, and we are concerned that the new system does not use <a href="http://en.wikipedia.org/wiki/Two-factor_authentication">multi-factor authentication</a> as the old one did. (We had been using RSA key-fobs, but they are being replaced due to cost.) The ne...
It sounds like what you really need is just an alias? Alias /terms /www/public/articles/terms/
This is called scanf in C, I've made a Delphi look-a-like for this : function ScanFormat(const Input, Format: string; Args: array of Pointer): Integer; var InputOffset: Integer; FormatOffset: Integer; InputChar: Char; FormatChar: Char; function _GetInputChar: Char; ...
From experience installing on Vista/XP I would recommend... 1, Install the source code/project/solution files into the 'Users' directory for Vista. That way when the user opens up the demo and compiles they have write access for generating the output files. If you put the files into the 'Program Files' directory und...
Here's a solution which will choose a random image per day from a directory, which might be easier than some other solutions posted here, since all you have to do to get something into the rotation is upload it, rather than edit an array, or name the files in arbitrary ways. function getImageOfTheDay() { ...
Why do you need explicitly have the "self" argument into a Python method?
|python|
When defining a method on a class in Python, it looks something like this: class MyClass(object): def __init__(self, x, y): self.x = x self.y = y But in some other languages, such as C#, you have a reference to the object that the method is bound to with the "this" keyword w...
I use Anjuta IDE. Not bad. Not sure how it compares to Eclipse IDE.
I don't know of any tutorials/guides, but you could try looking at the source for [tinypy][1], it's a very small implementation of a python like language. [1]: http://www.tinypy.org/
|windows|apache|tomcat|connector|
I have apache 2.2 and tomcat 5.5 running on a Windows XP machine. Which tomcat/apache connector is the easiest to set up and is well documented?
Some prevention techniques: XSS - If you take any parameters/input from the user and ever plan on outputting it, whether in a log or a web page, sanitize it (strip/escape anything resembling HTML, quotes, javascript...) If you print the current URI of a page within itself, sanitize! Even printing PHP_SELF, for e...
Nested class is a very general term: every class which is not top level is a nested class. An inner class is a non-static nested class. Joseph Darcy wrote a very nice explanation about [Nested, Inner, Member, and Top-Level Classes][1]. [1]: http://blogs.sun.com/darcy/entry/nested_inner_member_and_top
This [recent Vim tutorial from IBM][1] is pretty good [1]: http://www.ibm.com/developerworks/aix/library/au-speakingunix_vim/index.html
I'd suggest adding an explicit route for /Pages/ at the beginning. The problem is that it's being handled by the Default route and deriving: controller = "Pages" action = "Index" id = "" which are exactly the same as the parameters for your Admin route.
How should Rails models containing database and non-database datasources be broken up?
|ruby|ruby-on-rails|
So I'm working on a Rails app to get the feeling for the whole thing. I've got a `Product` model that's a standard ActiveRecord model. However, I also want to get some additional product info from Amazon ECS. So my complete model gets some of its info from the database and some from the web service. My question is, sho...
It is really up to you how you want to deal with it. If you are only going to be accessing a member of a namespace once or twice, then adding the "using" statement really doesn't do much for you. If you are going to use it multiple times then reducing the namespace chain is probably going to make things easier to r...
How to handle static fields that vary by implementing class
|c#|java|
I hit this problem all the time. Suppose I am making a command line interface (Java or C#, the problem is the same I think, I will show C# here). 1. I define an interface ICommand 2. I create an abstract base class CommandBase which implements ICommand, to contain common code. 3. I create several implementation...
I hit this problem all the time. Suppose I am making a command line interface (Java or C#, the problem is the same I think, I will show C# here). 1. I define an interface ICommand 2. I create an abstract base class CommandBase which implements ICommand, to contain common code. 3. I create several implementation...
The server.xml can have many connectors, typically port only 8080, but for my application a user might configure their servlet.xml to also have other ports open (say 8081-8088). I would like for my servlet to figure out what socket connections ports will be vaild (During the Servlet.init() tomcat has not yet started t...
Every programming language has its own set of rules and conventions for the kinds of names that you're allowed to use, and the Java programming language is no different. The rules and conventions for naming your variables can be summarized as follows: * Variable names are case-sensitive. A variable's name can b...
One reason that selecting specific columns is better is that it raises the probability that SQL Server can access the data from indexes rather than querying the table data. Here's a post I wrote about it: [http://weblogs.asp.net/jgalloway/archive/2007/07/18/the-real-reason-select-queries-are-bad-index-coverage.aspx][1...
I want to say git, but don't think a company of that size is going to be all Linux (Windows support for git still sucks). So go with the SCM that Linux used before git i.e. [BitKeeper][1] [1]: http://www.bitkeeper.com/Products.html
You can always write a small program or script to convert your text file into a header file and run it as part of your build process.
Its worth mentioning that the [ActiveMQ open source project](http://activemq.apache.org/) defines a [C# API for messaging called NMS](http://activemq.apache.org/nms/) which allows you to develop against a single C# / .Net API that can then use various messaging back ends such as * [ActiveMQ](http://activemq.apache.o...
It depends on what you want, though I'd shy away from invariantculture unless you're _very_ sure you'll never want to localize the code for other languages. Use CurrentCulture instead. Also, OrdinalIgnoreCase should respect numbers, which may or may not be what you want.
Creating a C++/CLI interop class to do the drawing in native code will result in crazy-fast drawing. We've witnesses this and measured it. If you're not up to doing that, we've found graphics.DrawString is just slightly faster than than TextRenderer.DrawText.
There may be something that allows you to do this in your servlet engine. This is part of the Servlet 3.0 spec which is yet to be released.
Can a svn repository include/link-to an external git repository?
|svn|git|
I have a svn repository, R, that depends on a library, l, in another repository. The goal is that when someone checks out R, they also check out l. We want l to still be in its own repository so that l can be updated without dependence on R. I don't know much about external svn links, but I believe that when depe...
I believe it is best to use multiple UpdatePanel if you can because of the size the POST that the UpdatePanel generates. It's even better if you can use manual AJAX approaches for small things like updating a field. The WPF provides some javascript functions and methods to accomplish this. Here's some link that may ...
Surrounding the path and the argument with spaces inside quotes as in your example should do. The command may need to handle the quotes when the parameters are passed to it, but it usually is not a big deal.
How about the "Can't decide whether this is an error or not" pattern. Seems like if you really had an exception but wanted to return a partial result, you'd wrap the result in the exception.
I agree with the others who have stated that this is a little on the WTFy side. If it's clearly documented functionality, then it's less of an issue, but I think it'd be safer to take an alternate route of returning 0 for success and integers for error codes. If you don't like that idea or the idea of a global last err...
Every task needs the right tool. Meet the [<acronym title="SO Overflow">SO</acronym> Overflow](http://page.mi.fu-berlin.de/krudolph/stuff/so/) language, optimized to produce stack overflows: so
Does C# have a String Tokenizer like Java's?
|c#|string|parsing|
I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is it? How do I use it?
Also try AppTranslator: http://www.apptranslator.com/. It has a build-in resource editor so that translators can, for example, enlargen a text box when need bo. It has separate versions for developers and translators and much more.
One way would be to use the Team Foundation System client under Windows in VMWare, and check out (or whatever TFS calls it) your sources to a directory on your Mac that's shared with the virtual machine. It also looks like [Teamprise][1] has a Team Foundation client for Mac OS X built atop Eclipse that would be worth ...
I'm coming at this from C#, but should be very similar in vb.net. In your main program file, in the Main method, you will have something like: Application.Run(new MainForm()); This creates a new main form and limits the lifetime of the application to the lifetime of the main form. However, if you remove...
I'm coming at this from C#, but should be very similar in vb.net. In your main program file, in the Main method, you will have something like: Application.Run(new MainForm()); This creates a new main form and limits the lifetime of the application to the lifetime of the main form. However, if you remove...
How to put text in the upper right, or lower right corner of a "box" using css
|css|layout|
See the following. How would I get the "here" and "and here" to be on the right, on the same lines as the lorem ipsums? ` Lorem Ipsum etc........here blah....................... blah blah.................. blah....................... lorem ipsums.......and here `
Either use a tool that parses your log files and gives you a 'broken links' report (e.g. [Analog][1] or Google [Webmaster Tools][2]), or run a tool that spiders your web site and reports broken links (e.g. [W3C Link Checker][3]). [1]: http://www.analog.cx/ [2]: http://www.google.com/webmasters/tools/ [3]: ...
On your first TDD project there are two big losses, time and personal freedom You lose time because: - Creating a comprehensive, refactored, maintainable suite of unit and acceptance tests adds major time to the first iteration of the project. This may be time saved in the long run but equally it can be time yo...
Performance wise, SELECT with specific columns can be faster (no need to read in all the data). If your query really does use ALL the columns, SELECT with explicit parameters is still preferred. Any speed difference will be basically unnoticeable and near constant-time. One day your schema will change, and this is good...
No, Enterprise Manager doesn't have a plug-in framework for you to hook in to.
This may be what you're looking for: [http://www.vim.org/scripts/script.php?script_id=1783][1] You can also mimic some CScope functionality in your own .vimrc file by using the various flavors of [map][2]. [1]: http://www.vim.org/scripts/script.php?script_id=1783 [2]: http://vimdoc.sourceforge.net/htmld...
You can use OpenID for all sites, regardless of platform. Use this for ease of login (it's javascript): https://www.idselector.com/ For your .NET sites, dotnetopenid works nicely. For PHP you can use the code from here: http://openidenabled.com/php-openid/ OpenID uses the URL to identify the site - not the tech...
If you have a core file and you have compiled the program with debuging options (-g), you can see where the core was dumped: $ gcc -g -o something something.c $ ./something Segmentation fault (core dumped) $ gdb something core You can use this to do some post-mortem debuging. A few gdb commands...
Any successful profibus communications from .NET?
|communication|plc|industrial|
Has anyone successfully talked [profibus][1] from a .NET application? If you did, what device/card did you use to accomplish this, what was the application, and did you use any kind of preexisting or available code? [1]: http://www.profibus.com/
You could use something like if (isset($argv[1]) { $arg1 = $argv[1]; $arg1 = explode("=", $arg1); $param = $arg1[1]; } (how to handle the lack of parameter/s is up to you) or if you need a more complex scenario, look into a commandline parser library such as t...
ICollection MyCollection; // Instantiate and populate the collection lock(MyCollection.SyncRoot) { // Some operation on the collection, which is now thread safe. } From [MSDN][1] [1]: http://msdn.microsoft.com/en-us/library/system.collections.icollection.syncroot.aspx
Unobtrusive Javascript: Removing links if Javascript is enabled
|javascript|unobtrusive|
I'm using [PopBox][1] for magnifying thumbnails on my page. But I want my website to work even for users which turned javascript off. I tried to use the following HTML code: <a href="image.jpg"> <img src="thumbnail.jpg" pbsrc="image.jpg" onclick="Pop(...);"/> </a> Now i need to disable the...
|javascript|
Checking online status from an iphone web app
|iphone|mobile-safari|javascript|
Is there a way to check to see if an iphone is online from a web app. That is, in mobile safari, can I check the online status of the device to see if I should try an ajax call or not. In firefox, this would be if(navigator.onLine) { onlineCode() }
|javascript|iphone|mobile-safari|
Is there a way to check to see if an iphone is online from a web app. That is, in mobile safari, can I check the online status of the device to see if I should try an ajax call or not. In firefox/regular webkit, this would be if(navigator.onLine) { onlineCode() }
You need to be very careful if you call System.gc(). Calling it can add unnecessary performance issues to your application, and it is not guaranteed to actually perform a collection. It is actually possible to disable explicit System.gc() via the java argument "-XX:+DisableExplicitGC". I'd highly recommend reading t...
Hold down the Ctrl key while pressing OK and you should be able to load past this point in the document and possibly get more details. What tool are you using to create the PDF (Aspose)?