我正在看以下苹果示例源代码:
/*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFormatter == nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
}
Run Code Online (Sandbox Code Playgroud)
试图找出:
为什么要使用static关键字?
如果在每次调用方法时将其设置为nil,这相当于缓存变量.
代码来自Tableview Suite演示中的示例4
尝试理解传递给setValue时'onlySelf'参数的作用.
this.form.get('name').setValue('', { onlySelf: true })
Run Code Online (Sandbox Code Playgroud)
文档说:"如果onlySelf为true,则此更改只会影响此FormControl的验证,而不会影响其父组件.默认为false."
但是我很难理解这一点.使用Angulars的模型驱动形式仍然相当新.
我有一个应用程序,我们称之为derpshow,它由两个存储库组成,一个用于前端,一个用于后端.
我想使用Heroku部署这些,最好是在同一个域上.我还想将两个部分的管道分开使用,每个管道都有一个分段和生产环境.
是否可以让两个应用程序在同一个域上运行,以便前端可以调用后端/api/*?另一种选择是服务于后端api.derpshow.com和前端,app.derpshow.com但这在一定程度上使安全性变得复杂.
这方面的最佳做法是什么?前端只是静态文件,所以它甚至可以从S3或类似的服务,但我仍然需要登台和生产环境和自动测试等等.
任何意见是极大的赞赏!
是否有可能创建一个泛型函数,将Foo或Bar作为参数,并返回一个在模式匹配中使用该参数的函数?
例如,如果我有
isFoo :: SomeData -> Bool
isFoo (Foo _) = True
isFoo _ = False
isBar :: SomeData -> Bool
isBar (Bar _) = True
isBar _ = False
Run Code Online (Sandbox Code Playgroud)
有没有办法创建一个通用函数,如
checkType :: SomeClass -> SomeData -> Bool
checkType (SomeClass _) = True
checkType _ = False
Run Code Online (Sandbox Code Playgroud)
我意识到情况看起来有点奇怪,实际的用例有点复杂,但问题是相同的.
我正在尝试重构的实际代码如下
isString :: [LispVal] -> ThrowsError LispVal
isString [(String _)] = return $ Bool True
isString ((String _):xs) = isString xs >>= unpackBool >>= return . Bool
isString _ = return $ …Run Code Online (Sandbox Code Playgroud) 是否可以在保持Helm缓冲区打开的同时从Helm的结果列表中访问缓冲区?或者是否有其他方法可以达到同样的效果?
我经常需要执行涉及搜索某些文件的任务,并访问它们中的每一个,但现在它的工作方式我每次访问缓冲区时都必须重做搜索.
编辑:FWIW,如果使用spacemacs,SPC r l则绑定helm-resume
我在使用OnPush变更检测策略测试组件时遇到问题。
测试是这样的
it('should show edit button for featured only for owners', () => {
let selector = '.edit-button';
component.isOwner = false;
fixture.detectChanges();
expect(fixture.debugElement.query(By.css(selector))).toBeFalsy();
component.isOwner = true;
fixture.detectChanges();
expect(fixture.debugElement.query(By.css(selector))).toBeTruthy();
});
Run Code Online (Sandbox Code Playgroud)
如果我使用Default策略,它会按预期工作,但OnPush更改isOwner为 时不会通过调用detectChanges. 我错过了什么吗?
我想知道为什么auto_increment用拼写"拼写",因为primary key not null这不是?
是因为auto_increment是一些旧的句法遗留物还是这样的?
我需要一个IClonable定义clone()成员的接口,该接口返回实现该成员的类的实例。
如果可能的话,如何指示返回类型与clone()调用的类相同?
interface IClonable {
clone(): ???
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用下面的泛型来做到这一点,但这似乎太冗长了
interface IClonable<T> {
clone(): T
}
Run Code Online (Sandbox Code Playgroud) 似乎emacs中的Zen Coding 的GitHub repo没有被主动维护(最后一次提交是一年前),并且缺少一些功能,例如html:5"标签".
我找不到emacs模式的任何其他来源.有谁知道是否有更新版本?
Zen Coding谷歌小组链接到EmacsWiki,后者又链接到上面提到的GitHub仓库.
我正在根据LLVM 站点上的教程编写一个玩具编译器,但我现在在代码生成过程中遇到错误(我相信)。程序因方法中的段错误而崩溃llvm::TypeFinder::incorporateValue,我无法弄清楚发生了什么。
这是崩溃发生时 LLDB 的输出。
* thread #1: tid = 0x2dfc, 0x0000000000a2a2d0 wtf`llvm::TypeFinder::incorporateValue(llvm::Value const*) + 16, stop reason = invalid address
frame #0: 0x0000000000a2a2d0 wtf`llvm::TypeFinder::incorporateValue(llvm::Value const*) + 16
wtf`llvm::TypeFinder::incorporateValue(llvm::Value const*) + 16:
-> 0xa2a2d0: movb 8(%r14), %al
0xa2a2d4: cmpb $17, %al
0xa2a2d6: jne 0xa2a332 ; llvm::TypeFinder::incorporateValue(llvm::Value const*) + 114
0xa2a2d8: movq %r14, (%rsp)
Run Code Online (Sandbox Code Playgroud)
当我尝试转储函数的 IR 代码、在verifyFunction其上运行或FunctionPassManager尝试优化它时,就会发生这种情况。当 FPM 运行时,它失败并显示
Stack dump:
0. Running pass 'Module Verifier' on function '@foo'
[1] 11485 segmentation fault …Run Code Online (Sandbox Code Playgroud) angular ×2
emacs ×2
angular-cli ×1
c++ ×1
caching ×1
deployment ×1
emacs-helm ×1
emmet ×1
forms ×1
haskell ×1
heroku ×1
llvm ×1
objective-c ×1
setvalue ×1
sql ×1
static ×1
testing ×1
typescript ×1