Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Häberlein dhaeb

  • Universität Leipzig
  • Leipzig / Germany
View GitHub Profile
@dhaeb
dhaeb / FunctionCast.java
Created Sep 9, 2015
Java 8 - Function abstraction can be difficult. Any Ideas to make it better?
View FunctionCast.java
@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);
}
}
@dhaeb
dhaeb / init-spark.R
Created Oct 26, 2015
Load SparkR in normal R interpreter. Assumes that SparkR is globally installed.
View init-spark.R
library(SparkR)
sc <- sparkR.init(sparkPackages = "com.databricks:spark-csv_2.10:1.2.0")
sqlContext <- sparkRSQL.init(sc)
@dhaeb
dhaeb / scrape.groovy
Created Oct 8, 2017
Scraping Bundestagswahlergebnis Ost/West
View scrape.groovy
@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"
View <app>-<models>DatabaseExecutionContext.scala
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.
You can’t perform that action at this time.