Question: I seem to only be able to write to the Apache error log via stderr.  Anyone know of a more structured logging architecture that I could use from my python web project, like commons?

Answer:
I've used the builtin
Python logging module
in (non-web) projects in the past, with success - it should work in a web-hosted environment as well.


Question:
I'm working on a java web-application, trying to be xml-friendly and writing my jsp files using the jspx/xml syntax. It took me hours of dissecting examples and configuration files to find out that with tomcat 5.5 files using the new syntax should end in .jspx, or tomcat won't translate tag libraries and stuff.

Both file extensions map to the same servlet in tomcat's configuration file, so I thought everything was fine with my .jsp files. Am I missing something?

Answer:
There are additional configurations for servlets that can affect behavior.  I haven't tried it, but would assume that you could just override some of the default configurations  for *.jsp to use that of *.jspx.
Try adding a
jsp-property-group
definition for
*.jsp
with
is-xml
set to true:
```
```
<jsp-property-group>
  <url-pattern>*.jsp</url-pattern>
  <is-xml>true</is-xml>
</jsp-property-group>
```
```
Some information on configuring property group
s.


Question: On a question of just performance, how does Python 3 compare to Python 2.x?

Answer:
I'd say any difference will be below trivial. For example, looping over a list will be the exact same.
The idea behind Python 3 is to clean up the language syntax itself - remove ambigious stuff like
```
except Exception1, Exception2
```
, cleanup the standard modules (no urllib, urllib2, httplib etc).
There really isn't much you can do to improve it's performance, although I imagine stuff like the garbage collection and memory management code  will have had some tweaks, but it's not going to be a "wow, my database statistic generation code completes in half the time!" improvement - that's something you get by improving the code, rather than the language!
Really, performance of the language is irrelevant - all interpreted languages basically function at the same speed.
Why I find Python "faster" is all the built-in moudles, and the nice-to-write syntax - something that
has
been improved in Python3, so I guess in those terms, yes, python3's performance is better then python2.x..


Question:
I have found that SP2 doesn't execute from within SP1 when SP1 is executed.

Below is the structure of SP1:

ALTER PROCEDURE SP1 AS BEGIN

Declare c1 cursor....

open c1 fetch next from c1 ...

while @@fetch_status = 0 Begin

...

Fetch Next from c1 end

close c1

deallocate c1

exec sp2

end

I see non of the PRINT statement outputs if they are printed in the 'Output window' in SQL Server 2005 management studio as the 'Output Window'is empty.

Answer:
What happens if you run the Stored Procedure code as a single query? If you put a
```
PRINT
```
statement before and after the exec, do you see both outputs?
If you do, then the stored procedure must have been executed. Probably it's not doing what you would like.
If you don't see any print output, then there's something wrong in the cycle
If you don't see the second output but you see the first, there's something wrong in the second Stored Procedure.


Question:
Which search engine would you recommend for a Commerce website?

We have millions of products in a catalog and we want it to be as quick as possible.

We would also want to make sure that the marketing driven through the search engine will be fast and effective.

What are your opinions?

Answer:
This is only half the answer to your question. I've used it with Java and not .NET. Fast is said to be the better search engine. I don't know. However for Commerce Endeca is considered to be the best. I've used it with a catalog of 5Mil. products and queries are very very fast.
If you use .NET or Java does not matter in the end solution the Search Engine stays the same.
And what search engine to be used is not answered easily. it all depends on what you want/can spend. My experiences with Endeca are very positive.


Question:
PHP has a number of opcode caches, which as i understand it are scripts that handle the caching aspects of an application. Is there something similar for classic asp, especially something that does not require component installation?

Regarding the IIS caching behaviour, it seems from reading here that the behaviour is relevant to some sort of pre-compilation step rather than finished pages. please correct me if i am wrong

Answer:
Looking at your comments to the answers here so far and at your edit of your question you seem a little confused over caching.
There are two types of caching we could be be talking about.
Opcode or Template caching
Output caching
Opcode or Template caching
is the caching that takes place when a raw script file which is merely a text file is transformed to an in memory set of opcodes that can be executed by the script engine.  PHP has some additional tools which allow such a set of opcodes be reused when the script file is requested subsequently.  Similarly ASP keeps a cache of 'compilied' opcodes in memory and on disk so that it can serve subsequent requests for the same script without going through the whole parsing process again.
Output caching
is where the generated output of script that is sent to a response buffer is cached so that subsequent requests for an identical URL (and possible matching other headers as well) would not re-run the script at all but resend the previously cached output.
ASP has no facility for output caching whereas ASP.NET does.  I'm not familiar enough with PHP or its normal platforms to comment on whether such a facility is available for it.
You can configure ASPs 'opcode' caching (which it calls template caching) in IIS manager (IIS6) open the properties window on the Web Sites node go to home directory tab and click Configuration... then select the cache options tab. By default 500 'compilied' pages will be cached in memory and 2000 will be cached on disk.
In a comment to my original version of this answer you seem to asking whether PHP hosted by IIS would also benefit from template caching.  That would depend how PHP is added to the platform.
I hardly know anything about PHP but I would imagine it is simply another dll which IIS script mapping maps files with the extension PHP to.  That being that case it won't be benefiting from ASPs template caching.
The following is probably fiction but just to try to round out the picture:-
Another unlikely possiblity would be if PHP were some how added as ASP Script language.  In this case files with PHP extension would be mapped to the ASP.DLL and the files would either contain <%@ language="PHP" or the default language in the application configuration would be set to PHP.  In this unlikely set up ASP would build a template that would be cached, however whether that template contains 'compilied' opcode etc would be up to PHP.


Question:
I want to experiment with GCC whole program optimizations. To do so I have to pass all C-files at once to the compiler frontend. However, I use makefiles to automate my build process, and I'm not an expert when it comes to makefile magic.

How should I modify the makefile if I want to compile (maybe even link) using just one call to GCC?

For reference - my makefile looks like this:

LIBS  = -lkernel32 -luser32 -lgdi32 -lopengl32
CFLAGS = -Wall

OBJ = 64bitmath.o    \
      monotone.o     \
      node_sort.o    \
      planesweep.o   \
      triangulate.o  \
      prim_combine.o \
      welding.o      \
      test.o         \
      main.o

%.o : %.c
    gcc -c $(CFLAGS) $< -o $@

test: $(OBJ)
    gcc -o $@ $^ $(CFLAGS) $(LIBS)

Answer:
```
```
LIBS  = -lkernel32 -luser32 -lgdi32 -lopengl32
CFLAGS = -Wall

# Should be equivalent to your list of C files, if you don't build selectively
SRC=$(wildcard *.c)

test: $(SRC)
    gcc -o $@ $^ $(CFLAGS) $(LIBS)
```
```


Question: What's the best way to create a non-NULL constraint in MySQL such that fieldA and fieldB can't both be NULL. I don't care if either one is NULL by itself, just as long as the other field has a non-NULL value. And if they both have non-NULL values, then it's even better.

Answer:
I've done something similar in SQL Server, I'm not sure if it will work directly in MySQL, but:
```
```
ALTER TABLE tableName ADD CONSTRAINT constraintName CHECK ( (fieldA IS NOT NULL) OR (fieldB IS NOT NULL) );
```
```
At least I believe that's the syntax.
However, keep in mind that you cannot create check constraints across tables, you can only check the columns within one table.


Question:
I want to save the objects I generated in a program. After restart the App should load automaticly all Objects in an Array. I want to write them in a file and parse them after restart. Are the other smarter possibilities than do it by hand?
Thank you

Answer:
Yes, the concept you are looking for is called serialization. There's a fine tutorial at Sun
here
.
The idea is that classes you want to persist have to implement the Serializable interface. After that you use java.io.ObjectOutputStream.writeObject() to write the object to a file and java.io.ObjectInputStream.readObject() to read it back.
You can't serialize everything, as there are things that don't make sense to serialize, but you can work around them. Here's a quote about that:
The basic mechanism of Java
  serialization is simple to use, but
  there are some more things to know. As
  mentioned before, only objects marked
  Serializable can be persisted. The
  java.lang.Object class does not
  implement that interface. Therefore,
  not all the objects in Java can be
  persisted automatically. The good news
  is that most of them -- like AWT and
  Swing GUI components, strings, and
  arrays -- are serializable.
On the other hand, certain
  system-level classes such as Thread,
  OutputStream and its subclasses, and
  Socket are not serializable. Indeed,
  it would not make any sense if they
  were. For example, thread running in
  my JVM would be using my system's
  memory. Persisting it and trying to
  run it in your JVM would make no sense
  at all. Another important point about
  java.lang.Object not implementing the
  Serializable interface is that any
  class you create that extends only
  Object (and no other serializable
  classes) is not serializable unless
  you implement the interface yourself
  (as done with the previous example).
That situation presents a problem:
  what if we have a class that contains
  an instance of Thread? In that case,
  can we ever persist objects of that
  type? The answer is yes, as long as we
  tell the serialization mechanism our
  intentions by marking our class's
  Thread object as transient.


Question:
This is related to the accepted answer for What’s your #1 way to be careful with a live database?

Suppose you create a temp table for backup purpose and make your changes in the original. The changes break the system and you want to restore the backup. In the meantime some other records have also changed in the original table (it is a live db). Now if you restore the backup, the system will be in an inconsistent state.

Whats the best way to tackle this

Answer:
I don't think that's desirable, I'd test harder before putting the table in production, but supposing it happened anyway, you'd have two options:
1.- Create an ON INSERT trigger which updates the temporary backup table with the rows inserted into the new table, massaging the data to fit into the old table
or
2.- Find the difference in the data like this
```
```
SELECT * FROM faultyTable
EXCEPT
SELECT * FROM backupTable
```
```
You'd have to adjust the columns to be selected to the common subset of course. And EXCEPT is called MINUS sometimes too.
After that you can insert the difference into the backed up table and restore the combination. This gets harder and harder the more relationships the table has... depending on the way used to restore the table you might drop the related data, thus you'd have to select it too.


Question:
Does anyone have an idea how long it will take before "almost all" widely used Python libraries work with Python 3.0?

I am planning to stay on 2.X for a while because I don't want to start porting stuff over and then find that some library I already rely on or a new library I might start using doesn't work yet with py3k.

My understanding is that the py3k beta process was drawn out specifically to give library developers time to move their stuff over. Has this been happening?

Examples of the sorts of libraries I am talking about would be PIL, numpy/ scipy, SQLAlchemy, BeautifulSoup, CherryPy...

Answer:
The examples you have listed will probably be ported very quickly, as they are so widely used.
I would be surprised if BeautifulSoup takes more than a month (In fact, I'm surprised it hasn't been ported already using the py3k betas), more complex things like numpy may take a big longer, especially because 2to3 only works on python sources, not C modules..
It's hard to generalise - some modules may never be ported, some may take days, others may take years. It could end up being a situation along the lines of "well I'm not porting my library to Python3, no one is using it!"/"Well I'm not porting my project to python3, no libraries have been updated yet!", but I hope not!


Question:
On some Microsoft Access queries, I get the following message:  Operation must use an updatable query. (Error 3073).  I work around it by using temporary tables, but I'm wondering if there's a better way.  All the tables involved have a primary key. Here's the code:

UPDATE CLOG SET CLOG.NEXTDUE = (
    SELECT H1.paidthru
    FROM CTRHIST as H1
    WHERE H1.ACCT = clog.ACCT AND
    H1.SEQNO = (
        SELECT MAX(SEQNO)
        FROM CTRHIST
        WHERE CTRHIST.ACCT = Clog.ACCT AND
        CTRHIST.AMTPAID > 0 AND
        CTRHIST.DATEPAID < CLOG.UPDATED_ON
    )
)
WHERE CLOG.NEXTDUE IS NULL;

Answer:
Since Jet 4, all queries that have a join to a SQL statement that summarizes data will be non-updatable. You aren't using a JOIN, but the WHERE clause is exactly equivalent to a join, and thus, the Jet query optimizer treats it the same way it treats a join.
I'm afraid you're out of luck without a temp table, though maybe somebody with greater Jet SQL knowledge than I can come up with a workaround.
BTW, it might have been updatable in Jet 3.5 (Access 97), as a whole lot of queries were updatable then that became non-updatable when upgraded to Jet 4.
--


Question:
I have read on Stack Overflow some people that have converting to C#2.0 to C#3, but is it really worth it?

I have a project that is done at 75% before going in maintenance phase. I am asking to myself if it is worth it to switch to C#3.0?

Update:

The project will have a web interface now so before entering the maintenance phase we have to develop the web part (all was done for internal purposes with Windows Forms). Most parts will be resused (back-end). Most people have said that it wasn't worth it in the past because it was already at 75%... but now do you still think it's not worth it?

What have been done finally

Finally since we are continuing the project with the web interface we will update to 3.5 for the new year. Thank you everybody for all your input.

Answer:
Is there any C# 3.5 feature you want badly at this stage? :)
If it is LINQ, you can give
LINQBridge
a try..
With Studio's multi-targeting and LINQBridge, you'll be able to write local (LINQ to Objects) queries using the full power of the C# 3.0 compiler—and yet your programs will require only Framework 2.0.


Question: I have a somewhat messily-formatted Objective-C code base. Is there a way to have Xcode reformat an entire project to conform to a coding standard (i.e., properly indent, spaces v. tabs, etc.)? Are there other tools that might accomplish this?

Answer:
According to this
blog post
,
bcpp
works with Objective-C.
In addition, the tool indent might help you. It's aimed at plain C but has a gazillion options that could help. I don't know if it comes by default on OS X though.
```
```
NAME
       indent - changes the appearance of a C program by inserting or deleting
       whitespace.

SYNOPSIS
       indent [options] [input-files]

       indent [options] [single-input-file] [-o output-file]

       indent --version

DESCRIPTION
       This man page is generated from the file indent.texinfo.  This is  Ediâ
       tion  of "The indent Manual", for Indent Version , last updated .

       The  indent  program  can  be used to make code easier to read.  It can
       also convert from one style of writing C to another.

       indent understands a substantial amount about the syntax of C,  but  it
       also attempts to cope with incomplete and misformed syntax.
```
```


Question:
I am trying to compile my apps (which uses 3rd party libraries) for the x64 platform. However selecting x64 from Build Configuration Manager from my VS2008 Pro doesn't seem to work. The binary does get created but my client wasn't able to get it to run on x64.

I wonder if the 3rd party DLLs could be the cause. Anyone has any idea on this?

Answer:
Do you have x64 versions of the third party libraries?  If not you are out of luck.  A process must either be fully x86 or x64, you can't mix and match libraries.  If the libraries are DLLs then you still need the export libraries from an x64 build.
In what way does selecting the x64 configuration in VS not work?
Updated:
If your app is .NET and architecture neutral, then it will be loaded as 64 bit on 64 bit OS'es.  However, if it relies on 32 bit DLLs then this will fail at run time. You can force your exe to always load 32 bit using the
corflags
utility.


Question:
This might sound like a little bit of a crazy question, but how can I find out (hopefully via an API/registry key) the install time and date of Windows?

The best I can come up with so far is to look at various files in C:\Windows and try to guess... but that's not exactly a nice solution.

Answer:
In
```
regedit.exe
```
go to:
```
```
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate
```
```
It's given as the number of seconds since January 1, 1970. (Note: for Windows 10, this date will be when the last feature update was installed, not the original install date.)
To convert that number into a readable date/time just paste the decimal value in the field "UNIX TimeStamp:" of this
Unix Time Conversion online tool
.


Question:
Does anyone know how to resize images proportionally using JavaScript?

I have tried to modify the DOM by adding attributes height and width on the fly, but seems did not work on IE6.

Answer:
Instead of modifying the height and width attributes of the image, try modifying the CSS height and width.
```
```
myimg = document.getElementById('myimg');
myimg.style.height = "50px";
myimg.style.width = "50px";
```
```
One common "gotcha" is that the height and width styles are strings that include a unit, like "px" in the example above.
Edit - I think that setting the height and width directly instead of using style.height and style.width should work. It would also have the advantage of already having the original dimensions. Can you post a bit of your code? Are you sure you're in standards mode instead of quirks mode?
This should work:
```
```
myimg = document.getElementById('myimg');
myimg.height = myimg.height * 2;
myimg.width = myimg.width * 2;
```
```


Question:
I am developing a collection of plugins on Eclipse 3.4 (official) on both mac and a PC.

At present (I'm aware it is not the best practice) some of my common plugins export all of their packages.

The problem is this: many of the listed packages are empty because subpackages are not,
for example: prefix.core may be empty while prefix.core.model may not be.

Even though I use the same manifest file, having the empty packages listed on one platform raises an error in the manifest file on the other platform. If I omit the packages in that platform, then when I come to the other platform I'm told that the plugin does not export everything.

Any idea what is going on? I have no idea why there would be differences between the PC and the Mac on a non-UI related issue. The only significant difference is that the mac is running Java 5 (still not Eclipse for Java 6) while the PC is running Java 6, but the manifests should have nothing to do with it.

Answer:
It's usually a good practice to use the same version of the JVM if you're developing plugins across multiple machines and platforms.
If you are going to build the plugins on a PC and expect them to run on the Mac, you should standardize on Java 5. You can easily install and add additional JREs to Eclipse by going to Window->Preferences->Installed JREs. You can even configure which JRE each project and launch configuration uses, if you don't want the rest of your PC Java coding to use 5.
I wouldn't be surprised if this fixes your manifest problem, as well.


Question: That's the question. Give only one reason you think why have OODB failed or why many systems nowadays still use relational databases.

Answer: The main reason is SQL. It is very useful to be able to use the data from a database in other contexts outside of the application, and often with object databases the data is stored in a format that can't easily be queried.  With a relational database the data can become part of a data warehouse, for instance, or just queried by sys admins etc.


Question:
I've been trying to consider how Row Level Security could be implemented with the Entity Framework.  The idea is to have a database agnostic means that would offer methods to restrict the rows coming from the ObjectContext.

Some of my inital ideas have involved modifying the partial classes created by the EDMGEN tool and that has offered some limited support.  Users are still able to get around this solution by using their own eSQL statements and a QueryObject.

I've been looking for a comprehensive solution that would exist above the database providers so that it would remain agnostic.

Answer:
The place where you add security really depends on who you're trying to secure against.
If, for example, you were securing a web site, then adding the filtering at the context level would be sufficient, because the "users" in this case are on the web site. They have no choice but to go through your context, since you would write the application entirely against the context.
In your case, it sounds like the "users" you're trying to secure against are developers. That's quite a bit more difficult. If the developers don't have access to make modifications to the database itself, then you'll have to put the security at the database level. No amount of eSQL access is going to be able to get around the database saying "no".


Question:
With Merb 1.0 rapidly approaching, I would like to know what Merb/Rails users recommend?

Is it time to try Merb? What was downside for you when you switched to Merb from Rails?

Answer: Everyone, including many from the Merb Core team have been recommended to wait for 1.0.  But if you're at all curious, grab the latest Gem and start toying.  Just don't expect to put it into production and hold off on any production work till 1.0 is out.


Question:
We are building a website which will display news headlines and news. It will be a public site initially, but will evolve include portal content like personalized web pages.

The site also needs to build web 2.0 features around the news stories being displayed, and needs to be extensible and highly customizable, allowing the business to change templates in which the stories are defined and use different templates based on business logic etc..

The core business logic is being built using Windows work flow and Windows communication foundation, we are now looking for a suitable UI stack, is WCSF a good choice?

Answer:
WCSF might be a good choice, but probably for reasons that have nothing to do with the possible feature needs you've listed.
The best things in my opinion that WCSF has going for it is that it's built on the Model-View-Presenter-[Controller] pattern which gives you the separation of concerns between the view and presenter (just like MVC)... BUT at the same time it's not a total paradigm shift from the "Page Control" model that many .net'ers are used to.  This means you can still use a lot of third party controls like Telerik or Infragistics pretty much like you did before (much more challenging with MVC).
Because the MVP pattern uses a dependency injection container (ObjectBuilder) and inversion of control you get a pretty nice way to write unit tests without a web context (easy to mock objects).  Also the container supports service location, so you can easily write WCSF services that will be shared (and WCF and or the WSSF fit in nicely here).
It's highly modularized from a programatic standpoint and has many extensibility points.
All that being said... it kind of sounds like you're looking for more of a templating, personalization, dynamic framework.  You might check out WSS/SharePoint in this case, because it may get you further down the field out of the box.


Question:
I want to use the Date::ABBR_MONTHS constant in my rails application. I see the Ruby stdlib documentation at http://www.ruby-doc.org/stdlib/ which does not seem to have this constant.
However, this constant is there at http://stdlib.rubyonrails.org/

What is the difference between these two libraries?

This constant is working on my unix deployment machine but not on my dev machine on windows. Can anybody explain whats going on?

Answer:
```
ABBR_MONTHS
```
is something you get given to you by ActiveSupport and it's just added into the Date class. The first library is for ruby, where the second one is for ruby on rails. The constant may not be working because of different versions of Rails.


Question:
Seems to me most of developers completely ignore this features. People prefer handling security exceptions as generic ones relying on standard windows roles and rights instead of learning to use CAS ways of enhancing security - probably because CAS is quite confusing in its logic and naming.

Can anyone suggest any general rule-of-thumb/best practices for using CAS at his best in a clean way?

Answer:
See also
this discussion
.
The problem is exacibated because a lot of code (perhaps too much) runs at full trust. And then the only checks that get done are things like PrincipalPermissionAttribute checks - most of the rest are simply bypassed. So in many cases there isn't much point! Unless you are loading in external (untrusted) files [and so need CAS], it simply doesn't add a lot in many cases (and yes, there are plenty of exceptions).
CAS is much more useful for clients running in the sandbox (for example downloaded from the internet). Sliverlight takes this to the extreme, with stricter rules (especially around reflection) than regular .NET.


Question:
I'm writing a game in Java, and I want the user to be able to provide input from both the command line and my GUI. Currently, I use this method to get input:

    static String getInput(){
        System.out.println("Your move:");
        Scanner sc = new Scanner(System.in);
        return sc.nextLine();
    }

I want to keep using this, but let a mousePressed event emulate the user actually typing in their input as well.  It's not that efficient of a solution, but it makes sense in my application. So the question is: how do I simulate a user typing to System.in from the code side?

Answer:
I made an application once that could run via the command line or using a GUI.
The way I did this was to define an Interface (named IODevice) which defined the following methods:
public String getInput();
public void showOutput(String output);
I then had two classes which implemented this interface - One used the host computer's terminal (as you are doing now) and one used a JTextArea (output) / JOptionPane (input).
Perhaps you could do something similar - To change the input device used, simply change the instance of the IODevice.
Hope this is of some use.


Question:
For PHP, what is the default time after which an HTTP request is deemed to have timed out?

I'm using the PECL HTTP extension to make HTTP requests. I can set a timeout limit when making a request, however I'd like to know what the default is if nothing is explicitly specified.

I've hunted through the PHP manual to no avail. I'd appreciate answers supported by evidence, such as a link to the relevant manual page, as opposed to speculative suggestions.

I'm keen to find out what the default timeout actually is not just what it probably is. I can guess it may probably be 30 seconds as this seems a reasonable value, however I can find nothing to confirm or deny this.

Answer:
I'm quite sure what you're looking for is the
default_socket_timeout
php.ini option.  It appears the default is 60 seconds.


Question:
I notice sometimes with my parent/child objects or many-to-many relationships, I need to call either SaveOrUpdate or Merge. Usually, when I need to call SaveOrUpdate, the exception I get on calling Merge has to do with transient objects not being saved first.

Please explain the difference between the two.

Answer:
This is from section
10.7. Automatic state detection
of the Hibernate Reference Documentation:
saveOrUpdate() does the following:
if the object is already persistent in this session, do nothing
if another object associated with the session has the same identifier,
   throw an exception
if the object has no identifier property, save() it
if the object's identifier has the value assigned to a newly
   instantiated object, save() it
if the object is versioned (by a <version> or <timestamp>), and the
   version property value is the same value assigned to a newly
   instantiated object, save() it
otherwise update() the object
and merge() is very different:
if there is a persistent instance with the same identifier currently
   associated with the session, copy the state of the given object onto
   the persistent instance
if there is no persistent instance currently associated with the
   session, try to load it from the database, or create a new persistent
   instance
the persistent instance is returned
the given instance does not become associated with the session, it
   remains detached
You should use Merge() if you are trying to update objects that were at one point detached from the session, especially if there might be persistent instances of those objects currently associated with the session. Otherwise, using SaveOrUpdate() in that case would result in an exception.


Question: What is the best method for removing a table row with jQuery?

Answer:
Is the following acceptable:
```
```
$('#myTableRow').remove();
```
```


Question:
I want to recreate the the update panel postback without using an update panel to do the postback.  What is the generic method for doing this?

For example, on Stackoverflow, when you vote up or down on a question it does a postback to update the database and I would bet they didn't use an update panel.

What do I have?

I have a table with table data.  When I click on the td item as a whole column, I want to do an update to the database and also update a gridview on the page itself.  The gridview shows all the currently clicked items in the table because it was updated via "our method".

Looking for a good generic method I could use for a lot of async postbacks without update panel.

Answer:
You can just use a standard AJAX call to accomplish this.  Create a .aspx page which updates the database in its Page_Load method, and displays any desired information (like the current DB value after the update) as XML.  Then make an AJAX call to that page using jQuery.
You can also return an HTML fragment (i.e. an updated GridView), and use jQuery to insert the updated HTML into the current page.
Edit:
Sample 2 on this page should be very close to what you want:
http://www.codeproject.com/KB/ajax/AjaxJQuerySample.aspx


Question: Any pointers on how to initiate serial communication with the iphone?  Or any other idea to interact with external hardware?

Answer:
It depends on what you want to do. For an SSH terminal connection I reccomend TouchTerm (search the appstore).
I have no experience with electrical connections, but you can find the pinout of the iPod/iPhone connector here:
http://pinouts.ru/PortableDevices/ipod_pinout.shtml
You can then download the iPhone developer kit here:
http://developer.apple.com/iphone/


Question:
I'm using jQuery to add an additional row to a table as the last row.

I have done it this way:

$('#myTable').append('<tr><td>my data</td><td>more data</td></tr>');

Are there limitations to what you can add to a table like this (such as inputs, selects, number of rows)? Is there a different way to do it?

Answer:
The approach you suggest is not guaranteed to give you the result you're looking for - what if you had a
```
tbody
```
for example:
```
```

...

...

```
```
You would end up with the following:
```
```

...

...

...

```
```
I would therefore recommend this approach instead:
```
```
$('#myTable tr:last').after('
...

...
');
```
```
You can include anything within the
```
after()
```
method as long as it's valid HTML, including multiple rows as per the example above.
Update:
Revisiting this answer following recent activity with this question. eyelidlessness makes a good comment that there will always be a
```
tbody
```
in the DOM; this is true, but only if there is at least one row. If you have no rows, there will be no
```
tbody
```
unless you have specified one yourself.
DaRKoN_
suggests
appending to the
```
tbody
```
rather than adding content after the last
```
tr
```
. This gets around the issue of having no rows, but still isn't bulletproof as you could theoretically have multiple
```
tbody
```
elements and the row would get added to each of them.
Weighing everything up, I'm not sure there is a single one-line solution that accounts for every single possible scenario. You will need to make sure the jQuery code tallies with your markup.
I think the safest solution is probably to ensure your
```
table
```
always includes at least one
```
tbody
```
in your markup, even if it has no rows. On this basis, you can use the following which will work however many rows you have (and also account for multiple
```
tbody
```
elements):
```
```
$('#myTable > tbody:last-child').append('
...

...
');
```
```


Question:
I need an API that can make menus like Win32API,

But something simpler and better than WinAPI.

That can make GUI, with text zones, buttons etc...like an average Windows program.(Windows GUI Style)

Can anyone recommand on one like it? Thanks.

Answer:
wxWidgets
:
wxWidgets lets developers create applications for Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more using one codebase. It can be used from languages such as C++, Python, Perl, and C#/.NET. Unlike other cross-platform toolkits, wxWidgets applications look and feel native. This is because wxWidgets uses the platform's own native controls rather than emulating them. It's also extensive, free, open-source, and mature.


Question:
There are several web applications which allow you to send photos from your mobile phone and post them to web site/application. How do these work and what sort of technologies would one use to implement such a feature?  Is it an MMS server or does one need to get into socket programming?  For example, some applications provide you with an email address to email your photos to via mobile phone.  I'm curious to know how these things work.  I can somewhat figure out on my own how they work, but I would like to know this feature is normally implemented.

Thanks

Answer:
I think you have three options to support this:
MMS - you would need an
MMS gateway
to recieve MMS messages. This can be software/hardware that you run yourself, or there are services were you pay per message. You would likely need to write your own handling of the message at the application end.
Email - you just provide users with an email address to send picture to and you either interface with the email server via POP/IMAP or with the message store directly.
Web form - you implement a web form specifically designed for mobile devices that lets them upload pictures. In truth I have no idea if and how many devices support
```
<input type="file" />
```
, so this may not actually be an option at all.
You can use whatever server-side technology you prefer for processing each of these.


Question:
So is there a way to initialize and start a command line Spring app without writing a main method. It seems like all such main methods have the same form

public static void main(final String[] args) throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot.class);
    FooService fooService = (FooService) ctx.getBean("fooService");
    fooService.bar();
}

I suppose that's not complicated, but has someone found a way to provide a way to just specify the context.xml at the command line or, better yet, in a manifest file?

The goal here is to simplify the creation of spring applications as executable jars. I hope that I can specify some utility class as the Main-Class in the manifest. I suppose I would also need to specify the starting point for the app, a bean and a method on it where begins the process.

Answer:
I'll try to answer the question as I understand it:
How to package a jar containing a spring configuration such as I just need to use
```
java -jar myjar.jar
```
?
The code snippet you have in your question simply works. You don't have to parameterise the
```
context.xml
```
. You just need to bundle your code and its dependencies (spring, etc.) in a single jar with a proper manifest entry for the main class in a jar file.
I personaly use
maven 2
and here is a
pom.xml
I would use that do just that:
```
```
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.stackoverflow</groupId>
  <artifactId>stackoverflow-autostart-spring-app</artifactId>
  <version>0.1</version>

  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
      <version>2.5.2</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.stackoverflow.spring.autostart.Autostart</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
```
```
This is assuming some package name for the java code, the source code being in the
```
src/main/java
```
directory and the file
```
context.xml
```
in the
```
src/main/resources
```
directory.
So in this
```
pom.xml
```
there are several important points:
the spring dependency (speaks for itself I believe)
the configuration of the
maven jar plugin
, that adds the main class as a manifest entry
the
maven shade plugin
, which is the plugin responsible for gathering all the dependencies/classes and packaging them into one single jar.
The executable jar will be available at
```
target\stackoverflow-autostart-spring-app-0.1.jar
```
when running
```
mvn package
```
.
I have this code all working on my box but just realised that I can't attach a zip file here. Anyone know of place I could do so and link here?
I created a
git repository at github
with the code related to this question if you want to check it out.
Hope this helps.


Question: I've implemented a basic search for a research project. I'm trying to make the search more efficient by building a suffix tree. I'm interested in a C# implementation of the Ukkonen algorith. I don't want to waste time rolling my own if such implementation exists.

Answer:
Hard question.  Here's the closest to match I could find:
http://www.codeproject.com/KB/recipes/ahocorasick.aspx
, which is an implementation of the Aho-Corasick string matching algorithm.  Now, the algorithm uses a suffix-tree-like structure per:
http://en.wikipedia.org/wiki/Aho-Corasick_algorithm
Now, if you want a prefix tree, this article claims to have an implementation for you:
http://www.codeproject.com/KB/recipes/prefixtree.aspx
<
HUMOR
> Now that I did your homework, how about you mow my lawn.  (Reference:
http://flyingmoose.org/tolksarc/homework.htm
) <
/HUMOR
>
Edit
: I found a C# suffix tree implementation that was a port of a C++ one posted on a blog:
http://code.google.com/p/csharsuffixtree/source/browse/#svn/trunk/suffixtree
Edit
: There is a new project at Codeplex that is focused on suffix trees:
http://suffixtree.codeplex.com/


Question:
I've always been able to allocate 1400 megabytes for Java SE running on 32-bit Windows XP (Java 1.4, 1.5 and 1.6).

java -Xmx1400m ...

Today I tried the same option on a new Windows XP machine using Java 1.5_16 and 1.6.0_07 and got the error:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Through trial and error it seems 1200 megabytes is the most I can allocate on this machine.

Any ideas why one machine would allow 1400 and another only 1200?

Edit: The machine has 4GB of RAM with about 3.5GB that Windows can recognize.

Answer: The JVM needs contiguous memory and depending on what else is running, what was running before, and how windows has managed memory you may be able to get up to 1.4GB of contiguous memory.  I think 64bit Windows will allow larger heaps.


Question: Has anyone ever heard of a UNIX shell written in a reasonable language, like Python?

Answer:
Well, there's emacs, which is arguably a shell written in lisp :)
Seriously though, are you looking for a reimplementation of an existing shell design in a different language such as Python? Or are you looking for a new implementation of a shell language that looks similar to your language of choice?


Question:
How to I get the Fixnum returned by the following:

"abc"[2]

Back into a character?

Answer:
This will do it (if n is an integer):
```
```
n.chr
```
```


Question:
Is there a way for me to add logging so that entering and exiting methods gets logged along with parameters automatically somehow for tracing purposes? How would I do so?

I am using Log4Net.

Answer:
The best way to achieve this sort of thing is by using interception,  There are a couple of ways to do this, though they all tend to be somewhat invasive.  One would be to derive all your objects from ContextBoundObject.
Here
is an example of using this sort of approach.  The other approach would be to use one of the existing AOP libraries to achieve this.  Something like DynamicProxy from the
Castle Project
is at the core of many of these.  Here are a few links:
Spring.Net
PostSharp
Cecil
There are probably several others, and I know
Castle Windsor
, and
Ninject
both provide AOP capabilities on top of the IoC functionality.
Once AOP is in place you would simply write an interceptor class that would write the information about the method calls out to log4net.
I actually wouldn't be surprised if one of the AOP frameworks would give you that sort of functionality out of the box.


Question:
I'm trying to Unit Test a class that has many internal functions. These obviously need testing too, but my Tests project is seperate, mainly because it covers many small, related projects. What I have so far is:

FieldInfo[] _fields =
    typeof(ButtonedForm.TitleButton).GetFields(
        BindingFlags.NonPublic | BindingFlags.Instance |
        BindingFlags.DeclaredOnly);
Console.WriteLine("{0} fields:", _fields.Length);
foreach (FieldInfo fi in _fields)
{
    Console.WriteLine(fi.Name);
}

This spits out all the private members nicely, but still doesn't display internals. I know this is possible, because when I was messing around with the autogenerated tests that Visual Studio can produce, it asked about something to do with displaying internals to the Test project. Well, now I'm using NUnit and really liking it, but how can I achieve the same thing with it?

Answer:
It would be more appropriate to use the
```
InternalsVisibleTo
```
attribute to grant access to the internal members of the assembly to your unit test assembly.
Here is a link with some helpful additional info and a walk through:
The Wonders Of InternalsVisibleTo
To actually answer your question... Internal and protected are not recognized in the .NET Reflection API.  Here is a quotation from
MSDN
:
The C# keywords protected and internal have no meaning in IL and are not used in the Reflection APIs. The corresponding terms in IL are Family and Assembly. To identify an internal method using Reflection, use the
IsAssembly
property. To identify a protected internal method, use the
IsFamilyOrAssembly
.


Question: I'm writing a quick Rails app and was wondering how I can validate the success an exec'd command.  The two commands I'm running are and SVN update, and a cp from one directory to another.

Answer:
For SVN update, check the version number before and after the update.
```
```
svn_start_version = IO.popen("svn info").readlines[4]
`svn update`
svn_end_version = IO.popen("svn info").readlines[4]
if svn_end_version > svn_start_version
  "success"
end
```
```
For the cp, you could do a filesize check on the original file being equal to the copied file.
```
```
source_file_size = IO.popen("du file1").readlines
`cp file1 file2`
dest_file_size = IO.popen("du file2").readlines
if dest_file_size == source_file_size
  "success"
end
```
```


Question: I am VERY new to ASP.NET.  I come from a VB6 / ASP (classic) / SQL Server 2000 background.  I am reading a lot about Visual Studio 2008 (have installed it and am poking around).  I have read about "reflection" and would like someone to explain, as best as you can to an older developer of the technologies I've written above, what exactly Reflection is and why I would use it...  I am having trouble getting my head around that.  Thanks!

Answer:
Reflection is how you can explore the internals of different Types, without normally having access (ie. private, protected, etc members).
It's also used to dynamically load DLL's and get access to types and methods defined in them without statically compiling them into your project.
In a nutshell: Reflection is your toolkit for peeking under the hood of a piece of code.
As to why you would use it, it's generally only used in complex situations, or code analysis. The other common use is for loading precompiled plugins into your project.


Question: I basically have an xml column, and I need to find and replace one tag value in each record.

Answer:
To find a content in an XML column, look into the exist() method, as described in MSDN
here
.
```
```
SELECT * FROM Table
WHERE XMLColumn.exist('/Root/MyElement') = 1
```
```
...to replace, use the modify() method, as described
here
.
```
```
SET XMLColumn.modify('
  replace value of (/Root/MyElement/text())[1]
  with "new value"
')
```
```
..all assuming SqlServer 2005 or 2008.  This is based on XPath, which you'll need to know.


Question:
I've got an app that my client wants to open a kiosk window to ie on startup that goes to their corporate internet.  Vb isn't my thing but they wanted it integrated into their current program and I figured it would be easy so I've got

Shell ("explorer.exe http://www.corporateintranet.com")

and command line thing that needs to be passed is -k

Can't figure out where in the hell to drop this to make it work.  Thanks in advance! :)

Answer:
If you would like to use -k, you will probably want to call
```
iexplore.exe
```
instead of
```
explorer.exe
```
.


Question:
I'm curious what tools people have found useful for building flowcharts. Obviously MS Visio and OmniGraffle come to mind but they both feel so bloated and also tend to emphasize the document formatting/printing side and less on helping to organize the actual logic. Is there anything else out there that fellow developers would recommend?

I'm hoping to find something fairly simple that would let me throw together flowcharts on the fly when I'm working through complex logic. I don't care about formatting or fonts or the like, just something that would help me keep my logic organized as I work through it. Even something that would arrange the chart itself and simply allow me to specify where to branch and what to check, etc.

Any OS would be fine, though I personally lean towards OS X apps as this has recently been my primary work environment.

Answer:
Though you list it as bloated I nonetheless use
OmniGraffle
.
For quick flowcharting a series of boxes with lines to magnets in the boxes is sufficient, but the rest of the formatting options are good to have later. I find that any flowchart I take the time to draw generally ends up in a document somewhere. Even when I'm just trying to understand some difficult code, I end up with a one page document which attempts to explain that code for the next poor schmuck who has to dig in.


Question:
I have a value like this:

"Foo Bar" "Another Value" something else

What regex will return the values enclosed in the quotation marks (e.g. Foo Bar and Another Value)?

Answer:
In general, the following regular expression fragment is what you are looking for:
```
```
"(.*?)"
```
```
This uses the non-greedy *? operator to capture everything up to but not including the next double quote. Then, you use a language-specific mechanism to extract the matched text.
In Python, you could do:
```
```
>>> import re
>>> string = '"Foo Bar" "Another Value"'
>>> print re.findall(r'"(.*?)"', string)
['Foo Bar', 'Another Value']
```
```


Question: I've got 256 colors working great in my terminal (test scripts here), but it stops working when I use ncurses (via Ruby-ncurses). Printing the escape sequences given on that page works fine, but when I initialize ncurses 'puts' stops working and I can't output the colors with any of the various ncurses color changing/string output functions I've found. What gives?

Answer:
I am not sure if this would be all the story, but make sure your terminal capabilities do indeed provide for the 256 colors description.
What is the TERM environment variable value? Try setting it to xterm-256color and rerun it.
ncurses should then get the proper color escape sequences.
You can also test the terminal capabilities and terminal color output with the program we use at SXEmacs development:
http://www.triatlantico.org/tmp/tty-colors.c
Compile with gcc -o tty-colors tty-colors.c -lncurses
EDIT:
Note that just because the scripts that are found on the net output the 256 colors, that is not "all set".
Curses programs rely on terminfo and termcap and the TERM environment variable to find out how to interact with the terminal.
So in order for a curses app to be able to use the 256 colors one should set the TERM variable to an existing terminal name which supports 256 colors.
The C program above will show you
what
ncurses thinks about your terminal, not just output the xterm sequences like most scripts do [even the one from X.org]


Question: I've been unsuccessfully searching for a way to install make utility on my CentOS 5.2. I've looked through some RPM repositories and online, with no avail. Installing gcc, gcc-c++ didn't help! Package build-essential is not made for CentOS/RHEL. I have RPMFORGE repo enabled in YUM.

Answer:
I just double checked and CentOS 5.2 already includes make!
I found it also in one of the online mirrors, if it is easier for you:
http://centos.cogentcloud.com/5.2/os/i386/CentOS/make-3.81-3.el5.i386.rpm
if you installed the 64 bit version:
http://centos.cogentcloud.com/5.2/os/x86_64/CentOS/make-3.81-3.el5.x86_64.rpm


Question:
I have a service app that creates AppDomain's during the course of its use for long running tasks. I've been tracking these by storing them in a Hashtable with a unique ID.

After a task is completed the service app then unloads the AppDomain allocated to that task and then it's removed it from the appdomain Hashtable.

Purely from a sanity checking point of view, is there a way I can query the CLR to see what app domains are still loaded by the creating app domain (i.e. so I can compare the tracking Hashtable against what the CLR actually sees)?

Answer:
```
children
```
is a simple has_many association
This means, when you call
```
.children
```
, it will load them from the database (if not already present). It will then cache them.
I was going to say that your second 'test' will actually be looking at the cached values not the real database, but that shouldn't happen as you are just using
```
Task.count
```
rather than
```
d1.children.count
```
. Hrm
Have you looked at the logs? They will show you the SQL which is being executed. You may see a mysql error in there which will tell you what's going on


Question:
I'm trying to set the width and height of an element with javascript to cover the entire browser viewport, and I'm successful using
document.body.clientHeight
 but in IE6 it seems that I always get horizontal and vertical scrollbars because the element must be slightly too big.

Now, I really don't want to use browser specific logic and substract a pixel or 2 from each dimension just for IE6. Also, I am not using CSS (width: 100% etc.) for this because I need the pixel amounts.

Does anyone know a better way to fill the viewport with an element in IE6+ (obviously all good browsers, too)?

Edit: Thanks Owen for the suggestion, I'm sure jQuery will work. I should have specified that I need a toolkit-agnostic solution.

Answer:
This
may
help the cause ...
From
http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
:
```
```

```
```


Question: Im using delphi's ttreeview as an 'options' menu. how would i go upon selecting the next node at runtime like a previous and next button? i tried the getprev and getnext methods but no luck.

Answer:
Here you have the 'Next' behavior. For 'Previous' I leave as exercise for you: :-)
```
```
procedure TForm8.btn1Click(Sender: TObject);
var
  crt: TTreeNode;

begin
  with tv1 do //this is our tree
  begin
    if Selected=nil then
      crt:=Items[0] //the first one
    else
      crt:=Selected.GetNext; //for previous you'll have 'GetPrev'

    if crt<>nil then //can be 'nil' if we reached to the end
      Selected:=crt;
  end;
end;
```
```
HTH


Question: Actually I will want to use that JeOS for our webserver. Is it a good choice?

Answer:
Here you have the 'Next' behavior. For 'Previous' I leave as exercise for you: :-)
```
```
procedure TForm8.btn1Click(Sender: TObject);
var
  crt: TTreeNode;

begin
  with tv1 do //this is our tree
  begin
    if Selected=nil then
      crt:=Items[0] //the first one
    else
      crt:=Selected.GetNext; //for previous you'll have 'GetPrev'

    if crt<>nil then //can be 'nil' if we reached to the end
      Selected:=crt;
  end;
end;
```
```
HTH


Question: If I modify or add an environment variable I have to restart the command prompt.  Is there a command I could execute that would do this without restarting CMD?

Answer:
By design there isn't a
built in
mechanism for Windows to propagate an environment variable add/change/remove to an already running cmd.exe, either from another cmd.exe or from "My Computer -> Properties ->Advanced Settings -> Environment Variables".
If you modify or add a new environment variable outside of the scope of an existing open command prompt you either need to restart the command prompt, or, manually add using SET in the existing command prompt.
The
latest accepted answer
shows a partial work-around by manually refreshing
all
the environment variables in a script. The script handles the use case of changing environment variables globally in "My Computer...Environment Variables", but if an environment variable is changed in one cmd.exe the script will not propagate it to another running cmd.exe.


Question:
I am involved in development of a tiered application that uses LINQ2SQL separated from the   web server with a NET.TCP Binding on WCF.

My questions are:

What sort of measures should I take
to achieve the best performance?

Since the entity objects returned by
the LINQ need to be converted to a
IEnumerable list to be serialized
everytime, is there anyway to remove
this dependency?

Answer:
1) Concentrate on a properly normalized database design.  I would say that when you are forced to make design tradeoffs in your code vs. database design, if performance is your goal, make tradeoffs in your object design instead of your database design.  Understand that you aren't going to be able to do a proper supertype/subtype database design which will work with Linq to SQL (I'm told you need to use the EF instead).
2) Depends what you mean here.  If you're asking how you would serialize anonymous classes across the wire, the easy answer is: "you can't, so don't try".  If you want to put lists of objects across the wire, just use the ToArray() extension method on your IEnumerable collections to ship arrays of your business objects over the wire.


Question:
I've got a data object with a component in it that is an System.Collections.Generic.IList, and I'd like to reflect changes to that list into a Gtk# NodeView, so that when an item is added to the list, the NodeView will get a new item added to it.

How would I listen for changes to an IList?  I have considered wrapping the IList with a class that implements IList, delegates the requisite methods, and broadcasts an event when changing it's contents, but that seems like a lot of work for something that has probably already been solved by someone else.

Answer:
1) Concentrate on a properly normalized database design.  I would say that when you are forced to make design tradeoffs in your code vs. database design, if performance is your goal, make tradeoffs in your object design instead of your database design.  Understand that you aren't going to be able to do a proper supertype/subtype database design which will work with Linq to SQL (I'm told you need to use the EF instead).
2) Depends what you mean here.  If you're asking how you would serialize anonymous classes across the wire, the easy answer is: "you can't, so don't try".  If you want to put lists of objects across the wire, just use the ToArray() extension method on your IEnumerable collections to ship arrays of your business objects over the wire.


Question:
im currently overiding the WM_NCPAINT, WM_NCCALCSIZE and WM_NCACTIVATE to paint my own color/themed title bar for an application im working on. Now this is working great however the min, max and close buttons still are xp default theme.

I looked into what controls them and the mouse messages do. However they also contol resizing and other functions that I dont want to lose.

Is there an easy way to just change the theme of these buttons?

Windows XP

MFC Forms

Visual studio 2005

Answer:
I think your best bet here is to disable the buttons and redraw them with something akin to to
the code I posted in this answer
. It's in C# with WinForms, but the vast majority of it is overloaded WndProc() anyway, which you should be able to use almost copy/paste into MFC.
Implementing click handlers to do what you want them to do is trivial.
Note: The asker of that question said the code didn't work in Vista. I don't have a Vista box, but it works for me in XP.


Question:
When using one's own iPhone for development it's easy enough to access any crash logs via XCode->Organizer->Crash Logs.

How does one access crash logs on another person's phone if they don't have it set up for development in XCode, as would likely be the case if you were distributing your app to them via ad hoc distribution for beta testing?

Answer:
Two ways:
iTunes syncs all crash reports during a regular sync. They can be found in Library/Logs/CrashReporter/MobileDevice on a Mac and probably somewhere in %APPDATA% on Windows.
You can use the
iPhone Configuration Utility for Mac OS X
on any Mac to access the phone's console and crash logs. Note:
the iPhone Web Configuration Utility, which is available for Windows and Mac (note the "web" in the name)
does not
allow this kind of access and only provides a portion of the Configuration Utility's features
.
Er, no you can't. Xcode provides this facility in the Organizer (from the Window menu), but not iPCU.


Question:
When maintaining a COM interface should an empty BSTR be treated the same way as NULL?
In other words should these two function calls produce the same result?

 // Empty BSTR
 CComBSTR empty(L""); // Or SysAllocString(L"")
 someObj->Foo(empty);

 // NULL BSTR
 someObj->Foo(NULL);

Answer:
Yes - a NULL BSTR is the same as an empty one. I remember we had all sorts of bugs that were uncovered when we switched from VS6 to 2003 - the CComBSTR class had a change to the default constructor that allocated it using NULL rather than an empty string. This happens when you for example treat a BSTR as a regular C style string and pass it to some function like
```
strlen
```
, or try to initialise a
```
std::string
```
with it.
Eric Lippert discusses BSTR's in great detail in
Eric's Complete Guide To BSTR Semantics
:
Let me list the differences first and
then discuss each point in
excruciating detail.
A BSTR must have identical
semantics for NULL and for "".  A PWSZ
frequently has different semantics for
those.
A BSTR must be allocated and freed
with the SysAlloc* family of
functions.  A PWSZ can be an
automatic-storage buffer from the
stack or allocated with malloc, new,
LocalAlloc or any other memory
allocator.
A BSTR is of fixed length.  A PWSZ
may be of any length, limited only by
the amount of valid memory in its
buffer.
A BSTR always points to the first
valid character in the buffer.  A PWSZ
may be a pointer to the middle or end
of a string buffer.
When allocating an n-byte BSTR you
have room for n/2 wide characters.
When you allocate n bytes for a PWSZ
you can store n / 2 - 1 characters --
you have to leave room for the null.
A BSTR may contain any Unicode data
including the zero character.  A PWSZ
never contains the zero character
except as an end-of-string marker.
Both a BSTR and a PWSZ always have a
zero character after their last valid
character, but in a BSTR a valid
character may be a zero character.
A BSTR may actually contain an odd
number of bytes -- it may be used for
moving binary data around.  A PWSZ is
almost always an even number of bytes
and used only for storing Unicode
strings.


Question:
I've been trying to create a Windows Media Player plugin in Visual Studio 2008, and am having great difficulty finding the correct template. MSDN provides advice here, but it does not appear to be relevant to VS2008.

Can anyone suggest how to start a WMP plugin in Visual Studio?

EDIT: Ive accepted this answer because it worked for me, but I'm afraid it isn't the most elegant of solutions. If anyone has a better idea, please add it!

Answer:
Generics doesn't natively support arithmetic. However, it can be done with .NET 3.5,
like so
. The Operator class is part of
MiscUtil
. This then becomes:
```
```
public T Evaluate<T>(T x, T y) {
      switch (Operation)
      {
        case BinaryOp.Add:
            return Operator.Add(x, y);
        case BinaryOp.Subtract:
            return Operator.Subtract(x, y);
     ... etc
```
```
Since you are writing an expression parser, it might be a good idea to use Expression directly, but you're welcome to use the above.


Question:
Many times I will use the same font scheme for static text in a wxPython application. Currently I am making a SetFont() call for each static text object but that seems like a lot of unnecessary work. However, the wxPython demo and wxPython In Action book don't discuss this.

Is there a way to easily apply the same SetFont() method to all these text objects without making separate calls each time?

Answer:
Maybe try subclassing the text object and in your class
```
__init__
```
method just call SetFont()?
Or, do something like:
```
```
def f(C):
  x = C()
  x.SetFont(font) # where font is defined somewhere else
  return x
```
```
and then just decorate every text object you create with with it:
```
```
text = f(wx.StaticText)
```
```
(of course, if
```
StaticText
```
constructor requires some parameters, it will require changing the first lines in
```
f
```
function definition).


Question: How do i delete all the tables in the schema on Apache Derby DB using JDBC?

Answer:
I think most db providers don't allow DROP TABLE * (or similar).
I think the best way would be to SHOW TABLES and then go through each deleting in a loop via a resultset.
HTH.


Question:
Using NHibernate from C# and only HQL (not SQL) in a way that is compatible with MS SQL Server 2005/2008 (and preferably Oracle).

Is there a way to write the order by clause so that nulls will sort at the end of the query results while the non-null results will be sorted in ascending order?

Based on the answer to the question referenced by nickf the answer is:

select x from MyClass x order by case when x.MyProperty is null then 1 else 0 end, x.MyProperty

Answer:
In the Wikipedia example, those instances can be passed into a function that doesn't have to care which class those instances belong to. The function just calls
```
execute
```
on the object passed, and know that the Right Thing will happen.
A typical example of the Strategy Pattern is how files work in Unix. Given a file descriptor, you can read from it, write to it, poll it, seek on it, send
```
ioctl
```
s to it, etc., without having to know whether you're dealing with a file, directory, pipe, socket, device, etc. (Of course some operations, like seek, don't work on pipes and sockets. But reads and writes will work just fine in these cases.)
That means you can write generic code to handle all these different types of "files", without having to write separate code to deal with files versus directories, etc. The Unix kernel takes care of delegating the calls to the right code.
Now, this is Strategy Pattern as used in kernel code, but you didn't specify that it had to be user code, just a real world example. :-)


Question:
I've updated my TortoiseSVN client and now I'm getting the error when trying to update or commit to different repositories:

The requested name is valid, but no data of the requested type was
  found

Any ideas on how I can solve this? Internet Explorer shows up appropriate URL just fine.

TortoiseSVN 1.5.3, Build 13783.

Answer:
This error being reported is a winsock one, rather than being particular to TSVN. From
Windows Sockets Error Codes
:
The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for, e.g. an MX record is returned but no A record - indicating the host itself exists, but is not directly reachable.
It is strange that you can access the host via IE however. Is it possible that in TSVN you've specified a port number that isn't available on the remote host, and IE is accessing the host on port 80?


Question:
Are there LaTeX packages for (more or less) easily drawing Gantt diagrams?

Thanks.

Answer:
I have not used myself, but it looks like PSTricks offers some Gantt chart drawing capabilities.
Main PSTricks site:
http://tug.org/PSTricks/main.cgi
Example of Gantt chart using PSTricks:
http://tug.org/PSTricks/main.cgi?file=Examples/Charts/gantt


Question:
I have a plug-in to an Eclipse RCP application that has a view.  After an event occurs in the RCP application, the plug-in is instantiated, its methods are called to populate the plug-in's model, but I cannot find how to make the view appear without going to the "Show View..." menu.

I would think that there would be something in the workbench singleton that could handle this, but I have not found out how anywhere.

Answer:
You are probably looking for this:
```
```
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewId");
```
```


Question:
I want to update a list of storage devices as the user inserts USB keys, adds external disks and mounts disk images. IOKit's IOServiceAddInterestNotification looks like the way to go, but the obvious use of registering general interest in kIOMediaClass only gives you notifications for unmounting of volumes and then only sometimes.

What's the right way to do this?

Answer:
Would watching
```
/Volumes
```
for changes do what you need?


Question:
I am studying how two-phase commit works across a distributed transaction. It is my understanding that in the last part of the phase the transaction coordinator asks each node whether it is ready to commit. If everyone agreed, then it tells them to go ahead and commit.

What prevents the following failure?

All nodes respond that they are
ready to commit

The transaction
coordinator tells them to "go ahead
and commit" but one of the nodes
crashes before receiving this
message

All other nodes commit successfully, but now the distributed transaction is corrupt

It is my understanding that when the crashed node comes back, its transaction will have been rolled back (since it never got the commit message)

I am assuming each node is running a normal database that doesn't know anything about distributed transactions. What did I miss?

Answer:
No.  Point 4 is incorrect.  Each node records in stable storage that it was able to commit or rollback the transaction, so that it will be able to do as commanded even across crashes.  When the crashed node comes back up, it must realize that it has a transaction in pre-commit state, reinstate any relevant locks or other controls, and then attempt to contact the coordinator site to collect the status of the transaction.
The problems only occur if the crashed node never comes back up (then everything else thinks the transaction was OK, or will be when the crashed node comes back).


Question:
Is there an app or way to browse a directory that requires different login credentials without using a mapped drive?

The issue is given one login credential Windows Explorer only allows you to map it to one drive and disallows using the same login credential to map to a different drive.

Answer:
No.  Point 4 is incorrect.  Each node records in stable storage that it was able to commit or rollback the transaction, so that it will be able to do as commanded even across crashes.  When the crashed node comes back up, it must realize that it has a transaction in pre-commit state, reinstate any relevant locks or other controls, and then attempt to contact the coordinator site to collect the status of the transaction.
The problems only occur if the crashed node never comes back up (then everything else thinks the transaction was OK, or will be when the crashed node comes back).


Question:
I am using the jquery-ui-dialog plugin

I am looking for way to refresh the page when in some circumstances when the dialog is closed.

Is there a way to capture a close event from the dialog?

I know I can run code when the close button is clicked but that doesn't cover the user closing with escape or the x in the top right corner.

Answer:
If I'm understanding the type of window you're talking about, wouldn't
$(window).unload()
(for the dialog window) give you the hook you need?
(And if I misunderstood, and you're talking about a dialog box made via CSS rather than a pop-up browser window, then
all
the ways of closing that window are elements you could register click handers for.)
Edit:
Ah, I see now you're talking about jquery-ui dialogs, which are made via CSS.  You can hook the
X
which closes the window by registering a click handler for the element with the class
ui-dialog-titlebar-close
.
More useful, perhaps, is you tell you how to figure that out quickly.  While displaying the dialog, just pop open FireBug and
Inspect
the elements that can close the window.  You'll instantly see how they are defined and that gives you what you need to register the click handlers.
So to directly answer your question, I believe the answer is really "no" -- there's isn't a close event you can hook, but "yes" -- you can hook all the ways to close the dialog box fairly easily and get what you want.


Question:
I've been hearing a lot about about how the new version of VMWare Fusion can run virtual operating systems in "headless mode".

A Google search makes it clear that other virtualisation products also have similar features, however, I have not been able to find a good description of what this actually means? What is happening when you do this?

Answer:
For anyone that is interested, you can activate headless mode in VMWare Fusion by running the following command in Terminal.app
```
```
defaults write com.vmware.fusion fluxCapacitor -bool YES
```
```


Question:
I'm storing all localizable strings in a ResourceDictionary (in App.xaml) and assign those via the StaticResource markup extension to TextBlock.Text, Button.Content etc.

In Beta 2 and RC0, sometimes parsing the XAML in InitializeComponent() will fail with an AG_E_PARSER_BAD_PROPERTY_VALUE on the line and position where I set the attribute value to the StaticResource.

It only happens sometimes: When restarting the app, it parses and displays without any problems. The same interface code works for days or weeks, then it happens again.

Any ideas?

Answer:
Parser, at least in beta 2, didnt like whitespace...
For instance:
```
```
Text="{StaticResource bleh}"
```
```
worked
however this:
```
```
Text = "{StaticResource bleh}"
```
```
bombed


Question: When logging in C#, how can I learn the name of the method that called the current method? I know all about System.Reflection.MethodBase.GetCurrentMethod(), but I want to go one step beneath this in the stack trace. I've considered parsing the stack trace, but I am hoping to find a cleaner more explicit way, something like Assembly.GetCallingAssembly() but for methods.

Answer:
Try this:
```
```
using System.Diagnostics;
// Get call stack
StackTrace stackTrace = new StackTrace();
// Get calling method name
Console.WriteLine(stackTrace.GetFrame(1).GetMethod().Name);
```
```
one-liner:
```
```
(new System.Diagnostics.StackTrace()).GetFrame(1).GetMethod().Name
```
```
It is from
Get Calling Method using Reflection [C#]
.


Question:
Is there a way to exclude all svn externals when doing a recursive update?

Is there a way to exclude only 1 of all of the svn externals when doing a recursive update?

Basically I'd like to cut down the svn update time, and a couple of the SVN externals that I have will just about never get updated.

Answer:
Yes, there is an option for this (to ignore all):
```
```
> svn update --ignore-externals
```
```
I don't know of any option to specifically ignore one or some externals while updating the rest.


Question:
I've written a small test application using the .Net FileSystemWatcher to keep an eye on a directory. When I copy a large-ish (a few Mb) file into that directory I get the following events listed (see screenshot - and ignore the Delete event to begin with).

alt text http://robinwilson.homelinux.com/FSW.png

I get a created event (as expected), but then two changed events (about 0.7 seconds apart). Why is this? This would cause major problems in the application I am planning to develop - as I'd try and do things with the file twice (presumably once before it has finished being written to!). Is there anything I can do to stop this happening? From what I've read on StackOverflow and elsewhere, you should just get one changed event once the file has been changed and then closed. Why am I getting two?

Answer:
Usually the copying program is doing it in blocks, not entire file at once. I don't think you can do anything to avoid this, you will have to adopt your algorithms to deal with this.
You can perform an attempt to open file with exclusive read rights, which should be granted to your program only when other program finished copying and closed file. Otherwise you will get IOException and you can wait for next change. But this doesn't mean you shouldn't deal with multiply change events. Opening text file in Notepad and saving it once in a while will generate change events, but file will not be locked all the time.
Another approach would be to collect touched files for a period of time, and when FileSystemWatcher stops generating events, process all files at once.


Question:
I'd like to create a subset of Users that don't have a login... basically as a way to add a photographer field to photos without having a full blown account associated with that person (since in many cases, they'll never actually log in to the site). A caveat is that I'd also like to be able to enable an account for them later.

So, I think the question becomes what's the best way to set up a "People" table that ties to the User table without actually extending the User table with UserProfile.

Answer:
A
user profile
(as returned by
```
django.contrib.auth.models.User.get_profile
```
) doesn't extend the User table - the model you specify as the profile model with the
```
AUTH_PROFILE_MODULE
```
setting is just a model which has a
```
ForeignKey
```
to
```
User
```
.
```
get_profile
```
and the setting are really just a convenience API for accessing an instance of a specific model which has a
```
ForeignKey
```
to a specific
```
User
```
instance.
As such, one option is to create a profile model in which the
```
ForeignKey
```
to
```
User
```
can be
```
null
```
and associate your
```
Photo
```
model with this profile model instead of the
```
User
```
model. This would allow you to create a profile for a non-existent user and attach a registered User to the profile at a later date.


Question: How can I elegantly print the date in RFC822 format in Perl?

Answer:
```
```
use POSIX qw(strftime);
print strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())) . "\n";
```
```


Question: Is it possible to get notified (without polling, but via an event) when a drive letter becomes accessible. For example if you have an external hard drive that always appears as drive F - is it possible to have an event raised when that is connected and F becomes accessible?

Answer:
```
```
use POSIX qw(strftime);
print strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())) . "\n";
```
```


Question: I've managed to mostly ignore all this multi-byte character stuff, but now I need to do some UI work and I know my ignorance in this area is going to catch up with me! Can anyone explain in a few paragraphs or less just what I need to know so that I can localize my applications? What types should I be using (I use both .Net and C/C++, and I need this answer for both Unix and Windows).

Answer:
Check out Joel Spolsky's
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
EDIT 20140523
: Also, watch
Characters, Symbols and the Unicode Miracle
by Tom Scott on YouTube - it's just under ten minutes, and a wonderful explanation of the brilliant 'hack' that is UTF-8


Question:
I get the Total length of columns in constraint is too long. erro from the following

sql] Failed to execute:   CREATE TABLE GTW_WORKFLOW_MON ( WORKFLOW_NAME VARCHAR(255) NOT
NULL, WORKFLOW_LOADED NUMERIC(20) NOT NULL, ACTIVITY_NAME VARCHAR(255) NOT NULL, FLAGS
INTEGER NOT NULL, MONITOR_NAME VARCHAR(255) NOT NULL, CLASSNAME VARCHAR(255) NOT NULL, S

TR0 VARCHAR(255), STR1 VARCHAR(255), STR2 VARCHAR(255), NUM0 VARCHAR(255), NUM1
VARCHAR(255), NUM2 VARCHAR(255), DATE0 VARCHAR(255), DATE1 VARCHAR(255), DATE2
VARCHAR(255), PRIMARY KEY (WORKFLOW_NAME,WORKFLOW_LOADED,ACTIVITY_NAME,MONITOR_NAME) )

  [sql] java.sql.SQLException: Total length of columns in constraint is too long.

Answer:
Your primary key constraint is 785 bytes (255+20+255+255).  If you increase your database page size to 4K it should work, barely.  You should also reconsider if you need your columns to be as wide as you are defining them.
I found a discussion group where an engineer, Radhika Gadde,
describes
that the maximum index size is related to page size.  He says:
which error you are getting while creation of Tables.
Maximum Index key length can be calculated as follows:
[(PAGESIZE -93)/5] -1
like for 2k it is
[( 2048-93)/5] -1 =[1955/5] -1 =391-1=390
if PAGESIZE is 4K
it is [(4096-93)/5] -1 =4003/5-1=800-1 =799


Question:
For development, I use a local LAMP stack, for production I'm using MediaTemple's Django Container (which I'm loving BTW).  MT's container uses lighthttpd.  Honestly I've never had any other experience with it. I've always used Apache. I've been doing some reading:

Onlamp

TextDrive

Linux.com

Here's are questions:

What strengths does one have over the other?

Would it benefit me to use lighthttpd on my dev setup?

What's up with using both?  The Linux.com article talks about using lighttpd with Apache.

Answer:
The benefit of both: Apache is more powerful and extensible (useless if you don't need that power, but anyway...) and lighttpd is faster at static content. The idea is of splitting your site into static content (css, js, images, etc) and dynamic code that flows through Apache.
I'm not saying you can't do a lot with lighttpd on its own. You can and people do.
If you're using lighttpd exclusively on your production server, I would seriously consider mirroring that on your development and staging servers so you know exactly what to expect before you deploy.


Question:
I am working on a web-application in which dynamically-created images are used to display information. This data is currently sent to the images using a GET query-string but with more complex images and data I am worried about running into problems with the url character limit.

I could simply pass the record ID to the image and have this query the database but this would obviously increase demand on the server. Is there some way I could add an image retrieved using POST into a HTML document?

Answer:
In the end, I think quering the database will probably be faster. To get a small string (say up to 2000 characters) from the database is very quick and probably faster than having the user post it all the time, especially if there is more than 1 on a page.
The best option would be create the image once and cache it if it doesn't change. When the image is requested again, check to see if it's cached and just use readfile() to send it to the browser. I like to store the cached image outside the doc root so it's not accessible by others, but this may not be a factor in what you're doing (both caching and privacy).
The SESSION might be an option, but this is the best option when you need to regenerate the image on multiple pages with slight changes, so you don't have query the db each time.


Question: Where can I find a list of all types of bsd style socket errors?

Answer:
You can also find a list of error codes (and a general description of their meaning) on the Open Group's pages for each function (like
connect
, for example).


Question: We're starting a large web project, mostly green field. I like the Tapestry framework for java/web solutions. I have concerns about starting a Tapestry 5 project since T5 is still in beta. However, if I understand the documentation correctly, T4 development will not be supported by T5 and up. My question: Should I begin a large project for a large company with T5? If not, with the imminent release of T5, should I ignore T4 altogether?

Answer:
T5 is in the last beta, the next release is RC, and then the full release. according to howard, things should be done by the end of october. so, if you're starting the project, i believe the framework will catch you with its release.
another thing, the betas are pretty quality products, howard does the great job with his framework. at my now previous company, there is a project started in september based on tapestry 5, a colleague managed to get a working example pretty quickly and it seems okay. we worked with tapestry 4 on a previous project, and when the question raised about which version to choose, the fact that T4 will be abandoned in favor of T5, and much changes in the framework concept itself, the counclusion was it's much better for a developer new in tapestry to learn new version immidiately (also, if i were to stay, i was interested in switching to T5 also as soon as possible, because i see a quality improvement in the T5 concepts compared to T4 which i worked with).
of course, you have your deadlines and project limitations which you have to take into account. if it's rather flexibile, or long-lasting project, maybe get a quick start of T5 for a week, and then decide based on your experience with it.


Question:
I've got a few hundred computers running an app.  On one computer, I've seen two instances of a single bit being incorrectly set on some strings that I pull out of SQLite.  If this was my dev computer I would assume I have a bug somewhere, but there is certainly some number of installations at which point I'll start seeing rare hardware based errors.

This is certainly dependent on how much IO I do, but are there any rules of thumbs for when there is a decent chance of seeing this kind of thing?  For example, for TCP packets, this paper determined that silent, undetected corruption will occur in "roughly 1 in 16 million to 10 billion packets".

Unfortunately, running a mem/disk checker on the machine in question is not likely to happen.

Answer:
When I notice strange things happening, my strategy is:
check if there is a bug
in the code
check if there is a bug in the used library/tool (SQLite, here)
check if there is a bug
in the compiler
then, and only then, check for hardware faults
In my 10 years-long career, 99,99% of bugs were software related.
Hope this helps.


Question:
I'd like to zoom and unzoom in ways the base class doesn't support.

For instance, upon receiving a double tap.

Answer:
I'm answering my own question, after playing with things and getting it working.
Apple has a very-simple example of this in their documentation on how to handle double taps.
The basic approach to doing programmatic zooms is to do it yourself, and then tell the UIScrollView that you did it.
Adjust the internal view's frame and bounds.
Mark the internal view as needing display.
Tell the UIScrollView about the new content size.
Calculate the portion of your
internal view that should be
displayed after the zoom, and have
the UIScrollView pan to that
location.
Also key: once you tell the UIScrollView about your new contents size it seems to reset its concept of the current zoom level.  You are now at the new 1.0 zoom factor.  So you'll almost certainly want to reset the minimum and maximum zoom factors.


Question:
I've written up a weekly-review GTD checklist for myself in TiddlyWiki, using CheckboxPlugin. After I'm finished with it each week, I'd like to click one link to uncheck (reset) all of the items on it, so it's ready for the next use.

I'm storing the check information as tags on a separate tiddler page. I should be able to just erase all the tags on that page and refresh the checklist page, but I haven't been able to work out how to do that yet.

I generally work in C, C++, and Lisp, I'm just learning about Javascript. Can anyone offer some useful pointers?

(And before anyone suggests it, I've looked at the ChecklistScript on the same site. It doesn't use the CheckboxPlugin stuff, and isn't compatible with it.)

Answer:
Try this (adapted from ChecklistScript's "resetall" code):
```
```
<html><form style="display:inline">
    <input type="button" value="clear all" onclick="
        var tid='SomeTiddler';
        var list='tag1 [[tag 2]] tag3 tag4';
        var tags=list.readBracketedList();
        store.suspendNotifications();
        for (var t=0; t<tags.length; t++)
            store.setTiddlerTag(tid,false,tags[t]);
        store.resumeNotifications();
        story.refreshTiddler(tid,null,true);
"></form></html>
```
```


Question: What is the difference between #include and #import in C++?

Answer:
Import in VC++:
```
#import
```
is for type libraries or .tlbs (COM stuff).
The content of the type library is converted into C++ classes, mostly describing the COM interfaces for you automatically, and then it is included into your file.
The
```
#import
```
directive was introduced by Microsoft as an extension to the C++ language.  You can read about it at
this MSDN article
.
The
```
#import
```
directive is also used with .NET / CLI stuff.
Import in gcc:
The import in gcc is different from the import in VC++. It is a simple way to include a header at most once only.  (In VC++ and GCC you can do this via
```
#pragma
```
once as well)
The
```
#import
```
directive was officially undeprecated by the gcc team in version 3.4 and works fine 99% of the time in all previous versions of gcc which support
Include:
```
#include
```
is for mostly header files, but to prepend the content to your current file.
```
#include
```
is part of the C++ standard.  You can read about it at
this MSDN article
.


Question:
I've got a WCF Web Service method whose prototype is:

[OperationContract]
Response<List<Customer>> GetCustomers();

When I add the service reference to a client, Visual Studio (2005) creates a type called "ResponseOfArrayOfCustomerrleXg3IC" that is a wrapper for "Response<List<Customer>>".  Is there any way I can control the wrapper name?  ResponseOfArrayOfCustomerrleXg3IC doesn't sound very appealing...

Answer:
Yes. The OperationContractAttribute takes a parameter called Name. You could specify it like this:
```
```
[OperationContract(Name = "NameGoesHere")]
Response<List<Customer>> GetCustomers();
```
```


Question:
I have a stored procedure with the following header:

FUNCTION SaveShipment (p_user_id IN INTEGER, p_transaction_id IN INTEGER, p_vehicle_code IN VARCHAR2 DEFAULT NULL, p_seals IN VARCHAR2 DEFAULT NULL) RETURN INTEGER;

And I am having trouble running it from TOAD's Editor.  I cannot run it as part of a select from dual statement because it preforms DML, but if I try the following syntax which I saw recommended on some forum:

var c integer;
exec :c := orm_helper.orm_helper.SAVESHIPMENT (9999, 31896, NULL, '');
print c;

I get:

ORA-01008: not all variables bound
Details:
BEGIN :c := orm_helper.orm_helper.saveshipment (9999, 31896, null, ''); END;
Error at line 2
ORA-01008: not all variables bound

What's the proper syntax to run this sp manually?

Answer:
Are you calling the stored procedure from another SP?
I think the syntax is (if I recall correctly):
```
```
declare
     c integer;
begin

c:=storedProc(...parameters...);
```
```
Hope this helps.


Question: Is it possible to detect a valid regular expression with another regular expression?  If so please give example code below.

Answer:
Unlikely.
Evaluate it in a
```
try..catch
```
or whatever your language provides.


Question:
I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon.  Some questions to get us going in the right direction:

Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?

Have you already started or plan on starting soon?  Or do you plan on waiting until the final version comes out to get into full swing?

Answer:
Speaking as a library author:
I'm waiting for the final version to be released. My belief, like that of most of the Python community, is that 2.x will continue to be the dominant version for a period of weeks or months. That's plenty of time to release a nice, polished 3.x release.
I'll be maintaining separate 2.x and 3.x branches. 2.x will be backwards compatible to 2.4, so I can't use a lot of the fancy syntax or new features in 2.6 / 3.0. In contrast, the 3.x branch will use every one of those features that results in a nicer experience for the user. The test suite will be modified so that 2to3 will work upon it, and I'll maintain the same tests for both branches.


Question:
I'm working with a webservice that offers almost duplicated code across two namesspaces.  Lets say for example PigFeet and HorseFeet, both namespaces contain a Feet class and other code that works with the Feet class requires it to be part of that same namespace.

Right now In my code I'm forced to do something like this:

if( _animalType == AnimalType.Pig )
{
     //namespace is pigfeet
     PigFeet.Feet feet = new Feet();
     feet.WashFeet();
}

if( _animalType == AnimalType.Horse )
{
     //namespace is horsefeet
     HorseFeet.Feet feet = new Feet();
     feet.WashFeet();
 }

This is leaving me with lots of duplicated code.  Is there a way to choose a namespace more dynamically?

Answer:
In your namespace imports you can assign an
alias
to a specific namespace or member.
```
```
using PigFeet = PigFeet.Feet;
using HorseFeet = HorseFeet.Feet;

//now your sample code should look something like

if( _animalType == AnimalType.Pig )
{
     //namespace is pigfeet
     PigFeet feet = new PigFeet();
     feet.WashFeet();
}

if( _animalType == AnimalType.Horse )
{
     //namespace is horsefeet
     HorseFeet feet = new HorseFeet();
     feet.WashFeet();
 }
```
```


Question:
I am writing a C# program which captures signals from a external device, and sends keystrokes to another application. I am using SendKeys and it works fine.

SendKeys does "press" a key by holding and releasing it immediately. I would like to make it push key and release it at will.

My question is : "is there a way to send a "push" signal to a key, then a "release" signal after a certain amount of time ?"

I am not sure SendKeys is able to do this. Any clue ?

Answer:
I don't think it's possible from .NET directly
You could try using keybd_event native call by p/invoking the function as described here:
http://pinvoke.net/default.aspx/user32.keybd_event
The MSDN for keybd_event is here:
http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx
Hope that helps!


Question:
I've created a web page that lets you input some information and then draws an image in a canvas element based on that info.  I have it pretty much working the way I want except for the printing.

Is there a way to print out the canvas element or is creating a new window to draw in, the only way to do it?

Update:

The answer was so simple.  I was thinking of a lot more complicated solution.

I wish I could pick more than 1 answer.  I wasn't able to get the canvas to print when I used * to disable display.  The simplest solution was to just turn off the form that I was using for input, using form {display:none;} in the CSS inside an @media print{}. Thanks for the quick response.

    @media print {
           form {
         display:none;
       }
    }

Answer:
I'm not 100% sure of the support, but you can use CSS and put an attribute in the
```
<link>
```
tag for
```
media="print"
```
. In this CSS file, just hide the elements you don't want to show while printing:
```
display:none;
```


Question: I understand that they are both supposed to be small, but what are the key differences between the two?

Answer:
Exokernel
is an
operating system from MIT
(and a class of it's variants) which handles relatively little hardware abstraction.  In exokernel, the low-level responsibilities of controlling hardware (particularly
memory allocation
) are often left in the hands of the developer.  Many developers would probably prefer to have the OS take more responsibility of such low-level tasks, because most developers are just writing applications.
An exokernel just
allocates physical hardware resources to programs
.  This allows the program to use library operating systems, which are linked in to provide some of the abstraction that the exokernel isn't providing.  The developer can then choose between abstraction models, or roll their own.  Given the application, this may have great performance benefits.  If you don't know what you're doing, you can also write programs that will explode when they crash.
Most kernels will do more to
abstract physical hardware
resources into some kind of
theoretical model
.  A developer interfaces with this model, which handles the finer points of dealing with hardware internally.
The term
nanokernel
is used to describe a specific
type of kernel
.  The prefix "pico-", or "nano-", "micro-" is usually denoting the "size" of the kernel..
Bigger kernels
are more built with more features, and
handle more hardware abstraction
.  Nanokernels are relatively small kernels which
provide hardware abstraction
, but
lack system services
.  Modern microkernels also lack system services, so the terms have become analogous.
The
names of kernels
usually stem from a specific batch of research which yielded a new kind of kernel, for example the kernel developed at at Carnegie Mellon called "Mach", which was one of the first examples of a modern "microkernel".
Sidenote:
The real benefit of exokernel is choice.  Most of the time, a lot of abstraction means fewer catastrophic bugs.  In some applications, you might want to use a different abstraction model, or you might want to handle everything yourself.  If we wanted to scrap the OS abstraction for a particular project, we'd have to cut out the operating system and commit a piece of hardware to the job.  In the case of exokernel, this isn't necessary.  We can program directly "to the metal", but also choose to link in an abstraction model whenever we like.  It's a very powerful concept.
Sidenote
: Dealing with memory on such a low level is unnecessary for most application developers.  There are usually several layers of operating system built on top of a kernel, and your application will run on the highest level of the OS.  When writing in javascript, you're higher up still, interfacing with a model implemented in an application which runs on an operating system, etc. etc.  Addressing memory, while it shouldn't be ignored, might mean something entirely different to a developer who is writing on such a high level of abstraction.


Question:
I have a method that takes an IQueryable. Is there a LINQ query that will give me back the size of each column in the IQueryable?

To be more clear: this is Linq-to-objects.  I want to get the length of the ToString() of each "column".

Answer:
It depends.  If you mean is there a completely generic way to make this determination the answer is no.  All IQueryable will give access to is the Type of each expression.  There is no way to arbitrarily map a Type to a column size.
If on the other hand you have the ability to map a Type to members and member type to a column size then yes there is a way to get the size.
```
```
public IEnumerable GetColumnSize(IQueryable source)
{
  var types = MapTypeToMembers(source).Select(x => x.Type);
  return types.Select(x => MapTypeToSize(x));
}
```
```