Hi,
By default nunit tests run alphabetically. Does anyone know of any way to set the execution order? Does an attribute exist for this?
Any help would be greatly appreciated.
Thanks
Zaps
function primeNumbers() {
array = [];
for (var i = 2; array.length < 100; i++) {
for (var count = 2; count < i; count++) {
var divisorFound = false;
if (i % count === 0) {
divisorFound = true;
break;
}
}
if (divisorFound == false) {array.push[i];}
}
return array;
}
When I run this code, it seems to get stuck in an infinite loop and doesn't return anything... why?
I am writing unittests for django views. I have observed that one of my views returns redirection code 301, which is not expected.
Here is my views.py mentioned earlier.
def index(request):
return render(request, 'index.html',
{'form': QueryForm()})
def query(request):
if request.is_ajax():
form = QueryForm(request.POST)
return HttpResponse('valid')
Below is urls.py.
urlpatterns = patterns('',
url(r'^$', 'core.views.index'),
url(r'^query/$', 'core.views.query')
)
And unittest that will fail.
def so_test(self):
response = self.client.post('/')
self.assertEquals(response.status_code, 200)
response = self.client.post('/query', {})
self.assertEquals(response.status_code, 200)
My question is: why there is status 301 returned?
i have been asked by a client to develop a javascript(mootools)/html/css/php based game as a widget which can be deployed anywhere.
I have not written a widget before, so would love to get some tips and experiences so that i know some of the pitfalls before i start!
Thanks :)
Dan
Hi All,
Here's what I want to do. I have 2 strings and I want to determine if one string is a permutation of another. I was thinking to simply remove the characters from string A from string B to determine if any characters are left. If no, then it passes.
However, I need to make sure that only 1 instance of each letter is removed (not all occurrences) unless there are multiple letters in the word.
An example:
String A: cant
String B: connect
Result: -o-nec-
Experimenting with NSString and NSScanner has yielded no results so far.
I’m new (only two weeks old) in Jquery, so please bear with me.
I know that a very similar question was asked some time ago
but I do not know how to adapt the answer to my problem.
I have a very wide multicolumn layout something like this:
| aaaa | bbbb | cccc | … |
| aaaa | b | cc | … |
| aaa | cccc | ddd | … |
The code looks like:
<div id="container">
<p>aaaaaaaaaaa</p>
<p>bbbbb</p>
<p>ccccccccccc</p>
<p>dddddddddd</p>
...
<p>xxxxxx</p>
</div>
There is no vertical scrolling and the container width
is set in such a way that only two columns are shown.
The user scrolls left or right to see the relevant text.
What I want is to get the position currently on display,
store it (maybe in a cookie) and retrieve it the next
time the user opens the page.
I think that I need a way of finding out what paragraph
is currently the left-top most, but other suggestions
are very welcome.
Any ideas?
btw: this is an internal project, so Mozilla only :-)
Thanks
Lolo
I have created a web application. One of the feature is text search which perform the boolean operator ( NOT, AND, OR) as well. However, I have no idea on calculating the search's accuracy and efficiency.
For example:
1 . Probe identification system for a measurement instrument
2 . Pulse-based impedance measurement instrument
3 . Millimeter with filtered measurement mode
when the user key in will return the result as below
input :measurement instrument
Result: 1,2
input : measurement OR instrument NOT milimeter
Result: 1,2,3
so, i have no idea on what issue and what algorithm to calculate on the accuracy and efficiency of the text search.. anyone have any idea on that?
I have these classes
public class EntityBase : IEntity
{
public int Id { get; set; }
public DateTime Created { get; set; }
public string CreatedBy { get; set; }
public DateTime Updated { get; set; }
public string UpdatedBy { get; set; }
}
public class EftInterface : EntityBase
{
public string Name { get; set; }
public Provider Provider { get; set; }
public List<BusinessUnit> BusinessUnits { get; set; }
}
public class Provider : EntityBase, IEntity
{
public string Name { get; set; }
public decimal DefaultDebitLimit { get; set; }
public decimal DefaultCreditLimit { get; set; }
public decimal TreasuryDebitLimit { get; set; }
public decimal TreasuryCreditLimit { get; set; }
}
public class BusinessUnit : EntityBase
{
public string Name { get; set; }
}
An interface, is really a Provider, with a collection of Business Units. The issue is that while my db model ends up having a correct EftInterfaces table, with a FK to Provider_Id, the BusinessUnits table has a FK to EftInterface_Id.
But, a BusinessUnit can be included in more than one EftInterface.
I need a many to many relationship. A BusinessUnit can be part of many EftInterfaces, and an EftInterface can contain many BusinessUnits.
How can I get CodeFirst to generate the many-to-many table?
I am trying to add an entity to the DB. Once I have added it, I want to detach it, so I can manipulate the object safely without making any changes to the DB. After calling context.SaveChanges() I do the following to detach the entity:
// save
context.Stories.Add(story);
// attach tags. They already exists in the database
foreach(var tag in story.Tags)
context.Entry(tag).State = System.Data.EntityState.Unchanged;
context.SaveChanges();
context.Entry(story).State = System.Data.EntityState.Detached;
However, changing the entity state to DETACHED will remove all related entities associated with the my entity. Is there a way to stop this ?
If I don't detach the entity, all my changes are sent to the DB next time I call context.SaveChanges()
Thanks!!
I would like to create a predicate to search for a specific letter at the start of each word in a string of words e.g. all words starting with A in @"The man ate apples", would return ate and apples. Is it possible to create such a predicate? Thank you.
Hey,
I have a table that contains sets of sequential datasets, like that:
ID set_ID some_column n
1 'set-1' 'aaaaaaaaaa' 1
2 'set-1' 'bbbbbbbbbb' 2
3 'set-1' 'cccccccccc' 3
4 'set-2' 'dddddddddd' 1
5 'set-2' 'eeeeeeeeee' 2
6 'set-3' 'ffffffffff' 2
7 'set-3' 'gggggggggg' 1
At the end of a transaction that makes several types of modifications to those rows, I would like to ensure that within a single set, all the values of "n" are still sequential (rollback otherwise). They do not need to be in the same order according to the PK, just sequential, like 1-2-3 or 3-1-2, but not like 1-3-4.
Due to the fact that there might be thousands of rows within a single set I would prefer to do it in the db to avoid the overhead of fetching the data just for verification after making some small changes.
Also there is the issue of concurrency. The way locking in InnoDB (repeatable read) works (as I understand) is that if I have an index on "n" then InnoDB also locks the "gaps" between values. If I combine set_ID and n to a single index, would that eliminate the problem of phantom rows appearing?
Looks to me like a common problem. Any brilliant ideas?
Thanks!
Note: using MySQL + InnoDB
I would like to use the EmailField in a form. However, instead of only storing
[email protected]
I want to store
"ACME Support" <[email protected]>
The reason is, that when I send email, I would like a "friendly name" to appear.
Can this be done?
Hi,
I've got a service which runs all the time and also keeps a log file. It basically adds new lines to the log file every few seconds. I'm written a small file which reads these lines and then parses them to various actions. The question I have is how can I delete the lines which I have already parsed from the log file without disrupting the writing of the log file by the service?
Usually when I need to delete a line in a file then I open the original one and a temporary one and then I just write all the lines to the temp file except the original which I want to delete. Obviously this method will not word here.
So how do I go about deleting them ?
I'm trying to figure out if
g++ -fsyntax-only
does only syntax checking or if it expands templates too.
Thus, I ask stack overflow for help:
is there to write a program so that syntactically it's valid, but when template expansion is done, an error occurs?
Thanks!
Hello,
Im trying to do load testing on a web server. I want to customise the error fields whenever i get results other than 200 ok. At present the error is realised only when the server doesnot respond. Is there anyway i could customise error as i need.
Here's my index action in the books controller: http://pastebin.com/XdtGRQKV
Here's the view for the action i just mentioned: http://pastebin.com/nQFy400m
Here's the result without being logged in: http://i.imgur.com/rQoiw.jpg
Here's the result when i'm logged in with the user 'admin': http://i.imgur.com/E1CUr.jpg
So the problem is that, in the view, before line 25 the 'user' variable seems to be empty ( or not loaded), and after line 25 the variable 'user' has the expected values.
I have tried initializing a variable in the index method of the books controller but get exactly the same results.
Thanks in advance!
BTW had to make the links text because of stackoverflow limit.
Hello I have a Rewrite rule I am trying to implement on my local host but I cannot get it to do the action no matter how I setup the regex
the files are in this naming scheme /docroot/css/stylesheet.min.css and I have them printed in the code like /docroot/css/stylesheet.min.123438348.css (the number is example it comes from a get modified function). Note docroot is an example directory
how can I have the server ignore the numbers and redirect to the stylesheet.min.css
I need to do this for every css and js files (/js and /css) as well as one specific spritemap image
my current attempt
RewriteRule ^/(docroot)/(js|css)/(.+)\.(min)\.(.+)\.(js|css)$ /$1/$2/$3.$4.$6
RewriteRule ^(/docroot/images/spritemap)\.([0-9]+)\.(png)$ $1.$3
I have this wrapped in a I am on linux..should this be mod_rewrite.so?"
I am writing a application where I am dealing with 4 activities, let's say A, B, C & D. Activity A invokes B, B invokes C, C invokes D. On each of the activity, I have a button called "home" button. When user clicks on home button in any of the B, C, D activities, application should go back to A activity screen ?
How to simulate "home" button in this case ?
I'm really not confident with Regex, I know some basic syntax but not enough to keep me happy.
I'm trying to build a regular expression to check if an email is valid. So far here's what I've got:
[A-Za-z0-9._-]+@[A-Za-z0-9]+.[A-Za-z.]+
It needs to take account of periods in the username/domain and I think it works with multiple TLDs (e.g. co.uk).
I'm working with the preg engine in PHP so it needs to work with that. Thanks if you can help!
I would like to know what are the open source and commerical tools for window Service Testing. Like memeory usage and code leakes etc ..
C# 2.0 - Window Service.
Hello,
I have a script that each time is called gets the 1st line of a file. Each line is known to be exactly of the same length (32 alphanumerci chars) and terminates with a "\r\n".
After getting the 1st line, the script removes it.
Now I do in this way:
$contents = file_get_contents($file));
$first_line = substr($contents, 0, 32);
file_put_contents($file, substr($contents, 32 + 2)); //+2 because we remove also the \r\n
Obvioulsy it works, but I was wondering if there could be a smarter (or more efficent) way to do this???
In my simple solution I basically read and rewrite all the file just to take and remove the 1st line.
Thanks!
I want to get the code coverage of my tests. So I set the settings, build an app with .gcno files and run it on simulator.
It can get the coverage data successfully if there is no crash issue.
But if the app crashed, I will get nothing.
So how can I get the code coverage data when the app crash?
In my thought, this is because it will not call __gcov_flush() method when app crash. I only add app does not run in background to my plist file, so __gcov_flush() is called only at the time I press Home button.
Is there any way to call __gcov_flush() before the app crash?
If you were a programming teacher and you had to choose one sorting algorithm to teach your students which one would it be? I am asking for only one because I just want to introduce the concept of sorting. Should it be the bubble sort or the selection sort? I have noticed that these two are taught most often. Is there another type of sort that will explain sorting in an easier to understand way?
Hi,
this is something I know I should embrass in my coding projects but, due to lack of knowledge and my legendary lazyness, I do not do.
In fact, when I do them, I feel like overloaded and I finally give up.
What I am looking for is a good book/tutorial on how to really write good tests -i.e useful and covering a large spectrum of the code -.
Regards