no ReserveMatch found for seemingly correct path converter - html

I have the following anchor in my HTML template
{{col.1}}
and the following line within urls.py
path('experiments/<str:table_name>/<uuid:foreign_key>/<str:foreign_attribute>/str:foreign_table_name>/', ExpViews.show_foreign_key, name='experiments_tables_foreign_key')
show_foreign_key exists in views.py and is a function that I'd like to use for a view. It accepts 4 parameters.
I have the correct namespace done aswell. I get the following error:
Reverse for 'experiments_tables_foreign_key' with arguments '('test_2', UUID('7a4c1cb5-6a7c-4fd3-8eea-8e9bef41802d'), 'ID', 'test_1')' not found

Here is a typo on the url.
path('experiments/<str:table_name>/<uuid:foreign_key>/<str:foreign_attribute>/str:foreign_table_name>/', ExpViews.show_foreign_key, name='experiments_tables_foreign_key')
^^^ # lacks a <
So, change this to:
path('experiments/<str:table_name>/<uuid:foreign_key>/<str:foreign_attribute>/<str:foreign_table_name>/', ExpViews.show_foreign_key, name='experiments_tables_foreign_key')

Related

How to add own namespace in Yii2

I have changed Yii2 advanced directory structure like following(it's working well):
app-folder
-admin
-assets
-.htaccess
-index.php
-assets
-protected
-backend
...
-common
...
-frontend
...
...
-uploads
...
Now, I am trying to add a namespace as namespace protected\base; into protected/base/AnyFile.php file and use it in a controller as use protected\base\AnyFile;. But, my project is giving error:
syntax error, unexpected 'protected' (T_PROTECTED), expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) or \\ (T_NS_SEPARATOR)
I saw this issue on the website: Yii2 Custom / Shorter Namespace. However, It didn't work on my condition.
First of all protected is reserved keyword (token T_PROTECTED). You can keep direcory name but you need to change namespace root alias.
In your alias config file protected/common/bootstrap.php write:
Yii::setAlias('app', dirname(dirname(__DIR__))); // set path to protected directory
And then use namespace app\base; and use app\base\AnyFile;.
See Class Autoloading section of the guide https://www.yiiframework.com/doc/guide/2.0/en/concept-autoloading

Readtimearray function in Julia TimeSeries package

I would like to read a csv file of the following form with readtimearray:
"","ES1 Index","VG1 Index","TY1 Comdty","RX1 Comdty","GC1 Comdty"
"1999-01-04",1391.12,3034.53,66.515625,86.2,441.39
"1999-01-05",1404.86,3072.41,66.3125,86.17,440.63
"1999-01-06",1435.12,3156.59,66.4375,86.32,441.7
"1999-01-07",1432.32,3106.08,66.25,86.22,447.67
"1999-01-08",1443.81,3093.46,65.859375,86.36,447.06
"1999-01-11",1427.84,3005.07,65.71875,85.74,449.5
"1999-01-12",1402.33,2968.04,65.953125,86.31,442.92
"1999-01-13",1388.88,2871.23,66.21875,86.52,439.4
"1999-01-14",1366.46,2836.72,66.546875,86.73,440.01
However, here's what I get when I evaluate readtimearray("myfile.csv")
ERROR: `convert` has no method matching convert(::Type{UTF8String}, ::Float64)
in push! at array.jl:460
in readtimearray at /home/juser/.julia/v0.3/TimeSeries/src/readwrite.jl:25
What is it that I am not seeing?
That looks like a bug in readtimearray.
Empty lines are removed but, to identify them,
the code only looks at the first column.
Since the header has an empty string in the first column, it is removed...
Changing the header of your file to
"date","ES1 Index","VG1 Index","TY1 Comdty","RX1 Comdty","GC1 Comdty"
addresses the problem.
You're using convert, which is meant for use with julia types (see doc for more info).
You parse the string using Date:
d=Date("1999-04-01","yyyy-mm-dd")
#...
array_of_dates = map(x->Date(x,"yyyy-mm-dd"),array_of_strings)

How to create new phpDoc annotations in PhpStorm 8

I searched via Google but couldn't find an answer to this. PhpStorm has many built in annotations for code completion but many are missing as well. I am pretty sure there is a way to create new annotations but couldn't find it anywhere within the settings. Or maybe it is an XML file somewhere. NetBeans has support for this feature.
In other words, how can I create new phpDoc annotations for completion in phpStorm 8 like #usesDefaultClass for phpUnit.
I have found this answer here: http://blog.jetbrains.com/webide/2013/02/phpdoc_and_code_templates/
Hope this will help you
PhpDoc Templates
PhpDoc templates are located under Settings | File Templates | Includes. Currently there are three templates named PHP Class Doc Comment, PHP Function Doc Comment and PHP Field Doc Comment. Any of these can be included into other templates via the #parse directive. For example, we can modify the original class template (Templates | PHP Class) to also include the class PHP Doc when a class is generated:
<?php
#parse("PHP File Header.php")
...
#parse("PHP Class Doc Comment")
class ${NAME} {
}
The same templates are used when:
A new PHP Doc comment is generated after we type /** and press Enter before a class, function (method) or class field.
We invoke Code | Generate | PHPDoc blocks or use the Add PHP Doc quick-fix for the inspection Missing PHP Doc.
Below is a list of variables that can be used in PHP Doc templates:
${NAME}
The element (class, function, field) name.
${NAMESPACE}
The name of the namespace the element belongs to without any leading or trailing backslashes, for example Core\Widgets. The variable value is empty if the element doesn’t belong to any namespace. A check like `#if (${NAMESPACE})` ... is possible.
${CLASS_NAME}
Contains a class name for class methods and fields. Will be empty for functions that do not belong to any class.
${TYPE_HINT}
For functions (methods), contains the return type of the function (method). For fields, evaluates to the field’s type if it can be found, for example, from a default value. Will be empty if the type cannot be retrieved from the code.
${STATIC}
Takes the value of “static” if the function or field is static, otherwise, an empty string. We can use this variable with the condition `#if (${STATIC})` ... to generate something specific for static class members.
${CARET}
Marks the position where the editor caret should be placed after the comment is added. Note: Works only if the comment is added after we type “/**” and hit Enter. Should be placed inside the comment, not on the first line /** or on the last line */. In all other cases the caret marker will be ignored.
${PARAM_DOC}
A generated PHP Doc fragment containing function (method) parameters in the form: “* #param type $name“. For example, if the function signature is foo ($x, $y), it will evaluate to:
#param $x
#param $y
${THROWS_DOC}
A generated PHP Doc fragment containing exceptions thrown from function (method) body in the form * #throws ExceptionName. One exception per line/#throws tag. For example:
#throws DOMException
#throws HttpException
Code Templates for Overridden/Implemented Methods
The following templates can be found under Settings | File Templates | Code: PHP Implemented Method Body and PHP Overridden Method Body. There are few parameters, considering that in most cases we will need either a simple call to a parent method or just our own comment (some version of TODO perhaps):
${NAME}
Method name.
${PARAM_LIST}
A comma-separated list of parameters. For example, if the original method signature is foo(Bar $bar, $y), the variable will take the value “$bar, $x” which can be used in a call to the parent method as `${NAME}(${PARAM_LIST})`”
${RETURN}
Either “return” or an empty string.
A Dollar Sign Variable: ${DS}
Solves the problem of putting a dollar sign $ anywhere within the template. Actually, the dollar sign is used both in PHP and in Velocity template engine taking care of code generation behind the scenes. So whenever we need a dollar sign, just use ${DS} as its equivalent. For example, if we want $this->foo() to be generated, we need to put ${DS}this->foo(). This may not look perfect but guarantees that there will be no conflicts.

using variable in argument - JSON target

I would like to use a variable (string) as part of my JSON target. Instead of simply coding for each section, like this:
$.each(data.portfolioitems.section1, function (k,v){...}
$.each(data.portfolioitems.section2, function (k,v){...}
$.each(data.portfolioitems.section3, function (k,v){...}
I would like to have a variable "varsection" that indicates which section should be called, like this:
$.each(data.portfolioitems.varsection, function (k,v){...}
As this exists, it seems that I am attempting to target the section "varsection", which of course doesn't exist.
I have found other topics where it was discussed how to use a variable as part of a JSON target, but it seems that none of the solutions I found are acceptable for this scenario where the target is an argument.
data.portfolioitems[varsection]

How to specify json format for Sinatra route with named parameter?

How do I add ".json" to a Sinatra route which includes a named parameter such as
get '/view/:name'
?
I thought
get '/view/:name.json'
might work but I get an "Unable to access path /view/name.json" exception.
This code works perfectly:
get '/hello/:name.json' do
"Hello #{params[:name]}"
end
=> /hello/samy.json outputs "Hello samy"
Please show the complete stack trace of your exception.
Also,
https://github.com/sinatra/sinatra/issues/490