I am trying to get the following link to work:
http://localhost:8001/name/jason/grey
and the routes definition:
{"/name/([a-zA-Z]+)/([a-zA-Z]+)", [{controller, "stuff"}, {action, "getStudentNames"}, [{firstname, '$1'}, {lastname, '$2'}]]}.
and then in my controller
getStudentNames('GET', [FirstName, LastName])->
{output, "ok"}.
I get the following error message
CRASH REPORT Process <0.313.0> with 0 neighbours exited with reason: no function clause matching boss_router_controller:'-index_and_extract_params/1-fun-0-'([{firstname,'$1'},{lastname,'$2'}], []) line 258 in gen_server:terminate/7 line 812
Seems I am not getting it right with the routes definition, any help?
Finally got it working, should in case there is anyone with the same issue. Instead of using list of tuples in the route definitions to define the parameters, use tuples separated by commas e.g
{"/name/([a-zA-Z]+)/([a-zA-Z]+)", [{controller, "stuff"}, {action, "getStudentNames"}, {firstname, '$1'}, {lastname, '$2'}]}.
Related
I need to get one date in one format like this:
2020-06-03T06:14:00.000+0100.
following this documentation page [1], I tried to do with this expression, but always get an error:
format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s][Z0000]")
I tried to put with this mask too:
format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s][Z0001]")
but the result is 2020-06-03-14:39:50+02:00
I need to delete the ":" on the offset, ¿Which mask may I use?
[1]https://www.rfc-editor.org/rfc/rfc3339#section-5.6
A workaround for your problem could be splitting the output of format-dateTime into two parts and remove the colon on the second expression:
concat(format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s]"),translate(format-dateTime(current-dateTime(), "[Z0001]"),":",""))
Maybe this works for you.
I'm developing an app using Grails. I want to get length of array.
I got a wrong value. Here is my code,
def Medias = params.medias
println params.medias // I got [37, 40]
println params.medias.size() // I got 7 but it should be 2
What I did wrong ?
Thanks for help.
What is params.medias (where is it being set)?
If Grials is treating it as a string, then using size() will return the length of the string, rather than an array.
Does:
println params.medias.length
also return 7?
You can check what Grails thinks an object is by using the assert keyword.
If it is indeed a string, you can try the following code to convert it into an array:
def mediasArray = Eval.me(params.medias)
println mediasArray.size()
The downside of this is that Eval presents the possibility of unwanted code execution if the params.medias is provided by an end user, or can be maliciously modified outside of your compiled code.
A good snippet on the "evil (or lack thereof) of eval" is here if you're interested (not mine):
https://javascriptweblog.wordpress.com/2010/04/19/how-evil-is-eval/
I think 7 is result of length of the string : "[37,40]"
Seems your media variable is an array not a collection
Try : params.medias.length
Thanks to everyone. I've found my mistake
First of all, I sent an array from client and my params.medias returned null,so I converted it to string but it is a wrong way.
Finally, I sent and array from client as array and in the grails, I got a params by
params."medias[]"
List medias = params.list('medias')
Documentation: http://grails.github.io/grails-doc/latest/guide/single.html#typeConverters
I've got a Server and want to add tabs to the menu I've put in the command
local force = actions:AddOption( "Kick Player from the game" )
force:SetIcon( "icon16/delete.png" )
function force:DoClick()
RunConsoleCommand("ulx kick","reason", ply:EntIndex())
end
But i Get This Error sign
RunConsoleCommand: Command has invalid characters! (ulx kick (' '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.
PLEASE Can anyone help me
Your command is ulx
Your arguments are: kick, reason and ply:EntIndex()
So instead of
RunConsoleCommand("ulx kick","reason", ply:EntIndex())
the line should be:
RunConsoleCommand("ulx", "kick", ply:EntIndex(), "reason")
'cause the first argument of the function should only contain the command you want to call.
Source: your Error Message ("The first parameter of this function should contain only the command, [...]") and
http://wiki.garrysmod.com/page/Global/RunConsoleCommand
Hitting my wall here...
I've got the following data where a Primary Employee may have multiple dependents. I need to create a function that will match the Employee's SSN (ab:SSN) against the Dependent_SSN and determine if one of them is a 'Spouse'. If so, then we'll return the Dependent_SSN of the 'Spouse'.
If not, we'll move on and return the next non-'Spouse' Dependent_SSN.
I'm trying to create a function as I think I'll need this more than once. The code snippet resides inside of an existing template that is doing other looping functionality.
I've tried this but Oxygen returns an error:
<xsl:function name="ab:PQB">
<xsl:param name="EE_SSN">
</xsl:param>
<xsl:for-each select="/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]ab:dependents/ab:Dependent_SSN">
</xsl:for-each>
The Error returned is :
"Engine name: Saxon-PE 9.3.0.5
Severity: fatal
Description: Unexpected token name "wd:dependents" beyond end of expression"
I know I need to test the higher level SSN against looping through the dependents, but like I said "I'm against my wall" :)
Data is here:
<ab:Report_Entry>
<ab:SSN>888881006</ab:SSN>
<ab:Last_Name>Smith</ab:Last_Name>
<ab:First_Name>Kimberly</ab:First_Name>
<ab:dependents>
<ab:Dependent_SSN>888881009</ab:Dependent_SSN>
<ab:Relation ab:Descriptor="Spouse">
</ab:Relation>
</ab:dependents>
<ab:dependents>
<ab:Dependent_SSN>888881004</ab:Dependent_SSN>
<ab:Relation ab:Descriptor="Child">
</ab:Relation>
</ab:dependents>
<ab:dependents>
<ab:Dependent_SSN>888881003</ab:Dependent_SSN>
<ab:Relation ab:Descriptor="Child">
<ab:ID ab:type="Related_Person_Relationship_ID">Child</ab:ID>
</ab:Relation>
</ab:dependents>
<ab:dependents>
<ab:Dependent_SSN>888881001</ab:Dependent_SSN>
<ab:Dependent_ID>1032D-4</ab:Dependent_ID>
<ab:Relation ab:Descriptor="Child">
<ab:ID ab:type="Related_Person_Relationship_ID">Child</ab:ID>
</ab:Relation>
</ab:dependents>
</ab:Report_Entry>
Thank you to any advice!
You might want to define the type of the input parameter and the type of the function result and then you should write a function body returning a value of that type. Currently your description sounds rather procedural, that is not going to work with XSLT/XPath.
As for the error, I think in the path /ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]ab:dependents/ab:Dependent_SSN you need one more slash /ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:dependents/ab:Dependent_SSN to have a syntactically correct path. That should avoid the syntax error you get but is not likely to return the result you want.
The code below was created by me with the help of many SO veterans:
The code takes an entered math expression and splits it into operators and operands for later use. I have created two functions, the parsing function that splits, and the error function. I am having problems with the error function because it won't display my error messages and I feel the function is being ignored when the code runs. An error should print if an expression such as this is entered: 3//3+4,etc. where there are two operators together, or there are more than two operators in the expression overall, but the error messages dont print. My code is below:
def errors():
numExtrapolation,opExtrapolation=parse(expression)
if (len(numExtrapolation) == 3) and (len(opExtrapolation) !=2):
print("Bad1")
if (len(numExtrapolation) ==2) and (len(opExtrapolation) !=1):
print("Bad2")
def parse(expression):
operators= set("*/+-")
opExtrapolate= []
numExtrapolate= []
buff=[]
for i in expression:
if i in operators:
numExtrapolate.append(''.join(buff))
buff= []
opExtrapolate.append(i)
opExtrapolation=opExtrapolate
else:
buff.append(i)
numExtrapolate.append(''.join(buff))
numExtrapolation=numExtrapolate
#just some debugging print statements
print(numExtrapolation)
print("z:", len(opExtrapolation))
return numExtrapolation, opExtrapolation
errors()
Any help would be appreciated. Please don't introduce new code that is any more advanced than the code already here. I am looking for a solution to my problem... not large new code segments. Thanks.
The errors() function is called after parse() returns because it appears inside the body of parse(). Hopefully that is a typo.
For this particular input, numExtrapolate is appended with an empty buffer because there is no operand between / and /. That makes its length 4 and your check for Bad1 fails. So put a check like this
if buff:
numExtrapolate.append(''.join(buff))