小编Ben*_*ers的帖子

Java日期到毫秒

我正在存储来自亚马逊云的消息,并按照他们在有序地图中的时间戳排序.

我正在使用以下代码从云中解析时间戳:

Date timestamp = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'", Locale.ENGLISH).parse(time);
Run Code Online (Sandbox Code Playgroud)

然后我将它们存储在一个有序的地图中,其中的关键是日期.问题是日期只能达到秒精度.我可以在1秒内发送几条消息,所以我需要它们以毫秒精度订购.是否有允许这样的数据结构?

java time date amazon-web-services

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

Slack API invalid_block

我正在构建一个简单的 Slack 机器人,并且正在使用该checkboxes元素。

当我从 API 以 JSON 响应返回以下内容到斜杠命令时,我收到错误failed with the error "invalid_blocks",但是,当我将其放入block-kit-builder中时,它可以正常工作(包括“发送到 slack”按钮)

当我运行斜杠命令时,有什么想法会失败吗?是否可以从 slack 中看到更详细的错误消息?

{
  "blocks": [
    {
      "elements": [
        {
          "style": "primary",
          "text": {
            "emoji": true,
            "text": "Create new TODO list",
            "type": "plain_text"
          },
          "type": "button",
          "value": "value"
        },
        {
          "style": "primary",
          "text": {
            "emoji": true,
            "text": "Help",
            "type": "plain_text"
          },
          "type": "button",
          "value": "value"
        }
      ],
      "type": "actions"
    },
    {
      "text": {
        "text": "Today",
        "type": "mrkdwn"
      },
      "type": "section"
    }, …
Run Code Online (Sandbox Code Playgroud)

slack-api

13
推荐指数
2
解决办法
3万
查看次数

亚马逊SNS - > SQS消息体

我正在从SNS主题向SQS发送消息.当我在客户端检查SQS消息的正文时,整个消息元数据正在SQS正文中发送.

IE如果我从主题发送消息"Hello World",我的客户端正在接收:

    BenFlowers {
  "Type" : "Notification",
  "MessageId" : "84102bd5-8890-4ed5-aeba-c15fafc926dc",
  "TopicArn" : "arn:aws:sns:eu-west-1:534706846367:HelloWorld",
  "Message" : "hello World",
  "Timestamp" : "2012-06-05T13:44:22.360Z",
  "SignatureVersion" : "1",
  "Signature" : "Qzh0qXhijBKylaFwc9PGE+lQQDwHGWkIzCW2Ld1eVrxNfSem4yyBTgouqGX26V0m1qhFD4RQcBzE3oNqx5jFhJfV4hN45FNcsFVnmfLPGNUTmJWblSk8f6znWgTy8UtK9xrTeNYzK59k3VJ4WTJ5kCEj+2vH7sBV15fAXeCAtdQ=",
  "SigningCertURL" : "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
  "UnsubscribeURL" : "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:534706846367:HelloWorld:8a3acde2-cb0b-4a56-9b9c-b75ed7307556"
}
Run Code Online (Sandbox Code Playgroud)

这有点烦人,因为我不得不在另一端拆分消息体.速度在这个应用程序中非常重要,所以我想消除这个.有没有办法从SNS发送消息并忽略其余的元数据?

谢谢,本

java amazon-sqs amazon-web-services amazon-sns

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

IntelliJ如何生成新类?

当我进入我的项目结构并右键单击 - > new时,我只看到新文件/文件夹等...但没有类生成或包.如何让IntelliJ执行此操作?(我有Intellij 14 Ultimate - 见下图)

的IntelliJ

java intellij-idea intellij-14

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

在构建ResourceTestRule时,dropwizard-testing资源测试会爆炸

我有一个简单的ResourceTest,我试图设置,但是当我尝试构建ResourceTestRule时,我得到以下异常:

ProfilesResourceTest,shouldGetEmptyStuff
    WARN  [2016-05-15 17:44:50,159] org.glassfish.jersey.internal.Errors: The following warnings have been detected: WARNING: HK2 service reification failed for [com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider] with an exception:
    MultiException stack 1 of 2
    java.lang.NoClassDefFoundError: javax/mail/MessagingException
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
        at java.lang.Class.getDeclaredConstructors(Class.java:2020)
        at org.jvnet.hk2.internal.Utilities$3.run(Utilities.java:1311)
        at org.jvnet.hk2.internal.Utilities$3.run(Utilities.java:1307)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.jvnet.hk2.internal.Utilities.getAllConstructors(Utilities.java:1307)
        at org.jvnet.hk2.internal.Utilities.findProducerConstructor(Utilities.java:1250)
        at org.jvnet.hk2.internal.DefaultClassAnalyzer.getConstructor(DefaultClassAnalyzer.java:83)
        at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getConstructor(JerseyClassAnalyzer.java:144)
        at org.jvnet.hk2.internal.Utilities.getConstructor(Utilities.java:179)
        at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:128)
        at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:179)
        at org.jvnet.hk2.internal.SystemDescriptor.internalReify(SystemDescriptor.java:723)
        at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:678)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:463)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2187)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.access$1200(ServiceLocatorImpl.java:121)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$10.compute(ServiceLocatorImpl.java:1331)
        at org.jvnet.hk2.internal.ServiceLocatorImpl$10.compute(ServiceLocatorImpl.java:1326)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:115)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$1.call(LRUHybridCache.java:111)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture.run(LRUHybridCache.java:173)
        at …
Run Code Online (Sandbox Code Playgroud)

java junit dropwizard

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

无服务器API网关将请求转换为base64

我有一个无服务器的应用程序,它将文件上传到s3(通过POST请求)并为它们提供服务(通过GET请求)

我正在使用serverless-apigw-binaryserverless-apigwy-binary插件允许我以图像的形式返回二进制数据.为了允许URL与浏览器一起使用,我必须将二进制类型设置为*/*.

为了上传图像,POST端点采用类似{"base64":"..."}的正文.但是,使用此配置,整个主体将作为base64编码的字符串传递.如何防止请求体application/json被转换?

serverless.yml下文:

service: image-service

custom:
  envName: ${opt:stage, self:provider.stage}
  domains:
    prod: api.<mydomain>
    dev: dev-api.<mydomain>
  customDomain:
    basePath: images
    domainName: ${self:custom.domains.${self:custom.envName}}
    certificateName: "*.<mydomain>"
  apigwBinary:
    types:
      - '*/*'

provider:
  name: aws
  runtime: nodejs8.10
  region: eu-west-1
  memorySize: 1536

  role: ImageRenderingRole

  environment:
    ENV_NAME: ${self:custom.envName}
    APP_NAME: image-service
    BUCKET: <mybucket>

plugins:
  - serverless-offline
  - serverless-domain-manager
  - serverless-apigw-binary
  - serverless-apigwy-binary

functions:
 uploadImage:
   handler: handler.uploadImage
   events:
     - http:
      path: /
      method: POST

  getImage:
    handler: handler.getImage
    events:
      - http: …
Run Code Online (Sandbox Code Playgroud)

aws-api-gateway serverless-framework aws-serverless

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

Cloud Firestore'哎呀,收藏无法加载!'

尝试使用新的Cloud Firestore,但当我选择firestore下拉列表时,数据通道会说:'糟糕,收集无法加载!'

这是否试图将我现有的realtimeDB导入和失败或其他原因?

谢谢,

firebase google-cloud-firestore

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

Java Observer Pattern无法通知

出于某种原因,当我使用java.util.Observable对象调用notifyObserver方法时,我的观察者没有得到通知:

这是我的可观察对象:

public class ProjectManager extends Observable
{
...
 public void updateProjects(String project, String pack, String source, String ARN)
{
   ...
if(newSource)
    {
    tempPack.add(tempSource);
    System.out.println("Notify observers: " + this.countObservers());
    this.notifyObservers();
    }
      ...
      }
Run Code Online (Sandbox Code Playgroud)

我可以从我的输出中看到观察者正在被添加但没有得到通知.

我的观察者对象看起来像这样:

public class IDE implements Observer
{

@Override
public void update(Observable o, Object arg) {

    System.out.println("Notified");

}
Run Code Online (Sandbox Code Playgroud)

由于某些奇怪的原因,可观察对象根本没有得到通知.我在这里做错了吗?

java architecture software-design observer-pattern

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

Java Money - 最小的货币单位

我有一个下游服务 (Stripe),它要求我以最小的货币单位(他们的文档中的零十进制货币)发送货币。即收取 $1 我会发送 { "currency": "USD", amount: 100 } 并收取 ¥100 我会发送 { "currency": "YEN", amount: 100 }

我的上游应用程序不想以这种方式处理货币并希望使用标准货币格式。有没有办法转换javax.money.MonetaryAmount成零十进制货币格式?

还是我必须手动编写转换?

java java-money

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

猫Seq [Xor [A,B]] => Xor [A,Seq [B]]

我有一系列的错误或观点(Seq[Xor[Error,View]])

我想将此映射到第一个错误的Xor(如果有)或视图序列(Xor[Error, Seq[View]])或可能只是(Xor[Seq[Error],Seq[View])

我怎样才能做到这一点?

scala scala-cats

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

在 Kotlin 中组合/合并数据类

有没有办法在不指定所有属性的情况下合并 kotlin 数据类?

data class MyDataClass(val prop1: String, val prop2: Int, ...//many props)
Run Code Online (Sandbox Code Playgroud)

具有以下签名的函数:

fun merge(left: MyDataClass, right: MyDataClass): MyDataClass
Run Code Online (Sandbox Code Playgroud)

这个函数检查两个类的每个属性,它们不同的地方使用 left 参数来创建一个新的 MyDataClass。

使用 kotlin-reflect 或其他方法可以实现吗?

编辑:更清晰

这是我想要做的更好的描述

  data class Bob(
        val name: String?,
        val age: Int?,
        val remoteId: String?,
        val id: String)

@Test
fun bob(){

    val original = Bob(id = "local_id", name = null, age = null, remoteId = null)
    val withName = original.copy(name = "Ben")
    val withAge = original.copy(age = 1)
    val withRemoteId = original.copy(remoteId = "remote_id") …
Run Code Online (Sandbox Code Playgroud)

kotlin kotlin-reflect

4
推荐指数
2
解决办法
9973
查看次数

Webpack无语义UI的模块构建失败

我一直在遵循有关将less-ui-ui-less导入到webpack项目中的各种教程。但是,只要我完成了不同的教程,我都会遇到相同的错误:

Module build failed:

module.exports = __webpack_public_path__ + "static/media/reset.b0bc6c14.less";
             ^
Unrecognised input
      in /Users/benflowers/Projects/candidate/candidate-ui-cra/node_modules/semantic-ui-less/definitions/globals/reset.less (line 1, column 15)
Run Code Online (Sandbox Code Playgroud)

我的webpack配置是否存在此问题-我弹出的create-react-appwebpack配置带有一些其他加载程序:

 {
        test: /\.less$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            { loader: 'css-loader' },
            { loader: 'less-loader' }
          ]
        }),
        exclude: [/[\/\\]node_modules[\/\\]semantic-ui-less[\/\\]/]
      },

      // for semantic-ui-less files:
      {
        test: /\.less$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            { loader: 'css-loader' },
            {
              loader: 'semantic-ui-less-module-loader',
              // you can also add specific options:
              options: { siteFolder: path.join(__dirname, 'src/site') }
            }
          ]
        }),
        include: …
Run Code Online (Sandbox Code Playgroud)

node.js semantic-ui webpack

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

Twitter api 回复推文

我正在尝试使用twitnpm 模块编写一个脚本来回复推文。然而,每当我通过in_reply_to_status_id_strin_reply_to_status_idthis 似乎被忽略。不知道是什么问题?

   T.get('search/tweets', { q: `golf since:2011-07-11`, count: 1 }).then(function (response) {

            const userName = response.data.statuses[0].user.screen_name;
            const tweetId = response.data.statuses[0].id_str;

            T.post('statuses/update', { in_reply_to_status_id_str: tweetId, status: `@${userName}, I like golf too` }, (err, data, response) => {
              resolve()
            })
          })

        })
Run Code Online (Sandbox Code Playgroud)

twitter node.js

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