instruction
stringlengths
0
30k
The misconception that I often see is that TDD ensures good results. Often times tests are written off of flawed requirements, and therefore, the developers produce a product that does not do what the user is expecting. Key to TDD is, in my opinion, working with the users to define requirements while helping manage ...
All objects in Javascript are implemented as hashtables, so their properties can be accessed through the indexer and vice-versa. Also, you can enumerate all the properties using the **for/in** operator: var x = {a: 0}; x["a"]; //returns 0 x["b"] = 1; x.b; //returns 1 for (p in x) docum...
Most documentation for Silverlight 2.0 example projects along with the source code is to be found on the Web. A goldmine for finding new and relevant stuff is to do a daily look at http://geekswithblogs.net/WynApseTechnicalMusings/Default.aspx, where links are posted to all the good stuff as it becomes available.
It is helpful in the particular case you describe. Consider the following: 1) You are at the start of a development cycle. It is always easier to make these types of changes at the start of or between cycles as opposed to in the middle of one. Given this principle, your next convenient time to upgrade (if the sch...
I don't think that a large application like yours will compile to machine code. Remember that java is not only java syntax (might compile to machine code) but also a virtual machine which is more like an application / process environment. I would suggest making an [uberjar][1] or like that instead. [1]: http://c...
It is normal for some processes to hang around for a while after they close their stdout (ie. you get an end-of-file reading from them). You need to call proc.WaitForExit() after reading all the data but before checking ExitCode.
IsNull function in DB2 SQL?
|sql|db2|null|
Is there a performant equivalent to the isnull function for DB2? Imagine some of our products are internal, so they don't have names: Select product.id, isnull(product.name, "Internal) From product Might return: 1 Socks 2 Shoes 3 Internal 4 Pants
I would avoid sending exceptions directly back to the client unless you are okay with that much detail being sent back. I would recommend using WCF faults to transmit your error message and code (something that can be used to make a decision on the receiver to retry, error out, etc) depending if it is the sender or ...
There is a script referenced here: http://www.webapper.net/index.cfm/2008/7/22/ColdFusion-SQL-Injection that will do the majority of the heavy lifting for you. All you have to do is check the queries and make sure the syntax will parse properly. There is no excuse for not using CFQueryParam, apart from it being mu...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. *(But the answers to this post have helped a **lot**.)* What can I d...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. *(But the answers to this post have h...
In this case I think your best bet might be to write a custom classloader to handle all classloading in your application, and whenever an exception class is requested you return a class that wraps the requested exception class. This wrapper calls through to the wrapped exception but also logs the exception event.
Unless you're running your Actionscript on the server side (I doubt that), connecting to a database directly wouldn't be very smart at all. To connect to a database from client side Actionscript you'd have to open your server to accept database connections from everyone, and you'd have to store access data in your swf ...
Unless you're running your Actionscript on the server side (I doubt that), connecting to a database directly wouldn't be very smart at all. To connect to a database from client side Actionscript you'd have to open your server to accept database connections from everyone, and you'd have to store access data in your swf ...
The new debugging hooks in Java 1.5 let you do this. It enables e.g. "break on any exception" in debuggers. [Here's the specific Javadoc][1] you need. [1]: http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jdi/com/sun/jdi/event/ExceptionEvent.html
Oracle is this way. SELECT * FROM dual WHERE NULL=null; --no rows returned
signed char has range -128 to 127 unsigned char has range 0 to 255 char will be equivalent to either signed char or unsigned char, depending on the compiler, but is a distinct type. If you're using C-style strings, just use char. If you need to use chars for arithmetic (pretty rare), specify signed or unsigned e...
How do I add a namespace reference to a SOAP response with Apache Axis2 and Java
|apache-axis|soap|java|namespaces|
I'm looking at the SOAP output from a web service I'm developing, and I noticed something curious: <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface"> <newKeys> ...
As stated by Jay, there are several client tools you can use to query the cubes that give the end user the ability to drag and drop dimensions for ad-hoc querying. ProClarity has been acquired by Microsoft, and most of the functionality is being incorporated into PerformancePoint Panorama Software (original deve...
> The basic difference between UNION and UNION ALL is union operation eliminates the duplicated rows from the result set but union all returns all rows after joining. frin http://zengin.wordpress.com/2007/07/31/union-vs-union-all/
> The basic difference between UNION and UNION ALL is union operation eliminates the duplicated rows from the result set but union all returns all rows after joining. from http://zengin.wordpress.com/2007/07/31/union-vs-union-all/
For the kernel to be 64-bit would only bring the effective advantage that kernel extensions (i.e., typically drivers) could be 64-bit. In fact, you'd need to have either all 64-bit kernel extensions, or (as is the case now) all 32-bit ones; they need to be native to the architecture of the running kernel.
Which is the best way to bring a file from a remote host to local host over an SSH session?
|ssh|
When connecting to remote hosts via ssh, I frequently want to bring a file on that system to the local system for viewing or processing. Is there a way to copy the file over without (a) opening a new terminal/pausing the ssh session (b) authenticating again to either the local or remote hosts which works (c) even when...
When connecting to remote hosts via ssh, I frequently want to bring a file on that system to the local system for viewing or processing. Is there a way to copy the file over without (a) opening a new terminal/pausing the ssh session (b) authenticating again to either the local or remote hosts which works (c) even when...
Garbage Collection
|.net|garbage-collection|
Is it necessary to set large objects to null when implementing a Dispose method?
The CPU can be switched from 64 bit execution mode to 32 bit when it traps into kernel context, and a 32 bit kernel can still be constructed to understand the structures passed in from 64 bit user-space apps. The MacOS X kernel does not directly dereference pointers from the user app anyway, as it resides its own se...
WSE2.0 uses Kerberos authentication if you're using an AD domain: http://msdn.microsoft.com/en-us/library/ms977323.aspx#program_topic8 I don't think there's a way to convince the kerberos ticketing system to allow clients that far out of sync to communicate. (it's been a hassle adding new client machines to my netw...
Does [this](http://geeknotes.wordpress.com/2007/03/21/more-wse-issues-timestamp-validation-and-clock-skew/) help? It also mentions setting timeToleranceInSeconds and defaultTtlInSeconds on the client as well as the server.
ORA-00933: SQL command not properly ended
|oracle-database|
I'm using OLEDB provider for ADO.Net connecting to an Oracle database. In my loop, I am doing an insert: insert into ps_tl_compleave_tbl values('2626899', 0, TO_DATE('01/01/2002', 'MM/DD/YYYY'), 'LTKN', 'LTKN', '52', TO_DATE('01/01/2002', 'MM/DD/YYYY'), 16.000000, 24.000)insert into ps_tl_compleave_tbl values('432...
|sql|oracle-database|
semi colon after the first insert?
Penetration testing tools
|sql|security|injection|
We have 100s of websites which were developed in asp, .net and java... and we are paying lot of money for an external agency to do a penetration testing for our sites to check for security loop holes. Are there any (good) software (paid or free) to do this? or.. are there any tehnical articles which can help me d...
Oracle SQL uses a semi-colon ; as its end of statement marker. you will need to add the ; after bother insert statments. NB: that also assumes ADODB will allow 2 inserts in a single call. the alternative might be to wrap both calls in a block, BEGIN insert (...) into (...); insert...
Here's the methods form. <pre> allDates .GroupBy(d => d.Year) .Select(g => g.ToList()) .ToList(); </pre>
This has something to do with the way name resolution works. Basically, we first find the scope from which the name comes, and then we collect all overloads for that name in that scope. However, the scope in your case is class B, and in class B, B::DoSomething **hides** A::DOSomething: 3.3.7 Name hiding ...
C++ Unit Testing Legacy Code: How to handle #include?
|c++|unit-testing|legacy|
I've just started writing unit tests for a legacy code module with large physical dependencies using the #include directive. I've been dealing with them a few ways that felt overly tedious (providing empty headers to break long #include dependency lists, and using #define to prevent classes from being compiled) and was...
ASP.net Membership Provider - Switching Between Forms and Integrated Auth
|asp.net|authentication|
I'm writing a web application that I want to be able to use forms authentication pointing to a SQL database, or use integrated authentication in different installations of the web app. I'm authenticating users just fine with either provider but I have a question on how to architect my database. Currently what I'm d...
I'm writing a web application that I want to be able to use forms authentication pointing to a SQL database, or use integrated authentication in different installations of the web app. I'm authenticating users just fine with either provider but I have a question on how to architect my database. Currently what I'm d...
To do this in Python (i.e. not wrapping scp through subprocess.Popen or similar) with the [Paramiko][1] library, you would do something like this: import os import paramiko ssh = paramiko.SSHClient() ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts"))) ssh.co...
While alternatives to subversion may be nice, subversion with lipstick may do just fine. Here's a review of front ends for subversion that run on Macs: http://www.geocities.com/~karlvonl/blog/2006/03/daddy-needs-new-subversion-gui.html
close() is a system call. It will close the file descriptor in the kernel, but will not free the FILE pointer and resources in libc. You should use fclose() on the FILE pointer instead, which will also take care of closing the file descriptor.
Proxy settings in Firefox don't "stick"
|javascript|firefox|proxy|
At home we have a proxy server. At work we don't. Firefox irritates in this regard: whenever I launch it, it defaults to the proxy server. If I do Tools>Options>Settings and select "No proxy", no problem. However, if I shutdown Firefox and restart it, I have to do the Tools>Options>Settings thing all over again because...
A tip: If you are going to write the regex in Perl, please use the "xms" options so that you can leave spaces and document the regex. For example you can write a regex like: m{\w+ \s+ #return type \w+ \s* #function name [(] [^)]* [)] #params \s* [{] #open paren ...
Something that I use on projects is a statusInd tinyint not null default 0 column using statusInd as a bitmask allows me to perform data management (delete, archive, replicate, restore, etc.). Using this in views I can then do the data distribution, publishing, etc for the consuming applications. If performance is a c...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
Ants Profiler just released version 4. We use it, and are quite happy with it. There's a 14 day trial to evaluate (as is true for most offerings).
1. List comprehensions. I often find myself filtering/mapping lists, and being able to say <code>[line.replace("spam","eggs") for line in open("somefile.txt") if line.startswith("nee")]</code> is really nice. 2. Functions are first class objects. They can be passed as parameters to other functions, defined inside ...
Basically you instrument your code to analyze your software as it is running (dynamic) rather than just analyzing the software without running (static). Also see this [JavaOne presentation comparing the two][1]. [Valgrind][2] is one example dynamic analysis tool for C. You could also use code coverage tools like [Cober...
How do I add a namespace reference to a SOAP response with Apache Axis2 and WSDL2Java
|java|soap|namespaces|apache-axis|wsdl2java|
I'm looking at the SOAP output from a web service I'm developing, and I noticed something curious: <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface"> <newKeys> ...
SelectedIndexChanged event handler getting old index
|c#|asp.net|webforms|
I'm handling the onSelectIndexChanged event. An event is raised when the DropDownList selection changes. the problem is that the DropDownList still returns the old values for SelectedValue and SelectedIndex. What am I doing wrong? Here is the DropDownList definition from the aspx file: <div style="margin: 0px...
There's probably some malformed markup somewhere in your document. Have you tried it on a fresh document?
Why bother? What "processing" are you doing? Unless it's very complex, it's probably faster to just do the calculation again, rather then waste time looking things up in a huge map or hashtable. This is one of the more counter-intuitive things about modern cpu's. Computation is fast, memory is slow. I realize ...
Check out [Thread.UncaughtExceptionHandler](http://java.sun.com/javase/6/docs/api/java/lang/Thread.UncaughtExceptionHandler.html). You can set it per thread or a default one for the entire VM. This would at least help you catch the ones you miss.
Depending on where the bug is, you could try going straight to the QuickTime C APIs to write the movie file. You might also try adding the chapters track using the C APIs. Any word on when Apple will fix the bug? I am planning to create enhanced podcasts with QTKit, and need this to work.
Use [FoxyProxy][1], much more flexible to configure [1]: http://foxyproxy.mozdev.org/
Though this doesn't answer your question exactly, here's one way to generate every permutation of the letters from a number of strings of the same length: eg, if your words were "coffee", "joomla" and "moodle", you can expect output like "coodle", "joodee", "joffle", etc. Basically, the number of combinations is the...
How to do hit-highlighting of results from a SQL Server full-text query
|c#|sql-server|full-text-search|
Microsoft's Search Server 2008 has hit highlighting support built in, but SQL Server (2008) does not seem to have it. Do we need to build this from scratch or is there perhaps some libraries or knowledge around on how to do this? Thanks.
We have a web application that uses SQL Server 2008 as the database. Our users are able to do full-text searches on particular columns in the database. SQL Server's full-text functionality does not seem to provide support for hit highlighting. Do we need to build this ourselves or is there perhaps some libraries or kno...
Long ago, I used a C++ interpreter called CodeCenter. It was pretty nice, although it couldn't handle things like bitfields or fancy pointer mangling. The two cool things about it were that you could watch when variables changed, and that you could evaluate C/C++ code on the fly while debugging. These days, I think ...
I used gacutil - installutil to to test your class (as a dll). The gacutil part worked, but installutil (actually mofcomp) complained about a syntax error: ... error SYNTAX 0X80044014: Unexpected character in class name (must be an identifier) Compiler returned error 0x80044014 ... So I changed the clas...
For memory profiling you have both the free CLR profiler and the commercial [.NET memory profiler][1]. Both are excellent but the latter is a bit more polished. [1]: http://memprofiler.com/
Here is a clever little way to do this using reflection: The basic idea: * Use a common base class for each Object class. * Put all of these classes in their own assembly. * Put this factory in that assembly too. * Pass in the KeyValuePair<String,String> that you read from your config, and in return it finds t...
**EDIT:** Scratch that, this still applies, but I think what your doing is reading a configuration file and parsing it into this: List<List<KeyValuePair<String,String>>> itemConfig = new List<List<KeyValuePair<String,String>>>(); In this case, we can still use a reflection factory to instantiate...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
**Original Question** I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (*But the answers to this post have h...
How to setup VIM properly for editing Python files - *.py
|python|vim|configuration|spaces|ident|
I've troubles setting VIM (7.1.xxx) for editing python files. Identing seems broken (optimal 4 spaces). I've followed some tutorials I found via google. Still no effect :/ Please help.
Yes, you can do this in Visual Studio C++ in versions 2005 and beyond (not sure about VS 2003). Take a look at __VA_ARGS__. You can basically do something like this: #define DBGPRINTF(fmt, ...) printf(fmt, __VA_ARGS__) and the variable arguments to the macro will get passed to the function provided as '......
I have good experiences with both phpThumb and Wideimage. Wideimage is the more modern PHP5 approach while phpThumb has much more features.
I only know the other way. [Dbo4][1] is developed in java and the c# version is generated from the java sources automaticaly. [1]: http://www.db4o.com/
The 'crap' placed in front of the id is related to the container(s) of the control and there is no way (as far as I know) to prevent this behavior, other than not putting it in any container. If you need to refer to the id in script, you can use the ClientID of the control, like so: <script type="text/javasc...
What you're looking for are called [variadic macros](http://msdn.microsoft.com/en-us/library/ms177415(VS.80\).aspx). Summary of the link: yes, from VC++ 2005 on up.
There is no good way. My recommendation is to start over in Java, or like you said use Mono.
Ideally you are aiming for a **separation of concerns** between your presentation (UI) code and your domain (business logic) code. The reason why you should avoid coupling these two concerns (in either direction) is simple... You will only have **one reason to change** a piece of code. whether this is from struct...