Skip to content

Instantly share code, notes, and snippets.

View collinvandyck's full-sized avatar
🏠
Working from home

Collin Van Dyck collinvandyck

🏠
Working from home
View GitHub Profile
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 is a test.
<T> T wrap(Callable<T> callback) throws Exception {
// do stuff
try {
return callback.call()
} finally {
// cleanup
}
}
// 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() {
/**
* 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));
}
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\"}");
class Foo {
Bar bar;
}
class Bar {
Collection<String> strings;
}
Is it possible to serialize Foo as:
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)
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"`
}
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)
}
})