Skip to content

Instantly share code, notes, and snippets.

@dcapwell
dcapwell / pom.xml
Created September 6, 2012 05:33
pom to use finagle
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ekaqu.finagle</groupId>
<artifactId>finagle-examples</artifactId>
<version>1.0</version>
@Override
public C get(final long timeout, final TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException {
try {
return super.get(timeout, unit);
} catch (TimeoutException e) {
Function<List<Optional<V>>, C> localCombiner = combiner;
if (localCombiner != null) {
// if the set took or not we don't care, if it doesn't take it means that it was set by the last future.
set(localCombiner.apply(values));
} else {
@dcapwell
dcapwell / gist:6907836
Created October 9, 2013 20:32
libs opened by bash on mac
$ sudo dtruss /bin/bash -c "echo hi" 2>&1 | egrep "^stat"
stat64("/AppleInternal\0", 0x7FFF584C0DD8, 0x0) = -1 Err#2
stat64("/Users/capwed\0", 0x7FFF584C1708, 0x0) = 0 0
stat64(".\0", 0x7FFF584C1678, 0x0) = 0 0
stat64("/usr/lib/libstdc++.6.dylib\0", 0x7FFF584C03E0, 0x7FFF584C12E0) = 0 0
stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x7FFF584C0610, 0x7FFF584C15E0) = 0 0
stat64("/usr/lib/libncurses.5.4.dylib\0", 0x7FFF584C03E0, 0x7FFF584C12E0) = 0 0
stat64("/usr/lib/libSystem.B.dylib\0", 0x7FFF584C03E0, 0x7FFF584C12E0) = 0 0
stat64("/usr/lib/system/libcache.dylib\0", 0x7FFF584BFFE0, 0x7FFF584C0EE0) = 0 0
stat64("/usr/lib/system/libcommonCrypto.dylib\0", 0x7FFF584BFFE0, 0x7FFF584C0EE0) = 0 0
docker:
pkgrepo.managed:
- humanname: Docker Inc. PPA
- name: deb http://get.docker.io/ubuntu docker main
- comments:
- "# Docker Inc. Repo"
- key_url: https://get.docker.io/gpg
# - require_in:
# - pkg: lxc-docker
pkg.installed:
include:
- java
jenkins:
pkgrepo.managed:
- humanname: Jenkins PPA
- name: deb http://pkg.jenkins-ci.org/debian binary/
- comments:
- "# Jenkins Repo"
- key_url: http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key
@dcapwell
dcapwell / init.pp
Last active December 30, 2015 02:09
centos64-2 : Error: Could not apply complete catalog: Found 1 dependency cycle:
centos64-2 : (Exec[wget zookeeper-3.4.5.tar.gz] => Exec[zookeeper_untar] => File[zookeeper-reown-build] => File[/opt/apache/zookeeper/zookeeper-current] => Class[Zookeeper::Setup_envo] => Class[Zookeeper::Install] => Exec[wget zookeeper-3.4.5.tar.gz])
centos64-2 : Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
@dcapwell
dcapwell / ScalaHibernate
Last active January 1, 2016 20:49
Dropwizard + Scala + JDBI + Validation
/**
* Removes boilerplate when working with Hibernate. History behind this:
*
* In scala, if you add an annotation to a var or case class param, it will put it on the field/getter/and setter.
*
* Many java annotations frameworks work with field OR getter/setter, but don't allow both
*
* Hibernate is an example of this. Some annotations are expected on fields but not methods, and vica-versa
*/
object ScalaHibernate {
Building heimdall...
panic: runtime error: makeslice: len out of range
goroutine 1 [running]:
runtime.panic(0x42cc0a0, 0x4675d00)
/usr/local/Cellar/go/1.2.1/libexec/src/pkg/runtime/panic.c:266 +0xb6
github.com/cloudius-systems/capstan/hypervisor/qemu.SetArgs(0xc2100375f0, 0xc210000298, 0x4, 0xc21001ef86, 0x8, ...)
/Users/dcapwell/src/github/gopath/src/github.com/cloudius-systems/capstan/hypervisor/qemu/qemu.go:147 +0x405
github.com/cloudius-systems/capstan/cmd.Build(0xc2100375f0, 0xc210000298, 0x4, 0xc21001ef86, 0x8, ...)
/Users/dcapwell/src/github/gopath/src/github.com/cloudius-systems/capstan/cmd/build.go:66 +0x7d1
/**
* Utility class for working with fibers
*/
public final class Fibers {
private Fibers() {
}
/**
* Defines work to run inside a fiber process.
*/
@dcapwell
dcapwell / RecursiveLocks.java
Last active August 29, 2015 14:09
Java recursion with sync blocks
package com.github.dcapwell.jmh.java;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OperationsPerInvocation;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;