Skip to content

Instantly share code, notes, and snippets.

@manzke
manzke / Iterables.java
Created August 24, 2013 20:43
Example how an iterator can look like to use a BlockingQueue in java's foreach so this blocks if nothing in it.
public class Iterables {
public static <Type> Iterable<Type> iterable(final BlockingQueue<Type> queue){
return new Iterable<Type>() {
@Override
public Iterator<Type> iterator() {
return new Iterator<Type>() {
@Override
public boolean hasNext() {
return true;
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r