小编ouf*_*lak的帖子

Zlib adler32滚动校验和问题

我正在使用zlib的adler32函数来计算一块内存x(长度为4096)的弱校验和.一切都很好,但是现在我想执行滚动校验和,如果来自不同文件的块不匹配,但是,我不知道如何编写一个函数来执行zlib中adler32返回的值.因此,如果校验和不匹配,如何使用原始校验和,x + 1字节和x + 4096 + 1来计算滚动校验和?基本上试图建立rsync实现.

提前致谢.

rsync checksum zlib adler32

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

如何从浏览器调用我的WCF服务?

我正在编写一个web服务,假设将json两个json字符串保存到DB.我可以使用sope UI和WCF Test Client调用它,但我无法通过浏览器调用它.有办法做到这一点吗?

该服务最初将由Android应用程序使用,我已经尝试从它运行,没有任何运气.

提前致谢.

这是我服务的界面

 [ServiceContract]
public interface IRService
{
    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Wrapped,
       UriTemplate = "SaveCallResults?callInfo={callInfo}&testInfo={testInfo}")]
    string SaveCallResults(string callInfo, string testInfo);
}
Run Code Online (Sandbox Code Playgroud)

这是我的web.config

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_RService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false"            hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536"
      textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
      messageEncoding="Text">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" /> …
Run Code Online (Sandbox Code Playgroud)

c# web-services asp.net-mvc-4

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

更改字体样式后,Android 应用程序在三星设备上崩溃

当我尝试更改设备的字体 (Samsung Galaxy Tab3) 时,应用程序出现问题,即我的应用程序崩溃。在这种情况下,当我更改字体时,应用程序正在后台运行。

脚步:

  • 启动应用程序
  • 使用状态栏打开设备设置
  • 更改设备的字体样式
  • 使用最近的应用程序返回应用程序
  • 碰撞

我试图在其他设备上测试这个场景,但无法重现。我的应用程序仅在三星设备上崩溃,并且仅在系统字体样式更改时崩溃。

附上崩溃日志:

07-22 12:26:09.359: E/AndroidRuntime(8110): FATAL EXCEPTION: main
07-22 12:26:09.359: E/AndroidRuntime(8110): java.lang.NullPointerException
07-22 12:26:09.359: E/AndroidRuntime(8110):     at com.acs.nomad.app.widget.h.a(Unknown Source)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at com.acs.nomad.app.b.ap.m(Unknown Source)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at com.acs.nomad.app.d.v.onPause(Unknown Source)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at android.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1129)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at android.app.BackStackRecord.popFromBackStack(BackStackRecord.java:662)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at android.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1450)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at android.app.FragmentManagerImpl$2.run(FragmentManager.java:444)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1401)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
07-22 12:26:09.359: E/AndroidRuntime(8110):     at …
Run Code Online (Sandbox Code Playgroud)

performance android android-fonts android-fragments android-settings

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

作曲家无法解码响应:zlib_decode()

我正在尝试安装crudkit.com。这是我的composer.json:

{
    "description" : "The CodeIgniter framework",
    "name" : "codeigniter/framework",
    "license": "MIT",
    "require": {
        "php": ">=5.2.4"
    },
    "require-dev": {
        "mikey179/vfsStream": "1.1.*"
    }

}
Run Code Online (Sandbox Code Playgroud)

之后,我使用以下命令运行作曲家:

$ sudo php composer.phar install
Run Code Online (Sandbox Code Playgroud)

但我有这样的错误:

Installing dependencies (including require-dev)
Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
Run Code Online (Sandbox Code Playgroud)

有人知道如何解决吗?

更新:我已经尝试作曲家诊断,并且我得到了:

Checking composer.json: FAIL
The version field is present, it is recommended to leave it out if the package is published on Packagist.
Checking platform settings: FAIL
The OpenSSL …
Run Code Online (Sandbox Code Playgroud)

php

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

基于微服务的后端-概念

我计划基于微服务构建后端。下图展示了我当前的想法:

在此处输入图片说明

两个重要功能是:

  • 上载大型文字和/或视频文件
  • 流视频-在Web应用程序和本机移动应用程序中显示用户

最终没有确定技术栈,但最初我想到的是:

  • 网路应用程式-ReactJs / Angular
  • 后端应用程序-Ruby on Rails

我对当前的概念有以下疑问:

  1. API Gateway是否应该充当路由器,将用户的请求重定向到特定的微服务?或者...应该是带有API的专用应用程序(例如Ruby on Rails应用程序)吗?
  2. 如何进行授权?我应该为此使用单独的微服务吗?假设用户上传文件,而他的请求应该转到第三个微服务:“大数据上传”。我应该在何时何地授权他访问?在那个微服务或更早的API Gateway中?还是应该在“身份验证微服务”中进行身份验证?
  3. 上传大文件-假设用户想通过HTTP将大型文件(带有原始数据的视频或压缩文本文件)从移动应用程序传输到后端。他的请求转到API网关,然后将其重定向到“大数据上传”微服务。应用程序将文件保存到对象存储。是上传文件的正确路径吗?或者我可以做一些捷径来缩短文件的路径?
  4. 视频流-用户上传视频文件时,我想将其放入资产(对象存储-例如Amazon S3)。将此视频呈现给Web应用程序或移动应用程序中的用户是否足够?(除了代码转换器服务和CDN之外)
  5. 负载平衡-使用负载平衡来控制流向微服务实例的流量(在API网关和绿色微服务之间的图片上)是否合理?还是这不是一个好方法,因为我们可能会丢失一些有关请求/收件人/用户的信息,甚至API网关都会成为更严重的“瓶颈”?
  6. 您认为这种架构概念是否具有易于扩展的良好潜力?当然,省略了硬件和软件配置。

cloud distributed ruby-on-rails video-streaming microservices

5
推荐指数
0
解决办法
385
查看次数

Angularjs mdDialog - 如何将数据发送回我的第一个控制器

我使用完美运行的“locals”属性向我的 md-Dialog 发送了一些信息。用户按下按钮后,他将通过 $resource 方法发送一些信息并获得响应。我需要在 md 对话框关闭后显示该响应。如何将该响应发送给我的第一个控制器?

这是示例:

 //Main controller
 app.controller('Postulation_Ctrl', function($scope, $mdDialog,Postulation, Lista_Complejos){

//md-dialog function
    $scope.showPrompt = function(ev){
        var parentEl = angular.element(document.body);

    var confirm = $mdDialog.show({
         parent: parentEl,
         locals: {

            values: $scope.values,
         },
         targetEvent: ev,
         t templateUrl: 'view/example.html',
         controller: function DialogController($scope, $mdDialog, valores, postulaciones,user_id, Postulation) {

        $scope.result = values;
      
        $scope.createPostulation = function(){
            
    
                $scope.postulation = {};
        //some logic
            
        auxPostulation = new Postulation($scope.postulation);
        auxPostulation.$save(null, function(){
        $scope.queryPost();
                );
            }

        $mdDialog.hide();
        }

$scope.queryPost = function() { 
    Postulation.query(function(response){
    $scope.postulations = response; <----------I NEED TO …
Run Code Online (Sandbox Code Playgroud)

controller angularjs angular-material mddialog

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

JavaScript 在 then 函数之外访问 Promise

我正在尝试使用 JavaScript 在 then 函数之外访问 Promise 中的值。我是 Promise 的新手,我不确定我是否做对了。这是我的代码:

//removed code
Run Code Online (Sandbox Code Playgroud)

基本上我已经将 Promise 返回的值存储到 then 函数内的一个单独变量中。我想在后面的部分访问它们,但是当我在后面的部分打印出来时,它返回我未定义。关于如何解决这个问题的任何想法?

我找到了一些例子并遵循了它们,但它不起作用。我不确定我的代码的哪一部分是错误的。我早些时候打开了一个线程,它被标记为重复并关闭。我想我的询问不够清楚,因此我在这里重新表述这个问题。

javascript global-variables promise

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

如何使用python将对数概率转换为0到1之间的简单概率

我正在使用高斯混合模型进行说话人识别。我使用此代码来预测每个语音剪辑的说话者。

for path in file_paths:   
path = path.strip()   
print (path)
sr,audio = read(source + path)
vector   = extract_features(audio,sr)
#print(vector)
log_likelihood = np.zeros(len(models))
#print(len(log_likelihood))
for i in range(len(models)):
    gmm1   = models[i]  #checking with each model one by one
    #print(gmm1)
    scores = np.array(gmm1.score(vector)) 
    #print(scores)
    #print(len(scores))
    log_likelihood[i] = scores.sum()
    print(log_likelihood)
    winner = np.argmax(log_likelihood)
    #print(winner)
print ("\tdetected as - ", speakers[winner])
Run Code Online (Sandbox Code Playgroud)

它给了我这样的输出:

[ 311.79769716    0.            0.            0.            0.        ]
[  311.79769716 -5692.56559902     0.             0.             0.        ]
[  311.79769716 -5692.56559902 -6170.21460788     0.             0.        ]
[ …
Run Code Online (Sandbox Code Playgroud)

python speech-recognition gaussian voice-recognition gmm

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

Azure 表存储 (412) 先决条件失败

我已将 GitHub 解决方案用于URLshortener并将其部署在我的 Azure 租户上。现在突然我收到一个错误:

"Exception while executing function: Functions.UrlIngest. 
Microsoft.Azure.WebJobs.Host: Error while handling parameter keyTable after 
function returned:. Microsoft.WindowsAzure.Storage: The remote server 
returned an error: (412) Precondition Failed."
Run Code Online (Sandbox Code Playgroud)

在研究这个问题时,我找到了一个链接,上面写着:

"If the entity's ETag differs from that specified with the update request,
the update operation fails with status code 412 (Precondition Failed). This 
error indicates that the entity has been changed on the server since it was 
retrieved. To resolve this error, retrieve the entity again …
Run Code Online (Sandbox Code Playgroud)

azure optimistic-concurrency azure-table-storage azure-functions

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

JSPDF 将数组导出为 PDF

我在使用 jsPDF 插件将数组数据导出为 PDF 格式时遇到问题。我第一次导出 PDF 时,格式看起来很棒。但是,在接下来的尝试中,导出为 PDF 时,第一页上会出现一个随机的空白区域。

function JSONToPDFConvertor() {
            var sel = document.getElementById("yourSelect");
            var text = sel.options[sel.selectedIndex].text;
            var data = [];

            // first row needs to be headers
            data.push(["Date & Time", "Location", "Speed", "Ignition", "Odometer", "Batt(V)", "GPS"]);
            // go through cells

            for (var i = 0; i < myArr.Table1.length; i++) {


                var rowData = {};

                rowData[0] = myArr.Table1[i].datetimer;
                rowData[1] = myArr.Table1[i].location;
                rowData[2] = myArr.Table1[i].speed.toString();
                rowData[3] = myArr.Table1[i].ignition;
                rowData[4] = myArr.Table1[i].odometer.toString();
                rowData[5] = myArr.Table1[i].battVolt;
                rowData[6] = myArr.Table1[i].gpsStat;



                data.push(rowData); …
Run Code Online (Sandbox Code Playgroud)

javascript jspdf

5
推荐指数
0
解决办法
238
查看次数