小编Dav*_*ots的帖子

如何使用Firestore填充引用字段

您知道如何使用Firestore在文档上填充参考字段吗?

公司的FireStore

android kotlin firebase google-cloud-firestore

2
推荐指数
1
解决办法
1378
查看次数

如何使用 IFileInfo 删除 ASP.NET Core 中的文件

我读过它更好地IFileProvider用于管理 ASP.NET Core Microsoft 文档中的文件。但是,如果我使用GetFileInfo()方法,我将可以访问IFileInfo它,它只提供了一些读取文件的方法!

如何删除文件?

c# .net-core asp.net-core

2
推荐指数
1
解决办法
5421
查看次数

使用循环或列表理解创建多个 pandas 数据框

我有一个 Python 数据框,我想按行细分,但分成 32 个不同的切片(想象一个大数据集按行切成 32 个较小的数据集)。我可以通过这种方式手动划分数据框:

df_a = df[df['Type']=='BROKEN PELVIS']

df_b = df[df['Type']=='ABDOMINAL STRAIN']
Run Code Online (Sandbox Code Playgroud)

我假设有人可能想分享一个更加Pythonic 的表达式。我正在寻找类似的东西:

for i in new1:
    df_%s= df[df['#RIC']=='%s'] , %i
Run Code Online (Sandbox Code Playgroud)

希望这是有道理的。

python loops dataframe pandas

1
推荐指数
1
解决办法
2421
查看次数

Mockito 覆盖静态类多次调用的返回值

为了获取对象,对静态类进行了两次调用。就像下面这样:

MyObject myobj1 = Mock(MyObject.class)

PowerMock(static1.class)

when(static1.method(param1,parame2,param3).thenreturn(myobj1);
myobj1.setcontent(inputstream1);

MyObject myobj2 = Mock(MyObject.class)

when(static1.method(param1,parame2,param3).thenreturn(myobj2);
myobj2.setcontent(inputstream2);
Run Code Online (Sandbox Code Playgroud)

通过上面的调用,我们注意到方法调用的响应中设置的内容被 的内容覆盖inputstream2

我们如何使用 Mockito 创建多个返回对象?

mockito powermock

1
推荐指数
1
解决办法
2672
查看次数

数组值是否可选?

你能解释一下原因吗:

  • 当我使用array.first访问数组值时,它是可选的
  • 当我从索引值访问它不是吗?

例:

var players = ["Alice", "Bob", "Cindy", "Dan"]
let firstPlayer = players.first
print(firstPlayer) // Optional("Alice")
let firstIndex = players[0]
print(firstIndex) // Alice
Run Code Online (Sandbox Code Playgroud)

swift

1
推荐指数
2
解决办法
173
查看次数

通过 HttpInterceptor Angular 5 添加标头

我想添加标头以从 Angular 5 Web 应用程序发布请求。我创建了以下 Injectable 类,在我的应用程序模块中注册:

@Injectable()
    export class headerInterceptor implements HttpInterceptor {
      intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {    
        // Clone the request to add the new header         
        const authReq = req.clone({
          headers: new HttpHeaders({
            'Content-Type':  'application/json; charset=utf-8',        
          })
        });        
        return next.handle(authReq);


      }
    }
Run Code Online (Sandbox Code Playgroud)

我有网络通信服务,并且我添加了如下的正文参数。

@Injectable()
export class NetworkService {

  Root:string = 'some valid url';
  results:Object[];
  loading:boolean;

  // inject Http client to our client service.
  constructor(private httpClient: HttpClient ) {

  }



  login(loginParams : URLSearchParams){    
    let baseURL = `${this.Root}/login`;                    
    this.httpClient.post(baseURL, …
Run Code Online (Sandbox Code Playgroud)

angular5

1
推荐指数
1
解决办法
1643
查看次数

router.navigateByUrl不发送值Angular

我正在尝试在组件Angular之间发送1值...但是当我到达组件时,我什么也没收到。

组件1:

onCellClicked(event) {
    if (event.colDef.field === 'dni') {
      console.log('dni en mi componente : ', event.value);
      this.router.navigateByUrl('probarborrar/', event.value);
    }
  }
Run Code Online (Sandbox Code Playgroud)

首先检查Cell是否为dni,然后显示"console.log(event.value)"是真的,我可以看到我的dni。最后,我讲第二部分。

路由。

     {
        path: 'probarborrar/:idUser',
        component: ProbandoBorrarComponent,
        data: {
          breadcrumb: 'probar'
        }
      }
Run Code Online (Sandbox Code Playgroud)

组件2。

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-probando-borrar',
  templateUrl: './probando-borrar.component.html',
  styleUrls: ['./probando-borrar.component.scss']
})
export class ProbandoBorrarComponent implements OnInit {
  public dni;

  constructor(private route: ActivatedRoute) {}

  ngOnInit() {
    this.dni= this.route.snapshot.paramMap.get('idUser');
    console.log('en probando es :', this.dni); -->nothing
  } …
Run Code Online (Sandbox Code Playgroud)

angular

1
推荐指数
1
解决办法
1887
查看次数

如何在模型本身的 Laravel 中将 unix 时间戳转换为 Carbon 实例?

我已经拥有的:

在模型中有这个:

protected $dates = [ 'applied_date' ];
Run Code Online (Sandbox Code Playgroud)

在数据库中applied_date就是以这种格式存储的2018-05-11 13:31:59

因此,我可以将其格式化如下:

$applied_date->format('m/d/Y')
Run Code Online (Sandbox Code Playgroud)

我想要的是:

在数据库applied_date中已经以这种格式存储1530205690(unix 时间戳)。

我想在视图中格式化,$applied_date->format('m/d/Y')我该如何实现?

注意:我们可以 Carbon::createFromTimestamp($applied_date)->format('m/d/Y');

laravel

1
推荐指数
1
解决办法
4985
查看次数

在 Angular 6 中实现子路由时出错

在为我的项目实施子路由时,我遇到了以下错误。我在 GitHub 和其他网站上没有找到任何帮助。

错误错误:未捕获(承诺):SecurityError:无法在“历史”上执行“pushState”:无法在具有“ http://%28routes%29/ ”的文档中创建具有 URL“ http://%28routes%29/ ”的历史状态对象http: //localhost:4200 ' 和 URL ' http://localhost:4200/ '。错误:无法在“历史”上执行“pushState”:无法在来源为“ http://localhost:4200 ”和 URL的文档中创建URL 为“ http://%28routes%29/ ”的历史状态对象http://localhost:4200/ '.

angular angular6

0
推荐指数
1
解决办法
1490
查看次数

在Angular 5 TypeScript中触发keyup事件

我们已经使用JavaScript / jQuery以编程方式轻松触发了按键/按下/按下事件。

$(function() {
    $('item').keydown();
    $('item').keypress();
    $('item').keyup();
    $('item').blur();
});
Run Code Online (Sandbox Code Playgroud)

但是,使用Angular 5和TypeScript,我们该怎么做呢?

//I am setting value programmatically -> working
document.getElementById('custom_Credit').setAttribute('value', coinsToBuy);    
//setting focus -> working
document.getElementById('custom_Credit').focus();
//but there are no way to generate or trigger keypress/up events.
document.getElementById('custom_Credit')..........;
Run Code Online (Sandbox Code Playgroud)

typescript angular angular5

0
推荐指数
1
解决办法
8144
查看次数