This file contains hidden or 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
/** | |
* Drop in replacement for the original {{ExtensibleReadability}} class, allowing us to add some of our own processing. (Like augmenting image URLs | |
* .) | |
*/ | |
class UltimateReadability(base: String) extends ExtensibleReadability with Logging { | |
val baseURI = URI.create(base) | |
val uriConversion = catching(classOf[IllegalArgumentException]) | |
override def cleanup(document: JSoupDocument) { |
This file contains hidden or 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
require 'formula' | |
class Dpkg <Formula | |
url 'http://ftp.debian.org/debian/pool/main/d/dpkg/dpkg_1.15.8.10.tar.bz2' | |
homepage 'http://en.wikipedia.org/wiki/Dpkg' | |
md5 'bce745c7083ace01da1df6cdcad35f9a' | |
def patches | |
#Fixes the PERL_LIBDIR | |
DATA |
This file contains hidden or 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
private Handler addResourceHandler(Handler handler, File directory, final String index) throws Exception { | |
final HandlerList list = new HandlerList(); | |
ContextHandler contextHandler = new ContextHandler("/resources"); | |
contextHandler.setHandler(createResourceHandler(directory)); | |
if (index != null) { | |
list.addHandler(new AbstractHandler() { | |
@Override | |
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { | |
if ("/".equals(target)) { | |
response.sendRedirect(index); |
This file contains hidden or 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
// Trait | |
trait EventLoggerComponent { | |
val eventProcessor: EventProcessor | |
trait EventLogger { | |
} | |
} |
This file contains hidden or 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
// SearchService #2 | |
class SearchService(implicit eventProcessor: EventProcessor) extends EventLogger | |
// EventLogger | |
trait EventLogger { | |
val eventProcessor: EventProcessor | |
} | |
// Context | |
class Context extends ... with ... with .. { |
This file contains hidden or 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 lzw { | |
trait Appendable[T] { | |
def append(value: T) | |
} | |
import scala.collection.generic._ | |
case class GrowingAppendable[T](growable: Growable[T]) extends Appendable[T] { | |
def append(value: T) { | |
growable += value |
This file contains hidden or 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
!!! | |
%html | |
%head | |
%title JMX Console | |
%script(src="js/ICanHaz.min.js" language="javascript") | |
%script(src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" language="javascript") | |
%script(src="js/json2.js" language="javascript") | |
%script(src="js/jolokia-min.js" language="javascript") | |
%script(src="js/jolokia-simple-min.js" language="javascript") | |
%link(href="css/style.css" rel="stylesheet" type="text/css") |
This file contains hidden or 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 math._ | |
object Jaro { | |
def distance(first: String, second: String) = { | |
val maxLength = max(first.length, second.length) | |
val maxDistance = (maxLength / 2) - 1 | |
var matches = 0 | |
var halfTranspositions = 0 | |
for (i <- 0 until first.length) { |
This file contains hidden or 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
/** | |
* A Traversable-alike abstraction of a traversable collection of tuples, without actually creating the tuples. | |
* I'd hope this would prevent me from polluting the heap with actual Tuple2 instances I never actually need. | |
*/ | |
trait Tuple2Traversable[+A, +B] { | |
def foreach[T](fn: (A, B) => T) | |
def map[T](fn: (A, B) => T): Traversable[T] = new Traversable[T] { | |
def foreach[U](f: (T) => U) { |
This file contains hidden or 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 Cocoa | |
enum Try<T>: Printable, DebugPrintable { | |
// Captures a successful outcome | |
case Success(@autoclosure() -> T) | |
// Captures a failure, including the root cause, which for now can be anything | |
case Failure(Any) | |
OlderNewer