小编sha*_*haz的帖子

杰克逊JSON字段映射大写?

我不清楚杰克逊如何处理绘图领域的资本化.如果有人可以提供帮助,我会很感激.

{"user":{"username":"user@host.com","password":"pwd","sendercompid":"COMPID","service":{"host":"address","port":6666,"service":"S1","serviceAsString":"s1"}},"MDReqID":"ghost30022","NoRelatedSym":1,"Symbol":["GOOG"],"MarketDepth":"0","NoMDEntryTypes":3,"MDEntryType":["0","1","2"],"SubscriptionRequestType":"1","AggregatedBook":"N"}:
Run Code Online (Sandbox Code Playgroud)

上面是我的json,下面是我的例外......

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "MDReqID" (class com.myco.qa.fixrest.MarketDataRequest), not marked as ignorable (10 known properties: , "mdreqID", "marketDepth", "user", "subscriptionRequestType", "aggregatedBook", "mdentryType", "symbol", "mdupdateType", "noRelatedSym", "noMDEntryTypes"])
Run Code Online (Sandbox Code Playgroud)

以上是我的例外,下面是我的班级......

public class MarketDataRequest {
    private User user;
    private String MDReqID;
    private char SubscriptionRequestType;
    private int MarketDepth;
    private int MDUpdateType;
    private char AggregatedBook;
    private int NoMDEntryTypes;
    private ArrayList<Character> MDEntryType;
    private int NoRelatedSym;
    private ArrayList<String> Symbol;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String …
Run Code Online (Sandbox Code Playgroud)

java json jackson

37
推荐指数
3
解决办法
4万
查看次数

在从Java中的方法返回之前需要等待异步api回调

  import java.util.concurrent.CountDownLatch;

  import quickfix.Initiator;


  public class UserSession {
    private final CountDownLatch latch = new CountDownLatch(1);

public String await() {
        try {
            System.out.println("waiting...");
            if (latch.await(5, TimeUnit.SECONDS))
                System.out.println("released!");
            else
                System.out.println("timed out");
            return secret;
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            System.out.println(e.getMessage());
            e.printStackTrace();
        }
        return null;
    }

    public void countdown(String s) {
        System.out.println("In countdown: "+s+ ". Latch count: "+latch.getCount());
        secret = s;
        latch.countDown();
        System.out.println("Latch count: "+latch.getCount());
    }
  }


  public class LogonHandler extends AbstractHandler {

    public void handle(String target, Request baseRequest, …
Run Code Online (Sandbox Code Playgroud)

java concurrency asynchronous callback

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

提升asio deadline_timer

我期待下面的代码打印Hello,world!每5秒钟,但会发生的是程序暂停5秒钟,然后一遍又一遍地打印消息而没有后续暂停.我错过了什么?

#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

using namespace boost::asio;
using namespace std;

io_service io;

void print(const boost::system::error_code& /*e*/)
{
  cout << "Hello, world!\n";
  deadline_timer t(io, boost::posix_time::seconds(5));
  t.async_wait(print);
}


int main()
{

  deadline_timer t(io, boost::posix_time::seconds(5));
  t.async_wait(print);

  io.run();

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

编辑以在下面添加工作代码.多谢你们.

#include <iostream>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

using namespace boost::asio;
using namespace std;

class Deadline {
public:
    Deadline(deadline_timer &timer) : t(timer) {
        wait();
    }

    void timeout(const boost::system::error_code &e) {
        if (e)
            return;
        cout << "tick" << …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-asio

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

在Sublime Text 2中,Scala REPL"粘贴"模式不会退出ctrl-D

有没有人见过这个问题?启动scala REPL和

scala> :paste
// Entering paste mode (ctrl-D to finish)

val x = 5
Run Code Online (Sandbox Code Playgroud)

ctrl-D不会导致REPL完成粘贴模式.

scala read-eval-print-loop sublimetext2 sublimerepl

9
推荐指数
1
解决办法
947
查看次数

带有{x,y}点数据的折线图仅显示2个值

https://codepen.io/shaz1234/pen/PEKjOV

Codepen有我的代码

new Chart(document.getElementById("chartjs-0"),                    {
    "type":"line",
    "data": {
              "datasets": [
                 { 
                   "label":"My First Dataset",
                   "data": [
                     {x: 0, y: 65}, 
                     {x: 4, y: 59}, 
                     {x: 100, y: 80}, 
                     {x: 110, y: 81}, 
                     {x: 125, y: 56}
                    ],
                   "fill":false,
                   "borderColor":"rgb(75, 192, 192)",
                   "lineTension":0.1
                 }
              ]
             },
             "options":{
             }
          }
     );
Run Code Online (Sandbox Code Playgroud)

非常简单的示例,但图表仅显示前两个点。我希望图表能够缩放到提供的最小和最大值x。我会误解点折线图是如何设计的,还是出现错误?

在此先感谢您的关注。

chart.js

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

从流中动态导入Javascript模块

目标:支持基于某些安全性或定义的用户角色要求的动态加载Javascript模块,这样,即使在开发工具中标识了模块名称,也无法通过控制台成功导入。

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

可以轻松地将JavaScript模块上载到Firebase(#AskFirebase)之类的云存储服务,并且可以firebase.functions().httpsCallable("ghost");基于自定义声明或类似测试的使用Firebase Cloud Function有条件地检索代码。

export const ghost = functions.https.onCall(async (data, context) => {
  if (! context.auth.token.restrictedAccess === true) {
    throw new functions.https.HttpsError('failed-precondition', 'The function must be called while authenticated.');
  }

  const storage = new Storage();
  const bucketName = 'bucket-name.appspot.com';
  const srcFilename = 'RestrictedChunk.chunk.js';

  // Downloads the file
  const response = await storage
    .bucket(bucketName)
    .file(srcFilename).download();
  const code = String.fromCharCode.apply(String, response[0])

  return {source: code};

})
Run Code Online (Sandbox Code Playgroud)

最后,我想做的是...

...将一个Webpack的React组件放入云端,在服务器端进行安全检查后有条件地将其下载到客户端,然后将import()其下载到用户的客户端环境中并进行渲染。

将Javascript存储在云中并有条件地下载到客户端很容易。在客户端中有了webpack的代码后,就可以像Function(downloadedRestrictedComponent)将其使用时那样将其添加到用户环境中,import('./RestrictedComponent')但是我不知道是如何从组件中获取默认导出的,以便我可以实际渲染事情。

import(pathToComponent)返回加载的模块,据我所知,没有选项传递import()字符串或流,而只是传递模块的路径。并且Function(downloadedComponent) …

javascript firebase reactjs webpack react-loadable

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

如何从Int或Byte初始化枚举?

我有这样的枚举:

object Ops extends Enumeration {
  val one = Value(0x01)
  val two = Value(0x02)
  val three = Value(0x03)
  val four = Value(0x04)
}
Run Code Online (Sandbox Code Playgroud)

我想说

Byte someByte = functionThatReturnsAByte
val op = Ops.valueOf(someByte)
Run Code Online (Sandbox Code Playgroud)

唯一的close方法是withName,它只接受一个String.

enumeration scala

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

React-Redux Counter 示例动作触发两次

https://codesandbox.io/s/jvj6o043yv

我正在尝试使用非常简单的 Counter 示例来了解 react-redux connect、Provider 和 mapStateToProps 和 MapDispatchToProps 的基础知识。练习的重点是将道具和动作注入到 Counter 组件中。

我看到的问题是,每次单击按钮时,我的操作都会触发两次。我是 Redux 菜鸟,所以我确定(我希望)这是一个相当基本的错误。我很感激任何指出我出错的地方。提前致谢。

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { connect } from 'react-redux'
import { createStore, applyMiddleware } from 'redux';
import { createLogger } from 'redux-logger';


// Reducer
const counter = (state = 0, action) => {
  switch (action.type) {
    case 'INCREMENT':
      return state + 1;
    case 'DECREMENT':
      return state - 1;
    default:
      return state;
  }
} …
Run Code Online (Sandbox Code Playgroud)

react-redux

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

Noob boost :: bind成员函数回调问题

#include <boost/bind.hpp>
#include <iostream>

using namespace std;
using boost::bind;

class A {
public:
    void print(string &s) {
        cout << s.c_str() << endl;
    }
};


typedef void (*callback)();

class B {
public:
    void set_callback(callback cb) {
        m_cb = cb;
    }

    void do_callback() {
        m_cb();
    }

private:
    callback m_cb;
};

void main() {
    A a;
    B b;
    string s("message");
    b.set_callback(bind(A::print, &a, s));
    b.do_callback();

}
Run Code Online (Sandbox Code Playgroud)

所以我想要做的是在激活b的回调时将A流"消息"的打印方法设置为cout.我从msvc10得到了意外数量的参数错误.我确定这是超级noob基本的,我很抱歉.

c++ boost bind

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

cmake中的奇怪字符"â"生成了makefile错误

可怕的头衔,抱歉.我使用cmake生成一个makefile,并且我将g ++指定为C++编译器,当我使用make或gmake运行生成的makefile时,我得到所有这些编译错误,并且我的所有符号都在它们上面.关于这些神秘的背后可能是什么的任何想法?

c++ unix gnu cmake

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

C++ for_each调用回调函数的向量并向每个函数传递一个参数

当涉及到c ++ 0x,lambda等时,我是相当绿色的,所以我希望你们可以帮助我解决这个小问题.

我想在向量中存储一堆回调,然后在时机成熟时使用for_each来调用它们.我希望回调函数能够接受参数.这是我现在的代码.问题在于void B :: do_another_callbacks(std :: string&)

#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <vector>
#include <iostream>
#include <algorithm>



class A {
public:
    void print(std::string &s) {
        std::cout << s.c_str() << std::endl;
    }
};

typedef boost::function<void(std::string&)> another_callback;
typedef boost::function<void()> callback;

typedef std::vector<callback> callback_vector;
typedef std::vector<another_callback> another_callback_vector;

class B {
public:
    void add_callback(callback cb) {
        m_cb.push_back(cb);
    }

    void add_another_callback(another_callback acb) {
        m_acb.push_back(acb);
    }

    void do_callbacks() {
        for_each(m_cb.begin(), m_cb.end(), this);
    }

    void do_another_callbacks(std::string &s) {
        std::tr1::function<void(another_callback , std::string &)> my_func = [] …
Run Code Online (Sandbox Code Playgroud)

c++ foreach lambda callback

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

试图用boost :: asio :: async_read替换我的boost :: asio :: read

所以,我开始使用的代码和工作的代码(下面有重要的警告)

int reply_length = boost::asio::read(*m_socketptr, boost::asio::buffer((char*)reply, 6));
Run Code Online (Sandbox Code Playgroud)

这工作,我得到标题,然后我解码并跟进另一个读取,让我得到我的消息,然后我循环回到顶部,并阅读另一个标题.这将我的CPU固定在100%所以我想用以下内容替换上面读取的标题:

m_socketptr->async_read_some(boost::asio::buffer(m_data, 6), boost::bind(&CSListener::handleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
Run Code Online (Sandbox Code Playgroud)

要么

boost::asio::async_read(*m_socketptr, boost::asio::buffer(m_data, 6), boost::bind(&CSListener::handleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
Run Code Online (Sandbox Code Playgroud)

无论哪种方式我编码它,handleRead方法永远不会被调用.救命!?

TIA

c++ boost asynchronous boost-asio

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

"vector iterator not incrementable"运行时错误与set_intersection

为什么这段代码会导致运行时错误"vector iterator not incrementable"?

vector<string> s1, s2;

 s1.push_back("joe");
 s1.push_back("steve");
 s1.push_back("jill");
 s1.push_back("svetlana");

 s2.push_back("bob");
 s2.push_back("james");
 s2.push_back("jill");
 s2.push_back("barbara");
 s2.push_back("steve");

 sort(s1.begin(), s1.end());
 sort(s2.begin(), s2.end());

 vector<string> result;
 vector<string>::iterator it_end, it_begin;
 it_end = set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), result.begin());
 cout << int (it_end - result.begin()) << endl;
 for_each(result.begin(), result.end(), print);
Run Code Online (Sandbox Code Playgroud)

c++ stl stl-algorithm

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