我正在学习静态类型和动态类型,我在很大程度上理解它,但是这个案例仍然没有找到我.
如果课程B延伸A,我有:
A x = new B();
Run Code Online (Sandbox Code Playgroud)
以下是允许的吗?:
B y = x;
Run Code Online (Sandbox Code Playgroud)
或者是否需要明确的演员?:
B y = (B) x;
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在尝试以最基本的方式使用自定义用户模型,扩展AbstractUser如Extending Django的默认用户所述.但是,我不确定如何正确地与南方合作.我在进行初始模式迁移时遇到问题以下是发生的事情:
我的扩展用户类Player在我的课程tournaments中启用了settings.INSTALLED_APPS.
要执行初始化syncdb,tournaments必须启用该应用程序.否则我收到此错误:
$ ./manage.py syncdb
CommandError: One or more models did not validate:
auth.user: Model has been swapped out for 'tournaments.Player' which has not been installed or is abstract.
admin.logentry: 'user' has a relation with model tournaments.Player, which has either not been installed or is abstract.
Run Code Online (Sandbox Code Playgroud)所以,我启用了tournaments具有我的Player(自定义用户)模型的应用程序.但是,在最初的迁移时:
$ ./manage.py schemamigration tournaments --initial
...
$ ./manage.py migrate tournaments
Running migrations for …Run Code Online (Sandbox Code Playgroud)几个月前我升级了Git,从那时起,我一直在尝试接受以下弃用通知git add --update:
警告:行为"git的添加--update(或-u)"从树的子目录没有路径参数将在Git的2.0改变,不应再使用.要为整个树添加内容,请运行:
git add --update:/(或git add -u:/)
要将命令限制到当前目录,请运行:
git add --update.(或git add -u.)
使用当前的Git版本,该命令仅限于当前目录.
警告本身非常有意义,它为我节省了一些重置.我已经习惯了输入.或者:/,但仍然发现后者非常奇怪,因为它与我遇到的任何其他命令行语法不同.这.是非常令牌:它只是意味着"当前目录",就像在find .,但:/......从未见过,除非在此上下文中.这是什么意思?
我一直认为它是一个表情符号,当然不是这样吗?
我正在尝试编写一个函数,使得第一个参数是boolean,并且取决于这个参数是true还是false,第二个参数是一个接受 astring或的函数string[]。
这是我的尝试:
type P<B extends boolean> = B extends true ? string[] : string
function callback<B extends boolean>(b: B, t: (f: P<B>) => void) {
const file = 'file'
if (b) {
t([file]) // <-- Error: Argument of type 'string' is not assignable to parameter of type 'P<B>'.
} else {
t(file) // <-- Error: Argument of type 'string[]' is not assignable to parameter of type 'P<B>'.
}
} …Run Code Online (Sandbox Code Playgroud) 我已经将Fabric设置git fetch在远程计算机上.它工作正常,但是stdout为Git打印的每个百分比进度打印了一个新行:
[host] out: remote: Compressing objects: 1% (3/252)
[host] out: remote: Compressing objects: 2% (6/252)
[host] out: remote: Compressing objects: 3% (8/252)
[host] out: remote: Compressing objects: 4% (11/252)
[host] out: remote: Compressing objects: 5% (13/252)
[host] out: remote: Compressing objects: 6% (16/252)
[host] out: remote: Compressing objects: 7% (18/252)
[host] out: remote: Compressing objects: 8% (21/252)
[host] out: remote: Compressing objects: 9% (23/252)
...
[host] out: Resolving deltas: 0% (0/72)
[host] out: Resolving deltas: …Run Code Online (Sandbox Code Playgroud) 我正在运行一个冲突的冲击:
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: Better `SelectMotifsView.js`
Using index info to reconstruct a base tree...
M browser/AddLinkView.js
M browser/SelectMotifsView.js
M browser/index.html
Falling back to patching base and 3-way merge...
Auto-merging browser/index.html
CONFLICT (content): Merge conflict in browser/index.html
Failed to merge in the changes.
Patch failed at 0001 Better `SelectMotifsView.js`
The copy of the patch that failed is found in:
/Users/dmitry/dev/links/.git/rebase-apply/patch
When you have resolved this problem, run "git …Run Code Online (Sandbox Code Playgroud) 在该文件的Document接口描述接口如:
Document接口表示整个HTML或XML文档.
javax.xml.parsers.DocumentBuilder构建XML Document.但是,我无法找到构建DocumentHTML的方法Document!
我想要一个HTML,Document因为我正在尝试构建一个文档,然后将其传递给期望HTML的库Document.此库Document#getElementsByTagName(String tagname)以非区分大小写的方式使用,这适用于HTML,但不适用于XML.
我环顾四周,找不到任何东西.像如何将网页的Html源转换为java中的org.w3c.dom.Document?实际上没有答案.
我有一个JacksonMappingException我用来为用户产生错误:
public Map<String, List<Map<String, String>>> getErrors(JsonMappingException e) {
Map<String, List<Map<String, String>>> errors = new HashMap<>();
List<Map<String, String>> badFields = new ArrayList<>();
for (Reference ref: e.getPath()) {
Map<String, String> badField = new HashMap<>();
badField.put("field", ref.getFieldName());
badField.put("description", e.getOriginalMessage());
badFields.add(badField);
}
errors.put("errors", badFields);
return errors;
}
Run Code Online (Sandbox Code Playgroud)
除了某些类型的错误之外哪个是很好的,某些技术细节泄露给用户,例如类结构等,这是完全不合适的:
{
"errors" : [ {
"field" : "id",
"description" : "Unrecognized field \"id\" (class motif.web.resource.UserResource$PutUser), not marked as ignorable"
} ]
}
Run Code Online (Sandbox Code Playgroud)
如果没有所有的技术笨蛋,我怎么能description更像Unrecognized field \"id\"?
我有一个PostgreSQL 9.2和一个小型数据库,只有一些我正在研究的网站的种子数据.
以下查询似乎永远运行:
ALTER TABLE diagnose_bodypart ADD description text NOT NULL;
Run Code Online (Sandbox Code Playgroud)
diagnose_bodypart是一个少于10行的表.我让查询运行超过一分钟没有结果.可能是什么问题呢?有没有调试这个的建议?
我正在尝试这场比赛
'/links/51f5382e7b7993e335000015'.match(/^\/links\/([0-9a-f]{24})$/g)
Run Code Online (Sandbox Code Playgroud)
得到了:
['/links/51f5382e7b7993e335000015']
Run Code Online (Sandbox Code Playgroud)
虽然我在期待:
['/links/51f5382e7b7993e335000015', '51f5382e7b7993e335000015']
Run Code Online (Sandbox Code Playgroud)
在我删除全局标志之前我没有运气,我认为这不会影响我的结果!
删除全局标志后,
'/links/51f5382e7b7993e335000015'.match(/^\/links\/([0-9a-f]{24})$/)
Run Code Online (Sandbox Code Playgroud)
制作:
[ '/links/51f5382e7b7993e335000015',
'51f5382e7b7993e335000015',
index: 0,
input: '/links/51f5382e7b7993e335000015' ]
Run Code Online (Sandbox Code Playgroud)
这很酷,但阅读我无法弄清楚的文档:
()匹配index和input属性的情况下获得我的预期结果在JavaScript Regex和Submatches上,最佳答案是:
如果设置了global修饰符,使用String的match()函数将不会返回捕获的组,如您所知.
然而,
> 'fofoofooofoooo'.match(/f(o+)/g)
["fo", "foo", "fooo", "foooo"]
Run Code Online (Sandbox Code Playgroud)
似乎产生被捕群体就好了.
谢谢.
java ×3
git ×2
casting ×1
django ×1
django-south ×1
dom ×1
fabric ×1
html ×1
jackson ×1
javascript ×1
postgresql ×1
regex ×1
typescript ×1
xml ×1