小编Ism*_*sma的帖子

哈希表如何工作?

我正在寻找哈希表如何工作的解释 - 用像我这样的傻瓜的简单英语!

例如,我知道它需要密钥,计算哈希值(我正在寻找解释如何)然后执行某种模数来计算它存储在存储值的数组中的位置,但这就是我的知识停止的地方.

任何人都可以澄清这个过程吗?

编辑:我没有具体询问如何计算哈希码,而是概述哈希表的工作原理.

hash hashtable modulo data-structures

477
推荐指数
11
解决办法
27万
查看次数

显示Jupyter Python Notebook中的所有数据帧列

我想在Jupyter Notebook中显示数据框中的所有列.Jupyter显示了一些列,并在最后一列中添加了点,如下图所示:

Juputer截图

如何显示所有列?

python dataframe python-3.x jupyter-notebook

61
推荐指数
6
解决办法
6万
查看次数

如何阻止ASP.NET Core 2.0 MVC缩小修改特定文件?

在ASP.NET Core 2.0 MVC中执行Bundling和Minification,但是当它不应该发生缩小时我遇到了一个问题.在我的页面中,我有以下脚本标记:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"
        integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"
        crossorigin="anonymous"
        asp-fallback-test="window.jQuery"
        asp-fallback-src="~/js/jquery.min.js">
</script>
Run Code Online (Sandbox Code Playgroud)

在我的bundleconfig.json中,我有以下部分:

{
    "outputFileName": "wwwroot/js/jquery.min.js",
    "inputFiles": [
        "node_modules/jquery/dist/jquery.min.js"
    ],
    "minify": {
        "enabled": false
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是〜/ js/jquery.min.js文件在通过此捆绑/缩小过程转换时丢失其尾随换行符,这使得文件的预期散列不再匹配.作为一种解决方法,我可以为完整性值指定2个哈希,以支持包含或不包含换行符的文件,如下所示:

integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT sha384-I7/UTpkJas2maMjJpGmrvEgQecqO8Dta/9Wwh+cQrH6Jj984WRRFhWg4MV/oTkIW"
Run Code Online (Sandbox Code Playgroud)

但这不仅仅是确保缩小不会触及此文件.如何阻止这条新线被修剪?

javascript visual-studio bundling-and-minification asp.net-core asp.net-core-2.0

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

如何删除在特定相册中添加但在其他相册中没有添加的照片?

我想知道swift和xcode:我如何删除在特定专辑中添加但在其他专辑中没有添加的照片.例如相机卷中添加的照片但其他相册中没有?我原则上知道,苹果只是在其他专辑中将它作为相机卷中相同照片的参考链接,所以如果在一个中删除,你将删除所有其他相册.但它有可能绕过它吗?例如,将其作为文件副本复制到具有不同名称的新相册?任何人都知道如何解决它?

谢谢,

xcode cocos2d-iphone ios swift

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

WPF RichTextBox SpellCheck ComException

我试图在某些Windows 8.1机器上启用拼写检查时遇到异常(两者都有最新更新,操作系统语言是俄语,.NET框架4.7是俄语)说:

System.Reflection.TargetInvocationException:调用目标抛出了异常.---> System.Runtime.InteropServices.COMException:Windows.Data.Text.WordsSegmenter..ctor处的System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)中的注册表值(来自HRESULT的异常:0x80040153(REGDB_E_INVALIDVALUE))无效()字符串语言)---内部异常堆栈跟踪的结束---在System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr,Binder binder)的System.RuntimeMethodHandle.InvokeMethod(Object target,Object []参数,Signature sig,Boolean构造函数)中,对象[]参数,CultureInfo文化)在MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter..ctor(String language)的MS.Internal.WindowsRuntime.ReflectionHelper.ReflectionNew [TArg1](类型类型,TArg1 arg1)在Syst的System.Windows.Documents.WinRTSpellerInterop.EnsureWordBreakerAndSpellCheckerForCulture(CultureInfo culture,Boolean throwOnError)的MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter.Create(String language,Boolean shouldPreferNeutralSegmenter)系统.Windows.Documents.WinRTSpellerInterop..ctor()在System.Windows.Documents.SpellerInteropBase.CreateInstance()处于System.Windows.Documents.Speller.EnsureInitialized()处于System.Windows.Documents.Speller.SetCustomDictionaries(CustomDictionarySources dictionaryLocations, System.Windows上的System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)上的System.Windows.Controls.SpellCheck.OnIsEnabledChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)中的System.Windows.Documents.TextEditor.SetCustomDictionaries(Boolean add)处的布尔添加)在System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs参数)在System.Windows.DependencyObject.UpdateEffectiveValue(entryIndex entryIndex,的DependencyProperty DP,PropertyMetadata元数据,EffectiveValueEntry oldEntry,EffectiveValueEntry&newEntry,布尔coerceWithDeferredReference,布尔coerceWithCu .FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs E)System.Windows.DependencyObject.SetValue(DependencyProperty dp,Object value)中的System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp,Object value,PropertyMetadata metadata,Boolean coerceWithDeferredReference,Boolean coerceWithCurrentValue,OperationType operationType,Boolean isInternal)中的rrentValue,OperationType operationType)

此代码可用于重现该问题:

var richTextBox = new RichTextBox();
InputLanguageManager.SetInputLanguage(richTextBox,CultureInfo.GetCultureInfo("en-US"));
richTextBox.SetValue(SpellCheck.IsEnabledProperty, true);
Run Code Online (Sandbox Code Playgroud)

在研究这个问题时,我发现异常是从s_WinRTType描述类型"Windows.Data.Text.WordsSegmenter,Windows,ContentType = WindowsRuntime.WindowsSegmenter似乎是WinRT组件的s_WinRTType.ReflectionNew<string>(language);地方抛出的,所以我看不到里面发生了什么.我想要要知道它为什么抛出REGDB_E_INVALIDVALUE /它寻找的值以及它应该是什么样的?谢谢!

更新1.我还看到该组件的密钥存在于注册表中: 在此输入图像描述 所以这个组件可能会抛出异常

c# wpf spell-checking richtextbox windows-runtime

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

await Task.WhenAll(tasks)异常处理,记录任务中的所有异常

我试图弄清楚如何报告下面的代码中的任务列表抛出的所有异常.

此代码段的基本思想是:用户向处理程序发送请求,处理程序创建消息tasks并将它们发送到将它们发送到外部系统的类.我包括了下面涉及的方法.

我必须要有一些东西,因为我正在调试异常处理程序,并且任务Exception始终为null,因为它似乎是状态,Waiting for Activiation除非我留在断点足够长的时间.

// Handle the user request
public async void Handle(WriteScanToSys settings)
{
  _successfulScanIds = new List<int>();

  // create the messages as tasks
  var tasks = _factory.CreateMessage(settings).Select(msg => SendScans(msg));

  try
  {
    // wait for all of them to complete
    await Task.WhenAll(tasks); // I had ConfigureAwait(false) here, but took it off
  }
  catch (Exception)
  {
    foreach (var task in tasks.Where(t => t.Exception != null))
    {
      // ELMAH
      var errorLog = ErrorLog.GetDefault(null);
      errorLog.Log(new Error(task.Exception));
    } …
Run Code Online (Sandbox Code Playgroud)

c# asynchronous exception-handling async-await

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

PyQt 保持纵横比固定

我正在研究 PyQt5 GUI,到目前为止,我只是有使用 python 脚本的经验,并没有深入研究创建用户界面。

GUI 必须用于不同的屏幕(可能还有一些旧的 4:3 比例屏幕),并且需要在不同尺寸下看起来不错。现在,我让我的生活更轻松的方法是强制执行窗口的固定纵横比并根据窗口大小调整不同元素的大小。

from PyQt5 import QtCore, QtGui, QtWidgets

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self, parent= None):
        super().__init__(parent)
        self.form_widget = FormWidget(self)
        self.setCentralWidget(self.form_widget)
        self.resize(200, 400)
        self.sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        self.sizePolicy.setHeightForWidth(True)
        self.setSizePolicy(self.sizePolicy)

    def heightForWidth(self, width):
        return width * 2

class FormWidget(QtWidgets.QWidget):

    def __init__(self, parent):
        super().__init__(parent)

    def resizeEvent(self, event):
        f = self.font()
        temp = event.size().height()
        f.setPixelSize(temp / 16)
        self.setFont(f)

        return super().resizeEvent(event)


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)

    w = MainWindow()
    w.show()
    sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)

根据窗口大小调整元素大小工作正常,但根本不保留窗口纵横比。我heightForWidth从旧的 PyQt4 …

python pyqt aspect-ratio python-3.x pyqt5

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

Nuget command fails in docker file but not when run manually

I am trying to configure a container to run my build. (It is a windows core container.)

When I run a nuget command in the docker file, it fails. But when I connect powershell to the container, it runs fine.

This is the command in question:

nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common
Run Code Online (Sandbox Code Playgroud)

I run it from the docker file like this:

RUN nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common
Run Code Online (Sandbox Code Playgroud)

And get the following error:

sources: invalid arguments. …
Run Code Online (Sandbox Code Playgroud)

containers nuget docker dockerfile

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

jQuery datepicker - 如何更改"今天"日期?

有没有办法在jquery.ui datepicker中更改"今天"日期?今天,我的意思是今天(class ="ui-datepicker-today")而不是minDate或当前选择的日期!

我发现,该datepicker使用系统时间作为默认值.现在我从服务器获取当前日期并将其设置为我的minDate.但我没有找到设置今天日期的方法......它仍然使用我的系统日期(有一些用户,其系统日期是在2000年或更早).

你能帮我吗?

javascript jquery datepicker

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

托管在Linux上的Visual Studio远程调试应用程序 - 无法在特定进程中枚举CoreCLR的运行实例

我正在尝试远程调试在Linux上托管的应用程序

"Debian GNU/Linux 8(jessie)"

.NET命令行工具(2.1.500)

我通过SSH连接Visual Studio

我尝试了两种模式:

  • 适用于Unix的托管.NET Core

  • 原生(GDB)

项目已在Windows上编译

dotnet publish --configuration Release -r linux-x64
Run Code Online (Sandbox Code Playgroud)

并且

dotnet publish --configuration Debug -r linux-x64
Run Code Online (Sandbox Code Playgroud)

并且工作得非常好,但出于某种原因,我收到了:

适用于Unix的托管.NET Core:

无法附加到进程:无法枚举特定进程中正在运行的CoreCLR实例


如果这是相关的(可能不是,因为其他人使用Managed .NET Core for Unix)

Native(GDB): 无法启动调试.无法建立与GDB的连接.调试输出可能包含更多信息

调试信息:

Starting unix command: 'gdb --interpreter=mi'
bash: gdb: command not found
gdb --interpreter=mi exited with code 127.
Run Code Online (Sandbox Code Playgroud)

在Visual Studio中,进程列为:

Process: MyProjectName

Title: /home/deploy/app/MyProjectName StartUpArgument
Run Code Online (Sandbox Code Playgroud)

有人知道是什么原因引起的吗?

你可以在这里看到人们如何使用Raspberry Pi做到这一点:

https://youtu.be/ySzTCl-H10w?t=955

c# remote-debugging visual-studio .net-core

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