小编Ole*_*ter的帖子

Google Apps Script 个人脚本不会授权

我以前使用过 Google Apps 脚本UrlFetchApp没有问题。

昨天我创建了一个新的,如果我包含该UrlFetchApp服务,我将无法运行任何功能——即使它被注释掉了!

当我尝试运行脚本时,我会得到通常的“权限”弹出窗口。但是当我同意时,我得到:

暂时禁用此应用的 Google 登录 此应用尚未通过 Google 验证才能使用 Google 登录。


这是个人脚本,我是唯一会使用它的人 - 我有什么选择?我不会去获取域只是为了通过验证来运行一个简单的小脚本......

google-authentication google-apps-script oauth-2.0 google-signin

8
推荐指数
0
解决办法
406
查看次数

CSS 计算(); 定位 div

我正在尝试创建一个宽度和高度为视图宽度 37% 的 div。

我希望 div 位于中间居中,因此我尝试采用视图宽度的 50% 并减去 37% 的值。

然后我希望 div 位于父 div 之外 50%。它基本上是一张带有个人资料图片的封面照片。底部位置需要为负数,以便将业务封面徽标强制放在业务视图包装器之外,而我能想到的唯一方法就是乘以负数。

<div class="business-view-cover">
    <div class="business-cover-logo"></div>
</div>

.business-view-cover {
    position: relative;
    height: calc(100vw * 0.5625);
    background-size: cover;
    background-position: center center;
    background-image: url('../images/business-cover-1.png');

    .business-cover-logo {
        position: absolute;
        --width-profile: calc(100vw * 0.37);
        --half-width: calc(var(--width-profile) / 2);
        --profile-bottom: calc(-1 * var(--half-width));
        bottom: calc(var(--profile-bottom) * -1);
        left: calc(50vw - var(--width-profile));
        width: var(--width-profile);
        height: var(--width-profile);
        border: 4px solid $e1-background-grey;
        border-radius: 1.6rem;
        background-size: cover;
        background-position: center center;
        background-image: url('../images/logo-cover-napa.png');
    }
} …
Run Code Online (Sandbox Code Playgroud)

css css-position css-calc

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

如何在 Google 幻灯片上添加具有新布局的新幻灯片?

以下是我所做的:

  1. 在 Google 幻灯片上创建了一个新的演示文稿,

  2. 编辑了主布局视图上的预定义布局之一,以便拥有我想要使用的新布局,

  3. 将主布局的名称编辑为“会议”,

  4. 编辑了我想用于“Office”的预定义布局的名称。

我的问题是,在 Google Script 上,我无法引用我想要使用的这个特定的预定义布局。

到目前为止,我的代码如下:

function AddSlideToPresentatio() {

// The following line opens my presentation
var presentation = SlidesApp.openById('PresentationID');

//Now, I try to use my new layout
  presentation.appendSlide("Office");
}
Run Code Online (Sandbox Code Playgroud)

我完全不知道为什么这不起作用。当我尝试运行它时,出现错误:

“找不到方法 appendSlide(string)。(第 6 行,文件“Office”)。

以下是我尝试过的一些组合,它们给我带来了类似的错误:

presentation.appendSlide('Office');
presentation.appendSlide(Office);
presentation.appendSlide("Meeting - Office");
presentation.appendSlide('Meeting - Office');
presentation.appendSlide(Meeting - Office);
Run Code Online (Sandbox Code Playgroud)

如果我只是使用presentation.appendSlide()它会创建一个新幻灯片,但不会使用我想要使用的布局。

Google Apps Script Reference 中有三种方法:

  1. 追加幻灯片(),
  2. appendSlide(布局),
  3. appendSlide(预定义布局)

但是,我似乎无法理解最后两个之间的区别,因为当我尝试使用它们时,它们似乎在做同样的事情。

javascript google-apps-script google-slides google-slides-api

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

我无法使从接口实现的类字段私有,也无法使接口字段私有

我在界面上有这个字段:

// Stores the to views folder
VIEW_PATH: string;
// Stores BrowserWindows with respective view  
browserWindows: [string, BrowserWindow | null][];
Run Code Online (Sandbox Code Playgroud)

当我在类中实现这些字段并尝试将它们设置为私有时,出现以下错误:

Class 'WindowHandler' incorrectly implements interface 'IWindowHandler'.
  Property 'VIEW_PATH' is private in type 'WindowHandler' but not in type 'IWindowHandler'.ts(2420)
Run Code Online (Sandbox Code Playgroud)

当我尝试将接口字段设置为私有时:

'private' modifier cannot appear on a type member.ts(1070)
Run Code Online (Sandbox Code Playgroud)

interface class typescript

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

如何将元组类型转换为联合?

如何将元组泛型类型映射到联合类型?

type NeededUnionType<T> = T[keyof T]; // Includes all the Array properties values
  
const value: NeededUnionType<[7, string]> = 2; // This should not be allowed (2 is the tuple length)
Run Code Online (Sandbox Code Playgroud)

预期类型: 7 | string

tuples typescript typescript-generics union-types mapped-types

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

当客户端取消连接时,Nginx(作为 revser 代理)不会通知 gin-gonic(作为 Web 服务器)

gin-gonic用作网络服务器和nginx代理服务器的网站中,客户端通过gin-conic公开的 API将他们的数据发送到服务器,并且为了向客户端发送服务器命令,每个(即客户端)都与网络服务器建立连接,并保留它很长一段时间(即几个小时内不会过期)并用所需的命令填充他们的响应主体(对于双向连接,我们可以使用它ws来代替)。

问题是我们需要了解客户端是否删除/取消了与服务器的连接。为了理解我们case <-c.Request.Context().Done():在下面的代码中有这一行。

func MakeConnection(c *gin.Context) {
// ... code
select {
case notification = <-clientModel.Channels[token]:// we have a command to send to user
    log.Info("Notification")
    err = nil
case <-c.Request.Context().Done(): // connection dropped by client
    log.Info("Cancel")
    err = c.Err()
case <-ctx.Done(): // time elapsed and there was no command to send to client
    log.Info("timeout")
    err = errors.New("timeout exceeded")
}
// ... code
}
Run Code Online (Sandbox Code Playgroud)

一切正常(如果我们与服务器建立这样的连接并在任意时间后取消它,立即Cancel显示在终端中),直到客户端数量增加。

对于大约 5 个客户端,这项工作按预期进行,但对于 …

nginx go go-gin nginx-reverse-proxy

7
推荐指数
0
解决办法
707
查看次数

既然链接没有反映为超链接,如何从单元格中提取链接?

“插入链接”不再产生=HYPERLINK(’’,’’)

之前,如果您使用值“X”链接单元格。它被转换成公式=HYPERLINK(*link*,’X’)

两天前“插入链接”改变了。

现在单元格的内容保持不变,只是加了下划线。

使用脚本,既然单元格的值和公式都不包含此信息,我该如何从单元格中提取链接?

我搜索了文档,但我能找到的与链接相关的唯一方法是 setShowHyperlink(showHyperlink)

google-sheets google-apps-script

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

使用 python-docx 在普通文本上设置背景颜色(阴影)

有很多用于在表格中设置背景颜色的线程,但我想更改段落中一段普通文本的颜色。

我可以设置突出显示颜色,但只能选择 17 种可用颜色中的一种。

在Word中,背景颜色被称为“底纹”,通过单击油漆桶图标来完成。

虽然突出显示只会改变文本后面的颜色,但阴影会绘制整行的颜色 - 无论哪种方式对我来说都很好。

是否可以使用 python-docx 在不在表格中的文本后面设置任何 RGB 值?

格式示例

python ms-word python-docx

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

为什么类型保护类型的差价会导致类型检查被跳过?

题:

为什么在T使用对象扩展构造所述对象时忘记将嵌套字段添加到类型的对象时不会收到编译时错误?

例子:

interface User {
  userId: number;
  profile: {
    username: string
  }
}

function updateUsername(user: User): User {
  return {
    ...user,
    profile: {
      // Error (as expected)
    }
  }
}

function updateUsernameGeneric<T extends User>(user: T): T {
  return {
    ...user,
    profile: {
      // No error (unexpected... why?)
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我自己对答案的猜测:

我可以想像的是,打字稿允许亚型删除其超级计算机的性能,从而有可能对某些亚型TUserprofile财产可能不包含任何属性。(如果是这样,我不知道 TypeScript 允许你这样做......)


打字稿版本 4.1.2

操场

typescript typescript-generics

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

如何正确输入类似 Object.assign 的泛型函​​数?

我正在尝试在 TypeScript 中创建一个“分配默认值”函数,它会循环遍历 的键source,如果同一键的值在 中为空target,它将使用 中的值source。这是我的尝试:

const assignDefault = <T, U>(target: T, source: U): T & U => {
  Object.keys(source).forEach(key => {
    // typecasted as Object.keys returns string[]
    const prop = target[key as keyof T]
    if (typeof prop === 'undefined' || prop === null) {
      // Error: Type 'U[keyof U]' is not assignable to type 'T[keyof T]'.
      target[key as keyof T] = source[key as keyof U] 
    }
  })
  return target // Error: Type 'T' …
Run Code Online (Sandbox Code Playgroud)

typescript typescript-generics

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