小编Jul*_*oro的帖子

在 Laravel 中使用 Socialite 登录后重定向到 URL

我需要使用以下网址注册锦标赛:

http://laravel.dev/tournaments/1/register/
Run Code Online (Sandbox Code Playgroud)

这个 URL 在中间件 'auth' 中,所以如果用户没有登录,他会被重定向到登录页面。

我需要的是重定向到

http://laravel.dev/tournaments/1/register/
Run Code Online (Sandbox Code Playgroud)

社交登录后(我有 2 个提供商,fb 和 google)

在这种情况下,我不希望用户被重定向到 .env 中定义的重定向 url

这是我用来登录 Socialite 的功能:

public function execute($request, $listener, $provider) {

    if (!$request) {

        return $this->getAuthorizationFirst($provider);
    }
    $user = $this->users->findByUserNameOrCreate($this->getSocialUser($provider), $provider);
    if (!is_null($user)){
        $this->auth->login($user, true);
    }else{
        Session::flash('error', Lang::get('auth.account_already_exists'));
        return redirect('auth/login');
    }


    return $listener->userHasLoggedIn($user);
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能让系统将我重定向到初始操作而不是默认的 redirect_url 参数。

我通过guest()函数正常登录解决了这个问题,但我不知道在这种情况下如何实现它。

问题与这篇文章非常相似

php redirect laravel laravel-socialite

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

使用 ng-bootstrap 在模式中提交表单

我只是想用 ng-boostrap 在模态中提交一个表单,它比应有的要复杂得多,我使用 ng-boostrap 来避免 JQuery 代码永远不优雅,但它有一个成本......我有点沮丧,简单和常见的东西应该更简单。

这是我的模态模板:

<form (ngSubmit)="onSubmit()">
  <ng-template #newCategory let-c="close" let-d="dismiss">
    <div class="modal-header bg-primary text-white text-uppercase">
      <h4 class="modal-title">{{ 'core.create_a_new_category' | translate | uppercase }}</h4>
      <button type="button" class="close text-white" aria-label="Close"  (click)="d()">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
    <div class="modal-body">
      ...
    </div>
    <div class="modal-footer">
      <button type="submit" class="btn btn-primary" (click)="c('Save click')">
        Add Category
      </button>
    </div>
  </ng-template>
</form>

<!-- Button that trigger modal -->
<div align="center" class="mt-2">
  <span class="mr-1">{{ 'core.want_to_create_custom_category' | translate }}</span>
  <button class="btn btn-lg btn-outline-primary" (click)="open(newCategory)">
    {{ 'core.add_custom_category' | translate }} …
Run Code Online (Sandbox Code Playgroud)

ng-bootstrap angular

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

如何备份和恢复包含 MongoDB 数据的命名 docker 卷

我有一个 mongoDB 的 docker 镜像。我想制作一个备份生产数据的脚本,并将其恢复到我的本地计算机中,这样我就可以拥有类似于生产的开发环境。

这是我的一部分docker-compose.yml

 mongo:
    image: "mongo:latest"
    container_name: "espace_client_mongo"
    volumes:
      - mongo-data:/data/db
Run Code Online (Sandbox Code Playgroud)

我想导出mongo-data卷中包含的数据。

文件指出我可以这样做:

 docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata
Run Code Online (Sandbox Code Playgroud)

但我无法让它发挥作用。

当我运行它时,我得到:

ec2-user@espace-client-prod prod]$ docker run --rm --volumes-from espace_client_mongo -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar ./backup
tar: ./backup/backup.tar: file is the archive; not dumped
./backup/
./backup/Caddyfile
./backup/docker-compose.yml
[ec2-user@espace-client-prod prod]$ ls
backup.tar  Caddyfile  docker-compose.yml
Run Code Online (Sandbox Code Playgroud)

它将把当前文件夹中的文件放入备份文件夹中。这不是我想要的。我想将docker卷的内容放在备份文件夹中。我误解了什么吗?

编辑:我想使用 mongo 工具( mongodump 和 mongorestore )备份和恢复数据

backup mongodb docker

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

来自服务器的错误 (NotFound):未找到 pods“\nmongo-client-79667cc85d-tsg72”

我正在尝试使用此脚本从 Mongo / K8S 进行备份

export POD=$(kubectl get pods -l app=mongo-client -o custom-columns=:metadata.name -n espace-client)
kubectl exec "$POD" sh -c 'mongodump --archive' > ~/backup/mongo/$(date +%F).db.dump
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Error from server (NotFound): pods "\nmongo-client-79667cc85d-tsg72" not found
Run Code Online (Sandbox Code Playgroud)

当我检查豆荚时,我可以看到 mongo-client-79667cc85d-tsg72

当我将名称放在没有变量的情况下时,效果很好,所以可能是因为初始\n. 我怎样才能避免它?如何从名称中删除它?

bash kubernetes kubectl

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

The node was low on resource: [DiskPressure]. but df -h shows 47% usage only

I have a node in my K8S cluster that I use for monitoring tools.

Pods running here: Grafana, PGAdmin, Prometheus, and kube-state-metrics

My problem is that I have a lot of evicted pods

The pods evicted: kube-state-metrics, grafana-core, pgadmin

Then, the pod evicted with reason: The node was low on resource: [DiskPressure]. : kube-state-metrics (90% of evicted pods), pgadmin (20% of evicted pods)

When I check any of the pods, I have free space on …

kubernetes

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

使用 K8S/Helm 安装 TimescaleDB 时出错:MountVolume.SetUp 卷“证书”失败:未找到秘密“timescaledb-certificate”

我只是尝试在 Ubuntu 20.04 上的 minikube 中使用 Helm 安装 timescaleDB Single。

通过安装后:

helm install timescaledb timescaledb/timescaledb-single --namespace espace-client-v2

我收到消息:

?  ~ helm install timescaledb timescaledb/timescaledb-single  --namespace espace-client-v2
NAME: timescaledb
LAST DEPLOYED: Fri Aug  7 17:17:59 2020
NAMESPACE: espace-client-v2
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
TimescaleDB can be accessed via port 5432 on the following DNS name from within your cluster:
timescaledb.espace-client-v2.svc.cluster.local

To get your password for superuser run:

    # superuser password
    PGPASSWORD_POSTGRES=$(kubectl get secret --namespace espace-client-v2 timescaledb-credentials -o jsonpath="{.data.PATRONI_SUPERUSER_PASSWORD}" …
Run Code Online (Sandbox Code Playgroud)

kubernetes kubernetes-helm timescaledb

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

在Play商店中取消已发布的Android应用程序版本

我刚刚发布了我的v1.1应用程序,我意识到它在启动时崩溃了.是否可以恢复我在Play商店中制作的更新???

android google-play

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

从同一个控制器管理视图和api

我的应用程序存在问题,即"混合",我的意思是"混合"控制器必须管理两个视图和API.

所以,基本上,对于每个控制器,我必须检查:

if $request->wantsJson(){
    ... // Client rendering using Angular, return json
}else{
   // Server rendering Using blade, return view
}
Run Code Online (Sandbox Code Playgroud)

我不喜欢在每个控制器方法中都有条件的事实.

我也不希望有一个带有我所有控制器副本的API文件夹,会有很多重复的代码.

我该怎么办?

api laravel

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

如果没有太多反馈,vagrant ssh worker1 就无法工作

我正在使用这个存储库来创建一个带有 vagrant 和 virtualbox 的 docker swarm 集群。

当我这样做时vagrant up,所有 3 个虚拟机的创建和配置都没有问题。

但当时我想通过连接vagrant ssh worker1我遇到这个问题:

... // Log is too long, had too cut it
SharedFolderNameMachineMapping1="vagrant"
SharedFolderPathMachineMapping1="\\\\?\\C:\\Users\\info\\code\\vagrant-docker-swarm"
VRDEActiveConnection="off"
VRDEClients==0
videocap="off"
videocapaudio="off"
capturescreens="0"
capturefilename="C:\\Users\\info\\VirtualBox VMs\\ubuntu-cloudimg-trusty-vagrant-amd64_1547555682734_91505\\ubuntu-cloudimg-trusty-vagrant-amd64_1547555682734_91505.webm"
captureres="1024x768"
capturevideorate=512
capturevideofps=25
captureopts=""
GuestMemoryBalloon=0
GuestOSType="Linux26_64"
GuestAdditionsRunLevel=2
GuestAdditionsVersion="4.3.36_Ubuntu r105129"
GuestAdditionsFacility_VirtualBox Base Driver=50,1547555723996
GuestAdditionsFacility_VirtualBox System Service=50,1547555740594
GuestAdditionsFacility_Seamless Mode=0,1547555723996
GuestAdditionsFacility_Graphics Mode=0,1547555723996
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0
 INFO warden: Calling IN action: …
Run Code Online (Sandbox Code Playgroud)

vagrant

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

无法从 Golang 中的 map[time.Time]Measure 中获取值,if val, ok := mapMeasures[ts]; 好的 {}

我有一个定义如下的地图:

mapMeasures := make(map[time.Time]models.Measure, 0)
Run Code Online (Sandbox Code Playgroud)

type Measure struct {
    Delta         float64      // I just let one field to simplificate
}
Run Code Online (Sandbox Code Playgroud)

所以初始循环将填充值从22/01/20-10:10:00to 22/01/20-12:00:00,因此它将存储 12 个键值(10 分钟时间步长)

然后,它将再次循环这些时间戳,并将增量添加到现有值。

所以,我需要检查是否已经有一个与我的实际时间戳相对应的键:

if val, ok := mapMeasures[ts]; ok { // ts already exists, we must sum delta values
    measure.Delta += val.Delta
}
Run Code Online (Sandbox Code Playgroud)

但似乎这种情况永远不会成立。

我调试了代码,我可以看到时间戳实际上存在于地图中:

 mapMeasures = {map[time.Time]gitlab.com/company/common/models.Measure} 
 0 =  -> 
  key = {time.Time} 2020-01-22 11:40:00 +0100
  value = {*gitlab.com/company/common/models.Measure | 0xc000132460} 
 1 =  -> 
  key = {time.Time} 2020-01-22 12:30:00 +0100
  value …
Run Code Online (Sandbox Code Playgroud)

time hashmap go

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

java.lang.IllegalArgumentException:provider不存在:null

我有一个Android应用程序正在生产中.我使用ACRA来获取崩溃报告.在很多报道中,我有这个例外...但对我来说,它总是有效,我无法重现它.

API可以是15,17等......

这是我的GPS管理文件:

public class ConectUtils {private final String TAG = getClass().getSimpleName();

private Context ctx;
private LocationManager locationManager;

public ConectUtils(Context ctx) {
    super();
    this.ctx = ctx;
    locationManager = (LocationManager) ctx
            .getSystemService(Context.LOCATION_SERVICE);
}

public boolean isConnectingToInternet() {
    ConnectivityManager connectivity = (ConnectivityManager) ctx
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity != null) {
        NetworkInfo[] info = connectivity.getAllNetworkInfo();
        if (info != null)
            for (int i = 0; i < info.length; i++)
                if (info[i].getState() == NetworkInfo.State.CONNECTED) {
                    return true;
                }

    }
    return false;
}

public boolean start() { …
Run Code Online (Sandbox Code Playgroud)

gps android

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

通过其他docker容器访问ftp服务

我有一个 Golang 应用程序,它应该连接到 FTP 服务器。

现在,Golang app 和 FTP Server 都已dockerized,但我不知道如何从 Golang app 连接到 FTP 服务器

这是我的 docker-compose.yml

version: '2'

services:
  myappgo:
    image: myappgo:exp
    volumes:
      - ./volume:/go
    networks:
      myappgo_network:
    env_file:
      - test.env

  ftpd-server:
    container_name: ftpd-server
    image: stilliard/pure-ftpd:hardened
    ports:
      - "21:21"
      - "30000-30009:30000-30000"
    environment:
      PUBLICHOST: "localhost"
      FTP_USER_NAME: "test"
      FTP_USER_PASS: "test"
      FTP_USER_HOME: "/home/test"
    restart: on-failure
    networks:
      myappgo_network:

networks:
  myappgo_network:
Run Code Online (Sandbox Code Playgroud)

当我运行 docker compose 时,所有服务都已启动。

我可以通过以下方式获取 ftp 容器的 IP:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ftpd-server
Run Code Online (Sandbox Code Playgroud)

然后,我在我的 golang 容器 lftp 中为 alpine 安装了一个 ftp 客户端: …

ftp docker docker-compose docker-networking

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

结构中的空字段是否消耗内存?

我有一个带有字段的结构:

type Measure struct {
    ID            int
    IndexName     string    
    IndexValue    int   
    Redistributed float64
    MyArray       []myObject
}
Run Code Online (Sandbox Code Playgroud)

如果我用

measure := Measure{
   ID: 10,
   IndexName: "",
   IndexName: 0,
   Redistributed: 0
   MyArray: nil         
}
Run Code Online (Sandbox Code Playgroud)

我的内存占用应该是多少?当我用空字段实例化一个结构体时,我是否仍然使用内存?

我很确定我是,但我只需要确认。

memory struct go

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