instruction
stringlengths
0
30k
MSDN says that you should use structs when you need lightweight objects. Are there any other scenarios when a struct is preferable over a class? **Edit:** Some people have forgotten that: 1. *structs* can have methods! 2. *structs* have no inheritance capabilites. **Another Edit:** I understand the te...
Converting floating point exceptions into C++ exceptions
|c++|exception|floating-point|signals|
Is it possible to convert floating point exceptions (signals) into C++ exceptions on x86 Linux? This is for debugging purposes, so nonportability and imperfection is okay (e.g., if it isn't 100% guaranteed that all destructors are called).
Are you 100% sure that's the line of code that's throwing the exception? I'm pretty certain that the FindControl method is not capable of throwing an ArithmeticException. Of course, I've been known to be wrong before... :)
How can I make a ComboBox non-editable in .net?
|.net|c#|vb.net|winforms|
I want to have a "select-only" ComboBox that provides a list of items for the user to select from. Typing should be disabled in the text portion of the ComboBox control. My initial Googling of this turned up an overly complex, misguided suggestion to capture the KeyPress event.
|.net|winforms|
How about writing an IQueryable wrapper like this: class QueryableWrapper<T> : IQueryable<T> { private IQueryable<T> _InnerQueryable; private bool _HasExecuted; public QueryableWrapper(IQueryable<T> innerQueryable) { _InnerQueryable = innerQueryable; ...
I've downloaded the IKVM sources (http://www.ikvm.net/) from http://sourceforge.net/cvs/?group_id=69637 Now I'm trying to get it to build in Visual Studio 2008 and am stuck. Does anyone know of documentation of how to build the thing, or could even give me pointers? I've tried opening the ikvm8.sln, which opens a...
I've downloaded the IKVM sources (http://www.ikvm.net/) from http://sourceforge.net/cvs/?group_id=69637 Now I'm trying to get it to build in Visual Studio 2008 and am stuck. Does anyone know of documentation of how to build the thing, or could even give me pointers? I've tried opening the ikvm8.sln, which opens a...
If the input goes beyond the business rule implemented by the business object, I'd say it's a case not handled by the busines object. Therefore I'd throw an exception. Even though the setter would "handle" a 5 in your example, the business object won't. For more complex combinations of input, a vaildation method is ...
Network I/O is not a priority for AIO because everyone writing POSIX network servers uses an event based, non-blocking approach. The old-style Java "billions of blocking threads" approach sucks horribly. Disk write I/O is already buffered and disk read I/O can be prefetched into buffer using functions like posix_fa...
Take a look at [Glade](http://glade.gnome.org) and [Gtk](http://www.gtk.org). Both are really easy to use. Glade is the GUI builder, and Gtk the toolkit. It's both cross platform and cross language. You can load the Glade files in almost any language. Here is a [Glade/Gtk tutorial](http://www.micahcarrick.com/12-24-200...
In general I consider toString() low cost when I use it on simple objects, such as an integer or very simple struct. When applied to complex objects, however, toString() is a bit of crap shoot. There are two reason's for this. First, complex objects tend to contain other objects, so a single call to toString() can c...
I've deparsed it, and it really shouldn't be faster. The opcode tree for the first is LISTOP (0x8177a18) leave [1] OP (0x8176590) enter COP (0x8177a40) nextstate LISTOP (0x8177b20) scope OP (0x81779b8) null [174] UNOP (0x8177c40) dofile ...
You might like to consider [the approach taken by the Spring framework][1]. If you're using Java (or .NET), you can use Spring as-is, but even if you're not, you could still use that pattern; you'd just have to write your own implementation of it. [1]: http://static.springframework.org/spring/docs/2.5.x/referenc...
What is the best way to connect remotely to a mac
|macos|desktop|controls|
I'm trying to remotely control a macintosh computer. I know that in the windows world, you can use Remote Desktop to connect from one windows computer to another windows computer. This works relatively well. I know that you can use a VNC server but this isn't always the most secure or give the best performance. ...
Use [TortoiseSVN][1] merge utility with the [xdocdiff][2] plugin to compare and merge Office documents [1]: http://tortoisesvn.tigris.org/ [2]: http://freemind.s57.xrea.com/xdocdiff/e/index.html
You must delete the link to the table and create a new one. When a table is linked all the connection info about the table's path, structure (including primary key), permissions, passwords and statistics are stored in the Access db. If any of those items change in the linked table, refreshing links won't automaticall...
Stack overflows in java are almost always caused by infinite recursion / method calls. In your case given the stack trace, it appears 'getAttribute()' is being called repeatedly until crash. While I'm not intimately familiar with the particular environments you are using, I would suggest checking your .jsp code for a...
I would add the [svn:needs-lock](http://svnbook.red-bean.com/en/1.5/svn.advanced.locking.html) property to Word documents stored in Subversion so that people are required to lock the file before editing it. This will go a long way to prevent merge conflicts. This is what we do at work and it works great. (We don't h...
Or use JUnit test cases and a code coverage tool for some common components of yours. If there are components that call other components, you'll quickly see those executed many more times. I use Clover with JUnit test cases, but for open-source, I hear EMMA is pretty good.
Using: lst = [8, 8, 9, 9, 7, 15, 15, 2, 20, 13, 2, 24, 6, 11, 7, 12, 4, 10, 18, 13, 23, 11, 3, 11, 12, 10, 4, 5, 4, 22, 6, 3, 19, 14, 21, 11, 1, 5, 14, 8, 0, 1, 16, 5, 10, 13, 17, 1, 16, 17, 12, 6, 10, 0, 3, 9, 9, 3, 7, 7, 6, 6, 7, 5, 14, 18, 12, 19, 2, 8, 9, 0, 8, 4, 5] And using the timeit module: $ ...
Try: Select Sum( DateDiff( Minute, IsNull((Select Start where Start!='9999.12.31'),GetDate()), IsNull((Select End where End!='9999.12.31'),GetDate()) ) )
Try: Select Sum( DateDiff( Minute, IsNull((Select Start where Start!='9999.12.31'),GetDate()), IsNull((Select End where End!='9999.12.31'),GetDate()) ) ) from *tableName*
After many tries for plugin-based Java architectures (what is precisely what you seem to look for), I finally found [JSPF][1] to be the best solution for Java5 code. it do not have the huge needs of OSGI like solutions, but is instead rather easy to use. [1]: http://code.google.com/p/jspf/
I'd recommend you go with REST first - if you're using Java look at JAX-RS and the [Jersey](https://jersey.dev.java.net/) implementation. REST is much simpler and easy to interop in many languages. As others have said in this thread, the problem with SOAP is its complexity when the other WS-* specifications come in...
You may be interested in [lxml][1]. It is a separate package and has C components, but is the fastest. It has also very nice API, allowing you to easily list links in HTML documents, or list forms, sanitize HTML, and more. It also has capabilities to parse not well-formed HTML (it's configurable). [1]: http://co...
Non-blocking pthread_join
|c|multithreading|pthreads|
Is there a way of doing a non-blocking pthread_join? Some sort of timed join would be good to.
Is there a way of doing a non-blocking pthread_join? Some sort of timed join would be good to. I'll try to clarify the question: I'm coding the shutdown of a multithreaded server. If everything goes as it should all the threads exit by their own, but there's a small chance that a thread gets stuck. In this c...
You could use SQL for this: $file = 'backups/mytable.sql'; $result = mysql_query("SELECT * INTO OUTFILE '".$file."' FROM ##TABLE##"); Then just point a browser or FTP client at the directory/file (backups/mytable.sql). This is also a nice way to do incremental backups, give the filename a timestamp for example. ...
I am especially interested in preserving commit history. If I rename and move branches around in SVN after the conversion, will the history be preserved?
I suppose the only thing that really speaks against them is excessive abstraction. If you will have a good idea what the alias refers to (good naming helps; 'a', 'b', 'c' can be quite problematic especially when you're reading the statement months or years later), I see nothing wrong with aliasing. As others have sa...
I have tried it out couple of times, mainly for viewing existing classes. If it would show all the relationships, it would be more usefull. Now it only shows inheritation.
I find it useful sometimes, more often for documentation afterwards. It's a new little utility, but I don't think you get the full functionality in VS Pro - I think you need Architect's Edition.
You'll need a crossdomain.xml policy file on the server that has the file you load, it should look a something like this: <?xml version="1.0"?> <!-- http://www.foo.com/crossdomain.xml --> <cross-domain-policy> <allow-access-from domain="www.friendOfFoo.com" /> <allow-access-from domain="*...
<blockquote>I am especially interested in preserving commit history. If I rename and move branches around in SVN after the conversion, will the history be preserved?</blockquote> Yes. Subversion also keeps track of changes to the directory structure, and all version history is preserved even if a file is moved in th...
TestNG's biggest draw cards for me include its support test groups, and more importantly - test group dependencies (marking a test as being dependent of a group causes the tests to simply skip running when the dependent group fails). TestNG's other big draw cards for me include test parameters, data providers, annot...
1) Declare a Public event in the user control 2) Issue a RaiseEvent where appropriate inside the user control 3) In the Init event of the parent page, use AddHandler to assign the control.event to the the handling procedure you want to use Simple as that!
Yep. Operators are not overloadable. Only methods. Some operators are not really. They're sugar for methods. So `5 + 5` is really `5.+(5)`, and `foo[bar] = baz` is really `foo.[]=(bar, baz)`.
Make sure you load the control on every postback - if the control isn't in the tree of controls when the page posts back, ASP.NET will not raise the button click event.
I routinely do that because for me the concept of "user" (username, password, create date, last login date) is different from "person" (name, address, phone, email). One of the drawbacks that you may find is that your queries will often require more joins to get the info you're looking for. If all you have is a login...
It's just a convention. Structs can be created to hold simple data but later evolve time with the addition of member functions and constructors. On the other hand it's unusual to see anything other than public: access in a struct.
A quick Google for "jslint ant task" reveals [jslint4java](http://code.google.com/p/jslint4java/), which apparently includes an Ant task.
Try switching the <a href="http://tidy.sourceforge.net/docs/quickref.html#clean">clean</a> option off.
Maven plugins for javascript
|javascript|pmd|findbugs|maven-2|static-analysis|
Javascript code can be tough to maintain.<br> I am looking for tools that will help me ensure a reasonable quality level.<br> So far I have found [JsUNit][1], a very nice unit test framework for javascript. Tests can be run automatically from ant on any browser available.<br> I have not found yet some javascript equ...
|javascript|maven-2|static-analysis|jslint|
Yes I stand corrected, my bad, learning something new every day. Here's my attempt at making up for it :) : - Register the devices you want to use for raw input (the two keyboards) with ::RegisterRawInputDevices(). - You can get these devices from GetRawInputDeviceList() - After you've registered your devic...
Adobe Flash (http://www.adobe.com/products/flash/)
I have been making a little toy web application in C# along the lines of Rob Connery's Asp.net MVC storefront. I find that I have a repository interface, call it IFooRepository, with methods, say IQueryable<Foo> GetFoo(); void PersistFoo(Foo foo); And I have three implementations of this: ISqlFooRepos...
Let some testers loose on it. Nothing is more motivating than seeing people use your interesting bits and finding obvious improvements.
I had to walk away from my PC when I saw the first answer, and am still distressed that it has been approved by so many people. It's an appalling example of the very worst kind of ASP code, the kind that would ensure your site is SQL-injectable and, if you continue using this code across the site, hackable within an i...
If all you have is a hammer, every problem begins to look like a nail. There are times when having a screwdriver or pair of pliers makes a complicated problem trivial. Nobody asks contractors, carpenters, etc, "Why learn to use a screwdriver if i already have a hammer?". Really good contractors/carpenters have...
I had this same question when I first encountered design patterns. I appreciated the concepts, but didn't know when or how to apply them. My initial approach was to look for applicability during the design phase. Once you have a block diagram and semi-clear responsibilities for each block, its not too hard to take t...
Here's an odd case: static class A { ... } static class B extends A implements Comparable<A> { public int compareTo(A o) { return ...; } } Luckily code like the one above is rare, but nullCompare() will not support comparison of Bs unless it is stated t...
Due to the way signals and exceptions work, you can't do it immediately when the signal is thrown - exceptions rely on certain aspects of the stack that aren't true when a signal handler gets called. You can set a global variable in the signal handler, and then check this at key points in the program and throw an ex...
Haven't done it yet with WCF but plan to have a local DNS entry pointing to our Network Load Balancing (NLB) virtual iP address which will direct all traffic to one of our servers hosting services within IIS. I have used NLB for this exact scenario in the past for web sites and see no reason why it will not work well w...
As Leigh Caldwell has stated, the query optimizer can produce different query plans based on what functionally looks like the same SQL statement. For further reading on this, have a look at the following two blog postings:- [One posting from the Oracle Optimizer Team][1] [Another posting from the "Structured Data...
I would not recommend JScript as that is definitely the road less traveled. ASP.NET MVC is rapidly maturing, and I think that you could begin a migration to it, simultaneously ramping up on the ASP.NET MVC framework as its finalization comes through. Another option would be to use something like ASP.NET w/Subsonic or...
The way to decide varys between 2 main few things 1. Is the data going to be accesses constantly 2. Is there a lot of data If you are constanty using the data in the tables, then load them on first use. If you only occasionally use the data, fill the table when you need it and then discard it. For example, if ...
If you're just looking at values of cells you can store the values in an array of variant type. It seems that getting the value of an element in an array can be much faster than interacting with Excel, so you can see some difference in performance using an array of all cell values compared to repeatedly getting single...
I'd skip JNI entirely, and use an external program which writes notifications on standard-output. Java can then simply read from the programs output stream and generate whatever event is necessary. JNI is way too much work if all you want is to send simple notifications. Also, on Linux you can simply start "inotifyw...
Have you tried the [Google Charts API][1]? - web service APIs don't really come much simpler. It's free to use, simple to implement, and the charts don't look too shoddy. [1]: http://code.google.com/apis/chart/
Here are the reserved words for MS Query: http://support.microsoft.com/kb/125948 Cell naming rules: http://ezinearticles.com/?Rules-For-Naming-Cells-in-Microsoft-Excel&id=218607
If i was to tacke this issue I would do this: 1. Plan for some kind of a DOM for html pages. starts at lightweight and then add more as needed. I would use composite pattern for the data structure. i.e. every element has children collection of the base class type. 2. Create a parser to parse html pages. 3. Using t...
Security is always about trade-offs. Hardware tokens may be harder to steal, but they offer no protection against network-based MITM attacks. If this is a web-based solution (I assume it is, since you're using one of the image-based systems), you should consider something that offer mutual https authentication. Then...
<a href="http://msdn.microsoft.com/en-us/library/ms178604.aspx">Microsoft has a great tutorial on this</a> which basically explains that you need to enable it using the <a href="http://msdn.microsoft.com/en-us/library/ms229862(VS.80).aspx">aspnet_regsql.exe</a> utility.
<a href="http://msdn.microsoft.com/en-us/library/ms178604.aspx">Microsoft has a great tutorial on this</a> which basically explains that you need to enable it using the <a href="http://msdn.microsoft.com/en-us/library/ms229862(VS.80).aspx">aspnet_regsql.exe</a> utility or the <a href="http://msdn.microsoft.com/en-us/li...
This is done so that the processor does not use stale values due to caching. When you access (regular) cached RAM, the processor can "remember" the value that you accessed. The next time you look at that same memory location, the processor will return the value it remembers without looking in RAM. This is caching. ...
http://www.apple.com/remotedesktop/ ^That's your best solution. If you go into the Settings panel, you can find a variety of other remote access options including SSH.
Yeah, VNC is good, but what about Apple's Remote Desktop?
You can use [VNC][1] which is built into Tiger. [1]: http://www.macminicolo.net/Mac_VNC_tutor.html
Apple's [Remote Desktop][1] has AES encryption. Another good way is to just enable SSH in sharing and use shell access to perform tasks without interrupting the user. [1]: http://www.apple.com/remotedesktop/
Can a .msi file install itself (presumably via a Custom Action)?
|windows-installer|wix|
I would like to insall my MSI via my MSI. Obviously I can't include the MSI as a file in my Media (chicken and egg scenario), so I believe it would have to be done via a Custom Action before the install process, adding the original MSI to the MSI database on the fly. Can this be done and if so how? I am familiar w...
I would like to insall my MSI via my MSI. Obviously I can't include the MSI as a file in my Media (chicken and egg scenario), so I believe it would have to be done via a Custom Action before the install process, adding the original MSI to the MSI database on the fly. Can this be done and if so how? Think of a cont...
> "If it ain't broke - don't fix it!" @Macka - Thanks, I needed to hear that. And thanks to everyone for your answers. While I am in the very fortunate position of having an ***insane*** amount of professional and creative control over my work, and can bring in just about any technology, library, or tool for j...
As of release 1.102 the JEDI Code Library has support for 7zip built into the JclCompression unit. Haven't used it myself yet, though.
As of release 1.102 the [JEDI Code Library][1] has support for 7zip built into the [JclCompression][2] unit. Haven't used it myself yet, though. [1]: http://homepages.codegear.com/jedi/jcl/ [2]: http://jcl.svn.sourceforge.net/viewvc/jcl/trunk/jcl/source/common/JclCompression.pas?view=markup
Quoting [The C++ FAQ][1], > [7.8] What's the difference between > the keywords struct and class? > > The members and base classes of a > struct are public by default, while in > class, they default to private. Note: > you should make your base classes > explicitly public, private, or > protected, rather th...
Just the thread.
Converting large ASP.NET VB.NET project to C# - incrementally?
|asp.net|c#|vb.net|
Was looking for some approaches to incrementally converting an large existing ASP.NET VB.NET project to C# while still being able to deploy it as a single web application (currently deployed on a weekly basis). My thoughts were to just create a new C# ASP.NET project and slowly move pages over, but I've never atte...
|c#|asp.net|vb.net|
Was looking for some approaches to incrementally converting an large existing ASP.NET VB.NET project to C# while still being able to deploy it as a single web application (currently deployed on a weekly basis). My thoughts were to just create a new C# ASP.NET project and slowly move pages over, but I've never atte...
In C++ you want to create a static function of a class (not a static class). class BitParser { public: ... static ... getBitAt(...) { } }; You should then be able to call the function using BitParser::getBitAt() without instantiating an object which I presume is the desired re...
If you want code to run when the user presses enter, **just use the onSubmit handler.** If you want code to run when the user presses the button, and *not* when the user presses enter, use a button other than type="submit".
You must note however that the Array.filter is not supported in all browser so, you must to prototyped: <pre> //This prototype is provided by the Mozilla foundation and //is distributed under the MIT license. //http://www.ibiblio.org/pub/Linux/LICENSES/mit.license if (!Array.prototype.filter) { Array.proto...
I don't have any VPN connections on my current computer but somewhere in the TCP/IP properties for the connection there's a checkbox to indicate that you use the remote host as a gateway or something like that. This once caused me alot of issues since all my traffic would go over the VPN and then back again, even wh...
Start here - I actually think it's among the best Software Dev books that I've read. http://books.google.com/books?id=L7d0LNpSrRwC&dq=expert+spring+mvc+and+web+flow&pg=PP1&ots=GC7894yug6&sig=xndzQdG2YWy27Ffx6kR1rXQwxf0&hl=en&sa=X&oi=book_result&resnum=1&ct=result Learn the new Annotation-based configuration for MVC ...