instruction
stringlengths
0
30k
[Moq][1] It's amazing, fully supports the new language features of C# 3.0 and it's very easy to get going with. I would highly recommend it. [1]: http://code.google.com/p/moq/
Is Global Memory Initialized in C++
|c++|memory|memory-management|
And if so, how?
And if so, how? Clarification: I'm talking about global **memory**, not global **data**. In other words - is it defined what my global memory looks like prior to initialization? See my C++ quiz on on multiple instances of a singleton...
And if so, how? (Second) Clarification: When a program starts up, what is in the memory space which will become global memory, prior to primitives being initialized. I'm trying to understand if it is zeroed out, or garbage for example. The situation is can a singleton reference be set - via an instance() call...
Hows' this ? <pre> import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; public class Server { public static void main(String[] args) throws IOException { DatagramSocket socket = new DatagramSocket(new InetSocketAddress(5000)); ...
[Agile Software Development with Scrum][1] by Ken Schwaber and Mike Beedle. I used this book as the starting point to understanding Agile development. [1]: http://www.amazon.com/Agile-Software-Development-SCRUM/dp/0130676349
Foreign keys allow someone who has not seen your database before to determine the relationship between tables. Everything may be fine now, but think what will happen when your programmer leaves and someone else has to take over. Foreign keys will allow them to understand the database structure without trawling th...
Ok, I'll try to help here : First a module is not a class, it allows you to mix behaviour in a class. second see the following example : module A module B module Error def foobar puts "foo" end end end end class StandardError...
Ok, I'll try to help here : First a module is not a class, it allows you to mix behaviour in a class. second see the following example : module A module B module Error def foobar puts "foo" end end end end class StandardError...
How do I create a link to a footnote in HTML?
|html|syntax|
For example: > This is main body of my content. I have a > footnote link for this line [1]. Then, I have some more > content. Some of it is interesting and it > has some footnotes as well [2]. > > [1] Here is my first footnote. > > [2] Another footnote. So, if I click on the "[1]" link it directs the web...
I'm fairly new to Python, but the tuple technique seems very pythonic to me. However, I've had another idea that may enhance readability. Using a dictionary allows access to the different values by name rather than position. For example: def divide(x, y): return {'quotient': x/y, 'remainder':x%y } ...
if ((a ^ b) >= 0) sign is the same
I would be wary of any bitwise tricks to determine the sign of integers, as then you have to make assumptions about how those numbers are represented internally. Almost 100% of the time, integers will be stored as <a href="http://en.wikipedia.org/wiki/Twos_Compliment">two's compliment</a>, but it's not good practice...
If you make the method public, then you could access it directly.... however, there could be some unexpected side effects when you call it. But making it public and calling it directly will not draw the screen or open the form.
anchor tags using named anchors [http://www.w3schools.com/HTML/html_links.asp][1] [1]: http://www.w3schools.com/HTML/html_links.asp
Check out this [Railscast on OpenId][1] for more info. I'm not sure if/how it might work alongside restful_authentication, but might be a good resource. (I haven't watched it yet) [1]: http://railscasts.com/episodes/68-openid-authentication
You *will* require assistance of your system administrator. Ordinary users are not able to run the executable of their choice on behalf on other users, period. She may add your application to `/etc/sudoers` with proper settings and you'll be able to run it as with `sudo -u nobody`. This will work for both scripts...
I don't have a Mac here, but there is some Documentation up here: [http://developer.apple.com/documentation/Hardware/Conceptual/iSightProgGuide/01introduction/chapter_1_section_1.html][1] It looks like you have to go through the QuickTime API. There is supposed to be a Sample Project called "MungGrab" which could...
Pretty much what @Lars already said: //force T to be a value (primitive) type public class Class1<T> where T: struct //force T to be a reference type public class Class1<T> where T: class //force T to be a parameterless constructor public class Class1<T> where T: new All w...
If you can move to SQL Server 2008, you can take advantage of the FILESTREAM support which gives you the best of both - the files are stored in the filesystem, but the database integration is much better than just storing a filepath in a varchar field. Your query can return a standard .NET file stream, which makes the ...
I would definitely have a look at the JW Flash Media Player: [http://www.jeroenwijering.com/?item=JW_FLV_Player][1] It's Open Source, and I found the Source quite clean and easy to understand, it also supports playlists. I don't know the DART In-Stream stuff, but maybe you could "creatively use" the playlist feat...
Calling Table-Valued SQL Functions From .NET
|c#|.net|sql|
Scalar-valued functions can be called from .NET as follows: SqlCommand cmd = new SqlCommand("testFunction", sqlConn); //testFunction is scalar cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("retVal", SqlDbType.Int); cmd.Parameters["retVal"].Direction = ParameterDirection.Retur...
How do you pull the URL for an ASP.NET web reference from a configuration file?
|asp.net|webreference|configurationfiles|
I think the is no memory leak. STRUCT* pStruct = (STRUCT*)new BYTE [sizeof(STRUCT) + nPaddingSize]; This gets translated into a memory allocation call within the operating system upon which a pointer to that memory is returned. At the time memory is allocated, the size of "sizeof(STRUCT)" and the size of "nPaddi...
[API/1.2/Ajax](http://docs.jquery.com/Ajax/ajaxSend#callback) has information on how to bind to AJAX events. // Hook into jQuery's ajaxSend event, which is triggered before every ajax // request. $(document).ajaxSend(function(event, request, settings) { // settings.data is either a query string ...
GIMP (http://www.gimp.org/) is a good tool for doing resize and is open source.
You can probably refactor your code so that conditional compile really isn't needed, just conditional classloading. Something like this: public interface Opener{ public void open(File f); public static class Util{ public Opener getOpener(){ if(System.getProp...
Outlook 07 2 column flexible layout
|html|outlook|office-2007|
I am trying to create an email two column flexible layout, which works in outlook 07, i have created a successful version in outlook 03, hotmail, gmail, yahoo and aol, in both IE and Mozilla Firefox, however when testing in outlook 07 it strips out my float left css. What I would like is a layout that has a photo o...
Ok, I'll try to help here : First a module is not a class, it allows you to mix behaviour in a class. second see the following example : module A module B module Error def foobar puts "foo" end end end end class StandardError...
Ok, I'll try to help here : First a module is not a class, it allows you to mix behaviour in a class. second see the following example : module A module B module Error def foobar puts "foo" end end end end class StandardError...
I have a web reference for our report server embedded in our application. The server that the reports live on could change though, and I'd like to be able to change it "on the fly" if necessary. I know I've done this before, but can't seem to remember how. Thanks for your help.
|asp.net|webreference|
How do you pull the URL for an ASP.NET web reference from a configuration file in Visual Studio 2008?
I have a web reference for our report server embedded in our application. The server that the reports live on could change though, and I'd like to be able to change it "on the fly" if necessary. I know I've done this before, but can't seem to remember how. Thanks for your help. **update** - I've manually driven a...
We made the decision to store as varbinary for [http://www.freshlogicstudios.com/Products/Folders/][1] halfway expecting performance issues. I can say that we've been pleasantly surprised at how well it's worked out. [1]: http://www.freshlogicstudios.com/Products/Folders/
No because you need to select them. However you can create a stored proc wrapper. Which may defeat the point of having a table function.
I believe you can set the desired solution up by rerunning the vmware configuration script. And doing a custom network setup, so that both NIC's are mapped to your vmware instance. I would recommend making eth0 the 2nd NIC since it will be easier for Linux to use by default. Then make eth1 the 1st NIC.
> I still use the _ prefix in VB for > private fields, so I'll have _foo as > the private field and Foo as the > property. I do this for c# as well and > pretty much any code I write. > Generally I wouldn't get too caught up > in "what is the right way to do it" > because there isn't really a "right" > way (alt...
To simplify Simon's code a bit, you could use the built in generic Action delegate. It saves peppering your code with a bunch of delegate types you don't really need. Also, in .NET 3.5 they added a params parameter to the Invoke method so you don't have to define a temporary array. void SomethingHappened(o...
Ok, I'll try to help here : First a module is not a class, it allows you to mix behaviour in a class. second see the following example : module A module B module Error def foobar puts "foo" end end end end class StandardError...
Ok, I'll try to help here : First a module is not a class, it allows you to mix behaviour in a class. second see the following example : module A module B module Error def foobar puts "foo" end end end end class StandardError...
I agree with @freespace that the the image is not part of the multi-factor authentication for the user. As you state the image is part of the anti-phishing scheme. I think that the image is actually a weak authentication of the system to the user. The image provides authentication to the user that the website is val...
I have had good luck with [Gallery][1]. It is free, open source, and has all the features you mentioned. [1]: http://gallery.menalto.com/ It will allow your users to upload photos without any intervention from you.
This question depends on your situation really. If you have control over the server you're deploying to and you can install whatever services you need, then the time to install a MySql or MSSQL Express server and code against an existing database framework VERSUS coding against flat file structure is not worth the e...
You should use the cfdocument tag (with format="PDF") to generate the PDF by placing it around the page you are generating. You'll want to specify a filename attribute, otherwise the document will just stream right to your browser. After you have saved the content as a PDF, use cfheader and cfcontent in combination...
In a Perl module, you occasionally want to create subroutines on the fly. The thing is, that once you have created the subroutine, how do you get to it. You could just call it, but then if the subroutine uses `caller()` it won't be as helpful as it could be. ###Here is a quick example: sub AUTOLOAD{ my...
##As a bookmarklet javascript:document.write(document.getSelection().match(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g)) Just create a new bookmark and paste that javascript in ##How to do it in Ubiquity CmdUtils.CreateCommand({ name: "findip", preview: function( pblock ) { ...
If the components are designed to be 100% orthogonal, it should be possible. A clear separation of concerns can achieve this. All a component needs to know is the interface of its input. The coupling should be one-directional: components know the semantics of their parameters, but should be agnostic of each other....
If components are 100% decoupled, it means that they don't communicate with each other.
If components are 100% decoupled, it means that they don't communicate with each other. Actually there are [different types of coupling][1]. But the general idea is that objects are not coupled if they don't depend on each other. [1]: http://en.wikipedia.org/wiki/Coupling_%28computer_science%29
It comes down to 'designing for testability'. Ideally, you should not instantiate those COM objects directly but should access them through a layer of indirection that can be replaced by a mock object. Now, COM itself does provide a level of indirection and you could provide a mock object that provided a substitute ...
Whilst MS SQL Server offers OLAP, you'll need an Enterprise licence to use a cube in a live environment that is web-facing.
Even if two components do not comunicate directly, the third component, which uses the other two is part of the system and it is coupled to them. @Vadmyst: If your components communicate over network they must use some kind of protocol which is the same as the interface of two local components.
That's a painfully abstract question to answer. If said system is the components of a single application, then there are various techniques such as those involving MVC (Model View Controller) and interfaces for IoC / Dependency Injection that facilitate decoupling of components. From the perspective of physically is...
There isn't anything you can use directly in C#, however you can use some libraries from J# to do it for you: http://msdn.microsoft.com/en-us/magazine/cc164129.aspx Should do just what you want? With regards to the encryption, have a look at these links: http://www.codeproject.com/KB/security/fileencryptdec...
Jean, Thanks a lot for your investigation. You're right, and actually I think you've uncovered a more severe bug, of species 'design bug'. What's happening is that rake will grab whatever value you pass to the command line and store them as environment variables. The rake tasks that will eventually get called wil...
Another option is Report Builder, that comes for free with SQL Server. Though the SQL Server 2005 version is a bit cranky, the new release with SQL Server 2008 seems to work much better. Although it isn't as flexible as excel for ad-hoc queries,it comes very handy for some scenarios.
What use is multiple indirection in C++?
|c++|pointers|
Under what circumstances might you want to use multiple indirection (that is, a chain of pointers as in **foo) in C++?
I'm not sure if the steps can be combined, but .NET has good support for basic crypto. Here's an [article on it](http://www.ondotnet.com/pub/a/dotnet/2003/02/10/dotnetcryto.html).
VMWare Server: Virtual Hard Drive Type
|virtualserver|hard-drive|performance|ide|scsi|
For best performance, is it better to use a virtual IDE HDD or virtual SCSI HDD? If, SCSI, does it matter whether you use an BusLogic or LSILogic?
|performance|ide|vmware|hard-drive|scsi|
As Greg mentions, compilers won't do it in debug mode. It's ok for debug builds to be slower than a prod build, but they shouldn't crash more often: and if you depend on a tail call optimization, they may do exactly that. Because of this it is often best to rewrite the tail call as an normal loop. :-(
I've been down this road before and it's an absolute nightmare when you have to work on "obfuscated" code because it drives up costs tremendously trying to debug a problem on the client's server when you, the developer, can't read the code. You wind up with "deobfuscators", copying the "real code" to the client's serv...
First, create a function (using CTE, common table expression does away with the need for a temp table. create function dbo.SplitString ( @str nvarchar(4000), @separator char(1) ) returns table AS return ( with tokens(p, a, b) AS ( ...
First, create a function (using CTE, common table expression does away with the need for a temp table) create function dbo.SplitString ( @str nvarchar(4000), @separator char(1) ) returns table AS return ( with tokens(p, a, b) AS ( ...
First, create a function (using CTE, common table expression does away with the need for a temp table) create function dbo.SplitString ( @str nvarchar(4000), @separator char(1) ) returns table AS return ( with tokens(p, a, b) AS ( ...
First, create a function (using CTE, common table expression does away with the need for a temp table) create function dbo.SplitString ( @str nvarchar(4000), @separator char(1) ) returns table AS return ( with tokens(p, a, b) AS ( ...
Very subjective question. What do you mean by "best"? Maybe you should provide some more context on your situation. [RhinoMocks](http://www.ayende.com/projects/rhino-mocks.aspx) is one of the most popular, as to whether it's the best for you, who knows?
I'm going through that process now, weighing them up for use by my team, and I have to say Moq as well, it seems to have the least of a learning curve, and some nice features, I love the use of Moq generics to specify a Mock class
I would think that this would be the simplest solution: SELECT TOP N PERCENT FROM TheTable ORDER BY TheScore DESC Where N = (100 - desired percentile). So if you wanted all rows in the 90th percentile, you'd select the top 10%. I'm not sure what you mean by "preferably in a single record". Do you mean ca...
I would think that this would be the simplest solution: SELECT TOP N PERCENT FROM TheTable ORDER BY TheScore DESC Where N = (100 - desired percentile). So if you wanted all rows in the 90th percentile, you'd select the top 10%. I'm not sure what you mean by "preferably in a single record". Do you mean ca...
For heavy computations and the like, purely functional languages like [Haskell][1] are easily [parallelizable][2] without any effort on the part of the programmer. Apart from learning Haskell, that is. However, I do not think that this is the way of the (near) future, simply because too many programmers are too used...
Make a notation at the end of each variable name to indicate whether the value is scaled or not, and write macros SCALE() and UNSCALE() that expand to x>>8 and x<<8.
Chaning fixed point representations is commonly called 'scaling'. To keep track of this you just need to use a consistent convention. Make a notation at the end of each variable name to indicate whether the value is scaled or not, and write macros SCALE() and UNSCALE() that expand to x>>8 and x<<8. #define...
It sounds like you want a [multi-index container][1]. This allows you to create a container and the various ways you may want to traverse the items in the container are updated on each insert/delete. If you really want to re-sort the container, you can call the [std::sort][2] function on any std::deque, std::vector...
It sounds like you want a [multi-index container][1]. This allows you to create a container and tell that container the various ways you may want to traverse the items in it. The container then keeps multiple lists of the items, and those lists are updated on each insert/delete. If you really want to re-sort the c...
Do you want to preview the url of the HTTP request being sent to the server for debugging purposes?
An easy way to preview the HTTP request being sent is to use <a href="http://getfirebug.com/">Firebug</a> for Firefox. Download and enable the plugin, and when the request is made it will show up in the firebug console.
How about using <a href="https://www.photoshop.com/express/landing.html">PhotoShop Online</a> It allows you to edit photos with a web based editor and offers 2GB of storage. I've not used it myself so don't know if it allows for multiple users to access the same account though
If the server side application logic threw an exception, it should be able to marshal over to the client to let it know what happened. You can test this by deliberately throwing an exception in one of the remote object's methods. Then call that particular method from the client side expecting an exception: HttpChan...
Let's say you have an interface and two classes: interface IResult {} class AResult implements IResult {} class BResult implements IResult {} Then you have classes that return a list as a result: interface ITest<T extends IResult> { List<T> getResult(); } class ATest implem...
Let's say you have an interface and two classes: interface IResult {} class AResult implements IResult {} class BResult implements IResult {} Then you have classes that return a list as a result: interface ITest<T extends IResult> { List<T> getResult(); } class ATest implem...
Most IDEs for Java will automatically generate getter and setter code for you if you want them to. There are a number of different conventions, and an IDE like Eclipse will allow you to choose which one you want to use, and even let you define your own. Eclipse even includes automated refactoring that will allow you...
Here is the [lucene index format documentation][1]. The major file is the compound index (.cfs file). If you have term statistics, you can probably get an estimate for the .cfs file size, Note that this varies greatly based on the Analyzer you use, and on the field types you define. [1]: http://lucene.apache.org/ja...
**Advantages:** - Can share identical application logic in client and database - Access to the Java API. Watch out for which java version each database supports - I believe 10g only supports 1.4 (which means at my work we have to be very careful since our main codebase has recently moved to 1.5). **Disadvant...
Chaning fixed point representations is commonly called 'scaling'. To keep track of this you just need to use a consistent convention. Make a notation at the end of each variable name to indicate whether the value is scaled or not, and write macros (or inline functions, but the C idiom is macros) SCALE() and UNSCALE...
Chaning fixed point representations is commonly called 'scaling'. If you can do this with a class with no performance penalty, then that's the way to go. If not, then you need a more traditional C-style approach. The oo approach will give you compiler-enforced type safety which the traditional implementation only ...