小编Igo*_*nko的帖子

正则表达式字符按照 grep 重复 n 次或更多次

我需要找到正则表达式来找到一个用 grep 重复 4 次或更多次的字符。

我知道表达式是 {n,},所以如果我需要查找行,例如,当字符“g”重复 4 次或更多次时,理论上 grep 手册页是:

grep "g{4,}" textsamplefile
Run Code Online (Sandbox Code Playgroud)

但不起作用。有什么帮助吗?

字符可以有其他字母。例如,有效匹配是:

g示例g of g有效g匹配g

g其他g有效g匹配g是g这里g

GGGG其他

regex grep repeat

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

如何解决泛型方法中类型推断的局限性

我正在尝试实现泛型方法,该方法用于将Tuple<Descendant>类型的对象转换为类型的对象Tuple<Ancestor>.我遇到了一个似乎是C#语言限制的问题.

using System;

namespace Samples
{
    public static class TupleExtensions
    {
        public static Tuple<SuperOfT1> ToSuper<T1, SuperOfT1>(this Tuple<T1> target)
            where T1 : SuperOfT1
        {
            return new Tuple<SuperOfT1>(target.Item1);
        }
    }

    public interface Interface { }

    public class Class : Interface { }

    static class Program
    {
        static void Main()
        {
            var tupleWithClass = new Tuple<Class>(new Class());

            // Next instruction lead the compilation to error. :( The compiler doesn't try to infer types if at least one of generic …
Run Code Online (Sandbox Code Playgroud)

c# generics extension-methods type-inference

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

尝试设置平台服务器时出现“错误:在此配置中 Angular 需要 Zone.js”

仍在尝试设置平台服务器并使用自定义渲染器渲染我的模块(我尚未实现)。

问题

  • 我收到一个我不知道如何修复的错误(zone.js位于我的 npm 依赖项中)。

    错误:在此配置中 Angular 需要 Zone.js

  • 我什至不确定我是否正在朝着自定义模块渲染的正确方向前进......

主要代码

export function createCompiler(compilerFactory: CompilerFactory) {
  return compilerFactory.createCompiler();
}

async function generate<M>(moduleType: Type<M>) {
  try {
    const extraProviders: StaticProvider[] = [
      { provide: Compiler, useFactory: createCompiler, deps: [CompilerFactory] },
    ];
    const platformRef = platformDynamicServer(extraProviders);
    const moduleRef = await platformRef
      .bootstrapModule(
        moduleType,
        {
          providers: [ { provide: ResourceLoader, useValue: new ResourceLoaderImpl(`src\\app`), deps: [ ] }, ],
        });
    
    const appComponent = moduleRef.injector.get(AppComponent);
    
    console.info(appComponent.title.toString());
  } catch (error) {
    throw new Error(error.toString()); …
Run Code Online (Sandbox Code Playgroud)

angular

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

如何永久删除 Azure DevOps 工件中的源?

我正在尝试删除 Azure DevOps 的工件中的项目范围的提要,因为我想将该提要名称用于组织范围的提要(允许在不同项目之间共享包)。

当我在 Feed 重命名 UI 中单击“保存”时,出现以下错误:

提要名称“myorg.internal”即将推出。

检查浏览器“网络”选项卡显示此请求失败,并显示 HTTP 409: PATCH https://myorf.feeds.visualstudio.com/_apis/Packaging/Feeds/ee54xxxx-xxxx-xxxx-xxxx-xxxx49c10d83。

{
    "$id": "1",
    "innerException": null,
    "message": "A feed with name 'myorg.internal' exists in feed recycle bin.
      The name will be available soon after it is permanently deleted from the feed recycle bin.",
    "typeName": "Microsoft.VisualStudio.Services.Feed.WebApi.FeedNotReleasedException,
      Microsoft.VisualStudio.Services.Feed.WebApi",
    "typeKey": "FeedNotReleasedException",
    "errorCode": 0,
    "eventId": 3000
}
Run Code Online (Sandbox Code Playgroud)

有没有办法可以加快永久删除 Feed 的速度?

azure azure-devops azure-artifacts

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

为什么Scala支持阴影变量?

我认为阴影变量太危险而无法使用它们.为什么Scala支持这种语言结构?应该有一些强有力的理由,但我找不到.

scala language-construct

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

Chrome扩展程序:如何显示PDF文件的自定义用户界面?

我正在尝试编写用于显示PDF文件的Google Chrome扩展程序.一旦我检测到浏览器重定向到指向PDF文件的URL,我希望它停止加载默认的PDF查看器,但是开始显示我的UI.UI将使用PDF.JS呈现PDF和jQuery-ui以显示其他一些内容.

问题:我该怎么做?阻止原始PDF查看器非常重要,因为我不想通过显示文档的两个实例来消耗内存消耗.因此,我应该以某种方式将选项卡导航到我自己的视图.

javascript google-chrome google-chrome-extension pdf.js

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

Json.Net:序列化/反序列化属性是一个值,而不是一个对象

在另一个类中使用时,如何实现Id类的以下JSON表示形式?

class Car
{
    public StringId Id { get; set; }
    public string Name { get; set; }
}

class StringId
{
    public string Value { get; set; }
}

// ---------------------------------------------

// Desired representation
{ "Id": "someId", "Name": "Ford" }

// Default (undesired) representation
{ "Id" : { "Value": "someId" }, "Name": "Ford" }
Run Code Online (Sandbox Code Playgroud)

c# serialization json json.net

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

错误:[mobx-state-tree]无法解析引用XXX以键入“用户”

语境

我有一个由mobx-state-tree(MST)支持的React应用程序。其中一个页面进行两个并行的 API调用,以获取的列表Projects和系统的列表Users。

然后,将这两个API的响应作为快照应用到同一树中的两个兄弟节点。项目模型的所有者字段是指用户模型。

我的问题是,GET项目API调用通常比GET Users API调用更早完成。经典的“比赛条件”。因此,当MST尝试取消引用所有者值时,具有此类标识符的用户在树中不可用,并且出现如下运行时错误:

错误:[mobx-状态树]无法解析引用'dtGNbVdNOQIAX0OMGaH2r2oSEf2cMSk9AJzPAf4n7kA'以键入“用户”(来自节点:/ projectListStore / projects / 0 / owner)

题

如何解决该错误?

请注意,进行API调用相互依赖(await或users.load().then(users => { projects.load(); })不是我们项目的选择。

MST模型

export const ProjectModel = types
  .model('Project', {
    projectId: types.optional(types.identifierNumber, 0),
    title: '',
    descriptionStatus: '',
    projectStatus: '',
    startDate: CustomDate,
    endDate: CustomDate,
    owner: types.maybeNull(types.reference(User)), // -----
  })                                                        \ 
  // ...                                                     |
                                                             |
export const User = types                                    |
  .model('User', {                                          /
    userId: types.identifier,                      // <<<--
    userName: '',
    firstName: '', …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs mobx mobx-state-tree

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

如何将List <DerivedClass>分配给IEnumerable <BaseClass>参数?

据我所知,派生类的List <>不能直接分配给基类的List <>.但是它如何允许将相同的List <>派生类分配给IEnumerable <>类型的基类参数.

public class Base 
{}

public class Derived : Base 
{}

public class Test
{
   // inside some method...
   List<Derived> someElements;
   ReadElements(someElements);

   public void ReadElements(List<Base> elements) // this throws compile error
   {...} 

   public void ReadElements(IEnumerable<Base> elements) // this one works
   {...}
}
Run Code Online (Sandbox Code Playgroud)

我知道这List是一个实现IEnumerable并支持索引和修改元素,但我似乎不理解这一部分?有人可以解释一下吗?谢谢.

c# list

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

在Google Cloud的值区中执行HTTP到HTTPS重定向

我将Vue.js SPA部署到了Google Cloud的存储桶中。

Google的平衡器不允许我配置从HTTPS到HTTP的重定向。该.htaccess文件也未得到确认(至少根据我偶然发现的其他StackOverflow问题)。

如何在GCP的存储分区的上下文中强制从HTTP重定向到HTTPS?

我当时正在考虑在应用程序中修改路由器本身,但是

  • 这是一个肮脏的骇客;
  • 导致不必要的额外通话;
  • 技术上似乎没有可解-航线表示为相对于域根反正(即我没有架构+域信息使用的编程式重定向,如/,/resume,/manifesto)...

google-cloud-storage google-cloud-platform vue.js angular google-cloud-networking

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