小编use*_*697的帖子

如何根据缩放级别加载图层?

我想控制OpenLayers中的缩放.

当缩放为3时我想加载KML1,当缩放为4时我想加载KML2.

你能告诉我如何控制变焦事件吗?

openlayers

9
推荐指数
2
解决办法
8544
查看次数

是否可以在运行时更新 zap 记录器的日志级别?

我创建了一个记录器kubebuilder,它基于 zap 记录器:

import (
    "flag"
    "github.com/gin-gonic/gin"
    "net/http"
    "os"
    "go.uber.org/zap/zapcore"
    uzap "go.uber.org/zap"
    // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
    // to ensure that exec-entrypoint and run can make use of them.
    _ "k8s.io/client-go/plugin/pkg/client/auth"

    "k8s.io/apimachinery/pkg/runtime"
    utilruntime "k8s.io/apimachinery/pkg/util/runtime"
    clientgoscheme "k8s.io/client-go/kubernetes/scheme"
    ctrl "sigs.k8s.io/controller-runtime"
    "sigs.k8s.io/controller-runtime/pkg/healthz"
    "sigs.k8s.io/controller-runtime/pkg/log/zap"

)

var (
    scheme   = runtime.NewScheme()
    setupLog = ctrl.Log.WithName("setup")
)

var zapOpts []uzap.Option
    zapOpts = append(zapOpts, uzap.AddCaller())
    zapOpts = append(zapOpts, uzap.AddCallerSkip(1))
    zapOpts = append(zapOpts, uzap.AddStacktrace(uzap.DebugLevel))

    opts := zap.Options{
        Development:     developmentFlag,
        StacktraceLevel: …
Run Code Online (Sandbox Code Playgroud)

logging go go-zap

8
推荐指数
2
解决办法
5648
查看次数

如何使用系统获取属性创建选项卡?

我知道我可以找到新的系统

     System.getProperty("line.separator");  
Run Code Online (Sandbox Code Playgroud)

line.separator总是新线吗?

如何才能为tab\t做同样的事情?

java

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

如何修复 Prometheus 中未定义变量“$labels”的错误?

我用过这个警报

        - alert: my alert
          expr: status{status="ERROR"}
          for: 30m
          labels:
            severity: WARNING   
          annotations:
            myData: "{{ $labels.myData }}"
            myData2: "{{ $labels.myData2 }}"
Run Code Online (Sandbox Code Playgroud)

我收到错误 - templates/: “prometheus/templates/alertmanager-prometheusRule.yaml”中的解析错误:模板:prometheus/templates/alertmanager-prometheusRule.yaml:419: 未定义变量“$labels”

我在中看到了同样的问题

Prometheus Docker 无法以 `Template: (dynamic): parse: template: :10: undefined variable "$labels"` 启动

但我不明白如何解决它

在配置中我使用了这些数据

text: "{{ range .Alerts -}}{{ .Annotations.myData }}{{ .Annotations.myData2}}{{ end-}}"
Run Code Online (Sandbox Code Playgroud)

该错误来自 helm lint

prometheus kubernetes-helm prometheus-alertmanager

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

如何在命令中传递对象参数?

我使用带有参数的新命令创建了 eclipse-rcp 项目的plugin.xml。

 ArrayList<parameterization> parameters = new ArrayList<parameterization>();
 IParameter iparam;

 //get the command from plugin.xml
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
 ICommandService cmdService =     (ICommandService)window.getService(ICommandService.class);
 Command cmd = cmdService.getCommand("org.ipiel.demo.commands.click");

//get the parameter
iparam = cmd.getParameter("org.ipiel.demo.commands.click.paramenter1");
Parameterization params = new Parameterization(iparam, "commandValue");
parameters.add(params);

//build the parameterized command
 ParameterizedCommand pc = new ParameterizedCommand(cmd, parameters.toArray(new       Parameterization[parameters.size()]));

//execute the command
 IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class);
handlerService.executeCommand(pc, null);
Run Code Online (Sandbox Code Playgroud)

我尝试了这个例子来传递参数并且它有效。

本示例中的问题是我只能传递 String 类型的参数。(因为参数化)

我想传递哈希映射的参数,并且通常传递任何对象。

我试过这段代码

     IServiceLocator serviceLocator = PlatformUI.getWorkbench();
    ICommandService commandService = (ICommandService)      serviceLocator.getService(ICommandService.class);




    ExecutionEvent executionEvent = new ExecutionEvent(cmd, …
Run Code Online (Sandbox Code Playgroud)

java eclipse-plugin

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

如何用sed替换第一次出现?

我有很多名字的文件:我只想替换第一个

sed -i "s/\(name:\).*/\1 ${NEW_VALUE}/" ./myFile

Input
-  martin:
    name: Martin D'vloper
    job: Developer
    skills:
      - python
      - perl
      - pascal
-  tabitha:
    name: Tabitha Bitumen
    job: Developer
    skills:
      - lisp
      - fortran
      - erlang
Run Code Online (Sandbox Code Playgroud)

输出仅更改名字 Martin D'vloper

-  martin:
        name: NEW VALUE!!!
        job: Developer
        skills:
          - python
          - perl
          - pascal
    -  tabitha:
        name: Tabitha Bitumen
        job: Developer
        skills:
          - lisp
          - fortran
          - erlang
Run Code Online (Sandbox Code Playgroud)

它改变了所有的名字

我看到了一些不同语法的东西

sed '0,/pattern/s/pattern/replacement/' filename
Run Code Online (Sandbox Code Playgroud)

但我无法将 sed 更改为此,因为动态值您能否建议我如何仅用我的语法替换第一个?

bash awk sed

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

为什么我对对象字面量的错误ype声明被禁止,请改用类型注释。tslint(no-object-literal-type-assertion)?

我在TS中有代码

interface Context {
    out: vscode.OutputChannel,
    myPorts: number[]
}

const outputChannel = vscode.window.createOutputChannel('my-run');

    const ctx = {
        out: OutputChannel,
        myPorts: []
    } as Context;
Run Code Online (Sandbox Code Playgroud)

我收到错误消息,禁止在对象常量上使用类型声明,请改用类型注释。tslint(no-object-literal-type-assertion

typescript

5
推荐指数
2
解决办法
2159
查看次数

如何使用 jQuery 查找特定脚本

我想查看我的 html 文件并查找特定脚本是否存在。

我写了这段代码:

var scriptExist = false;
$('script').each(function(i,e){                 
if( $(e).attr('src')){
if( $(e).attr('src').search("load.js)!=-1){    
scriptExist = true;
return false;
}            
}
 });
 return scriptExist;                    
},
Run Code Online (Sandbox Code Playgroud)

是否可以在 jQuery 中执行此操作而不使用 use.each 并找到特定的脚本,例如 src = load.js ?

jquery

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

如何在两个功能之间同步

我有两个函数,当其他函数(一和二)完成时,我想调用第三个函数。我需要将第一个函数和第二个函数称为异步函数。例如

  var func1 = function( do something..... return arr )
  var func2 = function ( do something ..... return arr2 )

   if ( arr.length > 0  && arr2.length > 0 )
       var func3 = function( do something )
Run Code Online (Sandbox Code Playgroud)

我的问题:

  1. 最好的方法是什么?

  2. 如何以异步方式调用函数?

javascript

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

使用Ionic还是Cordova?

我们想要构建一个使用大量视频和图像的简单应用程序.该应用程序应在运行Andriod和iPhone操作系统的不同移动设备上运行.Ionic是否也将每个应用程序转换为所有移动选项?

你有什么建议使用Cordova或Ionic?

cordova ionic-framework ionic

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