Skip to content

Instantly share code, notes, and snippets.

@thomasjungblut
thomasjungblut / gist:11193991
Created April 22, 2014 20:56
Apache GPG PublicKey
pub 2048D/4F238505 2011-09-20
uid Thomas Jungblut <tjungblut@apache.org>
sig 3 4F238505 2011-09-20 Thomas Jungblut <tjungblut@apache.org>
pub 4096R/56623ACB 2014-04-22
uid Thomas Jungblut (apache account email pgp client blax) <tjungblut@apache.org>
sig 3 56623ACB 2014-04-22 Thomas Jungblut (apache account email pgp client blax) <tjungblut@apache.org>
sub 4096R/BDDECF6D 2014-04-22
sig 56623ACB 2014-04-22 Thomas Jungblut (apache account email pgp client blax) <tjungblut@apache.org>
/**
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
String pathBase = "/home/thomasjungblut/Downloads/";
PDDocument source = PDDocument.load(pathBase
+ "c1.pdf");
PDDocument lastPage = PDDocument.load(pathBase + "updated.pdf");
source.removePage(source.getNumberOfPages() - 1);
source.addPage( (PDPage) lastPage.getDocumentCatalog().getAllPages().get(0) );
source.save(pathBase + "c2_updated.pdf");
package de.jungblut.benchmark;
import java.util.ArrayList;
import com.google.caliper.Param;
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
public class PerfectSquaresBenchmark extends SimpleBenchmark {
@thomasjungblut
thomasjungblut / MathLibBenchmark.java
Created May 26, 2013 08:03
Math Library Benchmark: GPU vs. JBLAS vs. pure Java
package de.jungblut.benchmark;
import java.util.Random;
import com.google.caliper.Param;
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
import de.jungblut.math.DoubleMatrix;
import de.jungblut.math.cuda.JCUDAMatrixUtils;
@thomasjungblut
thomasjungblut / gist:5390600
Last active December 16, 2015 06:19
Inverted Index in less than 50 lines of code (and I was verbose!)
package de.jungblut.index
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.MultiMap
import scala.collection.mutable.HashMap
import scala.collection.mutable.Set
final class Index[T](nGramSize: Int) {
private val index = new HashMap[String, Set[T]] with MultiMap[String, T]
@thomasjungblut
thomasjungblut / gist:5318761
Created April 5, 2013 11:58
simple pos tagger using HMM with ~ 91.82% accuracy with a small trainingset of 70k words and 10k test words.
package de.jungblut.ml;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@thomasjungblut
thomasjungblut / gist:5146284
Last active November 6, 2016 10:39
Image Segmentation using mean shift clustering
package de.jungblut.ml;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@thomasjungblut
thomasjungblut / gist:5048046
Last active December 14, 2015 07:08
On-disk MergeSort Numbers and code
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.hadoop.io.IntWritable;
@thomasjungblut
thomasjungblut / gist:4639695
Created January 26, 2013 02:20
mat mult benchmark
package de.jungblut.benchmark;
import java.util.Random;
import com.google.caliper.Param;
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
public class MatMultBenchmark extends SimpleBenchmark {