Skip to content

Instantly share code, notes, and snippets.

View cb372's full-sized avatar

Chris Birchall cb372

View GitHub Profile
@cb372
cb372 / gist:2299692
Created April 4, 2012 08:29
Steps to build 64bit native libs for Hadoop 0.23.1

Hadoop 0.23.1 only comes with 32bit libs. Here is how to rebuild them for your platform.

Compile them

  1. Install gcc, autoconf, automake, libtool, zlib-devel packages

  2. Fix pom.xml to avoid classpath error when running javah:

    1. in hadoop-common-project/hadoop-common/pom.xml, find the dependency on hadoop-annotations
  3. change the scope of the dependency from provided to compile

@cb372
cb372 / MyTest.java
Created April 19, 2012 08:21
JUnit ErrorCollector example
package com.foo;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ErrorCollector;
import static org.hamcrest.Matchers.equalTo;
/**
* Created: 12/04/19 17:12
@cb372
cb372 / Server.scala
Created May 17, 2012 11:59
Redis server in Finagle
package com.twitter.finagle.redis
import com.twitter.finagle.Service
import com.twitter.finagle.builder.{ServerBuilder}
import java.net.InetSocketAddress
import protocol._
import collection.mutable.{ Map => MMap }
import java.util.concurrent.Executors
import com.twitter.util.{FuturePool, Future}
@cb372
cb372 / Foo.java
Created July 6, 2012 04:08
Grepping for Java casts
public class Foo {
public A a = new B();
public B b = (B) a;
}
class A {
}
class B extends A {
}
@cb372
cb372 / compile_error.java
Created July 16, 2012 15:05
Project Lombok bug 399 - @ExtensionMethod fails unless extensions class is in root package
package com.github.cb372.lombok; // <-- Note: not the root package
import lombok.experimental.ExtensionMethod;
@ExtensionMethod({ Extensions.class })
public class Main {
public static void main(String[] args) {
System.out.println("Hello, %s".format("World.")); // => "Hello, World."
}
}
def add1(arr: Array[Int], value: Int, n: Int): Array[Int] = {
n match {
case 0 => loop(arr, value, 0, 1, {_ < arr.length}, arr.length)
case m if m > 0 => loop(arr, value, 0, 1, {_ < arr.length}, m)
case m if m < 0 => loop(arr, value, arr.length - 1, -1, {_ > 0}, -m)
}
arr
}
private def loop(arr: Array[Int], value: Int, startIndex: Int, step: Int, continueCond: Int => Boolean, maxIncr: Int) {
@cb372
cb372 / GuavaServiceTest.java
Created August 15, 2012 00:36
Can I use Guava's AbstractExecutionThreadService for services that need to be interrupted?
package chris;
import com.google.common.util.concurrent.AbstractExecutionThreadService;
import com.google.common.util.concurrent.Service;
import org.junit.Test;
import java.util.concurrent.*;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@cb372
cb372 / index.html
Created November 25, 2012 05:09
Call for Speakers English translation
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Scala Conference in Japan 2013</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="日本で初のScala言語のカンファレンスが開催されることになりました。">
<meta name="author" content="日本 Scala ユーザーズグループ">
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="./bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
@cb372
cb372 / Fedis.md
Created December 15, 2012 07:43
Finagle Advent Calendar 2012 (http://connpass.com/event/1524/) - Day 15 - Fedis
@cb372
cb372 / MyFormatter.java
Created January 17, 2013 10:01
Example of using Flume HDFS sink with a custom SeqFileFormatter.
package com.foo;
import org.apache.flume.Context;
import org.apache.flume.Event;
import org.apache.flume.sink.hdfs.SeqFileFormatter;
import org.apache.flume.sink.hdfs.SeqFileFormatter.Record;
public class MyFormatter implements SeqFileFormatter {
@Override