Doctrine expecting class instead of interface - doctrine-orm

The project is in ZF2 + doctrine
We installed the memcached in current working project. Memcached is working fine. First time project loads fine. When you try to load second time it throws an error. Doctrine expects class instead of interface. I am new to doctrine and ZF2 as well.
Fatal error: Doctrine\Common\Persistence\Mapping\MappingException: Class 'WdwTask\Entity\TaskUserInterface' does not exist in /Applications/XAMPP/xamppfiles/htdocs/TMS2/vendor/zendframework/zend-view/src/Helper/Navigation/AbstractHelper.php on line 153
Call Stack
# Time Memory Function Location
1 0.0040 245376 {main}( ) ../index.php:0
2 1.5424 25728664 Zend\Mvc\Application->run( ) ../index.php:33
3 3.8229 38425752 Zend\Mvc\Application->completeRequest( ) ../Application.php:356
4 3.8229 38425752 Zend\EventManager\EventManager->triggerEvent( ) ../Application.php:384
5 3.8229 38425752 Zend\EventManager\EventManager->triggerListeners( ) ../EventManager.php:251
6 3.8230 38427560 call_user_func:{/Applications/XAMPP/xamppfiles/htdocs/TMS2/vendor/zendframework/zend-eventmanager/src/EventManager.php:490} ( ) ../EventManager.php:490
7 3.8230 38427944 Zend\Mvc\View\Http\DefaultRenderingStrategy->render( ) ../EventManager.php:490
8 3.8230 38428480 Zend\View\View->render( ) ../DefaultRenderingStrategy.php:105
9 3.8323 38474200 Zend\View\Renderer\PhpRenderer->render( ) ../View.php:207
10 3.8355 38510640 include( '/Applications/XAMPP/xamppfiles/htdocs/TMS2/vendor/wdw/application/view/layout/layout.phtml' ) ../PhpRenderer.php:502
11 4.1710 41668944 Zend\View\Renderer\PhpRenderer->render( ) ../layout.phtml:29
12 4.1735 41695392 include( '/Applications/XAMPP/xamppfiles/htdocs/TMS2/vendor/wdw/application/view/layout/blocks/sidebar.phtml' ) ../PhpRenderer.php:502
13 4.1864 41952192 Zend\View\Helper\Navigation\AbstractHelper->__toString( ) ../PhpRenderer.php:24
14 4.2209 42131504 trigger_error ( ) ../AbstractHelper.php:153

Related

Python 3.5 loop to generate a new list each iteration

I'm trying to write some code that (pseudo-randomly) generates a list of 7 numbers. I have it working for a single run. I'd like to be able to loop this code to generate multiple lists, which I can output to a txt file (I don't need help with this I'm quite comfortable working with i/o and files :)
I'm now using this code (thanks Jason for getting it this far):
import random
pool = []
original_pool = list( range( 1,60))
def selectAndPrune(x):
pool = []
list1 = []
random.shuffle(pool)
pool = original_pool.copy()
current_choice = random.choice(pool)
list1.append(current_choice)
pool.remove(current_choice)
random.shuffle(pool)
print(list1)
def repeater():
for i in range(19):
pool_list = []
pool = original_pool.copy()
a = [ selectAndPrune(pool) for x in range(7)]
pool_list.append(a)
repeater()
This is giving output of single value lists like:
[21]
[1]
[54]
[48]
[4]
[32]
[15]
etc.
The output I want is 19 lists, all containing 7 random ints:
[1,4,17,23,45,51,3]
[10,2,9,38,4,1,24]
[15,42,35,54,43,28,14]
etc
If I am understanding the question correctly, the objective is to repeat a function 19 times. However, this function slowly removes items from the list at each call, making it impossible to run past the size of the pool as currently written in the question. I suspect that the solution is something like this:
import random
def spinAndPrune():
random.shuffle( pool )
current_choice = random.choice( pool )
pool.remove( current_choice )
random.shuffle( pool )
return current_choice
First, I added a return command at the end of the function call. Next, you can make copy of the original pool, so that it is possible to re-run it as many times as desired. Also, you need to store the lists you want to keep:
# create an original pool of values
original_pool = list( range( 1, 60 ) )
# initialize a variable that stores previous runs
pool_list = []
# repeat 19 times
for i in range( 19 ):
# create a copy of the original pool to a temporary pool
pool = original_pool.copy()
# run seven times, storing the current choice in variable a
a = [ spinAndPrune() for x in range( 7 ) ]
# keep track of variable a in the pool_list
pool_list.append( a )
print( a )
Note the .copy() function to make a copy of the list. As an aside, the range() makes it easy to create lists containing integers 1-59.
If you need to extract a specific list, you can do something along the lines of this:
# print first list
print( pool_list[ 0 ] )
# print fifth list
print( pool_list[ 4 ] )
# print all the lists
print( pool_list )
In my other answer, I approached it by modifying the code in the original question. However, if the point is just to extract X number of values without repeat in a collection/list, it is probably easiest to just use the random.sample() function. The code can be something along the lines of this:
import random
pool = list( range( 1, 60 ) )
pool_list = []
# sample 19 times and store to the pool_list
for i in range( 19 ):
sample = random.sample( pool, 7 )
pool_list.append( sample )
print( sample )

Why does this regular expression "freeze" the program in VC++?

I have the following code, originally programmed using C++11's regular expressions library (#include <regex>) but now using Boost in an attempt to troubleshoot:
boost::regex reg(R"(.*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z]*[0-9]+[a-z0-9]*)).*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z]+)).*?(\d+).*?((?:[a-z][a-z]+)))", boost::regex::icase);
boost::cmatch matches;
if (boost::regex_match(request, reg) && matches.size() > 1)
{
printf("Match found");
}
else
{
printf("No match.");
}
When executed, this code seems to "freeze" on boost::regex_match(request, reg), as if it's taking a long time to process. I waited five minutes for it to process (in case this is a processing issue) but the program state was the same.
I tested the STL's regex library version of the above code online on cpp.sh and onlinegdb, and it works flawlessly there. I then copied this code into a VC++ project, and the code freezes again:
#include <iostream>
#include <string>
#include <regex>
int main()
{
std::string request = "\\login\\\\challenge\\jRJkdflp3gvTzrwiQ3tyKSqnyppmaZog\\uniquenick\\Lament\\partnerid\\0\\response\\4767846ef255a88da9b10f7c923a1e6e\\port\\-14798\\productid\\11489\\gamename\\crysiswars\\namespaceid\\56\\sdkrevision\\3\\id\\1\\final\\";
std::regex reg(R"(.*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z]*[0-9]+[a-z0-9]*)).*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z]+)).*?(\d+).*?((?:[a-z][a-z]+)))", std::regex::icase);
std::smatch matches;
if (std::regex_search(request, matches, reg) && matches.size() > 1)
{
printf("Match found");
}
else
{
printf("No match.");
}
}
The string concerned is the following:
\login\challenge\jRJwdflp3gvTrrwiQ3tyKSqnyppmaZog\uniquenick\User\partnerid\0\response\4767846ef255a83da9b10f7f923a1e6e\port-14798\productid\11489\gamename\crysiswars\namespaceid\56\sdkrevision\3\id\1\final\
I tested the same code on a Visual Studio 2017 installation on another computer (brand new project) and get the exact same result... which seems to indicate that something that the compiler is doing is causing the code to freeze/take a long time processing. I am unable to test on another compiler locally at present.
The regular expression string checks out on regex101, so functionally the expression is OK.
This is with Visual Studio 2017 Professional targeting v141.
Why is this happening, and how can I fix it?
Your problem is one of backtracking.
In the boost sample, you use regex_match which forces a match on the
whole string.
You will get the same result if using regex_search and adding ^..$.
However, your string can never match because you have forced it to end
on a letter, but the string really ends with a backslash .
This forces the engine to retry all those .*? positions.
The fix is to put a final .*? at the end of your regex which will let
the regex fulfill it's mission of matching the entire string.
Other things may help, you could clean up your regex a bit and/or add some
atomic groups and/or add some slashes in place of those .*?
Anyway, use this :
^.*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z]*[0-9]+[a-z0-9]*)).*?((?:[a-z][a-z]+)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z0-9_]*)).*?(\d+).*?((?:[a-z][a-z]+)).*?(\d+).*?((?:[a-z][a-z]+)).*?$
Output
** Grp 0 - ( pos 0 : len 207 )
\login\challenge\jRJwdflp3gvTrrwiQ3tyKSqnyppmaZog\uniquenick\User\partnerid\0\response\4767846ef255a83da9b10f7f923a1e6e\port-14798\productid\11489\gamename\crysiswars\namespaceid\56\sdkrevision\3\id\1\final\
** Grp 1 - ( pos 1 : len 5 )
login
** Grp 2 - ( pos 7 : len 9 )
challenge
** Grp 3 - ( pos 17 : len 32 )
jRJwdflp3gvTrrwiQ3tyKSqnyppmaZog
** Grp 4 - ( pos 50 : len 10 )
uniquenick
** Grp 5 - ( pos 61 : len 4 )
User
** Grp 6 - ( pos 66 : len 9 )
partnerid
** Grp 7 - ( pos 76 : len 1 )
0
** Grp 8 - ( pos 78 : len 8 )
response
** Grp 9 - ( pos 94 : len 25 )
ef255a83da9b10f7f923a1e6e
** Grp 10 - ( pos 120 : len 4 )
port
** Grp 11 - ( pos 125 : len 5 )
14798
** Grp 12 - ( pos 131 : len 9 )
productid
** Grp 13 - ( pos 141 : len 5 )
11489
** Grp 14 - ( pos 147 : len 8 )
gamename
** Grp 15 - ( pos 156 : len 10 )
crysiswars
** Grp 16 - ( pos 167 : len 11 )
namespaceid
** Grp 17 - ( pos 179 : len 2 )
56
** Grp 18 - ( pos 182 : len 11 )
sdkrevision
** Grp 19 - ( pos 194 : len 1 )
3
** Grp 20 - ( pos 196 : len 2 )
id
** Grp 21 - ( pos 199 : len 1 )
1
** Grp 22 - ( pos 201 : len 5 )
final

Empty groups in regex

I use a regexp to test a link :
lolspec:\/\/(spectator\.(na|euw1|eu|kr|oc1|br|la1|la2|ru|tr|pbe1)\.lol\.riotgames\.com:(80|8088)((([?&]region=(NA1|EUW1|EUN1|KR|OC1|BR1|LA1|LA2|RU|TR1|PBE1))|([?&]gameID=([0-9]+))|([?&]encKey=(.+)))){3})
to test this link :
lolspec://spectator.euw1.lol.riotgames.com:80?region=NA1&gameID=44584&encKey=fghgdsv1134+ianfcuia
but some groups are empty (#7, #8, #9)
what should I do ?
Probably overkill on the capture groups.
The regex you use there contains a container capture group 4 that is quantified
like this ( ... ){3}.
What that will do is overwrite the container capture buffer 3 times leaving
the last value captured within the capture group.
Moving on to the next level is a single inner group with which the outer group encapsulates, like this (( ... )){3} so thats not needed, and you get the same affect of overwritting.
Moving even deeper, are three capture groups all separated by alternations.
They follow the same rules, each one will get overwritten if they can match
again during each successive 1..3 quantified passes.
Its only that one group match in the alternation cluster.
So, if you have identical adjacent data, it could be matched by the same
alternation cluster, leaving the other cluster groups empty.
So, this is not the approach if you want to match out-of-order parameters
in a string.
The way this is done is using lookahead assertions OR if you are using
an engine that can do conditionals.
The way to do it using conditionals is like this
(?:
.*?
(?:
( (?(1)(?!)) abc ) # (1)
| ( (?(2)(?!)) def ) # (2)
| ( (?(3)(?!)) ghi ) # (3)
)
){3}
It forces finding all of the capture group contents.
The way you are doing it is the same but without the conditionals,
and suffering the consequences as stated above.
Btw, Your regex above does not have any empty groups with that particular sample, But it has many problems.
lolspec:\/\/
( # (1 start)
spectator\.
( na | euw1 | eu | kr | oc1 | br | la1 | la2 | ru | tr | pbe1 ) # (2)
\.lol\.riotgames\.com:
( 80 | 8088 ) # (3)
( # (4 start)
( # (5 start)
( # (6 start)
[?&] region=
( NA1 | EUW1 | EUN1 | KR | OC1 | BR1 | LA1 | LA2 | RU | TR1 | PBE1 ) # (7)
) # (6 end)
| ( # (8 start)
[?&] gameID=
( [0-9]+ ) # (9)
) # (8 end)
| ( # (10 start)
[?&] encKey=
( .+ ) # (11)
) # (10 end)
) # (5 end)
){3} # (4 end)
) # (1 end)
Output
** Grp 0 - ( pos 0 , len 97 )
lolspec://spectator.euw1.lol.riotgames.com:80?region=NA1&gameID=44584&encKey=fghgdsv1134+ianfcuia
** Grp 1 - ( pos 10 , len 87 )
spectator.euw1.lol.riotgames.com:80?region=NA1&gameID=44584&encKey=fghgdsv1134+ianfcuia
** Grp 2 - ( pos 20 , len 4 )
euw1
** Grp 3 - ( pos 43 , len 2 )
80
** Grp 4 - ( pos 69 , len 28 )
&encKey=fghgdsv1134+ianfcuia
** Grp 5 - ( pos 69 , len 28 )
&encKey=fghgdsv1134+ianfcuia
** Grp 6 - ( pos 45 , len 11 )
?region=NA1
** Grp 7 - ( pos 53 , len 3 )
NA1
** Grp 8 - ( pos 56 , len 13 )
&gameID=44584
** Grp 9 - ( pos 64 , len 5 )
44584
** Grp 10 - ( pos 69 , len 28 )
&encKey=fghgdsv1134+ianfcuia
** Grp 11 - ( pos 77 , len 20 )
fghgdsv1134+ianfcuia

XTEA fragment: Which is better layout?

I am doing a University assignment in which part of the assignment is to implement the XTEA block cipher in C++. We are allowed to use Internet sources, so I went to the XTEA Wikipedia page and found the code there.
As I was copying it^ I was thinking about code style/layout. I initially had
data_first32 = ( (( data_last32 << 4 ) ^ ( data_last32 >> 5 )) + data_last32 ) ^
( sum + key[ sum & 3 ] );
(Note: those are 2 lines not 1 line wrapped)
However I then thought maybe it would be easier to read if it was:
data_first32 =
(
(
( data_last32 << 4 )
^
( data_last32 >> 5 )
)
+
data_last32
)
^
( sum + key[ sum & 3 ] );
The latter one seems to be to be (slightly) easier to read, however it just seems 'wrong'.
Which is the better (Readability) style?
Why does the latter one seem 'wrong'?
^ Not using copy & paste, as I wanted to go through it manually and I wanted better variable names.

RPAREN EQALOP and unbound variable and constructor errors in SML/ML

Said I have got 2 CNF logical phrases a,b and my distrib function should return the CNF form of a|b (a OR b).
Replacing rules that I've got are:
1) Replace p|(q&r) by (p|q)&(p|r)
2) Replace (q&r)|p by (q|p)&(r|p)
A prop defined this way:
datatype prop = Atom of string | Not of prop | And of prop*prop | Or of prop*prop;
The function:
local
fun doOr(prop1,prop2) = (Or(prop1,prop2))
fun distrib1 (Or(Atom(sName1),Atom(sName2) ) ) = Or(Atom(sName1), Atom(sName2) )
|distrib1 (Or(Not(Atom(sName1) ),Atom(sName2) ) ) = Or(Not(Atom(sName1) ), Atom(sName2) )
| distrib1 (Or(Atom(sName1),Not(Atom(sName2) ) ) ) = Or(Atom(sName1), Not(Atom(sName2) ) )
| distrib1 (Or(Not(Atom(sName1)),Not(Atom(sName2) ) ) ) = Or(Not(Atom(sName1)), Not(Atom(sName2) ) )
| distrib1 (Or(prop1,And(prop2,prop3) ) ) = And( distrib1(Or(prop1,prop2) ), distrib1(Or(prop1,prop3) ) )
| distrib1 (Or(And(prop1, prop2), prop3) ) ) = And( distrib1(Or(prop1,prop3) ), distrib1(Or(prop2,prop3) ) )
in
fun distrib (prop1,prop2) = distrib1(doOr(prop1,prop2) );
end;
Well, I don't know if the function itself is right although I just went through all the base options and the replacing rules but for now I get the above errors when the EQALOP appear after the distrib1 function and the constructors error appear the distrib function.
Why I get those errors? I am not sure but maybe I am supposed to use let and not local but then how can I transform it to a let structure?
Thanks.
In the last case of distrib1 you have a total of 3 opening parentheses, but 4 closing:
| distrib1 (Or(And(prop1, prop2), prop3) ) ) =
Which is why you get the the syntax error about the RPAREN.
You're getting an error in distrib because distrib1 has not been defined due to the syntax errors and thus it is an unknown variable. Fixing the syntax error in distrib1 will fix this too.