Skip to content

Instantly share code, notes, and snippets.

@softprops
softprops / build.sbt
Created August 16, 2011 06:53
unfiltered jsonp example
libraryDependencies ++= Seq(
"net.databinder" %% "unfiltered-jetty" % "0.4.1",
"net.databinder" %% "unfiltered-filter" % "0.4.1",
"net.databinder" %% "unfiltered-json" % "0.4.1"
)
@retronym
retronym / ordering-then-by.scala
Created November 5, 2011 23:33
Ordering thenBy
class RichOrdering[A](oa: Ordering[A]) {
def thenBy[B: Ordering](f: A => B): Ordering[A] = new Ordering[A] {
def compare(a1: A, a2: A) = oa.compare(a1, a2) match {
case 0 => Ordering[B].compare(f(a1), f(a2))
case x => x
}
}
}
implicit def ToRichOrdering[A](oa: Ordering[A]): RichOrdering[A] = new RichOrdering(oa)
@avernet
avernet / Client.java
Last active January 3, 2016 07:29
Connecting to a service and providing a client-side certificate, client using HttpClient 4.2, and server running on Node.js
/*
* ====================================================================
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
@ayosec
ayosec / Unpack.scala
Created October 6, 2013 12:41
Extract files with Apache Commons Compress, from any archive
package test
import org.apache.commons.compress.archivers.ArchiveStreamFactory
import org.apache.commons.compress.archivers.ArchiveInputStream
import org.apache.commons.compress.archivers.ArchiveEntry
import org.apache.commons.compress.compressors.CompressorStreamFactory
import scala.util.Try
import scala.util.Success
import scala.util.Failure
import java.io.InputStream
@andershammar
andershammar / install-apache-zeppelin-on-amazon-emr.sh
Last active October 9, 2018 03:31
Bootstrap script for installing Apache Zeppelin on an Amazon EMR Cluster. Verfied on Amazon EMR release 4.x.
#!/bin/bash -ex
if [ "$(cat /mnt/var/lib/info/instance.json | jq -r .isMaster)" == "true" ]; then
# Install Git
sudo yum -y install git
# Install Maven
wget -P /tmp http://apache.mirrors.spacedump.net/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
sudo mkdir /opt/apache-maven
sudo tar -xvzf /tmp/apache-maven-3.3.3-bin.tar.gz -C /opt/apache-maven
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@joshfp
joshfp / 1.tabular.ipynb
Last active October 10, 2020 16:02
Fast.ai p1v1: class 4
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sritchie
sritchie / WholeFile.java
Created February 2, 2011 17:32
Hadoop input format for swallowing entire files.
package forma;
import forma.WholeFileInputFormat;
import cascading.scheme.Scheme;
import cascading.tap.Tap;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;
import cascading.tuple.TupleEntry;
import java.io.IOException;
import org.apache.hadoop.mapred.JobConf;
@tokestermw
tokestermw / visualizing_topic_models.py
Last active September 7, 2021 16:57
visualization topic models in four different ways
import json
import urlparse
from itertools import chain
flatten = chain.from_iterable
from nltk import word_tokenize
from gensim.corpora import Dictionary
from gensim.models.ldamodel import LdaModel
from gensim.models.tfidfmodel import TfidfModel
@mrflip
mrflip / tuning_storm_trident.asciidoc
Last active May 27, 2022 23:59
Notes on Storm+Trident tuning

Tuning Storm+Trident

Tuning a dataflow system is easy:

The First Rule of Dataflow Tuning:
* Ensure each stage is always ready to accept records, and
* Deliver each processed record promptly to its destination