This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Pipe { | |
/*** | |
* Writes all lines read from the reader. | |
* @param reader The source reader | |
* @param writer The destination writer | |
* @throws IOException | |
*/ | |
public static void pipe(Reader reader, Writer writer) throws IOException { | |
pipe(reader, writer, 4092); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Timing { | |
/** Return a tuple, where the first part is the milliseconds | |
* taken and the second part is the result of the block | |
* execution. */ | |
def time[R](block: =>R): (Long, R) = { | |
val start = System.currentTimeMillis | |
val result = block | |
(System.currentTimeMillis - start, result) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# cdextras.sh - contains functions to optimize traversals | |
# of the directory tree. | |
# | |
# Author: Michael Schmitz <schmmd@cs.washington.edu> | |
# Original Author of up and down: Steve Rowe <steve_rowe@users.sourceforge.net> | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* contravariance required so Empty can be used with Nodes ( Nothing <: T ) */ | |
class Tree[+T] | |
case object Empty extends Tree[Nothing] | |
case class Node[T](val elem: T, val left: Tree[T], val right: Tree[T]) extends Tree[T] | |
def inOrder[T](t: Tree[T]): List[T] = t match { | |
case Empty => Nil | |
case Node(e, left, right) => inOrder(left) ::: List(e) ::: inOrder(right) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make a TAB variable globally accessible | |
export TAB=`echo -e "\t"` | |
# sort compares binary data | |
export LC_ALL=C | |
# search for a file and open it with vim | |
function vimfind() { | |
if [ "$1" == "-s" ] | |
then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Compiler: maven | |
" Author: Michael Schmitz <michael@schmitztech.com> | |
" Last Change: 10/27/2011 | |
if exists("current_compiler") | |
finish | |
endif | |
let current_compiler = "maven" | |
set makeprg=mvn\ clean\ compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collection.mutable.SetLike | |
class Trie[A] extends Set[List[A]] { | |
type S = List[A] | |
type This = Trie[A] | |
sealed abstract class AbstractLayer | |
case class Layer(val map: Map[A, Layer]) extends AbstractLayer | |
case class Entry(val seq: S) extends AbstractLayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
* Bypass the Tika wrapper for PDFs and go directly to PDFBox since | |
* Apache Tika 0.8 has a bug when processing PDFs. This should be fixed | |
* when Apache Tika 0.9 is released. | |
* @param file | |
* @param fileType | |
* @param writer | |
* @throws IOException | |
* @throws ConversionException | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def svg2xml(svgString: String) = { | |
import org.apache.batik.dom.svg.SVGDOMImplementation; | |
import org.apache.batik.util.XMLResourceDescriptor | |
import org.apache.batik.dom.svg.SAXSVGDocumentFactory | |
val uri = SVGDOMImplementation.SVG_NAMESPACE_URI; | |
val doc = using(new java.io.StringReader(svgString)) { reader => | |
val parser = XMLResourceDescriptor.getXMLParserClassName(); | |
val f = new SAXSVGDocumentFactory(parser); |
OlderNewer