Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <stdio.h>
#include <curl/curl.h>
using std::cout;
int main(void)
{
CURL *curl;
CURLcode res;
//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])
#!/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
#
"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
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,
@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]()
@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:3776855
Created September 24, 2012 16:28
Mult-SSH
tell application "iTerm"
activate
make new terminal
set Names to paragraphs of (read (choose file with prompt "File with hostnames") )
repeat with nextLine in Names
if length of nextLine is greater than 0 then
set cmd to "ssh ubuntu@" & nextLine
my open_tab(nextLine, cmd)
end if
@florianleibert
florianleibert / retry.bash
Created November 2, 2012 08:40
Retry logic in bash (for ssh / scp)
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
declare -r max=4
declare i=0
function wrap() {
local cmd=$1 ; shift
scala> case class Foo(val name : String)
defined class Foo
scala> case class Bar(override val name : String, val age : Int) extends Foo(name : String)
warning: there were 1 deprecation warnings; re-run with -deprecation for details
defined class Bar
scala> val a = Bar("foo", 1)
a: Bar = Foo(foo)