Skip to content

Instantly share code, notes, and snippets.

View rodrigopr's full-sized avatar

Rodrigo Ribeiro rodrigopr

View GitHub Profile

Instead of using TurnJsonIntoHttp in each place:

class MyEndpoint extends Endpoint[HttpRequest, HttpResponse] {
  def route = {
    case Method.Get -> Root / "items" 
      List() ! TurnJsonIntoHttp[List[MyObj]]

    case Method.Get -> Root / "item" / Long(id) 
      GetDetail(id) ! TurnJsonIntoHttp[MyObj]
 
trait Facade[A] {
def decode(json: String): A
}
trait DecodeJson[A] {
def apply(json: String): A
}
implicit def toDecode[A](implicit facade: Facade[A]): DecodeJson[A] = {
new DecodeJson[A] {
# Description:
# This script receives pages in the formats
# /usr/bin/curl -d host="$HOSTALIAS$" -d output="$SERVICEOUTPUT$" -d description="$SERVICEDESC$" -d type=service -d notificationtype="$NOTIFICATIONTYPE$ -d state="$SERVICESTATE$" $CONTACTADDRESS1$
# /usr/bin/curl -d host="$HOSTNAME$" -d output="$HOSTOUTPUT$" -d type=host -d notificationtype="$NOTIFICATIONTYPE$" -d state="$HOSTSTATE$" $CONTACTADDRESS1$
#
# Based on a gist by oremj (https://gist.github.com/oremj/3702073)
#
# Configuration:
# HUBOT_NAGIOS_URL - https://<user>:<password>@nagios.example.com/cgi-bin/nagios3
#
# Description:
# This script receives pages in the formats
# /usr/bin/curl -d host="$HOSTALIAS$" -d output="$SERVICEOUTPUT$" -d description="$SERVICEDESC$" -d type=service -d state="$SERVICESTATE$" $CONTACTADDRESS1$
# /usr/bin/curl -d host="$HOSTNAME$" -d output="$HOSTOUTPUT$" -d type=host -d state="$HOSTSTATE$" $CONTACTADDRESS1$
#
# Author:
# oremj
irc = require('irc')
history = [] # previous labels
for i, word in enumerate(sentence):
featureset = get_features(word, history, sentence, i)
label = predict(featureset)
history.append(label)
... remain processing
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}
TopChildrenQuery that = (TopChildrenQuery) obj;
2013-06-25_14:35:37.51497 org.elasticsearch.transport.TransportSerializationException: Failed to deserialize exception response from stream
2013-06-25_14:35:37.51497 at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:171)
2013-06-25_14:35:37.51497 at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:125)
2013-06-25_14:35:37.51497 at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
2013-06-25_14:35:37.51497 at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
2013-06-25_14:35:37.51497 at org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:786)
2013-06-25_14:35:37.51497 at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:296)
2013-06-
/**
* This file is licensed to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.