Skip to content

Instantly share code, notes, and snippets.

View dhaeb's full-sized avatar

Dan Häberlein dhaeb

  • Universität Leipzig
  • Leipzig / Germany
View GitHub Profile
package models
import javax.inject._
import akka.actor.ActorSystem
import play.api.libs.concurrent.CustomExecutionContext
/**
* This class is a pointer to an execution context configured to point to "database.dispatcher"
* in the "application.conf" file.
@dhaeb
dhaeb / scrape.groovy
Created October 8, 2017 12:55
Scraping Bundestagswahlergebnis Ost/West
@Grapes(
@Grab(group='net.sourceforge.htmlunit', module='htmlunit', version='2.27')
)
import com.gargoylesoftware.htmlunit.WebClient
import com.gargoylesoftware.htmlunit.html.HtmlPage
def isOsten = {bl ->
def ostenLabelBl = ["Sachsen", "Thüringen", "Sachsen-Anhalt", "Mecklenburg-Vorpommern", "Berlin", "Brandenburg"]
if (bl in ostenLabelBl)
"Osten"
@dhaeb
dhaeb / init-spark.R
Created October 26, 2015 12:43
Load SparkR in normal R interpreter. Assumes that SparkR is globally installed.
library(SparkR)
sc <- sparkR.init(sparkPackages = "com.databricks:spark-csv_2.10:1.2.0")
sqlContext <- sparkRSQL.init(sc)
@dhaeb
dhaeb / FunctionCast.java
Created September 9, 2015 12:35
Java 8 - Function abstraction can be difficult. Any Ideas to make it better?
@SuppressWarnings("unchecked") // It's a cast, I am responsible.
private void callToMethod(int i, int j) {
if(f instanceof BiFunction){
BiFunction<Integer, Integer, Boolean> callable = (BiFunction<Integer, Integer, Boolean>) f;
callable.apply(0, 1);
} else if(f instanceof BiConsumer){
BiConsumer<Integer, Integer> callable = (BiConsumer<Integer, Integer>) f;
callable.accept(i, j);
}
}