instruction stringlengths 0 30k ⌀ |
|---|
My automated functional tests usually follow one of two patters:
* Database Connected Tests
* Mock Persistence Layer Tests
**Database Connected Tests**
When I have automated tests that are connected to the database, I usually make a single test database template that has enough data for all the tests. When t... |
well, if it's 2-D, then all lines are on the only plane.
So this is basic 3-D geometry. You should be able to do this with a straightforward equation.
Check out this page: http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/ The second solution should be easy to implement in code, as long as you translate ... |
Hehe this was sort of asked moments ago and Jeff pointed out:
[http://www.regular-expressions.info/refflavors.html](http://www.regular-expressions.info/refflavors.html).
There is a comparison of regular expression capabilities across tools and languages. |
I've found that different implementations of regular expressions often have subtle differences in what exactly they support. If you want to be entirely sure that the result will be the same in both frontend and backend, the savest choice would be to make an Ajax call to your PHP backend and use the same piece of PHP co... |
+1 for using a file.ext.end signaler if possible, where the contents of file.ext.end is a checksum for the larger file. This isn't for security so much as it is to make sure nothing got garbled along the way. If someone can insert their own file into the large stream they can replace the checksum as well. |
If the regular expressions are simple then there should be no issue, as the basics of regular expressions are common across most implementations.
For particulars then it would be best to study both implementations:
<http://www.regular-expressions.info/php.html>
<http://www.regular-expressions.info/javascript.h... |
Stack automatic are variables which are allocated on the stack of the current method. The idea behind designing a class which can acts as Stack automatic is that it should be possible to fully initialize it with one call and destroy it with another. It is essential that the destructor frees all resources allocated by t... |
I've heard only good things about [ReSharper][1]. It's on my to-learn list.
[1]: http://www.jetbrains.com/resharper |
For me, Ctrl+Shift+F maps to Find in Files. When I need to format code, I highlight it and hit Ctrl+K, Ctrl+F.
I understand this doesn't really address automated formatting, I just wanted to clarify for those who may not know this feature even exists in VS. |
No, you shouldn't. Feel free to try it out on a new project, but a lot of people familiar with ASP.NET webforms aren't loving it yet, due to having to muck around with raw HTML + lots of different concepts + pretty slim pickings on documentation/tutorials.
|
I have created a recursive function to concatenate a list of strings with a separator between them. I use it mostly to create SQL expressions, by passing a list of fields as the '*items*' and a '*comma+space*' as the separator. Here's the function (It uses some Borland Builder native data types, but can be adapted to... |
Unfortunately the only API that isn't deprecated is located in the ApplicationServices framework, which doesn't have a bridge support file, and thus isn't available in the bridge. If you're wanting to use ctypes, you can use ATSFontGetFileReference after looking up the ATSFontRef.
Cocoa doesn't have any native suppo... |
Recursion works best with what I like to call "fractal problems", where you're dealing with a big thing that's made of smaller versions of that big thing, each of which is an even smaller version of the big thing, and so on. If you ever have to traverse or search through something like a tree or nested identical struct... |
I use recursion. What does that have to do with having a CS degree... (which I don't, by the way)
Common uses I have found:
1. **sitemaps** - recurse through filesystem starting at document root
1. **spiders** - crawling through a website to find email address, links, etc.
1. ? |
I'm not sure it's the same issue, but I had a similar sounding issue with trying to bind a DropDownList that I wanted to contain in a GridView. When I looked around I found a lot of people asking similar questions, but no robust solutions. I did read conflicting reports about whether you could intercept databindin... |
It turns out you have to set `top` to `.F.` for `float` to take effect, this worked:
USE report.frx
REPLACE float with .T., stretch with .T., top with .F. for objtype = 8
|
Most web sites I've seen don't solve this problem - they show you a page including some content you've already seen.
You might consider that a feature - when you click "next" and see some content you're seen before, it's a signal that you want to go back to the front again because there's some new content. |
Tag each question with its time entered into the database, carry the time the frontpage was last loaded as a cookie or part of the URL, and limit the search to items `n` through `n+displaynum` as you go forward.
But I wouldn't bother. This behavior is uniform enough that most users expect it, and it serves as a flag... |
Is the control that you are trying to reference inside of the repeater?
If so then you need to look them up using the FindControl method.
For example for:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">stest</asp:LinkButton>... |
The more code you can cover with compile time checking for me is something that I'd place a higher premium on than performance. Having said that at this stage I'd probably lean towards ESQL not just because of the performance, but it's also (at present) a lot more flexible in what it can do. There's nothing worse than ... |
Visual Studio 2008 Fubared |
|asp.net|visual-studio|c#|microsoft| |
Ok, so, my visual studio is broken. I say this NOT prematurely, as it was my first response to see where I had messed up in my code. When I add controls to the page I can't reference all of them in the code behind. Some of them I can, it seems that the first few I put on a page work, then it just stops.
I first t... |
Module level suppression messages need to be pasted into the same file as the code that is raising the FxCop error, before the namespace declaration. Additionally, you will need to have CODE_ANALYSIS defined as a conditional compiler symbols (Project > Properties > Build). Once that is in place, do a complete rebuild o... |
Module level suppression messages need to be pasted into the same file as the code that is raising the FxCop error before the namespace declaration or in assemblyinfo.cs. Additionally, you will need to have CODE_ANALYSIS defined as a conditional compiler symbols (Project > Properties > Build). Once that is in place, do... |
I don't know enough about the guts of the file systems to answer the first, except when I read the first descriptions of NTFS it sounded an awful lot like the Berkley Fast Filesystem.
As for the second, there are plenty of greps for Windows. When I had to use Windows in the past, I always installed Cygwin first thi... |
I think you are a little bit confused. There is no 'Unix' and 'Windows' file systems. The *nix family of filesystems include ext3, ZFS, UFS etc. Windows primarily has had support for FAT16/32 and their own filesystem NTFS. However today linux systems can read and write to NTFS. More filesystems [here][1]
I can't tel... |
Makepp source with two targets |
|lazy-c++|build-process| |
I use this tool called [Lazy C++][1] which breaks a single C++ <tt>.lzz</tt> file into a <tt>.h</tt> and <tt>.cpp</tt> file. I want [Makepp][2] to expect both of these files to exist after my rule for building <tt>.lzz</tt> files, but I'm not sure how to put two targets into a single build line.
[1]: http://www.la... |
Make source with two targets |
|build-process|makefile|lazy-c++| |
well the *nix filesystems do a far better job of actual file managment than fat16/32 or NTFS. The *nix systems try to prevent the need for a defrag over windows doing...nothing? Other than that I don't really know what would make one better than the other. |
If you don't want to write java code in-house, take a look at the commercial product <a href="http://scand.com/products/vault/">Vault Applet</a>. You can try out the eval to see if it fulfils your needs. |
Select your team project from team explorer, then right click on the Builds folder. Select a new build definition and then select the trigger tab. Move the radio button to "Build each check-in (more builds)"
More info can be found here
[MSDN How to: Create a Build Definition][1]
[1]: http://msdn.microsof... |
There is a Linq provider for PostgreSQL at [http://code2code.net/DB_Linq/][1].
[1]: http://code2code.net/DB_Linq/ |
depending on what (if any) framework you're using, I suggest you do a query to check for the jobname yourself and create the proper information to user in with the rest of the validations for the form.
Depending on the number of jobnames, you could send the names to the view that contains the form and use javascript... |
Another good one is [CEEBot][1]. It teaches C / Java style programming in a fun, robot-programming kind of game. It is aimed at 10-15 year olds, but it is a good one.
[1]: http://www.ceebot.com/ceebot/index-e.php |
First you should [turn warnings off][1] so that your visitors don't see your MySQL errors. Second, when you call [mysql_query()][2], you should check to see if it returned false. If it did, call [mysql_errno()][3] to find out what went wrong. Match the number returned to the error codes on [this page][4].
[1]: h... |
First you should [turn warnings off][1] so that your visitors don't see your MySQL errors. Second, when you call [mysql_query()][2], you should check to see if it returned false. If it did, call [mysql_errno()][3] to find out what went wrong. Match the number returned to the error codes on [this page][4].
It looks l... |
How to set the order in subnodes of a tree structure. |
|treeview|tree| |
I have a tree representation of pages in a CMS application. However, I don't have a good way to:
A) Reorder subpages under a prticular parent page.
B) Provide a UI implementation that allows the user to change the order.
Any suggestions? |
|tree|treeview| |
I have a tree representation of pages in a CMS application. However, I don't have a good way to:
A) Reorder subpages under a prticular parent page.
B) Provide a UI implementation that allows the user to change the order.
Any suggestions? |
How do I configure and communicate with a serial port? |
|java|c++|windows|unix| |
I need to send and receive data over serial connections (RS-232 and RS-422).
How do I set up and communicate with such a connection? How do I figure out what the configuration settings (e.g. baud rate) should be and how do I set them?
In particular I am looking to do this in Java, C/C++, or one of the major Unix... |
I think you might be alluding to an "invisible" captcha. Check out the Subkismet project for an invisible captcha implementation.
<http://www.codeplex.com/subkismet> |
Mario, I don't understand why you used recursion for that example.. Why not simply loop through each entry? Something like this:
String ArrangeString(TStringList* items, String separator)
{
String result = items->Strings[0];
for ( int position=1; position < items->count; position++ ) {
... |
Mario, I don't understand why you used recursion for that example.. Why not simply loop through each entry? Something like this:
String ArrangeString(TStringList* items, String separator)
{
String result = items->Strings[0];
for ( int position=1; position < items->count; position++ ) {
... |
So you mean that AD743 on spreadsheet B must be equal to AD743 on spreadsheet A? Try this:
- Open both spreadsheets on the same
machine.
- Go to AD743 on spreadsheet B.
- Type =.
- Go to spreadsheed A and click on
AD743.
- Press enter.
You'll notice that the formula is something like '*[p... |
Build a time machine and go back to 1987? Ho ho.
Ok, no more snarky comments.
> How do I figure out what the configuration settings (e.g. baud rate) should be...
Read the datasheet? Ok, ok. Seriously, last one. If you don't know the baud rate of the device you are trying to communicate with, you have two choi... |
Manual steps to upgrade VS.NET solution and target .NET framework? |
|.net|visual-studio| |
After you've let the VS.NET (2008 in this case) wizard upgrade your solution, do you perform any manual steps to upgrade specific properties of your solution and projects? For instance, you have to go to each project and target a new version of the framework (from 2.0 to 3.5 in this case). Even after targeting a new ve... |
Save yourself some headaches and use a parser instead. CPAN has several modules that are suitable. Here's an example using the <a href="http://search.cpan.org/dist/HTML-Parser/lib/HTML/TokeParser.pm">HTML::TokeParser</a> module that comes with the extremely capable <a href="http://search.cpan.org/dist/HTML-Parser">HT... |
If you _insist_ on using a regex, something like this will work in most cases:
# Remove all HTML except "p" tags
$html =~ s{<(?>/?)(?:[^pP]|[pP][^\s>/])[^>]*>}{}g;
Explanation:
s{
< # opening angled bracket
(?>/?) # ratchet past optional /
(?:
[^pP... |
|asp.net|visual-studio|c#| |
Ok, so, my visual studio is broken. I say this NOT prematurely, as it was my first response to see where I had messed up in my code. When I add controls to the page I can't reference all of them in the code behind. Some of them I can, it seems that the first few I put on a page work, then it just stops.
I first tho... |
Visual Studio 2008 Foo-barred |
ASP.NET controls cannot be referenced in code-behind in Visual Studio 2008 |
|c#|asp.net|visual-studio| |
Ok, so, my visual studio is broken. I say this NOT prematurely, as it was my first response to see where I had messed up in my code. When I add controls to the page I can't reference all of them in the code behind. Some of them I can, it seems that the first few I put on a page work, then it just stops.
I first tho... |
If you don't want to write java code in-house, there are commercial applet solutions available:
* <a href="http://scand.com/products/vault/">Vault</a>
* <a href="http://www.javaatwork.com/java-download-applet/details.html">MyDownloder</a>
Both of them have eval versions that you can download and test. |
I use: [Jquery-roundcorners-canvas][1]
it handles borders, and keeps things the same size, in fact you have to pad in a bit to keep from having letters live in the crease. Its pretty fast, unless you are on ie 6.
Same pretty syntax of the other corner packs, but just prettier in general.
[1]: http://jrc.meerbo... |
This question is far too vague to be useful to you or anyone else. Also, Wikipedia is your primary source of info on SQL Server, fail?
The first matrix of the MSDN page for [Features Supported by the Editions of SQL Server 2008][1] is titled "Scalability." The only edition with any features marked "Yes" is Enterpri... |
One of the fundamental differences in filesystem semantics between Unix and Windows is the idea of inodes.
On Windows, a file name is directly attached to the file data. This means that the OS prevents somebody from deleting a file that is currently open. On some versions of Windows you can rename a file that is cur... |
+1 on the execution plan. From here you can see where all the time is being spent in your particular query. Eg. 85% of the time is spent table scanning a particular table, can you put an index on that table to improve it? etc etc. |
There are differences in how Windows and Unix operating systems expose the disk drives to users and how drive space is partitioned.
The biggest difference between the two operating systems is that Unix essentially treats all of the physical drives as one logical drive. (This isn't exactly how it works, but should gi... |
|treeview|tree| |
I have a tree representation of pages in a CMS application. I understand how to persist the tree in the database. However, I don't have a good way to:
A) Reorder subpages under a particular parent page.
B) Provide a UI implementation that allows the user to change the order.
Any suggestions? |
[Pro Spring][1] is a superb introduction to the world of Inversion of Control and Dependency Injection. If you're not aware of these practices and their implications - the balance of topics and technical detail in Pro Spring is excellent. It builds a great case and consequent personal foundation.
Another book I'd su... |
[Pro Spring][1] is a superb introduction to the world of Inversion of Control and Dependency Injection. If you're not aware of these practices and their implications - the balance of topics and technical detail in Pro Spring is excellent. It builds a great case and consequent personal foundation.
Another book I'd su... |
If you _insist_ on using a regex, something like this will work in most cases:
# Remove all HTML except "p" tags
$html =~ s{<(?>/?)(?:[^pP]|[pP][^\s>/])[^>]*>}{}g;
Explanation:
s{
< # opening angled bracket
(?>/?) # ratchet past optional /
(?:
[^pP... |
Also take a look at [Microsoft StyleCop][1]
[1]: http://blogs.msdn.com/sourceanalysis/ |
How does WinXP's "Send to Compressed (zipped) Folder" decide what to include in zip file? |
|zip|windows-xp| |
I'm not going to be too surprised if I get shot-down for asking a "non programming" question, but maybe somebody knows ...
I was zipping the contents of my subversion sandbox using WinXP's inbuilt "Send to Compressed (zipped) Folder" capability and was surprised to find that the .zip file created did not contain the... |
What you described is GORM. It is part of the [Grails][1] framework and is built to work with Hibernate (maybe JPA in the future). When I was first using Grails it seemed backwards. I was more comfortable with a Rails style workflow of making the tables and letting the framework generate scaffolding from the database s... |
IDisposable has nothing to do with freeing memory. IDisposable is a pattern for freeing *unmanaged* resources -- and memory is quite definitely a managed resource.
The links pointing to GC.Collect() are the correct answer, though use of this function is generally discouraged by the Microsoft .NET documentation. |
IDisposable has nothing to do with freeing memory. IDisposable is a pattern for freeing *unmanaged* resources -- and memory is quite definitely a managed resource.
The links pointing to GC.Collect() are the correct answer, though use of this function is generally discouraged by the Microsoft .NET documentation.
... |
In these days of **SQL Server Express**, I'd say there's really no reason for you not to use a database.
I know this doesn't really answer your question, but I'd hate to see you roll out code that will be a nightmare to maintain and scale.
Maybe you could tell us why you want to use xml files instead of a proper ... |
Well, sysrqb will let you match anything in the first paragraph assuming there's no other html in the paragraph. You might want something more like this
<p>.*?</p>
Placing the ? after your * makes it non-greedy, meaning it will only match as little text as necessary before matching the </p> |
C++ Memory management |
|c++|memory|management|pointers| |
I've learned in College that you always have to free your unused Objects but not how you actually do it. For example structuring your code right and so on.
Are there any general rules on how to handle pointers in C++?
|
|c++|memory-management|pointers| |
I've learned in College that you always have to free your unused Objects but not how you actually do it. For example structuring your code right and so on.
Are there any general rules on how to handle pointers in C++?
I'm currently not allowed to use boost. I have to stick to pure c++ because the framework I'm us... |
|c++|pointers|memory-management| |
|c++|memory|pointers| |
How Does A Stack Overflow Occur and How Do You Prevent It? |
|hacking|stack-overflow| |
I was just wondering how a stack overflow occurs and the best ways to make sure it doesn't happen, or ways to prevent one - particularly on web servers, but other examples would be interesting, as well. |
|stack-overflow|memory-management| |
|stack-overflow|memory| |
C Memory Management |
|memory|c| |
I've always heard that in C you have to really watch how you manage memory. And I'm still beginning to learn C, but thus far, I have not had to do any memory managing related activities at all.. I always imagined having to release variables and do all sorts of ugly things. But this doesn't seem to be the case.
Can s... |
The **+ operator** can work between a string and a string, char, integer, double or float data type value. It just converts the value to its string representation before concatenation.
The **concat operator** can only be done on and with strings. It checks for data type compatibility and throws an error if they don'... |