Skip to content

Instantly share code, notes, and snippets.

@mariusae
mariusae / importfmt
Created March 20, 2012 16:18
Format scala imports
#!/bin/bash
norm(){
awk '
/^import/ {
if(current) print current
current = $0
}
$0 !~ /^import/ {
current = current $0
package com.twitter.finagle.example.echo
package router
import com.twitter.finagle.Service
import com.twitter.finagle.builder.{ServerBuilder, ClientBuilder, Server}
import com.twitter.util.Future
import java.net.InetSocketAddress
object EchoServer {
/* $FreeBSD$ */
/* $Id: nfs4_subs.c,v 1.3 2004/05/14 18:37:20 marius Exp $ */
/*
* nfs4client/nfs4_vfsops.c
*
* Copyright (c) 2003, 2004 The Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@mariusae
mariusae / gist:1339915
Created November 4, 2011 17:24
Monitors for Finagle.
diff --git a/finagle/finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala b/finagle/finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala
index 1df9c58..32663db 100644
--- a/finagle/finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala
+++ b/finagle/finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala
@@ -56,7 +56,7 @@ import org.jboss.netty.channel.socket.nio._
import org.jboss.netty.handler.ssl._
import org.jboss.netty.handler.timeout.IdleStateHandler
-import com.twitter.util.{Future, Duration, Throw, Return}
+import com.twitter.util.{Future, Duration, Throw, Return, Monitor, NullMonitor}
#!/bin/sh
exec runscala -dfinagle/finagle-core -dfinagle/finagle-ostrich4 -dfinagle/finagle-http "$0" "$@"
!#
import java.net.InetSocketAddress
import com.twitter.finagle._
import com.twitter.finagle.builder._
import com.twitter.finagle.http._
import com.twitter.finagle.stats.OstrichStatsReceiver
import org.jboss.netty.handler.codec.http._
trait LogicLike[A, This[A] <: LogicLike[A, This]] {
def or(t: => This[A]): This[A]
def map[B](f: A => B): This[B]
def flatMap[B](f: A => This[B]): This[B]
def filter(p: A => Boolean): This[A]
def split: Option[(A, This[A])]
def |(t: => This[A]): This[A] = or(t)
def run(n: Int): List[A] =
if (n <= 0) Nil else
@mariusae
mariusae / git-project.el
Created April 4, 2011 19:08
support for project operations using git
(defvar git-grep-history '())
(defvar git-grep-command "git grep -nH")
(defvar git-tree-command "git rev-parse --show-cdup")
;; from http://www.emacswiki.org/emacs/ElispCookbook
(defun chomp (str)
"Chomp leading and tailing whitespace from STR."
(let ((s (if (symbolp str) (symbol-name str) str)))
(replace-regexp-in-string "\\(^[[:space:]\n]*\\|[[:space:]\n]*$\\)" "" s)))
package com.twitter.test;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.concurrent.Executors;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import com.twitter.finagle.*;
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.atomic.AtomicInteger
object Hotpotato {
private val nwaiters = new AtomicInteger(0)
private val executionQueue = new LinkedBlockingQueue[Function0[Unit]]
def serialized(f: => Unit) {
executionQueue offer { () => f }
#!/bin/sh
# $ sshm /fifo/directory host1 host2 host3...
# $ sshm -k /fifo/directory
# $ sshm /fifo/directory -c "ls"
# XXX - extra ssh flags
# set -- $(getopt kc "$@")