Skip to content

Instantly share code, notes, and snippets.

@florianleibert
florianleibert / gist:3409897
Created August 21, 2012 00:35
pants broken
Florians-MacBook-Pro:commons florian$ ./pants idea tests/java/com/twitter/common:all-tests!
/usr/bin/python2.6
Installing virtualenv
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2087k 100 2087k 0 0 756k 0 0:00:02 0:00:02 --:--:-- 777k
Running virtualenv with interpreter /usr/bin/python2.6
New python executable in ./build-support/python/../../.python/bootstrap/bin/python2.6
Also creating executable in ./build-support/python/../../.python/bootstrap/bin/python
Installing distribute.............................................................................................................................................................................................done.
@florianleibert
florianleibert / gist:3406865
Created August 20, 2012 19:12
Dynamic protobuf builder
object Protobufs {
def newBuilder() : Builder = {
return new Builder()
}
class Builder {
private val desBuilder : DescriptorProtos.DescriptorProto.Builder = DescriptorProtos.DescriptorProto.newBuilder()
private val values = new mutable.HashMap[String, Any]()
case class BaseJob(@JsonProperty @BeanProperty val name: String,
@JsonProperty @BeanProperty val command: String,
@JsonProperty @BeanProperty val epsilon: Period = Minutes.minutes(5).toPeriod) {
def this(command: String, epsilon: Period) {
this("", command, epsilon)
}
}
case class ScheduleBasedJob(@JsonProperty @BeanProperty val schedule: String,
"properly parse expression" in {
val expected = (5L, DateTime.parse("2008-03-01T13:00:00Z"), new Period(Days.ONE))
val tuple = Iso8601ExpressionParser.parseExpression("R5/2008-03-01T13:00:00Z/P1D")
tuple must be_== (expected)
}
....
Error
'(5,2008-03-01T13:00:00.000Z,P1D)': anon is not equal to '(5,2008-03-01T13:00:00.000Z,P1D)': scala.Tuple3
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# 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
#
//Java Class
public class S3InputSupplier implements com.google.common.io.InputSupplier<java.io.InputStream>
//contents of the class
//Scala code
val mapper = new ObjectMapper()
val is = new S3InputSupplier(s3, metadataFile)
val json = CharStreams.toString(CharStreams.newReaderSupplier(is, Charsets.UTF_8));
mapper.readValue(json, classOf[CombinedGroup])
#include <iostream>
#include <stdio.h>
#include <curl/curl.h>
using std::cout;
int main(void)
{
CURL *curl;
CURLcode res;