This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Pair<U,T> { | |
| private final U left; | |
| private final T right; | |
| public static <U,T> Pair<U,T> of(U u, T t) { | |
| return new Pair<U, T>(u, t); | |
| } | |
| public Pair(U left, T right) { | |
| this.left = left; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This is a test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <T> T wrap(Callable<T> callback) throws Exception { | |
| // do stuff | |
| try { | |
| return callback.call() | |
| } finally { | |
| // cleanup | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // we want a return value here. | |
| int i = wrap(new Callable<Integer>() { | |
| public Integer call() { | |
| return 42; | |
| } | |
| }) | |
| // if we don't have a return value, we're forced to return null | |
| wrap(new Callable<Void>() { | |
| public Void call() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Provides for nice formatting of tabular data. | |
| */ | |
| public class TextTable { | |
| private final List<Integer> maxWidths = Lists.newArrayList(); // widths for each column | |
| private final List<List<String>> rows = Lists.newArrayList(); | |
| public TextTable addRow(Iterable<? extends Object> items) { | |
| return addRow(Lists.newArrayList(items)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.codehaus.jackson.map.ObjectMapper; | |
| import java.io.StringReader; | |
| public class Testing { | |
| private String foo; | |
| public static void main(String[] args) throws Exception { | |
| final ObjectMapper objectMapper = new ObjectMapper(); | |
| final StringReader reader = new StringReader("{\"foo\":\"bar\"}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo { | |
| Bar bar; | |
| } | |
| class Bar { | |
| Collection<String> strings; | |
| } | |
| Is it possible to serialize Foo as: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ERROR [2013-02-22 22:34:07,998] kafka.network.Processor: java.io.IOException: Connection reset by peer | |
| ! java.io.IOException: Connection reset by peer | |
| ! at sun.nio.ch.FileDispatcher.read0(Native Method) | |
| ! at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21) | |
| ! at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:198) | |
| ! at sun.nio.ch.IOUtil.read(IOUtil.java:171) | |
| ! at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:245) | |
| ! at kafka.utils.Utils$.read(Utils.scala:483) | |
| ! at kafka.network.BoundedByteBufferReceive.readFrom(BoundedByteBufferReceive.scala:53) | |
| ! at kafka.network.Processor.read(SocketServer.scala:298) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Event struct { | |
| OrganizationId string `json:"organizationId"` | |
| CreatedAt uint64 `json:"createdAt"` | |
| Level string `json:"level"` | |
| Status string `json:"status"` | |
| Source Source `json:"source"` | |
| Properties map[string]interface{} `json:"properties"` | |
| FingerprintFields []string `json:"fingerprintFields"` | |
| Tags []string `json:"tags"` | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func main() { | |
| flag.Parse() | |
| c := irc.SimpleClient("gesturebot") | |
| c.SSL = true | |
| c.AddHandler(irc.CONNECTED, | |
| func(conn *irc.Conn, line *irc.Line) { | |
| for _, channel := range channels { | |
| conn.Join(channel) | |
| } | |
| }) |