小编wez*_*ten的帖子

如何扩展单个文件?

我有一个有10页的网站,它共享一个Typescript文件,每个页面都有自己特定的Typescript文件.一个页面有一个JQuery插件,timepicker所以我使用以下命令扩展JQuery对象:

interface JQuery {
    timepicker(options:any):JQuery;
}
Run Code Online (Sandbox Code Playgroud)

但是我不希望任何其他TypeScript文件在JQuery对象上有时间戳.如何为此文件扩展它?

它不允许我JQuery在命名空间内扩展.

模块有帮助吗?我没有必要导入或导出任何东西,所以我不确定它是否合适,或者如何使用模块.

javascript typescript

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

catch没有捕获多线程错误

以下是一个完整的控制台程序,它重现了我遇到的一个奇怪的错误.该程序读取包含远程文件URL的文件,每行一个.它会激活50个线程来下载它们.

static void Main(string[] args)
{
    try
    {
        string filePath = ConfigurationManager.AppSettings["filePath"],
            folder = ConfigurationManager.AppSettings["folder"];
        Directory.CreateDirectory(folder);
        List<string> urls = File.ReadAllLines(filePath).Take(10000).ToList();

        int urlIX = -1;
        Task.WaitAll(Enumerable.Range(0, 50).Select(x => Task.Factory.StartNew(() =>
          {
              while (true)
              {
                  int curUrlIX = Interlocked.Increment(ref urlIX);
                  if (curUrlIX >= urls.Count)
                      break;
                  string url = urls[curUrlIX];
                  try
                  {
                      var req = (HttpWebRequest)WebRequest.Create(url);
                      using (var res = (HttpWebResponse)req.GetResponse())
                      using (var resStream = res.GetResponseStream())
                      using (var fileStream = File.Create(Path.Combine(folder, Guid.NewGuid() + url.Substring(url.LastIndexOf('.')))))
                          resStream.CopyTo(fileStream);
                  }
                  catch (Exception ex)
                  {
                      Console.WriteLine("Error downloading img: …
Run Code Online (Sandbox Code Playgroud)

c# multithreading task-parallel-library

11
推荐指数
2
解决办法
505
查看次数

限制flexbox项目的高度

我有一个带有2个项目的flexbox,direction = row.第二项的文本内容很长.我希望第二项与第一项一样高,并有一个滚动条.这可能吗?

#wrap { display: flex; }
#item-1 { height: 100px; background: orange; flex: 1; }
#item-2 { overflow: scroll; flex: 1; }
Run Code Online (Sandbox Code Playgroud)
<div id='wrap'>
  <div id='item-1'></div>
  <div id='item-2'>  
I would like this text to have a scrollbar, and thus not take up more height than the orange box.<br> I would like this text to have a scrollbar, and thus not take up more height than the orange box.<br> I would like this text to have a scrollbar, and …
Run Code Online (Sandbox Code Playgroud)

html css flexbox

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

在Cordova Android中推送通知图标

我正在使用Phonegap Push Plugin,当通知区域显示推送通知时,图标只是一个白色方块.我希望它显示出来star.png.我想下面的文件如下:

我把star.pngwww/images,并添加以下行config.xml

<platform name="android">
  <resource-file src="www/images/star.png" target="res/drawable-xhdpi/star.png" />
  <resource-file src="www/images/star.png" target="res/drawable-hdpi/star.png" />
  <resource-file src="www/images/star.png" target="res/drawable-mdpi/star.png" />
  <resource-file src="www/images/star.png" target="res/drawable-ldpi/star.png" />
</platform>
Run Code Online (Sandbox Code Playgroud)

(我知道我应该使用不同的分辨率,但我只是想让它现在正常工作.)

然后当我初始化插件时,我使用:

let push = PushNotification.init({
    android: { senderID: globalData.firebaseSenderID, icon: 'star.png', iconColor: 'blue' },
    ios: {}
});
Run Code Online (Sandbox Code Playgroud)

我也试过了icon: 'star'.然而,白色方块仍然存在.我怎样才能让它发挥作用?

使用cordova@8.0.0和cordova-android@6.4.0.

android push-notification cordova

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

使用SCH_CRED_FORMAT_CERT_HASH时,AcquireCredentialsHandle在内核模式下失败

我叫AcquireCredentialsHandle在内核驱动程序,传递SCHANNEL_CREDdwCredFormat设置为SCH_CRED_FORMAT_CERT_HASH.它失败了SEC_E_NO_CREDENTIALS.这是我的代码:

BYTE certHashBytes[20] = { 0x6d,0x64,0xed,0x56,0xd2,0x94,0x15,0xf4,0x49,0x08,0xaf,0x18,0xf1,0xca,0xf5,0xa2,0xc8,0x01,0x20,0x96 };
CredHandle credHandle;
RtlZeroMemory(&credHandle, sizeof(CredHandle));

SCHANNEL_CRED schannelCred;
RtlZeroMemory(&schannelCred, sizeof(SCHANNEL_CRED));
schannelCred.dwVersion = 4;
schannelCred.cCreds = 1;
schannelCred.paCred = certHashBytes;
schannelCred.dwCredFormat = 1;

UNICODE_STRING unispName;
RtlUnicodeStringInit(&unispName, L"Microsoft Unified Security Protocol Provider");
TimeStamp ts;

SECURITY_STATUS res = AcquireCredentialsHandle(NULL, &unispName, SECPKG_CRED_INBOUND, NULL, &schannelCred, NULL, NULL, &credHandle, &ts);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_INFO_LEVEL, "AcquireCredentialsHandle %x\n", res);
Run Code Online (Sandbox Code Playgroud)

我的证书哈希肯定是正确的,并且在MY商店中正确安装,用于用户帐户和本地计算机.我知道这是因为它在用户模式下工作正常,如下所示:

HCERTSTORE certStore = CertOpenSystemStore(NULL, L"MY");
BYTE certHashBytes[20] = { 0x6d,0x64,0xed,0x56,0xd2,0x94,0x15,0xf4,0x49,0x08,0xaf,0x18,0xf1,0xca,0xf5,0xa2,0xc8,0x01,0x20,0x96 };
CERT_NAME_BLOB certHash { 20, …
Run Code Online (Sandbox Code Playgroud)

c c++ schannel wdk kmdf

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

Cordova错误 - "npm不支持Node.js v0.12.9"

当我在Visual Studio中构建我的Cordova项目时,它给出了一个错误"npm不支持Node.js v0.12.9",即使我安装了v6.10.3.我尝试了最新版本的npm,x86和x64.

它曾经工作,不知道是什么打破了它.

visual-studio npm cordova visual-studio-cordova

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

在 Chrome 中呈现但不在 Acrobat 中呈现的 PDF

%PDF-1.7
4 0 obj
<</Type/ObjStm/N 3/First 14/Length 139>>
stream
1 0 2 41 3 76 <</Type/Catalog/Version/1.7/Pages 2 0 R>><</Type/Pages/Kids[3 0 R]/Count 1>><</Type/Page/MediaBox[0 0 200 200]/Parent 2 0 R>>
endstream
endobj
5 0 obj
<<
    /Root 1 0 R
    /ID[<7F1FE2C507E6DB4CB0787E660F2B0C65><2450E4E8FF5FC84380428886C0DD4C2F>]
    /Size 6
    /Index[1 5]
    /W[1 4 1]
    /Type/XRef
    /Length 68
    /Filter[/ASCIIHexDecode]
>>
stream
020000000400
020000000401
020000000402
010000000A00
01000000E500
endstream
endobj
startxref
229
%%EOF
Run Code Online (Sandbox Code Playgroud)

上面的 PDF 在 Chrome(或 Edge)中打开,但在 Adob​​e Acrobat(阅读器)中崩溃。Ghostscript 也认为它很好。请注意,它假定换行符为 CRLF。

我阅读了与基本 PDF 相关的 PDF 规范部分,似乎上面的语法遵循它。为什么 Adob​​e 不喜欢它?

这是PDF …

pdf

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

理解COM c#接口

Microsoft.Office.Interop.Word._Document接口有一个带有以下签名的方法:

void Close(ref object SaveChanges = Type.Missing, ref object OriginalFormat = Type.Missing, ref object RouteDocument = Type.Missing);
Run Code Online (Sandbox Code Playgroud)

有几点我无法理解:

  1. ref参数不能具有默认值.
  2. 默认值必须是常量,而Type.Missing不是.
  3. 调用这个方法时,我可以使用Close(false)- 通常一个ref参数需要一个可赋值的变量?
  4. 导航到TypeVisual Studio中的定义时,它会将我带到_Document.Type属性,但是它没有名为的属性Missing.这是VS中的一个错误吗?

谢谢你的任何解释.

c# com com-interop

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

在文本框上滑动时,iPhone滚动错误

我有一个包含以下html 的网页:

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
    <div style='display:flex;flex-direction:column;height:100%;'>
        <div style='overflow:auto'>
            <div style='height:500px; background:green;'></div>
            <div class='container'>
                <div class='row'>
                    <div class='col-sm-6'>
                        <input type='text' style='' class='form-control' placeholder='swipe here' />
                    </div>
                </div>
            </div>
            <div style='height:500px; background:blue;'></div>
        </div>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

将其加载到iPhone上.尝试通过滑动来上下滚动.现在尝试通过在"滑动此处"的文本框中开始滑动来滚动.对我来说,当我这样做时它不会滚动.我正在使用iPhone 6S.

这是一个错误吗?我该如何解决这个问题?

html css safari ios

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

在实体框架查询中引用临时表

内存中有一个包含50,000 个产品 ID 的列表。我想从数据库获取所有这些产品。使用dbContext.Products.Where(p => list.contains(p.ID))在 SQL 中生成一个巨大的 IN - WHERE ID IN (2134,1324543,5675,32451,45735...),并且需要很长时间。部分原因是SQL Server解析这么大的字符串需要时间,而且执行计划也很糟糕。(我通过尝试使用临时表知道这一点)。

所以我使用 SQLBulkCopy 将 ID 插入到临时表中,然后运行

dbContext.Set<Product>().SqlQuery("SELECT * FROM Products WHERE ID IN (SELECT ID FROM #tmp))"
Run Code Online (Sandbox Code Playgroud)

这提供了良好的性能。但是,现在我需要产品及其供应商(每种产品有多个)。使用自定义 SQL 命令无法取回我所知道的复杂对象。那么我如何使用临时表从供应商那里获取产品呢?

(如果我可以以某种方式引用 LINQ 中的临时表,那么就可以了 - 我可以这样做dbContext.Products.Where(p => dbContext.TempTable.Any(t => t.ID==p.ID))。如果我可以在 UDF 中引用它,那也很好 - 但你不能。我不能使用真正的表,因为并发用户会使它处于不一致的状态。)

谢谢

c# sql sql-server entity-framework

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