Skip to content

Instantly share code, notes, and snippets.

Tobias Pfeiffer tgpfeiffer

Block or report user

Report or block tgpfeiffer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Dockerfile
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y python3-pip virtualenv
RUN virtualenv -p python3 /env
COPY /root
RUN . /env/bin/activate && \
cd /root && \
tgpfeiffer / scaml2html.scala
Created Apr 2, 2017
Convert a Docbook-structured Scaml file to single-page/multi-page HTML Raw
View scaml2html.scala
// convert the HAML/SCAML layout file to Docbook XML
val engine = new org.fusesource.scalate.TemplateEngine
val output = engine.layout("src/main/docbook/handbook.scaml")
val file = (target in Compile).value / "handbook.xml"
IO.write(file, output)
// create Docbook HTML
import scala.sys.process._
// TODO make this independent of local user's environment
val xsltool = "xsltproc"
tgpfeiffer / gist:f2512a3fa932b1434ad0
Created Dec 29, 2014
Add QR codes to each link
View gist:f2512a3fa932b1434ad0
<!-- paste this into the head element of an HTML file to append QR codes to each link -->
<script src=""></script>
<script src=""></script>
<script type="text/javascript">
$("a").each(function(idx, item){
var a = $(item);
var href=a.attr("href");
text: href,
tgpfeiffer / KafkaDoesntShutdown.scala
Created Jun 5, 2014
Kafka does not shutdown properly
View KafkaDoesntShutdown.scala
import org.apache.log4j.{LogManager, Level}
import org.apache.spark.SparkContext
import org.apache.spark.streaming.kafka.KafkaUtils
import org.apache.spark.streaming.{Seconds, StreamingContext}
import scala.concurrent._
object KafkaDoesntShutdown {
def main(args: Array[String]) {
// get all threads
tgpfeiffer / SparkExamplesMinimal.scala
Last active Aug 29, 2015
ClassNotFoundException when using Mesos
View SparkExamplesMinimal.scala
package spark
import org.apache.spark
import org.apache.spark.rdd.RDD
import org.apache.spark.SparkConf
object SparkExamplesMinimal {
def asInt(s: String): Option[Int] = {
try {
tgpfeiffer / HostAndPath.scala
Created Jun 6, 2013
A replacement for S.hostAndPath that takes into account Lift running on a host with a different port and SSL setting than the reverse proxy in front of it.
View HostAndPath.scala
def realHostAndPath(forceNoSsl: Boolean = false): String =
S.request.flatMap(req => (Box !! req.request).map(r => {
// X-Forwarded-Host contains host *and* port (if not standard)
r.header("X-Forwarded-Host") match {
case Full(hostAndPort) =>
r.scheme match {
case "http" if r.header("X-SSL").isDefined =>
"https://" + hostAndPort + S.contextPath
case "http" if r.header("X_FORWARDED_PROTO") == Full("https") && !forceNoSsl =>
// this (correct) URL is not liked well by Java applets, so we allow to override it
tgpfeiffer / V.scala
Created Apr 26, 2013
Helper object to work around S.?(...) working only within a valid session in Lift.
View V.scala
package code
import java.util.{ResourceBundle, Locale}
import xml.{Node, NodeSeq}
import net.liftweb.util.Helpers.tryo
import net.liftweb.http.{Templates, LiftRules, S}
import net.liftweb.common._
import net.liftweb.util.{BundleBuilder, Helpers, NamedPF, Props}
tgpfeiffer / MongoSequence.scala
Created Apr 1, 2013
A Lift helper class to generate sequential long values when using MongoDB with Record.
View MongoSequence.scala
package code.model
import net.liftweb.mongodb.BsonDSL._
import net.liftweb.record.field._
import net.liftweb.util.Helpers._
import net.liftweb.common._
import net.liftweb.mongodb.record._
import field._
import com.mongodb.{DBObject, BasicDBObject}
tgpfeiffer / japanese-full.tex
Last active Nov 21, 2018
How to typeset Japanese with advanced features in (Xe)LaTeX.
View japanese-full.tex
\usepackage{xltxtra, setspace}
%% fonts
% xeCJK options from <>:
View basics.feature
Feature: Basic Appearance
Scenario: Loading Front Page
Given I go to "http://localhost:8080"
Then I should see "WorldWide Conferencing"
Scenario: Login fails
Given I go to "http://localhost:8080/user_mgt/login"
When I fill in "username" with ""
And I fill in "password" with "xyz"
You can’t perform that action at this time.