小编Pat*_* M.的帖子

如何从 Google Colab 访问 Cloud SQL

我有一个带有公共 IP 的 Google Cloud SQL 实例,只能通过列入白名单的 IP 并通过 SSL 连接访问。

我想知道如何使用 Python 从 Google Colab 连接到这个数据库。

如果我尝试像任何外部应用程序一样连接,则连接会被拒绝,因为“客户端”的 ip 未列入白名单(我无法将其列入白名单,因为我不这样做,而且很可能是不稳定的)

是否有快捷方式,例如使用 Google App Engine 使用其实例和 Google 客户端连接到数据库?

谢谢

google-cloud-sql google-colaboratory

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

如何在组件之间使用 Angular 7 cdkDropList?

我在屏幕左侧的 mat-list 组件中有一个项目(学生)列表(常规列表)。我的屏幕右侧还有一个教室组件列表。在每个教室组件中,都有一个学生列表。

我希望能够使用角度材料的新拖放 API将学生从常规列表拖动到任何教室组件中包含的学生列表之一

伪代码如下所示:

<mat-list #studentsList="cdkDropList" cdkDropList [cdkDropListData]="students">
  <mat-list-item cdkDrag *ngFor="let student of studentes">
    {{student.name}}
  </mat-list-item>
</mat-list>

<div class="right-panel>
  <app-class-room *ngFor="let cr of classRooms" [classRoom]="cr"></app-class-room>
</div>
Run Code Online (Sandbox Code Playgroud)

显然,我无法使用[cdkDropListConnectedTo]常规列表上的输入,因为我无权访问课堂组件内的学生列表。我应该如何进行?

drag-and-drop angular-material angular angular7

6
推荐指数
2
解决办法
2万
查看次数

Firebase Domain Whitelist not working for sendEmailVerification

In my onboarding work-flow, I'm trying to verify a newly created user's email with this code (as per example in the docs)

verifyEmail(): firebase.Promise<any> {

    const actionCodeSettings: firebase.auth.ActionCodeSettings = {
      url: 'http://localhost:4200/main/profile',
      handleCodeInApp: false
    };

    return this.afAuth.auth.currentUser.sendEmailVerification(actionCodeSettings);
  }
Run Code Online (Sandbox Code Playgroud)

Unfortunately, the result of the promise is this error:

{code: "auth/unauthorized-continue-uri", message: "Domain not whitelisted by project"}
Run Code Online (Sandbox Code Playgroud)

However, in Firebase console, 'localhost' is whitelisted (by default). If I change localhost by my current IP, which is also whitelisted, it doesn't work either. …

whitelist firebase firebase-authentication angular

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

单击 MatFormFieldControl 中的按钮触发 Angular 4 中表单上的提交操作

我开发了一个自定义组件(app-mat-avatar)用作头像选择(见图)。它由一个带有图片和 2 个按钮的大 div 组成。一个是编辑,另一个是擦除。我按照创建自定义表单字段控件中的Angular 指南构建了它 在此处输入图片说明

这是我使用它的形式:

<form name="detailsForm" [formGroup]="detailsForm" (submit)="submitDetails($event)">
    <app-mat-avatar [size]="150" formControlName="photoURL"></app-mat-avatar>
    <input matInput type="email" placeholder="Email" formControlNamesss="email" disabled value="{{detailsForm.get('email').value}}">
.....

    <div flex layout="row" layout-align="end center" class="fullWidth pad-right-sm">
        <button mat-button mat-raised (click)="resetDetails()" class="push-right-xs" [disabled]="busy">Reset</button>
        <button type="submit" mat-button mat-raised-button color="primary" [disabled]="detailsForm.invalid || busy">Save</button>
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

这是支持表单所在页面组件的代码:

@Component({
  selector: 'app-my-info',
  templateUrl: './my-info.component.html',
  styleUrls: ['./my-info.component.sass']
})
export class MyInfoComponent implements OnInit, OnDestroy {

  detailsForm = new FormGroup({
    uid: new FormControl(''),
    photoURL: new FormControl(''),
    firstName: new FormControl('', [Validators.required, Validators.minLength(2)]), …
Run Code Online (Sandbox Code Playgroud)

angular angular4-forms

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

我应该如何在Angular 4中的组件的HTML模板中使用Service中的BehaviorSubject类?

我有一个用于身份验证的服务,它暴露了BehaviorSubject类的用户.我想在组件中使用该服务来允许登录/注销并显示用户属性....那里没什么新东西.

我知道我可以订阅组件中的用户对象并将结果分配给本地对象,而本地对象又将在视图中使用.但我有兴趣知道如何使用它而无需订阅打字稿,但直接在html中,感谢异步管道,我想.

这些是我将使用的伪类:

Auth服务

export class User {
    id: string;
    username: string;
    gender: string;

    constructor( some params...) {
        // set all the attributes...
    }
}


@Injectable()
export class AuthService {

    private _currentUser: BehaviorSubject<User> = new BehaviorSubject(null);
    get currentUser() {
        // do some logic here if needed
        return this._currentUser;
    }

    constructor() {}

    login(email, password)  {
        DoSomeHttpRequestToLogin()
        .then( userParams => {
            const user = new User(userParams);
            this._currentUser.next(user);
            })
        .catch(error => {});
    }   
}
Run Code Online (Sandbox Code Playgroud)

组件

@Component({
    selector: 'app-main',
    templateUrl: './main.component.html'
})
export class …
Run Code Online (Sandbox Code Playgroud)

service typescript firebase-authentication angular

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

Firestore 计费和使用 API

有谁知道谷歌是否提供了一个 API 来以编程方式检索 firestore 的当前使用情况?

更准确地说,我指的是当前的读写操作数,如下所示: 在此处输入图片说明

firebase google-cloud-firestore

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