instruction stringlengths 0 30k ⌀ |
|---|
How about this:
class MyClass:
def __init__(self, foo):
if foo != 1:
raise Exception("foo is not equal to 1!")
import unittest
class Tests(unittest.TestCase):
def testSufficientArgs(self):
foo = 1
MyClass(foo)... |
This is almost as ugly but perhaps as step in right direction?
(1..8).map{|i| ('a'..'z').to_a[rand(26)]}.join
|
There will always be unanswered feature requests and bug reports. Ship it, but include a readme with "known issues" and workarounds when possible. |
I can verify that xplorer2 does show the HG tortoise context menu in 64bit Vista. |
I don't believe that there is a way without moving ClassX into a new code library project. .NET requires all an assembly's dependencies to exist in the same folder as the assembly itself, or in the GAC, to be automatically detected.
You could try loading the assembly manually via the Reflection classes, although ... |
Precisely document the wonkiness and ship it.
Make sure a user is likely to *see* and *understand* your documentation of the wonkiness.
You could even discuss the decision with users who have requested the feature: do some market research.
Just because you can't fix it now, doesn't mean you won't be able to in... |
Unit testing for C++ code - Tools and methodology |
|c++|unit-testing|refactoring| |
I work on a large c++ system that is being developed for a few years now. As part of an effort to improve the quality of the existing code we engaged on a large long-term refactoring project.
Do you know a good tool that can help me write unit tests in C++? Maybe something similar to Junit or Nunit?
Can anyone gi... |
Almost there! The escape sequence for a brace is {{ or }} so for your example you would use:
string t = "1, 2, 3";
string v = String.Format(" foo {{{0}}}", t); |
Try:
if [ ! -z `ls /some/dir/*` ]; then echo "huzzah"; fi |
I'd say, the *Game* class shouldn't care if this is a computer player or a human player. It should always call *TakeTurn* on the next player class. If this is a human player, it is the responsibility of the *Player* class, to communicate with the user and ask the user what to do. That means it will block till the user ... |
Problem with TVN_SELCHANGED on CTreeCtrl object |
|visual-c++||ctreectl| |
I have tree control object created using CTreeCtrl MFC class. The tree control needs to support rename.
When I left click on any of item in Tree the TVN_SELCHANGED event is called from which I can get the selected item of the tree as below :
HTREEITEM h = m_moveListTree.GetSelectedItem();
CString s = m_moveListT... |
|mfc|visual-c++|treeview| |
CppUnit is the way. See link below:
http://cppunit.sourceforge.net/cppunit-wiki
http://en.wikipedia.org/wiki/CppUnit
|
DIR="/some/dir"
if["$(ls -A $DIR)"]; then
echo 'Theres something alive in here';
fi
|
If you were using Oracle DBMS that would be pretty straightforward since Oracle supports tree queries with the **CONNECT BY/STARTS WITH** syntax. For SQL Server I think you might find [Common Table Expressions][1] useful
[1]: http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1277481,00.html |
Here's a section of html from a recent project:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{DYNAMIC(T... |
To disable the ?timestamp cache busting in production add this to your config/environments/production.rb
ENV['RAILS_ASSET_ID'] = ''
If you want to dig deeper into what this does, check out asset___tag_helper.rb in the ActionPack gem, line 527 (ish) |
To disable the ?timestamp cache busting in production add this to your config/environments/production.rb
ENV['RAILS_ASSET_ID'] = ''
If you want to dig deeper into what this does, check out asset_tag_helper.rb in the ActionPack gem, line 527 (ish) |
If you're doing a lot of bit twiddling you might want to use masks which will make the whole thing quicker. The following functions are very fast and still flexible (they allow bit twiddling in bit maps of any size).
const unsigned char TQuickByteMask[8] =
{
0x01, 0x02, 0x04, 0x08,
0x... |
Theoretically, the language is designed to be compiled into bytecode like Java which is interpreted by the Common Language Runtime, a mechanism that also allows several languages (not just C#) to work together and run on the .NET framework.
However, Microsoft has only developed the CLR for Windows. There are other n... |
Others have explained why adding the *.suo and *.user files to source control is not a good idea.
I'd like to suggest that you set the `svn:ignore` property to include those types of files, for 2 reasons:
1. So other developers won't wind up
with one developer's settings.
2. So when you view status, or co... |
Yes - purely on the basis that I found this question by looking for the usability tag. :)
So far, on sites like this one, I tend to see tags as mutually exclusive filters. I'd like to *combine* tags in a search, but the fact that it's not immediately obvious how to do this on many sites e.g. as with labels in Blogge... |
Use `` to jump back to the exact position you were in before you searched/jumped, or '' to jump back to the start of the line you were on before you searched/jumped. |
Yes and no. Parts of the .NET environment are standards and could be openly adopted.
For example, the runtime (CLR) has a portable version called [Mono][1] which is multi platform, open source and is used by (for example) Second Life.
[1]: http://en.wikipedia.org/wiki/Mono_(software) |
My intuitive feeling tells me that the answer would have something to do with a Pivot Table outline, which has a *fixed* number of zones, namely:
- the Page Fields zone
- the Column Fields zone
- the Row Fields zone and
- the Data zone
In my wild guess:
- The Page zone builds the W... |
The intention, or at least the pitch, was for this to be the case. The reality is that .NET can't really run on other platforms. The only major exception is <a href="http://www.mono-project.com/Main_Page">Mono</a>, which is an open source project. It's essentially a rewrite of the .NET runtime (the equivalent of the ja... |
- 508 Compliance - the ability for a screenreader to make sense of your markup.
- Waiting for render - tables don't render in the browser until it gets to the end of the `</table>` element.
|
According to the [PHP docs][1], strpos() and stripos() will return an integer for the position, **OR** a boolean FALSE.
Since 0 (zero) is a valid, and very expect-able index, this function should be used with extreme caution.
Most libs wrap this function in a better one (or a class) that returns -1 if the value i... |
I would not recommend having your get methods go to the database at all, unless absolutely necessary for your particular problem. It makes for a lot more places something could go wrong, and probably a lot of unnecessary reads on your DB, and could inadvertently tie your objects to db-specific features, losing a lot o... |
Shorthand if + nullable types (C#) |
|c#|shorthand-if| |
The following returns
> Type of conditional expression cannot be determined because there is no implicit conversion between 'double' and '<null>'
aNullableDouble = (double.TryParse(aString, out aDouble)?aDouble:null)
----------
The reason why I can't just use aNullableBool instead of the roundtrip ... |
The .vimrc clip in one of the other answers is slightly wrong. To turn your tab key into an auto-complete key, use this code:
inoremap <c-r>=InsertTabWrapper()<cr>
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
... |
The .vimrc clip in one of the other answers is slightly wrong. To turn your tab key into an auto-complete key, use this code:
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<ta... |
It might not be possible to avoid all feature requests.
But try assigning a cost for each feature request. When the next planning meeting or deciding the features for the next release comes around this will help to weed out the unnecessary ones. |
Best way to handle null when writing equals operator |
|c#| |
When I overload the == operator for objects I typically write something like this:
public static bool operator ==(MyObject uq1, MyObject uq2) {
if (((object)uq1 == null) || ((object)uq2 == null)) return false;
return uq1.Field1 == uq2.Field1 && uq1.Field2 == uq2.Field2;
}
If you don't down-cast to ob... |
|c#|operator-overloading|equals| |
In the past I've created a table that has the Name of the list and the acceptable values, then queried it to display the list. I also include a underlying value, so you can return a display value for the list, and a bound value that may be much uglier (a small int for normalized data, for instance)
CREATE TABLE ... |
Clarifications:
I'm surprised you added "database" as one of the tags, and considered it as an option. Why did you do this?
Essentially, you have a 2D, single component floating point image at every time step. Would you agree with this way of viewing your data?
You also mentioned the desire to insert a day b... |
I think you'll need to put something on the left and/or right of the split (split.setLeftWidget(widget), split.setRightWidget(widget)) in order for anything to show up. |
I think you'll need to put something on the left and/or right of the split (split.setLeftWidget(widget), split.setRightWidget(widget) OR split.add(widget), which will add first to the left, then to the right) in order for anything to show up. |
ZFS is a start. Many storage vendors provide 520B drives with extra data protection available as well. However, this only protects your data as soon as it enters the storage fabric. If it was corrupted at the host level, then you are hosed anyway.
On the horizon are some promising standards-based solutions to this v... |
first, you forgot your trailing commas in your data array items.
try the following:
<pre><code>var obj_hash = {
"hdrs": ["Make","Model","Year"],
"data" : [
{"Make":"Honda","Model":"Accord","Year":"2008"},
{"Make":"Toyota","Model":"Corolla","Year":"2008"},
{"Make":"Honda","Model":"Pilot","Year":"2008"... |
We were targeting >80% till few days back, But after we used a lot of Generated code, We do not care for %age, but rather make reviewer take a call on the coverage required. |
MojoPortal might be worth a look into. Other than that, the list linked to by Nathan is well-worth looking into |
The Sieve of Eratosthenes is fairly easy to implement but -- as you have discovered -- not the most efficient. Have you tried the Sieve of Atkin?
[Sieve of Atkin @ Wikipedia][1]
[1]: http://en.wikipedia.org/wiki/Sieve_of_Atkin |
Need Lightweight .NET SMTP implementation (assembly or source) |
|c#|.net|smtp| |
I am writing a small application that will receive messages to process over smtp port 25.
I am looking for an .NET assembly that I can incorporate that will listen to port 25 and talk SMTP. I invision that when a message arrives some event is triggered where I can read the message and process it.
Esstentilly I... |
This has to be dependent on what phase of your application development lifecycle you are in.
If you've been at development for a while and have a lot of implemented code already and are just now realizing that you need to think about code coverage then you have to check your current coverage (if it exists) and the... |
Code Coverage is a misleading metric if 100% coverage is your goal (instead of 100% testing of all features).
- You could get a 100% percent by hitting all the lines once. However you could still miss out testing a particular sequence (logical path) in which those lines are hit.
- You could not get a 100% bu... |
I think the best symptom of correct code coverage is that amount of concrete problems unit tests help to fix is reasonably corresponds to size of unit tests code you created. |
OO PHP explanation For a braindead n00b |
|php|oop| |
I've been writing PHP for about six years now and have got to a point where I feel I should be doing more to write better code. I know that Object Oriented code is the way to go but I can't get my head around the concept.
Can anyone explain in terms that any idiot can understand, OO and how it works in PHP or point ... |
To correct some comments by others here, .Net was ALWAYS intended to be multi-platform. That is why Microsoft separated the namespaces into "System.\*" (which were platform-neutral) and "Microsoft.\*" (which were Windows specific). |
Is .NET a write once, run anywhere (WORA) platform like Java claims to be? |
|.net|java| |
I remember Sun's slogan so vividly... ["Write Once, Run Anywhere"](http://en.wikipedia.org/wiki/Write_once,_run_anywhere). The idea being that since programs are compiled into standard byte codes, any device with a Java Virtual Machine could run it. Over the years, Java seems to have made it onto many platforms/devices... |
|.net|java|multiplatform| |
Uninstall Sharepoint Infrastructure Update |
|sharepoint|moss|wss| |
I installed WSS Infrastructure Update and MOSS Infrastructure Update (http://technet.microsoft.com/en-us/office/sharepointserver/bb735839.aspx) and now I can't restore the content database on an older version. Do you know if there is a way to uninstall it ? |
It's not the standard behaviour of the ListView control, even when MultiSelect is set to true.
If you wanted to create your own custom control you would need to do the following:
1. Derive a control from ListView
2. add a handler to the "Selected" event.
3. In the "OnSelected", maintain your own list of sel... |
WS-Security specifications are not typically contained in a WSDL (never in a WSE WSDL). So wsdl2java does not know that WS-Security is even required for this service. The fact that security constraints are not present in a WSE WSDL is a big disappointment to me (WCF will include WS-Trust information in a WSDL).
On t... |
Yes, according to <http://www.cplusplus.com/reference/stl/>, begin(), end() etc are all O(1).
|
You can create a video from a sequence of images using LiVES:
http://lives.sourceforge.net
Simply place all of the images in a directory, and make sure they are in alphanumeric order.
Then in LiVES, just go to File/Open File or Directory, and double-click on the image directory.
Once the images have loaded you ... |
As several folks have already said: don't.
It's pretty much implicit, given the nature of the Perl interpreter, that anything you do to obfuscate the Perl must be undoable before Perl gets its hands on it, which means you need to leave the de-obfuscation script/binary lying around where the interpreter (and thus you... |
As several folks have already said: don't.
It's pretty much implicit, given the nature of the Perl interpreter, that anything you do to obfuscate the Perl must be undoable before Perl gets its hands on it, which means you need to leave the de-obfuscation script/binary lying around where the interpreter (and thus you... |
Which heap size do you prefer ? |
|java| |
I know there is no "right" heap size, but which heap size do you use in your applications (application type, jdk, os)? |
|java|subjective| |
To me, if you want to go by the [ACID][1] standards, it is critical to have foreign keys to ensure referential integrity.
[1]: http://en.wikipedia.org/wiki/ACID |
aNullableDouble = (double.TryParse(aString, out aDouble)?new Nullable<double>(aDouble):null) |
You should be aware of the fact that your original attempt
<pre>int count = map.containsKey(word) ? map.get(word) : 0;</pre>
contains two potentially expensive operations on a map, namely <code>containsKey</code> and <code>get</code>. The former performs an operation potentially pretty similar to the latter, so you'... |
We are also having this issue. Our application runs on .Net 2.0 but is compiled by VS 2008 SP1. I have .NET 3.5 SP1 installed as well. I've got no idea why this happens either, it doesn't look like a deadlock issue on our end as no other threads are running at this point (it is during application shutdown). |
Label what you have now as a 'beta version' and send it out to those people who have asked for it. Get their feedback on how well it works, fix whatever they complain about, and you should then be ready to roll it out to larger groups of users. |
To address your three questions separately:
> What is the advantage in having other languages for the JVM?
There are two factors here. (1) Why have a language other than Java for the JVM, and (2) why have another language run on the JVM, instead of a different runtime?
1. Other languages can satisfy other ne... |
To address your three questions separately:
> What is the advantage in having other languages for the JVM?
There are two factors here. (1) Why have a language other than Java for the JVM, and (2) why have another language run on the JVM, instead of a different runtime?
1. Other languages can satisfy other ne... |
I hope there is none.
Mocks are supposed to mock interfaces, which have no constructors... just methods.
Something seems to be amiss in your approach to testing here. Any reason why you need to test that explicit constructors are being called ?
Asserting the type of returned object seems okay for testing facto... |
I hope there is none.
Mocks are supposed to mock interfaces, which have no constructors... just methods.
Something seems to be amiss in your approach to testing here. Any reason why you need to test that explicit constructors are being called ?
Asserting the type of returned object seems okay for testing facto... |
There are a couple of options here.
1. You can create a "Complex Type" and map that to the procedure result. However, you have to do that in your EDMX; it's not supported by the designer. Read [this article][1] for details. Note that Complex Types are not entity types *per se*, so this may or may not fit your nee... |
Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives |
|apache|windows|virtualhost|http-status-code-403| |
I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file:
<pre><code>
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>... |
Edit: Apparently this isn't clear enough, I am using Windows (XP).
I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file:
... |
Iterators can be used against any sort of collection. They allow you to define an algorithm against a collection of items regardless of the underlying implementation. This means you can process a List, Set, String, File, Array, etc.
Ten years from now you can change your List implementation to a better implementatio... |
I've never tried `script/destroy`, but if you're reverting changes that you just made, the generate command should give you a list of files added and changes made. If you're using a version control system of some sort, running status/diff might help as well. |
You could leave the structure as you currently have it (without the dependency from MessageManager to DataAccess that causes the problem) and then have MessageManager dynamically load the concrete implementation required at runtime using the System.Reflection.Assembly class. |
If you've been doing unit testing for a decent amount of time, I see no reason for it not to be approaching 95%+. However, at a minimum, I've always worked with 80%, even when new to testing.
This number should only include code written in the project (excludes frameworks, plugins, etc.) and maybe even exclude certa... |
Have you looked at this: [CodeProject: SMTP and POP3 Mail Server][1]?
[1]: http://www.codeproject.com/KB/IP/smtppop3mailserver.aspx |
Your problem is in how you're associating the `ReleaseItem` and the `Pack`.
`has_many :through` and `has_one :through` both work through an object that also acts as a join table, in this case `PackReleaseItem`. Since this is not just a join table (if it were, you should just use `has_many` without `:through`), prop... |
How to make my .NET app support different languages |