instruction
stringlengths
0
30k
Because it would break existing (pre-Java5) code. e.g., Set stringSet = new HashSet(); // do some stuff... Object o = "foobar"; stringSet.remove(o); Now you might say the above code is wrong, but suppose that o came from a heterogeneous set of objects (i.e., it contained strings, number, object...
Have "Person" implement some sort of IDeletable interface, then make the command take whatever base class or interface your entities use. That way, you can make a DeleteCommand, which tries to cast the entity to an IDeletable, and if that works, call .Delete public class DeleteCommand : ICommand { ...
As far as I know, there is no something like Guid.TryParse in mscrolib. According to Reference Source, Guid type has mega-complex constructor which checks all kinds of guid formats and tries to parse them. There is no helper method you can call, even via reflection. I think you have to search for 3rd party Guid parsers...
I use Red-Gate software's SQL Data Compare. It will do diffs of the data in both databases and generate the appropriate transactional update scripts. It will exclude any columns that don't exist in both tables, so you should be fine even if you've added or deleted columns in your test database.
"Attach to remote process" is a must. It lets you debug your application in several virtual (or physical) machines running different versions of Windows without installing Visual Studio on each such machine: you would run Visual Studio on your main development computer and attach it to the instance of your application ...
are you making the call from a thread with its ApartmentState set? if not, that might be the culprit - COM interop is pretty finicky about that sort of thing
Here is a sneaky way for it to happen. I had this essentially happen to me today. class A { A *pThis; public: A() : pThis(this) { } void callFoo() { pThis->foo(); // call through the pThis ptr which was initialized in the constructor ...
How to draw in the nonclient area?
|c++|mfc|drawing|nonclient|
I'd like to be able to do some drawing to the right of the menu bar, in the nonclient area of a window. Is this possible, using C++ / MFC?
We used to use Visual Build from Kinook software, but recently with our new application we switched to MSBuild since it had better integration with TFS and the ability to create custom tasks.
I'd guess there is a vtbl created for the abstract class for some internal reason (it might be needed for some sort of run time type info) and something goes wrong and a real object gets it. It's a bug. That alone should say that something that can't happen is. Pure speculation
I'd guess there is a vtbl created for the abstract class for some internal reason (it might be needed for some sort of run time type info) and something goes wrong and a real object gets it. It's a bug. That alone should say that something that can't happen is. Pure speculation **edit:** looks like I'm wrong in t...
The GNU Autotools definitely. The [autoconf][1] and [automake][2] are de-facto standard for unix systems. [1]: http://www.gnu.org/software/autoconf/ [2]: http://www.gnu.org/software/automake/
In order to draw in the non-client area, you need to get the "window" DC (rather than "client" DC), and draw in the "window" DC.
What's the definitive Java Swing starter guide and referencte
|.net|asp.net|table|listview|datagrid|
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As String Public Attendance As List(Of At...
|.net|asp.net|listview|table|datagrid|
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As String Public Attendance As List(Of At...
I'm not sure this helps, because I suspect you want to do this with a saved query rather than in VBA; however, the easiest thing you can do is build up a query line by line in VBA, and then creating a recordset from it. A quite hackish way would be to re-write the saved query on the fly and then access that; however...
What causes tables to need to be repaired?
|database|mysql|
Every so often I get an error saying one of my tables "is marked as crashed and should be repaired". I then do a REPAIR TABLE and repair it. What causes them to be marked as crashed and how can I prevent it? I am using MyISAM tables with MySQL 5.0.45.
Instead of writing the assembly to disk you can try to do Assembly.Load(byte[] rawAssembly) where you create rawAssembly from the embedded resource.
`use constant` actually makes constant subroutines. To do what you want, you need to explicitly call the sub: use constant X => 1; my %x = ( &X => 'X'); or use constant X => 1; my %x = ( X() => 'X');
|database|sqlite|firebird|
**[SlickRun][1]** is very handy for this, just a few keys to navigate to anything common and a very small footprint. With input variables and file path recognition all part of it I can quick remote desktop to any machine, search anything, pull up whatever's needed. [1]: http://www.bayden.com/SlickRun/
If it is really necessary to prefix member variables, I would definitely prefer `m_` to just an underscore. I find an underscore on its own reduces readability, and can be confused with C++ reserved words. However, I do doubt that member variables need any special notation. Even ignoring IDE help, it isn't obvious w...
The open method accepts a block. Do something like this: class Foo def do_something Syslog.open do # work with the syslog here end end end
A couple of points. First, you specified that you are using WSS 3.0, so the CQWP is not available (you need MOSS and to have publishing turned on for this to be available). The enhanced community edition will also not work for you since it derives from the CQWP. Second, I would agree with Eugene Katz that a Dat...
A couple of points. First, you specified that you are using WSS 3.0, so the CQWP is not available (you need MOSS and to have publishing turned on for this to be available). The enhanced community edition will also not work for you since it derives from the CQWP. Second, I would agree with Eugene Katz that a Dat...
There are some options: You could pass parameters by properties or constructor. Other option could be: interface ICommand<T> { void Execute<T>(T args); } And encapsulate all command parameters in a value object.
I found a workaround: http://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO i cannot exactly open a file using a relative path "../../index.html" but i can get the app directory and work with that. var DIR_SERVICE = new Components.Constructor("@mozilla.org/file/directory_service;1", "nsIProperties"); ...
Position An HTML Element Relative to its Container Using CSS
|html|css|positioning|
I'm trying to create a horizontal 100% stacked-bar graph using HTML and CSS. I'd like to create the bars using DIVs with background colors and percentage widths depending on the values I want to graph. I also want to have a grid lines to mark an arbitrary position along the graph. In my experimentation, I've already...
Finale files are not just binary files, but compressed, encrypted binary files. ETF files are text files and do have some documentation in older versions of the Finale plug-in developer kit. But ETF export was removed from Finale several versions ago. As was previously suggested, your best bet by far is to import Mu...
There really aren't any other frameworks out there. There's of course AGI bindings to every language, but as far as full-fledged frameworks for developing telephony applications, we're just not there yet. At least in the open-source world.
Compiler will optimise it anyway - go for the switch as it's the most readable.
The Switch, if only for readability. Giant if statements are harder to maintain and harder to read in my opinion. **ERROR_01** : // intentional fall-through or **(ERROR_01 == numError) ||** The later is more error prone and requires more typing and formatting than the first.
I'm not sure about best-practise, but I'd use switch except trap intentional fall-through via 'default'
I have recently found the List<A>.Cast<B>().ToList<B>() pattern. It does exactly what I was looking for,
IMO this is a perfect example of what switch fall-through was made for.
I would pick the if statement for the sake of clarity and convention, although I'm sure that some would disagree. After all, you are wanting to do something `if` some condition is true! Having a switch with one action seems a little... unneccesary.
If your cases are likely to remain grouped in the future--if more than one case corresponds to one result--the switch may prove to be easier to read and maintain.
Im not the person to tell you about speed and memory usage, but looking at a switch statment is a hell of a lot easier to understand then a large if statement (especially 2-3 months down the line)
I have asked somewhat related questions [here][1], [here][2], and [here][3]. I'm using Microsoft's Speech Server, and I'm very intested to learn about any alternatives that are out there, especially open source ones. You might find some good info in the answers to one of those questions. [1]: http://stackoverf...
Store them in a file outside web root.
Several period misread this as a question about how to **store** passwords in a database. That is wrong. It is about how to store the password that lets you get **to** the database. The usual solution is to move the password out of source-code into a configuration file. Then leave administration and securing that...
Put the database password in a file, make it read-only to the user serving the files. Unless you have some means of only allowing the php server process to access the database, this is pretty much all you can do.
You can use [array_multisort()][1] Try something like this: foreach ($mdarray as $key => $row) { $dates[$key] = $row[0]; // of course, replace 0 with whatever is the date field's index } array_multisort($dates, SORT_DESC, $mdarray); [1]: http://yu2.php.net/manual/en/functi...
How can I build C# ImageList Images from smaller component images?
|c#|winforms|.net-2.0|image|system.drawing|
I'd like to make status icons for a C# WinForms TreeList control. The statuses are combinations of other statuses (eg. a user node might be inactive or banned or inactive and banned), and the status icon is comprised of non-overlapping, smaller glyphs. I'd really like to avoid having to hand-generate all the poss...
ADF Business Components thru RMI Vs EJB and Toplink
|java|jakarta-ee|ejb|adf|
I was wondering what the differences would be in implementing remote business logic. Currently we are planning on using ADF to develop front-end web apps (moving from Struts). We were wondering what the differences between the front end calling EJBs using Toplink vs ADF Business Components thru RMI in terms of scalabil...
In short, this would involve rewriting the entire git commit tree to exclude the files. Have you tried using <code>git gc</code> and <code>git pack</code> to have git compress your repository?
To answer the original question: Session management changed some time back (I think it was around 4.4). The old mechanism still works, but is deprecated. It's rather confusing, so I recommend staying clear of it. Today, you use sessions by accessing the global variable $_SESSION (It's an array). You *can* put object in...
What Barak said. See also this topic on Eclipse help: http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tools/preference_pages/target_platform.htm Note also: - the default target platform is your Eclipse install - your dev environment should be at least as recent as the target...
You can do 2d physics with [opende][1] as well [1]: http://opende.sourceforge.net/
Profilers are definitely a good way to get numbers, but in my experience, perceived performance is all that matters to the user/client. For example, we had a project with an Ext accordion that expanded to show some data and then a few nested Ext grids. Everything was actually rendering pretty fast, no single operation...
http://chongqed.org/ maintains blacklists of active spam sources and the URLs being advertised in the spams. I have found filtering posts for the latter to be very effective in forums.
As you said, always access tables in the same order is a very good way to avoid deadlocks. Furthermore, shorten your transactions as much as possible. Another cool trick is to combine 2 sql statements in one whenever you can. Single statements are always transactional. For example use "UPDATE ... SELECT" or "INSERT...
another trick is **naming convention**: All member variables are named as usual, without any prefix (or 'this.' is it is usual to do so in the project) But they will be easily differentiated from local variable because in my project, those local variables are always named: - **a**Something: represents one obje...
This book might help: http://www.atariarchives.org/mlb/ Also, try examing any other 6502 aseembler/simulator/debugger out there to see how Assembly gets coded as Machine Language.
The opcode takes one byte, and the operands are in the following bytes. Check out the byte size column [here](http://www.atariarchives.org/2bml/chapter_10.php), for instance.
How do you "preview" user actions like resize or editing in GoDiagrams?
Finale files are not just binary files, but compressed, encrypted binary files. ETF files are text files and do have some documentation in older versions of the Finale plug-in developer kit. But ETF export was removed from Finale several versions ago. As was previously suggested, your best bet is to import MusicXML ...
Assume your original points are (x1,y1) -> (x2,y2). Use the following points (x1-width/2, y1), (x1+width/2,y1), (x2-width/2, y2), (x2+width/2,y2) to construct a rectangle and then use quads/tris to draw it. This the simple naive way. Note that for large line widths you'll get weird endpoint behavior. What you really wa...
Yeah, also: `ocamlc` is the bytecode compiler, and `ocamlopt` is the native code compiler. `GCL` compiles Common Lisp to native binaries. There isn't anything for F# since, for what I am aware of, .NET doesn't have a native compiler, like Joel mentions. Actually, CSML can be used to call C# from ocaml, uhh, not ...
Here is how to get a list of current printers and the default one if there is one set as the default DWORD numprinters; DWORD defprinter=0; DWORD dwSizeNeeded=0; DWORD dwItem; LPPRINTER_INFO_2 printerinfo = NULL; // Get buffer size EnumPrinters ( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS ,...
|java|swing|griffon|groovy|
Obviously the [Java API][1] reference, but what else is there that you all use? I've been doing web development my entire career. Lately I've been messing around a lot with [Groovy][2] and I've decided to do a small application in [Griffon][3] just to experiment more with Groovy and also break some ground in desk...
What's the definitive Java Swing starter guide and reference?
|java|swing|groovy|griffon|
@Statement: I am indeed already using a "greater than or equal to" comparison in my code, thank you for the suggestion. +1 My current solution is to add a small nudge amount to the edge test. Basically when each triangle is tested, its edges are pushed out by a very small amount to counteract the error in floating ...
«Software documentation» is a very general term. There is «End User documentation», «Developer documentation», «QA Documentation». First one is usually developed by qualified techwriters. Other ones may be dynamically formed from wikis, documentation comments from source code etc. All this stuff maintenance process us...
[Automated Build Studio][1]. Instead of letting you mes with scripts or xml files, it comes with predefined graphical macro operations that allows you to create tasks easily. [1]: http://www.automatedqa.com/products/abs/index.asp
If you just want something in the menu bar, maybe it is easier/cleaner to add it as a right-aligned menu item. This way it'll also work with different Windows themes, etc.
How can I create a Netflix-style iframe overlay without a huge javascript library?
|javascript|css|center|overlay|
I'm trying to use a link to open an overlay instead of in a separate popup window. This overlay should consist of a semi-transparent div layer that blocks the whole screen from being clicked on. I also aim to disable scrolling at this point. Not matter where you are on the main page, when the link is clicked, the overl...
Session management changed some time back (I think it was around 4.4). The old mechanism still works, but is deprecated. It's rather confusing, so I recommend staying clear of it. Today, you use sessions by accessing the global variable $_SESSION (It's an array). You *can* put object instances in there, but you need to...
From your comments to other posters, it looks like you're left with malloc() and friends. Vector won't let you have unconstructed elements.
|delphi|windows-vista|
CryptUnprotectData in Vista not working
|encryption|crypt|windows-vista|
I'm using an identical call to "CryptUnprotectData" (exposed from Crypt32.dll) between XP and Vista. Works fine in XP. I get the following exception when I run in Vista: "Decryption failed. Key not valid for use in specified state." As expected, the versions of crypt32.dll are different between XP and Vista (...
I'm using an identical call to "CryptUnprotectData" (exposed from Crypt32.dll) between XP and Vista. Works fine in XP. I get the following exception when I run in Vista: "Decryption failed. Key not valid for use in specified state." As expected, the versions of crypt32.dll are different between XP and Vista (...
I'm using an identical call to "CryptUnprotectData" (exposed from Crypt32.dll) between XP and Vista. Works fine in XP. I get the following exception when I run in Vista: "Decryption failed. Key not valid for use in specified state." As expected, the versions of crypt32.dll are different between XP and Vista (...
The only reasons I've had to use them is when interfacing with 3rd party libraries that use C style strings. There might also be esoteric situations where you would use C style strings for performance reasons, but more often than not, using methods on C++ strings is probably faster due to inlining and specialization, ...
try [this][1] [1]: http://us.php.net/manual/en/function.stripslashes.php That should make them all single slashes.
Join the [iPhone Dev program][1] and read through their code samples (they are simple) as well as their guides (very helpful). I know of no other way. [1]: http://developer.apple.com/iphone/
Have you considered the stripslashes() function? http://www.php.net/stripslashes
Reporting Services Line Graph: How to better control the smoothed curve.
|.net|graphics|reporting-services|charts|splines|
I have a report that I built for a client where i need to plot x 0-100, y 0-100. Lets imagine I have these points: 0,0 2,24 50,70 100,100 I need to represent these as a smoothed line chart, as the application of it is a dot gain graph for printing presses. Heres the problem. The line draws fine from 100,100...
If the code to set up the state required for a unit test becomes significantly more complex than the code to be tested I tend to draw the line, and find another way to test the functionality. At that point you have to ask how do you know the unit test is right!